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; }
// 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; }
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; }
bool CGameControllerMOD::PreSpawn(CPlayer* pPlayer, vec2 *pOutPos) { // spectators can't spawn if(pPlayer->GetTeam() == TEAM_SPECTATORS) return false; if(m_InfectedStarted) { pPlayer->StartInfection(); } else { pPlayer->m_WasHumanThisRound = true; } if(pPlayer->IsInfected() && m_ExplosionStarted) return false; if(m_InfectedStarted && pPlayer->IsInfected() && rand()%3 > 0) { CPlayerIterator<PLAYERITER_INGAME> Iter(GameServer()->m_apPlayers); while(Iter.Next()) { if(Iter.Player()->GetCID() == pPlayer->GetCID()) continue; if(Iter.Player()->GetClass() != PLAYERCLASS_WITCH) continue; if(!Iter.Player()->GetCharacter()) continue; vec2 SpawnPos; if(Iter.Player()->GetCharacter()->FindWitchSpawnPosition(SpawnPos)) { *pOutPos = SpawnPos; return true; } } } CSpawnEval Eval; int Team = (pPlayer->IsInfected() ? TEAM_RED : TEAM_BLUE); Eval.m_FriendlyTeam = Team; // first try own team spawn, then normal spawn and then enemy EvaluateSpawnType(&Eval, Team); *pOutPos = Eval.m_Pos; return Eval.m_Got; }
bool CGameControllerMOD::PreSpawn(CPlayer* pPlayer, vec2 *pOutPos) { // spectators can't spawn if(pPlayer->GetTeam() == TEAM_SPECTATORS) return false; if(m_InfectedStarted) { pPlayer->StartInfection(); } else { pPlayer->m_WasHumanThisRound = true; } if(pPlayer->IsInfected() && m_ExplosionStarted) return false; if(m_InfectedStarted && pPlayer->IsInfected() && rand()%3 > 0) { for(int i = 0; i < MAX_CLIENTS; i ++) { CPlayer *pWitch = GameServer()->m_apPlayers[i]; if(!pWitch) continue; if(pWitch->GetCID() == pPlayer->GetCID()) continue; if(pWitch->GetClass() != PLAYERCLASS_WITCH) continue; if(!pWitch->GetCharacter()) continue; vec2 spawnTile = vec2(16.0f, 16.0f) + vec2( static_cast<float>(static_cast<int>(round(pWitch->GetCharacter()->m_Pos.x))/32)*32.0, static_cast<float>(static_cast<int>(round(pWitch->GetCharacter()->m_Pos.y))/32)*32.0); for(int j=-1; j<=1; j++) { if(IsSpawnable(vec2(spawnTile.x + j*32.0, spawnTile.y-64.0))) { *pOutPos = spawnTile + vec2(j*32.0, -64.0); return true; } if(IsSpawnable(vec2(spawnTile.x + j*32.0, spawnTile.y+64.0))) { *pOutPos = spawnTile + vec2(j*32.0, 64.0); return true; } if(IsSpawnable(vec2(spawnTile.x-64.0, spawnTile.y + j*32.0))) { *pOutPos = spawnTile + vec2(-64.0, j*32.0); return true; } if(IsSpawnable(vec2(spawnTile.x+64.0, spawnTile.y + j*32.0))) { *pOutPos = spawnTile + vec2(64.0, j*32.0); return true; } } } } CSpawnEval Eval; int Team = (pPlayer->IsInfected() ? TEAM_RED : TEAM_BLUE); Eval.m_FriendlyTeam = Team; // first try own team spawn, then normal spawn and then enemy EvaluateSpawnType(&Eval, Team); *pOutPos = Eval.m_Pos; return Eval.m_Got; }