mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 22:37:03 +00:00
[10206] Implement ITEM_FLAGS2_HORDE_ONLY and ITEM_FLAGS2_ALLIANCE_ONLY
* Check item_template data * Check at equip/use * Skip at loot if not compatible * Skip in vendor list if not compatible
This commit is contained in:
parent
f2e3881a77
commit
9882bc811f
7 changed files with 84 additions and 52 deletions
|
|
@ -706,7 +706,7 @@ void Group::StartLootRool(Creature* lootTarget, Loot* loot, uint8 itemSlot, bool
|
||||||
if(!playerToRoll || !playerToRoll->GetSession())
|
if(!playerToRoll || !playerToRoll->GetSession())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ((!skipIfCanNotUse || playerToRoll->CanUseItem(item)) && lootItem.AllowedForPlayer(playerToRoll) )
|
if ((!skipIfCanNotUse || playerToRoll->CanUseItem(item)==EQUIP_ERR_OK) && lootItem.AllowedForPlayer(playerToRoll) )
|
||||||
{
|
{
|
||||||
if (playerToRoll->IsWithinDist(lootTarget, sWorld.getConfig(CONFIG_FLOAT_GROUP_XP_DISTANCE), false))
|
if (playerToRoll->IsWithinDist(lootTarget, sWorld.getConfig(CONFIG_FLOAT_GROUP_XP_DISTANCE), false))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -761,9 +761,23 @@ void WorldSession::SendListInventory(uint64 vendorguid)
|
||||||
{
|
{
|
||||||
if (ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(crItem->item))
|
if (ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(crItem->item))
|
||||||
{
|
{
|
||||||
if((pProto->AllowableClass & _player->getClassMask()) == 0 && pProto->Bonding == BIND_WHEN_PICKED_UP && !_player->isGameMaster())
|
if (!_player->isGameMaster())
|
||||||
|
{
|
||||||
|
// class wrong item skip only for bindable case
|
||||||
|
if ((pProto->AllowableClass & _player->getClassMask()) == 0 && pProto->Bonding == BIND_WHEN_PICKED_UP)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
// race wrong item skip always
|
||||||
|
if ((pProto->Flags2 & ITEM_FLAGS2_HORDE_ONLY) && _player->GetTeam() != HORDE)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if ((pProto->Flags2 & ITEM_FLAGS2_ALLIANCE_ONLY) && _player->GetTeam() != ALLIANCE)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if ((pProto->AllowableRace & _player->getRaceMask()) == 0)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
++count;
|
++count;
|
||||||
|
|
||||||
// reputation discount
|
// reputation discount
|
||||||
|
|
|
||||||
|
|
@ -340,6 +340,17 @@ bool LootItem::AllowedForPlayer(Player const * player) const
|
||||||
if (!sObjectMgr.IsPlayerMeetToCondition(player,conditionId))
|
if (!sObjectMgr.IsPlayerMeetToCondition(player,conditionId))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(itemid);
|
||||||
|
if (!pProto)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// not show loot for not own team
|
||||||
|
if ((pProto->Flags2 & ITEM_FLAGS2_HORDE_ONLY) && player->GetTeam() != HORDE)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if ((pProto->Flags2 & ITEM_FLAGS2_ALLIANCE_ONLY) && player->GetTeam() != ALLIANCE)
|
||||||
|
return false;
|
||||||
|
|
||||||
if ( needs_quest )
|
if ( needs_quest )
|
||||||
{
|
{
|
||||||
// Checking quests for quest-only drop (check only quests requirements in this case)
|
// Checking quests for quest-only drop (check only quests requirements in this case)
|
||||||
|
|
@ -349,8 +360,7 @@ bool LootItem::AllowedForPlayer(Player const * player) const
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Not quest only drop (check quest starting items for already accepted non-repeatable quests)
|
// Not quest only drop (check quest starting items for already accepted non-repeatable quests)
|
||||||
ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(itemid);
|
if (pProto->StartQuest && player->GetQuestStatus(pProto->StartQuest) != QUEST_STATUS_NONE && !player->HasQuestForItem(itemid))
|
||||||
if (pProto && pProto->StartQuest && player->GetQuestStatus(pProto->StartQuest) != QUEST_STATUS_NONE && !player->HasQuestForItem(itemid))
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1809,6 +1809,25 @@ void ObjectMgr::LoadItemPrototypes()
|
||||||
const_cast<ItemPrototype*>(proto)->Quality = ITEM_QUALITY_NORMAL;
|
const_cast<ItemPrototype*>(proto)->Quality = ITEM_QUALITY_NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (proto->Flags2 & ITEM_FLAGS2_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_FLAGS2_HORDE_ONLY (%u) in Flags field, item any way will can't be equipped or use by this races.",
|
||||||
|
i, proto->AllowableRace, ITEM_FLAGS2_HORDE_ONLY);
|
||||||
|
|
||||||
|
if (proto->Flags2 & ITEM_FLAGS2_ALLIANCE_ONLY)
|
||||||
|
sLog.outErrorDb("Item (Entry: %u) have in `Flags2` flags ITEM_FLAGS2_ALLIANCE_ONLY (%u) and ITEM_FLAGS2_HORDE_ONLY (%u) in Flags field, this is wrong combination.",
|
||||||
|
i, ITEM_FLAGS2_ALLIANCE_ONLY, ITEM_FLAGS2_HORDE_ONLY);
|
||||||
|
}
|
||||||
|
else if (proto->Flags2 & ITEM_FLAGS2_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_FLAGS2_ALLIANCE_ONLY (%u) in Flags field, item any way will can't be equipped or use by this races.",
|
||||||
|
i, proto->AllowableRace, ITEM_FLAGS2_ALLIANCE_ONLY);
|
||||||
|
}
|
||||||
|
|
||||||
if(proto->BuyCount <= 0)
|
if(proto->BuyCount <= 0)
|
||||||
{
|
{
|
||||||
sLog.outErrorDb("Item (Entry: %u) has wrong BuyCount value (%u), set to default(1).",i,proto->BuyCount);
|
sLog.outErrorDb("Item (Entry: %u) has wrong BuyCount value (%u), set to default(1).",i,proto->BuyCount);
|
||||||
|
|
|
||||||
|
|
@ -10477,8 +10477,9 @@ uint8 Player::CanBankItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, Item *p
|
||||||
if (slot - BANK_SLOT_BAG_START >= GetBankBagSlotCount())
|
if (slot - BANK_SLOT_BAG_START >= GetBankBagSlotCount())
|
||||||
return EQUIP_ERR_MUST_PURCHASE_THAT_BAG_SLOT;
|
return EQUIP_ERR_MUST_PURCHASE_THAT_BAG_SLOT;
|
||||||
|
|
||||||
if (uint8 cantuse = CanUseItem( pItem, not_loading ) != EQUIP_ERR_OK)
|
res = CanUseItem( pItem, not_loading );
|
||||||
return cantuse;
|
if (res != EQUIP_ERR_OK)
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = _CanStoreItem_InSpecificSlot(bag,slot,dest,pProto,count,swap,pItem);
|
res = _CanStoreItem_InSpecificSlot(bag,slot,dest,pProto,count,swap,pItem);
|
||||||
|
|
@ -10641,8 +10642,9 @@ uint8 Player::CanUseItem( Item *pItem, bool not_loading ) const
|
||||||
if (pItem->IsBindedNotWith(this))
|
if (pItem->IsBindedNotWith(this))
|
||||||
return EQUIP_ERR_DONT_OWN_THAT_ITEM;
|
return EQUIP_ERR_DONT_OWN_THAT_ITEM;
|
||||||
|
|
||||||
if ((pProto->AllowableClass & getClassMask()) == 0 || (pProto->AllowableRace & getRaceMask()) == 0)
|
uint8 msg = CanUseItem(pProto);
|
||||||
return EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM;
|
if (msg != EQUIP_ERR_OK)
|
||||||
|
return msg;
|
||||||
|
|
||||||
if (uint32 item_use_skill = pItem->GetSkill())
|
if (uint32 item_use_skill = pItem->GetSkill())
|
||||||
{
|
{
|
||||||
|
|
@ -10682,52 +10684,47 @@ uint8 Player::CanUseItem( Item *pItem, bool not_loading ) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pProto->RequiredSkill != 0)
|
|
||||||
{
|
|
||||||
if (GetSkillValue( pProto->RequiredSkill ) == 0)
|
|
||||||
return EQUIP_ERR_NO_REQUIRED_PROFICIENCY;
|
|
||||||
|
|
||||||
if (GetSkillValue( pProto->RequiredSkill ) < pProto->RequiredSkillRank)
|
|
||||||
return EQUIP_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)
|
if (pProto->RequiredReputationFaction && uint32(GetReputationRank(pProto->RequiredReputationFaction)) < pProto->RequiredReputationRank)
|
||||||
return EQUIP_ERR_CANT_EQUIP_REPUTATION;
|
return EQUIP_ERR_CANT_EQUIP_REPUTATION;
|
||||||
|
|
||||||
if (getLevel() < pProto->RequiredLevel)
|
|
||||||
return EQUIP_ERR_CANT_EQUIP_LEVEL_I;
|
|
||||||
|
|
||||||
return EQUIP_ERR_OK;
|
return EQUIP_ERR_OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return EQUIP_ERR_ITEM_NOT_FOUND;
|
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
|
// Used by group, function NeedBeforeGreed, to know if a prototype can be used by a player
|
||||||
|
|
||||||
if( pProto )
|
if( pProto )
|
||||||
{
|
{
|
||||||
|
if ((pProto->Flags2 & ITEM_FLAGS2_HORDE_ONLY) && GetTeam() != HORDE)
|
||||||
|
return EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM;
|
||||||
|
|
||||||
|
if ((pProto->Flags2 & ITEM_FLAGS2_ALLIANCE_ONLY) && GetTeam() != ALLIANCE)
|
||||||
|
return EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM;
|
||||||
|
|
||||||
if ((pProto->AllowableClass & getClassMask()) == 0 || (pProto->AllowableRace & getRaceMask()) == 0)
|
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( pProto->RequiredSkill != 0 )
|
||||||
{
|
{
|
||||||
if( GetSkillValue( pProto->RequiredSkill ) == 0 )
|
if( GetSkillValue( pProto->RequiredSkill ) == 0 )
|
||||||
return false;
|
return EQUIP_ERR_NO_REQUIRED_PROFICIENCY;
|
||||||
else if( GetSkillValue( pProto->RequiredSkill ) < pProto->RequiredSkillRank )
|
else if( GetSkillValue( pProto->RequiredSkill ) < pProto->RequiredSkillRank )
|
||||||
return false;
|
return EQUIP_ERR_CANT_EQUIP_SKILL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( pProto->RequiredSpell != 0 && !HasSpell( pProto->RequiredSpell ) )
|
if( pProto->RequiredSpell != 0 && !HasSpell( pProto->RequiredSpell ) )
|
||||||
return false;
|
return EQUIP_ERR_NO_REQUIRED_PROFICIENCY;
|
||||||
|
|
||||||
if( getLevel() < pProto->RequiredLevel )
|
if( getLevel() < pProto->RequiredLevel )
|
||||||
return false;
|
return EQUIP_ERR_CANT_EQUIP_LEVEL_I;
|
||||||
return true;
|
|
||||||
|
return EQUIP_ERR_OK;
|
||||||
}
|
}
|
||||||
return false;
|
return EQUIP_ERR_ITEM_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8 Player::CanUseAmmo( uint32 item ) const
|
uint8 Player::CanUseAmmo( uint32 item ) const
|
||||||
|
|
@ -10742,22 +10739,14 @@ uint8 Player::CanUseAmmo( uint32 item ) const
|
||||||
{
|
{
|
||||||
if( pProto->InventoryType!= INVTYPE_AMMO )
|
if( pProto->InventoryType!= INVTYPE_AMMO )
|
||||||
return EQUIP_ERR_ONLY_AMMO_CAN_GO_HERE;
|
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;
|
uint8 msg = CanUseItem(pProto);
|
||||||
if( pProto->RequiredSkill != 0 )
|
if (msg != EQUIP_ERR_OK)
|
||||||
{
|
return msg;
|
||||||
if( GetSkillValue( pProto->RequiredSkill ) == 0 )
|
|
||||||
return EQUIP_ERR_NO_REQUIRED_PROFICIENCY;
|
|
||||||
else if( GetSkillValue( pProto->RequiredSkill ) < pProto->RequiredSkillRank )
|
|
||||||
return EQUIP_ERR_CANT_EQUIP_SKILL;
|
|
||||||
}
|
|
||||||
if( pProto->RequiredSpell != 0 && !HasSpell( pProto->RequiredSpell ) )
|
|
||||||
return EQUIP_ERR_NO_REQUIRED_PROFICIENCY;
|
|
||||||
/*if ( GetReputationMgr().GetReputation() < pProto->RequiredReputation )
|
/*if ( GetReputationMgr().GetReputation() < pProto->RequiredReputation )
|
||||||
return EQUIP_ERR_CANT_EQUIP_REPUTATION;
|
return EQUIP_ERR_CANT_EQUIP_REPUTATION;
|
||||||
*/
|
*/
|
||||||
if( getLevel() < pProto->RequiredLevel )
|
|
||||||
return EQUIP_ERR_CANT_EQUIP_LEVEL_I;
|
|
||||||
|
|
||||||
// Requires No Ammo
|
// Requires No Ammo
|
||||||
if(GetDummyAura(46699))
|
if(GetDummyAura(46699))
|
||||||
|
|
|
||||||
|
|
@ -1266,7 +1266,7 @@ class MANGOS_DLL_SPEC Player : public Unit
|
||||||
uint8 CanBankItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, Item *pItem, bool swap, bool not_loading = true ) const;
|
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;
|
uint8 CanUseItem( Item *pItem, bool not_loading = true ) const;
|
||||||
bool HasItemTotemCategory( uint32 TotemCategory ) const;
|
bool HasItemTotemCategory( uint32 TotemCategory ) const;
|
||||||
bool CanUseItem( ItemPrototype const *pItem );
|
uint8 CanUseItem( ItemPrototype const *pItem ) const;
|
||||||
uint8 CanUseAmmo( uint32 item ) const;
|
uint8 CanUseAmmo( uint32 item ) const;
|
||||||
Item* StoreNewItem( ItemPosCountVec const& pos, uint32 item, bool update,int32 randomPropertyId = 0 );
|
Item* StoreNewItem( ItemPosCountVec const& pos, uint32 item, bool update,int32 randomPropertyId = 0 );
|
||||||
Item* StoreItem( ItemPosCountVec const& pos, Item *pItem, bool update );
|
Item* StoreItem( ItemPosCountVec const& pos, Item *pItem, bool update );
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "10205"
|
#define REVISION_NR "10206"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue