fix some small bugs

This commit is contained in:
Christopher 2021-08-07 16:35:21 +02:00
parent 2170ce351b
commit 6080ad3890
1 changed files with 98 additions and 21 deletions

View File

@ -2,8 +2,8 @@
yoptions;
//===================
//Version: 0.1.7
//Datum: 01.08.2021
//Version: 0.1.7.1
//Datum: 07.08.2021
//UpdateRAW: https://clatza.dev/Christopher/OpenSim.Script.Chris.MultiNPC/raw/branch/master/Chris.MultiNPC.lsl
//Made by: Chris Resident @ inc.li:8002
//Dependencies:
@ -165,7 +165,10 @@ doNextScriptStep()
currentStuck++;
if(currentStuck >= 5)
{
osTeleportAgent(currentNPCKey, targetPosition, <0, 0, 0>);
currentStuck = 0;
}
}else{
currentStuck = 0;
}
@ -182,7 +185,7 @@ doNextScriptStep()
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));
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);
@ -241,7 +244,6 @@ doNextScriptStep()
m_npcdata = setDataEntryInDataList(m_npcdata, "npc." + currentNPCSlot + ".data." + storageKey, data);
continue;
}
switch(llList2String(lineCommandData, 0))
{
@ -314,6 +316,14 @@ doNextScriptStep()
if(!script_profileText(currentNPCSlot, currentNPCKey, replaceVars(currentNPCSlot, lineCommandData)))
llSay(0, "Script execution in '" + llList2String(lineCommandData, 0) + "' in nc '"+ currentncname +"' on line '" + currentLine + "' failed.");
break;
case "give":
if(!script_give(currentNPCSlot, currentNPCKey, replaceVars(currentNPCSlot, lineCommandData)))
llSay(0, "Script execution in '" + llList2String(lineCommandData, 0) + "' in nc '"+ currentncname +"' on line '" + currentLine + "' failed.");
break;
case "rez":
if(!script_rez(currentNPCSlot, currentNPCKey, replaceVars(currentNPCSlot, lineCommandData)))
llSay(0, "Script execution in '" + llList2String(lineCommandData, 0) + "' in nc '"+ currentncname +"' on line '" + currentLine + "' failed.");
break;
default:
llSay(0, "Unknown command '" + llList2String(lineCommandData, 0) + "' in nc '"+ currentncname +"' on line '" + currentLine + "' failed.");
}
@ -339,7 +349,7 @@ integer script_create(integer slot, key npc, list command)
return FALSE;
}
npc = osNpcCreate(llList2String(command, 1), llList2String(command, 2), llList2Vector(llGetObjectDetails(llList2Key(objects, 0), [OBJECT_POS]), 0), llList2String(command, 3) + ".appearance");
npc = osNpcCreate(llList2String(command, 1), llList2String(command, 2), llList2Vector(llGetObjectDetails(llList2Key(objects, 0), [OBJECT_POS]), 0), llList2String(command, 3) + ".appearance", OS_NPC_CREATOR_OWNED);
m_npcdata = setDataEntryInDataList(m_npcdata, "npc." + slot, npc);
createNPCTempStorage();
return TRUE;
@ -360,6 +370,52 @@ integer script_say(integer slot, key npc, list command)
return TRUE;
}
integer script_rez(integer slot, key npc, list command)
{
vector targetPosition = <0, 0, 0>;
vector currentPosition = llGetPos();
if(llList2Vector(command, 1) == <0, 0, 0>)
{
list objects = osGetSearchableObjectPartList(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);
}
if(llGetInventoryType(llList2String(command, 1)) != INVENTORY_OBJECT)
{
llSay(0, "Cant find object '" + llList2String(command, 1) + "' to rez.");
return FALSE;
}
llSetRegionPos(targetPosition);
llRezAtRoot(llList2String(command, 1), targetPosition, llGetVel(), llGetRot(), 0);
llSetRegionPos(currentPosition);
return TRUE;
}
integer script_give(integer slot, key npc, list command)
{
if(llGetInventoryType(llList2String(command, 1)) != INVENTORY_ALL)
{
llSay(0, "Cant find '" + llList2String(command, 1) + "' to give.");
return FALSE;
}
llGiveInventory(llList2String(command, 0), llList2String(command, 1));
return TRUE;
}
integer script_sit(integer slot, key npc, list command)
{
list objects = osGetSearchableObjectPartList(llList2String(command, 1));
@ -388,33 +444,54 @@ integer script_wait(integer slot, key npc, list command)
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;
}
key startNode = NULL_KEY;
key endNode = NULL_KEY;
list nodes = [];
objects = osGetSearchableObjectPartList(llList2String(command, 2));
if(llGetListLength(objects) == 0)
if(llGetListLength(command) >= 3)
{
llSay(0, "Cant find the path target '" + llList2String(command, 1) + "'.");
return FALSE;
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;
}
startNode = llList2Key(osGetSearchableObjectPartList(llList2String(command, 1)), 0);
endNode = llList2Key(osGetSearchableObjectPartList(llList2String(command, 2)), 0);
}else{
list objects = osGetSearchableObjectPartList(llList2String(command, 1));
if(llGetListLength(objects) == 0)
{
llSay(0, "Cant find the path target '" + llList2String(command, 1) + "'.");
return FALSE;
}
list targetDataList = llGetObjectDetails(npc, [OBJECT_POS]);
vector startPosition = llList2Vector(targetDataList, 0);
startNode = osGetNextNode(startPosition);
endNode = llList2Key(osGetSearchableObjectPartList(llList2String(command, 1)), 0);
}
list nodes = [];
try
{
nodes = osGetNodeListToTarget(llList2Key(osGetSearchableObjectPartList(llList2String(command, 1)), 0), llList2Key(osGetSearchableObjectPartList(llList2String(command, 2)), 0));
nodes = osGetNodeListToTarget(startNode, endNode);
}
catch(scriptexception ex)
{
llSay(0, "Cant find the path to target '" + llList2String(command, 1) + "'.");
llSay(0, "Cant find the path to target '" + llKey2Name(endNode) + "'.");
return FALSE;
}
list targetDataList = llGetObjectDetails(llList2Key(osGetSearchableObjectPartList(llList2String(command, 1)), 0), [OBJECT_POS]);
list targetDataList = llGetObjectDetails(startNode, [OBJECT_POS]);
vector targetPosition = llList2Vector(targetDataList, 0);
osNpcMoveToTarget(npc, targetPosition, OS_NPC_NO_FLY);