//----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- void CObjectTeleporter::TeleporterTouch( CBaseEntity *pOther ) { if ( IsDisabled() ) { return; } // if it's not a player, ignore if ( !pOther->IsPlayer() ) return; CTFPlayer *pPlayer = ToTFPlayer( pOther ); CTFPlayer *pBuilder = GetBuilder(); Assert( pBuilder ); if ( !pBuilder ) { return; } // if its not a teammate of the builder, notify the builder if ( pBuilder->GetTeamNumber() != pOther->GetTeamNumber() ) { // Don't teleport enemies return; } // is this an entrance and do we have an exit? if ( GetType() == OBJ_TELEPORTER_ENTRANCE ) { if ( ( m_iState == TELEPORTER_STATE_READY ) ) { // are we able to teleport? if ( pPlayer->HasTheFlag() ) { // If they have the flag, print a warning that you can't tele with the flag CSingleUserRecipientFilter filter( pPlayer ); TFGameRules()->SendHudNotification( filter, HUD_NOTIFY_NO_TELE_WITH_FLAG ); return; } // get the velocity of the player touching the teleporter if ( pPlayer->GetAbsVelocity().Length() < 5.0 ) { CObjectTeleporter *pDest = GetMatchingTeleporter(); if ( pDest ) { TeleporterSend( pPlayer ); } } } } }
//----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- void CObjectTeleporter::TeleporterTouch( CBaseEntity *pOther ) { if ( IsDisabled() ) { return; } // if it's not a player, ignore if ( !pOther->IsPlayer() ) return; CTFPlayer *pPlayer = ToTFPlayer( pOther ); int bTwoWayTeleporter = 0; CALL_ATTRIB_HOOK_INT_ON_OTHER( pPlayer, bTwoWayTeleporter, bidirectional_teleport ); // is this an entrance and do we have an exit? if ( GetObjectMode() == TELEPORTER_TYPE_ENTRANCE || bTwoWayTeleporter > 0 ) { if ( ( m_iState == TELEPORTER_STATE_READY ) ) { // are we able to teleport? if ( !PlayerCanBeTeleported( pPlayer ) ) { if ( pPlayer->HasTheFlag() ) { // If they have the flag, print a warning that you can't tele with the flag CSingleUserRecipientFilter filter( pPlayer ); TFGameRules()->SendHudNotification( filter, HUD_NOTIFY_NO_TELE_WITH_FLAG ); } return; } // get the velocity of the player touching the teleporter if ( pPlayer->GetAbsVelocity().Length() < 5.0 ) { CObjectTeleporter *pDest = GetMatchingTeleporter(); if ( pDest ) { TeleporterSend( pPlayer ); } } } } }
//---------------------------------------------------------------------------------------- // Purpose: moves the player //---------------------------------------------------------------------------------------- void CTFGameMovement::PlayerMove() { // call base class to do movement BaseClass::PlayerMove(); // handle player's interaction with water int nNewWaterLevel = m_pTFPlayer->GetWaterLevel(); if ( m_nOldWaterLevel != nNewWaterLevel ) { if ( WL_NotInWater == m_nOldWaterLevel ) { // The player has just entered the water. Determine if we should play a splash sound. bool bPlaySplash = false; Vector vecVelocity = m_pTFPlayer->GetAbsVelocity(); if ( vecVelocity.z <= -200.0f ) { // If the player has significant downward velocity, play a splash regardless of water depth. (e.g. Jumping hard into a puddle) bPlaySplash = true; } else { // Look at the water depth below the player. If it's significantly deep, play a splash to accompany the sinking that's about to happen. Vector vecStart = m_pTFPlayer->GetAbsOrigin(); Vector vecEnd = vecStart; vecEnd.z -= 20; // roughly thigh deep trace_t tr; // see if we hit anything solid a little bit below the player UTIL_TraceLine( vecStart, vecEnd, MASK_SOLID,m_pTFPlayer, COLLISION_GROUP_NONE, &tr ); if ( tr.fraction >= 1.0f ) { // some amount of water below the player, play a splash bPlaySplash = true; } } if ( bPlaySplash ) { m_pTFPlayer->EmitSound( "Physics.WaterSplash" ); } } } }