xs_foodbowl_anim.lsl 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. // :CATEGORY:XS Quail
  2. // :NAME:XS Pet Quail Modified
  3. // :AUTHOR:Xundra Snowpaw, Ferd Frederix
  4. // :CREATED:2013-09-06
  5. // :EDITED:2013-09-17 21:48:47
  6. // :ID:987
  7. // :NUM:1427
  8. // :REV:1
  9. // :WORLD:Second Life
  10. // :DESCRIPTION:
  11. // Xs FoodBowl Animation
  12. // :CODE:
  13. // WORLD: Second Life, Opensim
  14. // DESCRIPTION:
  15. // Modified Pet Quail
  16. // Version .26 Robot 11-16-2011
  17. // script by Xundra Snowpaw
  18. // mods by Ferd Frederix
  19. //
  20. // New BSD License: http://www.opensource.org/licenses/bsd-license.php
  21. // Copyright (c) 2010, Xundra Snowpaw
  22. // All rights reserved.
  23. //
  24. // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
  25. //* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  26. //* 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.
  27. // 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.
  28. ////////////////////////////////////////////////////////////////////
  29. // revisions
  30. // 0.26 modified to show food bowl filling for creator only.
  31. ///////////////////////////////////////////////
  32. // COPY FROM GLOBAL CONSTANTS FILE LOCATED IN Debug Folder
  33. // INCLUDE THESE IN ALL SCRIPTS //
  34. // XS_pet constants and names
  35. ///// GLOBAL CONSTANTS extracted from original source //////
  36. //
  37. // if you change any of these constants, change it everywhere and in a list in XS_Debug so it can print them
  38. //
  39. // 0.24 is the original Pet Quail
  40. // 0.25 is the modified Pet Quail
  41. // 0.26 is the Robot code, which is generic
  42. float VERSION = 0.26;
  43. key YOUR_UUID = ""; // if you add a UUID for your avatar here, you can change it later
  44. // and other alts or feruiends can edit and make these pets
  45. // If you leave it blank, only the creator can work on them
  46. string Animal = "Troubot"; // was 'Quail', must be the name of your animal
  47. string Egg = "Nut and Bolt"; // was 'XS Egg', must be the name of your egg
  48. string Crate = "Transport UFO"; // was XS-Cryocrate
  49. string HomeObject = "Home Flag"; // was "XS Home Object
  50. string sound = "robot_sound";
  51. string SECRET_PASSWORD = "top secret robot"; // must use one unique to any animal
  52. integer SECRET_NUMBER = 99999; // any number thats a secret
  53. integer MaxAge = 7; // can get prggers in 7 days
  54. integer UNITS_OF_FOOD = 168; // food bowl food
  55. float secs_to_grow = 86400; // grow daily = 86400
  56. // global listeners
  57. integer FOOD_CHANNEL = -999191;
  58. integer ANIMAL_CHANNEL = -999192;
  59. integer EGG_CHANNEL = -999193;
  60. integer HOME_CHANNEL = -999194;
  61. integer BOX_CHANNEL = -999195;
  62. integer ACC_CHANNEL = -999196;
  63. integer UPDATE_CHANNEL = -999197;
  64. integer API_CHANNEL = -999198;
  65. // global prim animation linkmessages on channel 1
  66. // these are the prim animations played for each type of possible animation
  67. string ANI_STAND = "stand"; // default standing animation
  68. string ANI_WALKL = "left"; // triggers Left foot and righrt arm walk animation
  69. string ANI_WALKR = "right"; // triggers Right foot and left arm walk animation
  70. string ANI_SLEEP = "sleep"; // Sleeping
  71. string ANI_WAVE = "wave"; // Calling for sex, needs help with food, etc.
  72. // global link messages to control the animal
  73. integer LINK_AGE_START = 800; // when quail is rezzed and secret_number, is sent by brain to breeder, eater and informatic get booted up
  74. integer LINK_FOOD_CONSUME = 900; // from movement to brain when close to food, brain then consumes a random amount up to 10000
  75. integer LINK_FOODMINUS = 901; // xs_brain receives FOOD_CONSUME, decrement hunger (eat)
  76. integer LINK_HUNGRY = 903; // sent by eater (string)hunger_amount, checks each hour
  77. integer LINK_HAMOUNT = 904; // hunger_amount = (integer)str,m updates the hunger amount in scripts
  78. integer LINK_SET_HOME = 910; // loc ^ dist
  79. integer LINK_MOVER = 911; // tell mover to rest for str seconds
  80. integer LINK_FOODIE_CLR = 920; // clear all food_bowl_keys and contents
  81. integer LINK_FOODIE = 921; // send FOOD_LOCATION coordinates to movement
  82. integer LINK_COLOR1 = 930; // colour1
  83. integer LINK_COLOR2 = 931; // colour2
  84. integer LINK_SEX = 932; // sex
  85. integer LINK_SHINE = 933; // shine
  86. integer LINK_GLOW = 934; // glow
  87. integer LINK_GEN = 935; // generation
  88. integer LINK_RESET_SIZE = 936; // reset size to 1
  89. integer LINK_MAGE = 940; // xs_brain sends, xs_ager consumes, adds str to age, if older than 7 days, will grow the animal
  90. integer LINK_DAYTIME = 941; // xs_ager consumes, starts a timer of 86,400 seconds in xs_ager
  91. integer LINK_GET_AGE = 942; // get age from xs_ager and sent it on channel 943
  92. integer LINK_PUT_AGE = 943; // print age from xs_ager
  93. integer LINK_PACKAGE = 950; // look for a cryo_crate
  94. integer LINK_SEEK_FEMALE = 960; // MALE_BREED_CALL
  95. integer LINK_MALE_BREED_CALL = 961; // triggered by LINK_SEEK_FEMALE
  96. integer LINK_SIGNAL_ELIGIBLE = 962; // sent by female when hears LINK_MALE_BREED_CALL
  97. integer LINK_FEMALE_ELIGIBLE = 963; // sent when it hears in chat FEMALE_ELIGIBLE
  98. integer LINK_CALL_MALE = 964; // if LINK_FEMALE_ELIGIBLE && looking_for_female
  99. integer LINK_MALE_ON_THE_WAY = 965; // triggered by LINK_CALL_MALE
  100. integer LINK_FEMALE_LOCATION = 966; // female location, sends coordinates of a female
  101. integer LINK_RQST_BREED = 967; // sent when close enough to male/female
  102. integer LINK_CALL_MALE_INFO = 968; // sent by xs_breeding, this line of code was in error in v.24 of xs_breeding see line 557 and 636 of xs_brain which make calls and also xs_breeding which receives LINK_MALE_INFO.
  103. integer LINK_MALE_INFO = 969;
  104. integer LINK_LAY_EGG = 970; // llRezObject("XS Egg"
  105. integer LINK_BREED_FAIL = 971; // key = father, failed, timed out
  106. integer LINK_PREGNANT = 972; // chick is preggers
  107. integer LINK_SOUND_OFF= 974; // sound is off
  108. integer LINK_SOUND_ON= 973; // sound is on
  109. integer LINK_SLEEPING = 990; // close eyes
  110. integer LINK_UNSLEEPING = 991; // open eyes
  111. integer LINK_SOUND = 1001; // plays a sound if enabled
  112. integer LINK_SPECIAL = 1010; // xs_special, is str = "Normal", removes script
  113. integer LINK_PREGNANCY_TIME = 5000; // in seconds as str
  114. integer LINK_SLEEP = 7999; // disable sleep by parameter
  115. integer LINK_TIMER = 8000; // scan for food bowl about every 1800 seconds
  116. integer LINK_DIE = 9999; // death
  117. ///////// end global Link constants ////////
  118. ///////////// END OF COPIED CODE ////////////
  119. // tunable constants
  120. integer PIE = TRUE; // set to TRUE for pie slices, set to FALSE for Vertical liquid/plasma effect
  121. // globals
  122. integer food_left;
  123. // code
  124. // allow either a UUID to be entered, or not, and still maintain security
  125. integer CheckPerms()
  126. {
  127. if (YOUR_UUID != "" && llGetOwner() != YOUR_UUID)
  128. return 1;
  129. if (llGetOwner() != llGetCreator())
  130. return 1;
  131. return 0;
  132. }
  133. default
  134. {
  135. state_entry()
  136. {
  137. food_left = UNITS_OF_FOOD;
  138. if ( ! CheckPerms() )
  139. {
  140. float i = 0 ;
  141. while (i < 1)
  142. {
  143. if (PIE)
  144. llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_CYLINDER, PRIM_HOLE_DEFAULT, <0, i, 0>, 0, <0, 0, 0>, <1.0, 1.0, 0.0>, <0,0,0>]);
  145. else
  146. {
  147. float unit = (float) UNITS_OF_FOOD /10;
  148. llMessageLinked(LINK_SET,100,(string) unit,"");
  149. }
  150. i += 0.1 ;
  151. }
  152. // set the fusion back to full
  153. if (!PIE)
  154. llOffsetTexture(1,0.5,ALL_SIDES);
  155. }
  156. }
  157. link_message(integer sender, integer number, string str, key id)
  158. {
  159. if (number == 100) {
  160. // its a decrease message
  161. integer amount = (integer)str;
  162. food_left = food_left - amount;
  163. if (PIE)
  164. {
  165. // do the pie slice thing
  166. float cut_amount = ((float)food_left / (float)UNITS_OF_FOOD) * 0.95;
  167. llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_CYLINDER, PRIM_HOLE_DEFAULT, <0, cut_amount, 0>, 0.0, <0, 0, 0>, <1.0, 1.0, 0.0>, <0,0,0>]);
  168. }
  169. else
  170. {
  171. // do the vertical plasma draining effect
  172. float offset_amount = 1 - ((float)food_left / (float)UNITS_OF_FOOD) /2;
  173. llOffsetTexture(1,offset_amount,ALL_SIDES); // slide the texture
  174. }
  175. }
  176. llSleep(0.1); // time to see this at startup
  177. }
  178. }