Skip to content

Commit

Permalink
Merge pull request #34 from jpw1991/31-null-object-on-intercepting-mi…
Browse files Browse the repository at this point in the history
…nion-structure-damage

add some extra null checking to prevent occasional null object error
  • Loading branch information
jpw1991 authored Jan 10, 2023
2 parents 9333e70 + e4aa3fe commit 38d542e
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 @@ -424,21 +424,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 38d542e

Please sign in to comment.