Skip to content

Commit

Permalink
add some extra null checking to prevent occasional null object error
Browse files Browse the repository at this point in the history
  • Loading branch information
jpw1991 committed Jan 10, 2023
1 parent b5655b0 commit e4aa3fe
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions FriendlySkeletonWand/BasePlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
}
Expand Down

0 comments on commit e4aa3fe

Please sign in to comment.