本文整理汇总了C++中IsTeamplay函数的典型用法代码示例。如果您正苦于以下问题:C++ IsTeamplay函数的具体用法?C++ IsTeamplay怎么用?C++ IsTeamplay使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IsTeamplay函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
const char *CHL2MPRules::GetGameDescription( void )
{
if ( IsTeamplay() )
return "Team Deathmatch";
return "Deathmatch";
}
示例2: CheckTeamBalance
bool IGameController::CheckTeamBalance()
{
if(!IsTeamplay() || !g_Config.m_SvTeambalanceTime)
return true;
int aT[2] = {0, 0};
for(int i = 0; i < MAX_CLIENTS; i++)
{
CPlayer *pP = GameServer()->m_apPlayers[i];
if(pP && pP->GetTeam() != TEAM_SPECTATORS)
aT[pP->GetTeam()]++;
}
char aBuf[256];
if(absolute(aT[0]-aT[1]) >= 2)
{
str_format(aBuf, sizeof(aBuf), "Teams are NOT balanced (red=%d blue=%d)", aT[0], aT[1]);
GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf);
if(GameServer()->m_pController->m_UnbalancedTick == -1)
GameServer()->m_pController->m_UnbalancedTick = Server()->Tick();
return false;
}
else
{
str_format(aBuf, sizeof(aBuf), "Teams are balanced (red=%d blue=%d)", aT[0], aT[1]);
GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf);
GameServer()->m_pController->m_UnbalancedTick = -1;
return true;
}
}
示例3: CanChangeTeam
bool IGameController::CanChangeTeam(CPlayer *pPlayer, int JoinTeam)
{
int aT[2] = {0, 0};
if (!IsTeamplay() || JoinTeam == TEAM_SPECTATORS || !g_Config.m_SvTeambalanceTime)
return true;
for(int i = 0; i < MAX_CLIENTS; i++)
{
CPlayer *pP = GameServer()->m_apPlayers[i];
if(pP && pP->GetTeam() != TEAM_SPECTATORS)
aT[pP->GetTeam()]++;
}
// simulate what would happen if changed team
aT[JoinTeam]++;
if (pPlayer->GetTeam() != TEAM_SPECTATORS)
aT[JoinTeam^1]--;
// there is a player-difference of at least 2
if(absolute(aT[0]-aT[1]) >= 2)
{
// player wants to join team with less players
if ((aT[0] < aT[1] && JoinTeam == TEAM_RED) || (aT[0] > aT[1] && JoinTeam == TEAM_BLUE))
return true;
else
return false;
}
else
return true;
}
示例4: CanSpawn
bool IGameController::CanSpawn(CPlayer *pPlayer, vec2 *pOutPos)
{
CSpawnEval Eval;
// spectators can't spawn
if(pPlayer->GetTeam() == -1)
return false;
if(IsTeamplay())
{
Eval.m_FriendlyTeam = pPlayer->GetTeam();
// try first try own team spawn, then normal spawn and then enemy
EvaluateSpawnType(&Eval, 1+(pPlayer->GetTeam()&1));
if(!Eval.m_Got)
{
EvaluateSpawnType(&Eval, 0);
if(!Eval.m_Got)
EvaluateSpawnType(&Eval, 1+((pPlayer->GetTeam()+1)&1));
}
}
else
{
EvaluateSpawnType(&Eval, 0);
EvaluateSpawnType(&Eval, 1);
EvaluateSpawnType(&Eval, 2);
}
*pOutPos = Eval.m_Pos;
return Eval.m_Got;
}
示例5: CanSpawn
bool IGameController::CanSpawn(int Team, vec2 *pOutPos)
{
CSpawnEval Eval;
// spectators can't spawn
if(Team == TEAM_SPECTATORS)
return false;
if(IsTeamplay())
{
Eval.m_FriendlyTeam = Team;
// first try own team spawn, then normal spawn and then enemy
EvaluateSpawnType(&Eval, 1+(Team&1));
if(!Eval.m_Got)
{
EvaluateSpawnType(&Eval, 0);
if(!Eval.m_Got)
EvaluateSpawnType(&Eval, 1+((Team+1)&1));
}
}
else
{
EvaluateSpawnType(&Eval, 0);
EvaluateSpawnType(&Eval, 1);
EvaluateSpawnType(&Eval, 2);
}
*pOutPos = Eval.m_Pos;
return Eval.m_Got;
}
示例6: CheckTeamBalance
bool IGameController::CheckTeamBalance()
{
if(!IsTeamplay() || !g_Config.m_SvTeambalanceTime)
return true;
int aT[2] = {0, 0};
for(int i = 0; i < MAX_CLIENTS; i++)
{
CPlayer *pP = GameServer()->m_apPlayers[i];
if(pP && pP->GetTeam() != -1)
aT[pP->GetTeam()]++;
}
if(absolute(aT[0]-aT[1]) >= 2)
{
dbg_msg("game", "Team is NOT balanced (red=%d blue=%d)", aT[0], aT[1]);
if(GameServer()->m_pController->m_UnbalancedTick == -1)
GameServer()->m_pController->m_UnbalancedTick = Server()->Tick();
return false;
}
else
{
dbg_msg("game", "Team is balanced (red=%d blue=%d)", aT[0], aT[1]);
GameServer()->m_pController->m_UnbalancedTick = -1;
return true;
}
}
示例7: sizeof
void IGameController::Snap(int SnappingClient)
{
CNetObj_Game *pGameObj = (CNetObj_Game *)Server()->SnapNewItem(NETOBJTYPE_GAME, 0, sizeof(CNetObj_Game));
pGameObj->m_Paused = GameServer()->m_World.m_Paused;
pGameObj->m_GameOver = m_GameOverTick==-1?0:1;
pGameObj->m_SuddenDeath = m_SuddenDeath;
pGameObj->m_ScoreLimit = g_Config.m_SvScorelimit;
pGameObj->m_TimeLimit = g_Config.m_SvTimelimit;
pGameObj->m_RoundStartTick = m_RoundStartTick;
pGameObj->m_Flags = m_GameFlags;
pGameObj->m_Warmup = m_Warmup;
pGameObj->m_RoundNum = (str_length(g_Config.m_SvMaprotation) && g_Config.m_SvRoundsPerMap) ? g_Config.m_SvRoundsPerMap : 0;
pGameObj->m_RoundCurrent = m_RoundCount+1;
if(SnappingClient == -1)
{
// we are recording a demo, just set the scores
pGameObj->m_TeamscoreRed = m_aTeamscore[0];
pGameObj->m_TeamscoreBlue = m_aTeamscore[1];
}
else
{
// TODO: this little hack should be removed
pGameObj->m_TeamscoreRed = IsTeamplay() ? m_aTeamscore[0] : GameServer()->m_apPlayers[SnappingClient]->m_Score;
pGameObj->m_TeamscoreBlue = m_aTeamscore[1];
}
}
示例8: CanSpawn
// spawn
bool IGameController::CanSpawn(int Team, vec2 *pOutPos) const
{
// spectators can't spawn
if(Team == TEAM_SPECTATORS || GameServer()->m_World.m_Paused || GameServer()->m_World.m_ResetRequested)
return false;
CSpawnEval Eval;
if(IsTeamplay())
{
Eval.m_FriendlyTeam = Team;
// first try own team spawn, then normal spawn and then enemy
EvaluateSpawnType(&Eval, 1+(Team&1));
if(!Eval.m_Got)
{
EvaluateSpawnType(&Eval, 0);
if(!Eval.m_Got)
EvaluateSpawnType(&Eval, 1+((Team+1)&1));
}
}
else
{
EvaluateSpawnType(&Eval, 0);
EvaluateSpawnType(&Eval, 1);
EvaluateSpawnType(&Eval, 2);
}
*pOutPos = Eval.m_Pos;
return Eval.m_Got;
}
示例9: OnCharacterDeath
// event
int IGameController::OnCharacterDeath(CCharacter *pVictim, CPlayer *pKiller, int Weapon)
{
// do scoreing
if(!pKiller || Weapon == WEAPON_GAME)
return 0;
if(pKiller == pVictim->GetPlayer())
pVictim->GetPlayer()->m_Score--; // suicide
else
{
if(IsTeamplay() && pVictim->GetPlayer()->GetTeam() == pKiller->GetTeam())
pKiller->m_Score--; // teamkill
else
pKiller->m_Score++; // normal kill
}
if(Weapon == WEAPON_SELF)
pVictim->GetPlayer()->m_RespawnTick = Server()->Tick()+Server()->TickSpeed()*3.0f;
// update spectator modes for dead players in survival
if(m_GameFlags&GAMEFLAG_SURVIVAL)
{
for(int i = 0; i < MAX_CLIENTS; ++i)
if(GameServer()->m_apPlayers[i] && GameServer()->m_apPlayers[i]->m_DeadSpecMode)
GameServer()->m_apPlayers[i]->UpdateDeadSpecMode();
}
return 0;
}
示例10: GetStartTeam
int IGameController::GetStartTeam()
{
// this will force the auto balancer to work overtime aswell
if(g_Config.m_DbgStress)
return TEAM_RED;
if(g_Config.m_SvTournamentMode)
return TEAM_SPECTATORS;
// determine new team
int Team = TEAM_RED;
if(IsTeamplay())
Team = m_aTeamSize[TEAM_RED] > m_aTeamSize[TEAM_BLUE] ? TEAM_BLUE : TEAM_RED;
// check if there're enough player slots left
if(m_aTeamSize[TEAM_RED]+m_aTeamSize[TEAM_BLUE] < Server()->MaxClients()-g_Config.m_SvSpectatorSlots)
{
++m_aTeamSize[Team];
m_UnbalancedTick = TBALANCE_CHECK;
if(m_GameState == IGS_WARMUP_GAME && HasEnoughPlayers())
SetGameState(IGS_WARMUP_GAME, 0);
return Team;
}
return TEAM_SPECTATORS;
}
示例11: ClampTeam
int IGameController::ClampTeam(int Team)
{
if(Team < 0)
return TEAM_SPECTATORS;
if(IsTeamplay())
return Team&1;
return 0;
}
示例12: ClampTeam
int IGameController::ClampTeam(int Team)
{
if(Team < 0) // spectator
return -1;
if(IsTeamplay())
return Team&1;
return 0;
}
示例13: ClampTeam
int IGameController::ClampTeam(int Team) const
{
if(Team < TEAM_RED)
return TEAM_SPECTATORS;
if(IsTeamplay())
return Team&1;
return TEAM_RED;
}
示例14: DoTeamBalance
void IGameController::DoTeamBalance()
{
if(!IsTeamplay() || !g_Config.m_SvTeambalanceTime || absolute(m_aTeamSize[TEAM_RED]-m_aTeamSize[TEAM_BLUE]) < NUM_TEAMS)
return;
GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", "Balancing teams");
float aTeamScore[NUM_TEAMS] = {0};
float aPlayerScore[MAX_CLIENTS] = {0.0f};
// gather stats
for(int i = 0; i < MAX_CLIENTS; i++)
{
if(GameServer()->m_apPlayers[i] && GameServer()->m_apPlayers[i]->GetTeam() != TEAM_SPECTATORS)
{
aPlayerScore[i] = GameServer()->m_apPlayers[i]->m_Score*Server()->TickSpeed()*60.0f/
(Server()->Tick()-GameServer()->m_apPlayers[i]->m_ScoreStartTick);
aTeamScore[GameServer()->m_apPlayers[i]->GetTeam()] += aPlayerScore[i];
}
}
int BiggerTeam = (m_aTeamSize[TEAM_RED] > m_aTeamSize[TEAM_BLUE]) ? TEAM_RED : TEAM_BLUE;
int NumBalance = absolute(m_aTeamSize[TEAM_RED]-m_aTeamSize[TEAM_BLUE]) / NUM_TEAMS;
// balance teams
do
{
CPlayer *pPlayer = 0;
float ScoreDiff = aTeamScore[BiggerTeam];
for(int i = 0; i < MAX_CLIENTS; i++)
{
if(!GameServer()->m_apPlayers[i] || !CanBeMovedOnBalance(i))
continue;
// remember the player whom would cause lowest score-difference
if(GameServer()->m_apPlayers[i]->GetTeam() == BiggerTeam &&
(!pPlayer || absolute((aTeamScore[BiggerTeam^1]+aPlayerScore[i]) - (aTeamScore[BiggerTeam]-aPlayerScore[i])) < ScoreDiff))
{
pPlayer = GameServer()->m_apPlayers[i];
ScoreDiff = absolute((aTeamScore[BiggerTeam^1]+aPlayerScore[i]) - (aTeamScore[BiggerTeam]-aPlayerScore[i]));
}
}
// move the player to the other team
if(pPlayer)
{
int Temp = pPlayer->m_LastActionTick;
DoTeamChange(pPlayer, BiggerTeam^1);
pPlayer->m_LastActionTick = Temp;
pPlayer->Respawn();
GameServer()->SendGameMsg(GAMEMSG_TEAM_BALANCE_VICTIM, pPlayer->GetTeam(), pPlayer->GetCID());
}
}
while(--NumBalance);
m_UnbalancedTick = TBALANCE_OK;
GameServer()->SendGameMsg(GAMEMSG_TEAM_BALANCE, -1);
}
示例15: OnPlayerInfoChange
void IGameController::OnPlayerInfoChange(class CPlayer *pP)
{
const int aTeamColors[2] = {65387, 10223467};
if(IsTeamplay())
{
if(pP->GetTeam() >= 0 || pP->GetTeam() <= 1)
{
pP->m_TeeInfos.m_UseCustomColor = 1;
pP->m_TeeInfos.m_ColorBody = aTeamColors[pP->GetTeam()];
pP->m_TeeInfos.m_ColorFeet = aTeamColors[pP->GetTeam()];
}
}
}