„Chris.MultiNPC.lsl“ ändern

This commit is contained in:
Christopher 2021-08-01 14:41:28 +00:00
parent 7bc987dece
commit b1ebd37bf9
1 changed files with 73 additions and 3 deletions

View File

@ -25,7 +25,7 @@ readNPCPathNC(string ncName)
m_npcdata = setDataEntryInDataList(m_npcdata, "npc." + npcslot + ".path", nc);
m_npcdata = setDataEntryInDataList(m_npcdata, "npc." + npcslot + ".ncname", ncName);
}
integer getNextFreeNPCSlot()
{
integer currentNPCSlot = 0;
@ -151,6 +151,34 @@ doNextScriptStep()
m_npcdata = setDataEntryInDataList(m_npcdata, "npc." + currentNPCSlot + ".state", "");
}
if(currentState == "path")
{
//llOwnerSay("raw: " + getDataEntryFromDataList(m_npcdata, "npc." + currentNPCSlot + ".walkPath"));
key targetKey = llList2Key(llCSV2List(getDataEntryFromDataList(m_npcdata, "npc." + currentNPCSlot + ".walkPath")), 0);
vector targetPosition = llList2Vector(llGetObjectDetails(targetKey, [OBJECT_POS]), 0);
if(llGetListLength(currentNPCDataList) == 0)
hardReset("target '"+targetKey+"' not found");
if(llVecDist(currentNPCPosition, targetPosition) <= 1)
{
list newPathList = llDeleteSubList(llCSV2List(getDataEntryFromDataList(m_npcdata, "npc." + currentNPCSlot + ".walkPath")), 0, 0);
if(llGetListLength(newPathList) == 0)
{
m_npcdata = setDataEntryInDataList(m_npcdata, "npc." + currentNPCSlot + ".state", "");
m_npcdata = setDataEntryInDataList(m_npcdata, "npc." + currentNPCSlot + ".walkPath", "");
}else{
m_npcdata = setDataEntryInDataList(m_npcdata, "npc." + currentNPCSlot + ".walkPath", llList2CSV(newPathList));
targetKey = llList2Key(llCSV2List(getDataEntryFromDataList(m_npcdata, "npc." + currentNPCSlot + ".walkPath")), 0);
targetPosition = llList2Vector(llGetObjectDetails(targetKey, [OBJECT_POS]), 0);
osNpcMoveToTarget(currentNPCKey, targetPosition, OS_NPC_NO_FLY);
}
}
continue;
}
if(currentState == "walk")
{
@ -168,7 +196,7 @@ doNextScriptStep()
hardReset("npc stuck");
}else{
currentStuck = 0;
}
}
m_npcdata = setDataEntryInDataList(m_npcdata, "npc." + currentNPCSlot + ".lastPos", currentNPCPosition);
m_npcdata = setDataEntryInDataList(m_npcdata, "npc." + currentNPCSlot + ".stuckCounter", currentStuck);
@ -233,9 +261,13 @@ doNextScriptStep()
if(!script_walk(currentNPCSlot, currentNPCKey, replaceVars(currentNPCSlot, lineCommandData)))
llSay(0, "Script execution in '" + llList2String(lineCommandData, 0) + "' in nc '"+ currentncname +"' on line '" + currentLine + "' failed.");
break;
case "path":
if(!script_path(currentNPCSlot, currentNPCKey, replaceVars(currentNPCSlot, lineCommandData)))
llSay(0, "Script execution in '" + llList2String(lineCommandData, 0) + "' in nc '"+ currentncname +"' on line '" + currentLine + "' failed.");
break;
case "fly":
if(!script_fly(currentNPCSlot, currentNPCKey, replaceVars(currentNPCSlot, lineCommandData)))
llSay(0, "Script execution in '" + llList2String(lineCommandData, 0) + "' in nc '"+ currentncname +"' on line '" + currentLine + "' failed.");
llSay(0, "Script execution in '" + llList2String(lineCommandData, 0) + "' in nc '"+ currentncname +"' on line '" + currentLine + "' failed.");
break;
case "include":
if(!script_include(currentNPCSlot, currentNPCKey, replaceVars(currentNPCSlot, lineCommandData)))
@ -342,6 +374,44 @@ integer script_wait(integer slot, key npc, list command)
return TRUE;
}
integer script_path(integer slot, key npc, list command)
{
list objects = osGetSearchableObjectPartList(llList2String(command, 1));
if(llGetListLength(objects) == 0)
{
llSay(0, "Cant find the path start '" + llList2String(command, 1) + "'.");
return FALSE;
}
objects = osGetSearchableObjectPartList(llList2String(command, 2));
if(llGetListLength(objects) == 0)
{
llSay(0, "Cant find the path target '" + llList2String(command, 1) + "'.");
return FALSE;
}
list nodes = [];
try
{
nodes = osGetNodeListToTarget(llList2Key(osGetSearchableObjectPartList(llList2String(command, 1)), 0), llList2Key(osGetSearchableObjectPartList(llList2String(command, 2)), 0));
}
catch(scriptexception ex)
{
llSay(0, "Cant find the path to target '" + llList2String(command, 1) + "'.");
return FALSE;
}
list targetDataList = llGetObjectDetails(llList2Key(osGetSearchableObjectPartList(llList2String(command, 1)), 0), [OBJECT_POS]);
vector targetPosition = llList2Vector(targetDataList, 0);
osNpcMoveToTarget(npc, targetPosition, OS_NPC_NO_FLY);
m_npcdata = setDataEntryInDataList(m_npcdata, "npc." + slot + ".state", "path");
m_npcdata = setDataEntryInDataList(m_npcdata, "npc." + slot + ".walkPath", llList2CSV(nodes));
return TRUE;
}
integer script_walk(integer slot, key npc, list command)
{
vector targetPosition = <0, 0, 0>;