void CTriggerTeleportEnt::StartTouch(CBaseEntity *pOther) { if (pOther) { BaseClass::StartTouch(pOther); if (!pDestinationEnt) { if (m_target != NULL_STRING) pDestinationEnt = gEntList.FindEntityByName(NULL, m_target, NULL, pOther, pOther); else { DevWarning("CTriggerTeleport cannot teleport, pDestinationEnt and m_target are null!\n"); return; } } if (!PassesTriggerFilters(pOther)) return; if (pDestinationEnt)//ensuring not null { Vector tmp = pDestinationEnt->GetAbsOrigin(); // make origin adjustments. (origin in center, not at feet) tmp.z -= pOther->WorldAlignMins().z; pOther->Teleport(&tmp, m_bResetAngles ? &pDestinationEnt->GetAbsAngles() : NULL, m_bResetVelocity ? &vec3_origin : NULL); AfterTeleport(); } } }
//----------------------------------------------------------------------------- // Purpose: Touch function. Activates the trigger. // Input : pOther - The thing that touched us. //----------------------------------------------------------------------------- void CMOD_Dynamic_Difficulty_Modifier_Trigger::PositionTouch(CBaseEntity *pOther) { if (PassesTriggerFilters(pOther) && pOther->Classify() == CLASS_ASW_MARINE) { ActivatePositionTrigger( pOther ); } }
void CTriggerPhysicsTrap::Touch( CBaseEntity *pOther ) { if ( !PassesTriggerFilters(pOther) ) return; CBaseAnimating *pAnim = pOther->GetBaseAnimating(); if ( !pAnim ) return; pAnim->Dissolve( NULL, gpGlobals->curtime, false, m_nDissolveType ); }
//-------------------------------------------------------------------------------------------------------- void CTonemapTrigger::EndTouch( CBaseEntity *other ) { if ( !PassesTriggerFilters( other ) ) return; BaseClass::EndTouch( other ); CBasePlayer *player = ToBasePlayer( other ); if ( !player ) return; player->OnTonemapTriggerEndTouch( this ); }
//----------------------------------------------------------------------------- // Purpose: Collect any weapons inside our volume // Input : *pOther - //----------------------------------------------------------------------------- void CTriggerWeaponDissolve::StartTouch( CBaseEntity *pOther ) { BaseClass::StartTouch( pOther ); if ( PassesTriggerFilters( pOther ) == false ) return; CBaseCombatWeapon *pWeapon = dynamic_cast<CBaseCombatWeapon *>(pOther); if ( pWeapon == NULL ) return; AddWeapon( pWeapon ); }
//----------------------------------------------------------------------------- // Purpose: // Input : pOther - The thing that touched us. //----------------------------------------------------------------------------- void CFuncRespawnRoom::RespawnRoomTouch(CBaseEntity *pOther) { if ( PassesTriggerFilters(pOther) ) { if ( pOther->IsPlayer() && InSameTeam( pOther ) ) { // Players carrying the flag drop it if they try to run into a respawn room CTFPlayer *pPlayer = ToTFPlayer(pOther); if ( pPlayer->HasTheFlag() && !m_bAllowFlag ) { pPlayer->DropFlag(); } } } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CTriggerAreaCapture::AreaTouch( CBaseEntity *pOther ) { if ( !IsActive() ) return; if ( !PassesTriggerFilters(pOther) ) return; // Don't cap areas unless the round is running if ( !TeamplayGameRules()->PointsMayBeCaptured() ) return; Assert( m_iAreaIndex != -1 ); // dont touch for non-alive or non-players if( !pOther->IsPlayer() || !pOther->IsAlive() ) return; // make sure this point is in the round being played (if we're playing one) CTeamControlPointMaster *pMaster = g_hControlPointMasters.Count() ? g_hControlPointMasters[0] : NULL; if ( pMaster && m_hPoint ) { if ( !pMaster->IsInRound( m_hPoint ) ) { return; } } if ( m_hPoint ) { m_nOwningTeam = m_hPoint->GetOwner(); } CBaseMultiplayerPlayer *pPlayer = ToBaseMultiplayerPlayer(pOther); Assert( pPlayer ); if ( pPlayer->GetTeamNumber() != m_nOwningTeam ) { if ( m_TeamData[ pPlayer->GetTeamNumber() ].bCanCap ) { DisplayCapHintTo( pPlayer ); } } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CTriggerAreaCapture::StartTouch(CBaseEntity *pOther) { BaseClass::StartTouch( pOther ); if ( PassesTriggerFilters(pOther) && m_hPoint ) { m_nOwningTeam = m_hPoint->GetOwner(); IGameEvent *event = gameeventmanager->CreateEvent( "controlpoint_starttouch" ); if ( event ) { event->SetInt( "player", pOther->entindex() ); event->SetInt( "area", m_hPoint->GetPointIndex() ); gameeventmanager->FireEvent( event ); } // Call capture think immediately to make it update our area's player counts. // If we don't do this, the player can receive the above event telling him he's // in a zone, but the objective resource still thinks he's not. m_bStartTouch = true; CaptureThink(); m_bStartTouch = false; if ( m_bCapturing ) { CTeamControlPointMaster *pMaster = g_hControlPointMasters.Count() ? g_hControlPointMasters[0] : NULL; if ( pMaster ) { float flRate = pMaster->GetPartialCapturePointRate(); if ( flRate > 0.0f ) { CBaseMultiplayerPlayer *pPlayer = ToBaseMultiplayerPlayer(pOther); if ( pPlayer && pPlayer->GetTeamNumber() == m_nCapturingTeam ) { pPlayer->StartScoringEscortPoints( flRate ); } } } } } }
void CTriggerPhysicsTrap::Touch( CBaseEntity *pOther ) { if ( !PassesTriggerFilters(pOther) ) return; CBaseAnimating *pAnim = pOther->GetBaseAnimating(); if ( !pAnim ) return; #ifdef HL2_DLL // HACK: Upgrade the physcannon if ( FClassnameIs( pAnim, "weapon_physcannon" ) ) { PhysCannonBeginUpgrade( pAnim ); return; } #endif pAnim->Dissolve( NULL, gpGlobals->curtime, false, m_nDissolveType ); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CTriggerAreaCapture::EndTouch(CBaseEntity *pOther) { if ( PassesTriggerFilters(pOther) && m_hPoint ) { IGameEvent *event = gameeventmanager->CreateEvent( "controlpoint_endtouch" ); if ( event ) { event->SetInt( "player", pOther->entindex() ); event->SetInt( "area", m_hPoint->GetPointIndex() ); gameeventmanager->FireEvent( event ); } // incase we leave but the area keeps capturing CBaseMultiplayerPlayer *pPlayer = ToBaseMultiplayerPlayer(pOther); if ( pPlayer ) { pPlayer->StopScoringEscortPoints(); } } BaseClass::EndTouch( pOther ); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CTriggerWateryDeath::Touch( CBaseEntity *pOther ) { if (!PassesTriggerFilters(pOther)) return; // Find our index EHANDLE hOther; hOther = pOther; int iIndex = m_hTouchingEntities.Find( hOther ); if ( iIndex == m_hTouchingEntities.InvalidIndex() ) return; float flKillTime = m_flEntityKillTimes[iIndex]; // Time to kill it? if ( gpGlobals->curtime > flKillTime ) { //EmitSound( filter, entindex(), "WateryDeath.Bite", &pOther->GetAbsOrigin() ); // Kill it if ( pOther->IsPlayer() ) { m_flPainValue = min( m_flPainValue + WD_PAINVALUE_STEP, WD_MAX_DAMAGE ); } else { m_flPainValue = WD_MAX_DAMAGE; } // Use DMG_GENERIC & make the target inflict the damage on himself. // This ensures that if the target is the player, the damage isn't modified by skill CTakeDamageInfo info = CTakeDamageInfo( pOther, pOther, m_flPainValue, DMG_GENERIC ); GuessDamageForce( &info, (pOther->GetAbsOrigin() - GetAbsOrigin()), pOther->GetAbsOrigin() ); pOther->TakeDamage( info ); m_flEntityKillTimes[iIndex] = gpGlobals->curtime + WD_KILLTIME_NEXT_BITE; } }
//----------------------------------------------------------------------------- // Drops all weapons, marks the character as not being able to pick up weapons //----------------------------------------------------------------------------- void CTriggerWeaponStrip::StartTouch(CBaseEntity *pOther) { BaseClass::StartTouch( pOther ); if ( PassesTriggerFilters(pOther) == false ) return; CBaseCombatCharacter *pCharacter = pOther->MyCombatCharacterPointer(); if ( m_bKillWeapons ) { for ( int i = 0 ; i < pCharacter->WeaponCount(); ++i ) { CBaseCombatWeapon *pWeapon = pCharacter->GetWeapon( i ); if ( !pWeapon ) continue; pCharacter->Weapon_Drop( pWeapon ); UTIL_Remove( pWeapon ); } return; } // Strip the player of his weapons if ( pCharacter && !pCharacter->IsEFlagSet( EFL_NO_WEAPON_PICKUP ) ) { CBaseCombatWeapon *pBugbait = pCharacter->Weapon_OwnsThisType( "weapon_bugbait" ); if ( pBugbait ) { pCharacter->Weapon_Drop( pBugbait ); UTIL_Remove( pBugbait ); } pCharacter->Weapon_DropAll( true ); pCharacter->AddEFlags( EFL_NO_WEAPON_PICKUP ); } }
//----------------------------------------------------------------------------- // Purpose: Upon touching a non-filtered entity, CTriggerPortal teleports them to it's // remote portal location. // Input : *pOther - //----------------------------------------------------------------------------- void CTriggerPortal::Touch( CBaseEntity *pOther ) { // If we are enabled, and allowed to react to the touched entity if ( PassesTriggerFilters(pOther) ) { // If we somehow lost our pointer to the remote portal, get a new one if ( m_hRemotePortal == NULL ) { Disable(); return; } bool bDebug = portal_debug.GetBool(); if ( bDebug ) { Msg("%s TOUCH: for %s\n", GetDebugName(), pOther->GetDebugName() ); } // Don't touch entities that came through us and haven't left us yet. EHANDLE hHandle; hHandle = pOther; if ( m_hDisabledForEntities.Find(hHandle) != m_hDisabledForEntities.InvalidIndex() ) { Msg(" IGNORED\n", GetDebugName(), pOther->GetDebugName() ); return; } Pickup_ForcePlayerToDropThisObject( pOther ); // de-ground this entity pOther->SetGroundEntity( NULL ); // Build a this --> remote transformation VMatrix matMyModelToWorld, matMyInverse; matMyModelToWorld = this->EntityToWorldTransform(); MatrixInverseGeneral ( matMyModelToWorld, matMyInverse ); // Teleport our object VMatrix matRemotePortalTransform = m_hRemotePortal->EntityToWorldTransform(); Vector ptNewOrigin, vLook, vRight, vUp, vNewLook; pOther->GetVectors( &vLook, &vRight, &vUp ); // Move origin ptNewOrigin = matMyInverse * pOther->GetAbsOrigin(); ptNewOrigin = matRemotePortalTransform * Vector( ptNewOrigin.x, -ptNewOrigin.y, ptNewOrigin.z ); // Re-aim camera vNewLook = matMyInverse.ApplyRotation( vLook ); vNewLook = matRemotePortalTransform.ApplyRotation( Vector( -vNewLook.x, -vNewLook.y, vNewLook.z ) ); // Reorient the physics Vector vVelocity, vOldVelocity; pOther->GetVelocity( &vOldVelocity ); vVelocity = matMyInverse.ApplyRotation( vOldVelocity ); vVelocity = matRemotePortalTransform.ApplyRotation( Vector( -vVelocity.x, -vVelocity.y, vVelocity.z ) ); QAngle qNewAngles; VectorAngles( vNewLook, qNewAngles ); if ( pOther->IsPlayer() ) { ((CBasePlayer*)pOther)->SnapEyeAngles(qNewAngles); } Vector vecOldPos = pOther->WorldSpaceCenter(); if ( bDebug ) { NDebugOverlay::Box( pOther->GetAbsOrigin(), pOther->WorldAlignMins(), pOther->WorldAlignMaxs(), 255,0,0, 8, 20 ); NDebugOverlay::Axis( pOther->GetAbsOrigin(), pOther->GetAbsAngles(), 10.0f, true, 50 ); } // place player at the new destination CTriggerPortal *pPortal = m_hRemotePortal.Get(); pPortal->DisableForIncomingEntity( pOther ); pOther->Teleport( &ptNewOrigin, &qNewAngles, &vVelocity ); if ( bDebug ) { NDebugOverlay::Box( pOther->GetAbsOrigin(), pOther->WorldAlignMins(), pOther->WorldAlignMaxs(), 0,255,0, 8, 20 ); NDebugOverlay::Line( vecOldPos, pOther->WorldSpaceCenter(), 0,255,0, true, 20 ); NDebugOverlay::Axis( pOther->GetAbsOrigin(), pOther->GetAbsAngles(), 10.0f, true, 50 ); Msg("%s TELEPORTED: %s\n", GetDebugName(), pOther->GetDebugName() ); } // test collision on the new teleport location Vector vMin, vMax, vCenter; pOther->CollisionProp()->WorldSpaceAABB( &vMin, &vMax ); vCenter = (vMin + vMax) * 0.5f; vMin -= vCenter; vMax -= vCenter; Vector vStart, vEnd; vStart = ptNewOrigin; vEnd = ptNewOrigin; Ray_t ray; ray.Init( vStart, vEnd, vMin, vMax ); trace_t tr; pPortal->TestCollision( ray, pOther->PhysicsSolidMaskForEntity(), tr ); // Teleportation caused us to hit something, deal with it. if ( tr.DidHit() ) { } } }
//----------------------------------------------------------------------------- // Purpose: Called when an entity starts touching us. // Input : pOther - The entity that is touching us. //----------------------------------------------------------------------------- void CTriggerPortalCleanser::StartTouch( CBaseEntity *pOther ) { if ( PassesTriggerFilters(pOther) ) { EHANDLE hOther; hOther = pOther; bool bAdded = false; if ( m_hTouchingEntities.Find( hOther ) == m_hTouchingEntities.InvalidIndex() ) { m_hTouchingEntities.AddToTail( hOther ); bAdded = true; } m_OnStartTouch.FireOutput(pOther, this); if ( bAdded && ( m_hTouchingEntities.Count() == 1 ) ) { // First entity to touch us that passes our filters m_OnStartTouchAll.FireOutput( pOther, this ); } if ( portal_cleanser_debug.GetBool() ) { Msg("%s START-TOUCH: for %s\n", GetDebugName(), pOther->GetDebugName() ); } if ( !pOther->IsPlayer() ) { CBaseAnimating *pAnim = pOther->GetBaseAnimating(); if ( !pAnim ) return; // Can't dissolve twice. if ( pAnim->IsDissolving() ) return; // Force player to drop this object. Pickup_ForcePlayerToDropThisObject( pOther ); if ( !FClassnameIs( pOther, "prop_physics" ) ) { if ( FClassnameIs( pOther, "simple_physics_prop" ) || FClassnameIs( pOther, "simple_physics_brush" ) ) { // simple_physics_prop ? return; } if ( portal_cleanser_debug.GetBool() ) { Msg("%s IS CREATING: simple_physics_prop\n", GetDebugName()); } // Other object needs to be replaced by simple_physics_prop. pOther = CreateSimplePhysicsObject( pOther ); // Dissolve the entity. CBaseAnimating *pAnim = pOther->GetBaseAnimating(); pAnim->Dissolve( NULL, gpGlobals->curtime, false, ENTITY_DISSOLVE_NORMAL ); if ( portal_cleanser_debug.GetBool() ) { Msg("%s DISSOLVE SIMPLE PHYSICS: %s\n", GetDebugName(), pOther->GetDebugName() ); } // Outputs m_hActivator = pOther; m_OnDissolve.FireOutput(m_hActivator, this); return; } IPhysicsObject *pPhysics = pOther->VPhysicsGetObject(); if ( pPhysics ) { // Dissolve the entity. pAnim->Dissolve( NULL, gpGlobals->curtime, false, ENTITY_DISSOLVE_NORMAL ); if ( portal_cleanser_debug.GetBool() ) { Msg("%s DISSOLVE PHYSICS: %s\n", GetDebugName(), pOther->GetDebugName() ); } // Turn off the gravity for this object. pPhysics->EnableGravity( false ); // Slow down and push up the object. Vector vecVelocity, vecAngular; pPhysics->GetVelocity( &vecVelocity, &vecAngular ); vecVelocity /= 2; vecAngular /= 2; vecVelocity.z += 10; pPhysics->SetVelocity( &vecVelocity, &vecAngular ); // Outputs m_hActivator = pOther; m_OnDissolve.FireOutput(m_hActivator, this); const char *pModelName = STRING( pOther->GetModelName() ); if ( Q_strstr( pModelName, "models/props/metal_box.mdl" ) ) { m_OnDissolveBox.FireOutput(m_hActivator, this); } } } } }