[Rules] Restrict Finishing Blow to only Fleeing NPC's. (#3869)

* [Rules] Restrict Finishing Blow to only Fleeing NPC's.

Default is false to maintain current design

* Cleanup
This commit is contained in:
Fryguy 2024-01-07 02:11:49 -05:00 committed by GitHub
parent d6e1c3f187
commit 8fa6a0b496
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 14 deletions

View File

@ -542,6 +542,7 @@ RULE_BOOL(Combat, SummonMeleeRange, true, "Enable or disable summoning of a play
RULE_BOOL(Combat, WaterMatchRequiredForAutoFireLoS, true, "Enable/Disable the requirement of both the attacker/victim being both in or out of water for AutoFire LoS to pass.") RULE_BOOL(Combat, WaterMatchRequiredForAutoFireLoS, true, "Enable/Disable the requirement of both the attacker/victim being both in or out of water for AutoFire LoS to pass.")
RULE_INT(Combat, ExtraAllowedKickClassesBitmask, 0, "Bitmask for allowing extra classes beyond Warrior, Ranger, Beastlord, and Berserker to kick, No Extra Classes (0) by default") RULE_INT(Combat, ExtraAllowedKickClassesBitmask, 0, "Bitmask for allowing extra classes beyond Warrior, Ranger, Beastlord, and Berserker to kick, No Extra Classes (0) by default")
RULE_INT(Combat, MaxProcs, 4, "Adjustable maximum number of procs per round, the hard cap is MAX_PROCS (11). Requires mob repop or client zone when changed") RULE_INT(Combat, MaxProcs, 4, "Adjustable maximum number of procs per round, the hard cap is MAX_PROCS (11). Requires mob repop or client zone when changed")
RULE_BOOL(Combat, FinishingBlowOnlyWhenFleeing, false, "Enable to only allow Finishing Blow when fleeing (Original Style Finishing Blow)")
RULE_CATEGORY_END() RULE_CATEGORY_END()
RULE_CATEGORY(NPC) RULE_CATEGORY(NPC)

View File

@ -5191,7 +5191,6 @@ void Mob::TryCriticalHit(Mob *defender, DamageHitInfo &hit, ExtraAttackOptions *
bool Mob::TryFinishingBlow(Mob *defender, int64 &damage) bool Mob::TryFinishingBlow(Mob *defender, int64 &damage)
{ {
float hp_limit = 10.0f; float hp_limit = 10.0f;
auto fb_hp_limit = std::max( auto fb_hp_limit = std::max(
{ {
aabonuses.FinishingBlowLvl[SBIndex::FINISHING_BLOW_LEVEL_HP_RATIO], aabonuses.FinishingBlowLvl[SBIndex::FINISHING_BLOW_LEVEL_HP_RATIO],
@ -5203,28 +5202,36 @@ bool Mob::TryFinishingBlow(Mob *defender, int64 &damage)
if (fb_hp_limit) { if (fb_hp_limit) {
hp_limit = fb_hp_limit/10.0f; hp_limit = fb_hp_limit/10.0f;
} }
if (defender && !defender->IsClient() && defender->GetHPRatio() < hp_limit) {
uint32 FB_Dmg = if (defender && !defender->IsClient() && defender->GetHPRatio() < hp_limit) {
uint32 finishing_blow_damage =
aabonuses.FinishingBlow[SBIndex::FINISHING_EFFECT_DMG] + spellbonuses.FinishingBlow[SBIndex::FINISHING_EFFECT_DMG] + itembonuses.FinishingBlow[SBIndex::FINISHING_EFFECT_DMG]; aabonuses.FinishingBlow[SBIndex::FINISHING_EFFECT_DMG] + spellbonuses.FinishingBlow[SBIndex::FINISHING_EFFECT_DMG] + itembonuses.FinishingBlow[SBIndex::FINISHING_EFFECT_DMG];
uint32 FB_Level = 0; uint32 finishing_blow_level = 0;
FB_Level = aabonuses.FinishingBlowLvl[SBIndex::FINISHING_EFFECT_LEVEL_MAX]; finishing_blow_level = aabonuses.FinishingBlowLvl[SBIndex::FINISHING_EFFECT_LEVEL_MAX];
if (FB_Level < spellbonuses.FinishingBlowLvl[SBIndex::FINISHING_EFFECT_LEVEL_MAX]) if (finishing_blow_level < spellbonuses.FinishingBlowLvl[SBIndex::FINISHING_EFFECT_LEVEL_MAX]) {
FB_Level = spellbonuses.FinishingBlowLvl[SBIndex::FINISHING_EFFECT_LEVEL_MAX]; finishing_blow_level = spellbonuses.FinishingBlowLvl[SBIndex::FINISHING_EFFECT_LEVEL_MAX];
else if (FB_Level < itembonuses.FinishingBlowLvl[SBIndex::FINISHING_EFFECT_LEVEL_MAX]) } else if (finishing_blow_level < itembonuses.FinishingBlowLvl[SBIndex::FINISHING_EFFECT_LEVEL_MAX]) {
FB_Level = itembonuses.FinishingBlowLvl[SBIndex::FINISHING_EFFECT_LEVEL_MAX]; finishing_blow_level = itembonuses.FinishingBlowLvl[SBIndex::FINISHING_EFFECT_LEVEL_MAX];
}
// modern AA description says rank 1 (500) is 50% chance // modern AA description says rank 1 (500) is 50% chance
int ProcChance = ( int proc_chance = (
aabonuses.FinishingBlow[SBIndex::FINISHING_EFFECT_PROC_CHANCE] + aabonuses.FinishingBlow[SBIndex::FINISHING_EFFECT_PROC_CHANCE] +
itembonuses.FinishingBlow[SBIndex::FINISHING_EFFECT_PROC_CHANCE] + itembonuses.FinishingBlow[SBIndex::FINISHING_EFFECT_PROC_CHANCE] +
spellbonuses.FinishingBlow[SBIndex::FINISHING_EFFECT_PROC_CHANCE] spellbonuses.FinishingBlow[SBIndex::FINISHING_EFFECT_PROC_CHANCE]
); );
if (FB_Level && FB_Dmg && (defender->GetLevel() <= FB_Level) && if (
(ProcChance >= zone->random.Int(1, 1000))) { (
(RuleB(Combat, FinishingBlowOnlyWhenFleeing) && !defender->currently_fleeing) ||
!RuleB(Combat, FinishingBlowOnlyWhenFleeing)
) &&
finishing_blow_level &&
finishing_blow_damage &&
defender->GetLevel() <= finishing_blow_level &&
proc_chance >= zone->random.Int(1, 1000)
) {
/* Finishing Blow Critical Message */ /* Finishing Blow Critical Message */
entity_list.FilteredMessageCloseString( entity_list.FilteredMessageCloseString(
this, /* Sender */ this, /* Sender */
@ -5237,7 +5244,7 @@ bool Mob::TryFinishingBlow(Mob *defender, int64 &damage)
GetCleanName() /* Message1 */ GetCleanName() /* Message1 */
); );
damage = FB_Dmg; damage = finishing_blow_damage;
return true; return true;
} }
} }