Core/World: adapted Master branch version of world state handling

This commit is contained in:
Ovahlord committed 2022-10-08 23:13:06 +02:00
1 parent 6b8314454f
commit 2521489e2b
27 files changed
+258 -152

No files matched your search

@@ -0,0 +1,5 @@
ALTER TABLE `world_states`
ADD COLUMN `ScriptName` VARCHAR(64) NOT NULL AFTER `MapID`,
CHANGE `Comment` `Comment` TEXT CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci;
RENAME TABLE `world_states` TO `world_state`;
+2 -7
View File
@@ -8800,6 +8800,8 @@ void Player::SendInitWorldStates(uint32 zoneId, uint32 areaId)
packet.AreaID = zoneId;
packet.SubareaID = areaId;
sWorldStateMgr->FillInitialWorldStates(packet, GetMap());
packet.Worldstates.emplace_back(2264, 0); // 1
packet.Worldstates.emplace_back(2263, 0); // 2
packet.Worldstates.emplace_back(2262, 0); // 3
@@ -9420,13 +9422,6 @@ void Player::SendInitWorldStates(uint32 zoneId, uint32 areaId)
break;
}
// insert realm wide world states
sWorldStateMgr->AppendRealmWorldStates(packet.Worldstates);
// insert map world states
if (Map* map = GetMap())
map->AppendWorldStates(packet.Worldstates);
SendDirectMessage(packet.Write());
SendBGWeekendWorldStates();
SendBattlefieldWorldStates();
+18 -28
View File
@@ -145,9 +145,9 @@ i_scriptLock(false), _respawnCheckTimer(0)
MMAP::MMapFactory::createOrGetMMapManager()->loadMapInstance(sWorld->GetDataPath(), GetId(), i_InstanceId);
sScriptMgr->OnCreateMap(this);
_worldStateValues = sWorldStateMgr->GetInitialWorldStatesForMap(this);
sWorldStateMgr->FillDefaultWorldStatesForMap(_worldStates, id);
sScriptMgr->OnCreateMap(this);
}
void Map::InitVisibilityDistance()
@@ -3524,36 +3524,26 @@ void Map::UpdateAreaDependentAuras()
}
}
void Map::SetWorldState(uint32 worldStateId, int32 value, bool withUpdatePacket /*= true*/)
int32 Map::GetWorldStateValue(int32 worldStateId) const
{
_worldStates[worldStateId] = value;
if (!withUpdatePacket)
return;
// Notify all players on the map
WorldPackets::WorldState::UpdateWorldState updateWorldState;
updateWorldState.VariableID = worldStateId;
updateWorldState.Value = value;
updateWorldState.Write();
Map::PlayerList const& players = GetPlayers();
for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
if (Player* player = itr->GetSource())
player->SendDirectMessage(updateWorldState.GetRawPacket());
}
int32 Map::GetWorldStateValue(uint32 worldStateId) const
{
std::unordered_map<uint32, int32>::const_iterator itr = _worldStates.find(worldStateId);
if (itr != _worldStates.end())
return itr->second;
if (int32 const* value = Trinity::Containers::MapGetValuePtr(_worldStateValues, worldStateId))
return *value;
return 0;
}
void Map::AppendWorldStates(std::vector<WorldPackets::WorldState::WorldStateInfo>& worldStates)
void Map::SetWorldStateValue(int32 worldStateId, int32 value)
{
for (std::pair<uint32, int32> worldState : _worldStates)
worldStates.emplace_back(worldState.first, worldState.second);
auto itr = _worldStateValues.try_emplace(worldStateId, 0).first;
int32 oldValue = itr->second;
itr->second = value;
if (WorldStateTemplate const* worldStateTemplate = sWorldStateMgr->GetWorldStateTemplate(worldStateId))
sScriptMgr->OnWorldStateValueChange(worldStateTemplate, oldValue, value, this);
// Broadcast update to all players on the map
WorldPackets::WorldState::UpdateWorldState updateWorldState;
updateWorldState.VariableID = worldStateId;
updateWorldState.Value = value;
SendToPlayers(updateWorldState.Write());
}
+12 -7
View File
@@ -31,6 +31,7 @@
#include "SharedDefines.h"
#include "SpawnData.h"
#include "Timer.h"
#include "WorldStateDefines.h"
#include "Transaction.h"
#include "Weather.h"
#include <boost/heap/fibonacci_heap.hpp>
@@ -648,11 +649,6 @@ class TC_GAME_API Map : public GridRefManager<NGridType>
typedef std::function<void(Map*)> FarSpellCallback;
void AddFarSpellCallback(FarSpellCallback&& callback);
// Sets and stores world state values that will be used by the AchievementMgr to check additional criterias that require world state values
void SetWorldState(uint32 worldStateId, int32 value, bool withUpdatePacket = true);
int32 GetWorldStateValue(uint32 worldStateId) const;
void AppendWorldStates(std::vector<WorldPackets::WorldState::WorldStateInfo>& worldStates);
private:
// Type specific code for add/remove to/from grid
template<class T>
@@ -739,9 +735,18 @@ class TC_GAME_API Map : public GridRefManager<NGridType>
std::unordered_set<Object*> _updateObjects;
std::unordered_map<uint32 /*worldStateId*/, int32 /*value*/> _worldStates;
MPSCQueue<FarSpellCallback> _farSpellCallbacks;
/*********************************************************/
/*** WorldStates ***/
/*********************************************************/
public:
int32 GetWorldStateValue(int32 worldStateId) const;
void SetWorldStateValue(int32 worldStateId, int32 value);
WorldStateValueContainer const& GetWorldStateValues() const { return _worldStateValues; }
private:
WorldStateValueContainer _worldStateValues;
};
enum InstanceResetMethod
+23
View File
@@ -105,6 +105,10 @@ template<>
struct is_script_database_bound<WorldMapScript>
: std::true_type { };
template<>
struct is_script_database_bound<WorldStateScript>
: std::true_type { };
enum Spells
{
SPELL_HOTSWAP_VISUAL_SPELL_EFFECT = 40162 // 59084
@@ -1919,6 +1923,7 @@ void ScriptMgr::OnPlayerUpdateZone(Player* player, uint32 newZone, uint32 newAre
FOREACH_SCRIPT(PlayerScript)->OnUpdateZone(player, newZone, newArea);
}
// Quest
void ScriptMgr::OnQuestStatusChange(Player* player, uint32 questId)
{
FOREACH_SCRIPT(PlayerScript)->OnQuestStatusChange(player, questId);
@@ -2074,6 +2079,15 @@ void ScriptMgr::ModifySpellDamageTaken(Unit* target, Unit* attacker, int32& dama
FOREACH_SCRIPT(UnitScript)->ModifySpellDamageTaken(target, attacker, damage);
}
// WorldState
void ScriptMgr::OnWorldStateValueChange(WorldStateTemplate const* worldStateTemplate, int32 oldValue, int32 newValue, Map const* map)
{
ASSERT(worldStateTemplate);
GET_SCRIPT(WorldStateScript, worldStateTemplate->ScriptId, tmpscript);
tmpscript->OnValueChange(worldStateTemplate->Id, oldValue, newValue, map);
}
SpellScriptLoader::SpellScriptLoader(char const* name)
: ScriptObject(name)
{
@@ -2264,6 +2278,14 @@ GroupScript::GroupScript(char const* name)
ScriptRegistry<GroupScript>::Instance()->AddScript(this);
}
WorldStateScript::WorldStateScript(char const* name)
: ScriptObject(name)
{
ScriptRegistry<WorldStateScript>::Instance()->AddScript(this);
}
WorldStateScript::~WorldStateScript() = default;
// Specialize for each script type class like so:
template class TC_GAME_API ScriptRegistry<SpellScriptLoader>;
template class TC_GAME_API ScriptRegistry<ServerScript>;
@@ -2291,3 +2313,4 @@ template class TC_GAME_API ScriptRegistry<GuildScript>;
template class TC_GAME_API ScriptRegistry<GroupScript>;
template class TC_GAME_API ScriptRegistry<UnitScript>;
template class TC_GAME_API ScriptRegistry<AccountScript>;
template class TC_GAME_API ScriptRegistry<WorldStateScript>;
+19
View File
@@ -70,6 +70,7 @@ struct CreatureData;
struct ItemTemplate;
struct MapEntry;
struct Position;
struct WorldStateTemplate;
enum BattlegroundTypeId : uint32;
enum ContentLevels : uint8;
@@ -792,6 +793,20 @@ class TC_GAME_API GroupScript : public ScriptObject
virtual void OnDisband(Group* /*group*/) { }
};
class TC_GAME_API WorldStateScript : public ScriptObject
{
protected:
WorldStateScript(char const* name);
public:
~WorldStateScript();
// Called when worldstate changes value, map is optional
virtual void OnValueChange([[maybe_unused]] int32 worldStateId, [[maybe_unused]] int32 oldValue, [[maybe_unused]] int32 newValue, [[maybe_unused]] Map const* map) { }
};
// Manages registration, loading, and execution of scripts.
class TC_GAME_API ScriptMgr
{
@@ -1046,6 +1061,10 @@ class TC_GAME_API ScriptMgr
void ModifyMeleeDamage(Unit* target, Unit* attacker, uint32& damage);
void ModifySpellDamageTaken(Unit* target, Unit* attacker, int32& damage);
public: /* WorldStateScript */
void OnWorldStateValueChange(WorldStateTemplate const* worldStateTemplate, int32 oldValue, int32 newValue, Map const* map);
private:
uint32 _scriptCount;
+1 -1
View File
@@ -2129,7 +2129,7 @@ void World::SetInitialWorldSettings()
TC_LOG_INFO("server.loading", "Loading World States..."); // must be loaded before battleground, outdoor PvP and conditions
LoadWorldStates();
TC_LOG_INFO("server.loading", "Loading Map default and Realm wide World States...");
TC_LOG_INFO("server.loading", "Loading World State templates...");
sWorldStateMgr->LoadFromDB();
sObjectMgr->LoadPhases();
@@ -0,0 +1,36 @@
/*
* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef WorldStateDefines_h__
#define WorldStateDefines_h__
#include "Define.h"
#include "Optional.h"
#include <unordered_map>
struct WorldStateTemplate
{
int32 Id = 0;
int32 DefaultValue = 0;
uint32 ScriptId = 0;
Optional<uint32> MapId;
};
using WorldStateValueContainer = std::unordered_map<int32 /*worldStateId*/, int32 /*value*/>;
#endif // WorldStateDefines_h__
@@ -16,78 +16,118 @@
*/
#include "WorldStateMgr.h"
#include "Containers.h"
#include "DatabaseEnv.h"
#include "Log.h"
#include "Map.h"
#include "ObjectMgr.h"
#include "ScriptMgr.h"
#include "World.h"
#include "WorldStatePackets.h"
namespace
{
std::unordered_map<int32, WorldStateTemplate> _worldStateTemplates;
WorldStateValueContainer _realmWorldStateValues;
std::unordered_map<uint32, WorldStateValueContainer> _worldStatesByMap;
}
void WorldStateMgr::LoadFromDB()
{
uint32 oldMSTime = getMSTime();
_mapWorldStates.clear();
_realmWorldStates.clear();
// 0 1 2
QueryResult result = WorldDatabase.Query("SELECT ID, DefaultValue, MapID FROM world_states");
// 0 1 2 3
QueryResult result = WorldDatabase.Query("SELECT ID, DefaultValue, MapID, ScriptName FROM world_state");
if (!result)
return;
uint32 worldStatesCount = 0;
do
{
Field* fields = result->Fetch();
uint32 id = fields[0].GetUInt32();
uint32 defaultValue = fields[1].GetInt32();
Optional<uint32> mapId;
int32 id = fields[0].GetInt32();
WorldStateTemplate& worldState = _worldStateTemplates[id];
worldState.Id = id;
worldState.DefaultValue = fields[1].GetInt32();
if (!fields[2].IsNull())
mapId = fields[2].GetUInt32();
worldState.MapId = fields[2].GetUInt32();
if (mapId.has_value())
_mapWorldStates[*mapId][id] = defaultValue;
worldState.ScriptId = sObjectMgr->GetScriptId(fields[3].GetString());
if (worldState.MapId)
_worldStatesByMap[*worldState.MapId][id] = worldState.DefaultValue;
else
_realmWorldStates[id] = defaultValue;
++worldStatesCount;
_realmWorldStateValues[id] = worldState.DefaultValue;
} while (result->NextRow());
TC_LOG_INFO("server.loading", ">> Loaded %u map and realm world states %u ms", worldStatesCount, GetMSTimeDiffToNow(oldMSTime));
TC_LOG_INFO("server.loading", ">> Loaded " SZFMTD " world state templates %u ms", _worldStateTemplates.size(), GetMSTimeDiffToNow(oldMSTime));
}
void WorldStateMgr::FillDefaultWorldStatesForMap(WorldStateDataMap& worldStates, uint32 mapId)
WorldStateTemplate const* WorldStateMgr::GetWorldStateTemplate(int32 worldStateId) const
{
std::unordered_map<uint32, WorldStateDataMap>::const_iterator itr = _mapWorldStates.find(mapId);
if (itr != _mapWorldStates.end())
worldStates = itr->second;
return Trinity::Containers::MapGetValuePtr(_worldStateTemplates, worldStateId);
}
void WorldStateMgr::AppendRealmWorldStates(std::vector<WorldPackets::WorldState::WorldStateInfo>& worldStates)
int32 WorldStateMgr::GetValue(int32 worldStateId, Map const* map) const
{
for (std::pair<uint32 const, int32>& worldState : _realmWorldStates)
worldStates.emplace_back(worldState.first, worldState.second);
WorldStateTemplate const* worldStateTemplate = GetWorldStateTemplate(worldStateId);
if (!worldStateTemplate || !worldStateTemplate->MapId)
{
if (int32 const* value = Trinity::Containers::MapGetValuePtr(_realmWorldStateValues, worldStateId))
return *value;
return 0;
}
if (map->GetId() != worldStateTemplate->MapId)
return 0;
return map->GetWorldStateValue(worldStateId);
}
void WorldStateMgr::SetRealmWorldStateValue(uint32 worldStateId, int32 value)
void WorldStateMgr::SetValue(int32 worldStateId, int32 value, Map* map)
{
_realmWorldStates[worldStateId] = value;
WorldStateTemplate const* worldStateTemplate = GetWorldStateTemplate(worldStateId);
if (!worldStateTemplate || !worldStateTemplate->MapId)
{
auto itr = _realmWorldStateValues.try_emplace(worldStateId, 0).first;
int32 oldValue = itr->second;
itr->second = value;
// Broadcast update to all players on the server
WorldPackets::WorldState::UpdateWorldState packet;
packet.VariableID = worldStateId;
packet.Value = value;
packet.Write();
sWorld->SendGlobalMessage(packet.GetRawPacket());
if (worldStateTemplate)
sScriptMgr->OnWorldStateValueChange(worldStateTemplate, oldValue, value, nullptr);
// Broadcast update to all players on the server
WorldPackets::WorldState::UpdateWorldState updateWorldState;
updateWorldState.VariableID = worldStateId;
updateWorldState.Value = value;
sWorld->SendGlobalMessage(updateWorldState.Write());
return;
}
if (map->GetId() != worldStateTemplate->MapId)
return;
map->SetWorldStateValue(worldStateId, value);
}
int32 WorldStateMgr::GetRealmWorldStateValue(uint32 worldStateId) const
WorldStateValueContainer WorldStateMgr::GetInitialWorldStatesForMap(Map const* map) const
{
auto itr = _realmWorldStates.find(worldStateId);
if (itr != _realmWorldStates.end())
return itr->second;
WorldStateValueContainer initialValues;
if (WorldStateValueContainer const* valuesTemplate = Trinity::Containers::MapGetValuePtr(_worldStatesByMap, map->GetId()))
initialValues = *valuesTemplate;
return 0;
return initialValues;
}
void WorldStateMgr::FillInitialWorldStates(WorldPackets::WorldState::InitWorldStates& initWorldStates, Map const* map) const
{
for (auto const& [worldStateId, value] : _realmWorldStateValues)
initWorldStates.Worldstates.emplace_back(worldStateId, value);
for (auto const& [worldStateId, value] : map->GetWorldStateValues())
initWorldStates.Worldstates.emplace_back(worldStateId, value);
}
WorldStateMgr* WorldStateMgr::instance()
@@ -1,39 +1,33 @@
/*
* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef WorldStateMgr_h__
#define WorldStateMgr_h__
#include "Define.h"
#include "Optional.h"
#include <unordered_map>
#include <vector>
#include "WorldStateDefines.h"
namespace WorldPackets
class Map;
namespace WorldPackets::WorldState
{
namespace WorldState
{
struct WorldStateInfo;
}
class InitWorldStates;
}
typedef std::unordered_map<uint32, int32> WorldStateDataMap;
class TC_GAME_API WorldStateMgr
{
public:
@@ -41,15 +35,14 @@ public:
void LoadFromDB();
void FillDefaultWorldStatesForMap(WorldStateDataMap& worldStates, uint32 mapId);
void AppendRealmWorldStates(std::vector<WorldPackets::WorldState::WorldStateInfo>& worldStates);
WorldStateTemplate const* GetWorldStateTemplate(int32 worldStateId) const;
void SetRealmWorldStateValue(uint32 worldStateId, int32 value);
int32 GetRealmWorldStateValue(uint32 worldStateId) const;
int32 GetValue(int32 worldStateId, Map const* map) const;
void SetValue(int32 worldStateId, int32 value, Map* map);
private:
std::unordered_map<uint32 /*mapId*/, WorldStateDataMap> _mapWorldStates;
std::unordered_map<uint32 /*worldStateId*/, int32 /*value*/> _realmWorldStates;
WorldStateValueContainer GetInitialWorldStatesForMap(Map const* map) const;
void FillInitialWorldStates(WorldPackets::WorldState::InitWorldStates& initWorldStates, Map const* map) const;
};
#define sWorldStateMgr WorldStateMgr::instance()
@@ -333,7 +333,7 @@ struct boss_ascendant_council_controller final : public BossAI
break;
instance->SetBossState(DATA_ASCENDANT_COUNCIL, IN_PROGRESS);
instance->instance->SetWorldState(WORLD_STATE_ID_ELEMENTARY, 0);
instance->instance->SetWorldStateValue(WORLD_STATE_ID_ELEMENTARY, 0);
if (Creature* feludius = instance->GetCreature(DATA_FELUDIUS))
{
@@ -1325,7 +1325,7 @@ struct npc_elementium_monstrosity final : public ScriptedAI
{
++_liquidIceCount;
if (_liquidIceCount == 2)
_instance->instance->SetWorldState(WORLD_STATE_ID_ELEMENTARY, 1);
_instance->instance->SetWorldStateValue(WORLD_STATE_ID_ELEMENTARY, 1);
}
}
@@ -239,7 +239,7 @@ namespace CorruptionHandler
if (power > CORRUPTION_ACHIEVEMENT_CAP)
if (InstanceScript* instance = target->GetInstanceScript())
if (!instance->instance->GetWorldStateValue(WORLD_STATE_ID_THE_ABYSS_WILL_GAZE_BACK_INTO_YOU))
instance->instance->SetWorldState(WORLD_STATE_ID_THE_ABYSS_WILL_GAZE_BACK_INTO_YOU, 1);
instance->instance->SetWorldStateValue(WORLD_STATE_ID_THE_ABYSS_WILL_GAZE_BACK_INTO_YOU, 1);
}
}
@@ -299,7 +299,7 @@ struct boss_chogall final : public BossAI
BossAI::JustEngagedWith(who);
Talk(SAY_AGGRO);
instance->SendEncounterUnit(ENCOUNTER_FRAME_ENGAGE, me);
instance->instance->SetWorldState(WORLD_STATE_ID_THE_ABYSS_WILL_GAZE_BACK_INTO_YOU, 0);
instance->instance->SetWorldStateValue(WORLD_STATE_ID_THE_ABYSS_WILL_GAZE_BACK_INTO_YOU, 0);
DoCastSelf(SPELL_CORRUPTED_BLOOD);
events.SetPhase(PHASE_1);
events.ScheduleEvent(EVENT_FURY_OF_CHOGALL, 33s);
@@ -170,7 +170,7 @@ struct boss_halfus_wyrmbreaker final : public BossAI
BossAI::JustEngagedWith(who);
Talk(SAY_AGGRO);
instance->SendEncounterUnit(ENCOUNTER_FRAME_ENGAGE, me, 1);
instance->instance->SetWorldState(WORLD_STATE_ID_THE_ONLY_ESCAPE, 0);
instance->instance->SetWorldStateValue(WORLD_STATE_ID_THE_ONLY_ESCAPE, 0);
events.ScheduleEvent(EVENT_BERSERK, 10min);
if (Creature* protoBehemoth = instance->GetCreature(DATA_PROTO_BEHEMOTH))
@@ -237,13 +237,13 @@ struct boss_halfus_wyrmbreaker final : public BossAI
if (_theOnlyEscapeAchievementState == NOT_STARTED)
{
_theOnlyEscapeAchievementState = IN_PROGRESS;
instance->instance->SetWorldState(WORLD_STATE_ID_THE_ONLY_ESCAPE, 1);
instance->instance->SetWorldStateValue(WORLD_STATE_ID_THE_ONLY_ESCAPE, 1);
events.ScheduleEvent(EVENT_RESET_ACHIEVEMT, Seconds(10));
}
else if (_theOnlyEscapeAchievementState == IN_PROGRESS)
{
_theOnlyEscapeAchievementState = DONE;
instance->instance->SetWorldState(WORLD_STATE_ID_THE_ONLY_ESCAPE, 2);
instance->instance->SetWorldStateValue(WORLD_STATE_ID_THE_ONLY_ESCAPE, 2);
events.CancelEvent(EVENT_RESET_ACHIEVEMT);
}
break;
@@ -109,7 +109,7 @@ struct boss_ascendant_lord_obsidius : public BossAI
{
BossAI::JustEngagedWith(who);
instance->SendEncounterUnit(ENCOUNTER_FRAME_ENGAGE, me);
instance->instance->SetWorldState(WORLD_STATE_ID_ASCENDANT_DESCENDING, 0);
instance->instance->SetWorldStateValue(WORLD_STATE_ID_ASCENDANT_DESCENDING, 0);
Talk(SAY_AGGRO);
events.ScheduleEvent(EVENT_STONE_BLOW, 8s);
events.ScheduleEvent(EVENT_TWILIGHT_CORRUPTION, 12s);
@@ -321,7 +321,7 @@ class spell_obsidius_crepuscular_veil : public SpellScript
if (aura->GetStackAmount() == GetSpellInfo()->StackAmount)
if (InstanceScript* instance = target->GetInstanceScript())
if (!instance->instance->GetWorldStateValue(WORLD_STATE_ID_ASCENDANT_DESCENDING))
instance->instance->SetWorldState(WORLD_STATE_ID_ASCENDANT_DESCENDING, 1);
instance->instance->SetWorldStateValue(WORLD_STATE_ID_ASCENDANT_DESCENDING, 1);
}
void Register() override
@@ -205,7 +205,7 @@ struct boss_atramedes : public BossAI
{
BossAI::JustEngagedWith(who);
instance->SendEncounterUnit(ENCOUNTER_FRAME_ENGAGE, me);
instance->instance->SetWorldState(WORLD_STATE_ID_SILENCE_IS_GOLDEN, 0);
instance->instance->SetWorldStateValue(WORLD_STATE_ID_SILENCE_IS_GOLDEN, 0);
Talk(SAY_AGGRO);
DoCastSelf(SPELL_DEVASTATION_TRIGGER);
DoCastSelf(SPELL_SOUND_BAR);
@@ -915,7 +915,7 @@ class spell_atramedes_sound_bar : public AuraScript
}
else if (target->GetPower(POWER_ALTERNATE_POWER) >= 50)
if (!instance->instance->GetWorldStateValue(WORLD_STATE_ID_SILENCE_IS_GOLDEN))
instance->instance->SetWorldState(WORLD_STATE_ID_SILENCE_IS_GOLDEN, 1);
instance->instance->SetWorldStateValue(WORLD_STATE_ID_SILENCE_IS_GOLDEN, 1);
}
void Register() override
@@ -150,7 +150,7 @@ struct boss_chimaeron : public BossAI
{
BossAI::JustEngagedWith(who);
instance->SendEncounterUnit(ENCOUNTER_FRAME_ENGAGE, me);
instance->instance->SetWorldState(WORLD_STATE_ID_FULL_OF_SOUND_AND_FURY, 0);
instance->instance->SetWorldStateValue(WORLD_STATE_ID_FULL_OF_SOUND_AND_FURY, 0);
me->SetReactState(REACT_AGGRESSIVE);
events.SetPhase(PHASE_1);
events.ScheduleEvent(EVENT_CAUSTIC_SLIME, 5s, 0, PHASE_1);
@@ -212,7 +212,7 @@ struct boss_chimaeron : public BossAI
{
_killedPlayerCount++;
if (_killedPlayerCount == 3)
instance->instance->SetWorldState(WORLD_STATE_ID_FULL_OF_SOUND_AND_FURY, 1);
instance->instance->SetWorldStateValue(WORLD_STATE_ID_FULL_OF_SOUND_AND_FURY, 1);
}
}
@@ -235,7 +235,7 @@ struct boss_magmaw : public BossAI
BossAI::JustEngagedWith(who);
instance->SendEncounterUnit(ENCOUNTER_FRAME_ENGAGE, me, FRAME_PRIORITY_MAGMAW);
instance->instance->SetWorldState(WORLD_STATE_ID_PARASITE_EVENING, 0);
instance->instance->SetWorldStateValue(WORLD_STATE_ID_PARASITE_EVENING, 0);
me->SetReactState(REACT_AGGRESSIVE);
events.SetPhase(PHASE_COMBAT);
@@ -702,7 +702,7 @@ struct npc_magmaw_lava_parasite : public ScriptedAI
me->SetReactState(REACT_PASSIVE);
me->DespawnOrUnsummon(4s);
if (!_instance->instance->GetWorldStateValue(WORLD_STATE_ID_PARASITE_EVENING))
_instance->instance->SetWorldState(WORLD_STATE_ID_PARASITE_EVENING, 1);
_instance->instance->SetWorldStateValue(WORLD_STATE_ID_PARASITE_EVENING, 1);
}
}
@@ -785,7 +785,7 @@ struct boss_nefarians_end : public BossAI
break;
case EVENT_LAND_PHASE_THREE:
if (me->GetHealthPct() > 50.f)
instance->instance->SetWorldState(WORLD_STATE_ID_KEEPING_IT_IN_THE_FAMILY, 0);
instance->instance->SetWorldStateValue(WORLD_STATE_ID_KEEPING_IT_IN_THE_FAMILY, 0);
me->RemoveAurasDueToSpell(SPELL_NEFARIAN_PHASE_2_HEALTH_AURA);
me->SendSetPlayHoverAnim(true);
@@ -930,7 +930,7 @@ struct npc_nefarians_end_onyxia : public ScriptedAI
if (_instance->GetBossState(DATA_NEFARIANS_END) != IN_PROGRESS)
{
_instance->SetBossState(DATA_NEFARIANS_END, IN_PROGRESS);
_instance->instance->SetWorldState(WORLD_STATE_ID_KEEPING_IT_IN_THE_FAMILY, 1);
_instance->instance->SetWorldStateValue(WORLD_STATE_ID_KEEPING_IT_IN_THE_FAMILY, 1);
}
_instance->SendEncounterUnit(ENCOUNTER_FRAME_ENGAGE, me, FRAME_INDEX_ONYXIA);
@@ -302,10 +302,10 @@ struct boss_omnotron_defense_system : public BossAI
break;
case ACTION_START_ENCOUNTER:
instance->SetBossState(DATA_OMNOTRON_DEFENSE_SYSTEM, IN_PROGRESS);
instance->instance->SetWorldState(WORLD_STATE_ID_STATIC_SHOCK, 0);
instance->instance->SetWorldState(WORLD_STATE_ID_POISON_BOMB, 0);
instance->instance->SetWorldState(WORLD_STATE_ID_ARCANE_ANNIHILATOR, 0);
instance->instance->SetWorldState(WORLD_STATE_ID_FLAMETHROWER, 0);
instance->instance->SetWorldStateValue(WORLD_STATE_ID_STATIC_SHOCK, 0);
instance->instance->SetWorldStateValue(WORLD_STATE_ID_POISON_BOMB, 0);
instance->instance->SetWorldStateValue(WORLD_STATE_ID_ARCANE_ANNIHILATOR, 0);
instance->instance->SetWorldStateValue(WORLD_STATE_ID_FLAMETHROWER, 0);
if (IsHeroic())
DoSummon(NPC_LORD_VICTOR_NEFARIUS_OMNOTRON, LordVictorNefariusSummonPosition, 0, TEMPSUMMON_MANUAL_DESPAWN);
@@ -921,7 +921,7 @@ struct npc_omnotron_arcanotron : public ScriptedAI
{
if (spell->Id == SPELL_ARCANE_ANNIHILATION)
if (!_instance->instance->GetWorldStateValue(WORLD_STATE_ID_ARCANE_ANNIHILATOR))
_instance->instance->SetWorldState(WORLD_STATE_ID_ARCANE_ANNIHILATOR, 1);
_instance->instance->SetWorldStateValue(WORLD_STATE_ID_ARCANE_ANNIHILATOR, 1);
}
void UpdateAI(uint32 diff) override
@@ -1151,7 +1151,7 @@ struct npc_omnotron_poison_bomb : public ScriptedAI
{
if (InstanceScript* instance = me->GetInstanceScript())
if (!instance->instance->GetWorldStateValue(WORLD_STATE_ID_POISON_BOMB))
instance->instance->SetWorldState(WORLD_STATE_ID_POISON_BOMB, 1);
instance->instance->SetWorldStateValue(WORLD_STATE_ID_POISON_BOMB, 1);
DoCastSelf(SPELL_POISON_BOMB_DAMAGE, true);
DoCastSelf(SPELL_POISON_BOMB_SUMMON_PUDDLE, true);
@@ -1372,7 +1372,7 @@ class spell_omnotron_unstable_shield : public AuraScript
if (InstanceScript* instance = caster->GetInstanceScript())
if (!instance->instance->GetWorldStateValue(WORLD_STATE_ID_STATIC_SHOCK))
instance->instance->SetWorldState(WORLD_STATE_ID_STATIC_SHOCK, 1);
instance->instance->SetWorldStateValue(WORLD_STATE_ID_STATIC_SHOCK, 1);
}
void Register() override
@@ -1549,7 +1549,7 @@ class spell_omnotron_flamethrower : public SpellScript
if (targets.size() >= 2)
if (InstanceScript* instance = GetCaster()->GetInstanceScript())
if (!instance->instance->GetWorldStateValue(WORLD_STATE_ID_FLAMETHROWER))
instance->instance->SetWorldState(WORLD_STATE_ID_FLAMETHROWER, 1);
instance->instance->SetWorldStateValue(WORLD_STATE_ID_FLAMETHROWER, 1);
}
void Register() override
@@ -141,7 +141,7 @@ struct boss_erudax : public BossAI
BossAI::JustEngagedWith(who);
Talk(SAY_AGGRO);
instance->SendEncounterUnit(ENCOUNTER_FRAME_ENGAGE, me, 1);
instance->instance->SetWorldState(WORLD_STATE_ID_DONT_NEED_TO_BREAK_EGGS, 0);
instance->instance->SetWorldStateValue(WORLD_STATE_ID_DONT_NEED_TO_BREAK_EGGS, 0);
events.ScheduleEvent(EVENT_BINDING_SHADOWS, 10s + 500ms);
events.ScheduleEvent(EVENT_ENFEEBLING_BLOW, 19s);
events.ScheduleEvent(EVENT_SHADOW_GALE, 26s);
@@ -367,7 +367,7 @@ struct npc_erudax_faceless_corruptor : public ScriptedAI
break;
case EVENT_TWILIGHT_CORRUPTION:
// Fail achievement by setting the required world state to 1 (0 is required for successful achievement)
_instance->instance->SetWorldState(WORLD_STATE_ID_DONT_NEED_TO_BREAK_EGGS, 1);
_instance->instance->SetWorldStateValue(WORLD_STATE_ID_DONT_NEED_TO_BREAK_EGGS, 1);
DoCastAOE(SPELL_TWILIGHT_CORRUPTION);
break;
case EVENT_UMBRAL_MENDING:
@@ -86,7 +86,7 @@ struct boss_baron_ashbury : public BossAI
BossAI::JustEngagedWith(who);
Talk(SAY_AGGRO);
instance->SendEncounterUnit(ENCOUNTER_FRAME_ENGAGE, me, 1);
instance->instance->SetWorldState(WORLD_STATE_ID_PARDON_DENIED, 0);
instance->instance->SetWorldStateValue(WORLD_STATE_ID_PARDON_DENIED, 0);
events.ScheduleEvent(EVENT_ASPHYXIATE, IsHeroic() ? 20s + 500ms : 15s + 500ms);
events.ScheduleEvent(EVENT_PAIN_AND_SUFFERING, 6s);
@@ -115,7 +115,7 @@ struct boss_baron_ashbury : public BossAI
return;
if (!instance->instance->GetWorldStateValue(WORLD_STATE_ID_PARDON_DENIED))
instance->instance->SetWorldState(WORLD_STATE_ID_PARDON_DENIED, 1);
instance->instance->SetWorldStateValue(WORLD_STATE_ID_PARDON_DENIED, 1);
}
void DamageTaken(Unit* /*attacker*/, uint32& damage) override
@@ -510,7 +510,7 @@ public:
if (InstanceScript* instance = target->GetInstanceScript())
if (!instance->instance->GetWorldStateValue(WORLD_STATE_ID_TO_THE_GROUND))
instance->instance->SetWorldState(WORLD_STATE_ID_TO_THE_GROUND, 1);
instance->instance->SetWorldStateValue(WORLD_STATE_ID_TO_THE_GROUND, 1);
}
}
@@ -106,7 +106,7 @@ public:
case MAP_EVENT_AZURE_DRAGONSHRINE_ENTERED:
if (GetBossState(DATA_ECHO_OF_JAINA) == DONE)
break;
instance->SetWorldState(WORLD_STATE_ID_SHOW_COLLECTED_STAVE_FRAGMENTS, 1);
instance->SetWorldStateValue(WORLD_STATE_ID_SHOW_COLLECTED_STAVE_FRAGMENTS, 1);
break;
default:
break;
@@ -198,7 +198,7 @@ public:
case DATA_ECHO_OF_JAINA:
if (state == IN_PROGRESS)
{
instance->SetWorldState(WORLD_STATE_ID_SHOW_COLLECTED_STAVE_FRAGMENTS, 0);
instance->SetWorldStateValue(WORLD_STATE_ID_SHOW_COLLECTED_STAVE_FRAGMENTS, 0);
if (Creature* circle = GetCreature(DATA_ARCANE_CIRCLE))
circle->DespawnOrUnsummon();
}
@@ -219,7 +219,7 @@ public:
break;
++_collectedStaffFragments;
instance->SetWorldState(WORLD_STATE_ID_COLLECTED_STAVE_FRAGMENTS, _collectedStaffFragments);
instance->SetWorldStateValue(WORLD_STATE_ID_COLLECTED_STAVE_FRAGMENTS, _collectedStaffFragments);
if (_collectedStaffFragments < 16)
{
@@ -243,7 +243,7 @@ struct boss_lord_rhyolith : public BossAI
BossAI::JustEngagedWith(who);
Talk(SAY_ENGAGE, who);
instance->SendEncounterUnit(ENCOUNTER_FRAME_ENGAGE, me, 1);
me->GetMap()->SetWorldState(WORLD_STATE_ID_NOT_AN_AMBI_TURNER, 0);
me->GetMap()->SetWorldStateValue(WORLD_STATE_ID_NOT_AN_AMBI_TURNER, 0);
uint8 frameIndex = 2;
for (uint32 type : { DATA_LEFT_FOOT, DATA_RIGHT_FOOT })
@@ -536,7 +536,7 @@ struct boss_lord_rhyolith : public BossAI
if (!_achievementFailed && _currentBalance < CENTER_BALANCE)
{
me->GetMap()->SetWorldState(WORLD_STATE_ID_NOT_AN_AMBI_TURNER, 1);
me->GetMap()->SetWorldStateValue(WORLD_STATE_ID_NOT_AN_AMBI_TURNER, 1);
_achievementFailed = true;
}
@@ -103,7 +103,7 @@ struct boss_rajh : public BossAI
BossAI::JustEngagedWith(who);
Talk(SAY_AGGRO);
instance->SendEncounterUnit(ENCOUNTER_FRAME_ENGAGE, me);
instance->instance->SetWorldState(WORLD_STATE_ID_SUN_OF_A, 0);
instance->instance->SetWorldStateValue(WORLD_STATE_ID_SUN_OF_A, 0);
me->SetReactState(REACT_AGGRESSIVE);
_randomTimerCase = RAND(0, 1);
events.ScheduleEvent(EVENT_SOLAR_WINDS, 5s);
@@ -226,7 +226,7 @@ struct boss_rajh : public BossAI
break;
case EVENT_REENGAGE:
if (!instance->instance->GetWorldStateValue(WORLD_STATE_ID_SUN_OF_A))
instance->instance->SetWorldState(WORLD_STATE_ID_SUN_OF_A, 1);
instance->instance->SetWorldStateValue(WORLD_STATE_ID_SUN_OF_A, 1);
_energized = true;
_randomTimerCase = RAND(0, 1);
events.ScheduleEvent(EVENT_SOLAR_WINDS, 5s);
@@ -105,7 +105,7 @@ struct boss_temple_guardian_anhuur : public BossAI
{
BossAI::JustEngagedWith(who);
instance->SendEncounterUnit(ENCOUNTER_FRAME_ENGAGE, me);
instance->instance->SetWorldState(WORLD_STATE_ID_I_HATE_THAT_SONG, 0);
instance->instance->SetWorldStateValue(WORLD_STATE_ID_I_HATE_THAT_SONG, 0);
Talk(SAY_AGGRO);
events.SetPhase(PHASE_FIGHT);
events.ScheduleEvent(EVENT_DIVINE_RECKONING, 10s, 0, PHASE_FIGHT);
@@ -235,7 +235,7 @@ struct boss_temple_guardian_anhuur : public BossAI
instance->SetData(DATA_HANDLE_BEAM_OF_LIGHT, IN_PROGRESS);
break;
case EVENT_ACHIEVEMENT_FAILED:
instance->instance->SetWorldState(WORLD_STATE_ID_I_HATE_THAT_SONG, 1);
instance->instance->SetWorldStateValue(WORLD_STATE_ID_I_HATE_THAT_SONG, 1);
break;
default:
break;
@@ -470,7 +470,7 @@ class instance_halls_of_origination : public InstanceMapScript
anraphet->AI()->DoAction(ACTION_ANRAPHET_INTRO);
break;
case EVENT_FAIL_VAULTS_OF_LIGHT_ACHIEVEMENT:
instance->SetWorldState(WORLD_STATE_ID_FASTER_THAN_THE_SPEED_OF_LIGHT, 1);
instance->SetWorldStateValue(WORLD_STATE_ID_FASTER_THAN_THE_SPEED_OF_LIGHT, 1);
break;
default:
break;