Sequence.lsl 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. // :SHOW:1
  2. // :CATEGORY:Gaming
  3. // :NAME:Hypergrid Story Three
  4. // :AUTHOR:Ferd Frederix
  5. // :KEYWORDS:Game, Collider
  6. // :CREATED:2015-11-24 20:36:34
  7. // :EDITED:2015-11-24 19:36:34
  8. // :ID:1090
  9. // :NUM:1857
  10. // :REV:2.0
  11. // :WORLD:Opensim
  12. // :DESCRIPTION:
  13. // Sample sequencer script for NPC animator. It sequeunces multiple NPCs in order thru a scenarios
  14. // each 'things' entry is the NPC number, a (float) time to take between sending commands ( 0 is not allowed, but a small number is()
  15. ///and a @command that is sent to the NPC.
  16. // :CODE:
  17. // Notes: Link messages arte as follows
  18. // 1 = Racoon
  19. // 2 = Namaka
  20. // 3 = Dylan
  21. // Rev: 2 fixes the Linux bug for collisions.
  22. integer busy = FALSE;
  23. integer debug = FALSE;
  24. integer SENSE = TRUE;
  25. float RATE = 5;
  26. integer COLLIDE = TRUE;
  27. float RANGE = 2;
  28. list things ;
  29. RezIn()
  30. {
  31. things = [1,5,"@stop"];
  32. things += [2,5,"@stop"];
  33. things += [3,10,"@stop"];
  34. Speak();
  35. }
  36. DoIt()
  37. {
  38. things = [-1,1,"@pause=1"];
  39. things += [1,1,"@animate=avatar_jumpforjoy|1"];
  40. things += [1,1,"@say=Hello! What happened to you two?"];
  41. things += [1,1,"@run=<123.70119, 124.20567, 37.52779>"];
  42. things += [1,1,"@walk=<124.75295, 125.30030, 37.52779>"];
  43. // rezpoint
  44. things += [2,1,"@walk=<125.02877, 121.68277, 37.39204>"];
  45. things += [2,1,"@animate=SwayInBreeze|2"];
  46. things += [2,2,"@animate=avatar_type|2"];
  47. things += [2,2,"@say=We are cyber beings that were transformed into these appearances."];
  48. things += [3,1,"@walk=<122.39304, 121.43833, 37.50384>"];
  49. things += [3,1,"@animate=SwayInBreeze|2"];
  50. things += [3,2,"@animate=avatar_type|3"];
  51. things += [3,1,"@say=Fire and wood do not mix. I cannot be with you, my love, while in this form."];
  52. things += [2,2,"@animate=avatar_type|2"];
  53. things += [2,2,"@say=We must seek help to transform ourselves. I cannot live without you"];
  54. things += [2,2,"@pause=2"];
  55. things += [2,3,"@animate=avatar_type|3"];
  56. things += [2,1,"@say=Now we are on a journey to find our home, and find ourselves again"];
  57. things += [2,2,"@pause=2"];
  58. things += [1,3,"@animate=avatar_type|3"];
  59. things += [1,1,"@say=I see your friends have been changed by magic."];
  60. things += [1,2,"@pause=2"];
  61. things += [1,3,"@animate=avatar_type|3"];
  62. things += [1,1,"@stand"];
  63. things += [1,2,"@say=I can show a place that has potions to cure that."];
  64. things += [1,2,"@animate=avatar_type|2"];
  65. things += [1,2,"@say=But you need be careful here, the swamp is a dangerous place "];
  66. things += [1,1,"@stand"];
  67. things += [1,2,"@animate=avatar_type|2"];
  68. things += [1,1,"@say=I can show you the way. Follow me"];
  69. things += [1,1,"@walk=<119.90541, 124.44883, 37.51564>"];
  70. things += [1,1,"@walk=<121.84517, 124.44883, 37.51564>"];
  71. things += [3,1,"@animate=avatar_type|3"];
  72. things += [3,1,"@whisper=I do not trust this racoon. He has a mask and could mislead us. "];
  73. things += [2,1,"@animate=avatar_type|3"];
  74. things += [2,1,"@say=We must stay here, my love, where we do not burn the woods down."];
  75. things += [2,1,"@animate=avatar_type|2"];
  76. things += [2,1,"@say=Be careful, friend!"];
  77. things += [3,1,"@animate=avatar_type|3"];
  78. things += [3,1,"@say=Thank you for helping us"];
  79. things += [1,1,"@shout=Follow me!"];
  80. Speak();
  81. }
  82. Speak() {
  83. integer prim = llList2Integer(things,0);
  84. float time = llList2Float(things,1);
  85. string msg = llList2String(things,2);
  86. if (debug) llOwnerSay("Prim:" + (string) prim + " time:" + (string) time + " Msg:" + msg);
  87. if (prim) {
  88. things = llDeleteSubList(things,0,2);
  89. llMessageLinked(prim,0, msg,"");
  90. if (time > 0) {
  91. llSetTimerEvent(time);
  92. } else {
  93. llOwnerSay("Whooops, time = 0!");
  94. if (debug) llOwnerSay("Prim:" + (string) prim + " time:" + (string) time + " Msg:" + msg);
  95. llSetTimerEvent(0);
  96. Reset();
  97. busy = FALSE;
  98. }
  99. } else {
  100. if (debug) llOwnerSay("Done");
  101. busy = FALSE;
  102. Reset();
  103. llSetTimerEvent(0);
  104. if (SENSE)
  105. llSensorRepeat("","",AGENT,RANGE,PI,RATE);
  106. }
  107. }
  108. Reset()
  109. {
  110. llSetStatus(STATUS_PHANTOM, FALSE);
  111. llVolumeDetect(FALSE);
  112. llSleep(0.1);
  113. llVolumeDetect(TRUE);
  114. }
  115. default
  116. {
  117. state_entry()
  118. {
  119. llSetText("",<1,1,1>,1.0);
  120. Reset();
  121. llSetTimerEvent(0);
  122. if (SENSE)
  123. llSensorRepeat("","",AGENT,RANGE,PI,RATE);
  124. }
  125. sensor(integer n) {
  126. if (debug) llOwnerSay("Bumped");
  127. if (! osIsNpc(llDetectedKey(0))) {
  128. if (debug) llOwnerSay("Sensed avatar");
  129. llSensorRemove();
  130. RezIn();
  131. }
  132. }
  133. timer()
  134. {
  135. Speak();
  136. }
  137. collision_start(integer n) {
  138. if (debug) llOwnerSay("Collided with " + llKey2Name(llDetectedKey(0)));
  139. if (busy)
  140. return;
  141. if (! osIsNpc(llDetectedKey(0)))
  142. {
  143. DoIt();
  144. }
  145. }
  146. on_rez(integer p)
  147. {
  148. llResetScript();
  149. }
  150. changed(integer what)
  151. {
  152. if (what & CHANGED_REGION_START)
  153. {
  154. llResetScript();
  155. }
  156. }
  157. }