Core/Creatures: Allow scripts to change creature loot id (must be done before death)

Port From (https://github.com/TrinityCore/TrinityCore/commit/155cf58236f7adbd169f57e0578c96fd7ce2173f)
This commit is contained in:
hondacrx
2023-03-14 04:27:22 -04:00
parent 4879533cb1
commit 1d5d0a32e6
3 changed files with 19 additions and 3 deletions
@@ -55,6 +55,7 @@ namespace Game.Entities
bool DisableReputationGain; bool DisableReputationGain;
uint? _lootId;
LootModes m_LootMode; // Bitmask (default: LOOT_MODE_DEFAULT) that determines what loot will be lootable LootModes m_LootMode; // Bitmask (default: LOOT_MODE_DEFAULT) that determines what loot will be lootable
// Waypoint path // Waypoint path
+15
View File
@@ -1189,9 +1189,24 @@ namespace Game.Entities
{ {
_pickpocketLootRestore = GameTime.GetGameTime() + WorldConfig.GetIntValue(WorldCfg.CreaturePickpocketRefill); _pickpocketLootRestore = GameTime.GetGameTime() + WorldConfig.GetIntValue(WorldCfg.CreaturePickpocketRefill);
} }
public void ResetPickPocketRefillTimer() { _pickpocketLootRestore = 0; } public void ResetPickPocketRefillTimer() { _pickpocketLootRestore = 0; }
public bool CanGeneratePickPocketLoot() { return _pickpocketLootRestore <= GameTime.GetGameTime(); } public bool CanGeneratePickPocketLoot() { return _pickpocketLootRestore <= GameTime.GetGameTime(); }
public uint GetLootId()
{
if (_lootId.HasValue)
return _lootId.Value;
return GetCreatureTemplate().LootId;
}
public void SetLootId(uint? lootId)
{
_lootId = lootId;
}
public void SetTappedBy(Unit unit, bool withGroup = true) public void SetTappedBy(Unit unit, bool withGroup = true)
{ {
// set the player whose group should receive the right // set the player whose group should receive the right
+3 -3
View File
@@ -756,7 +756,7 @@ namespace Game.Entities
{ {
if (dungeonEncounter != null) if (dungeonEncounter != null)
{ {
creature.m_personalLoot = LootManager.GenerateDungeonEncounterPersonalLoot(dungeonEncounter.Id, creature.GetCreatureTemplate().LootId, creature.m_personalLoot = LootManager.GenerateDungeonEncounterPersonalLoot(dungeonEncounter.Id, creature.GetLootId(),
LootStorage.Creature, LootType.Corpse, creature, creature.GetCreatureTemplate().MinGold, creature.GetCreatureTemplate().MaxGold, LootStorage.Creature, LootType.Corpse, creature, creature.GetCreatureTemplate().MinGold, creature.GetCreatureTemplate().MaxGold,
(ushort)creature.GetLootMode(), creature.GetMap().GetDifficultyLootItemContext(), tappers); (ushort)creature.GetLootMode(), creature.GetMap().GetDifficultyLootItemContext(), tappers);
} }
@@ -767,7 +767,7 @@ namespace Game.Entities
Loot loot = new(creature.GetMap(), creature.GetGUID(), LootType.Corpse, dungeonEncounter != null ? group : null); Loot loot = new(creature.GetMap(), creature.GetGUID(), LootType.Corpse, dungeonEncounter != null ? group : null);
uint lootid = creature.GetCreatureTemplate().LootId; uint lootid = creature.GetLootId();
if (lootid != 0) if (lootid != 0)
loot.FillLoot(lootid, LootStorage.Creature, looter, dungeonEncounter != null, false, creature.GetLootMode(), creature.GetMap().GetDifficultyLootItemContext()); loot.FillLoot(lootid, LootStorage.Creature, looter, dungeonEncounter != null, false, creature.GetLootMode(), creature.GetMap().GetDifficultyLootItemContext());
@@ -794,7 +794,7 @@ namespace Game.Entities
if (dungeonEncounter != null) if (dungeonEncounter != null)
loot.SetDungeonEncounterId(dungeonEncounter.Id); loot.SetDungeonEncounterId(dungeonEncounter.Id);
uint lootid = creature.GetCreatureTemplate().LootId; uint lootid = creature.GetLootId();
if (lootid != 0) if (lootid != 0)
loot.FillLoot(lootid, LootStorage.Creature, tapper, true, false, creature.GetLootMode(), creature.GetMap().GetDifficultyLootItemContext()); loot.FillLoot(lootid, LootStorage.Creature, tapper, true, false, creature.GetLootMode(), creature.GetMap().GetDifficultyLootItemContext());