Core/Creatures: Allow disabling loot for creatures

This commit is contained in:
Shauren
2023-03-12 13:05:35 +01:00
parent 8f38c12c4e
commit ebf799c0f6
3 changed files with 9 additions and 2 deletions

View File

@@ -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();

View File

@@ -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);

View File

@@ -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;
}