From 9638d9af3a7d9570e0058d66c1b12a2f50b4f68d Mon Sep 17 00:00:00 2001 From: Fryguy Date: Sun, 26 May 2024 08:57:32 -0400 Subject: [PATCH] [Rule] Added MeleeMitigation Level Difference Roll Adjusted for level diffs (#4332) * Added MeleeMitigation LevelDifferent Roll Adjusted for level diffs * Adjustments per comments * Tune method and const. --------- Co-authored-by: Kinglykrab --- common/ruletypes.h | 2 ++ zone/attack.cpp | 22 +++++++++++++++++++++- zone/tune.cpp | 20 ++++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/common/ruletypes.h b/common/ruletypes.h index c114a0122..4786a43f0 100644 --- a/common/ruletypes.h +++ b/common/ruletypes.h @@ -521,6 +521,8 @@ RULE_BOOL(Combat, NPCCanCrit, false, "Setting whether an NPC can land critical h RULE_BOOL(Combat, UseIntervalAC, true, "Switch whether bonuses, armour class, multipliers, classes and caps should be considered in the calculation of damage values") RULE_INT(Combat, PetAttackMagicLevel, 10, "Level at which pets can cause magic damage, no longer used") RULE_INT(Combat, NPCAttackMagicLevel, 10, "Level at which NPC and pets can cause magic damage") +RULE_INT(Combat, LevelDifferenceRollCheck, -1, "Level Difference to enable LeverDifferenceRollBonus for MeleeMitigation - Default: -1 is disabled, 20 is common") +RULE_REAL(Combat, LevelDifferenceRollBonus, 0.5, "Roll Bonus/Detrement if using LevelDifferenceRollCheck") RULE_BOOL(Combat, EnableFearPathing, true, "Setting whether to use pathing during fear") RULE_BOOL(Combat, FleeGray, true, "If true FleeGrayHPRatio will be used") RULE_INT(Combat, FleeGrayHPRatio, 50, "HP percentage when a Gray NPC begins to flee") diff --git a/zone/attack.cpp b/zone/attack.cpp index f2785ef05..c06a6a639 100644 --- a/zone/attack.cpp +++ b/zone/attack.cpp @@ -1068,6 +1068,26 @@ void Mob::MeleeMitigation(Mob *attacker, DamageHitInfo &hit, ExtraAttackOptions auto roll = RollD20(hit.offense, mitigation); + // Add bonus to roll if level difference is sufficient + const int level_diff = attacker->GetLevel() - GetLevel(); + const int level_diff_roll_check = RuleI(Combat, LevelDifferenceRollCheck); + + if (level_diff_roll_check >= 0) { + if (level_diff > level_diff_roll_check) { + roll += RuleR(Combat, LevelDifferenceRollBonus); + + if (roll > 2.0f) { + roll = 2.0f; + } + } else if (level_diff < (-level_diff_roll_check)) { + roll -= RuleR(Combat, LevelDifferenceRollBonus); + + if (roll < 0.1f) { + roll = 0.1f; + } + } + } + // +0.5 for rounding, min to 1 dmg hit.damage_done = std::max(static_cast(roll * static_cast(hit.base_damage) + 0.5), 1); @@ -2535,7 +2555,7 @@ bool NPC::Death(Mob* killer_mob, int64 damage, uint16 spell, EQ::skills::SkillTy auto app = new EQApplicationPacket(OP_Death, sizeof(Death_Struct)); auto d = (Death_Struct*) app->pBuffer; - + // Convert last message to color to avoid duplicate damage messages // that occur in these rare cases when this is the death blow. if (IsValidSpell(spell) && diff --git a/zone/tune.cpp b/zone/tune.cpp index 4af8c4bda..853153884 100644 --- a/zone/tune.cpp +++ b/zone/tune.cpp @@ -1012,6 +1012,26 @@ void Mob::TuneMeleeMitigation(Mob *attacker, DamageHitInfo &hit, int ac_override auto roll = RollD20(hit.offense, mitigation); + // Add bonus to roll if level difference is sufficient + const int level_diff = attacker->GetLevel() - GetLevel(); + const int level_diff_roll_check = RuleI(Combat, LevelDifferenceRollCheck); + + if (level_diff_roll_check >= 0) { + if (level_diff > level_diff_roll_check) { + roll += RuleR(Combat, LevelDifferenceRollBonus); + + if (roll > 2.0f) { + roll = 2.0f; + } + } else if (level_diff < (-level_diff_roll_check)) { + roll -= RuleR(Combat, LevelDifferenceRollBonus); + + if (roll < 0.1f) { + roll = 0.1f; + } + } + } + // +0.5 for rounding, min to 1 dmg hit.damage_done = std::max(static_cast(roll * static_cast(hit.base_damage) + 0.5), 1); }