diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/game/Player.cpp | 31 | ||||
-rw-r--r-- | src/game/Player.h | 13 | ||||
-rw-r--r-- | src/game/SpellAuraDefines.h | 2 | ||||
-rw-r--r-- | src/game/SpellAuras.cpp | 61 | ||||
-rw-r--r-- | src/game/SpellHandler.cpp | 2 | ||||
-rw-r--r-- | src/game/StatSystem.cpp | 11 | ||||
-rw-r--r-- | src/game/Unit.cpp | 22 | ||||
-rw-r--r-- | src/game/Unit.h | 12 |
8 files changed, 95 insertions, 59 deletions
diff --git a/src/game/Player.cpp b/src/game/Player.cpp index bb8be628c54..3d2ed3de5f8 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -6742,7 +6742,12 @@ void Player::_ApplyItemMods(Item *item, uint8 slot,bool apply) sLog.outDetail("applying mods for item %u ",item->GetGUIDLow()); - uint32 attacktype = Player::GetAttackBySlot(slot); + uint8 attacktype = Player::GetAttackBySlot(slot); + + //check disarm only on mod apply to allow remove item mods + if (apply && !CanUseAttackType(attacktype) ) + return; + if(attacktype < MAX_ATTACK) _ApplyWeaponDependentAuraMods(item,WeaponAttackType(attacktype),apply); @@ -6993,7 +6998,7 @@ void Player::_ApplyItemBonuses(ItemPrototype const *proto, uint8 slot, bool appl SetBaseWeaponDamage(attType, MAXDAMAGE, damage); } - if(!IsUseEquipedWeapon(slot==EQUIPMENT_SLOT_MAINHAND)) + if(IsInFeralForm()) return; if (proto->Delay) @@ -8883,14 +8888,14 @@ Item* Player::GetWeaponForAttack(WeaponAttackType attackType, bool useable) cons default: return NULL; } - Item* item = GetItemByPos(INVENTORY_SLOT_BAG_0, slot); + Item* item = GetUseableItemByPos(INVENTORY_SLOT_BAG_0, slot); if (!item || item->GetProto()->Class != ITEM_CLASS_WEAPON) return NULL; if(!useable) return item; - if( item->IsBroken() || !IsUseEquipedWeapon(attackType==BASE_ATTACK) ) + if( item->IsBroken() || IsInFeralForm()) return NULL; return item; @@ -8898,7 +8903,7 @@ Item* Player::GetWeaponForAttack(WeaponAttackType attackType, bool useable) cons Item* Player::GetShield(bool useable) const { - Item* item = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); + Item* item = GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); if (!item || item->GetProto()->Class != ITEM_CLASS_ARMOR) return NULL; @@ -8911,7 +8916,7 @@ Item* Player::GetShield(bool useable) const return item; } -uint32 Player::GetAttackBySlot( uint8 slot ) +uint8 Player::GetAttackBySlot( uint8 slot ) { switch(slot) { @@ -9177,13 +9182,13 @@ bool Player::HasItemTotemCategory( uint32 TotemCategory ) const Item *pItem; for(uint8 i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; ++i) { - pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); + pItem = GetUseableItemByPos( INVENTORY_SLOT_BAG_0, i ); if( pItem && IsTotemCategoryCompatiableWith(pItem->GetProto()->TotemCategory,TotemCategory )) return true; } for(uint8 i = KEYRING_SLOT_START; i < QUESTBAG_SLOT_END; ++i) { - pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); + pItem = GetUseableItemByPos( INVENTORY_SLOT_BAG_0, i ); if( pItem && IsTotemCategoryCompatiableWith(pItem->GetProto()->TotemCategory,TotemCategory )) return true; } @@ -9193,7 +9198,7 @@ bool Player::HasItemTotemCategory( uint32 TotemCategory ) const { for(uint32 j = 0; j < pBag->GetBagSize(); ++j) { - pItem = GetItemByPos( i, j ); + pItem = GetUseableItemByPos( i, j ); if( pItem && IsTotemCategoryCompatiableWith(pItem->GetProto()->TotemCategory,TotemCategory )) return true; } @@ -19153,7 +19158,7 @@ bool Player::HasItemFitToSpellReqirements(SpellEntry const* spellInfo, Item cons case ITEM_CLASS_WEAPON: { for(int i= EQUIPMENT_SLOT_MAINHAND; i < EQUIPMENT_SLOT_TABARD; ++i) - if(Item *item = GetItemByPos( INVENTORY_SLOT_BAG_0, i )) + if(Item *item = GetUseableItemByPos( INVENTORY_SLOT_BAG_0, i )) if(item!=ignoreItem && item->IsFitToSpellRequirements(spellInfo)) return true; break; @@ -19162,17 +19167,17 @@ bool Player::HasItemFitToSpellReqirements(SpellEntry const* spellInfo, Item cons { // tabard not have dependent spells for(int i= EQUIPMENT_SLOT_START; i< EQUIPMENT_SLOT_MAINHAND; ++i) - if(Item *item = GetItemByPos( INVENTORY_SLOT_BAG_0, i )) + if(Item *item = GetUseableItemByPos( INVENTORY_SLOT_BAG_0, i )) if(item!=ignoreItem && item->IsFitToSpellRequirements(spellInfo)) return true; // shields can be equipped to offhand slot - if(Item *item = GetItemByPos( INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND)) + if(Item *item = GetUseableItemByPos( INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND)) if(item!=ignoreItem && item->IsFitToSpellRequirements(spellInfo)) return true; // ranged slot can have some armor subclasses - if(Item *item = GetItemByPos( INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_RANGED)) + if(Item *item = GetUseableItemByPos( INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_RANGED)) if(item!=ignoreItem && item->IsFitToSpellRequirements(spellInfo)) return true; diff --git a/src/game/Player.h b/src/game/Player.h index dde519fdef4..ea76f8253b1 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -1061,9 +1061,15 @@ class TRINITY_DLL_SPEC Player : public Unit Item* GetItemByGuid( uint64 guid ) const; Item* GetItemByPos( uint16 pos ) const; Item* GetItemByPos( uint8 bag, uint8 slot ) const; + inline Item* Player::GetUseableItemByPos( uint8 bag, uint8 slot ) const //Does additional check for disarmed weapons + { + if (!CanUseAttackType(GetAttackBySlot(slot))) + return NULL; + return GetItemByPos(bag, slot); + } Item* GetWeaponForAttack(WeaponAttackType attackType, bool useable = false) const; Item* GetShield(bool useable = false) const; - static uint32 GetAttackBySlot( uint8 slot ); // MAX_ATTACK if not weapon slot + static uint8 GetAttackBySlot( uint8 slot ); // MAX_ATTACK if not weapon slot std::vector<Item *> &GetItemUpdateQueue() { return m_itemUpdateQueue; } static bool IsInventoryPos( uint16 pos ) { return IsInventoryPos(pos >> 8,pos & 255); } static bool IsInventoryPos( uint8 bag, uint8 slot ); @@ -1153,11 +1159,6 @@ class TRINITY_DLL_SPEC Player : public Unit uint32 GetWeaponProficiency() const { return m_WeaponProficiency; } uint32 GetArmorProficiency() const { return m_ArmorProficiency; } bool IsInFeralForm() const { return m_form == FORM_CAT || m_form == FORM_BEAR || m_form == FORM_DIREBEAR; } - bool IsUseEquipedWeapon( bool mainhand ) const - { - // disarm applied only to mainhand weapon - return !IsInFeralForm() && (!mainhand || !HasFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_DISARMED) ); - } bool IsTwoHandUsed() const { Item* mainItem = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND); diff --git a/src/game/SpellAuraDefines.h b/src/game/SpellAuraDefines.h index abe3438aa43..318d5d26df5 100644 --- a/src/game/SpellAuraDefines.h +++ b/src/game/SpellAuraDefines.h @@ -298,7 +298,7 @@ enum AuraType SPELL_AURA_MOD_ENEMY_DODGE = 251, SPELL_AURA_252 = 252, SPELL_AURA_MOD_BLOCK_CRIT_CHANCE = 253, - SPELL_AURA_MOD_DISARM_SHIELD = 254, + SPELL_AURA_MOD_DISARM_OFFHAND = 254, SPELL_AURA_MOD_MECHANIC_DAMAGE_TAKEN_PERCENT = 255, SPELL_AURA_NO_REAGENT_USE = 256, SPELL_AURA_MOD_TARGET_RESIST_BY_SPELL_CLASS = 257, diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index ef843790c26..925f2e66d2e 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -308,7 +308,7 @@ pAuraHandler AuraHandler[TOTAL_AURAS]= &Aura::HandleNULL, //251 SPELL_AURA_MOD_ENEMY_DODGE &Aura::HandleNULL, //252 haste all? &Aura::HandleNULL, //253 SPELL_AURA_MOD_BLOCK_CRIT_CHANCE - &Aura::HandleNULL, //254 SPELL_AURA_MOD_DISARM_SHIELD disarm Shield + &Aura::HandleAuraModDisarm, //254 SPELL_AURA_MOD_DISARM_OFFHAND &Aura::HandleNoImmediateEffect, //255 SPELL_AURA_MOD_MECHANIC_DAMAGE_TAKEN_PERCENT implemented in Unit::SpellDamageBonus &Aura::HandleNoReagentUseAura, //256 SPELL_AURA_NO_REAGENT_USE Use SpellClassMask for spell select &Aura::HandleNULL, //257 SPELL_AURA_MOD_TARGET_RESIST_BY_SPELL_CLASS Use SpellClassMask for spell select @@ -332,7 +332,7 @@ pAuraHandler AuraHandler[TOTAL_AURAS]= &Aura::HandleNoImmediateEffect, //275 SPELL_AURA_MOD_IGNORE_SHAPESHIFT Use SpellClassMask for spell select &Aura::HandleNULL, //276 mod damage % mechanic? &Aura::HandleNoImmediateEffect, //277 SPELL_AURA_MOD_MAX_AFFECTED_TARGETS Use SpellClassMask for spell select - &Aura::HandleNULL, //278 SPELL_AURA_MOD_DISARM_RANGED disarm ranged weapon + &Aura::HandleAuraModDisarm, //278 SPELL_AURA_MOD_DISARM_RANGED disarm ranged weapon &Aura::HandleNULL, //279 &Aura::HandleNULL, //280 SPELL_AURA_MOD_TARGET_ARMOR_PCT &Aura::HandleNoImmediateEffect, //281 SPELL_AURA_MOD_HONOR_GAIN_PCT implemented in Player::RewardHonor @@ -3223,37 +3223,48 @@ void Aura::HandleFeignDeath(bool apply, bool Real) void Aura::HandleAuraModDisarm(bool apply, bool Real) { - if(!Real) - return; - - if(!apply && m_target->HasAuraType(SPELL_AURA_MOD_DISARM)) + if (!Real) return; - - // not sure for it's correctness + AuraType type = GetModifier()->m_auraname; + if(!apply && m_target->HasAuraType(type)) + return; + uint32 field, flag, slot; + WeaponAttackType attType; + switch (type) + { + case SPELL_AURA_MOD_DISARM: + field=UNIT_FIELD_FLAGS; + flag=UNIT_FLAG_DISARMED; + slot=EQUIPMENT_SLOT_MAINHAND; + attType=BASE_ATTACK; + break; + case SPELL_AURA_MOD_DISARM_OFFHAND: + field=UNIT_FIELD_FLAGS_2; + flag=UNIT_FLAG2_DISARM_OFFHAND; + slot=EQUIPMENT_SLOT_OFFHAND; + attType=OFF_ATTACK; + break; + case SPELL_AURA_MOD_DISARM_RANGED: + field=UNIT_FIELD_FLAGS_2; + flag=UNIT_FLAG2_DISARM_RANGED; + slot=EQUIPMENT_SLOT_RANGED; + attType=RANGED_ATTACK; + break; + } if(apply) - m_target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISARMED); + m_target->SetFlag(field, flag); else - m_target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISARMED); + m_target->RemoveFlag(field, flag); if (m_target->GetTypeId() == TYPEID_PLAYER) { - // main-hand attack speed already set to special value for feral form already and don't must change and reset at remove. - if (((Player *)m_target)->IsInFeralForm()) - return; - - if (apply) - m_target->SetAttackTime(BASE_ATTACK,BASE_ATTACK_TIME); - else - ((Player *)m_target)->SetRegularAttackTime(); - } - else - { - // creature does not have equipment - if(apply && !((Creature*)m_target)->GetCurrentEquipmentId()) + Item *pItem = ((Player*)m_target)->GetItemByPos( INVENTORY_SLOT_BAG_0, slot ); + if(!pItem ) return; + ((Player*)m_target)->_ApplyItemMods(pItem, slot, !apply); } - - m_target->UpdateDamagePhysical(BASE_ATTACK); + else if (((Creature*)m_target)->GetCurrentEquipmentId()) + m_target->UpdateDamagePhysical(attType); } void Aura::HandleAuraModStun(bool apply, bool Real) diff --git a/src/game/SpellHandler.cpp b/src/game/SpellHandler.cpp index 4186336fe18..20cf2e87c44 100644 --- a/src/game/SpellHandler.cpp +++ b/src/game/SpellHandler.cpp @@ -50,7 +50,7 @@ void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket) recvPacket >> bagIndex >> slot >> cast_count >> spellid >> item_guid >> glyphIndex >> unk_flags; - Item *pItem = pUser->GetItemByPos(bagIndex, slot); + Item *pItem = pUser->GetUseableItemByPos(bagIndex, slot); if(!pItem) { pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL ); diff --git a/src/game/StatSystem.cpp b/src/game/StatSystem.cpp index 5473206e8bd..8f520125986 100644 --- a/src/game/StatSystem.cpp +++ b/src/game/StatSystem.cpp @@ -427,8 +427,15 @@ void Player::CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, fl weapon_mindamage = lvl*0.85*att_speed; weapon_maxdamage = lvl*1.25*att_speed; } - else if(!IsUseEquipedWeapon(attType==BASE_ATTACK)) //check if player not in form but still can't use weapon (broken/etc) + else if(!CanUseAttackType(attType)) //check if player not in form but still can't use (disarm case) { + //cannot use ranged/off attack, set values to 0 + if (attType != BASE_ATTACK) + { + min_damage=0; + max_damage=0; + return; + } weapon_mindamage = BASE_MINDAMAGE; weapon_maxdamage = BASE_MAXDAMAGE; } @@ -820,7 +827,7 @@ void Creature::UpdateDamagePhysical(WeaponAttackType attType) float total_value = GetModifierValue(unitMod, TOTAL_VALUE); float total_pct = GetModifierValue(unitMod, TOTAL_PCT); - if(attType == BASE_ATTACK && HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISARMED)) + if(!CanUseAttackType(attType)) { weapon_mindamage = 0; weapon_maxdamage = 0; diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index f539ab24b1d..1191b7669fa 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -1293,15 +1293,15 @@ int32 Unit::GetIgnoredArmorMultiplier(SpellEntry const *spellInfo, WeaponAttackT if (GetTypeId() != TYPEID_PLAYER) return 0; //check if spell uses weapon - if (spellInfo && spellInfo->EquippedItemClass!=ITEM_CLASS_WEAPON) + if (!spellInfo || spellInfo->EquippedItemClass!=ITEM_CLASS_WEAPON) return 0; Item *item = NULL; if(attackType == BASE_ATTACK) - item = ((Player*)this)->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND); + item = ((Player*)this)->GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND); else if (attackType == OFF_ATTACK) - item = ((Player*)this)->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); + item = ((Player*)this)->GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); else if (attackType == RANGED_ATTACK) - item = ((Player*)this)->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_RANGED); + item = ((Player*)this)->GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_RANGED); if (!item) return 0; @@ -1657,7 +1657,7 @@ void Unit::DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss) if(GetTypeId() == TYPEID_PLAYER && pVictim->isAlive()) { for(int i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; i++) - ((Player*)this)->CastItemCombatSpell(((Player*)this)->GetItemByPos(INVENTORY_SLOT_BAG_0,i), pVictim, damageInfo->attackType); + ((Player*)this)->CastItemCombatSpell(((Player*)this)->GetUseableItemByPos(INVENTORY_SLOT_BAG_0,i), pVictim, damageInfo->attackType); } // victim's damage shield @@ -2919,7 +2919,7 @@ float Unit::GetUnitBlockChance() const Player const* player = (Player const*)this; if(player->CanBlock() ) { - Item *tmpitem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); + Item *tmpitem = player->GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); if(tmpitem && !tmpitem->IsBroken() && tmpitem->GetProto()->Block) return GetFloatValue(PLAYER_BLOCK_PERCENTAGE); } @@ -11681,13 +11681,13 @@ bool Unit::IsTriggeredAtSpellProcEvent(Unit *pVictim, Aura* aura, SpellEntry con { Item *item = NULL; if(attType == BASE_ATTACK) - item = ((Player*)this)->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND); + item = ((Player*)this)->GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND); else if (attType == OFF_ATTACK) - item = ((Player*)this)->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); + item = ((Player*)this)->GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); else - item = ((Player*)this)->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_RANGED); + item = ((Player*)this)->GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_RANGED); - if (!((Player*)this)->IsUseEquipedWeapon(attType==BASE_ATTACK)) + if (((Player*)this)->IsInFeralForm()) return false; if(!item || item->IsBroken() || item->GetProto()->Class != ITEM_CLASS_WEAPON || !((1<<item->GetProto()->SubClass) & spellProto->EquippedItemSubClassMask)) @@ -11696,7 +11696,7 @@ bool Unit::IsTriggeredAtSpellProcEvent(Unit *pVictim, Aura* aura, SpellEntry con else if(spellProto->EquippedItemClass == ITEM_CLASS_ARMOR) { // Check if player is wearing shield - Item *item = ((Player*)this)->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); + Item *item = ((Player*)this)->GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); if(!item || item->IsBroken() || item->GetProto()->Class != ITEM_CLASS_ARMOR || !((1<<item->GetProto()->SubClass) & spellProto->EquippedItemSubClassMask)) return false; } diff --git a/src/game/Unit.h b/src/game/Unit.h index aa038ab1fb4..ed496526e56 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -544,6 +544,8 @@ enum UnitFlags2 UNIT_FLAG2_UNK1 = 0x00000002, // Hide unit model (show only player equip) UNIT_FLAG2_COMPREHEND_LANG = 0x00000008, UNIT_FLAG2_FORCE_MOVE = 0x00000040, + UNIT_FLAG2_DISARM_OFFHAND = 0x00000080, + UNIT_FLAG2_DISARM_RANGED = 0x00000400, //this does not disable ranged weapon display (maybe additional flag needed?) UNIT_FLAG2_REGENERATE_POWER = 0x00000800 }; @@ -1005,6 +1007,16 @@ class TRINITY_DLL_SPEC Unit : public WorldObject float GetUnitParryChance() const; float GetUnitBlockChance() const; float GetUnitCriticalChance(WeaponAttackType attackType, const Unit *pVictim) const; + bool CanUseAttackType( uint8 attacktype ) const + { + switch(attacktype) + { + case BASE_ATTACK: return !HasFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_DISARMED); + case OFF_ATTACK: return !HasFlag(UNIT_FIELD_FLAGS_2,UNIT_FLAG2_DISARM_OFFHAND); + case RANGED_ATTACK: return !HasFlag(UNIT_FIELD_FLAGS_2,UNIT_FLAG2_DISARM_RANGED); + } + return true; + } virtual uint32 GetShieldBlockValue() const =0; uint32 GetUnitMeleeSkill(Unit const* target = NULL) const { return (target ? getLevelForTarget(target) : getLevel()) * 5; } |