Core/Spells: Moved dungeon encounter crediting to scripts

This commit is contained in:
Shauren
2011-02-04 11:27:02 +01:00
parent e9bae2d0a0
commit 8d5ebded8c
4 changed files with 74 additions and 4 deletions

View File

@@ -705,6 +705,47 @@ class spell_gen_parachute_ic : public SpellScriptLoader
}
};
class spell_gen_dungeon_credit : public SpellScriptLoader
{
public:
spell_gen_dungeon_credit() : SpellScriptLoader("spell_gen_dungeon_credit") { }
class spell_gen_dungeon_credit_SpellScript : public SpellScript
{
PrepareSpellScript(spell_gen_dungeon_credit_SpellScript);
bool Load()
{
_handled = false;
return true;
}
void CreditEncounter()
{
// This hook is executed for every target, make sure we only credit instance once
if (_handled)
return;
_handled = true;
if (GetCaster()->GetTypeId() == TYPEID_UNIT)
if (InstanceScript* instance = GetCaster()->GetInstanceScript())
instance->UpdateEncounterState(ENCOUNTER_CREDIT_CAST_SPELL, GetSpellInfo()->Id, GetCaster());
}
void Register()
{
AfterHit += SpellHitFn(spell_gen_dungeon_credit_SpellScript::CreditEncounter);
}
bool _handled;
};
SpellScript* GetSpellScript() const
{
return new spell_gen_dungeon_credit_SpellScript();
}
};
void AddSC_generic_spell_scripts()
{
new spell_gen_absorb0_hitlimit1();
@@ -723,4 +764,5 @@ void AddSC_generic_spell_scripts()
new spell_gen_divine_storm_cd_reset();
new spell_gen_parachute_ic();
new spell_gen_gunship_portal();
new spell_gen_dungeon_credit();
}