diff options
Diffstat (limited to 'src/game/Player.cpp')
-rw-r--r-- | src/game/Player.cpp | 60 |
1 files changed, 48 insertions, 12 deletions
diff --git a/src/game/Player.cpp b/src/game/Player.cpp index c449c53b23b..b24b3da2ace 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -6990,17 +6990,53 @@ void Player::UpdateEquipSpellsAtFormChange() } } } - -void Player::CastItemCombatSpell(Item *item, CalcDamageInfo *damageInfo, ItemPrototype const * proto) +void Player::CastItemCombatSpell(Unit *target, WeaponAttackType attType, uint32 procVictim, uint32 procEx) { - Unit * Target = damageInfo->target; - WeaponAttackType attType = damageInfo->attackType; - - if (!Target || Target == this ) + if(!target || !target->isAlive() || target == this) return; + for(int i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; i++) + { + // If usable, try to cast item spell + if (Item * item = ((Player*)this)->GetItemByPos(INVENTORY_SLOT_BAG_0,i)) + if(!item->IsBroken()) + if (ItemPrototype const *proto = item->GetProto()) + { + // Additional check for weapons + if (proto->Class==ITEM_CLASS_WEAPON) + { + // offhand item cannot proc from main hand hit etc + EquipmentSlots slot; + switch (attType) + { + case BASE_ATTACK: slot = EQUIPMENT_SLOT_MAINHAND; break; + case OFF_ATTACK: slot = EQUIPMENT_SLOT_OFFHAND; break; + case RANGED_ATTACK: slot = EQUIPMENT_SLOT_RANGED; break; + default: slot = EQUIPMENT_SLOT_END; break; + } + if (slot != i) + continue; + // Check if item is useable (forms or disarm) + if (attType == BASE_ATTACK) + { + if (!((Player*)this)->IsUseEquipedWeapon(true)) + continue; + } + else + { + if (((Player*)this)->IsInFeralForm()) + continue; + } + } + ((Player*)this)->CastItemCombatSpell(target, attType, procVictim, procEx, item, proto); + } + } +} + +void Player::CastItemCombatSpell(Unit *target, WeaponAttackType attType, uint32 procVictim, uint32 procEx, Item *item, ItemPrototype const * proto) +{ // Can do effect if any damage done to target - if (damageInfo->procVictim & PROC_FLAG_TAKEN_ANY_DAMAGE) + if (procVictim & PROC_FLAG_TAKEN_ANY_DAMAGE) { for (int i = 0; i < 5; i++) { @@ -7022,7 +7058,7 @@ void Player::CastItemCombatSpell(Item *item, CalcDamageInfo *damageInfo, ItemPro } // not allow proc extra attack spell at extra attack - if( m_extraAttacks && IsSpellHaveEffect(spellInfo,SPELL_EFFECT_ADD_EXTRA_ATTACKS) ) + if( m_extraAttacks && IsSpellHaveEffect(spellInfo, SPELL_EFFECT_ADD_EXTRA_ATTACKS) ) return; float chance = spellInfo->procChance; @@ -7038,7 +7074,7 @@ void Player::CastItemCombatSpell(Item *item, CalcDamageInfo *damageInfo, ItemPro } if (roll_chance_f(chance)) - CastSpell(Target, spellInfo->Id, true, item); + CastSpell(target, spellInfo->Id, true, item); } } @@ -7058,13 +7094,13 @@ void Player::CastItemCombatSpell(Item *item, CalcDamageInfo *damageInfo, ItemPro if (entry && entry->procEx) { // Check hit/crit/dodge/parry requirement - if((entry->procEx & damageInfo->procEx) == 0) + if((entry->procEx & procEx) == 0) continue; } else { // Can do effect if any damage done to target - if (!(damageInfo->procVictim & PROC_FLAG_TAKEN_ANY_DAMAGE)) + if (!(procVictim & PROC_FLAG_TAKEN_ANY_DAMAGE)) continue; } @@ -7093,7 +7129,7 @@ void Player::CastItemCombatSpell(Item *item, CalcDamageInfo *damageInfo, ItemPro if(IsPositiveSpell(pEnchant->spellid[s])) CastSpell(this, pEnchant->spellid[s], true, item); else - CastSpell(Target, pEnchant->spellid[s], true, item); + CastSpell(target, pEnchant->spellid[s], true, item); } } } |