„Chris.MultiNPC.lsl“ ändern
This commit is contained in:
parent
e27c3d233d
commit
7bc987dece
|
@ -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;
|
||||
|
@ -101,12 +101,19 @@ integer getGoToLine(integer slot, string target)
|
|||
string line = llList2String(pathLineData, currentLine);
|
||||
|
||||
if(line == target)
|
||||
return currentLine;
|
||||
return currentLine + 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
list replaceVars(integer slot, list commands)
|
||||
{
|
||||
|
||||
|
||||
return commands;
|
||||
}
|
||||
|
||||
//Script Engine
|
||||
doNextScriptStep()
|
||||
{
|
||||
|
@ -122,14 +129,18 @@ doNextScriptStep()
|
|||
string currentPath = getDataEntryFromDataList(m_npcdata, "npc." + currentNPCSlot + ".path");
|
||||
string currentState = getDataEntryFromDataList(m_npcdata, "npc." + currentNPCSlot + ".state");
|
||||
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, [";"], []);
|
||||
string currentCommand = llList2String(pathLineData, currentLine);
|
||||
list lineCommandData = llParseString2List(currentCommand, ["=", "|"], []);
|
||||
list lineCommands = llParseString2List(currentCommand, [" "], []);
|
||||
|
||||
list currentNPCDataList = llGetObjectDetails(currentNPCKey, [OBJECT_POS]);
|
||||
|
||||
vector currentNPCPosition = llList2Vector(currentNPCDataList, 0);
|
||||
//llOwnerSay(llKey2Name(currentNPCKey) + ": Current " + currentNPCPosition + "; Last " + lastPosition + "; " + llVecDist(currentNPCPosition, lastPosition));
|
||||
|
||||
if(currentState == "wait")
|
||||
{
|
||||
|
@ -147,6 +158,20 @@ doNextScriptStep()
|
|||
|
||||
if(llGetListLength(currentNPCDataList) == 0)
|
||||
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)
|
||||
continue;
|
||||
|
@ -161,13 +186,12 @@ doNextScriptStep()
|
|||
}
|
||||
|
||||
m_npcdata = setDataEntryInDataList(m_npcdata, "npc." + currentNPCSlot + ".line", currentLine);
|
||||
|
||||
|
||||
if(llGetSubString(llList2String(lineCommandData, 0), 0, 0) == ":")
|
||||
{
|
||||
currentNPCSlot--;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if(llGetSubString(llList2String(lineCommandData, 0), 0, 0) == "%")
|
||||
{
|
||||
|
@ -177,72 +201,73 @@ doNextScriptStep()
|
|||
m_npcdata = setDataEntryInDataList(m_npcdata, "npc." + currentNPCSlot + ".data." + storageKey, data);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
switch(llList2String(lineCommandData, 0))
|
||||
{
|
||||
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.");
|
||||
break;
|
||||
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.");
|
||||
break;
|
||||
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.");
|
||||
break;
|
||||
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.");
|
||||
break;
|
||||
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.");
|
||||
break;
|
||||
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.");
|
||||
break;
|
||||
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.");
|
||||
break;
|
||||
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.");
|
||||
break;
|
||||
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.");
|
||||
break;
|
||||
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.");
|
||||
currentNPCSlot--;
|
||||
break;
|
||||
case "goto":
|
||||
if(script_goto(currentNPCSlot, currentNPCKey, lineCommandData))
|
||||
if(script_goto(currentNPCSlot, currentNPCKey, replaceVars(currentNPCSlot, lineCommandData)))
|
||||
currentNPCSlot--;
|
||||
break;
|
||||
case "appearance":
|
||||
if(script_appearance(currentNPCSlot, currentNPCKey, lineCommandData))
|
||||
if(script_appearance(currentNPCSlot, currentNPCKey, replaceVars(currentNPCSlot, lineCommandData)))
|
||||
currentNPCSlot--;
|
||||
break;
|
||||
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.");
|
||||
break;
|
||||
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.");
|
||||
break;
|
||||
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.");
|
||||
break;
|
||||
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.");
|
||||
break;
|
||||
default:
|
||||
|
|
Loading…
Reference in New Issue