All pastes #916702 Raw Edit

Untitled

public text v1 · immutable
#916702 ·published 2008-02-24 21:29 UTC
rendered paste body
Index: game/Player.cpp
===================================================================
--- game/Player.cpp	(revision 5293)
+++ game/Player.cpp	(working copy)
@@ -6030,7 +6030,7 @@
         _ApplyAmmoBonuses();
 
     if(apply)
-        CastItemEquipSpell(item);
+        CastItemEquipSpell(item, false);
     else
         for (int i = 0; i < 5; i++)
             if(proto->Spells[i].SpellId)
@@ -6385,7 +6385,7 @@
     }
 }
 
-void Player::CastItemEquipSpell(Item *item)
+void Player::CastItemEquipSpell(Item *item, bool Shapeshift)
 {
     if(!item) return;
 
@@ -6405,6 +6405,19 @@
         if(spellData.SpellTrigger != ITEM_SPELLTRIGGER_ON_EQUIP)
             continue;
 
+        // check if it is valid spell
+        SpellEntry const* spellproto = sSpellStore.LookupEntry(spellData.SpellId);
+        if(!spellproto)
+            continue;
+
+        // Cannot be used in this stance/form
+        if ( !(spellproto->Stances & (1<<(m_form-1))))
+            continue;
+
+        // Shapeshift apply only spells with stance/form requirement
+        if ( Shapeshift && !spellproto->Stances)
+			continue;
+
         DEBUG_LOG("WORLD: cast Item spellId - %i", spellData.SpellId);
 
         CastSpell(this,spellData.SpellId,true,item);
@@ -6578,7 +6591,7 @@
             if(proto->ItemSet)
                 AddItemsSetItem(this,m_items[i]);
 
-            CastItemEquipSpell(m_items[i]);
+            CastItemEquipSpell(m_items[i], false);
 
             ApplyEnchantment(m_items[i], true);
         }
@@ -15203,6 +15216,10 @@
             break;
         }
     }
+    // apply auras in this form
+    for (int i = 0; i < INVENTORY_SLOT_BAG_END; i++)
+        if(m_items[i])
+            CastItemEquipSpell(m_items[i], true);
 
     UpdateAttackPowerAndDamage();
     UpdateAttackPowerAndDamage(true);
Index: game/Player.h
===================================================================
--- game/Player.h	(revision 5293)
+++ game/Player.h	(working copy)
@@ -1633,7 +1633,7 @@
         void CorrectMetaGemEnchants(uint8 slot, bool apply);
         void InitDataForForm();
 
-        void CastItemEquipSpell(Item *item);
+        void CastItemEquipSpell(Item *item, bool Shapeshift);
         void CastItemCombatSpell(Item *item,Unit* Target, WeaponAttackType attType);
 
         void SendInitWorldStates();