Scripts: UnitScript::OnDamageSpell, the damage with the spell that dealt it (#60)

Why: UnitScript::OnDamage gives a script the damage but not where it came from. A script that keeps a table of what hits the raid (which boss spell did how much) can not tell the spells apart.

What: one virtual UnitScript hook, empty by default, called just before OnDamage in Unit::DealDamage with the spell (null for a melee swing). Damage is passed by value, so a script can not change it. No change for scripts that do not override it.
This commit is contained in:
Karrz1
2026-10-18 09:14:58 +08:00
committed by GitHub
parent 812a3072d6
commit aa4ba30615
3 changed files with 15 additions and 0 deletions
+9
View File
@@ -2382,6 +2382,11 @@ void ScriptMgr::OnHeal(Unit* healer, Unit* reciever, uint32& gain)
FOREACH_SCRIPT(UnitScript)->OnHeal(healer, reciever, gain);
}
void ScriptMgr::OnDamageSpell(Unit* attacker, Unit* victim, uint32 damage, SpellInfo const* spellInfo)
{
FOREACH_SCRIPT(UnitScript)->OnDamageSpell(attacker, victim, damage, spellInfo);
}
void ScriptMgr::OnDamage(Unit* attacker, Unit* victim, uint32& damage)
{
FOREACH_SCRIPT(UnitScript)->OnDamage(attacker, victim, damage);
@@ -2764,6 +2769,10 @@ void UnitScript::OnHeal(Unit* /*healer*/, Unit* /*reciever*/, uint32& /*gain*/)
{
}
void UnitScript::OnDamageSpell(Unit* /*attacker*/, Unit* /*victim*/, uint32 /*damage*/, SpellInfo const* /*spellInfo*/)
{
}
void UnitScript::OnDamage(Unit* /*attacker*/, Unit* /*victim*/, uint32& /*damage*/)
{
}