From 5954011a9042267ca21b704d6b95b40c60eca35c Mon Sep 17 00:00:00 2001 From: Vincent-Michael Date: Thu, 6 Sep 2012 11:00:37 -0400 Subject: Core/Spells: clean up some code and move to spell script. Closes #7195 --- src/server/scripts/Spells/spell_generic.cpp | 13 +++++++++++++ src/server/scripts/Spells/spell_item.cpp | 11 +++++++++++ 2 files changed, 24 insertions(+) (limited to 'src/server/scripts') diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index 5153010c0cc..27a6dac95f7 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -907,9 +907,22 @@ class spell_gen_profession_research : public SpellScriptLoader return SPELL_CAST_OK; } + void HandleScript(SpellEffIndex /*effIndex*/) + { + Player* caster = GetCaster()->ToPlayer(); + uint32 spellId = GetSpellInfo()->Id; + + // learn random explicit discovery recipe (if any) + if (uint32 discoveredSpellId = GetExplicitDiscoverySpell(spellId, caster->ToPlayer())) + caster->learnSpell(discoveredSpellId, false); + + caster->UpdateCraftSkill(spellId); + } + void Register() { OnCheckCast += SpellCheckCastFn(spell_gen_profession_research_SpellScript::CheckRequirement); + OnEffectHitTarget += SpellEffectFn(spell_gen_profession_research_SpellScript::HandleScript, EFFECT_1, SPELL_EFFECT_SCRIPT_EFFECT); } }; diff --git a/src/server/scripts/Spells/spell_item.cpp b/src/server/scripts/Spells/spell_item.cpp index 3c89cb7005a..a88defad1ce 100644 --- a/src/server/scripts/Spells/spell_item.cpp +++ b/src/server/scripts/Spells/spell_item.cpp @@ -836,9 +836,20 @@ class spell_item_book_of_glyph_mastery : public SpellScriptLoader return SPELL_CAST_OK; } + void HandleScript(SpellEffIndex /*effIndex*/) + { + Player* caster = GetCaster()->ToPlayer(); + uint32 spellId = GetSpellInfo()->Id; + + // learn random explicit discovery recipe (if any) + if (uint32 discoveredSpellId = GetExplicitDiscoverySpell(spellId, caster->ToPlayer())) + caster->learnSpell(discoveredSpellId, false); + } + void Register() { OnCheckCast += SpellCheckCastFn(spell_item_book_of_glyph_mastery_SpellScript::CheckRequirement); + OnEffectHitTarget += SpellEffectFn(spell_item_book_of_glyph_mastery_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); } }; -- cgit v1.2.3