From e4aa3fe14738355872e5fe880009b2886b18a319 Mon Sep 17 00:00:00 2001 From: Joshua Paul Woods Date: Mon, 9 Jan 2023 20:44:16 -0800 Subject: [PATCH] add some extra null checking to prevent occasional null object error --- FriendlySkeletonWand/BasePlugin.cs | 31 +++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/FriendlySkeletonWand/BasePlugin.cs b/FriendlySkeletonWand/BasePlugin.cs index 8fbcb1c..1e45278 100644 --- a/FriendlySkeletonWand/BasePlugin.cs +++ b/FriendlySkeletonWand/BasePlugin.cs @@ -422,21 +422,26 @@ static class ArrowImpactPatch // stop minions from damaging player structures static void Prefix(ref HitData hit, Piece ___m_piece) { - if (hit.GetAttacker().TryGetComponent(out UndeadMinion undeadMinion)) + if (hit != null) { - if (___m_piece.IsPlacedByPlayer()) + Character attacker = hit.GetAttacker(); + if (attacker != null + && attacker.TryGetComponent(out UndeadMinion undeadMinion)) { - hit.m_damage.m_damage = 0f; - hit.m_damage.m_blunt = 0f; - hit.m_damage.m_slash = 0f; - hit.m_damage.m_pierce = 0f; - hit.m_damage.m_chop = 0f; - hit.m_damage.m_pickaxe = 0f; - hit.m_damage.m_fire = 0f; - hit.m_damage.m_frost = 0f; - hit.m_damage.m_lightning = 0f; - hit.m_damage.m_poison = 0f; - hit.m_damage.m_spirit = 0f; + if (___m_piece.IsPlacedByPlayer()) + { + hit.m_damage.m_damage = 0f; + hit.m_damage.m_blunt = 0f; + hit.m_damage.m_slash = 0f; + hit.m_damage.m_pierce = 0f; + hit.m_damage.m_chop = 0f; + hit.m_damage.m_pickaxe = 0f; + hit.m_damage.m_fire = 0f; + hit.m_damage.m_frost = 0f; + hit.m_damage.m_lightning = 0f; + hit.m_damage.m_poison = 0f; + hit.m_damage.m_spirit = 0f; + } } } }