* Implement additional usage of item_template.FlagsExtra Horde / Ally only
* Check loot (no longer need loot condition) * Check equip/use * Original patch by Vladimir * Ported to Trinity by Az@zel --HG-- branch : trunk
This commit is contained in:
@@ -42,7 +42,7 @@ enum InventoryChangeFailure
|
||||
{
|
||||
EQUIP_ERR_OK = 0,
|
||||
EQUIP_ERR_CANT_EQUIP_LEVEL_I = 1,
|
||||
EQUIP_ERR_ERR_CANT_EQUIP_SKILL = 2,
|
||||
EQUIP_ERR_CANT_EQUIP_SKILL = 2,
|
||||
EQUIP_ERR_ITEM_DOESNT_GO_TO_SLOT = 3,
|
||||
EQUIP_ERR_BAG_FULL = 4,
|
||||
EQUIP_ERR_NONEMPTY_BAG_OVER_OTHER_BAG = 5,
|
||||
|
||||
@@ -10883,9 +10883,10 @@ uint8 Player::CanEquipItem(uint8 slot, uint16 &dest, Item *pItem, bool swap, boo
|
||||
if (eslot == NULL_SLOT)
|
||||
return EQUIP_ERR_ITEM_CANT_BE_EQUIPPED;
|
||||
|
||||
uint8 msg = CanUseItem(pItem , not_loading);
|
||||
if (msg != EQUIP_ERR_OK)
|
||||
return msg;
|
||||
res = CanUseItem(pItem, not_loading);
|
||||
if (res != EQUIP_ERR_OK)
|
||||
return res;
|
||||
|
||||
if (!swap && GetItemByPos(INVENTORY_SLOT_BAG_0, eslot))
|
||||
return EQUIP_ERR_NO_EQUIPMENT_SLOT_AVAILABLE;
|
||||
|
||||
@@ -11039,8 +11040,9 @@ uint8 Player::CanBankItem(uint8 bag, uint8 slot, ItemPosCountVec &dest, Item *pI
|
||||
if (slot - BANK_SLOT_BAG_START >= GetBankBagSlotCount())
|
||||
return EQUIP_ERR_MUST_PURCHASE_THAT_BAG_SLOT;
|
||||
|
||||
if (uint8 cantuse = CanUseItem(pItem, not_loading) != EQUIP_ERR_OK)
|
||||
return cantuse;
|
||||
res = CanUseItem(pItem, not_loading);
|
||||
if (res != EQUIP_ERR_OK)
|
||||
return res;
|
||||
}
|
||||
|
||||
res = _CanStoreItem_InSpecificSlot(bag,slot,dest,pProto,count,swap,pItem);
|
||||
@@ -11203,8 +11205,9 @@ uint8 Player::CanUseItem(Item *pItem, bool not_loading) const
|
||||
if (pItem->IsBindedNotWith(this))
|
||||
return EQUIP_ERR_DONT_OWN_THAT_ITEM;
|
||||
|
||||
if ((pProto->AllowableClass & getClassMask()) == 0 || (pProto->AllowableRace & getRaceMask()) == 0)
|
||||
return EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM;
|
||||
uint8 res = CanUseItem(pProto);
|
||||
if (res != EQUIP_ERR_OK)
|
||||
return res;
|
||||
|
||||
if (pItem->GetSkill() != 0)
|
||||
{
|
||||
@@ -11234,52 +11237,44 @@ uint8 Player::CanUseItem(Item *pItem, bool not_loading) const
|
||||
return EQUIP_ERR_NO_REQUIRED_PROFICIENCY;
|
||||
}
|
||||
|
||||
if (pProto->RequiredSkill != 0)
|
||||
{
|
||||
if (GetSkillValue(pProto->RequiredSkill) == 0)
|
||||
return EQUIP_ERR_NO_REQUIRED_PROFICIENCY;
|
||||
|
||||
if (GetSkillValue(pProto->RequiredSkill) < pProto->RequiredSkillRank)
|
||||
return EQUIP_ERR_ERR_CANT_EQUIP_SKILL;
|
||||
}
|
||||
|
||||
if (pProto->RequiredSpell != 0 && !HasSpell(pProto->RequiredSpell))
|
||||
return EQUIP_ERR_NO_REQUIRED_PROFICIENCY;
|
||||
|
||||
if (pProto->RequiredReputationFaction && uint32(GetReputationRank(pProto->RequiredReputationFaction)) < pProto->RequiredReputationRank)
|
||||
return EQUIP_ERR_CANT_EQUIP_REPUTATION;
|
||||
|
||||
if (getLevel() < pProto->RequiredLevel)
|
||||
return EQUIP_ERR_CANT_EQUIP_LEVEL_I;
|
||||
|
||||
return EQUIP_ERR_OK;
|
||||
}
|
||||
}
|
||||
return EQUIP_ERR_ITEM_NOT_FOUND;
|
||||
}
|
||||
|
||||
bool Player::CanUseItem(ItemPrototype const *pProto)
|
||||
uint8 Player::CanUseItem(ItemPrototype const *pProto) const
|
||||
{
|
||||
// Used by group, function NeedBeforeGreed, to know if a prototype can be used by a player
|
||||
|
||||
if (pProto)
|
||||
{
|
||||
if ((pProto->Flags2 & ITEM_FLAGS_EXTRA_HORDE_ONLY) && GetTeam() != HORDE)
|
||||
return EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM;
|
||||
|
||||
if ((pProto->Flags2 & ITEM_FLAGS_EXTRA_ALLIANCE_ONLY) && GetTeam() != ALLIANCE)
|
||||
return EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM;
|
||||
|
||||
if ((pProto->AllowableClass & getClassMask()) == 0 || (pProto->AllowableRace & getRaceMask()) == 0)
|
||||
return false;
|
||||
return EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM;
|
||||
|
||||
if (pProto->RequiredSkill != 0)
|
||||
{
|
||||
if (GetSkillValue(pProto->RequiredSkill) == 0)
|
||||
return false;
|
||||
return EQUIP_ERR_NO_REQUIRED_PROFICIENCY;
|
||||
else if (GetSkillValue(pProto->RequiredSkill) < pProto->RequiredSkillRank)
|
||||
return false;
|
||||
return EQUIP_ERR_CANT_EQUIP_SKILL;
|
||||
}
|
||||
if (pProto->RequiredSpell != 0 && !HasSpell(pProto->RequiredSpell))
|
||||
return false;
|
||||
return EQUIP_ERR_NO_REQUIRED_PROFICIENCY;
|
||||
if (getLevel() < pProto->RequiredLevel)
|
||||
return false;
|
||||
return true;
|
||||
return EQUIP_ERR_CANT_EQUIP_LEVEL_I;
|
||||
return EQUIP_ERR_OK;
|
||||
}
|
||||
return false;
|
||||
return EQUIP_ERR_ITEM_NOT_FOUND;
|
||||
}
|
||||
|
||||
uint8 Player::CanUseAmmo(uint32 item) const
|
||||
@@ -11294,22 +11289,14 @@ uint8 Player::CanUseAmmo(uint32 item) const
|
||||
{
|
||||
if (pProto->InventoryType!= INVTYPE_AMMO)
|
||||
return EQUIP_ERR_ONLY_AMMO_CAN_GO_HERE;
|
||||
if ((pProto->AllowableClass & getClassMask()) == 0 || (pProto->AllowableRace & getRaceMask()) == 0)
|
||||
return EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM;
|
||||
if (pProto->RequiredSkill != 0)
|
||||
{
|
||||
if (GetSkillValue(pProto->RequiredSkill) == 0)
|
||||
return EQUIP_ERR_NO_REQUIRED_PROFICIENCY;
|
||||
else if (GetSkillValue(pProto->RequiredSkill) < pProto->RequiredSkillRank)
|
||||
return EQUIP_ERR_ERR_CANT_EQUIP_SKILL;
|
||||
}
|
||||
if (pProto->RequiredSpell != 0 && !HasSpell(pProto->RequiredSpell))
|
||||
return EQUIP_ERR_NO_REQUIRED_PROFICIENCY;
|
||||
|
||||
uint8 res = CanUseItem(pProto);
|
||||
if (res != EQUIP_ERR_OK)
|
||||
return res;
|
||||
|
||||
/*if (GetReputationMgr().GetReputation() < pProto->RequiredReputation)
|
||||
return EQUIP_ERR_CANT_EQUIP_REPUTATION;
|
||||
*/
|
||||
if (getLevel() < pProto->RequiredLevel)
|
||||
return EQUIP_ERR_CANT_EQUIP_LEVEL_I;
|
||||
|
||||
// Requires No Ammo
|
||||
if (HasAura(46699))
|
||||
|
||||
@@ -1171,7 +1171,7 @@ class Player : public Unit, public GridObject<Player>
|
||||
uint8 CanBankItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, Item *pItem, bool swap, bool not_loading = true) const;
|
||||
uint8 CanUseItem(Item *pItem, bool not_loading = true) const;
|
||||
bool HasItemTotemCategory(uint32 TotemCategory) const;
|
||||
bool CanUseItem(ItemPrototype const *pItem);
|
||||
uint8 CanUseItem(ItemPrototype const *pItem) const;
|
||||
uint8 CanUseAmmo(uint32 item) const;
|
||||
Item* StoreNewItem(ItemPosCountVec const& pos, uint32 item, bool update,int32 randomPropertyId = 0);
|
||||
Item* StoreItem(ItemPosCountVec const& pos, Item *pItem, bool update);
|
||||
|
||||
@@ -2029,6 +2029,25 @@ void ObjectMgr::LoadItemPrototypes()
|
||||
const_cast<ItemPrototype*>(proto)->Quality = ITEM_QUALITY_NORMAL;
|
||||
}
|
||||
|
||||
if (proto->Flags2 & ITEM_FLAGS_EXTRA_HORDE_ONLY)
|
||||
{
|
||||
if (FactionEntry const* faction = sFactionStore.LookupEntry(HORDE))
|
||||
if ((proto->AllowableRace & faction->BaseRepRaceMask[0]) == 0)
|
||||
sLog.outErrorDb("Item (Entry: %u) have in `AllowableRace` races (%u) only not compatible with ITEM_FLAGS_EXTRA_HORDE_ONLY (%u) in Flags field, item any way will can't be equipped or use by this races.",
|
||||
i, proto->AllowableRace, ITEM_FLAGS_EXTRA_HORDE_ONLY);
|
||||
|
||||
if (proto->Flags2 & ITEM_FLAGS_EXTRA_ALLIANCE_ONLY)
|
||||
sLog.outErrorDb("Item (Entry: %u) have in `Flags2` flags ITEM_FLAGS_EXTRA_ALLIANCE_ONLY (%u) and ITEM_FLAGS_EXTRA_HORDE_ONLY (%u) in Flags field, this is wrong combination.",
|
||||
i, ITEM_FLAGS_EXTRA_ALLIANCE_ONLY, ITEM_FLAGS_EXTRA_HORDE_ONLY);
|
||||
}
|
||||
else if (proto->Flags2 & ITEM_FLAGS_EXTRA_ALLIANCE_ONLY)
|
||||
{
|
||||
if (FactionEntry const* faction = sFactionStore.LookupEntry(ALLIANCE))
|
||||
if ((proto->AllowableRace & faction->BaseRepRaceMask[0]) == 0)
|
||||
sLog.outErrorDb("Item (Entry: %u) have in `AllowableRace` races (%u) only not compatible with ITEM_FLAGS_EXTRA_ALLIANCE_ONLY (%u) in Flags field, item any way will can't be equipped or use by this races.",
|
||||
i, proto->AllowableRace, ITEM_FLAGS_EXTRA_ALLIANCE_ONLY);
|
||||
}
|
||||
|
||||
if (proto->BuyCount <= 0)
|
||||
{
|
||||
sLog.outErrorDb("Item (Entry: %u) has wrong BuyCount value (%u), set to default(1).",i,proto->BuyCount);
|
||||
|
||||
@@ -725,7 +725,7 @@ void Group::NeedBeforeGreed(Loot *loot, WorldObject* pLootedObject)
|
||||
if (!playerToRoll || !playerToRoll->GetSession())
|
||||
continue;
|
||||
|
||||
if (playerToRoll->CanUseItem(item) && i->AllowedForPlayer(playerToRoll))
|
||||
if (playerToRoll->CanUseItem(item) == EQUIP_ERR_OK && i->AllowedForPlayer(playerToRoll))
|
||||
{
|
||||
if (playerToRoll->IsWithinDistInMap(pLootedObject,sWorld.getConfig(CONFIG_GROUP_XP_DISTANCE),false))
|
||||
{
|
||||
|
||||
@@ -346,10 +346,21 @@ LootItem::LootItem(LootStoreItem const& li)
|
||||
// Basic checks for player/item compatibility - if false no chance to see the item in the loot
|
||||
bool LootItem::AllowedForPlayer(Player const * player) const
|
||||
{
|
||||
// DB conditions check
|
||||
// DB conditions check
|
||||
if (!sConditionMgr.IsPlayerMeetToConditions(const_cast<Player*>(player), conditions))
|
||||
return false;
|
||||
|
||||
ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(itemid);
|
||||
if (!pProto)
|
||||
return false;
|
||||
|
||||
// not show loot for not own team
|
||||
if ((pProto->Flags2 & ITEM_FLAGS_EXTRA_HORDE_ONLY) && player->GetTeam() != HORDE)
|
||||
return false;
|
||||
|
||||
if ((pProto->Flags2 & ITEM_FLAGS_EXTRA_ALLIANCE_ONLY) && player->GetTeam() != ALLIANCE)
|
||||
return false;
|
||||
|
||||
if (needs_quest)
|
||||
{
|
||||
// Checking quests for quest-only drop (check only quests requirements in this case)
|
||||
@@ -359,9 +370,8 @@ bool LootItem::AllowedForPlayer(Player const * player) const
|
||||
else
|
||||
{
|
||||
// Not quest only drop (check quest starting items for already accepted non-repeatable quests)
|
||||
if (ItemPrototype const *pProto = objmgr.GetItemPrototype(itemid))
|
||||
if (pProto->StartQuest && player->GetQuestStatus(pProto->StartQuest) != QUEST_STATUS_NONE && !player->HasQuestForItem(itemid))
|
||||
return false;
|
||||
if (pProto->StartQuest && player->GetQuestStatus(pProto->StartQuest) != QUEST_STATUS_NONE && !player->HasQuestForItem(itemid))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -142,7 +142,7 @@ bool ItemUse_item_flying_machine(Player* pPlayer, Item* pItem, SpellCastTargets
|
||||
return false;
|
||||
|
||||
sLog.outDebug("TSCR: Player attempt to use item %u, but did not meet riding requirement",itemId);
|
||||
pPlayer->SendEquipError(EQUIP_ERR_ERR_CANT_EQUIP_SKILL,pItem,NULL);
|
||||
pPlayer->SendEquipError(EQUIP_ERR_CANT_EQUIP_SKILL,pItem,NULL);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user