// This function is in replacement of "Touch" since we are using the VPhysics // and that does not stimulate "Touch" responses if we collide with the world void CGEGrenade::VPhysicsCollision( int index, gamevcollisionevent_t *pEvent ) { // Call the baseclass first so we don't interfere with the normal running of things BaseClass::VPhysicsCollision( index, pEvent ); // Grab what we hit CBaseEntity *pOther = pEvent->pEntities[!index]; if ( pOther->IsWorld() ) { m_bHitSomething = true; surfacedata_t *phit = physprops->GetSurfaceData( pEvent->surfaceProps[!index] ); if ( phit->game.material == 'X' ) { // Game Over, we hit the sky box, remove the rocket from the world (no explosion) PhysCallbackRemove( GetNetworkable() ); return; } } }
void CRagdollBoogie::DecrementSuppressionCount(CBaseEntity *pTarget) { // Look for other boogies on the ragdoll + kill them CBaseEntity *pNext; for (CBaseEntity *pChild = pTarget->FirstMoveChild(); pChild; pChild = pNext) { pNext = pChild->NextMovePeer(); CRagdollBoogie *pBoogie = dynamic_cast<CRagdollBoogie*>(pChild); if (!pBoogie) continue; if (--pBoogie->m_nSuppressionCount <= 0) { pBoogie->m_nSuppressionCount = 0; float dt = gpGlobals->curtime - pBoogie->m_flStartTime; if (dt >= pBoogie->m_flBoogieLength) { PhysCallbackRemove(pBoogie->NetworkProp()); } } } }
void CGETKnife::VPhysicsCollision( int index, gamevcollisionevent_t *pEvent ) { // Call the baseclass first so we don't interfere with the normal running of things BaseClass::VPhysicsCollision( index, pEvent ); // Grab what we hit CBaseEntity *pOther = pEvent->pEntities[!index]; if ( !pOther->IsSolid() || pOther->IsSolidFlagSet(FSOLID_VOLUME_CONTENTS) ) return; if ( !PassServerEntityFilter( this, pOther) ) return; if ( !g_pGameRules->ShouldCollide( GetCollisionGroup(), pOther->GetCollisionGroup() ) ) return; trace_t tr; CollisionEventToTrace( index, pEvent, tr ); Vector vecAiming = pEvent->preVelocity[index]; VectorNormalize( vecAiming ); if ( pOther->m_takedamage != DAMAGE_NO && (pOther->IsPlayer() || pOther->IsNPC()) ) { ClearMultiDamage(); CTakeDamageInfo dmgInfo( this, GetOwnerEntity(), GetDamage(), DMG_SLASH | DMG_NEVERGIB ); CalculateMeleeDamageForce( &dmgInfo, vecAiming, tr.endpos, TKNIFE_FORCE_SCALE ); dmgInfo.SetDamagePosition( tr.endpos ); if ( this->GetOwnerEntity() && this->GetOwnerEntity()->IsPlayer() ) { CBasePlayer *pPlayer = ToBasePlayer( this->GetOwnerEntity() ); dmgInfo.SetWeapon( pPlayer->Weapon_OwnsThisType( "weapon_throwing_knife" ) ); } pOther->DispatchTraceAttack( dmgInfo, vecAiming, &tr ); ApplyMultiDamage(); PhysCallbackSetVelocity( pEvent->pObjects[index], vec3_origin ); SetTouch( NULL ); SetThink( NULL ); PhysCallbackRemove( this->NetworkProp() ); } else { if ( pOther->IsWorld() ) { // We hit the world, we have to check if this is sky trace_t tr2; Vector origin; pEvent->pInternalData->GetContactPoint( origin ); UTIL_TraceLine( origin, origin + (vecAiming * 4), MASK_SOLID, this, COLLISION_GROUP_NONE, &tr2 ); if ( tr2.surface.flags & SURF_SKY ) { // We hit sky, remove us NOW SetTouch( NULL ); SetThink( NULL ); PhysCallbackRemove( this->NetworkProp() ); return; } } m_bInAir = false; CollisionProp()->UseTriggerBounds( true, 24 ); g_PostSimulationQueue.QueueCall( this, &CBaseEntity::SetOwnerEntity, (CBaseEntity*)NULL ); // const CBaseEntity *host = te->GetSuppressHost(); // te->SetSuppressHost( NULL ); // StopParticleEffects( this ); // te->SetSuppressHost( (CBaseEntity*)host ); SetTouch( &CGETKnife::PickupTouch ); SetThink( &CGETKnife::RemoveThink ); g_PostSimulationQueue.QueueCall(this, &CBaseEntity::SetCollisionGroup, COLLISION_GROUP_DROPPEDWEAPON); SetNextThink( gpGlobals->curtime + 10.0f ); } }
void CGETKnife::DamageTouch( CBaseEntity *pOther ) { if ( !pOther->IsSolid() || pOther->IsSolidFlagSet(FSOLID_VOLUME_CONTENTS) ) return; if ( !PassServerEntityFilter( this, pOther) ) return; if ( !g_pGameRules->ShouldCollide( GetCollisionGroup(), pOther->GetCollisionGroup() ) ) return; if (!pOther->IsPlayer() && !pOther->IsNPC()) return; Vector vecAiming; VPhysicsGetObject()->GetVelocity( &vecAiming, NULL ); VectorNormalize( vecAiming ); trace_t tr; UTIL_TraceLine( GetAbsOrigin(), GetAbsOrigin() + (vecAiming * 24), MASK_SHOT, this, COLLISION_GROUP_NONE, &tr ); // We didn't hit the player again with our damage cast. Do a cast to the player's center to get a proper hit. if (tr.m_pEnt != pOther) { Vector TargetVec = pOther->GetAbsOrigin(); TargetVec.z = min(GetAbsOrigin().z, pOther->EyePosition().z); //Make sure we don't cast over their head. UTIL_TraceLine(GetAbsOrigin(), pOther->GetAbsOrigin(), MASK_SHOT, this, COLLISION_GROUP_NONE, &tr); } // TEMPORARY DEBUGGING PURPOSES // DebugDrawLine( tr.startpos, tr.endpos, 0, 255, 0, true, 5.0f ); // debugoverlay->AddSweptBoxOverlay( tr.startpos, tr.endpos, CollisionProp()->OBBMins(), CollisionProp()->OBBMaxs(), GetAbsAngles(), 0, 0, 255, 100, 5.0f ); // END TEMPORARY // If our target can take damage and the trace actually hit our target if ( pOther->m_takedamage != DAMAGE_NO && tr.fraction < 1.0f && tr.m_pEnt == pOther ) { ClearMultiDamage(); CTakeDamageInfo dmgInfo( this, GetOwnerEntity(), GetDamage(), DMG_SLASH | DMG_NEVERGIB ); CalculateMeleeDamageForce( &dmgInfo, vecAiming, tr.endpos, TKNIFE_FORCE_SCALE ); dmgInfo.SetDamagePosition( tr.endpos ); if ( this->GetOwnerEntity() && this->GetOwnerEntity()->IsPlayer() ) { CBasePlayer *pPlayer = ToBasePlayer( this->GetOwnerEntity() ); dmgInfo.SetWeapon( pPlayer->Weapon_OwnsThisType( "weapon_knife_throwing" ) ); } pOther->DispatchTraceAttack( dmgInfo, vecAiming, &tr ); ApplyMultiDamage(); SetAbsVelocity( vec3_origin ); SetTouch( NULL ); SetThink( NULL ); PhysCallbackRemove( this->NetworkProp() ); } }