From 7ddcaf19da6212207feb06d543d0af43a86d5fde Mon Sep 17 00:00:00 2001 From: Cekis Date: Fri, 3 Feb 2017 17:10:28 +0000 Subject: [PATCH] Prevented null pointer from happening when a vendor attempts to path away from its target. --- .../compiled/game/script/library/ai_lib.java | 35 +++++++++---------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/sku.0/sys.server/compiled/game/script/library/ai_lib.java b/sku.0/sys.server/compiled/game/script/library/ai_lib.java index 27b1a0128..8df932e6b 100755 --- a/sku.0/sys.server/compiled/game/script/library/ai_lib.java +++ b/sku.0/sys.server/compiled/game/script/library/ai_lib.java @@ -916,26 +916,25 @@ public class ai_lib extends script.base_script return; } } - location myLoc = new location(getLocation(npc)); - location targetLoc = new location(getLocation(target)); - if (myLoc.x < targetLoc.x) - { - myLoc.x -= rand(20f, 40f); + location myLoc = getLocation(npc); + location targetLoc = getLocation(target); + if(isValidLocation(myLoc) && isValidLocation(targetLoc)) { + if (myLoc.x < targetLoc.x) { + myLoc.x -= rand(20f, 40f); + } else { + myLoc.x += rand(20f, 40f); + } + if (myLoc.z < targetLoc.z) { + myLoc.z -= rand(20f, 40f); + } else { + myLoc.z += rand(20f, 40f); + } + setObjVar(npc, "ai.pathingAwayFrom", target); + pathTo(npc, myLoc); } - else - { - myLoc.x += rand(20f, 40f); + else{ + LOG("debug_ai","Unable to get a valid location for myLoc (" + myLoc + ") or targetLoc (" + targetLoc + ") to make vendor path away."); } - if (myLoc.z < targetLoc.z) - { - myLoc.z -= rand(20f, 40f); - } - else - { - myLoc.z += rand(20f, 40f); - } - setObjVar(npc, "ai.pathingAwayFrom", target); - pathTo(npc, myLoc); messageTo(npc, "handleClearPathingFlag", null, 30f, isObjectPersisted(npc)); } public static void setLoiterRanges(obj_id npc, float minRange, float maxRange) throws InterruptedException