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
+19 -19
View File
@@ -109,10 +109,10 @@ namespace Game.AI
/// <param name="who"></param>
public void AddThreat(Unit victim, float amount, Unit who = null)
{
if (!victim)
if (victim == null)
return;
if (!who)
if (who == null)
who = me;
who.GetThreatManager().AddThreat(victim, amount, null, true, true);
@@ -126,10 +126,10 @@ namespace Game.AI
/// <param name="who"></param>
public void ModifyThreatByPercent(Unit victim, int pct, Unit who = null)
{
if (!victim)
if (victim == null)
return;
if (!who)
if (who == null)
who = me;
who.GetThreatManager().ModifyThreatByPercent(victim, pct);
@@ -142,10 +142,10 @@ namespace Game.AI
/// <param name="who"></param>
public void ResetThreat(Unit victim, Unit who)
{
if (!victim)
if (victim == null)
return;
if (!who)
if (who == null)
who = me;
who.GetThreatManager().ResetThreat(victim);
@@ -157,7 +157,7 @@ namespace Game.AI
/// <param name="who"></param>
public void ResetThreatList(Unit who = null)
{
if (!who)
if (who == null)
who = me;
who.GetThreatManager().ResetAllThreat();
@@ -171,10 +171,10 @@ namespace Game.AI
/// <returns></returns>
public float GetThreat(Unit victim, Unit who = null)
{
if (!victim)
if (victim == null)
return 0.0f;
if (!who)
if (who == null)
who = me;
return who.GetThreatManager().GetThreat(victim);
@@ -645,11 +645,11 @@ namespace Game.AI
delayToRespawn = TimeSpan.FromSeconds(2);
}
if (!who)
if (who == null)
who = me;
TempSummon whoSummon = who.ToTempSummon();
if (whoSummon)
if (whoSummon != null)
{
Log.outWarn(LogFilter.ScriptsAi, $"BossAI::_DespawnAtEvade: called on a temporary summon (who: {who.GetGUID()})");
whoSummon.UnSummon();
@@ -705,7 +705,7 @@ namespace Game.AI
void _JustEngagedWith()
{
Unit target = SelectTarget(SelectTargetMethod.Random, 0, 0.0f, true);
if (target)
if (target != null)
AttackStart(target);
}
@@ -713,7 +713,7 @@ namespace Game.AI
{
summons.Summon(summon);
Unit target = SelectTarget(SelectTargetMethod.Random, 0, 0.0f, true);
if (target)
if (target != null)
summon.GetAI().AttackStart(target);
}
@@ -772,7 +772,7 @@ namespace Game.AI
foreach (var id in this)
{
Creature summon = ObjectAccessor.GetCreature(_me, id);
if (summon && summon.IsAIEnabled() && (entry == 0 || summon.GetEntry() == entry))
if (summon != null && summon.IsAIEnabled() && (entry == 0 || summon.GetEntry() == entry))
{
summon.GetAI().DoZoneInCombat();
}
@@ -784,7 +784,7 @@ namespace Game.AI
foreach (var id in this)
{
Creature summon = ObjectAccessor.GetCreature(_me, id);
if (!summon)
if (summon == null)
Remove(id);
else if (summon.GetEntry() == entry)
{
@@ -800,7 +800,7 @@ namespace Game.AI
{
Creature summon = ObjectAccessor.GetCreature(_me, this.FirstOrDefault());
RemoveAt(0);
if (summon)
if (summon != null)
summon.DespawnOrUnsummon();
}
}
@@ -821,7 +821,7 @@ namespace Game.AI
{
foreach (var id in this)
{
if (!ObjectAccessor.GetCreature(_me, id))
if (ObjectAccessor.GetCreature(_me, id) == null)
Remove(id);
}
}
@@ -847,7 +847,7 @@ namespace Game.AI
foreach (var id in this)
{
Creature summon = ObjectAccessor.GetCreature(_me, id);
if (summon && summon.GetEntry() == entry)
if (summon != null && summon.GetEntry() == entry)
return true;
}
@@ -859,7 +859,7 @@ namespace Game.AI
foreach (var guid in summons)
{
Creature summon = ObjectAccessor.GetCreature(_me, guid);
if (summon && summon.IsAIEnabled())
if (summon != null && summon.IsAIEnabled())
summon.GetAI().DoAction(action);
}
}
@@ -33,7 +33,7 @@ namespace Game.AI
//see followerAI
bool AssistPlayerInCombatAgainst(Unit who)
{
if (!who || !who.GetVictim())
if (who == null || who.GetVictim() == null)
return false;
if (me.HasReactState(ReactStates.Passive))
@@ -44,7 +44,7 @@ namespace Game.AI
return false;
//not a player
if (!who.GetVictim().GetCharmerOrOwnerPlayerOrPlayerItself())
if (who.GetVictim().GetCharmerOrOwnerPlayerOrPlayerItself() == null)
return false;
//never attack friendly
@@ -78,15 +78,15 @@ namespace Game.AI
return;
Player player = GetPlayerForEscort();
if (player)
if (player != null)
{
Group group = player.GetGroup();
if (group)
if (group != null)
{
for (GroupReference groupRef = group.GetFirstMember(); groupRef != null; groupRef = groupRef.Next())
{
Player member = groupRef.GetSource();
if (member)
if (member != null)
if (member.IsInMap(player))
member.FailQuest(_escortQuest.Id);
}
@@ -145,15 +145,15 @@ namespace Game.AI
bool IsPlayerOrGroupInRange()
{
Player player = GetPlayerForEscort();
if (player)
if (player != null)
{
Group group = player.GetGroup();
if (group)
if (group != null)
{
for (GroupReference groupRef = group.GetFirstMember(); groupRef != null; groupRef = groupRef.Next())
{
Player member = groupRef.GetSource();
if (member)
if (member != null)
if (me.IsWithinDistInMap(member, GetMaxPlayerDistance()))
return true;
}
@@ -47,15 +47,15 @@ namespace Game.AI
// @todo need a better check for quests with time limit.
Player player = GetLeaderForFollower();
if (player)
if (player != null)
{
Group group = player.GetGroup();
if (group)
if (group != null)
{
for (GroupReference groupRef = group.GetFirstMember(); groupRef != null; groupRef = groupRef.Next())
{
Player member = groupRef.GetSource();
if (member)
if (member != null)
if (member.IsInMap(player))
member.FailQuest(_questForFollow);
}
@@ -104,10 +104,10 @@ namespace Game.AI
bool questAbandoned = (_questForFollow != 0);
Player player = GetLeaderForFollower();
if (player)
if (player != null)
{
Group group = player.GetGroup();
if (group)
if (group != null)
{
for (GroupReference groupRef = group.GetFirstMember(); groupRef != null && (maxRangeExceeded || questAbandoned); groupRef = groupRef.Next())
{
@@ -247,19 +247,19 @@ namespace Game.AI
Player GetLeaderForFollower()
{
Player player = Global.ObjAccessor.GetPlayer(me, _leaderGUID);
if (player)
if (player != null)
{
if (player.IsAlive())
return player;
else
{
Group group = player.GetGroup();
if (group)
if (group != null)
{
for (GroupReference groupRef = group.GetFirstMember(); groupRef != null; groupRef = groupRef.Next())
{
Player member = groupRef.GetSource();
if (member && me.IsWithinDistInMap(member, 100.0f) && member.IsAlive())
if (member != null && me.IsWithinDistInMap(member, 100.0f) && member.IsAlive())
{
Log.outDebug(LogFilter.Scripts, $"FollowerAI::GetLeaderForFollower: GetLeader changed and returned new leader. ({me.GetGUID()})");
_leaderGUID = member.GetGUID();
@@ -279,7 +279,7 @@ namespace Game.AI
//The flag (type_flag) is unconfirmed, but used here for further research and is a good candidate.
bool ShouldAssistPlayerInCombatAgainst(Unit who)
{
if (!who || !who.GetVictim())
if (who == null || who.GetVictim() == null)
return false;
//experimental (unknown) flag not present