xs_eater.lsl 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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:1418
  8. // :REV:1
  9. // :WORLD:Second Life, Opensim
  10. // :DESCRIPTION:
  11. // Modified Pet Quail
  12. // :CODE:
  13. // Version .24 10-3-2011
  14. // script by Xundra Snowpaw
  15. // mods by Ferd Frederix
  16. //
  17. // New BSD License: http://www.opensource.org/licenses/bsd-license.php
  18. // Copyright (c) 2010, Xundra Snowpaw
  19. // All rights reserved.
  20. //
  21. // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
  22. //* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  23. //* 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.
  24. // 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.
  25. ////////////////////////////////////////////////////////////////////
  26. ///// GLOBAL LINK CONSTANTS extracted from original source //////
  27. ///
  28. // if you change anything, you change it everywhere and in a list in XS_Debug
  29. ///
  30. integer LINK_AGE_START = 800; // when quail is rezzed and secret_number, is sent by brain to breeder, eater and informatic get booted up
  31. integer LINK_FOOD_CONSUME = 900; // from movement to brain when close to food, brain then consumes a random amount up to 10000
  32. integer LINK_FOODMINUS = 901; // xs_brain receives FOOD_CONSUME, decrement hunger (eat)
  33. integer LINK_HUNGRY = 903; // sent by eater (string)hunger_amount, checks each hour
  34. integer LINK_HAMOUNT = 904; // hunger_amount = (integer)str,m updates the hunger amount in scripts
  35. integer LINK_SET_HOME = 910; // loc ^ dist
  36. integer LINK_MOVER = 911; // tell mover to rest for str seconds
  37. integer LINK_FOODIE_CLR = 920; // clear all food_bowl_keys and contents
  38. integer LINK_FOODIE = 921; // send FOOD_LOCATION coordinates to movement
  39. integer LINK_COLOR1 = 930; // colour1
  40. integer LINK_COLOR2 = 931; // colour2
  41. integer LINK_SEX = 932; // sex
  42. integer LINK_SHINE = 933; // shine
  43. integer LINK_GLOW = 934; // glow
  44. integer LINK_GEN = 935; // generation
  45. integer LINK_MAGE = 940; // xs_brain sends, xs_ager consumes, adds str to age, if older than 7 days, will grow the animal
  46. integer LINK_DAYTIME = 941; // xs_ager consumes, starts a timer of 86,400 seconds in xs_ager
  47. integer LINK_GET_AGE = 942; // get age from xs_ager and sent it on channel 943
  48. integer LINK_PUT_AGE = 943; // print age from xs_ager
  49. integer LINK_PACKAGE = 950; // look for a cryo_crate
  50. integer LINK_SEEK_FEMALE = 960; // MALE_BREED_CALL
  51. integer LINK_MALE_BREED_CALL = 961; // triggered by LINK_SEEK_FEMALE
  52. integer LINK_SIGNAL_ELIGIBLE = 962; // sent by female when hears LINK_MALE_BREED_CALL
  53. integer LINK_FEMALE_ELIGIBLE = 963; // sent when it hears in chat FEMALE_ELIGIBLE
  54. integer LINK_CALL_MALE = 964; // if LINK_FEMALE_ELIGIBLE && looking_for_female
  55. integer LINK_MALE_ON_THE_WAY = 965; // triggered by LINK_CALL_MALE
  56. integer LINK_FEMALE_LOCATION = 966; // female location, sends coordinates of a female
  57. integer LINK_RQST_BREED = 967; // sent when close enough to male/female
  58. integer LINK_CALL_MALE_INFO = 968; // ****** BUG ***** read, but never sent by anybody!!!!!
  59. // see line 557 and 636 of xs_brain which make calls and also xs_breeding which receives LUNK_MALE_INFO.
  60. integer LINK_MALE_INFO = 969;
  61. integer LINK_LAY_EGG = 970; // llRezObject("XS Egg"
  62. integer LINK_BREED_FAIL = 971; // key = father, failed, timed out
  63. integer LINK_PREGNANT = 972; // chick is preggers
  64. integer LINK_SLEEPING = 990; // close eyes
  65. integer LINK_UNSLEEPING = 991; // open eyes
  66. integer LINK_SOUND = 1001; // plays a sound if enabled
  67. integer LINK_SPECIAL = 1010; // xs_special, is str = "Normal", removes script
  68. integer LINK_PREGNANCY_TIME = 5000; // in seconds as str
  69. integer LINK_SLEEP = 7999; // disable sleep by parameter
  70. integer LINK_TIMER = 8000; // scan for food bowl about every 1800 seconds
  71. integer LINK_DIE = 9999; // death
  72. ///////// end global Link constants ////////
  73. // END //
  74. integer SECONDS_BETWEEN_FOOD_NORMAL = 14400;
  75. integer SECONDS_BETWEEN_FOOD_HUNGRY = 3600;
  76. integer hunger_amount;
  77. integer seconds_elapsed_normal;
  78. integer seconds_elapsed_hungry;
  79. default
  80. {
  81. link_message(integer sender, integer num, string str, key id)
  82. {
  83. if (num == LINK_AGE_START) {
  84. state running;
  85. }
  86. }
  87. }
  88. state running
  89. {
  90. state_entry()
  91. {
  92. hunger_amount = 0;
  93. seconds_elapsed_normal = 0;
  94. seconds_elapsed_hungry = 0;
  95. llSetTimerEvent(1.0);
  96. }
  97. timer()
  98. {
  99. integer do_message = 0;
  100. if (hunger_amount > 0) {
  101. if (seconds_elapsed_hungry == SECONDS_BETWEEN_FOOD_HUNGRY) {
  102. do_message = 1;
  103. seconds_elapsed_hungry = 0;
  104. } else {
  105. seconds_elapsed_hungry++;
  106. }
  107. }
  108. if (seconds_elapsed_normal == SECONDS_BETWEEN_FOOD_NORMAL) {
  109. hunger_amount++;
  110. seconds_elapsed_normal = 0;
  111. } else {
  112. seconds_elapsed_normal++;
  113. }
  114. if (do_message == 1) {
  115. llMessageLinked(LINK_SET, LINK_HUNGRY, (string)hunger_amount, "");
  116. }
  117. }
  118. link_message(integer sender, integer num, string str, key id)
  119. {
  120. if (num == LINK_FOODMINUS) {
  121. hunger_amount --;
  122. } else
  123. if (num == LINK_HAMOUNT) {
  124. hunger_amount = (integer)str;
  125. }
  126. }
  127. }