Core/WorldStates: Migrate war mode bonus value worldstates to new system
Port From (https://github.com/TrinityCore/TrinityCore/commit/4ac86c13d2b00817c9213ca2c22b747d3fff454e)
This commit is contained in:
@@ -3028,6 +3028,9 @@ namespace Framework.Constants
|
|||||||
BattlefieldTbEastIntactNeutral = 5451,
|
BattlefieldTbEastIntactNeutral = 5451,
|
||||||
BattlefieldTbEastDamagedNeutral = 5452,
|
BattlefieldTbEastDamagedNeutral = 5452,
|
||||||
|
|
||||||
|
WarModeHordeBuffValue = 17042,
|
||||||
|
WarModeAllianceBuffValue = 17043,
|
||||||
|
|
||||||
CurrencyResetTime = 20001, // Next Arena Distribution Time
|
CurrencyResetTime = 20001, // Next Arena Distribution Time
|
||||||
WeeklyQuestResetTime = 20002, // Next Weekly Quest Reset Time
|
WeeklyQuestResetTime = 20002, // Next Weekly Quest Reset Time
|
||||||
BgDailyResetTime = 20003, // Next Daily Bg Reset Time
|
BgDailyResetTime = 20003, // Next Daily Bg Reset Time
|
||||||
|
|||||||
@@ -2938,12 +2938,6 @@ namespace Game.Entities
|
|||||||
packet.AddState(2491, 15); // NA_UI_GUARDS_LEFT
|
packet.AddState(2491, 15); // NA_UI_GUARDS_LEFT
|
||||||
}
|
}
|
||||||
|
|
||||||
// Horde War Mode bonus
|
|
||||||
packet.AddState(17042, (uint)(10 + (Global.WorldMgr.GetWarModeDominantFaction() == TeamId.Alliance ? Global.WorldMgr.GetWarModeOutnumberedFactionReward() : 0)));
|
|
||||||
|
|
||||||
// Alliance War Mode bonus
|
|
||||||
packet.AddState(17043, (uint)(10 + (Global.WorldMgr.GetWarModeDominantFaction() == TeamId.Horde ? Global.WorldMgr.GetWarModeOutnumberedFactionReward() : 0)));
|
|
||||||
|
|
||||||
// insert <field> <value>
|
// insert <field> <value>
|
||||||
switch (zoneId)
|
switch (zoneId)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -895,6 +895,10 @@ namespace Game
|
|||||||
Log.outInfo(LogFilter.ServerLoading, "Loading World States..."); // must be loaded before Battleground, outdoor PvP and conditions
|
Log.outInfo(LogFilter.ServerLoading, "Loading World States..."); // must be loaded before Battleground, outdoor PvP and conditions
|
||||||
LoadWorldStates();
|
LoadWorldStates();
|
||||||
|
|
||||||
|
// TODO: this is temporary until custom world states are purged from old world state saved values
|
||||||
|
Global.WorldStateMgr.SetValue(WorldStates.WarModeHordeBuffValue, (int)GetWorldState(WorldStates.WarModeHordeBuffValue), null);
|
||||||
|
Global.WorldStateMgr.SetValue(WorldStates.WarModeAllianceBuffValue, (int)GetWorldState(WorldStates.WarModeAllianceBuffValue), null);
|
||||||
|
|
||||||
Global.ObjectMgr.LoadPhases();
|
Global.ObjectMgr.LoadPhases();
|
||||||
|
|
||||||
Log.outInfo(LogFilter.ServerLoading, "Loading Conditions...");
|
Log.outInfo(LogFilter.ServerLoading, "Loading Conditions...");
|
||||||
@@ -1254,8 +1258,12 @@ namespace Game
|
|||||||
|
|
||||||
public void SetForcedWarModeFactionBalanceState(int team, int reward = 0)
|
public void SetForcedWarModeFactionBalanceState(int team, int reward = 0)
|
||||||
{
|
{
|
||||||
_warModeDominantFaction = team;
|
Global.WorldStateMgr.SetValue(WorldStates.WarModeHordeBuffValue, 10 + (team == TeamId.Alliance ? reward : 0), null);
|
||||||
_warModeOutnumberedFactionReward = reward;
|
Global.WorldStateMgr.SetValue(WorldStates.WarModeAllianceBuffValue, 10 + (team == TeamId.Horde ? reward : 0), null);
|
||||||
|
|
||||||
|
// save to db
|
||||||
|
SetWorldState(WorldStates.WarModeHordeBuffValue, Global.WorldStateMgr.GetValue(WorldStates.WarModeHordeBuffValue, null));
|
||||||
|
SetWorldState(WorldStates.WarModeAllianceBuffValue, Global.WorldStateMgr.GetValue(WorldStates.WarModeAllianceBuffValue, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DisableForcedWarModeFactionBalanceState()
|
public void DisableForcedWarModeFactionBalanceState()
|
||||||
@@ -2501,33 +2509,36 @@ namespace Game
|
|||||||
} while (result.NextRow());
|
} while (result.NextRow());
|
||||||
}
|
}
|
||||||
|
|
||||||
_warModeDominantFaction = TeamId.Neutral;
|
|
||||||
_warModeOutnumberedFactionReward = 0;
|
|
||||||
|
|
||||||
if (warModeEnabledFaction.All(val => val == 0))
|
|
||||||
return;
|
|
||||||
|
|
||||||
long dominantFactionCount = warModeEnabledFaction[TeamId.Alliance];
|
|
||||||
int dominantFaction = TeamId.Alliance;
|
int dominantFaction = TeamId.Alliance;
|
||||||
if (warModeEnabledFaction[TeamId.Alliance] < warModeEnabledFaction[TeamId.Horde])
|
int outnumberedFactionReward = 0;
|
||||||
|
|
||||||
|
if (warModeEnabledFaction.Any(val => val != 0))
|
||||||
{
|
{
|
||||||
dominantFactionCount = warModeEnabledFaction[TeamId.Horde];
|
long dominantFactionCount = warModeEnabledFaction[TeamId.Alliance];
|
||||||
dominantFaction = TeamId.Horde;
|
if (warModeEnabledFaction[TeamId.Alliance] < warModeEnabledFaction[TeamId.Horde])
|
||||||
|
{
|
||||||
|
dominantFactionCount = warModeEnabledFaction[TeamId.Horde];
|
||||||
|
dominantFaction = TeamId.Horde;
|
||||||
|
}
|
||||||
|
|
||||||
|
double total = warModeEnabledFaction[TeamId.Alliance] + warModeEnabledFaction[TeamId.Horde];
|
||||||
|
double pct = dominantFactionCount / total;
|
||||||
|
|
||||||
|
if (pct >= WorldConfig.GetFloatValue(WorldCfg.CallToArms20Pct))
|
||||||
|
outnumberedFactionReward = 20;
|
||||||
|
else if (pct >= WorldConfig.GetFloatValue(WorldCfg.CallToArms10Pct))
|
||||||
|
outnumberedFactionReward = 10;
|
||||||
|
else if (pct >= WorldConfig.GetFloatValue(WorldCfg.CallToArms5Pct))
|
||||||
|
outnumberedFactionReward = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
double total = warModeEnabledFaction[TeamId.Alliance] + warModeEnabledFaction[TeamId.Horde];
|
Global.WorldStateMgr.SetValue(WorldStates.WarModeHordeBuffValue, 10 + (dominantFaction == TeamId.Alliance ? outnumberedFactionReward : 0), null);
|
||||||
double pct = dominantFactionCount / total;
|
Global.WorldStateMgr.SetValue(WorldStates.WarModeAllianceBuffValue, 10 + (dominantFaction == TeamId.Horde ? outnumberedFactionReward : 0), null);
|
||||||
|
|
||||||
if (pct >= WorldConfig.GetFloatValue(WorldCfg.CallToArms20Pct))
|
// save to db
|
||||||
_warModeOutnumberedFactionReward = 20;
|
SetWorldState(WorldStates.WarModeHordeBuffValue, Global.WorldStateMgr.GetValue(WorldStates.WarModeHordeBuffValue, null));
|
||||||
else if (pct >= WorldConfig.GetFloatValue(WorldCfg.CallToArms10Pct))
|
SetWorldState(WorldStates.WarModeAllianceBuffValue, Global.WorldStateMgr.GetValue(WorldStates.WarModeAllianceBuffValue, null));
|
||||||
_warModeOutnumberedFactionReward = 10;
|
|
||||||
else if (pct >= WorldConfig.GetFloatValue(WorldCfg.CallToArms5Pct))
|
|
||||||
_warModeOutnumberedFactionReward = 5;
|
|
||||||
else
|
|
||||||
return;
|
|
||||||
|
|
||||||
_warModeDominantFaction = dominantFaction;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public uint GetVirtualRealmAddress()
|
public uint GetVirtualRealmAddress()
|
||||||
@@ -2558,10 +2569,6 @@ namespace Game
|
|||||||
|
|
||||||
public bool IsGuidWarning() { return _guidWarn; }
|
public bool IsGuidWarning() { return _guidWarn; }
|
||||||
public bool IsGuidAlert() { return _guidAlert; }
|
public bool IsGuidAlert() { return _guidAlert; }
|
||||||
|
|
||||||
// War mode balancing
|
|
||||||
public int GetWarModeDominantFaction() { return _warModeDominantFaction; }
|
|
||||||
public int GetWarModeOutnumberedFactionReward() { return _warModeOutnumberedFactionReward; }
|
|
||||||
|
|
||||||
public WorldUpdateTime GetWorldUpdateTime() { return _worldUpdateTime; }
|
public WorldUpdateTime GetWorldUpdateTime() { return _worldUpdateTime; }
|
||||||
|
|
||||||
@@ -2638,10 +2645,6 @@ namespace Game
|
|||||||
bool _guidAlert;
|
bool _guidAlert;
|
||||||
uint _warnDiff;
|
uint _warnDiff;
|
||||||
long _warnShutdownTime;
|
long _warnShutdownTime;
|
||||||
|
|
||||||
// War mode balancing
|
|
||||||
int _warModeDominantFaction; // the team that has higher percentage
|
|
||||||
int _warModeOutnumberedFactionReward;
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -140,6 +140,11 @@ namespace Game
|
|||||||
return _worldStateTemplates.LookupByKey(worldStateId);
|
return _worldStateTemplates.LookupByKey(worldStateId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int GetValue(WorldStates worldStateId, Map map)
|
||||||
|
{
|
||||||
|
return GetValue((int)worldStateId, map);
|
||||||
|
}
|
||||||
|
|
||||||
public int GetValue(int worldStateId, Map map)
|
public int GetValue(int worldStateId, Map map)
|
||||||
{
|
{
|
||||||
WorldStateTemplate worldStateTemplate = GetWorldStateTemplate(worldStateId);
|
WorldStateTemplate worldStateTemplate = GetWorldStateTemplate(worldStateId);
|
||||||
|
|||||||
@@ -4441,10 +4441,15 @@ namespace Scripts.Spells.Generic
|
|||||||
if (target == null)
|
if (target == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (target.GetTeamId() == Global.WorldMgr.GetWarModeDominantFaction())
|
switch (target.GetTeamId())
|
||||||
return;
|
{
|
||||||
|
case TeamId.Alliance:
|
||||||
amount += Global.WorldMgr.GetWarModeOutnumberedFactionReward();
|
amount = Global.WorldStateMgr.GetValue(WorldStates.WarModeAllianceBuffValue, null);
|
||||||
|
break;
|
||||||
|
case TeamId.Horde:
|
||||||
|
amount = Global.WorldStateMgr.GetValue(WorldStates.WarModeHordeBuffValue, null);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Register()
|
public override void Register()
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
DELETE FROM `world_state` WHERE `ID` IN (17042,17043);
|
||||||
|
INSERT INTO `world_state` (`ID`,`DefaultValue`,`MapIDs`,`AreaIDs`,`Comment`) VALUES
|
||||||
|
(17042,10,NULL,NULL,'Horde War Mode bonus'),
|
||||||
|
(17043,10,NULL,NULL,'Alliance War Mode bonus');
|
||||||
Reference in New Issue
Block a user