diff --git a/src/engine/shared/variables_insta.h b/src/engine/shared/variables_insta.h index 778ed20e3ed..5d4cc34e90b 100644 --- a/src/engine/shared/variables_insta.h +++ b/src/engine/shared/variables_insta.h @@ -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") /* diff --git a/src/game/server/gamemodes/instagib.cpp b/src/game/server/gamemodes/instagib.cpp index 368c9cb80cc..d5e15f640fe 100644 --- a/src/game/server/gamemodes/instagib.cpp +++ b/src/game/server/gamemodes/instagib.cpp @@ -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(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); diff --git a/src/game/server/gamemodes/instagib.h b/src/game/server/gamemodes/instagib.h index 43a4548dcf6..ab2499a1b8b 100644 --- a/src/game/server/gamemodes/instagib.h +++ b/src/game/server/gamemodes/instagib.h @@ -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 diff --git a/src/game/server/player.h b/src/game/server/player.h index 0d2cfd07e41..d3eb928a47d 100644 --- a/src/game/server/player.h +++ b/src/game/server/player.h @@ -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