Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.3.5][Hunter] Core/Spell: Glyph of Arcane Shot - Missing Script #16500

Closed
Rushor opened this issue Feb 8, 2016 · 5 comments
Closed

[3.3.5][Hunter] Core/Spell: Glyph of Arcane Shot - Missing Script #16500

Rushor opened this issue Feb 8, 2016 · 5 comments

Comments

@Rushor
Copy link
Contributor

Rushor commented Feb 8, 2016

rev: 814c3e7

Links:
http://wotlk.openwow.com/item=42898
http://wotlk.openwow.com/spell=56870
http://wotlk.openwow.com/spell=56841

How it should work:
Your Arcane Shot refunds 20% of its mana cost if the target has one of your Stings active on it.

How it works on TC:
The whole glyph is not implemented at all. Reason for this is, that the the glyph is only a dummy effect (http://wotlk.openwow.com/spell=56841 Apply Aura: Dummy
Value: 20 ). We need to add a script for this.

Some refernces/found stuff:
http://ru-mangos.ru/archive/index.php/t-4928.html

@Eliminationzx
Copy link
Contributor

-- Glyph of Arcane Shot
DELETE FROM `spell_proc_event` WHERE `entry`= 56841;
INSERT INTO `spell_proc_event` VALUES ('56841', '0', '9', '2048', '2048', '2048', '256', '0', '0', '0', '0');
 src/server/game/Entities/Unit/Unit.cpp | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 3aed5fd..8b8df0a 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -6382,6 +6382,35 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere
                     victim->CastSpell(victim, 57894, true, NULL, NULL, GetGUID());
                     return true;
                 }
+                case 56841: // Glyph of Arcane Shot
+                {
+                    if (!procSpell)
+                        return false;
+
+                    // search Serpent Sting, Viper Sting, Scorpid Sting, Wyvern Sting
+                    bool found = false;
+                    AuraApplicationMap const& victimAuras = victim->GetAppliedAuras();
+                    for (AuraApplicationMap::const_iterator itr = victimAuras.begin(); itr != victimAuras.end(); ++itr)
+                    {
+                        Aura const* aura = itr->second->GetBase();
+                        SpellInfo const* spellInfo = aura->GetSpellInfo();
+                        if (spellInfo->SpellFamilyName == SPELLFAMILY_HUNTER && (spellInfo->SpellFamilyFlags[1] & 0x1080 || spellInfo->SpellFamilyFlags[0] & 0xC000))
+                        {
+                            found = true;
+                            break;
+                        }
+                    }
+
+                    if (!found)
+                        return false;
+
+                    uint32 mana = procSpell->ManaCost + procSpell->ManaCostPercentage *  GetCreateMana() / 100;
+                    basepoints0 = CalculatePct(int32(mana), triggerAmount);
+
+                    target = this;
+                    triggered_spell_id = 61389;
+                    return true;
+                }

@Rushor
Copy link
Contributor Author

Rushor commented Feb 8, 2016

@Eliminationzx thank you for your work :)

@Shauren
Copy link
Member

Shauren commented Feb 8, 2016

Please only write new spell fixes as scripts if its a single spell fix - reason for that is updating code to new client versions, a case in switch cannot be easily detected when it becomes invalid (simply because its a compile time thing)
On the other hand, a spell (and aura) script has startup validation on multiple aspects of the spell -whether it exists, has expected effect, has expected aura allowing us to easily spot any outdated code.

To illustrate - our 6.x branch reports multiple errors on startup about removed spells that still have scripts attached (and does in few milliseconds) while we have an unknown number of invalid cases in switches in Unit::Proc* that would take many hours (or days) to verify if they are valid

@Eliminationzx
Copy link
Contributor

In SpellScript

-- Glyph of Arcane Shot
DELETE FROM `spell_proc_event` WHERE `entry`= 56841;
INSERT INTO `spell_proc_event` VALUES ('56841', '0', '9', '2048', '2048', '2048', '256', '0', '0', '0', '0');

DELETE FROM `spell_script_names` WHERE `ScriptName` = 'spell_hun_glyph_of_arcane_shot';
INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES
(56841,'spell_hun_glyph_of_arcane_shot');
 src/server/scripts/Spells/spell_hunter.cpp | 64 +++++++++++++++++++++++++++++-
 1 file changed, 63 insertions(+), 1 deletion(-)

