本文整理汇总了C++中CTeamControlPointMaster类的典型用法代码示例。如果您正苦于以下问题:C++ CTeamControlPointMaster类的具体用法?C++ CTeamControlPointMaster怎么用?C++ CTeamControlPointMaster使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CTeamControlPointMaster类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetGlobalTeam
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTeamControlPoint::HandleScoring( int iTeam )
{
if ( TeamplayRoundBasedRules() && !TeamplayRoundBasedRules()->ShouldScorePerRound() )
{
GetGlobalTeam( iTeam )->AddScore( 1 );
TeamplayRoundBasedRules()->HandleTeamScoreModify( iTeam, 1 );
CTeamControlPointMaster *pMaster = g_hControlPointMasters.Count() ? g_hControlPointMasters[0] : NULL;
if ( pMaster && !pMaster->WouldNewCPOwnerWinGame( this, iTeam ) )
{
#ifdef TF_DLL
if ( TeamplayRoundBasedRules()->GetGameType() == TF_GAMETYPE_ESCORT )
{
CBroadcastRecipientFilter filter;
EmitSound( filter, entindex(), "Hud.EndRoundScored" );
}
else
#endif
{
CTeamRecipientFilter filter( iTeam );
EmitSound( filter, entindex(), "Hud.EndRoundScored" );
}
}
}
}
示例2: GetControlPointMasterName
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTeamControlPoint::CaptureStart( int iCapTeam, int iNumCappingPlayers, int *pCappingPlayers )
{
int iNumCappers = iNumCappingPlayers;
float flLastOwnershipChangeTime = -1.f;
CBaseEntity *pEnt = gEntList.FindEntityByClassname( NULL, GetControlPointMasterName() );
while( pEnt )
{
CTeamControlPointMaster *pMaster = dynamic_cast<CTeamControlPointMaster *>( pEnt );
if ( pMaster && pMaster->IsActive() )
{
flLastOwnershipChangeTime = pMaster->GetLastOwnershipChangeTime();
}
pEnt = gEntList.FindEntityByClassname( pEnt, GetControlPointMasterName() );
}
IGameEvent *event = gameeventmanager->CreateEvent( "teamplay_point_startcapture" );
if ( event )
{
event->SetInt( "cp", m_iPointIndex );
event->SetString( "cpname", STRING( m_iszPrintName ) );
event->SetInt( "team", m_iTeam );
event->SetInt( "capteam", iCapTeam );
event->SetFloat( "captime", gpGlobals->curtime - flLastOwnershipChangeTime );
// safety check
if ( iNumCappers > 8 )
{
iNumCappers = 8;
}
char cappers[9]; // pCappingPlayers should be max length 8
int i;
for( i = 0 ; i < iNumCappers ; i++ )
{
cappers[i] = (char)pCappingPlayers[i];
}
cappers[i] = '\0';
// pCappingPlayers is a null terminated list of player indices
event->SetString( "cappers", cappers );
event->SetInt( "priority", 7 );
gameeventmanager->FireEvent( event );
}
}
示例3: FindControlPoints
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTeamControlPointRound::FindControlPoints( void )
{
// Let out control point masters know that the round has started
CTeamControlPointMaster *pMaster = g_hControlPointMasters.Count() ? g_hControlPointMasters[0] : NULL;
if ( pMaster )
{
// go through all the points
CBaseEntity *pEnt = gEntList.FindEntityByClassname( NULL, pMaster->GetControlPointName() );
while( pEnt )
{
CTeamControlPoint *pPoint = assert_cast<CTeamControlPoint *>(pEnt);
if ( pPoint )
{
const char *pString = STRING( m_iszCPNames );
const char *pName = STRING( pPoint->GetEntityName() );
// HACK to work around a problem with cp_a being returned for an entity name with cp_A
const char *pos = Q_stristr( pString, pName );
if ( pos )
{
int len = Q_strlen( STRING( pPoint->GetEntityName() ) );
if ( *(pos + len) == ' ' || *(pos + len) == '\0' )
{
if( m_ControlPoints.Find( pPoint ) == m_ControlPoints.InvalidIndex() )
{
DevMsg( 2, "Adding control point %s to control point round %s\n", pPoint->GetEntityName().ToCStr(), GetEntityName().ToCStr() );
m_ControlPoints.AddToHead( pPoint );
}
}
}
}
pEnt = gEntList.FindEntityByClassname( pEnt, pMaster->GetControlPointName() );
}
}
if( m_ControlPoints.Count() == 0 )
{
Warning( "Error! No control points found in map for team_game_round %s!\n", GetEntityName().ToCStr() );
}
}
示例4: MakePlayable
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool CTeamControlPointRound::MakePlayable( void )
{
CTeamControlPointMaster *pMaster = g_hControlPointMasters.Count() ? g_hControlPointMasters[0] : NULL;
if ( pMaster )
{
if ( !IsPlayable() )
{
// we need to try switching the owners of the teams to make this round playable
for ( int i = FIRST_GAME_TEAM ; i < GetNumberOfTeams() ; i++ )
{
for ( int j = 0 ; j < m_ControlPoints.Count() ; j++ )
{
if ( ( !pMaster->IsBaseControlPoint( m_ControlPoints[j]->GetPointIndex() ) ) && // this is NOT the base point for one of the teams (we don't want to assign the base to the wrong team)
( !WouldNewCPOwnerWinGame( m_ControlPoints[j], i ) ) ) // making this change would make this round playable
{
// need to find the trigger area associated with this point
CBaseEntity *pEnt = gEntList.FindEntityByClassname( NULL, pMaster->GetTriggerAreaCaptureName() );
while( pEnt )
{
CTriggerAreaCapture *pArea = assert_cast<CTriggerAreaCapture*>( pEnt );
if ( pArea )
{
if ( pArea->TeamCanCap( i ) )
{
CHandle<CTeamControlPoint> hPoint = pArea->GetControlPoint();
if ( hPoint == m_ControlPoints[j] )
{
// found!
pArea->ForceOwner( i ); // this updates the trigger_area *and* the control_point
return true;
}
}
}
pEnt = gEntList.FindEntityByClassname( pEnt, pMaster->GetTriggerAreaCaptureName() );
}
}
}
}
}
}
return false;
}
示例5: Assert
//-----------------------------------------------------------------------------
// 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 );
}
}
}
示例6: CaptureThink
//-----------------------------------------------------------------------------
// 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 );
}
}
}
}
}
}
示例7: MakePlayable
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool CTeamControlPointRound::MakePlayable( void )
{
CTeamControlPointMaster *pMaster = g_hControlPointMasters.Count() ? g_hControlPointMasters[0] : NULL;
if ( pMaster )
{
if ( !IsPlayable() )
{
// we need to try switching the owners of the teams to make this round playable
for ( int iTeam = FIRST_GAME_TEAM ; iTeam < GetNumberOfTeams() ; iTeam++ )
{
for ( int iControlPoint = 0 ; iControlPoint < m_ControlPoints.Count() ; iControlPoint++ )
{
if ( ( !pMaster->IsBaseControlPoint( m_ControlPoints[iControlPoint]->GetPointIndex() ) ) && // this is NOT the base point for one of the teams (we don't want to assign the base to the wrong team)
( !WouldNewCPOwnerWinGame( m_ControlPoints[iControlPoint], iTeam ) ) ) // making this change would make this round playable
{
// need to find the trigger area associated with this point
for ( int iObj=0; iObj<ITriggerAreaCaptureAutoList::AutoList().Count(); ++iObj )
{
CTriggerAreaCapture *pArea = static_cast< CTriggerAreaCapture * >( ITriggerAreaCaptureAutoList::AutoList()[iObj] );
if ( pArea->TeamCanCap( iTeam ) )
{
CHandle<CTeamControlPoint> hPoint = pArea->GetControlPoint();
if ( hPoint == m_ControlPoints[iControlPoint] )
{
// found!
pArea->ForceOwner( iTeam ); // this updates the trigger_area *and* the control_point
return true;
}
}
}
}
}
}
}
}
return false;
}
示例8: switch
//-----------------------------------------------------------------------------
// 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 );
}
}
}
}
}
}
示例9: SetNextThink
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTriggerAreaCapture::CaptureThink( void )
{
SetNextThink( gpGlobals->curtime + AREA_THINK_TIME );
// 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 ( !TeamplayGameRules()->PointsMayBeCaptured() )
{
// Points aren't allowed to be captured. If we were
// being captured, we need to clean up and reset.
if ( m_bCapturing )
{
BreakCapture( false );
UpdateNumPlayers();
}
return;
}
// go through our list of players
Assert( GetNumberOfTeams() <= MAX_CAPTURE_TEAMS );
int iNumPlayers[MAX_CAPTURE_TEAMS];
int iNumBlockablePlayers[MAX_CAPTURE_TEAMS]; // Players in the zone who can't cap, but can block / pause caps
CBaseMultiplayerPlayer *pFirstPlayerTouching[MAX_CAPTURE_TEAMS];
for ( int i = FIRST_GAME_TEAM; i < GetNumberOfTeams(); i++ )
{
iNumPlayers[i] = 0;
iNumBlockablePlayers[i] = 0;
pFirstPlayerTouching[i] = NULL;
}
if ( m_hPoint )
{
// Loop through the entities we're touching, and find players
for ( int i = 0; i < m_hTouchingEntities.Count(); i++ )
{
CBaseEntity *ent = m_hTouchingEntities[i];
if ( ent && ent->IsPlayer() )
{
CBaseMultiplayerPlayer *pPlayer = ToBaseMultiplayerPlayer(ent);
if ( pPlayer->IsAlive() )
{
int iTeam = pPlayer->GetTeamNumber();
// If a team's not allowed to cap a point, don't count players in it at all
if ( !TeamplayGameRules()->TeamMayCapturePoint( iTeam, m_hPoint->GetPointIndex() ) )
continue;
if ( !TeamplayGameRules()->PlayerMayCapturePoint( pPlayer, m_hPoint->GetPointIndex() ) )
{
if ( TeamplayGameRules()->PlayerMayBlockPoint( pPlayer, m_hPoint->GetPointIndex() ) )
{
if ( iNumPlayers[iTeam] == 0 && iNumBlockablePlayers[iTeam] == 0 )
{
pFirstPlayerTouching[iTeam] = pPlayer;
}
iNumBlockablePlayers[iTeam] += TeamplayGameRules()->GetCaptureValueForPlayer( pPlayer );
}
continue;
}
if ( iTeam >= FIRST_GAME_TEAM )
{
if ( iNumPlayers[iTeam] == 0 && iNumBlockablePlayers[iTeam] == 0 )
{
pFirstPlayerTouching[iTeam] = pPlayer;
}
iNumPlayers[iTeam] += TeamplayGameRules()->GetCaptureValueForPlayer( pPlayer );
}
}
}
}
}
int iTeamsInZone = 0;
bool bUpdatePlayers = false;
m_nTeamInZone = TEAM_UNASSIGNED;
for ( int i = FIRST_GAME_TEAM; i < GetNumberOfTeams(); i++ )
{
iNumPlayers[i] *= mp_simulatemultiplecappers.GetInt();
if ( m_TeamData[i].iNumTouching != iNumPlayers[i] )
{
m_TeamData[i].iNumTouching = iNumPlayers[i];
bUpdatePlayers = true;
}
m_TeamData[i].iBlockedTouching = m_TeamData[i].iNumTouching;
//.........这里部分代码省略.........
示例10: Assert
//.........这里部分代码省略.........
TeamplayGameRules()->SetLastCapPointChanged( m_iPointIndex+1 );
// Determine the pose parameters for each team
for ( int i = 0; i < m_TeamData.Count(); i++ )
{
// Skip spectator
if ( i == TEAM_SPECTATOR )
continue;
if ( GetModelPtr() && GetModelPtr()->SequencesAvailable() )
{
m_TeamData[i].iTeamPoseParam = LookupPoseParameter( UTIL_VarArgs( "cappoint_%d_percentage", i ) );
}
else
{
m_TeamData[i].iTeamPoseParam = -1;
}
}
UpdateCapPercentage();
if ( m_iTeam == TEAM_UNASSIGNED )
{
m_OnCapReset.FireOutput( this, this );
}
else
{
// Remap team to get first game team = 1
switch ( m_iTeam - FIRST_GAME_TEAM+1 )
{
case 1:
m_OnCapTeam1.FireOutput( this, this );
break;
case 2:
m_OnCapTeam2.FireOutput( this, this );
break;
default:
Assert(0);
break;
}
}
// If we're playing a sound, this is a true cap by players.
if ( bMakeSound )
{
if ( iOldTeam > LAST_SHARED_TEAM && iOldTeam != m_iTeam )
{
// Make the members of our old team say something
for ( int i = 1; i <= gpGlobals->maxClients; i++ )
{
CBaseMultiplayerPlayer *pPlayer = ToBaseMultiplayerPlayer( UTIL_PlayerByIndex( i ) );
if ( !pPlayer )
continue;
if ( pPlayer->GetTeamNumber() == iOldTeam )
{
pPlayer->SpeakConceptIfAllowed( MP_CONCEPT_LOST_CONTROL_POINT );
}
}
}
for( int i = 0; i < iNumCappers; i++ )
{
int playerIndex = pCappingPlayers[i];
Assert( playerIndex > 0 && playerIndex <= gpGlobals->maxClients );
PlayerCapped( ToBaseMultiplayerPlayer(UTIL_PlayerByIndex( playerIndex )) );
}
// Remap team to get first game team = 1
switch ( m_iTeam - FIRST_GAME_TEAM+1 )
{
case 1:
m_OnOwnerChangedToTeam1.FireOutput( this, this );
break;
case 2:
m_OnOwnerChangedToTeam2.FireOutput( this, this );
break;
}
if ( m_iTeam != TEAM_UNASSIGNED && iNumCappers )
{
SendCapString( m_iTeam, iNumCappers, pCappingPlayers );
}
}
// Have control point master check the win conditions now!
CBaseEntity *pEnt = gEntList.FindEntityByClassname( NULL, GetControlPointMasterName() );
while( pEnt )
{
CTeamControlPointMaster *pMaster = dynamic_cast<CTeamControlPointMaster *>( pEnt );
if ( pMaster->IsActive() )
{
pMaster->CheckWinConditions();
}
pEnt = gEntList.FindEntityByClassname( pEnt, GetControlPointMasterName() );
}
}
示例11: HandleTrainMovement
//.........这里部分代码省略.........
}
if ( m_flTotalPathDistance <= 0 )
{
Assert( !"No path distance in team_train_watcher\n" );
m_flTotalPathDistance = 1;
}
m_flTotalProgress = clamp( 1.0 - ( flDistanceToGoal / m_flTotalPathDistance ), 0.0, 1.0 );
m_flTrainDistanceFromStart = m_flTotalPathDistance - flDistanceToGoal;
// play alert sounds if necessary
for ( int iCount = 0 ; iCount < m_iNumCPLinks ; iCount++ )
{
if ( m_flTrainDistanceFromStart < m_CPLinks[iCount].flDistanceFromStart - TEAM_TRAIN_ALERT_DISTANCE )
{
// back up twice the alert distance before resetting our flag to play the warning again
if ( ( m_flTrainDistanceFromStart < m_CPLinks[iCount].flDistanceFromStart - ( TEAM_TRAIN_ALERT_DISTANCE * 2 ) ) || // has receded back twice the alert distance or...
( !m_bTrainCanRecede ) ) // used to catch the case where the train doesn't normally recede but has rolled back down a hill away from the CP
{
// reset our alert flag
m_CPLinks[iCount].bAlertPlayed = false;
}
}
else
{
if ( m_flTrainDistanceFromStart < m_CPLinks[iCount].flDistanceFromStart && !m_CPLinks[iCount].bAlertPlayed )
{
m_CPLinks[iCount].bAlertPlayed = true;
bool bFinalPointInMap = false;
CTeamControlPoint *pCurrentPoint = m_CPLinks[iCount].hCP.Get();
CTeamControlPointMaster *pMaster = g_hControlPointMasters.Count() ? g_hControlPointMasters[0] : NULL;
if ( pMaster )
{
// if we're not playing mini-rounds
if ( !pMaster->PlayingMiniRounds() )
{
for ( int i = FIRST_GAME_TEAM ; i < MAX_CONTROL_POINT_TEAMS ; i++ )
{
if ( ObjectiveResource() && ObjectiveResource()->TeamCanCapPoint( pCurrentPoint->GetPointIndex(), i ) )
{
if ( pMaster->WouldNewCPOwnerWinGame( pCurrentPoint, i ) )
{
bFinalPointInMap = true;
}
}
}
}
else
{
// or this is the last round
if ( pMaster->NumPlayableControlPointRounds() == 1 )
{
CTeamControlPointRound *pRound = pMaster->GetCurrentRound();
if ( pRound )
{
for ( int i = FIRST_GAME_TEAM ; i < MAX_CONTROL_POINT_TEAMS ; i++ )
{
if ( ObjectiveResource() && ObjectiveResource()->TeamCanCapPoint( pCurrentPoint->GetPointIndex(), i ) )
{
if ( pRound->WouldNewCPOwnerWinGame( pCurrentPoint, i ) )
{
bFinalPointInMap = true;
}