Skip to content

Commit

Permalink
Spell: Add spellInfo to OnCritChanceCalculate
Browse files Browse the repository at this point in the history
  • Loading branch information
killerwife committed Sep 28, 2023
1 parent 62a3458 commit c9dbe0f
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/game/Entities/Unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3906,7 +3906,7 @@ float Unit::CalculateEffectiveCritChance(const Unit* victim, WeaponAttackType at
{
if (!i->isAffectedOnSpell(ability))
continue;
i->OnCritChanceCalculate(victim, chance);
i->OnCritChanceCalculate(victim, chance, ability);
}
return std::max(0.0f, std::min(chance, 100.0f));
}
Expand Down Expand Up @@ -3991,7 +3991,7 @@ float Unit::CalculateSpellCritChance(const Unit* victim, SpellSchoolMask schoolM
{
if (!i->isAffectedOnSpell(spellInfo))
continue;
i->OnCritChanceCalculate(victim, chance);
i->OnCritChanceCalculate(victim, chance, spellInfo);
}
return std::max(0.0f, std::min(chance, 100.0f));
}
Expand Down
2 changes: 1 addition & 1 deletion src/game/Spells/Scripts/Scripting/ClassScripts/Mage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ struct ShatterMage : public AuraScript
aura->GetTarget()->RegisterScriptedLocationAura(aura, SCRIPT_LOCATION_CRIT_CHANCE, apply);
}

void OnCritChanceCalculate(Aura* aura, Unit const* target, float& chance) const override
void OnCritChanceCalculate(Aura* aura, Unit const* target, float& chance, SpellEntry const* /*spellInfo*/) const override
{
switch (aura->GetModifier()->m_miscvalue)
{
Expand Down
2 changes: 1 addition & 1 deletion src/game/Spells/Scripts/SpellScript.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ struct AuraScript
virtual void OnDamageCalculate(Aura* /*aura*/, Unit* /*attacker*/, Unit* /*victim*/, int32& /*advertisedBenefit*/, float& /*totalMod*/) const {}
// called during duration calculation - target can be nullptr for channel duration calculation
virtual int32 OnDurationCalculate(WorldObject const* /*caster*/, Unit const* /*target*/, int32 duration) const { return duration; }
virtual void OnCritChanceCalculate(Aura* /*aura*/, Unit const* /*target*/, float& /*chance*/) const {}
virtual void OnCritChanceCalculate(Aura* /*aura*/, Unit const* /*target*/, float& /*chance*/, SpellEntry const* /*spellInfo*/) const {}
// the following two hooks are done in an alternative fashion due to how they are usually used
// if an aura is applied before, its removed after, and if some aura needs to do something after aura effect is applied, need to revert that change before its removed
// called before aura apply and after aura unapply
Expand Down
4 changes: 2 additions & 2 deletions src/game/Spells/SpellAuras.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8917,10 +8917,10 @@ void Aura::OnDamageCalculate(Unit* victim, Unit* attacker, int32& advertisedBene
return script->OnDamageCalculate(this, attacker, victim, advertisedBenefit, totalMod);
}

void Aura::OnCritChanceCalculate(Unit const* victim, float& chance)
void Aura::OnCritChanceCalculate(Unit const* victim, float& chance, SpellEntry const* spellInfo)
{
if (AuraScript* script = GetAuraScript())
return script->OnCritChanceCalculate(this, victim, chance);
return script->OnCritChanceCalculate(this, victim, chance, spellInfo);
}

void Aura::OnApply(bool apply)
Expand Down
2 changes: 1 addition & 1 deletion src/game/Spells/SpellAuras.h
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ class Aura
void OnAuraInit();
int32 OnAuraValueCalculate(Unit* caster, int32 currentValue);
void OnDamageCalculate(Unit* victim, Unit* attacker, int32& advertisedBenefit, float& totalMod);
void OnCritChanceCalculate(Unit const* victim, float& chance);
void OnCritChanceCalculate(Unit const* victim, float& chance, SpellEntry const* spellInfo);
void OnApply(bool apply);
void OnAfterApply(bool apply);
bool OnCheckProc(ProcExecutionData& data);
Expand Down

0 comments on commit c9dbe0f

Please sign in to comment.