mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Creatures: Allow disabling loot for creatures
This commit is contained in:
@@ -229,6 +229,8 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
|
||||
virtual void SaveToDB(uint32 mapid, std::vector<Difficulty> const& spawnDifficulties);
|
||||
static bool DeleteFromDB(ObjectGuid::LowType spawnId);
|
||||
|
||||
bool CanHaveLoot() const { return !_staticFlags.HasFlag(CREATURE_STATIC_FLAG_NO_LOOT); }
|
||||
void SetCanHaveLoot(bool canHaveLoot) { _staticFlags.ApplyFlag(CREATURE_STATIC_FLAG_NO_LOOT, !canHaveLoot); }
|
||||
std::unique_ptr<Loot> m_loot;
|
||||
std::unordered_map<ObjectGuid, std::unique_ptr<Loot>> m_personalLoot;
|
||||
void StartPickPocketRefillTimer();
|
||||
|
||||
@@ -10631,10 +10631,15 @@ void Unit::SetMeleeAnimKitId(uint16 animKitId)
|
||||
|
||||
std::vector<Player*> tappers;
|
||||
if (isRewardAllowed && creature)
|
||||
{
|
||||
for (ObjectGuid tapperGuid : creature->GetTapList())
|
||||
if (Player* tapper = ObjectAccessor::GetPlayer(*creature, tapperGuid))
|
||||
tappers.push_back(tapper);
|
||||
|
||||
if (!creature->CanHaveLoot())
|
||||
isRewardAllowed = false;
|
||||
}
|
||||
|
||||
// Exploit fix
|
||||
if (creature && creature->IsPet() && creature->GetOwnerGUID().IsPlayer())
|
||||
isRewardAllowed = false;
|
||||
@@ -10822,7 +10827,7 @@ void Unit::SetMeleeAnimKitId(uint16 animKitId)
|
||||
else
|
||||
creature->AllLootRemovedFromCorpse();
|
||||
|
||||
if (LootTemplates_Skinning.HaveLootFor(creature->GetCreatureTemplate()->SkinLootId))
|
||||
if (creature->CanHaveLoot() && LootTemplates_Skinning.HaveLootFor(creature->GetCreatureTemplate()->SkinLootId))
|
||||
{
|
||||
creature->SetDynamicFlag(UNIT_DYNFLAG_CAN_SKIN);
|
||||
creature->SetUnitFlag(UNIT_FLAG_SKINNABLE);
|
||||
|
||||
@@ -2176,7 +2176,7 @@ SpellCastResult SpellInfo::CheckTarget(WorldObject const* caster, WorldObject co
|
||||
if (!targetCreature)
|
||||
return SPELL_FAILED_BAD_TARGETS;
|
||||
|
||||
if (!LootTemplates_Pickpocketing.HaveLootFor(targetCreature->GetCreatureTemplate()->pickpocketLootId))
|
||||
if (!targetCreature->CanHaveLoot() || !LootTemplates_Pickpocketing.HaveLootFor(targetCreature->GetCreatureTemplate()->pickpocketLootId))
|
||||
return SPELL_FAILED_TARGET_NO_POCKETS;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user