fix some small bugs
This commit is contained in:
parent
2170ce351b
commit
6080ad3890
|
@ -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;
|
||||
}
|
||||
|
@ -242,7 +245,6 @@ doNextScriptStep()
|
|||
continue;
|
||||
}
|
||||
|
||||
|
||||
switch(llList2String(lineCommandData, 0))
|
||||
{
|
||||
case "create":
|
||||
|
@ -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,6 +444,12 @@ integer script_wait(integer slot, key npc, list command)
|
|||
|
||||
integer script_path(integer slot, key npc, list command)
|
||||
{
|
||||
key startNode = NULL_KEY;
|
||||
key endNode = NULL_KEY;
|
||||
list nodes = [];
|
||||
|
||||
if(llGetListLength(command) >= 3)
|
||||
{
|
||||
list objects = osGetSearchableObjectPartList(llList2String(command, 1));
|
||||
if(llGetListLength(objects) == 0)
|
||||
{
|
||||
|
@ -402,19 +464,34 @@ integer script_path(integer slot, key npc, list command)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
list nodes = [];
|
||||
|
||||
try
|
||||
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)
|
||||
{
|
||||
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) + "'.");
|
||||
llSay(0, "Cant find the path target '" + llList2String(command, 1) + "'.");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
list targetDataList = llGetObjectDetails(llList2Key(osGetSearchableObjectPartList(llList2String(command, 1)), 0), [OBJECT_POS]);
|
||||
list targetDataList = llGetObjectDetails(npc, [OBJECT_POS]);
|
||||
vector startPosition = llList2Vector(targetDataList, 0);
|
||||
|
||||
startNode = osGetNextNode(startPosition);
|
||||
endNode = llList2Key(osGetSearchableObjectPartList(llList2String(command, 1)), 0);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
nodes = osGetNodeListToTarget(startNode, endNode);
|
||||
}
|
||||
catch(scriptexception ex)
|
||||
{
|
||||
llSay(0, "Cant find the path to target '" + llKey2Name(endNode) + "'.");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
list targetDataList = llGetObjectDetails(startNode, [OBJECT_POS]);
|
||||
vector targetPosition = llList2Vector(targetDataList, 0);
|
||||
osNpcMoveToTarget(npc, targetPosition, OS_NPC_NO_FLY);
|
||||
|
||||
|
|
Loading…
Reference in New Issue