diff options
Diffstat (limited to 'src/game/Unit.cpp')
-rw-r--r-- | src/game/Unit.cpp | 64 |
1 files changed, 31 insertions, 33 deletions
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 7117449ae34..d0b71d0f3a3 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -1615,41 +1615,39 @@ void Unit::DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss) { for(int i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; i++) { - EquipmentSlots slot = (EquipmentSlots)i; - // For weapon slots check if valid attack type and if weapon useable - if (i == EQUIPMENT_SLOT_MAINHAND - || i == EQUIPMENT_SLOT_OFFHAND - || i == EQUIPMENT_SLOT_RANGED) - { - switch (damageInfo->attackType) - { - 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; - } - // offhand item cannot proc from main hand hit etc - if (slot != i) - slot=EQUIPMENT_SLOT_END; - else - { - // Check if item is useable (forms or disarm) - if (damageInfo->attackType == BASE_ATTACK) - { - if (!((Player*)this)->IsUseEquipedWeapon(true)) - slot=EQUIPMENT_SLOT_END; - } - else if (damageInfo->attackType == OFF_ATTACK) + // 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()) { - if (((Player*)this)->IsInFeralForm()) - slot=EQUIPMENT_SLOT_END; + // Additional check for weapons + if (proto->Class==ITEM_CLASS_WEAPON) + { + // offhand item cannot proc from main hand hit etc + EquipmentSlots slot; + switch (damageInfo->attackType) + { + 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 (damageInfo->attackType == BASE_ATTACK) + { + if (!((Player*)this)->IsUseEquipedWeapon(true)) + continue; + } + else + { + if (((Player*)this)->IsInFeralForm()) + continue; + } + } + ((Player*)this)->CastItemCombatSpell(item, damageInfo, proto); } - } - } - // If usable, try to cast item spell - if(slot!=EQUIPMENT_SLOT_END) - ((Player*)this)->CastItemCombatSpell(((Player*)this)->GetItemByPos(INVENTORY_SLOT_BAG_0,i), damageInfo); } } |