Some cleanups. (might break build for scripts as they are a WIP)

This commit is contained in:
hondacrx
2023-10-08 10:35:31 -04:00
parent fa10b981bd
commit cda53c8e7f
208 changed files with 2266 additions and 2329 deletions
@@ -354,13 +354,13 @@ namespace Game.BattleGrounds.Zones
CastSpellOnTeam(BattlegroundConst.AbQuestReward4Bases, team);
Creature trigger = !BgCreatures[node + 7].IsEmpty() ? GetBGCreature(node + 7) : null; // 0-6 spirit guides
if (!trigger)
if (trigger == null)
trigger = AddCreature(SharedConst.WorldTrigger, node + 7, NodePositions[node], GetTeamIndexByTeamId(team));
//add bonus honor aura trigger creature when node is accupied
//cast bonus aura (+50% honor in 25yards)
//aura should only apply to players who have accupied the node, set correct faction for trigger
if (trigger)
if (trigger != null)
{
trigger.SetFaction(team == Team.Alliance ? 84u : 83u);
trigger.CastSpell(trigger, BattlegroundConst.SpellHonorableDefender25y, false);
@@ -389,7 +389,7 @@ namespace Game.BattleGrounds.Zones
byte node = ABBattlegroundNodes.NodeStables;
GameObject obj = GetBgMap().GetGameObject(BgObjects[node * 8 + 7]);
while ((node < ABBattlegroundNodes.DynamicNodesCount) && ((!obj) || (!source.IsWithinDistInMap(obj, 10))))
while ((node < ABBattlegroundNodes.DynamicNodesCount) && ((obj == null) || (!source.IsWithinDistInMap(obj, 10))))
{
++node;
obj = GetBgMap().GetGameObject(BgObjects[node * 8 + ABObjectTypes.AuraContested]);
@@ -153,13 +153,13 @@ namespace Game.BattleGrounds.Zones
for (byte i = 0; i < EotSPoints.PointsMax; ++i)
{
obj = GetBgMap().GetGameObject(BgObjects[EotSObjectTypes.TowerCapFelReaver + i]);
if (obj)
if (obj != null)
{
byte j = 0;
while (j < m_PlayersNearPoint[EotSPoints.PointsMax].Count)
{
Player player = Global.ObjAccessor.FindPlayer(m_PlayersNearPoint[EotSPoints.PointsMax][j]);
if (!player)
if (player == null)
{
Log.outError(LogFilter.Battleground, "BattlegroundEY:CheckSomeoneJoinedPoint: Player ({0}) could not be found!", m_PlayersNearPoint[EotSPoints.PointsMax][j].ToString());
++j;
@@ -194,13 +194,13 @@ namespace Game.BattleGrounds.Zones
for (byte i = 0; i < EotSPoints.PointsMax; ++i)
{
obj = GetBgMap().GetGameObject(BgObjects[EotSObjectTypes.TowerCapFelReaver + i]);
if (obj)
if (obj != null)
{
byte j = 0;
while (j < m_PlayersNearPoint[i].Count)
{
Player player = Global.ObjAccessor.FindPlayer(m_PlayersNearPoint[i][j]);
if (!player)
if (player == null)
{
Log.outError(LogFilter.Battleground, "BattlegroundEY:CheckSomeoneLeftPoint Player ({0}) could not be found!", m_PlayersNearPoint[i][j].ToString());
//move non-existing players to "free space" - this will cause many errors showing in log, but it is a very important bug
@@ -256,7 +256,7 @@ namespace Game.BattleGrounds.Zones
for (byte i = 0; i < m_PlayersNearPoint[point].Count; ++i)
{
Player player = Global.ObjAccessor.FindPlayer(m_PlayersNearPoint[point][i]);
if (player)
if (player != null)
{
player.SendUpdateWorldState(EotSWorldStateIds.ProgressBarStatus, (uint)m_PointBarStatus[point]);
Team team = GetPlayerTeam(player.GetGUID());
@@ -375,7 +375,7 @@ namespace Game.BattleGrounds.Zones
{
if (m_FlagKeeper == guid)
{
if (player)
if (player != null)
EventPlayerDroppedFlag(player);
else
{
@@ -578,7 +578,7 @@ namespace Game.BattleGrounds.Zones
RespawnFlag(true);
GameObject obj = GetBgMap().GetGameObject(GetDroppedFlagGUID());
if (obj)
if (obj != null)
obj.Delete();
else
Log.outError(LogFilter.Battleground, "BattlegroundEY: Unknown dropped flag ({0}).", GetDroppedFlagGUID().ToString());
@@ -764,13 +764,13 @@ namespace Game.BattleGrounds.Zones
return;
Creature trigger = GetBGCreature(Point + 6);//0-5 spirit guides
if (!trigger)
if (trigger == null)
trigger = AddCreature(SharedConst.WorldTrigger, Point + 6, EotSMisc.TriggerPositions[Point], GetTeamIndexByTeamId(Team));
//add bonus honor aura trigger creature when node is accupied
//cast bonus aura (+50% honor in 25yards)
//aura should only apply to players who have accupied the node, set correct faction for trigger
if (trigger)
if (trigger != null)
{
trigger.SetFaction(Team == Team.Alliance ? 84u : 83);
trigger.CastSpell(trigger, BattlegroundConst.SpellHonorableDefender25y, false);
@@ -58,7 +58,7 @@ namespace Game.BattleGrounds.Zones
foreach (var pair in GetPlayers())
{
Player player = Global.ObjAccessor.FindPlayer(pair.Key);
if (player)
if (player != null)
SendTransportsRemove(player);
}
@@ -77,7 +77,7 @@ namespace Game.BattleGrounds.Zones
for (byte i = 0; i < GateStatus.Length; ++i)
GateStatus[i] = Attackers == TeamId.Horde ? SAGateState.AllianceGateOk : SAGateState.HordeGateOk;
if (!AddCreature(SAMiscConst.NpcEntries[SACreatureTypes.Kanrethad], SACreatureTypes.Kanrethad, SAMiscConst.NpcSpawnlocs[SACreatureTypes.Kanrethad]))
if (AddCreature(SAMiscConst.NpcEntries[SACreatureTypes.Kanrethad], SACreatureTypes.Kanrethad, SAMiscConst.NpcSpawnlocs[SACreatureTypes.Kanrethad]) == null)
{
Log.outError(LogFilter.Battleground, $"SOTA: couldn't spawn Kanrethad, aborted. Entry: {SAMiscConst.NpcEntries[SACreatureTypes.Kanrethad]}");
return false;
@@ -135,7 +135,7 @@ namespace Game.BattleGrounds.Zones
//By capturing GYs.
for (byte i = 0; i < SACreatureTypes.Demolisher5; i++)
{
if (!AddCreature(SAMiscConst.NpcEntries[i], i, SAMiscConst.NpcSpawnlocs[i], Attackers == TeamId.Alliance ? TeamId.Horde : TeamId.Alliance, 600))
if (AddCreature(SAMiscConst.NpcEntries[i], i, SAMiscConst.NpcSpawnlocs[i], Attackers == TeamId.Alliance ? TeamId.Horde : TeamId.Alliance, 600) == null)
{
Log.outError(LogFilter.Battleground, $"SOTA: couldn't spawn Cannon or demolisher, Entry: {SAMiscConst.NpcEntries[i]}, Attackers: {(Attackers == TeamId.Alliance ? "Horde(1)" : "Alliance(0)")}");
continue;
@@ -252,7 +252,7 @@ namespace Game.BattleGrounds.Zones
foreach (var pair in GetPlayers())
{
Player player = Global.ObjAccessor.FindPlayer(pair.Key);
if (player)
if (player != null)
SendTransportInit(player);
}
}
@@ -276,15 +276,15 @@ namespace Game.BattleGrounds.Zones
{
foreach (var pair in GetPlayers())
{
Player p = Global.ObjAccessor.FindPlayer(pair.Key);
if (p)
Player player = Global.ObjAccessor.FindPlayer(pair.Key);
if (player != null)
{
UpdateData data = new(p.GetMapId());
GetBGObject(i).BuildValuesUpdateBlockForPlayer(data, p);
UpdateData data = new(player.GetMapId());
GetBGObject(i).BuildValuesUpdateBlockForPlayer(data, player);
UpdateObject pkt;
data.BuildPacket(out pkt);
p.SendPacket(pkt);
player.SendPacket(pkt);
}
}
}
@@ -318,9 +318,9 @@ namespace Game.BattleGrounds.Zones
UpdateWorldState(SAWorldStateIds.Timer, (int)(GameTime.GetGameTime() + EndRoundTimer));
if (TotalTime >= SATimers.WarmupLength)
{
Creature c = GetBGCreature(SACreatureTypes.Kanrethad);
if (c)
SendChatMessage(c, SATextIds.RoundStarted);
Creature creature = GetBGCreature(SACreatureTypes.Kanrethad);
if (creature != null)
SendChatMessage(creature, SATextIds.RoundStarted);
TotalTime = 0;
ToggleTimer();
@@ -342,9 +342,9 @@ namespace Game.BattleGrounds.Zones
UpdateWorldState(SAWorldStateIds.Timer, (int)(GameTime.GetGameTime() + EndRoundTimer));
if (TotalTime >= 60000)
{
Creature c = GetBGCreature(SACreatureTypes.Kanrethad);
if (c)
SendChatMessage(c, SATextIds.RoundStarted);
Creature creature = GetBGCreature(SACreatureTypes.Kanrethad);
if (creature != null)
SendChatMessage(creature, SATextIds.RoundStarted);
TotalTime = 0;
ToggleTimer();
@@ -355,9 +355,9 @@ namespace Game.BattleGrounds.Zones
SetStatus(BattlegroundStatus.InProgress);
foreach (var pair in GetPlayers())
{
Player p = Global.ObjAccessor.FindPlayer(pair.Key);
if (p)
p.RemoveAurasDueToSpell(BattlegroundConst.SpellPreparation);
Player player = Global.ObjAccessor.FindPlayer(pair.Key);
if (player != null)
player.RemoveAurasDueToSpell(BattlegroundConst.SpellPreparation);
}
}
if (TotalTime >= 30000)
@@ -443,7 +443,7 @@ namespace Game.BattleGrounds.Zones
foreach (var pair in GetPlayers())
{
Player player = Global.ObjAccessor.FindPlayer(pair.Key);
if (player)
if (player != null)
{
// should remove spirit of redemption
if (player.HasAuraType(AuraType.SpiritOfRedemption))
@@ -488,12 +488,12 @@ namespace Game.BattleGrounds.Zones
public override void ProcessEvent(WorldObject obj, uint eventId, WorldObject invoker = null)
{
GameObject go = obj.ToGameObject();
if (go)
if (go != null)
{
switch (go.GetGoType())
{
case GameObjectTypes.Goober:
if (invoker)
if (invoker != null)
if (eventId == (uint)SAEventIds.BG_SA_EVENT_TITAN_RELIC_ACTIVATED)
TitanRelicActivated(invoker.ToPlayer());
break;
@@ -509,9 +509,9 @@ namespace Game.BattleGrounds.Zones
{
GateStatus[gateId] = Attackers == TeamId.Horde ? SAGateState.AllianceGateDamaged : SAGateState.HordeGateDamaged;
Creature c = obj.FindNearestCreature(SharedConst.WorldTrigger, 500.0f);
if (c)
SendChatMessage(c, (byte)gate.DamagedText, invoker);
Creature creature = obj.FindNearestCreature(SharedConst.WorldTrigger, 500.0f);
if (creature != null)
SendChatMessage(creature, (byte)gate.DamagedText, invoker);
PlaySoundToAll(Attackers == TeamId.Alliance ? SASoundIds.WallAttackedAlliance : SASoundIds.WallAttackedHorde);
}
@@ -523,9 +523,9 @@ namespace Game.BattleGrounds.Zones
if (gateId < 5)
DelObject((int)gateId + 14);
Creature c = obj.FindNearestCreature(SharedConst.WorldTrigger, 500.0f);
if (c)
SendChatMessage(c, (byte)gate.DestroyedText, invoker);
Creature creature = obj.FindNearestCreature(SharedConst.WorldTrigger, 500.0f);
if (creature != null)
SendChatMessage(creature, (byte)gate.DestroyedText, invoker);
PlaySoundToAll(Attackers == TeamId.Alliance ? SASoundIds.WallDestroyedAlliance : SASoundIds.WallDestroyedHorde);
@@ -552,13 +552,13 @@ namespace Game.BattleGrounds.Zones
break;
}
if (invoker)
if (invoker != null)
{
Unit unit = invoker.ToUnit();
if (unit)
if (unit != null)
{
Player player = unit.GetCharmerOrOwnerPlayerOrPlayerItself();
if (player)
if (player != null)
{
UpdatePlayerScore(player, ScoreType.DestroyedWall, 1);
if (rewardHonor)
@@ -605,14 +605,14 @@ namespace Game.BattleGrounds.Zones
for (byte i = SACreatureTypes.Gun1; i <= SACreatureTypes.Gun10; i++)
{
Creature gun = GetBGCreature(i);
if (gun)
if (gun != null)
gun.SetFaction(SAMiscConst.Factions[Attackers != 0 ? TeamId.Alliance : TeamId.Horde]);
}
for (byte i = SACreatureTypes.Demolisher1; i <= SACreatureTypes.Demolisher4; i++)
{
Creature dem = GetBGCreature(i);
if (dem)
if (dem != null)
dem.SetFaction(SAMiscConst.Factions[Attackers]);
}
}
@@ -626,7 +626,7 @@ namespace Game.BattleGrounds.Zones
for (byte i = SACreatureTypes.Demolisher1; i <= SACreatureTypes.Demolisher4; i++)
{
Creature dem = GetBGCreature(i);
if (dem)
if (dem != null)
{
if (start)
{
@@ -704,7 +704,7 @@ namespace Game.BattleGrounds.Zones
void UpdateObjectInteractionFlags(uint objectId)
{
GameObject go = GetBGObject((int)objectId);
if (go)
if (go != null)
{
if (CanInteractWithObject(objectId))
go.RemoveFlag(GameObjectFlags.NotSelectable);
@@ -774,23 +774,23 @@ namespace Game.BattleGrounds.Zones
npc = SACreatureTypes.Rigspark;
Creature rigspark = AddCreature(SAMiscConst.NpcEntries[npc], (int)npc, SAMiscConst.NpcSpawnlocs[npc], Attackers);
if (rigspark)
if (rigspark != null)
rigspark.GetAI().Talk(SATextIds.SparklightRigsparkSpawn);
for (byte j = SACreatureTypes.Demolisher7; j <= SACreatureTypes.Demolisher8; j++)
{
AddCreature(SAMiscConst.NpcEntries[j], j, SAMiscConst.NpcSpawnlocs[j], (Attackers == TeamId.Alliance ? TeamId.Horde : TeamId.Alliance), 600);
Creature dem = GetBGCreature(j);
if (dem)
if (dem != null)
dem.SetFaction(SAMiscConst.Factions[Attackers]);
}
UpdateWorldState(SAWorldStateIds.LeftGyAlliance, GraveyardStatus[i] == TeamId.Alliance ? 1 : 0);
UpdateWorldState(SAWorldStateIds.LeftGyHorde, GraveyardStatus[i] == TeamId.Horde ? 1 : 0);
Creature c = source.FindNearestCreature(SharedConst.WorldTrigger, 500.0f);
if (c)
SendChatMessage(c, teamId == TeamId.Alliance ? SATextIds.WestGraveyardCapturedA : SATextIds.WestGraveyardCapturedH, source);
Creature creature = source.FindNearestCreature(SharedConst.WorldTrigger, 500.0f);
if (creature != null)
SendChatMessage(creature, teamId == TeamId.Alliance ? SATextIds.WestGraveyardCapturedA : SATextIds.WestGraveyardCapturedH, source);
}
break;
case SAGraveyards.RightCapturableGy:
@@ -802,7 +802,7 @@ namespace Game.BattleGrounds.Zones
npc = SACreatureTypes.Sparklight;
Creature sparklight = AddCreature(SAMiscConst.NpcEntries[npc], (int)npc, SAMiscConst.NpcSpawnlocs[npc], Attackers);
if (sparklight)
if (sparklight != null)
sparklight.GetAI().Talk(SATextIds.SparklightRigsparkSpawn);
for (byte j = SACreatureTypes.Demolisher5; j <= SACreatureTypes.Demolisher6; j++)
@@ -810,16 +810,16 @@ namespace Game.BattleGrounds.Zones
AddCreature(SAMiscConst.NpcEntries[j], j, SAMiscConst.NpcSpawnlocs[j], Attackers == TeamId.Alliance ? TeamId.Horde : TeamId.Alliance, 600);
Creature dem = GetBGCreature(j);
if (dem)
if (dem != null)
dem.SetFaction(SAMiscConst.Factions[Attackers]);
}
UpdateWorldState(SAWorldStateIds.RightGyAlliance, GraveyardStatus[i] == TeamId.Alliance ? 1 : 0);
UpdateWorldState(SAWorldStateIds.RightGyHorde, GraveyardStatus[i] == TeamId.Horde ? 1 : 0);
Creature c = source.FindNearestCreature(SharedConst.WorldTrigger, 500.0f);
if (c)
SendChatMessage(c, teamId == TeamId.Alliance ? SATextIds.EastGraveyardCapturedA : SATextIds.EastGraveyardCapturedH, source);
Creature creature = source.FindNearestCreature(SharedConst.WorldTrigger, 500.0f);
if (creature != null)
SendChatMessage(creature, teamId == TeamId.Alliance ? SATextIds.EastGraveyardCapturedA : SATextIds.EastGraveyardCapturedH, source);
}
break;
case SAGraveyards.CentralCapturableGy:
@@ -832,9 +832,9 @@ namespace Game.BattleGrounds.Zones
UpdateWorldState(SAWorldStateIds.CenterGyAlliance, GraveyardStatus[i] == TeamId.Alliance ? 1 : 0);
UpdateWorldState(SAWorldStateIds.CenterGyHorde, GraveyardStatus[i] == TeamId.Horde ? 1 : 0);
Creature c = source.FindNearestCreature(SharedConst.WorldTrigger, 500.0f);
if (c)
SendChatMessage(c, teamId == TeamId.Alliance ? SATextIds.SouthGraveyardCapturedA : SATextIds.SouthGraveyardCapturedH, source);
Creature creature = source.FindNearestCreature(SharedConst.WorldTrigger, 500.0f);
if (creature != null)
SendChatMessage(creature, teamId == TeamId.Alliance ? SATextIds.SouthGraveyardCapturedA : SATextIds.SouthGraveyardCapturedH, source);
}
break;
default:
@@ -845,7 +845,7 @@ namespace Game.BattleGrounds.Zones
void TitanRelicActivated(Player clicker)
{
if (!clicker)
if (clicker == null)
return;
if (CanInteractWithObject(SAObjectTypes.TitanRelic))
@@ -866,7 +866,7 @@ namespace Game.BattleGrounds.Zones
foreach (var pair in GetPlayers())
{
Player player = Global.ObjAccessor.FindPlayer(pair.Key);
if (player)
if (player != null)
if (GetTeamIndexByTeamId(GetPlayerTeam(player.GetGUID())) == Attackers)
player.UpdateCriteria(CriteriaType.BeSpellTarget, 65246);
}
@@ -876,9 +876,9 @@ namespace Game.BattleGrounds.Zones
TotalTime = 0;
ToggleTimer();
Creature c = GetBGCreature(SACreatureTypes.Kanrethad);
if (c)
SendChatMessage(c, SATextIds.Round1Finished);
Creature creature = GetBGCreature(SACreatureTypes.Kanrethad);
if (creature != null)
SendChatMessage(creature, SATextIds.Round1Finished);
UpdateWaitTimer = 5000;
SignaledRoundTwo = false;
@@ -898,7 +898,7 @@ namespace Game.BattleGrounds.Zones
foreach (var pair in GetPlayers())
{
Player player = Global.ObjAccessor.FindPlayer(pair.Key);
if (player)
if (player != null)
if (GetTeamIndexByTeamId(GetPlayerTeam(player.GetGUID())) == Attackers && RoundScores[1].winner == Attackers)
player.UpdateCriteria(CriteriaType.BeSpellTarget, 65246);
}
@@ -941,10 +941,10 @@ namespace Game.BattleGrounds.Zones
{
if (!BgCreatures[i].IsEmpty())
{
Creature Demolisher = GetBGCreature(i);
if (Demolisher)
Creature demolisher = GetBGCreature(i);
if (demolisher != null)
{
if (Demolisher.IsDead())
if (demolisher.IsDead())
{
// Demolisher is not in list
if (!DemoliserRespawnList.ContainsKey(i))
@@ -955,8 +955,8 @@ namespace Game.BattleGrounds.Zones
{
if (DemoliserRespawnList[i] < GameTime.GetGameTimeMS())
{
Demolisher.Relocate(SAMiscConst.NpcSpawnlocs[i]);
Demolisher.Respawn();
demolisher.Relocate(SAMiscConst.NpcSpawnlocs[i]);
demolisher.Respawn();
DemoliserRespawnList.Remove(i);
}
}
@@ -97,11 +97,11 @@ namespace Game.BattleGrounds.Zones
{
// Apply Stage 1 (Focused Assault)
Player player = Global.ObjAccessor.FindPlayer(m_FlagKeepers[0]);
if (player)
if (player != null)
player.CastSpell(player, WSGSpellId.FocusedAssault, true);
player = Global.ObjAccessor.FindPlayer(m_FlagKeepers[1]);
if (player)
if (player != null)
player.CastSpell(player, WSGSpellId.FocusedAssault, true);
_flagDebuffState = 1;
@@ -110,14 +110,14 @@ namespace Game.BattleGrounds.Zones
{
// Apply Stage 2 (Brutal Assault)
Player player = Global.ObjAccessor.FindPlayer(m_FlagKeepers[0]);
if (player)
if (player != null)
{
player.RemoveAurasDueToSpell(WSGSpellId.FocusedAssault);
player.CastSpell(player, WSGSpellId.BrutalAssault, true);
}
player = Global.ObjAccessor.FindPlayer(m_FlagKeepers[1]);
if (player)
if (player != null)
{
player.RemoveAurasDueToSpell(WSGSpellId.FocusedAssault);
player.CastSpell(player, WSGSpellId.BrutalAssault, true);
@@ -132,14 +132,14 @@ namespace Game.BattleGrounds.Zones
// Remove assault debuffs, reset timers
Player player = Global.ObjAccessor.FindPlayer(m_FlagKeepers[0]);
if (player)
if (player != null)
{
player.RemoveAurasDueToSpell(WSGSpellId.FocusedAssault);
player.RemoveAurasDueToSpell(WSGSpellId.BrutalAssault);
}
player = Global.ObjAccessor.FindPlayer(m_FlagKeepers[1]);
if (player)
if (player != null)
{
player.RemoveAurasDueToSpell(WSGSpellId.FocusedAssault);
player.RemoveAurasDueToSpell(WSGSpellId.BrutalAssault);
@@ -231,7 +231,7 @@ namespace Game.BattleGrounds.Zones
PlaySoundToAll(WSGSound.FlagsRespawned);
GameObject obj = GetBgMap().GetGameObject(GetDroppedFlagGUID(team));
if (obj)
if (obj != null)
obj.Delete();
else
Log.outError(LogFilter.Battleground, "unknown droped flag ({0})", GetDroppedFlagGUID(team).ToString());
@@ -547,7 +547,7 @@ namespace Game.BattleGrounds.Zones
// sometimes flag aura not removed :(
if (IsAllianceFlagPickedup() && m_FlagKeepers[TeamId.Alliance] == guid)
{
if (!player)
if (player == null)
{
Log.outError(LogFilter.Battleground, "BattlegroundWS: Removing offline player who has the FLAG!!");
SetAllianceFlagPicker(ObjectGuid.Empty);
@@ -558,7 +558,7 @@ namespace Game.BattleGrounds.Zones
}
if (IsHordeFlagPickedup() && m_FlagKeepers[TeamId.Horde] == guid)
{
if (!player)
if (player == null)
{
Log.outError(LogFilter.Battleground, "BattlegroundWS: Removing offline player who has the FLAG!!");
SetHordeFlagPicker(ObjectGuid.Empty);