diff --git a/src/server/scripts/Spells/spell_hunter.cpp b/src/server/scripts/Spells/spell_hunter.cpp
index abf4c6c..83c93c8 100644
--- a/src/server/scripts/Spells/spell_hunter.cpp
+++ b/src/server/scripts/Spells/spell_hunter.cpp
@@ -55,7 +55,8 @@ enum HunterSpells
     SPELL_HUNTER_SNIPER_TRAINING_BUFF_R1            = 64418,
     SPELL_HUNTER_VICIOUS_VIPER                      = 61609,
     SPELL_HUNTER_VIPER_ATTACK_SPEED                 = 60144,
-    SPELL_DRAENEI_GIFT_OF_THE_NAARU                 = 59543
+    SPELL_DRAENEI_GIFT_OF_THE_NAARU                 = 59543,
+    SPELL_HUNTER_GLYPH_OF_ARCANE_SHOT               = 61389
 };

 // 13161 - Aspect of the Beast
@@ -946,6 +947,66 @@ class spell_hun_viper_attack_speed : public SpellScriptLoader
         }
 };

+// 56841 - Glyph of Arcane Shot
+class spell_hun_glyph_of_arcane_shot : public SpellScriptLoader
+{
+    public:
+        spell_hun_glyph_of_arcane_shot() : SpellScriptLoader("spell_hun_glyph_of_arcane_shot") { }
+
+        class spell_hun_glyph_of_arcane_shot_AuraScript : public AuraScript
+        {
+            PrepareSpellScript(spell_hun_glyph_of_arcane_shot_AuraScript);
+
+            bool Validate(SpellInfo const* /*spellInfo*/) override
+            {
+                if (!sSpellMgr->GetSpellInfo(SPELL_HUNTER_GLYPH_OF_ARCANE_SHOT))
+                    return false;
+                return true;
+            }
+
+            bool CheckProc(ProcEventInfo& eventInfo)
+            {
+                bool found = false;
+                Unit::AuraApplicationMap& Auras = eventInfo.GetProcTarget()->GetAppliedAuras();
+                for (Unit::AuraApplicationMap::const_iterator i = Auras.begin(); i != Auras.end(); ++i)
+                {
+                    Aura const* aura = i->second->GetBase();
+                    // Search only Serpent Sting, Viper Sting, Scorpid Sting, Wyvern Sting
+                    flag96 familyFlag = aura->GetSpellInfo()->SpellFamilyFlags;
+                    if (familyFlag[1] & 0x1080 || familyFlag[0] & 0xC000)
+                    {
+                        found = true;
+                        break;
+                    }
+                }
+                return found;
+            }
+
+            void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
+            {
+                PreventDefaultAction();
+                SpellInfo const* procSpell = eventInfo.GetSpellInfo();
+                if (!procSpell)
+                    return;
+
+                uint32 mana = procSpell->ManaCost + procSpell->ManaCostPercentage *  GetTarget()->GetCreateMana() / 100;
+                int32 basepoint = CalculatePct(int32(mana), aurEff->GetAmount());
+                GetTarget()->CastCustomSpell(GetTarget(), SPELL_HUNTER_GLYPH_OF_ARCANE_SHOT, &basepoint, NULL, NULL, true, NULL, aurEff, GetCasterGUID());
+            }
+
+            void Register() override
+            {
+                DoCheckProc += AuraCheckProcFn(spell_hun_glyph_of_arcane_shot_AuraScript::CheckProc);
+                OnEffectProc += AuraEffectProcFn(spell_hun_glyph_of_arcane_shot_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_DUMMY);
+            }
+        };
+
+        AuraScript* GetAuraScript() const override
+        {
+            return new spell_hun_glyph_of_arcane_shot_AuraScript();
+        }
+};
+
 void AddSC_hunter_spell_scripts()
 {
     new spell_hun_aspect_of_the_beast();
@@ -967,4 +1028,5 @@ void AddSC_hunter_spell_scripts()
     new spell_hun_tame_beast();
     new spell_hun_target_only_pet_and_owner();
     new spell_hun_viper_attack_speed();
+    new spell_hun_glyph_of_arcane_shot();

@Rushor Rushor changed the title [3.3.5][Core/Aura] Glyph of Arcane Shot - Missing Script [3.3.5] Core/Spell: Glyph of Arcane Shot - Missing Script Feb 9, 2016
@Rushor
Copy link
Contributor Author

Rushor commented Feb 9, 2016

yes the fix in HandleDummyAuraProc works fine. also the spellscript works fine. going to pr it this evening, if you are not first :D

@Rushor Rushor self-assigned this Feb 9, 2016
@Rushor Rushor changed the title [3.3.5] Core/Spell: Glyph of Arcane Shot - Missing Script [3.3.5][Hunter] Core/Spell: Glyph of Arcane Shot - Missing Script Feb 9, 2016
@Rushor Rushor removed their assignment Feb 11, 2016
@Kittnz Kittnz closed this as completed Feb 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants