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; }