Core/Loot: Set loot dungeon encounter id before generating

Port From (https://github.com/TrinityCore/TrinityCore/commit/5f1a4cf9044d9ad65b49eb859ec36e1f62c2be10)
This commit is contained in:
hondacrx
2022-10-05 16:21:19 -04:00
parent 023fc60699
commit 86fa768ef3
4 changed files with 23 additions and 16 deletions
+3 -10
View File
@@ -547,16 +547,7 @@ namespace Game.AI
summons.DespawnAll();
_scheduler.CancelAll();
if (instance != null)
{
if (me.loot != null)
{
DungeonEncounterRecord dungeonEncounter = instance.GetBossDungeonEncounter(_bossId);
if (dungeonEncounter != null)
me.loot.SetDungeonEncounterId(dungeonEncounter.Id);
}
instance.SetBossState(_bossId, EncounterState.Done);
}
}
public void _JustEngagedWith(Unit who)
@@ -587,7 +578,7 @@ namespace Game.AI
{
Unit target = pair.Value.GetOther(me);
if (target.IsControlledByPlayer() && !IsInBoundary(target))
target.NearTeleportTo(x, y, z, 0);
target.NearTeleportTo(x, y, z, 0);
}
}
@@ -689,6 +680,8 @@ namespace Game.AI
public override bool CanAIAttack(Unit victim) { return IsInBoundary(victim); }
public void _JustReachedHome() { me.SetActive(false); }
public uint GetBossId() { return _bossId; }
}
public class WorldBossAI : ScriptedAI
+9
View File
@@ -20,6 +20,7 @@ using Game.AI;
using Game.BattleFields;
using Game.BattleGrounds;
using Game.Combat;
using Game.DataStorage;
using Game.Groups;
using Game.Loots;
using Game.Maps;
@@ -778,6 +779,14 @@ namespace Game.Entities
if (creature.GetMap().Is25ManRaid())
loot.maxDuplicates = 3;
InstanceScript instance = creature.GetInstanceScript();
if (instance != null)
{
DungeonEncounterRecord dungeonEncounter = instance.GetBossDungeonEncounter(creature);
if (dungeonEncounter != null)
loot.SetDungeonEncounterId(dungeonEncounter.Id);
}
uint lootid = creature.GetCreatureTemplate().LootId;
if (lootid != 0)
loot.FillLoot(lootid, LootStorage.Creature, looter, false, false, creature.GetLootMode(), creature.GetMap().GetDifficultyLootItemContext());
+10 -4
View File
@@ -16,18 +16,15 @@
*/
using Framework.Constants;
using Framework.Database;
using Framework.IO;
using Game.AI;
using Game.DataStorage;
using Game.Entities;
using Game.Groups;
using Game.Networking.Packets;
using Game.Scenarios;
using Game.Spells;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Game.Maps
{
@@ -703,6 +700,15 @@ namespace Game.Maps
{
return id < bosses.Count ? bosses[id].GetDungeonEncounterForDifficulty(instance.GetDifficultyID()) : null;
}
public DungeonEncounterRecord GetBossDungeonEncounter(Creature creature)
{
BossAI bossAi = (BossAI)creature.GetAI();
if (bossAi != null)
return GetBossDungeonEncounter(bossAi.GetBossId());
return null;
}
public virtual bool CheckAchievementCriteriaMeet(uint criteria_id, Player source, Unit target = null, uint miscvalue1 = 0)
{
+1 -2
View File
@@ -1259,6 +1259,7 @@ namespace Game.Spells
loot = new(gameObjTarget.GetMap(), guid, loottype, groupRules ? group : null);
gameObjTarget.loot = loot;
loot.SetDungeonEncounterId(gameObjTarget.GetGoInfo().Chest.DungeonEncounter);
loot.FillLoot(lootId, LootStorage.Gameobject, player, !groupRules, false, gameObjTarget.GetLootMode(), gameObjTarget.GetMap().GetDifficultyLootItemContext());
if (gameObjTarget.GetLootMode() > 0)
@@ -1267,8 +1268,6 @@ namespace Game.Spells
if (addon != null)
loot.GenerateMoneyLoot(addon.Mingold, addon.Maxgold);
}
loot.SetDungeonEncounterId(gameObjTarget.GetGoInfo().Chest.DungeonEncounter);
}
/// @todo possible must be moved to loot release (in different from linked triggering)