Core/Instances: Spawn defeated bosses in instances using loot based locks if their preceding bosses are not killed

Port From (https://github.com/TrinityCore/TrinityCore/commit/ca5f7a15b9c2ca352f7f83ddc065d795f2294d98)
This commit is contained in:
hondacrx
2022-10-04 20:01:23 -04:00
parent 87fdd30072
commit 60995d9a93
@@ -462,6 +462,12 @@ namespace Game.Maps
InstanceScriptDataReader reader = new(this);
if (reader.Load(data) == InstanceScriptDataReader.Result.Ok)
{
// in loot-based lockouts instance can be loaded with later boss marked as killed without preceding bosses
// but we still need to have them alive
for (uint i = 0; i < bosses.Count; ++i)
if (bosses[i].state == EncounterState.Done && !CheckRequiredBosses(i))
bosses[i].state = EncounterState.NotStarted;
UpdateSpawnGroups();
AfterDataLoad();
}
@@ -715,6 +721,16 @@ namespace Game.Maps
return false;
}
public bool IsEncounterCompletedInMaskByBossId(uint completedEncountersMask, uint bossId)
{
DungeonEncounterRecord dungeonEncounter = GetBossDungeonEncounter(bossId);
if (dungeonEncounter != null)
if ((completedEncountersMask & (1 << dungeonEncounter.Bit)) != 0)
return bosses[bossId].state == EncounterState.Done;
return false;
}
public void SetEntranceLocation(uint worldSafeLocationId)
{
_entranceId = worldSafeLocationId;