diff options
| -rw-r--r-- | sql/updates/world/2012_08_30_00_world_spell_script_names.sql | 8 | ||||
| -rw-r--r-- | src/server/scripts/Spells/spell_generic.cpp | 174 |
2 files changed, 129 insertions, 53 deletions
diff --git a/sql/updates/world/2012_08_30_00_world_spell_script_names.sql b/sql/updates/world/2012_08_30_00_world_spell_script_names.sql new file mode 100644 index 00000000000..d7602dd8c79 --- /dev/null +++ b/sql/updates/world/2012_08_30_00_world_spell_script_names.sql @@ -0,0 +1,8 @@ +DELETE FROM `spell_script_names` WHERE `spell_id` IN (41054, 63418, 69893, 45205, 69896, 57594); +INSERT INTO `spell_script_names` VALUES +(41054, "spell_gen_clone_weapon_aura"), +(63418, "spell_gen_clone_weapon_aura"), +(69893, "spell_gen_clone_weapon_aura"), +(45205, "spell_gen_clone_weapon_aura"), +(69896, "spell_gen_clone_weapon_aura"), +(57594, "spell_gen_clone_weapon_aura"); diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index 5eebb69d7a5..242dc9d613b 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -950,14 +950,14 @@ class spell_generic_clone : public SpellScriptLoader enum CloneWeaponSpells { - SPELL_COPY_WEAPON = 41055, - SPELL_COPY_WEAPON_2 = 63416, - SPELL_COPY_WEAPON_3 = 69891, + SPELL_COPY_WEAPON_AURA = 41054, + SPELL_COPY_WEAPON_2_AURA = 63418, + SPELL_COPY_WEAPON_3_AURA = 69893, - SPELL_COPY_OFFHAND = 45206, - SPELL_COPY_OFFHAND_2 = 69892, + SPELL_COPY_OFFHAND_AURA = 45205, + SPELL_COPY_OFFHAND_2_AURA = 69896, - SPELL_COPY_RANGED = 57593 + SPELL_COPY_RANGED_AURA = 57594 }; class spell_generic_clone_weapon : public SpellScriptLoader @@ -969,80 +969,147 @@ class spell_generic_clone_weapon : public SpellScriptLoader { PrepareSpellScript(spell_generic_clone_weapon_SpellScript); - bool Validate(SpellInfo const* /*spellEntry*/) - { - if (!sSpellMgr->GetSpellInfo(SPELL_COPY_WEAPON) || !sSpellMgr->GetSpellInfo(SPELL_COPY_WEAPON_2) || !sSpellMgr->GetSpellInfo(SPELL_COPY_WEAPON_3) || !sSpellMgr->GetSpellInfo(SPELL_COPY_OFFHAND) - || !sSpellMgr->GetSpellInfo(SPELL_COPY_OFFHAND_2) || !sSpellMgr->GetSpellInfo(SPELL_COPY_RANGED)) - return false; - return true; - } - void HandleScriptEffect(SpellEffIndex effIndex) { PreventHitDefaultEffect(effIndex); Unit* caster = GetCaster(); + if (Unit* target = GetHitUnit()) { uint32 spellId = uint32(GetSpellInfo()->Effects[EFFECT_0].CalcValue()); - target->CastSpell(caster, spellId, true); + caster->CastSpell(target, spellId, true); + } + } - if (target->GetTypeId() == TYPEID_PLAYER) - return; + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_generic_clone_weapon_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_generic_clone_weapon_SpellScript(); + } +}; + +class spell_gen_clone_weapon_aura : public SpellScriptLoader +{ + public: + spell_gen_clone_weapon_aura() : SpellScriptLoader("spell_gen_clone_weapon_aura") { } - switch (GetSpellInfo()->Id) + class spell_gen_clone_weapon_auraScript : public AuraScript + { + PrepareAuraScript(spell_gen_clone_weapon_auraScript); + + uint32 prevItem; + + bool Validate(SpellInfo const* /*spellEntry*/) + { + if (!sSpellMgr->GetSpellInfo(SPELL_COPY_WEAPON_AURA) || !sSpellMgr->GetSpellInfo(SPELL_COPY_WEAPON_2_AURA) || !sSpellMgr->GetSpellInfo(SPELL_COPY_WEAPON_3_AURA) + || !sSpellMgr->GetSpellInfo(SPELL_COPY_OFFHAND_AURA) || !sSpellMgr->GetSpellInfo(SPELL_COPY_OFFHAND_2_AURA) || !sSpellMgr->GetSpellInfo(SPELL_COPY_RANGED_AURA)) + return false; + return true; + } + + void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + Unit* caster = GetCaster(); + Unit* target = GetTarget(); + + if (!caster) + return; + + switch (GetSpellInfo()->Id) + { + case SPELL_COPY_WEAPON_AURA: + case SPELL_COPY_WEAPON_2_AURA: + case SPELL_COPY_WEAPON_3_AURA: { - case SPELL_COPY_WEAPON: - case SPELL_COPY_WEAPON_2: - case SPELL_COPY_WEAPON_3: + prevItem = target->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID); + + if (Player* player = caster->ToPlayer()) { - if (Player* player = caster->ToPlayer()) - { - if (Item* mainItem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND)) - target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID, mainItem->GetEntry()); - } - else - target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID, caster->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID)); - break; + if (Item* mainItem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND)) + target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID, mainItem->GetEntry()); } - case SPELL_COPY_OFFHAND: - case SPELL_COPY_OFFHAND_2: + else + target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID, caster->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID)); + break; + } + case SPELL_COPY_OFFHAND_AURA: + case SPELL_COPY_OFFHAND_2_AURA: + { + prevItem = target->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID) + 1; + + if (Player* player = caster->ToPlayer()) { - if (Player* player = caster->ToPlayer()) - { - if (Item* offItem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND)) - target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1, offItem->GetEntry()); - } - else - target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1, caster->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1)); - break; + if (Item* offItem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND)) + target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1, offItem->GetEntry()); } - case SPELL_COPY_RANGED: + else + target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1, caster->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1)); + break; + } + case SPELL_COPY_RANGED_AURA: + { + prevItem = target->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID) + 2; + + if (Player* player = caster->ToPlayer()) { - if (Player* player = caster->ToPlayer()) - { - if (Item* rangedItem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_RANGED)) - target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 2, rangedItem->GetEntry()); - } - else - target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 2, caster->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 2)); - break; + if (Item* rangedItem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_RANGED)) + target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 2, rangedItem->GetEntry()); } - default: - break; + else + target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 2, caster->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 2)); + break; + } + default: + break; + } + } + + void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + Unit* target = GetTarget(); + + switch (GetSpellInfo()->Id) + { + case SPELL_COPY_WEAPON_AURA: + case SPELL_COPY_WEAPON_2_AURA: + case SPELL_COPY_WEAPON_3_AURA: + { + target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID, prevItem); + break; + } + case SPELL_COPY_OFFHAND_AURA: + case SPELL_COPY_OFFHAND_2_AURA: + { + target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1, prevItem); + break; + } + case SPELL_COPY_RANGED_AURA: + { + target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 2, prevItem); + break; } + default: + break; } } void Register() { - OnEffectHitTarget += SpellEffectFn(spell_generic_clone_weapon_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + OnEffectApply += AuraEffectApplyFn(spell_gen_clone_weapon_auraScript::OnApply, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK); + OnEffectRemove += AuraEffectRemoveFn(spell_gen_clone_weapon_auraScript::OnRemove, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK); } + }; - SpellScript* GetSpellScript() const + AuraScript* GetAuraScript() const { - return new spell_generic_clone_weapon_SpellScript(); + return new spell_gen_clone_weapon_auraScript(); } }; @@ -3189,6 +3256,7 @@ void AddSC_generic_spell_scripts() new spell_gen_profession_research(); new spell_generic_clone(); new spell_generic_clone_weapon(); + new spell_gen_clone_weapon_aura(); new spell_gen_seaforium_blast(); new spell_gen_turkey_marker(); new spell_gen_lifeblood(); |
