From f44def1cddf5866f0485bbf2ac38fa06d8dec662 Mon Sep 17 00:00:00 2001 From: ChillerDragon Date: Sat, 31 Aug 2024 18:56:21 +0800 Subject: [PATCH] Only do armor progress hack in ddrace controller Only mess with the characters armor in ddrace controllers. This allows other game modes to use the armor as actual armor. --- src/game/server/entities/character.cpp | 4 ++-- src/game/server/gamecontroller.h | 1 + src/game/server/gamemodes/DDRace.cpp | 5 +++++ src/game/server/gamemodes/DDRace.h | 1 + 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index 59f078297..8e60014e8 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -260,7 +260,7 @@ void CCharacter::HandleNinja() GameServer()->CreateDamageInd(m_Pos, 0, NinjaTime / Server()->TickSpeed(), TeamMask() & GameServer()->ClientsMaskExcludeClientVersionAndHigher(VERSION_DDNET_NEW_HUD)); } - m_Armor = clamp(10 - (NinjaTime / 15), 0, 10); + GameServer()->m_pController->SetArmorProgress(this, NinjaTime); // force ninja Weapon SetWeapon(WEAPON_NINJA); @@ -2055,7 +2055,7 @@ void CCharacter::ForceSetRescue(int RescueMode) void CCharacter::DDRaceTick() { mem_copy(&m_Input, &m_SavedInput, sizeof(m_Input)); - m_Armor = clamp(10 - (m_FreezeTime / 15), 0, 10); + GameServer()->m_pController->SetArmorProgress(this, m_FreezeTime); if(m_Input.m_Direction != 0 || m_Input.m_Jump != 0) m_LastMove = Server()->Tick(); diff --git a/src/game/server/gamecontroller.h b/src/game/server/gamecontroller.h index 3f80e67eb..a732123b4 100644 --- a/src/game/server/gamecontroller.h +++ b/src/game/server/gamecontroller.h @@ -95,6 +95,7 @@ public: virtual void OnCharacterSpawn(class CCharacter *pChr); virtual void HandleCharacterTiles(class CCharacter *pChr, int MapIndex); + virtual void SetArmorProgress(CCharacter *pCharacer, int Progress){}; /* Function: OnEntity diff --git a/src/game/server/gamemodes/DDRace.cpp b/src/game/server/gamemodes/DDRace.cpp index da14b863a..a2959a885 100644 --- a/src/game/server/gamemodes/DDRace.cpp +++ b/src/game/server/gamemodes/DDRace.cpp @@ -112,6 +112,11 @@ void CGameControllerDDRace::HandleCharacterTiles(CCharacter *pChr, int MapIndex) } } +void CGameControllerDDRace::SetArmorProgress(CCharacter *pCharacer, int Progress) +{ + pCharacer->SetArmor(clamp(10 - (Progress / 15), 0, 10)); +} + void CGameControllerDDRace::OnPlayerConnect(CPlayer *pPlayer) { IGameController::OnPlayerConnect(pPlayer); diff --git a/src/game/server/gamemodes/DDRace.h b/src/game/server/gamemodes/DDRace.h index 17626f26a..bc307e053 100644 --- a/src/game/server/gamemodes/DDRace.h +++ b/src/game/server/gamemodes/DDRace.h @@ -13,6 +13,7 @@ public: CScore *Score(); void HandleCharacterTiles(class CCharacter *pChr, int MapIndex) override; + void SetArmorProgress(CCharacter *pCharacer, int Progress) override; void OnPlayerConnect(class CPlayer *pPlayer) override; void OnPlayerDisconnect(class CPlayer *pPlayer, const char *pReason) override;