*Add more Player::CanUseAttackType checks in places where item bonuses are applied.
--HG-- branch : trunk
This commit is contained in:
@@ -1258,13 +1258,12 @@ void Player::Update(uint32 p_time)
|
||||
// If this is set during update SetSpellModTakingSpell call is missing somewhere in the code
|
||||
// Having this would prevent more aura charges to be dropped, so let's crash
|
||||
//assert (!m_spellModTakingSpell);
|
||||
if (/*m_pad ||*/ m_spellModTakingSpell)
|
||||
if ( m_spellModTakingSpell)
|
||||
{
|
||||
//sLog.outCrash("Player has m_pad %u during update!", m_pad);
|
||||
//if (m_spellModTakingSpell)
|
||||
sLog.outCrash("Player has m_spellModTakingSpell %u during update!", m_spellModTakingSpell->m_spellInfo->Id);
|
||||
return;
|
||||
//m_spellModTakingSpell = NULL;
|
||||
sLog.outCrash("Player has m_spellModTakingSpell %u during update!", m_spellModTakingSpell->m_spellInfo->Id);
|
||||
m_spellModTakingSpell = NULL;
|
||||
}
|
||||
|
||||
//used to implement delayed far teleports
|
||||
@@ -5574,7 +5573,7 @@ void Player::SetRegularAttackTime()
|
||||
{
|
||||
for (uint8 i = 0; i < MAX_ATTACK; ++i)
|
||||
{
|
||||
Item *tmpitem = GetWeaponForAttack(WeaponAttackType(i));
|
||||
Item *tmpitem = GetWeaponForAttack(WeaponAttackType(i), true);
|
||||
if (tmpitem && !tmpitem->IsBroken())
|
||||
{
|
||||
ItemPrototype const *proto = tmpitem->GetProto();
|
||||
@@ -7606,7 +7605,7 @@ void Player::_ApplyWeaponDependentAuraCritMod(Item *item, WeaponAttackType attac
|
||||
void Player::_ApplyWeaponDependentAuraDamageMod(Item *item, WeaponAttackType attackType, AuraEffect const* aura, bool apply)
|
||||
{
|
||||
//don't apply mod if item is broken
|
||||
if (item->IsBroken())
|
||||
if (item->IsBroken() || !CanUseAttackType(attackType))
|
||||
return;
|
||||
|
||||
// ignore spell mods for not wands
|
||||
@@ -7715,7 +7714,7 @@ void Player::UpdateEquipSpellsAtFormChange()
|
||||
{
|
||||
for (uint8 i = 0; i < INVENTORY_SLOT_BAG_END; ++i)
|
||||
{
|
||||
if (m_items[i] && !m_items[i]->IsBroken())
|
||||
if (m_items[i] && !m_items[i]->IsBroken() && CanUseAttackType(GetAttackBySlot(i)))
|
||||
{
|
||||
ApplyItemEquipSpell(m_items[i],false,true); // remove spells that not fit to form
|
||||
ApplyItemEquipSpell(m_items[i],true,true); // add spells that fit form but not active
|
||||
@@ -7749,7 +7748,7 @@ void Player::CastItemCombatSpell(Unit *target, WeaponAttackType attType, uint32
|
||||
{
|
||||
// If usable, try to cast item spell
|
||||
if (Item * item = GetItemByPos(INVENTORY_SLOT_BAG_0,i))
|
||||
if (!item->IsBroken())
|
||||
if (!item->IsBroken() && CanUseAttackType(attType))
|
||||
if (ItemPrototype const *proto = item->GetProto())
|
||||
{
|
||||
// Additional check for weapons
|
||||
@@ -7999,7 +7998,7 @@ void Player::_RemoveAllItemMods()
|
||||
if (proto->ItemSet)
|
||||
RemoveItemsSetItem(this,proto);
|
||||
|
||||
if (m_items[i]->IsBroken())
|
||||
if (m_items[i]->IsBroken() || !CanUseAttackType(GetAttackBySlot(i)))
|
||||
continue;
|
||||
|
||||
ApplyItemEquipSpell(m_items[i], false);
|
||||
@@ -8011,7 +8010,7 @@ void Player::_RemoveAllItemMods()
|
||||
{
|
||||
if (m_items[i])
|
||||
{
|
||||
if (m_items[i]->IsBroken())
|
||||
if (m_items[i]->IsBroken() || !CanUseAttackType(GetAttackBySlot(i)))
|
||||
continue;
|
||||
ItemPrototype const *proto = m_items[i]->GetProto();
|
||||
if (!proto)
|
||||
@@ -8039,7 +8038,7 @@ void Player::_ApplyAllItemMods()
|
||||
{
|
||||
if (m_items[i])
|
||||
{
|
||||
if (m_items[i]->IsBroken())
|
||||
if (m_items[i]->IsBroken() || !CanUseAttackType(GetAttackBySlot(i)))
|
||||
continue;
|
||||
|
||||
ItemPrototype const *proto = m_items[i]->GetProto();
|
||||
@@ -8069,7 +8068,7 @@ void Player::_ApplyAllItemMods()
|
||||
if (proto->ItemSet)
|
||||
AddItemsSetItem(this,m_items[i]);
|
||||
|
||||
if (m_items[i]->IsBroken())
|
||||
if (m_items[i]->IsBroken() || !CanUseAttackType(GetAttackBySlot(i)))
|
||||
continue;
|
||||
|
||||
ApplyItemEquipSpell(m_items[i],true);
|
||||
@@ -8086,7 +8085,7 @@ void Player::_ApplyAllLevelScaleItemMods(bool apply)
|
||||
{
|
||||
if (m_items[i])
|
||||
{
|
||||
if (m_items[i]->IsBroken())
|
||||
if (m_items[i]->IsBroken() || !CanUseAttackType(GetAttackBySlot(i)))
|
||||
continue;
|
||||
|
||||
ItemPrototype const *proto = m_items[i]->GetProto();
|
||||
@@ -9542,7 +9541,11 @@ Item* Player::GetWeaponForAttack(WeaponAttackType attackType, bool useable /*= f
|
||||
default: return NULL;
|
||||
}
|
||||
|
||||
Item* item = GetUseableItemByPos(INVENTORY_SLOT_BAG_0, slot);
|
||||
Item* item = NULL;
|
||||
if (useable)
|
||||
GetUseableItemByPos(INVENTORY_SLOT_BAG_0, slot);
|
||||
else
|
||||
GetItemByPos(INVENTORY_SLOT_BAG_0, slot);
|
||||
if (!item || item->GetProto()->Class != ITEM_CLASS_WEAPON)
|
||||
return NULL;
|
||||
|
||||
@@ -9557,7 +9560,11 @@ Item* Player::GetWeaponForAttack(WeaponAttackType attackType, bool useable /*= f
|
||||
|
||||
Item* Player::GetShield(bool useable) const
|
||||
{
|
||||
Item* item = GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND);
|
||||
Item* item = NULL;
|
||||
if (useable)
|
||||
GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND);
|
||||
else
|
||||
GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND);
|
||||
if (!item || item->GetProto()->Class != ITEM_CLASS_ARMOR)
|
||||
return NULL;
|
||||
|
||||
|
||||
@@ -666,7 +666,7 @@ void Player::UpdateExpertise(WeaponAttackType attack)
|
||||
|
||||
int32 expertise = int32(GetRatingBonusValue(CR_EXPERTISE));
|
||||
|
||||
Item *weapon = GetWeaponForAttack(attack);
|
||||
Item *weapon = GetWeaponForAttack(attack, true);
|
||||
|
||||
AuraEffectList const& expAuras = GetAuraEffectsByType(SPELL_AURA_MOD_EXPERTISE);
|
||||
for (AuraEffectList::const_iterator itr = expAuras.begin(); itr != expAuras.end(); ++itr)
|
||||
|
||||
@@ -1585,7 +1585,7 @@ uint32 Unit::CalcArmorReducedDamage(Unit* pVictim, const uint32 damage, SpellEnt
|
||||
// item dependent spell - check curent weapons
|
||||
for (int i = 0; i < MAX_ATTACK; ++i)
|
||||
{
|
||||
Item *weapon = ToPlayer()->GetWeaponForAttack(WeaponAttackType(i));
|
||||
Item *weapon = ToPlayer()->GetWeaponForAttack(WeaponAttackType(i), true);
|
||||
|
||||
if (weapon && weapon->IsFitToSpellRequirements((*itr)->GetSpellProto()))
|
||||
{
|
||||
@@ -14488,7 +14488,7 @@ float Unit::GetAPMultiplier(WeaponAttackType attType, bool normalized)
|
||||
if (!normalized || GetTypeId() != TYPEID_PLAYER)
|
||||
return float(GetAttackTime(attType))/1000.0f;
|
||||
|
||||
Item *Weapon = this->ToPlayer()->GetWeaponForAttack(attType);
|
||||
Item *Weapon = this->ToPlayer()->GetWeaponForAttack(attType, true);
|
||||
if (!Weapon)
|
||||
return 2.4; // fist attack
|
||||
|
||||
|
||||
@@ -4116,7 +4116,7 @@ void Spell::EffectAddHonor(uint32 /*i*/)
|
||||
if (m_CastItem)
|
||||
{
|
||||
unitTarget->ToPlayer()->RewardHonor(NULL, 1, damage/10);
|
||||
sLog.outError("SpellEffect::AddHonor (spell_id %u) rewards %d honor points (item %u) for player: %u", m_spellInfo->Id, damage/10, m_CastItem->GetEntry(),unitTarget->ToPlayer()->GetGUIDLow());
|
||||
sLog.outDebug("SpellEffect::AddHonor (spell_id %u) rewards %d honor points (item %u) for player: %u", m_spellInfo->Id, damage/10, m_CastItem->GetEntry(),unitTarget->ToPlayer()->GetGUIDLow());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user