Skip to content

Commit

Permalink
reworked some methods and made zombies spawning better
Browse files Browse the repository at this point in the history
  • Loading branch information
AssassinTee committed Feb 2, 2019
1 parent 00c7daa commit dda7e10
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 17 deletions.
45 changes: 29 additions & 16 deletions src/game/server/wave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,19 @@ void CWave::StartWave()
{
GetEndlessWave();
}

//Fill in wave vector
ClearZombies();
for(int i = 0; i < 13; ++i)
else
{
int value = j.value(m_JsonZombieNames[i], 0);
m_vWave.push_back(value);
m_ZombLeft+= value;
//Fill in wave vector
ClearZombies();
for(int i = 0; i < 13; ++i)
{
int value = j.value(m_JsonZombieNames[i], 0);
m_vWave.push_back(value);
m_ZombLeft+= value;
}
m_ZombAlive = m_ZombLeft;
}
m_ZombAlive = m_ZombLeft;
DoWaveStartMessage();
}

void CWave::GetEndlessWave()
Expand Down Expand Up @@ -109,18 +112,28 @@ void CWave::OnZombieKill()
void CWave::DoZombMessage()
{
std::stringstream ss;
if(!m_ZombAlive)
if(m_ZombAlive == 0)
{
ss << "Wave " << m_Wave << " defeated!";
}
else if(m_ZombAlive <= 5 || !(m_ZombAlive%10))
{
ss << "Wave " << m_Wave << " started with " << m_ZombAlive << " Zombies!";
GameServer()->SendBroadcast(ss.str().c_str(), -1);
return;

ss << "Wave " << m_Wave << ": " << m_ZombAlive << " zombie"
<< (m_ZombAlive == 1 ? " is" : "s are") << " left";
}
if(m_ZombAlive <= 5 || !(m_ZombAlive%10))
else
{
ss << "Wave " << m_Wave << ": " << m_ZombAlive << "zombie"
<< (m_ZombAlive == 1 ? " is" : "s are") << " left";
GameServer()->SendChat(-1, CHAT_ALL, -1, ss.str().c_str());
return;
}
GameServer()->SendChat(-1, CHAT_ALL, -1, ss.str().c_str());
}

void CWave::DoWaveStartMessage()
{
std::stringstream ss;
ss << "Wave " << m_Wave << " started with " << m_ZombAlive << " Zombies!";
GameServer()->SendBroadcast(ss.str().c_str(), -1);
}

void CWave::DoLifeMessage(int Life)
Expand Down
3 changes: 2 additions & 1 deletion src/game/server/wave.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@ class CWave
void OnZombieKill();
int GetZombAlive(){return m_ZombAlive;}

void DoZombMessage();
void DoWaveStartMessage();
void DoLifeMessage(int Life);

private:
CGameContext *GameServer() const { return m_pGameServer; }
void ReadWave(std::string filename);
void GetEndlessWave();
void DoZombMessage();

nlohmann::json m_Json;
const std::string m_JsonZombieNames[13];
Expand Down

0 comments on commit dda7e10

Please sign in to comment.