mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-13 09:17:18 +00:00
fix(Core/Player): fix Eluna hook in Player::CanUseItem (#7117)
This commit is contained in:
@@ -2302,48 +2302,70 @@ InventoryResult Player::CanUseItem(ItemTemplate const* proto) const
|
||||
{
|
||||
// Used by group, function NeedBeforeGreed, to know if a prototype can be used by a player
|
||||
|
||||
if (proto)
|
||||
if (!proto)
|
||||
{
|
||||
if ((proto->Flags2 & ITEM_FLAGS_EXTRA_HORDE_ONLY) && GetTeamId(true) != TEAM_HORDE)
|
||||
return EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM;
|
||||
|
||||
if ((proto->Flags2 & ITEM_FLAGS_EXTRA_ALLIANCE_ONLY) && GetTeamId(true) != TEAM_ALLIANCE)
|
||||
return EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM;
|
||||
|
||||
if ((proto->AllowableClass & getClassMask()) == 0 || (proto->AllowableRace & getRaceMask()) == 0)
|
||||
return EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM;
|
||||
|
||||
if (proto->RequiredSkill != 0)
|
||||
{
|
||||
if (GetSkillValue(proto->RequiredSkill) == 0)
|
||||
return EQUIP_ERR_NO_REQUIRED_PROFICIENCY;
|
||||
else if (GetSkillValue(proto->RequiredSkill) < proto->RequiredSkillRank)
|
||||
return EQUIP_ERR_CANT_EQUIP_SKILL;
|
||||
}
|
||||
|
||||
if (proto->RequiredSpell != 0 && !HasSpell(proto->RequiredSpell))
|
||||
return EQUIP_ERR_NO_REQUIRED_PROFICIENCY;
|
||||
|
||||
InventoryResult result = EQUIP_ERR_OK;
|
||||
|
||||
if (!sScriptMgr->CanUseItem(const_cast<Player*>(this), proto, result))
|
||||
return result;
|
||||
|
||||
if (getLevel() < proto->RequiredLevel)
|
||||
return EQUIP_ERR_CANT_EQUIP_LEVEL_I;
|
||||
|
||||
// If World Event is not active, prevent using event dependant items
|
||||
if (proto->HolidayId && !IsHolidayActive((HolidayIds)proto->HolidayId))
|
||||
return EQUIP_ERR_CANT_DO_RIGHT_NOW;
|
||||
|
||||
return EQUIP_ERR_OK;
|
||||
return EQUIP_ERR_ITEM_NOT_FOUND;
|
||||
}
|
||||
|
||||
if ((proto->Flags2 & ITEM_FLAGS_EXTRA_HORDE_ONLY) && GetTeamId(true) != TEAM_HORDE)
|
||||
{
|
||||
return EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM;
|
||||
}
|
||||
|
||||
if ((proto->Flags2 & ITEM_FLAGS_EXTRA_ALLIANCE_ONLY) && GetTeamId(true) != TEAM_ALLIANCE)
|
||||
{
|
||||
return EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM;
|
||||
}
|
||||
|
||||
if ((proto->AllowableClass & getClassMask()) == 0 || (proto->AllowableRace & getRaceMask()) == 0)
|
||||
{
|
||||
return EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM;
|
||||
}
|
||||
|
||||
if (proto->RequiredSkill != 0)
|
||||
{
|
||||
if (GetSkillValue(proto->RequiredSkill) == 0)
|
||||
{
|
||||
return EQUIP_ERR_NO_REQUIRED_PROFICIENCY;
|
||||
}
|
||||
else if (GetSkillValue(proto->RequiredSkill) < proto->RequiredSkillRank)
|
||||
{
|
||||
return EQUIP_ERR_CANT_EQUIP_SKILL;
|
||||
}
|
||||
}
|
||||
|
||||
if (proto->RequiredSpell != 0 && !HasSpell(proto->RequiredSpell))
|
||||
{
|
||||
return EQUIP_ERR_NO_REQUIRED_PROFICIENCY;
|
||||
}
|
||||
|
||||
InventoryResult result = EQUIP_ERR_OK;
|
||||
|
||||
if (!sScriptMgr->CanUseItem(const_cast<Player*>(this), proto, result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
if (getLevel() < proto->RequiredLevel)
|
||||
{
|
||||
return EQUIP_ERR_CANT_EQUIP_LEVEL_I;
|
||||
}
|
||||
|
||||
// If World Event is not active, prevent using event dependant items
|
||||
if (proto->HolidayId && !IsHolidayActive((HolidayIds)proto->HolidayId))
|
||||
{
|
||||
return EQUIP_ERR_CANT_DO_RIGHT_NOW;
|
||||
}
|
||||
|
||||
#ifdef ELUNA
|
||||
InventoryResult eres = sEluna->OnCanUseItem(this, proto->ItemId);
|
||||
if (eres != EQUIP_ERR_OK)
|
||||
{
|
||||
return eres;
|
||||
}
|
||||
#endif
|
||||
return EQUIP_ERR_ITEM_NOT_FOUND;
|
||||
|
||||
return EQUIP_ERR_OK;
|
||||
}
|
||||
|
||||
InventoryResult Player::CanRollForItemInLFG(ItemTemplate const* proto, WorldObject const* lootedObject) const
|
||||
|
||||
Reference in New Issue
Block a user