Advertisement
salahzar

Jane Doe (NPC)

Dec 21st, 2014
462
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. key npc;
  2. integer listenChannel = 10;
  3.  
  4. default
  5. {
  6.     // NPC manipulator adapted by justincc 0.0.3 released 20121025
  7.     state_entry()
  8.     {
  9.         llListen(listenChannel,"",NULL_KEY,"");
  10.         llSetText("Listening on " + listenChannel, <0, 255, 0>, 1);
  11.         llOwnerSay("Say /" + (string)listenChannel + " help for commands");
  12.     }  
  13.  
  14.     listen(integer channel, string name, key id, string msg)
  15.     {
  16.         if (msg != "")
  17.         {
  18.             list commands = llParseString2List(msg, [ " " ], []);
  19.             string msg0 = llList2String(commands, 0);
  20.             string msg1 = llList2String(commands, 1);            
  21.             string msg2 = llList2String(commands, 2);
  22.             string msg3 = llList2String(commands, 3);
  23.  
  24.             if (msg0 == "create")
  25.             {
  26.                 if (msg1 != "")
  27.                 {
  28.                     string notecardName = msg1;
  29.  
  30.                     npc = osNpcCreate("Jane", "Doe", llGetPos() + <5, 5, 0>, notecardName);
  31.  
  32.                     llOwnerSay("Created npc from notecard " + notecardName);
  33.                 }
  34.                 else
  35.                 {
  36.                     llOwnerSay("Usage: create <notecard-name>");
  37.                 }
  38.             }  
  39.             else if (msg0 =="createm" && msg1 != "")
  40.             {
  41.                 osOwnerSaveAppearance("appearance");
  42.                 vector pos = llGetPos();
  43.                 integer i;
  44.                 for (i = 0; i < (integer)msg1; i++)
  45.                 {
  46.                     osNpcCreate("John", "Doe", pos + <8, 0, 0>, "appearance");
  47.                     llSleep(1);
  48.                 }
  49.             }
  50.             else if (msg0 == "remove" && npc != NULL_KEY)
  51.             {
  52.                 osNpcSay(npc, "You will pay for this with your liiiiiivvveeessss!!!.....");
  53.                 osNpcRemove(npc);
  54.             }  
  55.             else if (msg0 == "say" && npc != NULL_KEY)
  56.             {
  57.                 osNpcSay(npc, "I am your worst Nightmare!!!!");
  58.             }  
  59.             else if (msg0 == "move")
  60.             {
  61.                 if (msg1 != "" && msg2 != "" && npc != NULL_KEY)
  62.                 {                
  63.                     vector delta = <(integer)msg1, (integer)msg2, 0>;
  64.  
  65.                     if (msg3 != "")
  66.                     {
  67.                         delta.z = (integer)msg3;
  68.                     }
  69.  
  70.                     osNpcMoveTo(npc, osNpcGetPos(npc) + delta);                    
  71.                 }                            
  72.                 else
  73.                 {
  74.                     llOwnerSay("Usage: move <x> <y> [<z>]");
  75.                 }
  76.             }  
  77.             else if (msg0 == "moveto")
  78.             {
  79.                 if (msg1 != "" && msg2 != "" && npc != NULL_KEY)
  80.                 {                
  81.                     vector pos = <(integer)msg1, (integer)msg2, 0>;
  82.  
  83.                     if (msg3 != "")
  84.                     {
  85.                         pos.z = (integer)msg3;
  86.                     }
  87.  
  88.                     osNpcMoveTo(npc, pos);                    
  89.                 }                            
  90.                 else
  91.                 {
  92.                     llOwnerSay("Usage: move <x> <y> [<z>]");
  93.                 }
  94.             }            
  95.             else if (msg0 == "movetarget" && npc != NULL_KEY)
  96.             {
  97.                 osNpcMoveToTarget(npc, llGetPos() + <9,9,5>, OS_NPC_FLY|OS_NPC_LAND_AT_TARGET);
  98.             }
  99.             else if (msg0 == "movetargetnoland" && npc != NULL_KEY)
  100.             {
  101.                 osNpcMoveToTarget(npc, llGetPos() + <9,9,5>, OS_NPC_FLY);
  102.             }            
  103.             else if (msg0 == "movetargetwalk" && npc != NULL_KEY)
  104.             {
  105.                 osNpcMoveToTarget(npc, llGetPos() + <9,9,0>, OS_NPC_NO_FLY);                
  106.             }
  107.             else if (msg0 == "rot" && npc != NULL_KEY)
  108.             {
  109.                 vector xyz_angles = <0,0,90>; // This is to define a 1 degree change
  110.                 vector angles_in_radians = xyz_angles * DEG_TO_RAD; // Change to Radians
  111.                 rotation rot_xyzq = llEuler2Rot(angles_in_radians); // Change to a Rotation                
  112.                 rotation rot = osNpcGetRot(npc);
  113.                 osNpcSetRot(npc, rot * rot_xyzq);
  114.             }
  115.             else if (msg0 == "rotabs" && msg1 != "")
  116.             {
  117.                 vector xyz_angles = <0, 0, (integer)msg1>;
  118.                 vector angles_in_radians = xyz_angles * DEG_TO_RAD; // Change to Radians
  119.                 rotation rot_xyzq = llEuler2Rot(angles_in_radians); // Change to a Rotation                
  120.                 osNpcSetRot(npc, rot_xyzq);                
  121.             }
  122.             else if (msg0 == "animate" && npc != NULL_KEY)
  123.             {
  124.                 osAvatarPlayAnimation(npc, "stabbed+die_2");
  125.                 llSleep(3);
  126.                 osAvatarStopAnimation(npc, "stabbed+die_2");
  127.             }  
  128.             else if (msg0 == "save" && msg1 != "" && npc != NULL_KEY)
  129.             {
  130.                 osNpcSaveAppearance(npc, msg1);
  131.                 llOwnerSay("Saved appearance " + msg1 + " to " + npc);                
  132.             }
  133.             else if (msg0 == "load" && msg1 != "" && npc != NULL_KEY)
  134.             {
  135.                 osNpcLoadAppearance(npc, msg1);
  136.                 llOwnerSay("Loaded appearance " + msg1 + " to " + npc);
  137.             }
  138.             else if (msg0 == "clone")
  139.             {
  140.                 if (msg1 != "")
  141.                 {
  142.                     osOwnerSaveAppearance(msg1);
  143.                     llOwnerSay("Cloned your appearance to " + msg1);
  144.                 }
  145.                 else
  146.                 {
  147.                     llOwnerSay("Usage: clone <notecard-name-to-save>");
  148.                 }
  149.             }
  150.             else if (msg0 == "stop" && npc != NULL_KEY)
  151.             {
  152.                 osNpcStopMoveToTarget(npc);
  153.             }
  154.             else if (msg0 == "sit" && msg1 != "" && npc != NULL_KEY)
  155.             {
  156.                 osNpcSit(npc, msg1, OS_NPC_SIT_NOW);
  157.             }
  158.             else if (msg0 == "stand" && npc != NULL_KEY)
  159.             {
  160.                 osNpcStand(npc);
  161.             }
  162.             else if (msg0 == "help")
  163.             {
  164.                 llOwnerSay("Commands are:");
  165.                 llOwnerSay("create <notecard-name> - Create NPC from a stored notecard");
  166.                 llOwnerSay("createm");      
  167.                 llOwnerSay("remove - Remove current NPC");    
  168.                 llOwnerSay("clone <notecard-name> - Clone own appearance to a notecard");
  169.                 llOwnerSay("load <notecard-name>  - Load appearance on notecard to current npc");
  170.                 llOwnerSay("save <notecard-name>  - Save appearance of current NPC to notecard");
  171.                 llOwnerSay("animate");
  172.                 llOwnerSay("move");
  173.                 llOwnerSay("moveto <x> <y> <z> - move to absolute position");
  174.                 llOwnerSay("movetarget");
  175.                 llOwnerSay("movetargetnoland");
  176.                 llOwnerSay("movetargetwalk");
  177.                 llOwnerSay("rot");
  178.                 llOwnerSay("say");
  179.                 llOwnerSay("sit <target-uuid>");
  180.                 llOwnerSay("stop");
  181.                 llOwnerSay("stand");
  182.             }
  183.             else
  184.             {
  185.                 llOwnerSay("I don't understand [" + msg + "]");
  186.             }
  187.         }  
  188.     }  
  189. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement