From 9efea72bfb5f583c41f621e0d3a1d24f47cd26b2 Mon Sep 17 00:00:00 2001 From: osuphobia <78858975+osuphobia@users.noreply.github.com> Date: Mon, 19 Aug 2024 06:32:53 +0800 Subject: [PATCH] fix wont_hit_friend (#75760) --- src/npcmove.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/npcmove.cpp b/src/npcmove.cpp index a1ac030171e7f..6bcbd7f43021e 100644 --- a/src/npcmove.cpp +++ b/src/npcmove.cpp @@ -2712,6 +2712,10 @@ int npc::confident_throw_range( const item &thrown, Creature *target ) const // Index defaults to -1, i.e., wielded weapon bool npc::wont_hit_friend( const tripoint &tar, const item &it, bool throwing ) const { + if( !throwing && it.is_gun() && it.empty() ) { + return true; // Prevent calling nullptr ammo_data + } + if( throwing && rl_dist( pos(), tar ) == 1 ) { return true; // If we're *really* sure that our aim is dead-on }