xs_breeding.lsl 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. // :CATEGORY:XS Pet
  2. // :NAME:XS Pet Quail Modified
  3. // :AUTHOR:Xundra Snowpaw, Ferd Frederix
  4. // :CREATED:2013-09-06
  5. // :EDITED:2013-09-18 15:39:09
  6. // :ID:987
  7. // :NUM:1417
  8. // :REV:1
  9. // :WORLD:Second Life, Opensim
  10. // :DESCRIPTION:
  11. // Modified Pet Quail
  12. // :CODE:
  13. // Version .25 12-15-2011
  14. // revision history
  15. // xs_breeding: LINK_CALL_MALE_INFO was in error on line 159, was LINK_CALL_MALE, should be LINK_CALL_MALE_INFO
  16. // script by Xundra Snowpaw
  17. // mods by Ferd Frederix
  18. //
  19. // New BSD License: http://www.opensource.org/licenses/bsd-license.php
  20. // Copyright (c) 2010, Xundra Snowpaw
  21. // All rights reserved.
  22. //
  23. // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
  24. //* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  25. //* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  26. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. ////////////////////////////////////////////////////////////////////
  28. ///// GLOBAL LINK CONSTANTS extracted from original source //////
  29. ///
  30. // if you change anything, you change it everywhere and in a list in XS_Debug
  31. ///
  32. integer LINK_AGE_START = 800; // when quail is rezzed and secret_number, is sent by brain to breeder, eater and informatic get booted up
  33. integer LINK_FOOD_CONSUME = 900; // from movement to brain when close to food, brain then consumes a random amount up to 10000
  34. integer LINK_FOODMINUS = 901; // xs_brain receives FOOD_CONSUME, decrement hunger (eat)
  35. integer LINK_HUNGRY = 903; // sent by eater (string)hunger_amount, checks each hour
  36. integer LINK_HAMOUNT = 904; // hunger_amount = (integer)str,m updates the hunger amount in scripts
  37. integer LINK_SET_HOME = 910; // loc ^ dist
  38. integer LINK_MOVER = 911; // tell mover to rest for str seconds
  39. integer LINK_FOODIE_CLR = 920; // clear all food_bowl_keys and contents
  40. integer LINK_FOODIE = 921; // send FOOD_LOCATION coordinates to movement
  41. integer LINK_COLOR1 = 930; // colour1
  42. integer LINK_COLOR2 = 931; // colour2
  43. integer LINK_SEX = 932; // sex
  44. integer LINK_SHINE = 933; // shine
  45. integer LINK_GLOW = 934; // glow
  46. integer LINK_GEN = 935; // generation
  47. integer LINK_MAGE = 940; // xs_brain sends, xs_ager consumes, adds str to age, if older than 7 days, will grow the animal
  48. integer LINK_DAYTIME = 941; // xs_ager consumes, starts a timer of 86,400 seconds in xs_ager
  49. integer LINK_GET_AGE = 942; // get age from xs_ager and sent it on channel 943
  50. integer LINK_PUT_AGE = 943; // print age from xs_ager
  51. integer LINK_PACKAGE = 950; // look for a cryo_crate
  52. integer LINK_SEEK_FEMALE = 960; // MALE_BREED_CALL
  53. integer LINK_MALE_BREED_CALL = 961; // triggered by LINK_SEEK_FEMALE
  54. integer LINK_SIGNAL_ELIGIBLE = 962; // sent by female when hears LINK_MALE_BREED_CALL
  55. integer LINK_FEMALE_ELIGIBLE = 963; // sent when it hears in chat FEMALE_ELIGIBLE
  56. integer LINK_CALL_MALE = 964; // if LINK_FEMALE_ELIGIBLE && looking_for_female
  57. integer LINK_MALE_ON_THE_WAY = 965; // triggered by LINK_CALL_MALE
  58. integer LINK_FEMALE_LOCATION = 966; // female location, sends coordinates of a female
  59. integer LINK_RQST_BREED = 967; // sent when close enough to male/female
  60. integer LINK_CALL_MALE_INFO = 968; // ****** BUG ***** read, but never sent by anybody!!!!!
  61. // see line 557 and 636 of xs_brain which make calls and also xs_breeding which receives LUNK_MALE_INFO.
  62. integer LINK_MALE_INFO = 969;
  63. integer LINK_LAY_EGG = 970; // llRezObject("XS Egg"
  64. integer LINK_BREED_FAIL = 971; // key = father, failed, timed out
  65. integer LINK_PREGNANT = 972; // chick is preggers
  66. integer LINK_SLEEPING = 990; // close eyes
  67. integer LINK_UNSLEEPING = 991; // open eyes
  68. integer LINK_SOUND = 1001; // plays a sound if enabled
  69. integer LINK_SPECIAL = 1010; // xs_special, is str = "Normal", removes script
  70. integer LINK_PREGNANCY_TIME = 5000; // in seconds as str
  71. integer LINK_SLEEP = 7999; // disable sleep by parameter
  72. integer LINK_TIMER = 8000; // scan for food bowl about every 1800 seconds
  73. integer LINK_DIE = 9999; // death
  74. ///////// end global Link constants ////////
  75. // END //
  76. integer age;
  77. integer looking_for_female;
  78. key father;
  79. key mother;
  80. integer preg_time;
  81. default
  82. {
  83. link_message(integer sender, integer num, string str, key id)
  84. {
  85. if (num == LINK_AGE_START) {
  86. state running;
  87. }
  88. }
  89. }
  90. state running
  91. {
  92. state_entry()
  93. {
  94. age = 0;
  95. }
  96. link_message(integer sender, integer num, string str, key id)
  97. {
  98. if (num == LINK_SEX) {
  99. if (str == "1") {
  100. state male;
  101. } else {
  102. state female;
  103. }
  104. } else
  105. if (num == LINK_MAGE) {
  106. age += (integer)str;
  107. } else
  108. if (num == LINK_PREGNANCY_TIME) {
  109. preg_time = (integer)str;
  110. if (preg_time != 0) {
  111. state pregnant;
  112. } else {
  113. state female;
  114. }
  115. }
  116. }
  117. }
  118. state male
  119. {
  120. state_entry()
  121. {
  122. looking_for_female = 0;
  123. mother = NULL_KEY;
  124. father = NULL_KEY;
  125. llMessageLinked(LINK_SET, LINK_GET_AGE, "", "");
  126. if (age >= 7) {
  127. llSetTimerEvent(10800.0);
  128. }
  129. }
  130. link_message(integer sender, integer num, string str, key id)
  131. {
  132. if (num == LINK_PUT_AGE) {
  133. age = (integer)str;
  134. if (age >= 7) {
  135. llSetTimerEvent(10800.0);
  136. }
  137. } else
  138. if (num == LINK_MAGE) {
  139. age += (integer)str;
  140. if (age >= 7) {
  141. llSetTimerEvent(10800.0);
  142. }
  143. } else
  144. if (num == LINK_FEMALE_ELIGIBLE) {
  145. if (looking_for_female == 1) {
  146. looking_for_female = 0;
  147. mother = id;
  148. father = llGetKey();
  149. llMessageLinked(LINK_SET, LINK_CALL_MALE, "", mother);
  150. }
  151. } else
  152. if (num == LINK_RQST_BREED) {
  153. if (mother != NULL_KEY) {
  154. llMessageLinked(LINK_SET, LINK_CALL_MALE_INFO, "", mother); // error by Ferd, was LINK_CALL-MALE, should be LINK_CALL_MALE_INFO
  155. }
  156. } else
  157. if (num == LINK_MALE_INFO) {
  158. state male;
  159. }
  160. }
  161. timer()
  162. {
  163. looking_for_female = 1;
  164. // look for an eligible female.
  165. llWhisper(0, llGetObjectName() + " gets a gleam in his eye.");
  166. llMessageLinked(LINK_SET, LINK_SEEK_FEMALE, "", "");
  167. }
  168. }
  169. state female
  170. {
  171. state_entry()
  172. {
  173. mother = NULL_KEY;
  174. father = NULL_KEY;
  175. if (age == 0) {
  176. llMessageLinked(LINK_SET, LINK_GET_AGE, "", "");
  177. }
  178. }
  179. link_message(integer sender, integer num, string str, key id)
  180. {
  181. if (num == LINK_MAGE) {
  182. age += (integer)str;
  183. } else
  184. if (num == LINK_MALE_BREED_CALL) {
  185. // signal I am eligible
  186. if (age >= 7 && father == NULL_KEY) {
  187. llWhisper(0, llGetObjectName() + " blushes then bobs her head up and down.");
  188. llMessageLinked(LINK_SET, LINK_SIGNAL_ELIGIBLE, "", "");
  189. }
  190. } else
  191. if (num == LINK_MALE_ON_THE_WAY) {
  192. // male on the way, rest for 20m
  193. llSetTimerEvent(900.0);
  194. father = id;
  195. mother = llGetKey();
  196. llMessageLinked(LINK_SET, LINK_MOVER, "1200", "");
  197. } else
  198. if (num == LINK_PREGNANT) {
  199. // pregnant
  200. llSetTimerEvent(0);
  201. preg_time = 0;
  202. state pregnant;
  203. } else
  204. if (num == LINK_MALE_INFO) {
  205. llSetTimerEvent(0);
  206. state female;
  207. } else
  208. if (num == LINK_PUT_AGE) {
  209. age = (integer)str;
  210. } else
  211. if (num == LINK_PREGNANCY_TIME) {
  212. preg_time = (integer)str;
  213. if (preg_time != 0) {
  214. state pregnant;
  215. }
  216. }
  217. }
  218. timer()
  219. {
  220. llSetTimerEvent(0);
  221. // fail
  222. llMessageLinked(LINK_SET, LINK_BREED_FAIL, "", father);
  223. state female;
  224. }
  225. }
  226. state pregnant
  227. {
  228. state_entry()
  229. {
  230. if (preg_time != 0) {
  231. llSetTimerEvent(172800.0 - (float)(llGetUnixTime() - preg_time));
  232. } else {
  233. llSetTimerEvent(172800.0);
  234. }
  235. }
  236. timer()
  237. {
  238. // lay egg.
  239. llSetTimerEvent(0);
  240. llMessageLinked(LINK_SET, LINK_LAY_EGG, "", "");
  241. state female;
  242. }
  243. }