Core/WorldStates: Migrate battleground HolidayWorldState to new system
Port From (https://github.com/TrinityCore/TrinityCore/commit/020166649dd5afb94dddbfcc990d4bb51e231ab1)
This commit is contained in:
@@ -717,20 +717,6 @@ namespace Game.Entities
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendBGWeekendWorldStates()
|
|
||||||
{
|
|
||||||
foreach (var bl in CliDB.BattlemasterListStorage.Values)
|
|
||||||
{
|
|
||||||
if (bl.HolidayWorldState != 0)
|
|
||||||
{
|
|
||||||
if (Global.BattlegroundMgr.IsBGWeekend((BattlegroundTypeId)bl.Id))
|
|
||||||
SendUpdateWorldState(bl.HolidayWorldState, 1);
|
|
||||||
else
|
|
||||||
SendUpdateWorldState(bl.HolidayWorldState, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SendPvpRewards()
|
public void SendPvpRewards()
|
||||||
{
|
{
|
||||||
//WorldPacket packet(SMSG_REQUEST_PVP_REWARDS_RESPONSE, 24);
|
//WorldPacket packet(SMSG_REQUEST_PVP_REWARDS_RESPONSE, 24);
|
||||||
|
|||||||
@@ -2932,7 +2932,6 @@ namespace Game.Entities
|
|||||||
packet.AddState(3901, previousArenaSeason);
|
packet.AddState(3901, previousArenaSeason);
|
||||||
|
|
||||||
SendPacket(packet);
|
SendPacket(packet);
|
||||||
SendBGWeekendWorldStates();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public long GetBarberShopCost(List<ChrCustomizationChoice> newCustomizations)
|
public long GetBarberShopCost(List<ChrCustomizationChoice> newCustomizations)
|
||||||
|
|||||||
@@ -38,13 +38,13 @@ namespace Game
|
|||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case GameEventState.Normal:
|
case GameEventState.Normal:
|
||||||
{
|
{
|
||||||
long currenttime = GameTime.GetGameTime();
|
long currenttime = GameTime.GetGameTime();
|
||||||
// Get the event information
|
// Get the event information
|
||||||
return mGameEvent[entry].start < currenttime
|
return mGameEvent[entry].start < currenttime
|
||||||
&& currenttime < mGameEvent[entry].end
|
&& currenttime < mGameEvent[entry].end
|
||||||
&& (currenttime - mGameEvent[entry].start) % (mGameEvent[entry].occurence * Time.Minute) < mGameEvent[entry].length * Time.Minute;
|
&& (currenttime - mGameEvent[entry].start) % (mGameEvent[entry].occurence * Time.Minute) < mGameEvent[entry].length * Time.Minute;
|
||||||
}
|
}
|
||||||
// if the state is conditions or nextphase, then the event should be active
|
// if the state is conditions or nextphase, then the event should be active
|
||||||
case GameEventState.WorldConditions:
|
case GameEventState.WorldConditions:
|
||||||
case GameEventState.WorldNextPhase:
|
case GameEventState.WorldNextPhase:
|
||||||
@@ -55,18 +55,18 @@ namespace Game
|
|||||||
return false;
|
return false;
|
||||||
// if inactive world event, check the prerequisite events
|
// if inactive world event, check the prerequisite events
|
||||||
case GameEventState.WorldInactive:
|
case GameEventState.WorldInactive:
|
||||||
|
{
|
||||||
|
long currenttime = GameTime.GetGameTime();
|
||||||
|
foreach (var gameEventId in mGameEvent[entry].prerequisite_events)
|
||||||
{
|
{
|
||||||
long currenttime = GameTime.GetGameTime();
|
if ((mGameEvent[gameEventId].state != GameEventState.WorldNextPhase && mGameEvent[gameEventId].state != GameEventState.WorldFinished) || // if prereq not in nextphase or finished state, then can't start this one
|
||||||
foreach (var gameEventId in mGameEvent[entry].prerequisite_events)
|
mGameEvent[gameEventId].nextstart > currenttime) // if not in nextphase state for long enough, can't start this one
|
||||||
{
|
return false;
|
||||||
if ((mGameEvent[gameEventId].state != GameEventState.WorldNextPhase && mGameEvent[gameEventId].state != GameEventState.WorldFinished) || // if prereq not in nextphase or finished state, then can't start this one
|
|
||||||
mGameEvent[gameEventId].nextstart > currenttime) // if not in nextphase state for long enough, can't start this one
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// all prerequisite events are met
|
|
||||||
// but if there are no prerequisites, this can be only activated through gm command
|
|
||||||
return !(mGameEvent[entry].prerequisite_events.Empty());
|
|
||||||
}
|
}
|
||||||
|
// all prerequisite events are met
|
||||||
|
// but if there are no prerequisites, this can be only activated through gm command
|
||||||
|
return !(mGameEvent[entry].prerequisite_events.Empty());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1005,7 +1005,7 @@ namespace Game
|
|||||||
// changed, save to DB the gameevent state, will be updated in next update cycle
|
// changed, save to DB the gameevent state, will be updated in next update cycle
|
||||||
SaveWorldEventStateToDB(id);
|
SaveWorldEventStateToDB(id);
|
||||||
|
|
||||||
Log.outDebug(LogFilter.Misc, "GameEvent {0} is active", id);
|
Log.outDebug(LogFilter.Misc, "GameEvent {0} is active", id);
|
||||||
// queue for activation
|
// queue for activation
|
||||||
if (!IsActiveEvent(id))
|
if (!IsActiveEvent(id))
|
||||||
activate.Add(id);
|
activate.Add(id);
|
||||||
@@ -1137,7 +1137,7 @@ namespace Game
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateBattlegroundSettings()
|
void UpdateBattlegroundSettings()
|
||||||
@@ -1342,7 +1342,7 @@ namespace Game
|
|||||||
{
|
{
|
||||||
var creatureBounds = map.GetCreatureBySpawnIdStore().LookupByKey(tuple.Item1);
|
var creatureBounds = map.GetCreatureBySpawnIdStore().LookupByKey(tuple.Item1);
|
||||||
foreach (var creature in creatureBounds)
|
foreach (var creature in creatureBounds)
|
||||||
{
|
{
|
||||||
if (activate)
|
if (activate)
|
||||||
{
|
{
|
||||||
tuple.Item2.equipement_id_prev = creature.GetCurrentEquipmentId();
|
tuple.Item2.equipement_id_prev = creature.GetCurrentEquipmentId();
|
||||||
@@ -1477,15 +1477,10 @@ namespace Game
|
|||||||
BattlegroundTypeId bgTypeId = Global.BattlegroundMgr.WeekendHolidayIdToBGType(Event.holiday_id);
|
BattlegroundTypeId bgTypeId = Global.BattlegroundMgr.WeekendHolidayIdToBGType(Event.holiday_id);
|
||||||
if (bgTypeId != BattlegroundTypeId.None)
|
if (bgTypeId != BattlegroundTypeId.None)
|
||||||
{
|
{
|
||||||
BattlemasterListRecord bl = CliDB.BattlemasterListStorage.LookupByKey(bgTypeId);
|
var bl = CliDB.BattlemasterListStorage.LookupByKey(Global.BattlegroundMgr.WeekendHolidayIdToBGType(Event.holiday_id));
|
||||||
if (bl != null && bl.HolidayWorldState != 0)
|
if (bl != null)
|
||||||
{
|
if (bl.HolidayWorldState != 0)
|
||||||
UpdateWorldState worldstate = new();
|
Global.WorldStateMgr.SetValue(bl.HolidayWorldState, Activate ? 1 : 0, false, null);
|
||||||
worldstate.VariableID = bl.HolidayWorldState;
|
|
||||||
worldstate.Value = Activate ? 1 : 0;
|
|
||||||
//worldstate.Hidden = false;
|
|
||||||
Global.WorldMgr.SendGlobalMessage(worldstate);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ namespace Game
|
|||||||
if (worldStateTemplate == null || worldStateTemplate.MapIds.Empty())
|
if (worldStateTemplate == null || worldStateTemplate.MapIds.Empty())
|
||||||
return _realmWorldStateValues.LookupByKey(worldStateId);
|
return _realmWorldStateValues.LookupByKey(worldStateId);
|
||||||
|
|
||||||
if (!worldStateTemplate.MapIds.Contains(map.GetId()))
|
if (map == null || !worldStateTemplate.MapIds.Contains(map.GetId()))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return map.GetWorldStateValue(worldStateId);
|
return map.GetWorldStateValue(worldStateId);
|
||||||
@@ -197,7 +197,7 @@ namespace Game
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!worldStateTemplate.MapIds.Contains(map.GetId()))
|
if (map == null || !worldStateTemplate.MapIds.Contains(map.GetId()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
map.SetWorldStateValue(worldStateId, value, hidden);
|
map.SetWorldStateValue(worldStateId, value, hidden);
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
DELETE FROM `world_state` WHERE `ID` IN (1941,1942,1943,2851,3695,4273,5360,5361,6306,6436,7671);
|
||||||
|
INSERT INTO `world_state` (`ID`,`DefaultValue`,`MapIDs`,`AreaIDs`,`ScriptName`,`Comment`) VALUES
|
||||||
|
(1941,0,NULL,NULL,'','Battleground Call to Arms - Alterac Valley'),
|
||||||
|
(1942,0,NULL,NULL,'','Battleground Call to Arms - Warsong Gulch'),
|
||||||
|
(1943,0,NULL,NULL,'','Battleground Call to Arms - Arathi Basin'),
|
||||||
|
(2851,0,NULL,NULL,'','Battleground Call to Arms - Eye of the Storm'),
|
||||||
|
(3695,0,NULL,NULL,'','Battleground Call to Arms - Strand of the Ancients'),
|
||||||
|
(4273,0,NULL,NULL,'','Battleground Call to Arms - Isle of Conquest'),
|
||||||
|
(5360,0,NULL,NULL,'','Battleground Call to Arms - The Battle for Gilneas'),
|
||||||
|
(5361,0,NULL,NULL,'','Battleground Call to Arms - Twin Peaks'),
|
||||||
|
(6306,0,NULL,NULL,'','Battleground Call to Arms - Temple of Kotmogu'),
|
||||||
|
(6436,0,NULL,NULL,'','Battleground Call to Arms - Silvershard Mines'),
|
||||||
|
(7671,0,NULL,NULL,'','Battleground Call to Arms - Deepwind Gorge (Legacy)');
|
||||||
Reference in New Issue
Block a user