[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 <kinglykrab@gmail.com>
This commit is contained in:
Fryguy 2024-05-26 08:57:32 -04:00 committed by GitHub
parent 87c207e862
commit 9638d9af3a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 43 additions and 1 deletions

View File

@ -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")

View File

@ -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<int>(roll * static_cast<double>(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) &&

View File

@ -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<int>(roll * static_cast<double>(hit.base_damage) + 0.5), 1);
}