Ejemplo n.º 1
0
// game
void CGameControllerLTS::DoWincheckRound()
{
	int Count[2] = {0};
	for(int i = 0; i < MAX_CLIENTS; ++i)
	{
		if(GameServer()->m_apPlayers[i] && GameServer()->m_apPlayers[i]->GetTeam() != TEAM_SPECTATORS &&
			(!GameServer()->m_apPlayers[i]->m_RespawnDisabled ||
			(GameServer()->m_apPlayers[i]->GetCharacter() && GameServer()->m_apPlayers[i]->GetCharacter()->IsAlive())))
			++Count[GameServer()->m_apPlayers[i]->GetTeam()];
	}

	if(Count[TEAM_RED]+Count[TEAM_BLUE] == 0 || (m_GameInfo.m_TimeLimit > 0 && (Server()->Tick()-m_GameStartTick) >= m_GameInfo.m_TimeLimit*Server()->TickSpeed()*60))
	{
		++m_aTeamscore[TEAM_BLUE];
		++m_aTeamscore[TEAM_RED];
		EndRound();
	}
	else if(Count[TEAM_RED] == 0)
	{
		++m_aTeamscore[TEAM_BLUE];
		EndRound();
	}
	else if(Count[TEAM_BLUE] == 0)
	{
		++m_aTeamscore[TEAM_RED];
		EndRound();
	}
}
void CGameControllerSimon::PushPad(short pad)
{
    v_Pads[pad].m_Timer = GetTickCount() + 1000 * 0.3f;
    v_Pads[pad].m_Used = true;

    if (m_ActivePlayer == PLAYER_1)
    {
        if (v_Seq[m_SeqP1Pos] != pad)
            EndRound();

        m_SeqP1Pos++;
        if (m_SeqP1Pos >= v_Seq.size()-1)
        {
            m_SeqP1Pos=0;
            m_ActivePlayer = PLAYER_CPU;
        }
    }
    else
    {
        ANIM *m_pAnim = new ANIM();
        m_pAnim->m_Dir=-1;
        m_pAnim->m_Pos = vec2(g_Game.GetScreenW()/2 - dimTW/2*2+(dimTW/3)*3, g_Game.GetScreenH()/2);
        m_pAnim->m_Radius = dimTH/2 + (dimTH/3)/2;
        m_pAnim->m_Timer = GetTickCount();
        m_pAnim->m_Color = GetPadColor(pad);
        v_Anims.push_back(m_pAnim);
    }
}
Ejemplo n.º 3
0
void IGameController::DoPlayerScoreWincheck()
{
	if(m_GameOverTick == -1 && !m_Warmup)
	{
		// gather some stats
		int Topscore = 0;
		int TopscoreCount = 0;
		for(int i = 0; i < MAX_CLIENTS; i++)
		{
			if(GameServer()->m_apPlayers[i])
			{
				if(GameServer()->m_apPlayers[i]->m_Score > Topscore)
				{
					Topscore = GameServer()->m_apPlayers[i]->m_Score;
					TopscoreCount = 1;
				}
				else if(GameServer()->m_apPlayers[i]->m_Score == Topscore)
					TopscoreCount++;
			}
		}

		// check score win condition
		if((g_Config.m_SvScorelimit > 0 && Topscore >= g_Config.m_SvScorelimit) ||
			(g_Config.m_SvTimelimit > 0 && (Server()->Tick()-m_RoundStartTick) >= g_Config.m_SvTimelimit*Server()->TickSpeed()*60))
		{
			if(TopscoreCount == 1)
				EndRound();
			else
				m_SuddenDeath = 1;
		}
	}
}
Ejemplo n.º 4
0
void IGameController::ChangeMap(const char *pToMap)
{
	

	str_copy(m_aMapWish, pToMap, sizeof(m_aMapWish));
	EndRound();
}
Ejemplo n.º 5
0
void CGameControllerJUG::OnCharacterSpawn(class CCharacter *pChr)
{

		if(!current_jug)
		{
			if(!m_CountDown[0] && CheckPlayerCount() > 1)
			{
				EndRound(true);
			}
		}

		// default health
		pChr->IncreaseHealth(10);

		pChr->GiveWeapon(WEAPON_HAMMER, -1);
		if(!g_Config.m_JugHammer || !IsJuggernaut(pChr->GetPlayer()->GetCID()))
		{
			// give default weapons for everyone except juggernaut
			pChr->GiveWeapon(WEAPON_GUN, 10);
	  }

		if(current_jug && pChr && pChr->GetPlayer() && pChr->GetPlayer()->GetCID() == current_jug->GetCID()){
			current_jug->GetCharacter()->SetHealth(g_Config.m_JugHealth);
		}
}
Ejemplo n.º 6
0
void IGameController::DoWincheck()
{
	if(m_GameOverTick == -1 && !m_Warmup && !GameServer()->m_World.m_ResetRequested)
	{
		if(IsTeamplay())
		{
			// check score win condition
			if((g_Config.m_SvScorelimit > 0 && (m_aTeamscore[TEAM_RED] >= g_Config.m_SvScorelimit || m_aTeamscore[TEAM_BLUE] >= g_Config.m_SvScorelimit)) ||
				(g_Config.m_SvTimelimit > 0 && (Server()->Tick()-m_RoundStartTick) >= g_Config.m_SvTimelimit*Server()->TickSpeed()*60))
			{
				if(m_aTeamscore[TEAM_RED] != m_aTeamscore[TEAM_BLUE])
					EndRound();
				else
					m_SuddenDeath = 1;
			}
		}
		else
		{
			// gather some stats
			int Topscore = 0;
			int TopscoreCount = 0;
			for(int i = 0; i < MAX_CLIENTS; i++)
			{
				if(GameServer()->m_apPlayers[i])
				{
					if(GameServer()->m_apPlayers[i]->m_Score > Topscore)
					{
						Topscore = GameServer()->m_apPlayers[i]->m_Score;
						TopscoreCount = 1;
					}
					else if(GameServer()->m_apPlayers[i]->m_Score == Topscore)
						TopscoreCount++;
				}
			}

			// check score win condition
			if((g_Config.m_SvScorelimit > 0 && Topscore >= g_Config.m_SvScorelimit) ||
				(g_Config.m_SvTimelimit > 0 && (Server()->Tick()-m_RoundStartTick) >= g_Config.m_SvTimelimit*Server()->TickSpeed()*60))
			{
				if(TopscoreCount == 1)
					EndRound();
				else
					m_SuddenDeath = 1;
			}
		}
	}
}
Ejemplo n.º 7
0
/**
* Tests that the state of the battle is set back to InBetween at the end of the round,
* if it is not the end of a match. 
*/
TEST_F(TestBattleController, TestChangeStateToInBetween)
{
	// Set the battle state
	SetBattleState(BattleController::BattleState::WinRound);
	SetPlayerMove(new Skill("Paper", Skill::SkillType::Paper));
	// End the round and check that the battle state is set to InBetween
	EndRound();
	EXPECT_EQ(BattleController::BattleState::InBetween, GetBattleState());
	EXPECT_EQ(nullptr, GetCurrentMove());
}
Ejemplo n.º 8
0
// game
void CGameControllerLMS::DoWincheckRound()
{
    // check for time based win
    if(g_Config.m_SvTimelimit > 0 && (Server()->Tick()-m_GameStartTick) >= g_Config.m_SvTimelimit*Server()->TickSpeed()*60)
    {
        for(int i = 0; i < MAX_CLIENTS; ++i)
        {
            if(GameServer()->m_apPlayers[i] && GameServer()->m_apPlayers[i]->GetTeam() != TEAM_SPECTATORS &&
                    (!GameServer()->m_apPlayers[i]->m_RespawnDisabled ||
                     (GameServer()->m_apPlayers[i]->GetCharacter() && GameServer()->m_apPlayers[i]->GetCharacter()->IsAlive())))
                GameServer()->m_apPlayers[i]->m_Score++;
        }

        EndRound();
    }
    else
    {
        // check for survival win
        CPlayer *pAlivePlayer = 0;
        int AlivePlayerCount = 0;
        for(int i = 0; i < MAX_CLIENTS; ++i)
        {
            if(GameServer()->m_apPlayers[i] && GameServer()->m_apPlayers[i]->GetTeam() != TEAM_SPECTATORS &&
                    (!GameServer()->m_apPlayers[i]->m_RespawnDisabled ||
                     (GameServer()->m_apPlayers[i]->GetCharacter() && GameServer()->m_apPlayers[i]->GetCharacter()->IsAlive())))
            {
                ++AlivePlayerCount;
                pAlivePlayer = GameServer()->m_apPlayers[i];
            }
        }

        if(AlivePlayerCount == 0)		// no winner
            EndRound();
        else if(AlivePlayerCount == 1)	// 1 winner
        {
            pAlivePlayer->m_Score++;
            EndRound();
        }
    }
}
Ejemplo n.º 9
0
void CGameControllerCTF::DoWincheck()
{
	if(m_GameOverTick == -1 && !m_Warmup)
	{
		// check score win condition
		if((g_Config.m_SvScorelimit > 0 && (m_aTeamscore[TEAM_RED] >= g_Config.m_SvScorelimit || m_aTeamscore[TEAM_BLUE] >= g_Config.m_SvScorelimit)) ||
			(g_Config.m_SvTimelimit > 0 && (Server()->Tick()-m_RoundStartTick) >= g_Config.m_SvTimelimit*Server()->TickSpeed()*60))
		{
			if(m_SuddenDeath)
			{
				if(m_aTeamscore[TEAM_RED]/100 != m_aTeamscore[TEAM_BLUE]/100)
					EndRound();
			}
			else
			{
				if(m_aTeamscore[TEAM_RED] != m_aTeamscore[TEAM_BLUE])
					EndRound();
				else
					m_SuddenDeath = 1;
			}
		}
	}
}
Ejemplo n.º 10
0
void IGameController::DoTeamScoreWincheck()
{
	if(m_GameOverTick == -1 && !m_Warmup)
	{
		// check score win condition
		if((g_Config.m_SvScorelimit > 0 && (m_aTeamscore[0] >= g_Config.m_SvScorelimit || m_aTeamscore[1] >= g_Config.m_SvScorelimit)) ||
			(g_Config.m_SvTimelimit > 0 && (Server()->Tick()-m_RoundStartTick) >= g_Config.m_SvTimelimit*Server()->TickSpeed()*60))
		{
			if(m_aTeamscore[0] != m_aTeamscore[1])
				EndRound();
			else
				m_SuddenDeath = 1;
		}
	}
}
void CGameControllerRalla3::CheckWinner(PLAYERTYPE winner)
{
    /** Verificacion Lineas **/
    if ((v_GameTable[0][0] == winner && v_GameTable[1][0] == winner && v_GameTable[2][0] == winner)
        || (v_GameTable[0][1] == winner && v_GameTable[1][1] == winner && v_GameTable[2][1] == winner)
        || (v_GameTable[0][2] == winner && v_GameTable[1][2] == winner && v_GameTable[2][2] == winner)
        || (v_GameTable[0][0] == winner && v_GameTable[0][1] == winner && v_GameTable[0][2] == winner)
        || (v_GameTable[1][0] == winner && v_GameTable[1][1] == winner && v_GameTable[1][2] == winner)
        || (v_GameTable[2][0] == winner && v_GameTable[2][1] == winner && v_GameTable[2][2] == winner)
        || (v_GameTable[2][0] == winner && v_GameTable[1][1] == winner && v_GameTable[0][2] == winner)
        || (v_GameTable[0][0] == winner && v_GameTable[1][1] == winner && v_GameTable[2][2] == winner)
        )
    {
        m_PlayerWin = winner;
        EndRound();
    }
}
Ejemplo n.º 12
0
void DogfightClass::UpdateDogfight (void)
{
	if (vuxRealTime > lastUpdateTime + VU_TICS_PER_SECOND)
	{
		// Check for new players
		TheCampaign.MissionEvaluator->RebuildEvaluationData();
		
		// Update the game status
		UpdateGameStatus();
		
		// Update local game status
		if (localGameStatus == dog_EndRound)
		{
			// Only Matchplay gets here :-)
			if ((restart_matchplay_round) && (vuxRealTime > static_cast<VU_TIME>(restart_matchplay_round)))
			{
				MonoPrint ("Ending Round Now\n");
				
				RoundOver ();
				
				if (GameOver())
				{
					EndGame();
					OTWDriver.EndFlight();
				}
				else
				{
					EndRound();
				}
				
				restart_matchplay_round = 0;
			}
			else
			{
				MonoPrint ("Still waiting to end round %d\n", restart_matchplay_round - vuxRealTime);
				
				if ((gameType == dog_TeamMatchplay) && (CheckRoundOver() == 0))
				{
					RoundOver ();
					
					if (GameOver())
					{
						EndGame();
						OTWDriver.EndFlight();
					}
					else
					{
						EndRound();
					}
					
					restart_matchplay_round = 0;
				}
			}
		}
		else if (localGameStatus == dog_Flying)
		{
			if ((gameType == dog_TeamMatchplay) && (CheckRoundOver() <= 1))
			{
				MonoPrint ("GameStatus: dog EndRound\n");
				restart_matchplay_round = vuxRealTime + 10 * VU_TICS_PER_SECOND;
				localGameStatus = dog_EndRound;
			}
			else if (GameOver())
			{
				EndGame();
				OTWDriver.EndFlight();
			}
			else if (GameManager.NoMorePlayers(FalconLocalGame))
			{
				EndGame();
			}
			else if (gameType != dog_TeamMatchplay)
			{
				RegenerateAvailableAircraft();
			}
		}
		else if (localGameStatus == dog_Starting)
		{
			if (gameType == dog_TeamMatchplay)
			{
				// Wait until all players are no longer flying before resetting
				if (gameStatus != dog_Flying)
				{
					ResetRound();
				}
				
				// Wait until all players are ready before restarting
				if (GameManager.AllPlayersReady(FalconLocalGame))
				{
					GameManager.ReleasePlayer(FalconLocalSession);
					action_cam_started = FALSE;
					action_cam_time = 0;
					OTWDriver.SetExitMenu(FALSE);
					MonoPrint ("GameStatus: dog Flying\n");
					localGameStatus = dog_Flying;
				}
			}
			else
			{
				RegenerateAvailableAircraft();
				MonoPrint ("GameStatus: dog Flying\n");
				localGameStatus = dog_Flying;
			}
		}
		else
		{
			// Check for game restart
			if ((localFlags & DF_VIEWED_SCORES) && (gameStatus == dog_Waiting))
			{
				RestartGame();
			}
			
			if ((FalconLocalSession->GetFlyState() >= FLYSTATE_LOADING) && (FalconLocalSession->GetFlyState() <= FLYSTATE_FLYING))
			{
				MonoPrint ("GameStatus: dog Starting\n");
				localGameStatus = dog_Starting;
			}
		}
		
		lastUpdateTime = vuxRealTime;
		
		if ((!SimDriver.GetPlayerEntity()) && (!action_cam_started) && (!action_cam_time))
		{
			action_cam_time = vuxRealTime + 10 * VU_TICS_PER_SECOND;
			
			action_cam_started = TRUE;
		}
		
		if ((action_cam_started) && (static_cast<VU_TIME>(action_cam_time) > vuxRealTime))
		{
			OTWDriver.ToggleActionCamera();
			action_cam_started = FALSE;
		}
	}
}
Ejemplo n.º 13
0
Archivo: csbb.cpp Proyecto: Siile/CSTT
void CGameControllerCSBB::Tick()
{
	IGameController::Tick();

	
	if(GameServer()->m_World.m_ResetRequested || GameServer()->m_World.m_Paused)
		return;	

	m_RoundTick++;
		
	// no actual players (bots kicked if human_players == 0)
	if (CountPlayers() < 1 || m_NewGame)
	{
		GameServer()->m_CanRespawn = true;
	
		if (m_Round != 0 || m_GameState != CSBB_NEWBASE)
			Restart();
		
		m_RoundTick = 0;
	}
	else
	{
		if (CountPlayers() == 1)
		{
			Restart();
			AutoBalance();
			return;
		}
		
		AutoBalance();
		
		if (m_GameState == CSBB_NEWBASE)
		{
			CaptureBase();
			
			if (GameServer()->m_pArrow)
			{
				GameServer()->m_pArrow->m_Hide = false;
				GameServer()->m_pArrow->m_Target = m_apBombArea[m_Base]->m_Pos;
			}
		}
		if (m_GameState == CSBB_DEFENDING)
		{

			if (GameServer()->m_pArrow)
			{
				GameServer()->m_pArrow->m_Hide = false;
				GameServer()->m_pArrow->m_Target = m_apBombArea[m_Base]->m_Pos;
			}
			
			RoundWinLose();
		}
		if (m_GameState == CSBB_ENDING)
		{
			if (m_RoundTick >= g_Config.m_SvPreroundTime*Server()->TickSpeed())
			{
				if (m_aTeamscore[TEAM_RED] >= g_Config.m_SvNumRounds || m_aTeamscore[TEAM_BLUE] >= g_Config.m_SvNumRounds)
				{
					EndRound();
					m_NewGame = true;
					return;
				}
				
				NewBase();
				//AutoBalance();
				
				if (GameServer()->m_pArrow)
					GameServer()->m_pArrow->m_Hide = true;
				

			}
		}
	}
	
	
	
	


	GameServer()->UpdateAI();

	

	// warm welcome
	for (int c = 0; c < MAX_CLIENTS; c++)
	{
		CPlayer *pPlayer = GameServer()->m_apPlayers[c];
		if(!pPlayer)
			continue;
		
		if (!pPlayer->m_Welcomed && !pPlayer->m_IsBot)
		{
			GameServer()->SendBroadcast("Welcome to Counter-Strike: Base Bombing", pPlayer->GetCID(), true);
			pPlayer->m_Welcomed = true;
		}
	}
	
	
	
	
	// the bomb (red flag)
	CBomb *B = m_pBomb;
	
	if (!B)
		return;
	
	
	
	/*
	// always update bomb position
	if(B->m_pCarryingCharacter)
	{
		B->m_Pos = B->m_pCarryingCharacter->m_Pos;
	}
	else
	{
		if (B->m_Status == BOMB_CARRYING || B->m_Status == BOMB_IDLE)
		{
			B->m_Vel.y += GameServer()->m_World.m_Core.m_Tuning.m_Gravity;
			GameServer()->Collision()->MoveBox(&B->m_Pos, &B->m_Vel, vec2(B->ms_PhysSize, B->ms_PhysSize), 0.5f);
			B->m_Status = BOMB_IDLE;
		}
	}
	*/
	
	
	if (m_Timeout || m_BombDefused || m_GameState != CSBB_DEFENDING)
		return;

	
	if (B->m_Status == BOMB_PLANTED)
	{
		B->m_Timer++;
		
		// bomb ticking sound
		int Time = Server()->TickSpeed();
		
		if (Server()->TickSpeed() / 30 + GetTimeLeft()*8 < Time)
			Time = Server()->TickSpeed() / 20 + GetTimeLeft()*4;
		
		if (++m_BombSoundTimer >= Time)
		{
			m_BombSoundTimer = 0;
			GameServer()->CreateSound(B->m_Pos, SOUND_CHAT_SERVER);
			GameServer()->CreateSound(B->m_Pos, SOUND_CHAT_SERVER);
		}
		
		// bomb defusing
		//CCharacter *apCloseCCharacters[MAX_CLIENTS];
		//int Num = GameServer()->m_World.FindEntities(B->m_Pos, CFlag::ms_PhysSize * 2, (CEntity**)apCloseCCharacters, MAX_CLIENTS, CGameWorld::ENTTYPE_CHARACTER);
		
		bool DefusingBomb = false;
		
		for (int i = 0; i < MAX_CLIENTS; i++)
		{
			CPlayer *pPlayer = GameServer()->m_apPlayers[i];
			if(!pPlayer)
				continue;

			CCharacter *pCharacter = pPlayer->GetCharacter();
			if (!pCharacter)
				continue;
		
			if(!pCharacter->IsAlive() || pPlayer->GetTeam() != m_DefendingTeam)
				continue;
			
			// check distance
			if (abs(pCharacter->m_Pos.x - B->m_Pos.x) < 150 && abs(pCharacter->m_Pos.y - B->m_Pos.y) < 150 &&
				pCharacter->IsGrounded())
			{
				DefusingBomb = true;
				m_aDefusing[i] = true;
				
				pPlayer->m_InterestPoints += 7;
							
				if (m_BombDefuseTimer == 0)
				{
					GameServer()->SendBroadcast("Defusing bomb", pPlayer->GetCID());
					//GameServer()->CreateSoundGlobal(SOUND_CTF_DROP, pPlayer->GetCID());
				}
			}
			else
			{
				if (m_aDefusing[i])
				{
					m_aDefusing[i] = false;
					GameServer()->SendBroadcast("", pPlayer->GetCID());
				}
			}
		}
		
		if (DefusingBomb)
		{
			// bomb defusing sound
			if (++m_BombActionTimer >= Server()->TickSpeed()/4)
			{
				m_BombActionTimer = 0;
				GameServer()->CreateSound(B->m_Pos, SOUND_BODY_LAND);
			}
			
			if (++m_BombDefuseTimer >= g_Config.m_SvBombDefuseTime*Server()->TickSpeed())
			{
				B->m_Hide = true;
				m_BombDefused = true;
				if (m_DefendingTeam == TEAM_RED)
					GameServer()->SendBroadcast("Bomb defused - Terrorists score!", -1, true);
				if (m_DefendingTeam == TEAM_BLUE)
					GameServer()->SendBroadcast("Bomb defused - Counter-terrorists score!", -1, true);
				GameServer()->CreateSoundGlobal(SOUND_CTF_GRAB_PL, -1);
							
				m_RoundTimeLimit = 0; // gamecontroller
				m_ResetTime = true; // gamecontroller
			}
		}
		else
		{
			m_BombDefuseTimer = 0;
		}
		
		return;
	}
	else
	{
		for (int c = 0; c < MAX_CLIENTS; c++)
		{
			bool BombPlantable = false;
			CPlayer *pPlayer = GameServer()->m_apPlayers[c];
			if(!pPlayer)
				continue;
			
			if(pPlayer->GetTeam() == m_DefendingTeam)
				continue;

			CCharacter *pCharacter = pPlayer->GetCharacter();
			if (!pCharacter)
				continue;
		
			if(!pCharacter->IsAlive() || pPlayer->GetTeam() == m_DefendingTeam)
				continue;
				
			if (m_Base >= 0)
			{
				if (m_apBombArea[m_Base] && !m_apBombArea[m_Base]->m_Hide)
				{
					
					// check distance
					if (abs(m_apBombArea[m_Base]->m_Pos.x - pCharacter->m_Pos.x) < 200 && abs(m_apBombArea[m_Base]->m_Pos.y - pCharacter->m_Pos.y) < 200 &&
						pCharacter->IsGrounded())
					{
						BombPlantable = true;
						//GameServer()->SendBroadcast("Inside range", pPlayer->GetCID());
						
						if (pCharacter->m_BombStatus != BOMB_PLANTING)
						{
							pCharacter->m_BombStatus = BOMB_PLANTING;
							m_aPlanting[c] = 0;
							
							GameServer()->SendBroadcast("Planting bomb", pPlayer->GetCID());
						}
						else if (pCharacter->m_BombStatus == BOMB_PLANTING)
						{
							// bomb planting sound
							if (++m_aBombActionTimer[c] >= Server()->TickSpeed()/4)
							{
								m_aBombActionTimer[c] = 0;
								GameServer()->CreateSound(B->m_Pos, SOUND_BODY_LAND);
							}
							
							pPlayer->m_InterestPoints += 6;
							
							if (++m_aPlanting[c] >= g_Config.m_SvBombPlantTime*Server()->TickSpeed())
							{
								pPlayer->m_InterestPoints += 120;
								
								B->m_pCarryingCharacter = NULL;
								B->m_Status = BOMB_PLANTED;
								pCharacter->m_BombStatus = BOMB_PLANTED;
								m_aPlanting[c] = 0;
								B->m_Timer = 0;
								GameServer()->SendBroadcast("Bomb planted!", -1, true);
								GameServer()->CreateSoundGlobal(SOUND_CTF_GRAB_PL, -1);
								
								B->m_Hide = false;
								B->m_Pos = pCharacter->m_Pos;
								B->m_Owner = c;
								
								m_RoundTimeLimit = g_Config.m_SvBombTime; // gamecontroller
								m_ResetTime = true; // gamecontroller
								
								return;
							}
						}
					}
				}
			}
			
			if (!BombPlantable)
			{
				pCharacter->m_BombStatus = BOMB_CARRYING;
				if (m_aPlanting[c] > 0)
					GameServer()->SendBroadcast("", c);
				
				m_aPlanting[c] = 0;
			}
		}
	}


	// don't add anything relevant here! possible return; above!
}
Ejemplo n.º 14
0
void CGameControllerJUG::NewJuggernaut(class CPlayer *pPlayer)
{
	if(CheckPlayerCount() < 2)
		return;

	//No.. There will be no new juggernaut during countdowns! Thank you
	if(m_CountDown[0])
		return;

	//Random juggernaut
	if(!pPlayer)
	{
	  int count = 0;
		int CIDs[MAX_CLIENTS];
		for(int i = 0; i < MAX_CLIENTS; i++)
		{
			if(GameServer()->m_apPlayers[i] && GameServer()->m_apPlayers[i]->GetTeam() != TEAM_SPECTATORS)
			{ //this player is not null and not a spectator
				CIDs[count] = i; //add ClientID to array
				count++;
			}
		}

		if(count < 1)
		{
			current_jug = NULL;
			m_bCriticalHealth = false;
			return;
		}

		int random_index = 0;
		if(m_pLastJug && count > 1)
		{ //if there was a juggernaut, and more than 1 player
			while (CIDs[random_index] == m_pLastJug->GetCID())
			{ //make sure new juggernaut is not same as last one
				random_index = rand() % count;
			}
	  }
		else if (!m_pLastJug)//if theres was no juggernaut but there are players
			random_index = rand() % count;
		else {
			EndRound(); //just restart
			return;
		}
		//if player is not null
		if(GameServer()->m_apPlayers[CIDs[random_index]])
			pPlayer = GameServer()->m_apPlayers[CIDs[random_index]];
		else return;
	}
	//end random

	if(pPlayer && pPlayer->GetTeam() != TEAM_SPECTATORS) //if player is not spectating, continue
		current_jug = pPlayer;
	else
	{
		NewJuggernaut();
		return;
	}

	//Give 50 health
	if(current_jug->GetCharacter())
	{
		current_jug->GetCharacter()->SetHealth(g_Config.m_JugHealth);
		if(g_Config.m_JugHammer)
			current_jug->GetCharacter()->GiveWeapon(WEAPON_HAMMER, -1);
	}

	m_bCriticalHealth = false;
	char buf[512];
	str_format(buf, sizeof(buf), "%s is the new Juggernaut!", GameServer()->Server()->ClientName(current_jug->GetCID()));
	GameServer()->SendChat(-1, CGameContext::CHAT_ALL, buf);
	GameServer()->SendBroadcast(buf, -1);
}
Ejemplo n.º 15
0
void CGameControllerMOD::Tick()
{
	IGameController::Tick();
	
	m_HumanCounter = 0;
	m_InfectedCounter = 0;
	
	//Count type of players
	for(int i = 0; i < MAX_CLIENTS; i ++)
	{
		CPlayer *pPlayer = GameServer()->m_apPlayers[i];
		
		if(!pPlayer) continue;
		if(pPlayer->GetTeam() == TEAM_SPECTATORS) continue;
		
		if(pPlayer->IsInfected()) m_InfectedCounter++;
		else m_HumanCounter++;
	}
	
	m_InfectedStarted = false;
	
	//If the game can start ...
	if(m_GameOverTick == -1 && m_HumanCounter + m_InfectedCounter >= 2)
	{
		//If the infection started
		if(m_RoundStartTick + Server()->TickSpeed()*10 < Server()->Tick())
		{	
			m_InfectedStarted = true;
	
			for(int i = 0; i < MAX_CLIENTS; i ++)
			{
				CPlayer *pPlayer = GameServer()->m_apPlayers[i];
				
				if(!pPlayer) continue;
				if(pPlayer->GetTeam() == TEAM_SPECTATORS)
				{
					pPlayer->StartInfection();
				}
				else if(pPlayer->GetClass() == PLAYERCLASS_NONE)
				{
					pPlayer->SetClass(ChooseHumanClass(pPlayer));
					if(pPlayer->GetCharacter())
						pPlayer->GetCharacter()->IncreaseArmor(10);
				}
			}
			
			//If needed, infect players
			int nbInfectedNeeded = 2;
			if(m_InfectedCounter + m_HumanCounter < 4)
			{
				nbInfectedNeeded = 1;
			}
			
			while(m_InfectedCounter < nbInfectedNeeded)
			{
				float InfectionProb = 1.0/static_cast<float>(m_HumanCounter);
				float random = frandom();
				
				//Fair infection
				bool FairInfectionFound = false;
				for(int i = 0; i < MAX_CLIENTS; i ++)
				{
					CPlayer *pPlayer = GameServer()->m_apPlayers[i];
					
					if(!pPlayer) continue;
					if(pPlayer->GetTeam() == TEAM_SPECTATORS) continue;
					if(pPlayer->IsInfected()) continue;
					
					if(!Server()->IsClientInfectedBefore(i))
					{
						Server()->InfecteClient(i);
						GameServer()->m_apPlayers[i]->StartInfection();
						m_InfectedCounter++;
						m_HumanCounter--;
						
						GameServer()->SendChatTarget_Language_s(-1, "%s has been infected", Server()->ClientName(i));
						FairInfectionFound = true;
						break;
					}
				}
				
				//Unfair infection
				if(!FairInfectionFound)
				{
					for(int i = 0; i < MAX_CLIENTS; i ++)
					{
						CPlayer *pPlayer = GameServer()->m_apPlayers[i];
						
						if(!pPlayer) continue;
						if(pPlayer->GetTeam() == TEAM_SPECTATORS) continue;
						if(pPlayer->IsInfected()) continue;
						
						if(random < InfectionProb)
						{
							Server()->InfecteClient(i);
							GameServer()->m_apPlayers[i]->StartInfection();
							m_InfectedCounter++;
							m_HumanCounter--;
							
							GameServer()->SendChatTarget_Language_s(-1, "%s has been infected", Server()->ClientName(i));
							
							break;
						}
						else
						{
							random -= InfectionProb;
						}
					}
				}
			}
		}
		else
		{
			for(int i = 0; i < MAX_CLIENTS; i ++)
			{
				CPlayer *pPlayer = GameServer()->m_apPlayers[i];
				
				if(!pPlayer) continue;
				if(pPlayer->GetTeam() == TEAM_SPECTATORS)
				{
					pPlayer->SetClass(PLAYERCLASS_NONE);
				}
			}
		}
		
		//Win check
		if(m_InfectedStarted && m_HumanCounter == 0 && m_InfectedCounter > 1)
		{			
			float RoundDuration = static_cast<float>((Server()->Tick()-m_RoundStartTick)/((float)Server()->TickSpeed()))/60.0f;
			int Minutes = static_cast<int>(RoundDuration);
			int Seconds = static_cast<int>((RoundDuration - Minutes)*60.0f);
			
			GameServer()->SendChatTarget_Language_ii(-1, "Infected won the round in %i:%02i minutes", Minutes, Seconds);
			
			EndRound();
		}
		
		//Start the final explosion if the time is over
		if(m_InfectedStarted && !m_ExplosionStarted && g_Config.m_SvTimelimit > 0 && (Server()->Tick()-m_RoundStartTick) >= g_Config.m_SvTimelimit*Server()->TickSpeed()*60)
		{
			for(CCharacter *p = (CCharacter*) GameServer()->m_World.FindFirst(CGameWorld::ENTTYPE_CHARACTER); p; p = (CCharacter *)p->TypeNext())
			{
				if(p->IsInfected())
				{
					GameServer()->SendEmoticon(p->GetPlayer()->GetCID(), EMOTICON_GHOST);
				}
				else
				{
					GameServer()->SendEmoticon(p->GetPlayer()->GetCID(), EMOTICON_EYES);
				}
			}
			m_ExplosionStarted = true;
		}
		
		//Do the final explosion
		if(m_ExplosionStarted)
		{		
			bool NewExplosion = false;
			
			for(int j=0; j<m_MapHeight; j++)
			{
				for(int i=0; i<m_MapWidth; i++)
				{
					if((m_GrowingMap[j*m_MapWidth+i] & 1) && (
						(i > 0 && m_GrowingMap[j*m_MapWidth+i-1] & 2) ||
						(i < m_MapWidth-1 && m_GrowingMap[j*m_MapWidth+i+1] & 2) ||
						(j > 0 && m_GrowingMap[(j-1)*m_MapWidth+i] & 2) ||
						(j < m_MapHeight-1 && m_GrowingMap[(j+1)*m_MapWidth+i] & 2)
					))
					{
						NewExplosion = true;
						m_GrowingMap[j*m_MapWidth+i] |= 8;
						m_GrowingMap[j*m_MapWidth+i] &= ~1;
						if(rand()%10 == 0)
						{
							vec2 TilePos = vec2(16.0f, 16.0f) + vec2(i*32.0f, j*32.0f);
							GameServer()->CreateExplosion(TilePos, -1, WEAPON_GAME, true);
							GameServer()->CreateSound(TilePos, SOUND_GRENADE_EXPLODE);
						}
					}
				}
			}
			
			for(int j=0; j<m_MapHeight; j++)
			{
				for(int i=0; i<m_MapWidth; i++)
				{
					if(m_GrowingMap[j*m_MapWidth+i] & 8)
					{
						m_GrowingMap[j*m_MapWidth+i] &= ~8;
						m_GrowingMap[j*m_MapWidth+i] |= 2;
					}
				}
			}
			
			for(CCharacter *p = (CCharacter*) GameServer()->m_World.FindFirst(CGameWorld::ENTTYPE_CHARACTER); p; p = (CCharacter *)p->TypeNext())
			{
				if(!p->IsInfected())
					continue;
				
				int tileX = static_cast<int>(round(p->m_Pos.x))/32;
				int tileY = static_cast<int>(round(p->m_Pos.y))/32;
				
				if(tileX < 0) tileX = 0;
				if(tileX >= m_MapWidth) tileX = m_MapWidth-1;
				if(tileY < 0) tileY = 0;
				if(tileY >= m_MapHeight) tileY = m_MapHeight-1;
				
				if(m_GrowingMap[tileY*m_MapWidth+tileX] & 2 && p->GetPlayer())
				{
					p->Die(p->GetPlayer()->GetCID(), WEAPON_GAME);
				}
			}
		
			//If no more explosions, game over, decide who win
			if(!NewExplosion)
			{
				if(m_HumanCounter)
				{
					if(m_HumanCounter <= 1)
					{
						GameServer()->SendChatTarget_Language(-1, "One human won the round");
					}
					else
					{
						GameServer()->SendChatTarget_Language_i(-1, "%i humans won the round", m_HumanCounter);
					}
					
					for(int i = 0; i < MAX_CLIENTS; i ++)
					{
						CPlayer *pPlayer = GameServer()->m_apPlayers[i];
						
						if(!pPlayer) continue;
						if(pPlayer->GetTeam() == TEAM_SPECTATORS) continue;
						
						if(!pPlayer->IsInfected())
						{
							pPlayer->IncreaseScore(5);
							pPlayer->m_WinAsHuman++;
							
							GameServer()->SendChatTarget_Language(i, "You have survived, +5 points");
						}
					}
				}
				else
				{
					GameServer()->SendChatTarget_Language_ii(-1, "Infected won the round in %i:%02i minutes", g_Config.m_SvTimelimit, 0);
				}
				
				EndRound();
			}
		}
	}
	else
	{
		m_RoundStartTick = Server()->Tick();
	}
}
Ejemplo n.º 16
0
void CGameStats::OnGameplayEvent(IEntity *pEntity, const GameplayEvent &event)
{
/*	for(int i=0;i<gEventNamesNum;++i)
	{
		if(gEventNames[i].key == event.event)
		{
			CryLog("GameStats : Event %s",gEventNames[i].name);
		}
	}*/

	int e_id = pEntity ? (int) pEntity->GetId() : 0;
	switch(event.event)
	{
	case eGE_GameStarted:
		StartGame(event.value!=0);
		break;
	case eGE_GameEnd:
		EndGame(event.value!=0);
		break;
	case eGE_SuddenDeath:
		SuddenDeath(event.value!=0);
		break;
	case eGE_RoundEnd:
		EndRound(event.value!=0, atoi(event.description));
		break;
	case eGE_Renamed:
		SetName(e_id, event.description);
		break;
	case eGE_Scored:
		SetScore(e_id, event.description, (int)event.value);
		break;
	case eGE_Kill:
		OnKill(e_id, (EntityId*)event.extra);
		if(pEntity)
			ProcessPlayerStat(pEntity,event);
		break;
	case eGE_Death:
		OnDeath(e_id, (int)(TRUNCATE_PTR)event.extra);
		if(pEntity)
			ProcessPlayerStat(pEntity,event);
		break;
  case eGE_WeaponShot:
	case eGE_WeaponHit:
	case eGE_SuitModeChanged:
	case eGE_WeaponMelee:
	case eGE_LeftVehicle:
	case eGE_EnteredVehicle:
	case eGE_ItemSelected:
	case eGE_WeaponReload:
	case eGE_Damage:
	case eGE_Revive:
	case eGE_WeaponFireModeChanged:
	case eGE_ZoomedIn:
	case eGE_ZoomedOut:
		if(pEntity)
			ProcessPlayerStat(pEntity,event);
		break;
	case eGE_Connected:
		{
			bool restored = event.value!=0.0f;

			struct SExtraData
			{
					int status[2];
			};

			SExtraData* pExtra = static_cast<SExtraData*>(event.extra);
			NewPlayer(e_id, pExtra->status[0], pExtra->status[1]!=0, restored);
		}
		break;
  case eGE_ChangedTeam:
    SetTeam(e_id,(int)event.value);
    break;
  case eGE_Spectator:
    SetSpectator(e_id,(int)event.value);
		if(pEntity)
			ProcessPlayerStat(pEntity,event);
    break;
	case eGE_Disconnected:
		RemovePlayer(e_id, event.value!=0);
		break;
	case eGE_ScoreReset:
		ResetScore(e_id);
		break;
  case eGE_Rank:
    SetRank(e_id,(int)event.value);
    break;
	case eGE_GameReset:
		GameReset();
		break;
	default:
		break;
	}
}
Ejemplo n.º 17
0
void CGameController_iLMS::DoWincheck()
{
	if(m_GameOverTick == -1)
	{
		int Players = 0, Players_Spec = 0, Players_SpecExplicit = 0;
		
		for(int i = 0; i < MAX_CLIENTS; i++)
		{
			if(GameServer()->m_apPlayers[i])
			{
				Players++;
				if(GameServer()->m_apPlayers[i]->GetTeam() == TEAM_SPECTATORS)
					Players_Spec++;
				if(GameServer()->m_apPlayers[i]->m_SpecExplicit == 1)
					Players_SpecExplicit++;
			}
		}
		
		m_PlayerCount = Players;
		m_ActivePlayerCount = Players - Players_Spec;
		
		/*if(m_ActivePlayerCount >= g_Config.m_SvzCatchMinPlayers)
		{
			m_iLMS_enabled = true;
		}
		else if (g_Config.m_SvAutoIdm == 1)
		{
			m_iLMS_enabled = true;
			for(int i = 0; i < MAX_CLIENTS; i++)
			{
				if(GameServer()->m_apPlayers[i])
				{
					if(GameServer()->m_apPlayers[i]->m_CaughtBy != CPlayer::ZCATCH_NOT_CAUGHT)
					{
						GameServer()->m_apPlayers[i]->m_CaughtBy = CPlayer::ZCATCH_NOT_CAUGHT;
						GameServer()->m_apPlayers[i]->SetTeamDirect(GameServer()->m_pController->ClampTeam(1));
					}
				}
			}
		}*/
		
    m_iLMS_enabled = true;
		if(Players == 1)
		{
			//Do nothing
		}
		else if((Players - Players_Spec == 1) && (Players != Players_Spec) && (Players - Players_SpecExplicit != 1))
		{
			for(int i = 0; i < MAX_CLIENTS; i++)
			{
				if(GameServer()->m_apPlayers[i] && GameServer()->m_apPlayers[i]->GetTeam() != TEAM_SPECTATORS)
				{
          //GameServer()->m_apPlayers[i]->m_Score += g_Config.m_SvBonus;
          GameServer()->m_apPlayers[i]->m_Score = m_points;
        }
			}
			EndRound();
		}

		IGameController::DoWincheck(); //do also usual wincheck
	}
}
void CGameControllerRalla3::Tick()
{
    if (g_Game.Keyboard.KeyPressed)
    {
        switch(g_Game.Keyboard.Key)
        {
            case 13:
                if (g_Game.m_WorldPaused && m_PlayerWin != PLAYER_NULL)
                {
                    g_Game.m_GameState = CGameContext::GAME_MENU;
                    return;
                }
                break;
        }
    }

    if (!g_Game.m_WorldPaused)
    {
        /** Captar Raton **/
        if (g_Game.Mouse.m_isPressed)
        {
            vec2 m_MousePos = vec2(mousex(), mousey());

            for (int i=0; i<3;i++)
            {
                for (int o=0;o<3;o++)
                {
                    if (m_MousePos.x > g_Game.GetScreenW()/2-dimTX/2 + dimTX/3*o && m_MousePos.x <= g_Game.GetScreenW()/2-dimTX/2 + dimTX/3*(o+1)
                        && m_MousePos.y >= 20+((dimTY/3)*i) && m_MousePos.y <= 20+((dimTY/3)*(i+1)))
                    {
                        if (v_GameTable[i][o] != PLAYER_NULL)
                        {
                            m_Indicator.m_Timer = GetTickCount() + 1000 * 0.15f;
                            m_Indicator.m_Pos = vec2(g_Game.GetScreenW()/2-dimTX/2 + dimTX/3*o, 20+((dimTY/3)*i));
                            continue;
                        }

                        v_GameTable[i][o] = m_ActivePlayer;
                        CheckWinner(m_ActivePlayer);

                        if (m_CPU)
                            m_ActivePlayer = (m_ActivePlayer==PLAYER_1)?PLAYER_CPU:PLAYER_1;
                        else
                            m_ActivePlayer = (m_ActivePlayer==PLAYER_1)?PLAYER_2:PLAYER_1;
                    }
                }
            }
            clearmouseclick(WM_LBUTTONDOWN);
        }

        //Comprobar Empate
        if (m_PlayerWin == PLAYER_NULL)
        {
            bool draw=true;
            for (int i=0; i<3; i++)
            {
                for (int o=0; o<3; o++)
                    if (v_GameTable[i][o] == PLAYER_NULL)
                    {
                        draw=false;
                        break;
                    }
            }
            if (draw)
            {
                m_PlayerWin = PLAYER_DRAW;
                EndRound();
            }
        }

        //Jugada de la Makina
        if (m_PlayerWin == PLAYER_NULL && m_ActivePlayer == PLAYER_CPU)
        {
            int i, o;
            bool error = true;
            for (int i=rand()%3; i<3; i++)
            {
                for (int o=rand()%3; o<3; o++)
                {
                    if (v_GameTable[i][o] == PLAYER_NULL)
                    {
                        if ((i-1 > 0 && (v_GameTable[i-1][o] == PLAYER_NULL || v_GameTable[i-1][o] == PLAYER_CPU))
                            || (i+i<3 && (v_GameTable[i+1][o] == PLAYER_NULL || v_GameTable[i+1][o] == PLAYER_CPU))
                            || (o-1 > 0 && (v_GameTable[i][o-1] == PLAYER_NULL || v_GameTable[i][o-1] == PLAYER_CPU))
                            || (o+1 > 0 && (v_GameTable[i][o+1] == PLAYER_NULL || v_GameTable[i][o+1] == PLAYER_CPU))
                            || (i-1>0 && o-1>0 && (v_GameTable[i-1][o-1] == PLAYER_NULL || v_GameTable[i-1][o-1] == PLAYER_CPU))
                            || (i+1<3 && o-1>0 && (v_GameTable[i+1][o-1] == PLAYER_NULL || v_GameTable[i+1][o-1] == PLAYER_CPU))
                            || (i+1<3 && o+1<3 && (v_GameTable[i+1][o+1] == PLAYER_NULL || v_GameTable[i+1][o+1] == PLAYER_CPU))
                            || (i-1>0 && o+1<3 && (v_GameTable[i-1][o+1] == PLAYER_NULL || v_GameTable[i-1][o+1] == PLAYER_CPU)))
                        {
                            v_GameTable[i][o]=PLAYER_CPU;
                            error = false;
                            break;
                        }
                    }
                }

                if (!error)
                    break;
            }

            if (error)
            {
                do {
                    i=rand() % 3;
                    o=rand() % 3;
                } while (v_GameTable[i][o] != PLAYER_NULL);

                v_GameTable[i][o]=PLAYER_CPU;
            }

            CheckWinner(PLAYER_CPU);
            m_ActivePlayer = PLAYER_1;
        }

        //Resetear Color Indicador
        if (GetTickCount() < m_Indicator.m_Timer)
        {
            setfillstyle(SOLID_FILL, RED);
            int points[4*2];
            points[0]=static_cast<int>(m_Indicator.m_Pos.x);
            points[1]=static_cast<int>(m_Indicator.m_Pos.y);
            points[2]=static_cast<int>(m_Indicator.m_Pos.x) + dimTX/3;
            points[3]=points[1];
            points[4]=points[2];
            points[5]=static_cast<int>(m_Indicator.m_Pos.y) + dimTY/3;
            points[6]=points[0];
            points[7]=points[5];
            fillpoly(4, points);
        }
    }

    /** Dibujar Tablero **/
    int offsetx = dimTX/3;
    int offsety = dimTY/3;

    setcolor(DARKGRAY);
    for (int i=offsety; i<dimTY-dimTY/3; i+=offsety)
    {
        moveto(g_Game.GetScreenW()/2-dimTX/2, i+20);
        lineto(g_Game.GetScreenW()/2-dimTX/2+dimTX, i+20);
    }
    for (int i=offsetx; i<dimTX-dimTX/3; i+=offsetx)
    {
        moveto(g_Game.GetScreenW()/2-dimTX/2+i, 1+20);
        lineto(g_Game.GetScreenW()/2-dimTX/2+i, dimTY+20);
    }
    setcolor(WHITE);
    //Fichas
    for (int i=0;i<3;i++)
    {
        for (int o=0;o<3;o++)
        {
            if (v_GameTable[i][o] == PLAYER_NULL)
                continue;

            if (v_GameTable[i][o] == PLAYER_1)
            {
                circle(g_Game.GetScreenW()/2-dimTX/2 + dimTX/3*(o+1) - ((dimTX/3)/2), 20+dimTY/3*(i+1) - (dimTY/3)/2, 25);
            }
            else
            {
                moveto(g_Game.GetScreenW()/2-dimTX/2 + dimTX/3*(o+1)-((dimTX/3)/2) -25, 20+dimTY/3*(i+1)-(dimTY/3)/2 -25);
                lineto(g_Game.GetScreenW()/2-dimTX/2 + dimTX/3*(o+1)-((dimTX/3)/2) +25, 20+dimTY/3*(i+1)-(dimTY/3)/2 +25);
                moveto(g_Game.GetScreenW()/2-dimTX/2 + dimTX/3*(o+1)-((dimTX/3)/2) +25, 20+dimTY/3*(i+1)-(dimTY/3)/2 -25);
                lineto(g_Game.GetScreenW()/2-dimTX/2 + dimTX/3*(o+1)-((dimTX/3)/2) -25, 20+dimTY/3*(i+1)-(dimTY/3)/2 +25);
            }
        }
    }
}
Ejemplo n.º 19
0
void CGameControllerMOD::Tick()
{
	IGameController::Tick();
	
	//Check session
	{
		CPlayerIterator<PLAYERITER_ALL> Iter(GameServer()->m_apPlayers);
		while(Iter.Next())
		{
			//Update session
			IServer::CClientSession* pSession = Server()->GetClientSession(Iter.ClientID());
			if(pSession)
			{
				if(!Server()->GetClientMemory(Iter.ClientID(), CLIENTMEMORY_SESSION_PROCESSED))
				{
					//The client already participated to this round,
					//and he exit the game as infected.
					//To avoid cheating, we assign to him the same class again.
					if(
						m_InfectedStarted &&
						pSession->m_RoundId == m_RoundId &&
						pSession->m_Class > END_HUMANCLASS
					)
					{
						Iter.Player()->SetClass(pSession->m_Class);
					}
					
					Server()->SetClientMemory(Iter.ClientID(), CLIENTMEMORY_SESSION_PROCESSED, true);
				}
				
				pSession->m_Class = Iter.Player()->GetClass();
				pSession->m_RoundId = GameServer()->m_pController->GetRoundId();
			}
		}
	}
	
	UpdatePlayerCounter();
	
	m_InfectedStarted = false;
	
	//If the game can start ...
	if(m_GameOverTick == -1 && m_HumanCounter + m_InfectedCounter >= 2)
	{
		//If the infection started
		if(IsInfectionStarted())
		{
			bool StartInfectionTrigger = (m_RoundStartTick + Server()->TickSpeed()*10 == Server()->Tick());
			
			GameServer()->EnableTargetToKill();
			
			if(m_pHeroFlag)
				m_pHeroFlag->Show();
			
			m_InfectedStarted = true;
	
			CPlayerIterator<PLAYERITER_INGAME> Iter(GameServer()->m_apPlayers);
			while(Iter.Next())
			{
				if(Iter.Player()->GetClass() == PLAYERCLASS_NONE)
				{
					if(StartInfectionTrigger)
					{
						Iter.Player()->SetClass(ChooseHumanClass(Iter.Player()));
						if(Iter.Player()->GetCharacter())
							Iter.Player()->GetCharacter()->IncreaseArmor(10);
					}
					else
						Iter.Player()->StartInfection();
				}
			}
			
			int NumNeededInfection = m_NumFirstInfected;
			
			while(m_InfectedCounter < NumNeededInfection)
			{
				float InfectionProb = 1.0/static_cast<float>(m_HumanCounter);
				float random = frandom();
				
				//Fair infection
				bool FairInfectionFound = false;
				
				Iter.Reset();
				while(Iter.Next())
				{
					if(Iter.Player()->IsInfected()) continue;
					
					if(!Server()->IsClientInfectedBefore(Iter.ClientID()))
					{
						Server()->InfecteClient(Iter.ClientID());
						Iter.Player()->StartInfection();
						m_InfectedCounter++;
						m_HumanCounter--;
						
						GameServer()->SendChatTarget_Localization(-1, CHATCATEGORY_INFECTION, _("{str:VictimName} has been infected"),
							"VictimName", Server()->ClientName(Iter.ClientID()),
							NULL
						);
						FairInfectionFound = true;
						break;
					}
				}
				
				//Unfair infection
				if(!FairInfectionFound)
				{
					Iter.Reset();
					while(Iter.Next())
					{
						if(Iter.Player()->IsInfected()) continue;
						
						if(random < InfectionProb)
						{
							Server()->InfecteClient(Iter.ClientID());
							Iter.Player()->StartInfection();
							m_InfectedCounter++;
							m_HumanCounter--;
							
							GameServer()->SendChatTarget_Localization(-1, CHATCATEGORY_INFECTION, _("{str:VictimName} has been infected"), "VictimName", Server()->ClientName(Iter.ClientID()), NULL);
							
							break;
						}
						else
						{
							random -= InfectionProb;
						}
					}
				}
			}
		}
		else
		{
			if(m_pHeroFlag)
				m_pHeroFlag->Show();
			
			GameServer()->DisableTargetToKill();
			
			CPlayerIterator<PLAYERITER_SPECTATORS> IterSpec(GameServer()->m_apPlayers);
			while(IterSpec.Next())
			{
				IterSpec.Player()->SetClass(PLAYERCLASS_NONE);
			}
		}
		
		//Win check
		if(m_InfectedStarted && m_HumanCounter == 0 && m_InfectedCounter > 1)
		{			
			int Seconds = (Server()->Tick()-m_RoundStartTick)/((float)Server()->TickSpeed());
			
			GameServer()->SendChatTarget_Localization(-1, CHATCATEGORY_INFECTED, _("Infected won the round in {sec:RoundDuration}"), "RoundDuration", &Seconds, NULL);
			
			EndRound();
		}
		
		//Start the final explosion if the time is over
		if(m_InfectedStarted && !m_ExplosionStarted && g_Config.m_SvTimelimit > 0 && (Server()->Tick()-m_RoundStartTick) >= g_Config.m_SvTimelimit*Server()->TickSpeed()*60)
		{
			for(CCharacter *p = (CCharacter*) GameServer()->m_World.FindFirst(CGameWorld::ENTTYPE_CHARACTER); p; p = (CCharacter *)p->TypeNext())
			{
				if(p->IsInfected())
				{
					GameServer()->SendEmoticon(p->GetPlayer()->GetCID(), EMOTICON_GHOST);
				}
				else
				{
					GameServer()->SendEmoticon(p->GetPlayer()->GetCID(), EMOTICON_EYES);
				}
			}
			m_ExplosionStarted = true;
		}
		
		//Do the final explosion
		if(m_ExplosionStarted)
		{		
			bool NewExplosion = false;
			
			for(int j=0; j<m_MapHeight; j++)
			{
				for(int i=0; i<m_MapWidth; i++)
				{
					if((m_GrowingMap[j*m_MapWidth+i] & 1) && (
						(i > 0 && m_GrowingMap[j*m_MapWidth+i-1] & 2) ||
						(i < m_MapWidth-1 && m_GrowingMap[j*m_MapWidth+i+1] & 2) ||
						(j > 0 && m_GrowingMap[(j-1)*m_MapWidth+i] & 2) ||
						(j < m_MapHeight-1 && m_GrowingMap[(j+1)*m_MapWidth+i] & 2)
					))
					{
						NewExplosion = true;
						m_GrowingMap[j*m_MapWidth+i] |= 8;
						m_GrowingMap[j*m_MapWidth+i] &= ~1;
						if(rand()%10 == 0)
						{
							vec2 TilePos = vec2(16.0f, 16.0f) + vec2(i*32.0f, j*32.0f);
							GameServer()->CreateExplosion(TilePos, -1, WEAPON_GAME, true);
							GameServer()->CreateSound(TilePos, SOUND_GRENADE_EXPLODE);
						}
					}
				}
			}
			
			for(int j=0; j<m_MapHeight; j++)
			{
				for(int i=0; i<m_MapWidth; i++)
				{
					if(m_GrowingMap[j*m_MapWidth+i] & 8)
					{
						m_GrowingMap[j*m_MapWidth+i] &= ~8;
						m_GrowingMap[j*m_MapWidth+i] |= 2;
					}
				}
			}
			
			for(CCharacter *p = (CCharacter*) GameServer()->m_World.FindFirst(CGameWorld::ENTTYPE_CHARACTER); p; p = (CCharacter *)p->TypeNext())
			{
				if(!p->IsInfected())
					continue;
				
				int tileX = static_cast<int>(round(p->m_Pos.x))/32;
				int tileY = static_cast<int>(round(p->m_Pos.y))/32;
				
				if(tileX < 0) tileX = 0;
				if(tileX >= m_MapWidth) tileX = m_MapWidth-1;
				if(tileY < 0) tileY = 0;
				if(tileY >= m_MapHeight) tileY = m_MapHeight-1;
				
				if(m_GrowingMap[tileY*m_MapWidth+tileX] & 2 && p->GetPlayer())
				{
					p->Die(p->GetPlayer()->GetCID(), WEAPON_GAME);
				}
			}
		
			//If no more explosions, game over, decide who win
			if(!NewExplosion)
			{
				if(m_HumanCounter)
				{
					GameServer()->SendChatTarget_Localization_P(-1, CHATCATEGORY_HUMANS, m_HumanCounter, _P("One human won the round", "{int:NumHumans} humans won the round"), "NumHumans", &m_HumanCounter, NULL);
					
					CPlayerIterator<PLAYERITER_INGAME> Iter(GameServer()->m_apPlayers);
					while(Iter.Next())
					{
						if(!Iter.Player()->IsInfected())
						{
							//TAG_SCORE
							Server()->RoundStatistics()->OnScoreEvent(Iter.ClientID(), SCOREEVENT_HUMAN_SURVIVE, Iter.Player()->GetClass());
							Server()->RoundStatistics()->SetPlayerAsWinner(Iter.ClientID());
							GameServer()->SendScoreSound(Iter.ClientID());
							Iter.Player()->m_WinAsHuman++;
							
							GameServer()->SendChatTarget_Localization(Iter.ClientID(), CHATCATEGORY_SCORE, _("You have survived, +5 points"), NULL);
						}
					}
				}
				else
				{
					int Seconds = g_Config.m_SvTimelimit*60;
					GameServer()->SendChatTarget_Localization(-1, CHATCATEGORY_INFECTED, _("Infected won the round in {sec:RoundDuration}"), "RoundDuration", &Seconds, NULL);
				}
				
				EndRound();
			}
		}
	}
	else
	{
		GameServer()->DisableTargetToKill();
		
		if(m_pHeroFlag)
			m_pHeroFlag->Show();
		
		m_RoundStartTick = Server()->Tick();
	}
}