From f50893536e28113c026dccc31a04cb8526532e77 Mon Sep 17 00:00:00 2001 From: sleet01 Date: Tue, 19 Sep 2023 19:20:06 -0700 Subject: [PATCH] Fix for #4796: NPE in Princess off-board artillery targeting --- .../bot/princess/ArtilleryTargetingControl.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/megamek/src/megamek/client/bot/princess/ArtilleryTargetingControl.java b/megamek/src/megamek/client/bot/princess/ArtilleryTargetingControl.java index c78d2f23f27..fcf39db98da 100644 --- a/megamek/src/megamek/client/bot/princess/ArtilleryTargetingControl.java +++ b/megamek/src/megamek/client/bot/princess/ArtilleryTargetingControl.java @@ -170,13 +170,14 @@ public void initializeForTargetingPhase() { private boolean getADAAvailable(Entity shooter){ boolean available = false; for (Mounted weapon: shooter.getWeaponList()){ - if(((AmmoType) weapon.getLinked().getType()).getMunitionType().contains(AmmoType.Munitions.M_ADA) - && !weapon.isFired() && weapon.getLinked().getUsableShotsLeft() > 0){ - available = true; - break; + if (weapon.getType().hasFlag(WeaponType.F_ARTILLERY)){ + if(((AmmoType) weapon.getLinked().getType()).getMunitionType().contains(AmmoType.Munitions.M_ADA) + && !weapon.isFired() && weapon.getLinked().getUsableShotsLeft() > 0) { + available = true; + break; + } } } - return available; } /**