„Chris.MultiNPC.lsl“ ändern
This commit is contained in:
parent
7bc987dece
commit
b1ebd37bf9
|
@ -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;
|
||||||
|
@ -151,6 +151,34 @@ doNextScriptStep()
|
||||||
|
|
||||||
m_npcdata = setDataEntryInDataList(m_npcdata, "npc." + currentNPCSlot + ".state", "");
|
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")
|
if(currentState == "walk")
|
||||||
{
|
{
|
||||||
|
@ -168,7 +196,7 @@ doNextScriptStep()
|
||||||
hardReset("npc stuck");
|
hardReset("npc stuck");
|
||||||
}else{
|
}else{
|
||||||
currentStuck = 0;
|
currentStuck = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_npcdata = setDataEntryInDataList(m_npcdata, "npc." + currentNPCSlot + ".lastPos", currentNPCPosition);
|
m_npcdata = setDataEntryInDataList(m_npcdata, "npc." + currentNPCSlot + ".lastPos", currentNPCPosition);
|
||||||
m_npcdata = setDataEntryInDataList(m_npcdata, "npc." + currentNPCSlot + ".stuckCounter", currentStuck);
|
m_npcdata = setDataEntryInDataList(m_npcdata, "npc." + currentNPCSlot + ".stuckCounter", currentStuck);
|
||||||
|
@ -233,9 +261,13 @@ doNextScriptStep()
|
||||||
if(!script_walk(currentNPCSlot, currentNPCKey, replaceVars(currentNPCSlot, 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 "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":
|
case "fly":
|
||||||
if(!script_fly(currentNPCSlot, currentNPCKey, replaceVars(currentNPCSlot, 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, replaceVars(currentNPCSlot, lineCommandData)))
|
if(!script_include(currentNPCSlot, currentNPCKey, replaceVars(currentNPCSlot, lineCommandData)))
|
||||||
|
@ -342,6 +374,44 @@ integer script_wait(integer slot, key npc, list command)
|
||||||
return TRUE;
|
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)
|
integer script_walk(integer slot, key npc, list command)
|
||||||
{
|
{
|
||||||
vector targetPosition = <0, 0, 0>;
|
vector targetPosition = <0, 0, 0>;
|
||||||
|
|
Loading…
Reference in New Issue