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.
This commit is contained in:
ChillerDragon 2024-08-31 18:56:21 +08:00
parent 6ab597a465
commit f44def1cdd
4 changed files with 9 additions and 2 deletions

View file

@ -260,7 +260,7 @@ void CCharacter::HandleNinja()
GameServer()->CreateDamageInd(m_Pos, 0, NinjaTime / Server()->TickSpeed(), TeamMask() & GameServer()->ClientsMaskExcludeClientVersionAndHigher(VERSION_DDNET_NEW_HUD)); 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 // force ninja Weapon
SetWeapon(WEAPON_NINJA); SetWeapon(WEAPON_NINJA);
@ -2055,7 +2055,7 @@ void CCharacter::ForceSetRescue(int RescueMode)
void CCharacter::DDRaceTick() void CCharacter::DDRaceTick()
{ {
mem_copy(&m_Input, &m_SavedInput, sizeof(m_Input)); 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) if(m_Input.m_Direction != 0 || m_Input.m_Jump != 0)
m_LastMove = Server()->Tick(); m_LastMove = Server()->Tick();

View file

@ -95,6 +95,7 @@ public:
virtual void OnCharacterSpawn(class CCharacter *pChr); virtual void OnCharacterSpawn(class CCharacter *pChr);
virtual void HandleCharacterTiles(class CCharacter *pChr, int MapIndex); virtual void HandleCharacterTiles(class CCharacter *pChr, int MapIndex);
virtual void SetArmorProgress(CCharacter *pCharacer, int Progress){};
/* /*
Function: OnEntity Function: OnEntity

View file

@ -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) void CGameControllerDDRace::OnPlayerConnect(CPlayer *pPlayer)
{ {
IGameController::OnPlayerConnect(pPlayer); IGameController::OnPlayerConnect(pPlayer);

View file

@ -13,6 +13,7 @@ public:
CScore *Score(); CScore *Score();
void HandleCharacterTiles(class CCharacter *pChr, int MapIndex) override; void HandleCharacterTiles(class CCharacter *pChr, int MapIndex) override;
void SetArmorProgress(CCharacter *pCharacer, int Progress) override;
void OnPlayerConnect(class CPlayer *pPlayer) override; void OnPlayerConnect(class CPlayer *pPlayer) override;
void OnPlayerDisconnect(class CPlayer *pPlayer, const char *pReason) override; void OnPlayerDisconnect(class CPlayer *pPlayer, const char *pReason) override;