All pastes #917589 Raw Edit

Something

public text v1 · immutable
#917589 ·published 2008-02-25 15:00 UTC
rendered paste body
Index: game/SpellEffects.cpp
===================================================================
--- game/SpellEffects.cpp	(revision 5306)
+++ game/SpellEffects.cpp	(working copy)
@@ -1395,6 +1395,43 @@
         {
             m_caster->CastSpell(unitTarget, 31790, true);
             return;
+        }
+        // Vanish
+        case 18461:
+        {
+            m_caster->RemoveSpellsCausingAura(SPELL_AURA_MOD_ROOT);
+            m_caster->RemoveSpellsCausingAura(SPELL_AURA_MOD_DECREASE_SPEED);
+            m_caster->RemoveSpellsCausingAura(SPELL_AURA_MOD_STALKED);
+
+			// if this spell is given to NPC it must handle rest by it's own AI
+            if ( m_caster->GetTypeId() != TYPEID_PLAYER )
+                return;
+
+            // Get highest rank of the Stealth spell
+            uint32 spellId = 0;
+            const PlayerSpellMap& sp_list = ((Player *)m_caster)->GetSpellMap();
+            for (PlayerSpellMap::const_iterator itr = sp_list.begin(); itr != sp_list.end(); ++itr)
+            {
+                if(itr->second->state == PLAYERSPELL_REMOVED) continue;
+                SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first);
+                if (!spellInfo) continue;
+                
+                if (spellInfo->SpellFamilyName == SPELLFAMILY_ROGUE && spellInfo->SpellFamilyFlags & SPELLFAMILYFLAG_ROGUE_STEALTH)
+                {
+                    spellId = spellInfo->Id;
+                    break;
+                }
+            }
+            // No Stealth spell found
+            if (!spellId)
+                return;
+
+            // Reset Cooldown on it if needed
+            if(((Player *)m_caster)->HasSpellCooldown(spellId))
+                ((Player *)m_caster)->RemoveSpellCooldown(spellId);
+
+            m_caster->CastSpell(m_caster, spellId, true);
+            return;
         }
     }
 
@@ -3742,11 +3779,6 @@
 
     unitTarget->CombatStop();
     unitTarget->getHostilRefManager().deleteReferences();   // stop all fighting
-    //Vanish allows to remove all threat and cast regular stealth so other spells can be used
-    if(m_spellInfo->SpellFamilyName == SPELLFAMILY_ROGUE && (m_spellInfo->SpellFamilyFlags & SPELLFAMILYFLAG_ROGUE_VANISH))
-    {
-        ((Player *)m_caster)->RemoveSpellsCausingAura(SPELL_AURA_MOD_ROOT);
-    }
 }
 
 void Spell::EffectAddComboPoints(uint32 /*i*/)