mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 22:48:18 +00:00
added rounds, wincheck and start equipment for survival
This commit is contained in:
parent
98c18ebade
commit
340ac89967
|
@ -231,12 +231,27 @@ int IGameController::OnCharacterDeath(class CCharacter *pVictim, class CPlayer *
|
|||
|
||||
void IGameController::OnCharacterSpawn(class CCharacter *pChr)
|
||||
{
|
||||
// default health
|
||||
pChr->IncreaseHealth(10);
|
||||
if(m_GameFlags&GAMEFLAG_SURVIVAL)
|
||||
{
|
||||
// give start equipment
|
||||
pChr->IncreaseHealth(10);
|
||||
pChr->IncreaseArmor(5);
|
||||
|
||||
// give default weapons
|
||||
pChr->GiveWeapon(WEAPON_HAMMER, -1);
|
||||
pChr->GiveWeapon(WEAPON_GUN, 10);
|
||||
pChr->GiveWeapon(WEAPON_HAMMER, -1);
|
||||
pChr->GiveWeapon(WEAPON_GUN, 10);
|
||||
pChr->GiveWeapon(WEAPON_SHOTGUN, 10);
|
||||
pChr->GiveWeapon(WEAPON_GRENADE, 10);
|
||||
pChr->GiveWeapon(WEAPON_RIFLE, 5);
|
||||
}
|
||||
else
|
||||
{
|
||||
// default health
|
||||
pChr->IncreaseHealth(10);
|
||||
|
||||
// give default weapons
|
||||
pChr->GiveWeapon(WEAPON_HAMMER, -1);
|
||||
pChr->GiveWeapon(WEAPON_GUN, 10);
|
||||
}
|
||||
}
|
||||
|
||||
bool IGameController::OnEntity(int Index, vec2 Pos)
|
||||
|
@ -347,7 +362,7 @@ void IGameController::OnReset()
|
|||
}
|
||||
|
||||
// game
|
||||
void IGameController::DoWincheck()
|
||||
void IGameController::DoWincheckMatch()
|
||||
{
|
||||
if(IsTeamplay())
|
||||
{
|
||||
|
@ -397,6 +412,11 @@ void IGameController::EndMatch()
|
|||
SetGameState(GS_GAMEOVER, 10);
|
||||
}
|
||||
|
||||
void IGameController::EndRound()
|
||||
{
|
||||
SetGameState(GS_ROUNDOVER, 10);
|
||||
}
|
||||
|
||||
void IGameController::ResetGame()
|
||||
{
|
||||
GameServer()->m_World.m_ResetRequested = true;
|
||||
|
@ -479,6 +499,17 @@ void IGameController::SetGameState(int GameState, int Seconds)
|
|||
}
|
||||
}
|
||||
break;
|
||||
case GS_ROUNDOVER:
|
||||
{
|
||||
if(GetGameState() != GS_WARMUP && GetGameState() != GS_PAUSED)
|
||||
{
|
||||
m_GameState = GS_ROUNDOVER;
|
||||
m_GameStateTimer = Seconds*Server()->TickSpeed();
|
||||
m_SuddenDeath = 0;
|
||||
GameServer()->m_World.m_Paused = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GS_GAMEOVER:
|
||||
{
|
||||
if(GetGameState() != GS_WARMUP && GetGameState() != GS_PAUSED)
|
||||
|
@ -587,6 +618,15 @@ void IGameController::Tick()
|
|||
else
|
||||
++m_GameStartTick;
|
||||
break;
|
||||
case GS_ROUNDOVER:
|
||||
if(m_GameStateTimer == 0)
|
||||
{
|
||||
ResetGame();
|
||||
DoWincheckMatch();
|
||||
SetGameState(GS_STARTCOUNTDOWN, TIMER_STARTCOUNTDOWN);
|
||||
m_StartCountdownReset = false;
|
||||
}
|
||||
break;
|
||||
case GS_GAMEOVER:
|
||||
if(m_GameStateTimer == 0)
|
||||
{
|
||||
|
@ -615,7 +655,12 @@ void IGameController::Tick()
|
|||
|
||||
// win check
|
||||
if(GetGameState() == GS_GAME && !GameServer()->m_World.m_ResetRequested)
|
||||
DoWincheck();
|
||||
{
|
||||
if(m_GameFlags&GAMEFLAG_SURVIVAL)
|
||||
DoWincheckRound();
|
||||
else
|
||||
DoWincheckMatch();
|
||||
}
|
||||
}
|
||||
|
||||
// info
|
||||
|
|
|
@ -39,8 +39,11 @@ class IGameController
|
|||
int m_GameStateTimer;
|
||||
bool m_StartCountdownReset;
|
||||
|
||||
virtual void DoWincheck();
|
||||
virtual void DoWincheckMatch();
|
||||
virtual void DoWincheckRound() {};
|
||||
void ResetGame();
|
||||
void SetGameState(int GameState, int Seconds=0);
|
||||
void StartMatch();
|
||||
|
||||
// map
|
||||
char m_aMapWish[128];
|
||||
|
@ -82,8 +85,7 @@ protected:
|
|||
int m_aTeamscore[NUM_TEAMS];
|
||||
|
||||
void EndMatch();
|
||||
void ResetGame();
|
||||
void StartMatch();
|
||||
void EndRound();
|
||||
|
||||
// info
|
||||
int m_GameFlags;
|
||||
|
@ -140,6 +142,7 @@ public:
|
|||
GS_STARTCOUNTDOWN,
|
||||
GS_GAME,
|
||||
GS_PAUSED,
|
||||
GS_ROUNDOVER,
|
||||
GS_GAMEOVER,
|
||||
|
||||
TIMER_INFINITE = -1,
|
||||
|
|
|
@ -85,7 +85,7 @@ bool CGameControllerCTF::OnEntity(int Index, vec2 Pos)
|
|||
}
|
||||
|
||||
// game
|
||||
void CGameControllerCTF::DoWincheck()
|
||||
void CGameControllerCTF::DoWincheckMatch()
|
||||
{
|
||||
// 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)) ||
|
||||
|
|
|
@ -13,7 +13,7 @@ class CGameControllerCTF : public IGameController
|
|||
// game
|
||||
class CFlag *m_apFlags[2];
|
||||
|
||||
virtual void DoWincheck();
|
||||
virtual void DoWincheckMatch();
|
||||
|
||||
public:
|
||||
CGameControllerCTF(class CGameContext *pGameServer);
|
||||
|
|
|
@ -13,6 +13,35 @@ CGameControllerSUR::CGameControllerSUR(class CGameContext *pGameServer) : IGameC
|
|||
m_GameFlags = GAMEFLAG_TEAMS|GAMEFLAG_SURVIVAL;
|
||||
}
|
||||
|
||||
// game
|
||||
void CGameControllerSUR::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]->GetCharacter() && GameServer()->m_apPlayers[i]->GetCharacter()->IsAlive())
|
||||
++Count[GameServer()->m_apPlayers[i]->GetTeam()];
|
||||
}
|
||||
|
||||
if(Count[TEAM_RED]+Count[TEAM_BLUE] == 0 || (g_Config.m_SvTimelimit > 0 && (Server()->Tick()-m_GameStartTick) >= g_Config.m_SvTimelimit*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();
|
||||
}
|
||||
}
|
||||
|
||||
// general
|
||||
void CGameControllerSUR::Snap(int SnappingClient)
|
||||
{
|
||||
|
|
|
@ -9,6 +9,9 @@ class CGameControllerSUR : public IGameController
|
|||
public:
|
||||
CGameControllerSUR(class CGameContext *pGameServer);
|
||||
|
||||
// game
|
||||
virtual void DoWincheckRound();
|
||||
|
||||
// general
|
||||
virtual void Snap(int SnappingClient);
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue