diff --git a/Source/Game/Maps/Instances/InstanceScript.cs b/Source/Game/Maps/Instances/InstanceScript.cs index 9cc4faa00..699895f9f 100644 --- a/Source/Game/Maps/Instances/InstanceScript.cs +++ b/Source/Game/Maps/Instances/InstanceScript.cs @@ -383,6 +383,8 @@ namespace Game.Maps { DoUpdateCriteria(CriteriaType.DefeatDungeonEncounter, dungeonEncounter.Id); SendBossKillCredit(dungeonEncounter.Id); + if (dungeonEncounter.CompleteWorldStateID != 0) + DoUpdateWorldState((uint)dungeonEncounter.CompleteWorldStateID, 1); } instance.DoOnPlayers(player => player.AtEndOfEncounter(EncounterType.DungeonEncounter)); @@ -448,9 +450,15 @@ namespace Game.Maps // 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; + var dungeonEncounter = bosses[i].GetDungeonEncounterForDifficulty(instance.GetDifficultyID()); + if (dungeonEncounter != null && dungeonEncounter.CompleteWorldStateID != 0) + DoUpdateWorldState((uint)dungeonEncounter.CompleteWorldStateID, bosses[i].state == EncounterState.Done ? 1 : 0); + } + UpdateSpawnGroups(); AfterDataLoad(); } @@ -810,7 +818,6 @@ namespace Game.Maps { if (encounter.creditType == type && encounter.creditEntry == creditEntry) { - completedEncounters |= (1u << encounter.dbcEntry.Bit); if (encounter.dbcEntry.CompleteWorldStateID != 0) DoUpdateWorldState((uint)encounter.dbcEntry.CompleteWorldStateID, 1); @@ -840,19 +847,6 @@ namespace Game.Maps } } - public void SetCompletedEncountersMask(uint newMask) - { - completedEncounters = newMask; - - var encounters = Global.ObjectMgr.GetDungeonEncounterList(instance.GetId(), instance.GetDifficultyID()); - if (encounters != null) - { - foreach (DungeonEncounter encounter in encounters) - if ((completedEncounters & (1 << encounter.dbcEntry.Bit)) != 0 && encounter.dbcEntry.CompleteWorldStateID != 0) - DoUpdateWorldState((uint)encounter.dbcEntry.CompleteWorldStateID, 1); - } - } - void UpdatePhasing() { instance.DoOnPlayers(player => PhasingHandler.SendToPlayer(player)); @@ -940,8 +934,6 @@ namespace Game.Maps public virtual bool CheckRequiredBosses(uint bossId, Player player = null) { return true; } - public uint GetCompletedEncounterMask() { return completedEncounters; } - // Sets a temporary entrance that does not get saved to db public void SetTemporaryEntranceLocation(uint worldSafeLocationId) { _temporaryEntranceId = worldSafeLocationId; } @@ -989,7 +981,6 @@ namespace Game.Maps Dictionary _creatureInfo = new(); Dictionary _gameObjectInfo = new(); Dictionary _objectGuids = new(); - uint completedEncounters; // DEPRECATED, REMOVE List _instanceSpawnGroups = new(); List _activatedAreaTriggers = new(); uint _entranceId; diff --git a/Source/Game/Maps/Map.cs b/Source/Game/Maps/Map.cs index 213d8ae47..de74b0fc9 100644 --- a/Source/Game/Maps/Map.cs +++ b/Source/Game/Maps/Map.cs @@ -4889,7 +4889,6 @@ namespace Game.Maps } InstanceLockData lockData = i_instanceLock.GetInstanceInitializationData(); - i_data.SetCompletedEncountersMask(lockData.CompletedEncountersMask); i_data.SetEntranceLocation(lockData.EntranceWorldSafeLocId); if (!lockData.Data.IsEmpty()) {