From 8289b22344bb159f19a546554500d4fec6690c22 Mon Sep 17 00:00:00 2001 From: Christopher Date: Sun, 1 Aug 2021 15:04:08 +0000 Subject: [PATCH] =?UTF-8?q?=E2=80=9EChris.MultiNPC.lsl=E2=80=9C=20=C3=A4nd?= =?UTF-8?q?ern?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Chris.MultiNPC.lsl | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Chris.MultiNPC.lsl b/Chris.MultiNPC.lsl index ec346a9..9d2d9e3 100644 --- a/Chris.MultiNPC.lsl +++ b/Chris.MultiNPC.lsl @@ -161,6 +161,19 @@ doNextScriptStep() if(llGetListLength(currentNPCDataList) == 0) hardReset("target '"+targetKey+"' not found"); + if(llVecDist(currentNPCPosition, lastPosition) <= 0.1) + { + currentStuck++; + + if(currentStuck >= 5) + osTeleportAgent(currentNPCKey, targetPosition, <0, 0, 0>); + }else{ + currentStuck = 0; + } + + m_npcdata = setDataEntryInDataList(m_npcdata, "npc." + currentNPCSlot + ".lastPos", currentNPCPosition); + m_npcdata = setDataEntryInDataList(m_npcdata, "npc." + currentNPCSlot + ".stuckCounter", currentStuck); + if(llVecDist(currentNPCPosition, targetPosition) <= 1) { list newPathList = llDeleteSubList(llCSV2List(getDataEntryFromDataList(m_npcdata, "npc." + currentNPCSlot + ".walkPath")), 0, 0); @@ -193,7 +206,7 @@ doNextScriptStep() currentStuck++; if(currentStuck >= 5) - hardReset("npc stuck"); + osTeleportAgent(currentNPCKey, targetPosition, <0, 0, 0>); }else{ currentStuck = 0; }