„Chris.MultiNPC.lsl“ ändern

This commit is contained in:
Christopher 2021-08-01 00:04:04 +00:00
parent e27c3d233d
commit 7bc987dece
1 changed files with 45 additions and 20 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 + ".path", nc);
m_npcdata = setDataEntryInDataList(m_npcdata, "npc." + npcslot + ".ncname", ncName); m_npcdata = setDataEntryInDataList(m_npcdata, "npc." + npcslot + ".ncname", ncName);
} }
integer getNextFreeNPCSlot() integer getNextFreeNPCSlot()
{ {
integer currentNPCSlot = 0; integer currentNPCSlot = 0;
@ -101,12 +101,19 @@ integer getGoToLine(integer slot, string target)
string line = llList2String(pathLineData, currentLine); string line = llList2String(pathLineData, currentLine);
if(line == target) if(line == target)
return currentLine; return currentLine + 1;
} }
return 0; return 0;
} }
list replaceVars(integer slot, list commands)
{
return commands;
}
//Script Engine //Script Engine
doNextScriptStep() doNextScriptStep()
{ {
@ -122,14 +129,18 @@ doNextScriptStep()
string currentPath = getDataEntryFromDataList(m_npcdata, "npc." + currentNPCSlot + ".path"); string currentPath = getDataEntryFromDataList(m_npcdata, "npc." + currentNPCSlot + ".path");
string currentState = getDataEntryFromDataList(m_npcdata, "npc." + currentNPCSlot + ".state"); string currentState = getDataEntryFromDataList(m_npcdata, "npc." + currentNPCSlot + ".state");
string currentncname = getDataEntryFromDataList(m_npcdata, "npc." + currentNPCSlot + ".ncname"); string currentncname = getDataEntryFromDataList(m_npcdata, "npc." + currentNPCSlot + ".ncname");
vector lastPosition = (vector)getDataEntryFromDataList(m_npcdata, "npc." + currentNPCSlot + ".lastPos");
integer currentStuck = (integer)getDataEntryFromDataList(m_npcdata, "npc." + currentNPCSlot + ".stuckCounter");
list pathLineData = llParseString2List(currentPath, [";"], []); list pathLineData = llParseString2List(currentPath, [";"], []);
string currentCommand = llList2String(pathLineData, currentLine); string currentCommand = llList2String(pathLineData, currentLine);
list lineCommandData = llParseString2List(currentCommand, ["=", "|"], []); list lineCommandData = llParseString2List(currentCommand, ["=", "|"], []);
list lineCommands = llParseString2List(currentCommand, [" "], []);
list currentNPCDataList = llGetObjectDetails(currentNPCKey, [OBJECT_POS]); list currentNPCDataList = llGetObjectDetails(currentNPCKey, [OBJECT_POS]);
vector currentNPCPosition = llList2Vector(currentNPCDataList, 0); vector currentNPCPosition = llList2Vector(currentNPCDataList, 0);
//llOwnerSay(llKey2Name(currentNPCKey) + ": Current " + currentNPCPosition + "; Last " + lastPosition + "; " + llVecDist(currentNPCPosition, lastPosition));
if(currentState == "wait") if(currentState == "wait")
{ {
@ -147,6 +158,20 @@ doNextScriptStep()
if(llGetListLength(currentNPCDataList) == 0) if(llGetListLength(currentNPCDataList) == 0)
hardReset("NPC not found"); hardReset("NPC not found");
if(llVecDist(currentNPCPosition, lastPosition) <= 0.1)
{
currentStuck++;
if(currentStuck >= 5)
hardReset("npc stuck");
}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) if(llVecDist(currentNPCPosition, targetPosition) >= 1)
continue; continue;
@ -161,13 +186,12 @@ doNextScriptStep()
} }
m_npcdata = setDataEntryInDataList(m_npcdata, "npc." + currentNPCSlot + ".line", currentLine); m_npcdata = setDataEntryInDataList(m_npcdata, "npc." + currentNPCSlot + ".line", currentLine);
if(llGetSubString(llList2String(lineCommandData, 0), 0, 0) == ":") if(llGetSubString(llList2String(lineCommandData, 0), 0, 0) == ":")
{ {
currentNPCSlot--; currentNPCSlot--;
continue; continue;
} }
if(llGetSubString(llList2String(lineCommandData, 0), 0, 0) == "%") if(llGetSubString(llList2String(lineCommandData, 0), 0, 0) == "%")
{ {
@ -177,72 +201,73 @@ doNextScriptStep()
m_npcdata = setDataEntryInDataList(m_npcdata, "npc." + currentNPCSlot + ".data." + storageKey, data); m_npcdata = setDataEntryInDataList(m_npcdata, "npc." + currentNPCSlot + ".data." + storageKey, data);
continue; continue;
} }
switch(llList2String(lineCommandData, 0)) switch(llList2String(lineCommandData, 0))
{ {
case "create": case "create":
if(!script_create(currentNPCSlot, currentNPCKey, lineCommandData)) if(!script_create(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; break;
case "remove": case "remove":
if(!script_remove(currentNPCSlot, currentNPCKey, lineCommandData)) if(!script_remove(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; break;
case "say": case "say":
if(!script_say(currentNPCSlot, currentNPCKey, lineCommandData)) if(!script_say(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; break;
case "sit": case "sit":
if(!script_sit(currentNPCSlot, currentNPCKey, lineCommandData)) if(!script_sit(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; break;
case "wait": case "wait":
if(!script_wait(currentNPCSlot, currentNPCKey, lineCommandData)) if(!script_wait(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; break;
case "stand": case "stand":
if(!script_stand(currentNPCSlot, currentNPCKey, lineCommandData)) if(!script_stand(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; break;
case "walk": case "walk":
if(!script_walk(currentNPCSlot, currentNPCKey, lineCommandData)) if(!script_walk(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; break;
case "fly": case "fly":
if(!script_fly(currentNPCSlot, currentNPCKey, lineCommandData)) 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; break;
case "include": case "include":
if(!script_include(currentNPCSlot, currentNPCKey, lineCommandData)) if(!script_include(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; break;
case "touch": case "touch":
if(!script_touch(currentNPCSlot, currentNPCKey, lineCommandData)) if(!script_touch(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.");
currentNPCSlot--; currentNPCSlot--;
break; break;
case "goto": case "goto":
if(script_goto(currentNPCSlot, currentNPCKey, lineCommandData)) if(script_goto(currentNPCSlot, currentNPCKey, replaceVars(currentNPCSlot, lineCommandData)))
currentNPCSlot--; currentNPCSlot--;
break; break;
case "appearance": case "appearance":
if(script_appearance(currentNPCSlot, currentNPCKey, lineCommandData)) if(script_appearance(currentNPCSlot, currentNPCKey, replaceVars(currentNPCSlot, lineCommandData)))
currentNPCSlot--; currentNPCSlot--;
break; break;
case "animation": case "animation":
if(!script_animation(currentNPCSlot, currentNPCKey, lineCommandData)) if(!script_animation(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; break;
case "stopAnimation": case "stopAnimation":
if(!script_StopAnimation(currentNPCSlot, currentNPCKey, lineCommandData)) if(!script_StopAnimation(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; break;
case "profileImage": case "profileImage":
if(!script_profileImage(currentNPCSlot, currentNPCKey, lineCommandData)) if(!script_profileImage(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; break;
case "profileText": case "profileText":
if(!script_profileText(currentNPCSlot, currentNPCKey, lineCommandData)) if(!script_profileText(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; break;
default: default: