//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CTriggerAreaCapture::BreakCapture( bool bNotEnoughPlayers ) { if( m_bCapturing ) { // Remap team to get first game team = 1 switch ( m_nCapturingTeam - FIRST_GAME_TEAM+1 ) { case 1: m_OnBreakTeam1.FireOutput( this, this ); break; case 2: m_OnBreakTeam2.FireOutput( this, this ); break; default: Assert(0); break; } m_BreakOutput.FireOutput(this,this); m_bCapturing = false; m_nCapturingTeam = TEAM_UNASSIGNED; UpdateCappingTeam( TEAM_UNASSIGNED ); if ( bNotEnoughPlayers ) { IncrementCapAttemptNumber(); } SetCapTimeRemaining( 0 ); if( m_hPoint ) { m_hPoint->CaptureEnd(); } m_OnNumCappersChanged.Set( 0, this, this ); // tell all touching players to stop racking up capture points CTeam *pTeam = GetGlobalTeam( m_nCapturingTeam ); if ( pTeam ) { for ( int i=0;i<pTeam->GetNumPlayers();i++ ) { CBaseMultiplayerPlayer *pPlayer = ToBaseMultiplayerPlayer( pTeam->GetPlayer(i) ); if ( pPlayer && IsTouching( pPlayer ) ) { pPlayer->StopScoringEscortPoints(); } } } } }
//----------------------------------------------------------------------------- // Purpose: Proxy that only sends data to team members // Input : *pStruct - // *pData - // *pOut - // objectID - // Output : Returns true on success, false on failure. //----------------------------------------------------------------------------- void* SendProxy_OnlyToTeam( const SendProp *pProp, const void *pStruct, const void *pVarData, CSendProxyRecipients *pRecipients, int objectID ) { CBaseEntity *pEntity = (CBaseEntity*)pStruct; if ( pEntity ) { CTeam *pTeam = pEntity->GetTeam(); if ( pTeam ) { pRecipients->ClearAllRecipients(); for ( int i=0; i < pTeam->GetNumPlayers(); i++ ) pRecipients->SetRecipient( pTeam->GetPlayer( i )->GetClientIndex() ); return (void*)pVarData; } } return NULL; }
void CSDKPlayer::State_Enter_OBSERVER_MODE() { // Always start a spectator session in roaming mode m_iObserverLastMode = OBS_MODE_ROAMING; if( m_hObserverTarget == NULL ) { // find a new observer target CheckObserverSettings(); } // Change our observer target to the nearest teammate CTeam *pTeam = GetGlobalTeam( GetTeamNumber() ); CBasePlayer *pPlayer; Vector localOrigin = GetAbsOrigin(); Vector targetOrigin; float flMinDist = FLT_MAX; float flDist; for ( int i=0;i<pTeam->GetNumPlayers();i++ ) { pPlayer = pTeam->GetPlayer(i); if ( !pPlayer ) continue; if ( !IsValidObserverTarget(pPlayer) ) continue; targetOrigin = pPlayer->GetAbsOrigin(); flDist = ( targetOrigin - localOrigin ).Length(); if ( flDist < flMinDist ) { m_hObserverTarget.Set( pPlayer ); flMinDist = flDist; } } StartObserverMode( m_iObserverLastMode ); PhysObjectSleep(); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CTriggerAreaCapture::BreakCapture( bool bNotEnoughPlayers ) { if( m_bCapturing ) { // Remap team to get first game team = 1 switch ( m_nCapturingTeam - FIRST_GAME_TEAM+1 ) { case 1: m_OnBreakTeam1.FireOutput( this, this ); break; case 2: m_OnBreakTeam2.FireOutput( this, this ); break; default: Assert(0); break; } m_BreakOutput.FireOutput(this,this); m_bCapturing = false; m_nCapturingTeam = TEAM_UNASSIGNED; UpdateCappingTeam( TEAM_UNASSIGNED ); if ( bNotEnoughPlayers ) { IncrementCapAttemptNumber(); } SetCapTimeRemaining( 0 ); if( m_hPoint ) { m_hPoint->CaptureEnd(); // The point reverted to it's previous owner. IGameEvent *event = gameeventmanager->CreateEvent( "teamplay_capture_broken" ); if ( event ) { event->SetInt( "cp", m_hPoint->GetPointIndex() ); event->SetString( "cpname", m_hPoint->GetName() ); event->SetFloat( "time_remaining", m_fTimeRemaining ); gameeventmanager->FireEvent( event ); } } SetNumCappers( 0 ); // tell all touching players to stop racking up capture points CTeam *pTeam = GetGlobalTeam( m_nCapturingTeam ); if ( pTeam ) { for ( int i=0;i<pTeam->GetNumPlayers();i++ ) { CBaseMultiplayerPlayer *pPlayer = ToBaseMultiplayerPlayer( pTeam->GetPlayer(i) ); if ( pPlayer && IsTouching( pPlayer ) ) { pPlayer->StopScoringEscortPoints(); } } } } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CTriggerAreaCapture::EndCapture( int team ) { IncrementCapAttemptNumber(); // Remap team to get first game team = 1 switch ( team - FIRST_GAME_TEAM+1 ) { case 1: m_OnCapTeam1.FireOutput( this, this ); break; case 2: m_OnCapTeam2.FireOutput( this, this ); break; default: Assert(0); break; } m_CapOutput.FireOutput(this,this); int numcappers = 0; int cappingplayers[MAX_AREA_CAPPERS]; GetNumCappingPlayers( team, numcappers, cappingplayers ); // Handle this before we assign the new team as the owner of this area HandleRespawnTimeAdjustments( m_nOwningTeam, team ); m_nOwningTeam = team; m_bCapturing = false; m_nCapturingTeam = TEAM_UNASSIGNED; SetCapTimeRemaining( 0 ); //there may have been more than one capper, but only report this one. //he hasn't gotten points yet, and his name will go in the cap string if its needed //first capper gets name sent and points given by flag. //other cappers get points manually above, no name in message //send the player in the cap string if( m_hPoint ) { OnEndCapture( m_nOwningTeam ); UpdateOwningTeam(); m_hPoint->SetOwner( m_nOwningTeam, true, numcappers, cappingplayers ); m_hPoint->CaptureEnd(); } SetNumCappers( 0 ); // tell all touching players to stop racking up capture points CTeam *pTeam = GetGlobalTeam( m_nCapturingTeam ); if ( pTeam ) { for ( int i=0;i<pTeam->GetNumPlayers();i++ ) { CBaseMultiplayerPlayer *pPlayer = ToBaseMultiplayerPlayer( pTeam->GetPlayer(i) ); if ( pPlayer && IsTouching( pPlayer ) ) { pPlayer->StopScoringEscortPoints(); } } } // play any special cap sounds if ( TeamplayRoundBasedRules() ) { TeamplayRoundBasedRules()->PlaySpecialCapSounds( m_nOwningTeam ); } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CTriggerAreaCapture::StartCapture( int team, int capmode ) { // Remap team to get first game team = 1 switch ( team - FIRST_GAME_TEAM+1 ) { case 1: m_OnStartTeam1.FireOutput( this, this ); break; case 2: m_OnStartTeam2.FireOutput( this, this ); break; default: Assert(0); break; } m_StartOutput.FireOutput(this,this); m_nCapturingTeam = team; UpdateNumPlayers(); if ( CaptureModeScalesWithPlayers() ) { SetCapTimeRemaining( ((m_flCapTime * 2) * m_TeamData[team].iNumRequiredToCap) ); } else { SetCapTimeRemaining( m_flCapTime ); } m_bCapturing = true; m_bBlocked = false; m_iCapMode = capmode; m_flLastReductionTime = gpGlobals->curtime; UpdateCappingTeam( m_nCapturingTeam ); UpdateBlocked(); if( m_hPoint ) { int numcappers = 0; int cappingplayers[MAX_AREA_CAPPERS]; GetNumCappingPlayers( m_nCapturingTeam, numcappers, cappingplayers ); m_hPoint->CaptureStart( m_nCapturingTeam, numcappers, cappingplayers ); } // tell all touching players to start racking up capture points CTeamControlPointMaster *pMaster = g_hControlPointMasters.Count() ? g_hControlPointMasters[0] : NULL; if ( pMaster ) { float flRate = pMaster->GetPartialCapturePointRate(); if ( flRate > 0.0f ) { // for each player touch CTeam *pTeam = GetGlobalTeam( m_nCapturingTeam ); if ( pTeam ) { for ( int i=0;i<pTeam->GetNumPlayers();i++ ) { CBaseMultiplayerPlayer *pPlayer = ToBaseMultiplayerPlayer( pTeam->GetPlayer(i) ); if ( pPlayer && IsTouching( pPlayer ) ) { pPlayer->StartScoringEscortPoints( flRate ); } } } } } }
void CC4::PrimaryAttack() { bool PlaceBomb = false; CCSPlayer *pPlayer = GetPlayerOwner(); int onGround = FBitSet( pPlayer->GetFlags(), FL_ONGROUND ); if( m_bStartedArming == false ) { if( pPlayer->m_bInBombZone && onGround ) { m_bStartedArming = true; m_fArmedTime = gpGlobals->curtime + WEAPON_C4_ARM_TIME; m_bBombPlacedAnimation = false; //SendWeaponAnim( C4_ARM, UseDecrement() ? 1: 0 ); #if !defined( CLIENT_DLL ) // freeze the player in place while planting pPlayer->SetMaxSpeed( 1 ); // player "arming bomb" animation pPlayer->SetAnimation( PLAYER_ATTACK1 ); pPlayer->SetProgressBarTime( 3 ); #endif } else { if ( !pPlayer->m_bInBombZone ) { ClientPrint( pPlayer, HUD_PRINTCENTER, "#C4_Plant_At_Bomb_Spot"); } else { ClientPrint( pPlayer, HUD_PRINTCENTER, "#C4_Plant_Must_Be_On_Ground"); } m_flNextPrimaryAttack = gpGlobals->curtime + 1.0; return; } } else { if ( !onGround || !pPlayer->m_bInBombZone ) { if( !pPlayer->m_bInBombZone ) { ClientPrint( pPlayer, HUD_PRINTCENTER, "#C4_Arming_Cancelled" ); } else { ClientPrint( pPlayer, HUD_PRINTCENTER, "#C4_Plant_Must_Be_On_Ground" ); } m_flNextPrimaryAttack = gpGlobals->curtime + 1.5; m_bStartedArming = false; #if !defined( CLIENT_DLL ) // release the player from being frozen, we've somehow left the bomb zone pPlayer->ResetMaxSpeed(); pPlayer->SetProgressBarTime( 0 ); //pPlayer->SetAnimation( PLAYER_HOLDBOMB ); #endif /* if(m_bBombPlacedAnimation == true) //this means the placement animation is canceled { SendWeaponAnim( C4_DRAW, UseDecrement() ? 1: 0 ); } else { SendWeaponAnim( C4_IDLE1, UseDecrement() ? 1: 0 ); } */ return; } else { if( gpGlobals->curtime >= m_fArmedTime ) //the c4 is ready to be armed { //check to make sure the player is still in the bomb target area PlaceBomb = true; } else if( ( gpGlobals->curtime >= (m_fArmedTime - 0.75) ) && ( !m_bBombPlacedAnimation ) ) { //call the c4 Placement animation m_bBombPlacedAnimation = true; //SendWeaponAnim( C4_DROP, UseDecrement() ? 1: 0 ); #if !defined( CLIENT_DLL ) // player "place" animation //pPlayer->SetAnimation( PLAYER_HOLDBOMB ); #endif } } } if ( PlaceBomb && m_bStartedArming ) { m_bStartedArming = false; m_fArmedTime = 0; if( pPlayer->m_bInBombZone ) { #if !defined( CLIENT_DLL ) //Broadcast("BOMBPL"); CPlantedC4::ShootSatchelCharge( pPlayer, pPlayer->GetAbsOrigin(), QAngle(0,0,0) ); // send director message, that something important happened here /* MESSAGE_BEGIN( MSG_SPEC, SVC_DIRECTOR ); WRITE_BYTE ( 9 ); // command length in bytes WRITE_BYTE ( DRC_CMD_EVENT ); // bomb placed WRITE_SHORT( ENTINDEX(pPlayer->edict()) ); WRITE_SHORT( 0 ); WRITE_LONG( 11 | DRC_FLAG_FACEPLAYER ); // eventflags (priority and flags) MESSAGE_END(); */ // tell the Ts the bomb has been planted (on radar) CTeam *pTeam = GetGlobalTeam( TEAM_TERRORIST ); for ( int iPlayer=0; iPlayer < pTeam->GetNumPlayers(); iPlayer++ ) { CBasePlayer *pTempPlayer = pTeam->GetPlayer( iPlayer ); if ( pTempPlayer->m_lifeState != LIFE_DEAD ) { /* MESSAGE_BEGIN( MSG_ONE, gmsgBombDrop, NULL, pTempPlayer->pev ); WRITE_COORD( pBomb->pev->origin.x ); WRITE_COORD( pBomb->pev->origin.y ); WRITE_COORD( pBomb->pev->origin.z ); WRITE_BYTE( 1 ); // bomb was planted MESSAGE_END(); */ } } UTIL_ClientPrintAll( HUD_PRINTCENTER,"#Bomb_Planted" ); pPlayer->SetProgressBarTime( 0 ); // tell bots the bomb has been planted //g_pBotControl->OnEvent( EVENT_BOMB_PLANTED, pPlayer ); CSGameRules()->m_bBombDropped = false; // Play the plant sound. CPASAttenuationFilter filter( this ); EmitSound( filter, entindex(), "c4.plant" ); // release the player from being frozen pPlayer->ResetMaxSpeed(); // Remove the C4 icon from the HUD //pPlayer->SetBombIcon(); // No more c4! pPlayer->Weapon_Drop( this, NULL, NULL ); UTIL_Remove( this ); #endif return; } else { ClientPrint( pPlayer, HUD_PRINTCENTER, "#C4_Activated_At_Bomb_Spot" ); #if !defined( CLIENT_DLL ) //pPlayer->SetAnimation( PLAYER_HOLDBOMB ); // release the player from being frozen pPlayer->ResetMaxSpeed(); #endif m_flNextPrimaryAttack = gpGlobals->curtime + 1.0; return; } } m_flNextPrimaryAttack = gpGlobals->curtime + 0.3; m_flTimeWeaponIdle = gpGlobals->curtime + random->RandomFloat ( 10, 15 ); }