Skip to content

Commit

Permalink
added killingsprees
Browse files Browse the repository at this point in the history
  • Loading branch information
JSaurusRex committed Dec 11, 2023
1 parent 6e2cb1a commit 9d63a0f
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/engine/shared/variables_insta.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ MACRO_CONFIG_INT(SvGrenadeAmmoRegenResetOnFire, sv_grenade_ammo_regen_reset_on_f
MACRO_CONFIG_INT(SvSprayprotection, sv_sprayprotection, 0, 0, 1, CFGFLAG_SERVER, "Spray protection")
MACRO_CONFIG_INT(SvOnlyHookKills, sv_only_hook_kills, 0, 0, 1, CFGFLAG_SERVER, "Only count kills when enemy is hooked")
MACRO_CONFIG_INT(SvKillHook, sv_kill_hook, 0, 0, 1, CFGFLAG_SERVER, "Hook kills")
MACRO_CONFIG_INT(SvKillingspreeKills, sv_killingspree_kills, 0, 0, 20, CFGFLAG_SERVER, "How many kills are needed to be on a killing-spree")
MACRO_CONFIG_INT(SvDamageNeededForKill, sv_damage_needed_for_kill, 4, 0, 5, CFGFLAG_SERVER, "Damage needed to kill")
/*
Expand Down
55 changes: 55 additions & 0 deletions src/game/server/gamemodes/instagib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,61 @@ void CGameControllerInstagib::OnCharacterSpawn(class CCharacter *pChr)
pChr->SetTeleports(&m_TeleOuts, &m_TeleCheckOuts);
}

int CGameControllerInstagib::OnCharacterDeath(class CCharacter *pVictim, class CPlayer *pKiller, int Weapon)
{
if(g_Config.m_SvKillingspreeKills > 0 && pKiller && pVictim)
{
if(pKiller->GetCharacter() && pKiller != pVictim->GetPlayer())
AddSpree(pKiller);
EndSpree(pVictim->GetPlayer(), pKiller);
}

return 0;
}

void CGameControllerInstagib::AddSpree(class CPlayer * pPlayer)
{
pPlayer->m_Spree++;
const int NumMsg = 5;
char aBuf[128];

if(pPlayer->m_Spree % g_Config.m_SvKillingspreeKills == 0)
{
static const char aaSpreeMsg[NumMsg][32] = { "is on a killing spree", "is on a rampage", "is dominating", "is unstoppable", "is godlike"};
int No = pPlayer->m_Spree/g_Config.m_SvKillingspreeKills;

str_format(aBuf, sizeof(aBuf), "'%s' %s with %d kills!", Server()->ClientName(pPlayer->GetCID()), aaSpreeMsg[(No > NumMsg-1) ? NumMsg-1 : No], pPlayer->m_Spree);
GameServer()->SendChat(-1, CGameContext::CHAT_ALL, aBuf);
}
}

void CGameControllerInstagib::EndSpree(class CPlayer * pPlayer, class CPlayer *pKiller)
{
if(pPlayer->m_Spree >= g_Config.m_SvKillingspreeKills)
{
CCharacter * charac = pPlayer->GetCharacter();

if(charac)
{
GameServer()->CreateSound(charac->m_Pos, SOUND_GRENADE_EXPLODE);
// GameServer()->CreateExplosion(charac->m_Pos, pPlayer->GetCID(), WEAPON_GRENADE, true, -1, -1);
CNetEvent_Explosion *pEvent = GameServer()->m_Events.Create<CNetEvent_Explosion>(CClientMask());
if(pEvent)
{
pEvent->m_X = (int)charac->m_Pos.x;
pEvent->m_Y = (int)charac->m_Pos.y;
}

char aBuf[128];
str_format(aBuf, sizeof(aBuf), "'%s' %d-kills killing spree was ended by %s",
Server()->ClientName(pPlayer->GetCID()), pPlayer->m_Spree, Server()->ClientName(pKiller->GetCID()));
GameServer()->SendChat(-1, CGameContext::CHAT_ALL, aBuf);
}
}
// pPlayer->m_GotAward = false;
pPlayer->m_Spree = 0;
}

void CGameControllerInstagib::OnPlayerConnect(CPlayer *pPlayer)
{
IGameController::OnPlayerConnect(pPlayer);
Expand Down
4 changes: 4 additions & 0 deletions src/game/server/gamemodes/instagib.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ class CGameControllerInstagib : public CGameControllerDDRace
void OnPlayerDisconnect(class CPlayer *pPlayer, const char *pReason) override;
void DoTeamChange(CPlayer *pPlayer, int Team, bool DoChatMsg) override;
void OnCharacterSpawn(class CCharacter *pChr) override;
int OnCharacterDeath(class CCharacter *pVictim, class CPlayer *pKiller, int Weapon) override;
void Tick() override;

void AddSpree(CPlayer * pPlayer);
void EndSpree(CPlayer * pPlayer, CPlayer * pKiller);
};
#endif // GAME_SERVER_GAMEMODES_INSTAGIB_H
3 changes: 3 additions & 0 deletions src/game/server/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,9 @@ class CPlayer
bool m_IsReadyToEnter; // 0.7 ready change
bool m_IsReadyToPlay; // 0.7 ready change
bool m_DeadSpecMode; // 0.7 dead players

//ictf
int m_Spree;
/*
m_HasGhostCharInGame
Expand Down

0 comments on commit 9d63a0f

Please sign in to comment.