From e6f58382debf59f67ff034849ea3e2bb56805983 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 19 Dec 2022 22:04:03 -0500 Subject: [PATCH] [Rule] Add ManaOnDeath and EndurOnDeath (#2661) * [Rule] Add ManaOnDeath and EndurOnDeath This rule allows death to fully fill Mana or Endurance. * Updates rules to live-like * Adjust rule names to be more descriptive of their intent, remove else cases Co-authored-by: Akkadius --- common/ruletypes.h | 2 ++ zone/client.cpp | 22 ++++++++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/common/ruletypes.h b/common/ruletypes.h index 1d9a61c71..59f22b149 100644 --- a/common/ruletypes.h +++ b/common/ruletypes.h @@ -194,6 +194,8 @@ RULE_INT(Character, BeastlordTrackingDistanceMultiplier, 0, "If you want beastlo RULE_INT(Character, BerserkerTrackingDistanceMultiplier, 0, "If you want berserkers to be able to track, increase this above 0. 0 disables tracking packets.") RULE_BOOL(Character, OnInviteReceiveAlreadyinGroupMessage, true, "If you want clients to receive a message when trying to invite a player into a group that is currently in another group.") RULE_BOOL(Character, PetZoneWithOwner, true, "Should Pets Zone with Owner") +RULE_BOOL(Character, FullManaOnDeath, true, "On death set mana to full") +RULE_BOOL(Character, FullEndurOnDeath, true, "On death set endurance to full") RULE_CATEGORY_END() RULE_CATEGORY(Mercs) diff --git a/zone/client.cpp b/zone/client.cpp index 3884cc56f..10667b5e0 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -645,16 +645,22 @@ bool Client::Save(uint8 iCommitNow) { m_pp.guildrank = guildrank; - /* Mana and HP */ - if (GetHP() <= 0) { + if (dead && GetHP() <= 0) { m_pp.cur_hp = GetMaxHP(); - } - else { - m_pp.cur_hp = GetHP(); - } + m_pp.mana = current_mana; + if (RuleB(Character, FullManaOnDeath)) { + m_pp.mana = GetMaxMana(); + } - m_pp.mana = current_mana; - m_pp.endurance = current_endurance; + m_pp.endurance = current_endurance; + if (RuleB(Character, FullEndurOnDeath)) { + m_pp.endurance = GetMaxEndurance(); + } + } else { // Otherwise, no changes. + m_pp.cur_hp = GetHP(); + m_pp.mana = current_mana; + m_pp.endurance = current_endurance; + } /* Save Character Currency */ database.SaveCharacterCurrency(CharacterID(), &m_pp);