From c06b02f5e29f1708c7b81d3c71ff6c8b01b2ba7b Mon Sep 17 00:00:00 2001 From: RealityMachina Date: Wed, 23 May 2018 18:05:49 -0400 Subject: [PATCH] Added more null checks. --- PunchinOut/BasicPanic.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/PunchinOut/BasicPanic.cs b/PunchinOut/BasicPanic.cs index 278bf2f..1c0c802 100644 --- a/PunchinOut/BasicPanic.cs +++ b/PunchinOut/BasicPanic.cs @@ -27,8 +27,9 @@ public static void Prefix(AttackStackSequence __instance, MessageCenterMessage m if (__instance.directorSequences[0].target is Mech) { - ShouldPanic = RollHelpers.ShouldPanic(__instance.directorSequences[0].target as Mech, attackCompleteMessage.attackSequence); mech = __instance.directorSequences[0].target as Mech; + ShouldPanic = RollHelpers.ShouldPanic(mech, attackCompleteMessage.attackSequence); + } @@ -194,6 +195,11 @@ public static int GetTrackedPilotIndex(Mech mech) return -1; } + if(Holder.TrackedPilots == null) + { + Holder.TrackedPilots = new List(); + } + for (int i = 0; i < Holder.TrackedPilots.Count; i++) { @@ -217,6 +223,11 @@ public static bool ShouldPanic(Mech mech, AttackDirector.AttackSequence attackSe return false; } + if(attackSequence == null) + { + return false; + } + if (!attackSequence.attackDidDamage) //no point in panicking over nothing { return false;