mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-26 03:42:37 +01:00
Core/Toys: Check whether player has the toy he is attempting to use and if that toy has the spell that player is trying to cast
This commit is contained in:
@@ -60,6 +60,7 @@ public:
|
||||
|
||||
bool AddToy(uint32 itemId, bool isFavourite /*= false*/);
|
||||
bool UpdateAccountToys(uint32 itemId, bool isFavourite /*= false*/);
|
||||
bool HasToy(uint32 itemId) const { return _toys.count(itemId) > 0; }
|
||||
|
||||
ToyBoxContainer const& GetAccountToys() const { return _toys; }
|
||||
|
||||
|
||||
@@ -51,6 +51,17 @@ void WorldSession::HandleUseToy(WorldPackets::Toy::UseToy& packet)
|
||||
if (!item)
|
||||
return;
|
||||
|
||||
if (!_collectionMgr->HasToy(packet.ItemID))
|
||||
return;
|
||||
|
||||
auto effect = std::find_if(item->Effects.begin(), item->Effects.end(), [&packet](ItemEffectEntry const* effect)
|
||||
{
|
||||
return packet.Cast.SpellID = effect->SpellID;
|
||||
});
|
||||
|
||||
if (effect == item->Effects.end())
|
||||
return;
|
||||
|
||||
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(packet.Cast.SpellID);
|
||||
if (!spellInfo)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user