zombieEnemy.lslp 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. /*
  2. * sloodle_quiz_router.lsl
  3. * Part of the Sloodle project (www.sloodle.org)
  4. *
  5. * Copyright (c) 2011-06 contributors (see below)
  6. * Released under the GNU GPL v3
  7. * -------------------------------------------
  8. *
  9. * This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation, either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. *
  22. * All scripts must maintain this copyrite information, including the contributer information listed
  23. *
  24. * Contributors:
  25. * Paul Preibisch
  26. *
  27. * DESCRIPTION
  28. * This script will send messages to waiting quizServers. When a player enters the game, this router
  29. * sends a message to all listening quizServers asking if anyone is available.
  30. * The quiz servers will report if they are AVAILABLE or BUSY.
  31. * The router will select an available quizServer and then send that quizServer the id of the player.
  32. *
  33. * Contributors:
  34. * Edmund Edgar
  35. * Paul Preibisch
  36. */
  37. list tmp;
  38. key sound;
  39. integer vulnerable=FALSE;
  40. key enemy;
  41. key player;
  42. key myKey;
  43. integer reward=10;
  44. integer damage;
  45. integer health=100;
  46. string command;
  47. integer QUIZER_CHANNEL=81;
  48. integer ENEMY_CHANNEL=80;
  49. integer SWORD_CHANNEL=55;
  50. list angry_sounds;
  51. list blood_textures;
  52. list body_parts;
  53. list commandList;
  54. integer REMOTE_ACCESS_PIN= 445566; //enables the ability to copy scripts into this object
  55. integer random_integer( integer min, integer max )
  56. {
  57. return min + (integer)( llFrand( max - min + 1 ) );
  58. }
  59. explosion(key id){
  60. if (id==NULL_KEY){
  61. llParticleSystem ([]);
  62. return;
  63. }
  64. llParticleSystem ([
  65. PSYS_SRC_PATTERN,8,
  66. PSYS_PART_FLAGS,(0|PSYS_PART_EMISSIVE_MASK|PSYS_PART_INTERP_COLOR_MASK|PSYS_PART_INTERP_SCALE_MASK|PSYS_PART_TARGET_POS_MASK),
  67. PSYS_PART_START_COLOR, <0.96,0.98,0.98>,
  68. PSYS_PART_END_COLOR, <0.40,0.83,0.89>,
  69. PSYS_PART_START_ALPHA, 0.58,
  70. PSYS_PART_END_ALPHA, 0.20,
  71. PSYS_PART_START_SCALE, <3.86,3.91,0>,
  72. PSYS_PART_END_SCALE, <3.89,3.82,0>,
  73. PSYS_SRC_BURST_SPEED_MIN, 1.11,
  74. PSYS_SRC_BURST_SPEED_MAX, 1.13,
  75. PSYS_SRC_ACCEL, <-8.15,-5.70,-10.00>,
  76. PSYS_SRC_OMEGA, <-8.99,-10.00,-10.00>,
  77. PSYS_SRC_ANGLE_END, 0.75,
  78. PSYS_SRC_ANGLE_BEGIN, 0.03,
  79. PSYS_PART_MAX_AGE, 1.20,
  80. PSYS_SRC_BURST_PART_COUNT, 1,
  81. PSYS_SRC_BURST_RATE, 0.00,
  82. PSYS_SRC_BURST_RADIUS, 1.56,
  83. PSYS_SRC_MAX_AGE, 0.00,
  84. PSYS_SRC_TEXTURE, "9c8eca51-53d5-42a7-bb58-cef070395db8",
  85. PSYS_SRC_TARGET_KEY, id
  86. ]);
  87. }
  88. //explode will cause an unlinked bunch of bones to appear, along with an explosion. Inside the unlinked object is a script that causes an explosion particle effect
  89. //along with an explosion sound, all of the zombie bones will also be set to invisible via a linked message, so that only the brain is left hovering around
  90. //A message will be sent from this enemy to the playerServer asking to disburse a question
  91. //if the question is answered correctly, the zombie brain will die
  92. explode(){
  93. llRezObject("EVZombieBones", llGetPos(),llGetVel(),llGetRot(), 1);
  94. llMessageLinked(LINK_SET, 1, "ENEMY:HIDEBONES","");
  95. }
  96. //playSound will simply play a sound from a random list of sounds based on type
  97. playSound(string soundType){
  98. if (soundType="Zombie Growl") {
  99. angry_sounds=llListRandomize(angry_sounds, 0);
  100. llTriggerSound(llList2String(angry_sounds,0), 1.0);
  101. }
  102. if (soundType="Dieing zombie"){
  103. angry_sounds=llListRandomize(angry_sounds, 0);
  104. llTriggerSound(llList2String(angry_sounds,0), 1.0);
  105. }
  106. }
  107. loadSounds(){
  108. angry_sounds=["SND_SNARL","SND_GROWL","SND_ZOMBIE_SQUEEL","SND_ZOMBIE_CAT"];
  109. }
  110. integer screamCounter;
  111. list screams;
  112. string getScream(){
  113. screams = ["scream1","scream2","scream3","scream4"];
  114. integer screamLen = llGetListLength(screams);
  115. screamCounter++;
  116. if (screamCounter>screamLen-1){
  117. screamCounter=0;
  118. }
  119. return llList2String(screams,screamCounter);
  120. }
  121. string getApproachSound(){
  122. screams = ["SND_SNARL","SND_GROWL","SND_ZOMBIE_SQUEEL","SND_ZOMBIE_CAT"];
  123. integer screamLen = llGetListLength(screams);
  124. screamCounter++;
  125. if (screamCounter>screamLen-1){
  126. screamCounter=0;
  127. }
  128. return llList2String(screams,screamCounter);
  129. }
  130. integer SLOODLE_ROUTER=-1639271139;
  131. integer SLOODLE_PLAYERSERVER=-1639271140;
  132. integer SLOODLE_DEREZ=-1639271141;
  133. default {
  134. on_rez(integer start_param) {
  135. llResetScript();
  136. llSetText((string)health+"%", <255,0,0>, 1.0);
  137. }
  138. state_entry() {
  139. llTriggerSound("SND_ALIVE", 1);
  140. //make sure all zombie parts are displaying their bone textures
  141. llMessageLinked(LINK_SET, 1, "ENEMY:SHOWBONES","");
  142. //allow scripts to be copied into this zombie
  143. llSetRemoteScriptAccessPin(REMOTE_ACCESS_PIN);
  144. //display health
  145. llSetText((string)health+"%", <255,0,0>, 1.0);
  146. loadSounds();
  147. myKey = llGetKey();
  148. llListen(ENEMY_CHANNEL,"","","");
  149. llListen(SWORD_CHANNEL,"","","");
  150. llListen(SLOODLE_ROUTER, "", "", "");
  151. llListen(SLOODLE_PLAYERSERVER, "", "", "");
  152. llListen(SLOODLE_DEREZ, "", "", "");
  153. //llSetText("ready"+(string)llFrand(10), BLUE, 1);
  154. explosion(NULL_KEY);
  155. }
  156. listen(integer channel, string name, key id, string message) {
  157. commandList = llParseString2List(message, ["|"],[]);
  158. //this enemy will listen to players swords as they play the game. Each sword has a sensor in it, and if it detects a zombie
  159. //it sends out a message on the sword channel saying a HIT was made
  160. //All zombies within range of a whisper will here the player's sword whisper this message
  161. // If the message sent from the sword applies to this enemy, this enemy will then start spurting blood and apply damage to itself
  162. command = llList2String(commandList,0);
  163. if (channel==SLOODLE_PLAYERSERVER){
  164. if (command=="EXPLODE"){
  165. state myDeath;
  166. }
  167. }else
  168. if (channel == SLOODLE_DEREZ){
  169. llDie();
  170. }else
  171. if (channel==SWORD_CHANNEL){
  172. tmp= llParseString2List(llList2Key(commandList,1), [":"],[]);
  173. player = llList2Key(tmp,1);
  174. tmp= llParseString2List(llList2Key(commandList,2), [":"],[]);
  175. enemy= llList2Key(tmp,1);
  176. tmp= llParseString2List(llList2Key(commandList,3), [":"],[]);
  177. damage = llList2Integer(tmp,1);
  178. tmp= llParseString2List(llList2Key(commandList,4), [":"],[]);
  179. sound = llList2Key(tmp,1);
  180. //a hit message was received from a players swordHUD
  181. if (command=="SWORDHUD:HIT"){
  182. //play sword sound
  183. llMessageLinked(LINK_SET, 1, "SWORD:PLAY_SWORD_SOUND|"+(string)sound,"");
  184. //find out if this hit message is actually for us
  185. if (enemy==llGetKey()){
  186. //it is, so lets play a zombie grow sound
  187. playSound("Zombie Growl");
  188. //player has hit the zombie so we must minus damage points of the weapon used
  189. health-=damage;
  190. if (health<0) health=0;//make sure we don't go to negative health
  191. //display updated health
  192. llSetText((string)health+"%", <255,0,0>, 1.0);
  193. //if the health of this enemy get's below 0, ask a question and only display the brain
  194. llMessageLinked(LINK_SET,random_integer(0,4),"BLOOD","");
  195. if (health<=0){
  196. llRegionSay(SLOODLE_ROUTER, "ENEMY CLICKED|"+(string)player);
  197. }
  198. }
  199. }
  200. }
  201. }
  202. }
  203. state myDeath{
  204. on_rez(integer start_param) {
  205. llResetScript();
  206. llSetText((string)health+"%", <255,0,0>, 1.0);
  207. }
  208. state_entry() {
  209. llSetScriptState("ZombieMove",FALSE);
  210. explode();
  211. llSetTimerEvent(3);
  212. }
  213. timer() {
  214. llDie();
  215. }
  216. }
  217. // Please leave the following line intact to show where the script lives in Git:
  218. // SLOODLE LSL Script Git Location: mod/interaction-1.0/objects/enemyrezzer/assets/zombieEnemy.lslp