*Cleanup, and beda0979614d redux
--HG-- branch : trunk
This commit is contained in:
+95
-145
@@ -2644,7 +2644,7 @@ void Player::InitStatsForLevel(bool reapplyMods)
|
|||||||
SetUInt32Value(index, 0);
|
SetUInt32Value(index, 0);
|
||||||
|
|
||||||
SetUInt32Value(PLAYER_FIELD_MOD_HEALING_DONE_POS,0);
|
SetUInt32Value(PLAYER_FIELD_MOD_HEALING_DONE_POS,0);
|
||||||
for (uint8 i = 0; i < 7; i++)
|
for (uint8 i = 0; i < 7; ++i)
|
||||||
{
|
{
|
||||||
SetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG+i, 0);
|
SetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG+i, 0);
|
||||||
SetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS+i, 0);
|
SetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS+i, 0);
|
||||||
@@ -2691,7 +2691,7 @@ void Player::InitStatsForLevel(bool reapplyMods)
|
|||||||
SetResistanceBuffMods(SpellSchools(0), true, 0.0f);
|
SetResistanceBuffMods(SpellSchools(0), true, 0.0f);
|
||||||
SetResistanceBuffMods(SpellSchools(0), false, 0.0f);
|
SetResistanceBuffMods(SpellSchools(0), false, 0.0f);
|
||||||
// set other resistance to original value (0)
|
// set other resistance to original value (0)
|
||||||
for (uint8 i = 1; i < MAX_SPELL_SCHOOL; i++)
|
for (uint8 i = 1; i < MAX_SPELL_SCHOOL; ++i)
|
||||||
{
|
{
|
||||||
SetResistance(SpellSchools(i), 0);
|
SetResistance(SpellSchools(i), 0);
|
||||||
SetResistanceBuffMods(SpellSchools(i), true, 0.0f);
|
SetResistanceBuffMods(SpellSchools(i), true, 0.0f);
|
||||||
@@ -2706,13 +2706,13 @@ void Player::InitStatsForLevel(bool reapplyMods)
|
|||||||
SetFloatValue(UNIT_FIELD_POWER_COST_MULTIPLIER+i,0.0f);
|
SetFloatValue(UNIT_FIELD_POWER_COST_MULTIPLIER+i,0.0f);
|
||||||
}
|
}
|
||||||
// Reset no reagent cost field
|
// Reset no reagent cost field
|
||||||
for (uint8 i = 0; i < 3; i++)
|
for (uint8 i = 0; i < 3; ++i)
|
||||||
SetUInt32Value(PLAYER_NO_REAGENT_COST_1 + i, 0);
|
SetUInt32Value(PLAYER_NO_REAGENT_COST_1 + i, 0);
|
||||||
// Init data for form but skip reapply item mods for form
|
// Init data for form but skip reapply item mods for form
|
||||||
InitDataForForm(reapplyMods);
|
InitDataForForm(reapplyMods);
|
||||||
|
|
||||||
// save new stats
|
// save new stats
|
||||||
for (uint8 i = POWER_MANA; i < MAX_POWERS; i++)
|
for (uint8 i = POWER_MANA; i < MAX_POWERS; ++i)
|
||||||
SetMaxPower(Powers(i), uint32(GetCreatePowers(Powers(i))));
|
SetMaxPower(Powers(i), uint32(GetCreatePowers(Powers(i))));
|
||||||
|
|
||||||
SetMaxHealth(classInfo.basehealth); // stamina bonus will applied later
|
SetMaxHealth(classInfo.basehealth); // stamina bonus will applied later
|
||||||
@@ -7326,7 +7326,7 @@ void Player::ApplyEquipSpell(SpellEntry const* spellInfo, Item* item, bool apply
|
|||||||
|
|
||||||
void Player::UpdateEquipSpellsAtFormChange()
|
void Player::UpdateEquipSpellsAtFormChange()
|
||||||
{
|
{
|
||||||
for (uint8 i = 0; i < INVENTORY_SLOT_BAG_END; i++)
|
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())
|
||||||
{
|
{
|
||||||
@@ -7358,10 +7358,10 @@ void Player::CastItemCombatSpell(Unit *target, WeaponAttackType attType, uint32
|
|||||||
if (!target || !target->isAlive() || target == this)
|
if (!target || !target->isAlive() || target == this)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (int i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; i++)
|
for (UINT8 i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; ++i)
|
||||||
{
|
{
|
||||||
// If usable, try to cast item spell
|
// If usable, try to cast item spell
|
||||||
if (Item * item = ((Player*)this)->GetItemByPos(INVENTORY_SLOT_BAG_0,i))
|
if (Item * item = GetItemByPos(INVENTORY_SLOT_BAG_0,i))
|
||||||
if (!item->IsBroken())
|
if (!item->IsBroken())
|
||||||
if (ItemPrototype const *proto = item->GetProto())
|
if (ItemPrototype const *proto = item->GetProto())
|
||||||
{
|
{
|
||||||
@@ -7381,12 +7381,10 @@ void Player::CastItemCombatSpell(Unit *target, WeaponAttackType attType, uint32
|
|||||||
continue;
|
continue;
|
||||||
// Check if item is useable (forms or disarm)
|
// Check if item is useable (forms or disarm)
|
||||||
if (attType == BASE_ATTACK)
|
if (attType == BASE_ATTACK)
|
||||||
{
|
if (!IsUseEquipedWeapon(true))
|
||||||
if (!((Player*)this)->IsUseEquipedWeapon(true))
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
CastItemCombatSpell(target, attType, procVictim, procEx, item, proto);
|
||||||
((Player*)this)->CastItemCombatSpell(target, attType, procVictim, procEx, item, proto);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7397,7 +7395,7 @@ void Player::CastItemCombatSpell(Unit *target, WeaponAttackType attType, uint32
|
|||||||
if (procVictim & PROC_FLAG_TAKEN_ANY_DAMAGE)
|
if (procVictim & PROC_FLAG_TAKEN_ANY_DAMAGE)
|
||||||
//if (damageInfo->procVictim & PROC_FLAG_TAKEN_ANY_DAMAGE)
|
//if (damageInfo->procVictim & PROC_FLAG_TAKEN_ANY_DAMAGE)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 5; i++)
|
for (uint8 i = 0; i < 5; ++i)
|
||||||
{
|
{
|
||||||
_Spell const& spellData = proto->Spells[i];
|
_Spell const& spellData = proto->Spells[i];
|
||||||
|
|
||||||
@@ -7450,12 +7448,12 @@ void Player::CastItemCombatSpell(Unit *target, WeaponAttackType attType, uint32
|
|||||||
}
|
}
|
||||||
|
|
||||||
// item combat enchantments
|
// item combat enchantments
|
||||||
for (int e_slot = 0; e_slot < MAX_ENCHANTMENT_SLOT; ++e_slot)
|
for (uint8 e_slot = 0; e_slot < MAX_ENCHANTMENT_SLOT; ++e_slot)
|
||||||
{
|
{
|
||||||
uint32 enchant_id = item->GetEnchantmentId(EnchantmentSlot(e_slot));
|
uint32 enchant_id = item->GetEnchantmentId(EnchantmentSlot(e_slot));
|
||||||
SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id);
|
SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id);
|
||||||
if(!pEnchant) continue;
|
if(!pEnchant) continue;
|
||||||
for (int s=0; s<3; s++)
|
for (uint8 s = 0; s < 3; ++s)
|
||||||
{
|
{
|
||||||
if(pEnchant->type[s]!=ITEM_ENCHANTMENT_TYPE_COMBAT_SPELL)
|
if(pEnchant->type[s]!=ITEM_ENCHANTMENT_TYPE_COMBAT_SPELL)
|
||||||
continue;
|
continue;
|
||||||
@@ -7533,10 +7531,10 @@ void Player::CastItemUseSpell(Item *item,SpellCastTargets const& targets,uint8 c
|
|||||||
}
|
}
|
||||||
|
|
||||||
// use triggered flag only for items with many spell casts and for not first cast
|
// use triggered flag only for items with many spell casts and for not first cast
|
||||||
int count = 0;
|
uint8 count = 0;
|
||||||
|
|
||||||
// item spells casted at use
|
// item spells casted at use
|
||||||
for (int i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
|
for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
|
||||||
{
|
{
|
||||||
_Spell const& spellData = proto->Spells[i];
|
_Spell const& spellData = proto->Spells[i];
|
||||||
|
|
||||||
@@ -7565,12 +7563,13 @@ void Player::CastItemUseSpell(Item *item,SpellCastTargets const& targets,uint8 c
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Item enchantments spells casted at use
|
// Item enchantments spells casted at use
|
||||||
for (int e_slot = 0; e_slot < MAX_ENCHANTMENT_SLOT; ++e_slot)
|
for (uint8 e_slot = 0; e_slot < MAX_ENCHANTMENT_SLOT; ++e_slot)
|
||||||
{
|
{
|
||||||
uint32 enchant_id = item->GetEnchantmentId(EnchantmentSlot(e_slot));
|
uint32 enchant_id = item->GetEnchantmentId(EnchantmentSlot(e_slot));
|
||||||
SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id);
|
SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id);
|
||||||
if(!pEnchant) continue;
|
if (!pEnchant)
|
||||||
for (int s=0; s<3; s++)
|
continue;
|
||||||
|
for (uint8 s = 0; s < 3; ++s)
|
||||||
{
|
{
|
||||||
if(pEnchant->type[s]!=ITEM_ENCHANTMENT_TYPE_USE_SPELL)
|
if(pEnchant->type[s]!=ITEM_ENCHANTMENT_TYPE_USE_SPELL)
|
||||||
continue;
|
continue;
|
||||||
@@ -7597,7 +7596,7 @@ void Player::_RemoveAllItemMods()
|
|||||||
{
|
{
|
||||||
sLog.outDebug("_RemoveAllItemMods start.");
|
sLog.outDebug("_RemoveAllItemMods start.");
|
||||||
|
|
||||||
for (uint8 i = 0; i < INVENTORY_SLOT_BAG_END; i++)
|
for (uint8 i = 0; i < INVENTORY_SLOT_BAG_END; ++i)
|
||||||
{
|
{
|
||||||
if (m_items[i])
|
if (m_items[i])
|
||||||
{
|
{
|
||||||
@@ -7617,7 +7616,7 @@ void Player::_RemoveAllItemMods()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint8 i = 0; i < INVENTORY_SLOT_BAG_END; i++)
|
for (uint8 i = 0; i < INVENTORY_SLOT_BAG_END; ++i)
|
||||||
{
|
{
|
||||||
if (m_items[i])
|
if (m_items[i])
|
||||||
{
|
{
|
||||||
@@ -7645,7 +7644,7 @@ void Player::_ApplyAllItemMods()
|
|||||||
{
|
{
|
||||||
sLog.outDebug("_ApplyAllItemMods start.");
|
sLog.outDebug("_ApplyAllItemMods start.");
|
||||||
|
|
||||||
for (uint8 i = 0; i < INVENTORY_SLOT_BAG_END; i++)
|
for (uint8 i = 0; i < INVENTORY_SLOT_BAG_END; ++i)
|
||||||
{
|
{
|
||||||
if (m_items[i])
|
if (m_items[i])
|
||||||
{
|
{
|
||||||
@@ -7667,7 +7666,7 @@ void Player::_ApplyAllItemMods()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint8 i = 0; i < INVENTORY_SLOT_BAG_END; i++)
|
for (uint8 i = 0; i < INVENTORY_SLOT_BAG_END; ++i)
|
||||||
{
|
{
|
||||||
if (m_items[i])
|
if (m_items[i])
|
||||||
{
|
{
|
||||||
@@ -7692,7 +7691,7 @@ void Player::_ApplyAllItemMods()
|
|||||||
|
|
||||||
void Player::_ApplyAllLevelScaleItemMods(bool apply)
|
void Player::_ApplyAllLevelScaleItemMods(bool apply)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < INVENTORY_SLOT_BAG_END; ++i)
|
for (uint8 i = 0; i < INVENTORY_SLOT_BAG_END; ++i)
|
||||||
{
|
{
|
||||||
if (m_items[i])
|
if (m_items[i])
|
||||||
{
|
{
|
||||||
@@ -7897,7 +7896,7 @@ void Player::SendLoot(uint64 guid, LootType loot_type)
|
|||||||
{
|
{
|
||||||
Corpse *bones = ObjectAccessor::GetCorpse(*this, guid);
|
Corpse *bones = ObjectAccessor::GetCorpse(*this, guid);
|
||||||
|
|
||||||
if (!bones || !((loot_type == LOOT_CORPSE) || (loot_type == LOOT_INSIGNIA)) || (bones->GetType() != CORPSE_BONES) )
|
if (!bones || !(loot_type == LOOT_CORPSE || loot_type == LOOT_INSIGNIA) || bones->GetType() != CORPSE_BONES)
|
||||||
{
|
{
|
||||||
SendLootRelease(guid);
|
SendLootRelease(guid);
|
||||||
return;
|
return;
|
||||||
@@ -7915,7 +7914,7 @@ void Player::SendLoot(uint64 guid, LootType loot_type)
|
|||||||
loot->FillLoot(1, LootTemplates_Creature, this, true);
|
loot->FillLoot(1, LootTemplates_Creature, this, true);
|
||||||
// It may need a better formula
|
// It may need a better formula
|
||||||
// Now it works like this: lvl10: ~6copper, lvl70: ~9silver
|
// Now it works like this: lvl10: ~6copper, lvl70: ~9silver
|
||||||
bones->loot.gold = (uint32)( urand(50, 150) * 0.016f * pow( ((float)pLevel)/5.76f, 2.5f) * sWorld.getRate(RATE_DROP_MONEY) );
|
bones->loot.gold = uint32(urand(50, 150) * 0.016f * pow(float(pLevel)/5.76f, 2.5f) * sWorld.getRate(RATE_DROP_MONEY));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bones->lootRecipient != this)
|
if (bones->lootRecipient != this)
|
||||||
@@ -8781,7 +8780,14 @@ uint8 Player::FindEquipSlot( ItemPrototype const* proto, uint32 slot, bool swap
|
|||||||
break;
|
break;
|
||||||
case INVTYPE_2HWEAPON:
|
case INVTYPE_2HWEAPON:
|
||||||
slots[0] = EQUIPMENT_SLOT_MAINHAND;
|
slots[0] = EQUIPMENT_SLOT_MAINHAND;
|
||||||
if (CanDualWield() && CanTitanGrip() && proto && proto->SubClass != ITEM_SUBCLASS_WEAPON_POLEARM && proto->SubClass != ITEM_SUBCLASS_WEAPON_STAFF)
|
if (Item *mhWeapon = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND))
|
||||||
|
if (ItemPrototype const *mhWeaponProto = mhWeapon->GetProto())
|
||||||
|
if (mhWeaponProto->SubClass == ITEM_SUBCLASS_WEAPON_POLEARM || mhWeaponProto->SubClass == ITEM_SUBCLASS_WEAPON_STAFF)
|
||||||
|
{
|
||||||
|
const_cast<Player *>(this)->AutoUnequipOffhandIfNeed(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (CanDualWield() && CanTitanGrip() && proto->SubClass != ITEM_SUBCLASS_WEAPON_POLEARM && proto->SubClass != ITEM_SUBCLASS_WEAPON_STAFF)
|
||||||
slots[1] = EQUIPMENT_SLOT_OFFHAND;
|
slots[1] = EQUIPMENT_SLOT_OFFHAND;
|
||||||
break;
|
break;
|
||||||
case INVTYPE_TABARD:
|
case INVTYPE_TABARD:
|
||||||
@@ -8842,34 +8848,24 @@ uint8 Player::FindEquipSlot( ItemPrototype const* proto, uint32 slot, bool swap
|
|||||||
if (slot != NULL_SLOT)
|
if (slot != NULL_SLOT)
|
||||||
{
|
{
|
||||||
if (swap || !GetItemByPos(INVENTORY_SLOT_BAG_0, slot))
|
if (swap || !GetItemByPos(INVENTORY_SLOT_BAG_0, slot))
|
||||||
{
|
for (uint8 i = 0; i < 4; ++i)
|
||||||
for (uint8 i = 0; i < 4; i++)
|
|
||||||
{
|
|
||||||
if (slots[i] == slot)
|
if (slots[i] == slot)
|
||||||
return slot;
|
return slot;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// search free slot at first
|
// search free slot at first
|
||||||
for (uint8 i = 0; i < 4; i++)
|
for (uint8 i = 0; i < 4; ++i)
|
||||||
{
|
|
||||||
if (slots[i] != NULL_SLOT && !GetItemByPos(INVENTORY_SLOT_BAG_0, slots[i]))
|
if (slots[i] != NULL_SLOT && !GetItemByPos(INVENTORY_SLOT_BAG_0, slots[i]))
|
||||||
{
|
|
||||||
// in case 2hand equipped weapon (without titan grip) offhand slot empty but not free
|
// in case 2hand equipped weapon (without titan grip) offhand slot empty but not free
|
||||||
if(slots[i] != EQUIPMENT_SLOT_OFFHAND || !IsTwoHandUsed())
|
if(slots[i] != EQUIPMENT_SLOT_OFFHAND || !IsTwoHandUsed())
|
||||||
return slots[i];
|
return slots[i];
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// if not found free and can swap return first appropriate from used
|
// if not found free and can swap return first appropriate from used
|
||||||
for (uint8 i = 0; i < 4; i++)
|
for (uint8 i = 0; i < 4; ++i)
|
||||||
{
|
|
||||||
if (slots[i] != NULL_SLOT && swap)
|
if (slots[i] != NULL_SLOT && swap)
|
||||||
return slots[i];
|
return slots[i];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// no free position
|
// no free position
|
||||||
return NULL_SLOT;
|
return NULL_SLOT;
|
||||||
@@ -8877,15 +8873,13 @@ uint8 Player::FindEquipSlot( ItemPrototype const* proto, uint32 slot, bool swap
|
|||||||
|
|
||||||
uint8 Player::CanUnequipItems( uint32 item, uint32 count ) const
|
uint8 Player::CanUnequipItems( uint32 item, uint32 count ) const
|
||||||
{
|
{
|
||||||
Item *pItem;
|
|
||||||
uint32 tempcount = 0;
|
uint32 tempcount = 0;
|
||||||
|
|
||||||
uint8 res = EQUIP_ERR_OK;
|
uint8 res = EQUIP_ERR_OK;
|
||||||
|
|
||||||
for (uint8 i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_BAG_END; i++)
|
for (uint8 i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_BAG_END; ++i)
|
||||||
{
|
if (Item *pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i))
|
||||||
pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i );
|
if (pItem->GetEntry() == item)
|
||||||
if( pItem && pItem->GetEntry() == item )
|
|
||||||
{
|
{
|
||||||
uint8 ires = CanUnequipItem(INVENTORY_SLOT_BAG_0 << 8 | i, false);
|
uint8 ires = CanUnequipItem(INVENTORY_SLOT_BAG_0 << 8 | i, false);
|
||||||
if (ires == EQUIP_ERR_OK)
|
if (ires == EQUIP_ERR_OK)
|
||||||
@@ -8897,45 +8891,35 @@ uint8 Player::CanUnequipItems( uint32 item, uint32 count ) const
|
|||||||
else
|
else
|
||||||
res = ires;
|
res = ires;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
for (uint8 i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; i++)
|
for (uint8 i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; ++i)
|
||||||
{
|
if (Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i))
|
||||||
pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i );
|
if (pItem->GetEntry() == item)
|
||||||
if( pItem && pItem->GetEntry() == item )
|
|
||||||
{
|
{
|
||||||
tempcount += pItem->GetCount();
|
tempcount += pItem->GetCount();
|
||||||
if (tempcount >= count)
|
if (tempcount >= count)
|
||||||
return EQUIP_ERR_OK;
|
return EQUIP_ERR_OK;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
for (uint8 i = KEYRING_SLOT_START; i < CURRENCYTOKEN_SLOT_END; ++i)
|
for (uint8 i = KEYRING_SLOT_START; i < CURRENCYTOKEN_SLOT_END; ++i)
|
||||||
{
|
if (Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i))
|
||||||
pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i );
|
if (pItem->GetEntry() == item)
|
||||||
if( pItem && pItem->GetEntry() == item )
|
|
||||||
{
|
{
|
||||||
tempcount += pItem->GetCount();
|
tempcount += pItem->GetCount();
|
||||||
if(tempcount >= count)
|
if(tempcount >= count)
|
||||||
return EQUIP_ERR_OK;
|
return EQUIP_ERR_OK;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
Bag *pBag;
|
for (uint8 i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i)
|
||||||
for (uint8 i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++)
|
if (Bag *pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i))
|
||||||
{
|
for (uint32 j = 0; j < pBag->GetBagSize(); ++j)
|
||||||
pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i );
|
if (Item *pItem = GetItemByPos(i, j))
|
||||||
if( pBag )
|
if (pItem->GetEntry() == item)
|
||||||
{
|
|
||||||
for (uint32 j = 0; j < pBag->GetBagSize(); j++)
|
|
||||||
{
|
|
||||||
pItem = GetItemByPos( i, j );
|
|
||||||
if( pItem && pItem->GetEntry() == item )
|
|
||||||
{
|
{
|
||||||
tempcount += pItem->GetCount();
|
tempcount += pItem->GetCount();
|
||||||
if (tempcount >= count)
|
if (tempcount >= count)
|
||||||
return EQUIP_ERR_OK;
|
return EQUIP_ERR_OK;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// not found req. item count and have unequippable items
|
// not found req. item count and have unequippable items
|
||||||
return res;
|
return res;
|
||||||
@@ -8945,104 +8929,71 @@ uint32 Player::GetItemCount( uint32 item, bool inBankAlso, Item* skipItem ) cons
|
|||||||
{
|
{
|
||||||
uint32 count = 0;
|
uint32 count = 0;
|
||||||
for (uint8 i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; i++)
|
for (uint8 i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; i++)
|
||||||
{
|
if (Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i))
|
||||||
Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i );
|
if (pItem != skipItem && pItem->GetEntry() == item)
|
||||||
if( pItem && pItem != skipItem && pItem->GetEntry() == item )
|
|
||||||
count += pItem->GetCount();
|
count += pItem->GetCount();
|
||||||
}
|
|
||||||
for (uint8 i = KEYRING_SLOT_START; i < CURRENCYTOKEN_SLOT_END; ++i)
|
for (uint8 i = KEYRING_SLOT_START; i < CURRENCYTOKEN_SLOT_END; ++i)
|
||||||
{
|
if (Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i))
|
||||||
Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i );
|
if (pItem != skipItem && pItem->GetEntry() == item)
|
||||||
if( pItem && pItem != skipItem && pItem->GetEntry() == item )
|
|
||||||
count += pItem->GetCount();
|
count += pItem->GetCount();
|
||||||
}
|
|
||||||
for (uint8 i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++)
|
for (uint8 i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i)
|
||||||
{
|
if (Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, i))
|
||||||
Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i );
|
|
||||||
if( pBag )
|
|
||||||
count += pBag->GetItemCount(item,skipItem);
|
count += pBag->GetItemCount(item,skipItem);
|
||||||
}
|
|
||||||
|
|
||||||
if(skipItem && skipItem->GetProto()->GemProperties)
|
if(skipItem && skipItem->GetProto()->GemProperties)
|
||||||
{
|
for (uint8 i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; ++i)
|
||||||
for (uint8 i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; i++)
|
if (Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i))
|
||||||
{
|
if (pItem != skipItem && pItem->GetProto()->Socket[0].Color)
|
||||||
Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i );
|
|
||||||
if( pItem && pItem != skipItem && pItem->GetProto()->Socket[0].Color )
|
|
||||||
count += pItem->GetGemCountWithID(item);
|
count += pItem->GetGemCountWithID(item);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (inBankAlso)
|
if (inBankAlso)
|
||||||
{
|
{
|
||||||
for (uint8 i = BANK_SLOT_ITEM_START; i < BANK_SLOT_ITEM_END; i++)
|
for (uint8 i = BANK_SLOT_ITEM_START; i < BANK_SLOT_ITEM_END; ++i)
|
||||||
{
|
if (Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i))
|
||||||
Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i );
|
if (pItem != skipItem && pItem->GetEntry() == item)
|
||||||
if( pItem && pItem != skipItem && pItem->GetEntry() == item )
|
|
||||||
count += pItem->GetCount();
|
count += pItem->GetCount();
|
||||||
}
|
|
||||||
for (uint8 i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; i++)
|
for (uint8 i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; ++i)
|
||||||
{
|
if (Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i))
|
||||||
Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i );
|
|
||||||
if( pBag )
|
|
||||||
count += pBag->GetItemCount(item,skipItem);
|
count += pBag->GetItemCount(item,skipItem);
|
||||||
}
|
|
||||||
|
|
||||||
if (skipItem && skipItem->GetProto()->GemProperties)
|
if (skipItem && skipItem->GetProto()->GemProperties)
|
||||||
{
|
for (uint8 i = BANK_SLOT_ITEM_START; i < BANK_SLOT_ITEM_END; ++i)
|
||||||
for (uint8 i = BANK_SLOT_ITEM_START; i < BANK_SLOT_ITEM_END; i++)
|
if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i))
|
||||||
{
|
if (pItem != skipItem && pItem->GetProto()->Socket[0].Color)
|
||||||
Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i );
|
|
||||||
if( pItem && pItem != skipItem && pItem->GetProto()->Socket[0].Color )
|
|
||||||
count += pItem->GetGemCountWithID(item);
|
count += pItem->GetGemCountWithID(item);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
Item* Player::GetItemByGuid( uint64 guid ) const
|
Item* Player::GetItemByGuid( uint64 guid ) const
|
||||||
{
|
{
|
||||||
for (uint8 i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; i++)
|
for (uint8 i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; ++i)
|
||||||
{
|
if (Item *pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i))
|
||||||
Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i );
|
if (pItem->GetGUID() == guid)
|
||||||
if( pItem && pItem->GetGUID() == guid )
|
|
||||||
return pItem;
|
return pItem;
|
||||||
}
|
|
||||||
for (uint8 i = KEYRING_SLOT_START; i < CURRENCYTOKEN_SLOT_END; ++i)
|
|
||||||
{
|
|
||||||
Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i );
|
|
||||||
if( pItem && pItem->GetGUID() == guid )
|
|
||||||
return pItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (uint8 i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++)
|
for (uint8 i = KEYRING_SLOT_START; i < CURRENCYTOKEN_SLOT_END; ++i)
|
||||||
{
|
if (Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i))
|
||||||
Bag *pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i );
|
if (pItem->GetGUID() == guid)
|
||||||
if( pBag )
|
|
||||||
{
|
|
||||||
for (uint32 j = 0; j < pBag->GetBagSize(); j++)
|
|
||||||
{
|
|
||||||
Item* pItem = pBag->GetItemByPos( j );
|
|
||||||
if( pItem && pItem->GetGUID() == guid )
|
|
||||||
return pItem;
|
return pItem;
|
||||||
}
|
|
||||||
}
|
for (uint8 i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i)
|
||||||
}
|
if (Bag *pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, i))
|
||||||
for (uint8 i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; i++)
|
for (uint32 j = 0; j < pBag->GetBagSize(); ++j)
|
||||||
{
|
if (Item* pItem = pBag->GetItemByPos(j))
|
||||||
Bag *pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i );
|
if (pItem->GetGUID() == guid)
|
||||||
if( pBag )
|
return pItem;
|
||||||
{
|
|
||||||
for (uint32 j = 0; j < pBag->GetBagSize(); j++)
|
for (uint8 i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; ++i)
|
||||||
{
|
if (Bag *pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, i))
|
||||||
Item* pItem = pBag->GetItemByPos( j );
|
for (uint32 j = 0; j < pBag->GetBagSize(); ++j)
|
||||||
if( pItem && pItem->GetGUID() == guid )
|
if (Item* pItem = pBag->GetItemByPos(j))
|
||||||
|
if (pItem->GetGUID() == guid)
|
||||||
return pItem;
|
return pItem;
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -9061,14 +9012,13 @@ Item* Player::GetItemByPos( uint8 bag, uint8 slot ) const
|
|||||||
else if ((bag >= INVENTORY_SLOT_BAG_START && bag < INVENTORY_SLOT_BAG_END)
|
else if ((bag >= INVENTORY_SLOT_BAG_START && bag < INVENTORY_SLOT_BAG_END)
|
||||||
|| (bag >= BANK_SLOT_BAG_START && bag < BANK_SLOT_BAG_END))
|
|| (bag >= BANK_SLOT_BAG_START && bag < BANK_SLOT_BAG_END))
|
||||||
{
|
{
|
||||||
Bag *pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, bag );
|
if (Bag *pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, bag))
|
||||||
if ( pBag )
|
|
||||||
return pBag->GetItemByPos(slot);
|
return pBag->GetItemByPos(slot);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Item* Player::GetWeaponForAttack(WeaponAttackType attackType, bool useable) const
|
Item* Player::GetWeaponForAttack(WeaponAttackType attackType, bool useable /*= false*/) const
|
||||||
{
|
{
|
||||||
uint16 slot;
|
uint16 slot;
|
||||||
switch (attackType)
|
switch (attackType)
|
||||||
@@ -19979,14 +19929,14 @@ void Player::AddItemDurations( Item *item )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::AutoUnequipOffhandIfNeed()
|
void Player::AutoUnequipOffhandIfNeed(bool force /*= false*/)
|
||||||
{
|
{
|
||||||
Item *offItem = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND);
|
Item *offItem = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND);
|
||||||
if(!offItem)
|
if(!offItem)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// need unequip offhand for 2h-weapon without TitanGrip (in any from hands)
|
// need unequip offhand for 2h-weapon without TitanGrip (in any from hands)
|
||||||
if (CanTitanGrip() || (offItem->GetProto()->InventoryType != INVTYPE_2HWEAPON && !IsTwoHandUsed()))
|
if (!force && (CanTitanGrip() || (offItem->GetProto()->InventoryType != INVTYPE_2HWEAPON && !IsTwoHandUsed())))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ItemPosCountVec off_dest;
|
ItemPosCountVec off_dest;
|
||||||
|
|||||||
+2
-10
@@ -1125,7 +1125,7 @@ class MANGOS_DLL_SPEC Player : public Unit
|
|||||||
Item* StoreItem( ItemPosCountVec const& pos, Item *pItem, bool update );
|
Item* StoreItem( ItemPosCountVec const& pos, Item *pItem, bool update );
|
||||||
Item* EquipNewItem( uint16 pos, uint32 item, bool update );
|
Item* EquipNewItem( uint16 pos, uint32 item, bool update );
|
||||||
Item* EquipItem( uint16 pos, Item *pItem, bool update );
|
Item* EquipItem( uint16 pos, Item *pItem, bool update );
|
||||||
void AutoUnequipOffhandIfNeed();
|
void AutoUnequipOffhandIfNeed(bool force = false);
|
||||||
bool StoreNewItemInBestSlots(uint32 item_id, uint32 item_count);
|
bool StoreNewItemInBestSlots(uint32 item_id, uint32 item_count);
|
||||||
void AutoStoreLoot(uint8 bag, uint8 slot, uint32 loot_id, LootStore const& store, bool broadcast = false);
|
void AutoStoreLoot(uint8 bag, uint8 slot, uint32 loot_id, LootStore const& store, bool broadcast = false);
|
||||||
void AutoStoreLoot(uint32 loot_id, LootStore const& store, bool broadcast = false) { AutoStoreLoot(NULL_BAG,NULL_SLOT,loot_id,store,broadcast); }
|
void AutoStoreLoot(uint32 loot_id, LootStore const& store, bool broadcast = false) { AutoStoreLoot(NULL_BAG,NULL_SLOT,loot_id,store,broadcast); }
|
||||||
@@ -1854,15 +1854,7 @@ class MANGOS_DLL_SPEC Player : public Unit
|
|||||||
void SetCanParry(bool value);
|
void SetCanParry(bool value);
|
||||||
bool CanBlock() const { return m_canBlock; }
|
bool CanBlock() const { return m_canBlock; }
|
||||||
void SetCanBlock(bool value);
|
void SetCanBlock(bool value);
|
||||||
bool CanTitanGrip() const
|
bool CanTitanGrip() const { return m_canTitanGrip; }
|
||||||
{
|
|
||||||
Item *mainItem = GetItemByPos( INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND );
|
|
||||||
|
|
||||||
if (mainItem && ( mainItem->GetProto()->SubClass == ITEM_SUBCLASS_WEAPON_POLEARM || mainItem->GetProto()->SubClass == ITEM_SUBCLASS_WEAPON_STAFF ))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return m_canTitanGrip ;
|
|
||||||
}
|
|
||||||
void SetCanTitanGrip(bool value) { m_canTitanGrip = value; }
|
void SetCanTitanGrip(bool value) { m_canTitanGrip = value; }
|
||||||
bool CanTameExoticPets() const { return isGameMaster() || HasAuraType(SPELL_AURA_ALLOW_TAME_PET_TYPE); }
|
bool CanTameExoticPets() const { return isGameMaster() || HasAuraType(SPELL_AURA_ALLOW_TAME_PET_TYPE); }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user