diff --git a/Chris.MultiNPC.lsl b/Chris.MultiNPC.lsl index 4804e89..26f9595 100644 --- a/Chris.MultiNPC.lsl +++ b/Chris.MultiNPC.lsl @@ -173,6 +173,32 @@ integer script_walk(integer slot, key npc, list command) return TRUE; } +integer script_fly(integer slot, key npc, list command) +{ + vector targetPosition = <0, 0, 0>; + + if(llList2Vector(command, 1) == <0, 0, 0>) + { + list objects = osGetSearchableObjectList(llList2String(command, 1)); + if(llGetListLength(objects) == 0) + { + llSay(0, "Cant find the walk target '" + llList2String(command, 1) + "'."); + return FALSE; + } + + list targetDataList = llGetObjectDetails(llList2Key(objects, 0), [OBJECT_POS]); + targetPosition = llList2Vector(targetDataList, 0); + }else{ + targetPosition = llList2Vector(command, 1); + } + + osNpcMoveToTarget(npc, targetPosition, OS_NPC_FLY); + + m_npcdata = setDataEntryInDataList(m_npcdata, "npc." + slot + ".state", "walk"); + m_npcdata = setDataEntryInDataList(m_npcdata, "npc." + slot + ".targetPosition", targetPosition); + return TRUE; +} + integer script_touch(integer slot, key npc, list command) { list objects = osGetSearchableObjectList(llList2String(command, 1)); @@ -354,6 +380,10 @@ doNextScriptStep() if(!script_walk(currentNPCSlot, currentNPCKey, lineCommandData)) llSay(0, "Script execution in '" + llList2String(lineCommandData, 0) + "' in nc '"+ currentncname +"' on line '" + currentLine + "' failed."); break; + case "fly": + if(!script_fly(currentNPCSlot, currentNPCKey, lineCommandData)) + llSay(0, "Script execution in '" + llList2String(lineCommandData, 0) + "' in nc '"+ currentncname +"' on line '" + currentLine + "' failed."); + break; case "include": if(!script_include(currentNPCSlot, currentNPCKey, lineCommandData)) llSay(0, "Script execution in '" + llList2String(lineCommandData, 0) + "' in nc '"+ currentncname +"' on line '" + currentLine + "' failed.");