prevent that players respawn in survival

This commit is contained in:
oy 2012-02-15 01:39:59 +01:00
parent 340ac89967
commit 495dc849ba
6 changed files with 38 additions and 6 deletions

View file

@ -1,7 +1,7 @@
from datatypes import *
Emotes = ["NORMAL", "PAIN", "HAPPY", "SURPRISE", "ANGRY", "BLINK"]
PlayerFlags = ["PLAYING", "IN_MENU", "CHATTING", "SCOREBOARD", "READY"]
PlayerFlags = ["PLAYING", "IN_MENU", "CHATTING", "SCOREBOARD", "READY", "DEAD"]
GameFlags = ["TEAMS", "FLAGS", "SURVIVAL"]
GameStateFlags = ["WARMUP", "SUDDENDEATH", "GAMEOVER", "PAUSED", "STARTCOUNTDOWN"]

View file

@ -24,7 +24,7 @@ IGameController::IGameController(CGameContext *pGameServer)
m_GameStateTimer = TIMER_INFINITE;
m_GameStartTick = Server()->Tick();
m_MatchCount = 0;
m_StartCountdownReset = false;
m_StartCountdownReset = true;
m_SuddenDeath = 0;
m_aTeamscore[TEAM_RED] = 0;
m_aTeamscore[TEAM_BLUE] = 0;
@ -242,6 +242,9 @@ void IGameController::OnCharacterSpawn(class CCharacter *pChr)
pChr->GiveWeapon(WEAPON_SHOTGUN, 10);
pChr->GiveWeapon(WEAPON_GRENADE, 10);
pChr->GiveWeapon(WEAPON_RIFLE, 5);
// prevent respawn
pChr->GetPlayer()->m_RespawnDisabled = true;
}
else
{
@ -357,6 +360,7 @@ void IGameController::OnReset()
GameServer()->m_apPlayers[i]->m_Score = 0;
GameServer()->m_apPlayers[i]->m_ScoreStartTick = Server()->Tick();
GameServer()->m_apPlayers[i]->m_IsReadyToPlay = true;
GameServer()->m_apPlayers[i]->m_RespawnDisabled = false;
}
}
}
@ -456,6 +460,7 @@ void IGameController::SetGameState(int GameState, int Seconds)
{
m_GameState = GS_STARTCOUNTDOWN;
m_GameStateTimer = Seconds*Server()->TickSpeed();
m_StartCountdownReset = true;
GameServer()->m_World.m_Paused = true;
}
}
@ -464,7 +469,6 @@ void IGameController::SetGameState(int GameState, int Seconds)
{
m_GameState = GS_GAME;
m_GameStateTimer = TIMER_INFINITE;
m_StartCountdownReset = true;
SetPlayersReadyState(true);
GameServer()->m_World.m_Paused = false;
}
@ -875,6 +879,19 @@ void IGameController::EvaluateSpawnType(CSpawnEval *pEval, int Type) const
}
}
bool IGameController::GetStartRespawnState() const
{
if(m_GameFlags&GAMEFLAG_SURVIVAL)
{
if(GetGameState() == GS_GAME)
return true;
else
return false;
}
else
return false;
}
// team
bool IGameController::CanChangeTeam(CPlayer *pPlayer, int JoinTeam) const
{
@ -943,6 +960,8 @@ void IGameController::DoTeamChange(CPlayer *pPlayer, int Team, bool DoChatMsg)
m_UnbalancedTick = TBALANCE_CHECK;
pPlayer->m_IsReadyToPlay = GetGameState() != GS_WARMUP && GetGameState() != GS_PAUSED;
if(m_GameFlags&GAMEFLAG_SURVIVAL)
pPlayer->m_RespawnDisabled = true;
OnPlayerInfoChange(pPlayer);
}

View file

@ -171,6 +171,7 @@ public:
//spawn
bool CanSpawn(int Team, vec2 *pPos) const;
bool GetStartRespawnState() const;
// team
bool CanJoinTeam(int Team, int NotThisID) const;

View file

@ -20,7 +20,8 @@ void CGameControllerSUR::DoWincheckRound()
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())
(!GameServer()->m_apPlayers[i]->m_RespawnDisabled ||
(GameServer()->m_apPlayers[i]->GetCharacter() && GameServer()->m_apPlayers[i]->GetCharacter()->IsAlive())))
++Count[GameServer()->m_apPlayers[i]->GetTeam()];
}

View file

@ -26,6 +26,7 @@ CPlayer::CPlayer(CGameContext *pGameServer, int ClientID, bool Dummy)
m_Dummy = Dummy;
m_IsReadyToPlay = GameServer()->m_pController->GetGameState() != IGameController::GS_WARMUP &&
GameServer()->m_pController->GetGameState() != IGameController::GS_PAUSED;
m_RespawnDisabled = GameServer()->m_pController->GetStartRespawnState();
}
CPlayer::~CPlayer()
@ -74,7 +75,7 @@ void CPlayer::Tick()
m_ViewPos -= vec2(clamp(m_ViewPos.x-m_LatestActivity.m_TargetX, -500.0f, 500.0f), clamp(m_ViewPos.y-m_LatestActivity.m_TargetY, -400.0f, 400.0f));
if(!m_pCharacter && m_DieTick+Server()->TickSpeed()*3 <= Server()->Tick())
m_Spawning = true;
Respawn();
if(m_pCharacter)
{
@ -135,6 +136,8 @@ void CPlayer::Snap(int SnappingClient)
pPlayerInfo->m_PlayerFlags = m_PlayerFlags&PLAYERFLAG_CHATTING;
if(!GameServer()->m_pController->IsPlayerReadyMode() || m_IsReadyToPlay)
pPlayerInfo->m_PlayerFlags |= PLAYERFLAG_READY;
if(m_RespawnDisabled && (!GetCharacter() || !GetCharacter()->IsAlive()))
pPlayerInfo->m_PlayerFlags |= PLAYERFLAG_DEAD;
pPlayerInfo->m_Latency = SnappingClient == -1 ? m_Latency.m_Min : GameServer()->m_apPlayers[SnappingClient]->m_aActLatency[m_ClientID];
pPlayerInfo->m_Local = 0;
pPlayerInfo->m_ClientID = m_ClientID;
@ -199,7 +202,7 @@ void CPlayer::OnDirectInput(CNetObj_PlayerInput *NewInput)
m_pCharacter->OnDirectInput(NewInput);
if(!m_pCharacter && m_Team != TEAM_SPECTATORS && (NewInput->m_Fire&1))
m_Spawning = true;
Respawn();
// check for activity
if(NewInput->m_Direction || m_LatestActivity.m_TargetX != NewInput->m_TargetX ||
@ -231,6 +234,12 @@ void CPlayer::KillCharacter(int Weapon)
void CPlayer::Respawn()
{
if(m_RespawnDisabled)
{
// todo: enable spectate mode
return;
}
if(m_Team != TEAM_SPECTATORS)
m_Spawning = true;
}

View file

@ -58,6 +58,8 @@ public:
bool m_IsReadyToEnter;
bool m_IsReadyToPlay;
bool m_RespawnDisabled;
//
int m_Vote;
int m_VotePos;