Join us in Outworldz at www.outworldz.com:9000 or follow us:

Search dozens of selected web sites for OpenSim and LSL script

New! Script Meta-Search will search thousands of scripts here and at other sites for LSL or Opensim scripts.
Loading

Want to add a script or a project? Upload it and a half million people will see it and your name here this year.

Home   Show All
Category: Contributor: Creator
XS Pet XS Pet Robot  

XS Pet Robot

XS Pet makes a female pet 8 days old

Category: XS Pet
By : Ferd Frederix
Created: 2013-09-06 Edited: 2015-07-24
Worlds: Second Life

the Zip file

Download all files for XS Pet Robot
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. license.txt
Get file # 2. Readme.txt
Get file # 3. [5460 bytes] License.png
Get file # 4. Force breeding early female.lsl
Get file # 5. Force breeding early male.lsl
Get file # 6. Force breeding early.lsl
Get file # 7. Global constants.lsl
Get file # 8. READ ME.txt
Get file # 9. Revisions.txt
Get file # 10. Updater.lsl
Get file # 11. xs_ager test script.lsl
Get file # 12. xs_debug.lsl
Get file # 13. [1224 bytes] 1.jpg
Get file # 14. [5955 bytes] 10.jpg
Get file # 15. [22078 bytes] 10;4;2;10.jpg
Get file # 16. [4522 bytes] 11.jpg
Get file # 17. [29951 bytes] 11;4;4;10.jpg
Get file # 18. [1842 bytes] 12.jpg
Get file # 19. [8077 bytes] 12;4;2;10.jpg
Get file # 20. [3853 bytes] 1;4;2;10.jpg
Get file # 21. [2022 bytes] 2.jpg
Get file # 22. [9441 bytes] 2;5;2;10.jpg
Get file # 23. [1716 bytes] 3.jpg
Get file # 24. [7191 bytes] 3;4;2;10.jpg
Get file # 25. [2247 bytes] 4.jpg
Get file # 26. [8979 bytes] 4;3;2;10.jpg
Get file # 27. [2702 bytes] 5.jpg
Get file # 28. [13534 bytes] 5;3;3;10.jpg
Get file # 29. [4630 bytes] 7.jpg
Get file # 30. [17102 bytes] 7;4;2;10.jpg
Get file # 31. [4210 bytes] 8.jpg
Get file # 32. [18825 bytes] 8;4;2;10.jpg
Get file # 33. [3826 bytes] 9.jpg
Get file # 34. [11107 bytes] 9;2;2;10.jpg
Get file # 35. xs_animated_eye script.lsl
Get file # 36. xs_sleep script.lsl
Get file # 37. xs_two-texture eyes.lsl
Get file # 38. [805 bytes] Z.png
Get file # 39. [147097 bytes] animated_flag.anim;4;2;10_small.png
Get file # 40. [36093 bytes] mars_attacks.anim;4;2;10_small.png
Get file # 41. rotate the globe.lsl
Get file # 42. waving flag.lsl
Get file # 43. xs_home.lsl
Get file # 44. [73778 bytes] moon map.jpg
Get file # 45. Moonlet Pose Ball.lsl
Get file # 46. README.txt
Get file # 47. rotate moon.lsl
Get file # 48. [21771 bytes] telstar.jpg
Get file # 49. walking.lsl
Get file # 50. xs movement plug-in for robot sphere walk.lsl
Get file # 51. xs_home.lsl
Get file # 52. xs_radius.lsl
Get file # 53. [26812 bytes] Mr-Fusion.jpg
Get file # 54. [3010 bytes] Mr-Fusion.png
Get file # 55. [1149 bytes] plasma.jpg
Get file # 56. xs_foodbowl.lsl
Get file # 57. xs_foodbowl_anim.lsl
Get file # 58. [12342 bytes] Bolt_assy.bmp
Get file # 59. [12342 bytes] Nut_assy.bmp
Get file # 60. [46773 bytes] steel texture.jpg
Get file # 61. xs coloring plug-in.lsl
Get file # 62. xs_egg.lsl
Get file # 63. [1424 bytes] toolbox-handle-sculpt.jpg
Get file # 64. [12342 bytes] Ufo.bmp
Get file # 65. xs coloring plug-in.lsl
Get file # 66. xs_eggcup.lsl
Get file # 67. Beam Particle effects.lsl
Get file # 68. Particle effects.lsl
Get file # 69. rotate the teleport.lsl
Get file # 70. [13483 bytes] scale.png
Get file # 71. [5804 bytes] Torley creme.jpg
Get file # 72. [12342 bytes] Ufo.bmp
Get file # 73. xs coloring plugin.lsl
Get file # 74. xs_cryocrate.lsl
Get file # 75. ColorNames.lsl
Get file # 76. texture_server.lsl
Get file # 77. texture_test by touch.lsl
Get file # 78. xs_texture.lsl
Get file # 79. rotate the globe.lsl
Get file # 80. xs_home_world.lsl
Get file # 81. xs_listener.lsl
Get file # 82. xs_movement.lsl
Get file # 83. add_animations.lsl
Get file # 84. Animator.lsl
Get file # 85. [2230 bytes] bent finger.png
Get file # 86. Compiler.lsl
Get file # 87. DEBUG prim animator timer.lsl
Get file # 88. [196664 bytes] finger texture.bmp
Get file # 89. [9351 bytes] foot texture.jpg
Get file # 90. [3058 bytes] foot.png
Get file # 91. Optional - xs_infomatic - home in pet.lsl
Get file # 92. Optional - xs_home_in_pet.lsl
Get file # 93. Optional Birth particle_plug_in.lsl
Get file # 94. prim animator timer (DEBUG).lsl
Get file # 95. xs_ager.lsl
Get file # 96. xs_brain.lsl
Get file # 97. xs_breeding.lsl
Get file # 98. xs_eater.lsl
Get file # 99. xs_infomatic - home in pet.lsl
Get file # 100. xs_infomatic.lsl
Get file # 101. xs_movement.lsl
Get file # 102. xs_movement_globe plugin.lsl
Get file # 103. xs_sex OPTIONAL.lsl
Get file # 104. xs_Sound_Module.lsl
Get file # 105. xs_special.lsl
Get file # 106. alien.wav
Get file # 107. boink.wav
Get file # 108. eat.wav
Get file # 109. electricity.wav
Get file # 110. electrocute.wav
Get file # 111. gravel-path-walk.wav
Get file # 112. ka-ching.wav
Get file # 113. meadow-walk.wav
Get file # 114. notes on sounds.txt
Get file # 115. robot_sound.wav
Get file # 116. selfdestruct.wav
Get file # 117. sex-failed.wav
Get file # 118. Sex.wav
Get file # 119. sleeping.wav
Get file # 120. startup.wav
Get file # 121. steps-in-shallow-water.wav
Get file # 122. touch.wav
Get file # 123. ultra-sub.wav
Get file # 124. walk.wav
Get file # 125. yawn.wav
Get file # 126. XsPet Updater.lsl

This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1
2 // used only to acclerate a pet from being born to being 8 days old for debug - they will give birth much quicker this way
3
4 string sex = "2"; // make it male, use 2 for female
5
6 integer LINK_AGE_START = 800; // when quail is rezzed and secret_number, is sent by brain to breeder, eater and informatic get booted up
7 integer LINK_SEX = 932; // sex
8 integer LINK_MAGE = 940; // xs_brain sends, xs_ager consumes, adds str to age, if older than 7 days, will grow the animal
9
10 default
11 {
13 {
14 llMessageLinked(LINK_SET, LINK_MAGE, "1", ""); // force it to be 8 days old
15 llSleep(1);
16 llMessageLinked(LINK_SET, LINK_MAGE, "1", ""); // force it to be 8 days old
17 llSleep(1);
18 llMessageLinked(LINK_SET, LINK_MAGE, "1", ""); // force it to be 8 days old
19 llSleep(1);
20 llMessageLinked(LINK_SET, LINK_MAGE, "1", ""); // force it to be 8 days old
21 llSleep(1);
22 llMessageLinked(LINK_SET, LINK_MAGE, "1", ""); // force it to be 8 days old
23 llSleep(1);
24 llMessageLinked(LINK_SET, LINK_MAGE, "1", ""); // force it to be 8 days old
25 llSleep(1);
26 llMessageLinked(LINK_SET, LINK_MAGE, "1", ""); // force it to be 8 days old
27 llSleep(1);
28 llMessageLinked(LINK_SET, LINK_MAGE, "1", ""); // force it to be 8 days old
29 llSleep(1);
30
31 llMessageLinked(LINK_SET, LINK_SEX, sex, ""); // make it female, should trigger LINK_GET_AGE and the 3 hour timers
32 }
33 }

XS Pet Robot

XS Pet makes a male pet 8 days old

Category: XS Pet
By : Ferd Frederix
Created: 2013-09-06 Edited: 2015-07-24
Worlds: Second Life


This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1
2 // used only to accelerate a pet from being born to being 8 days old for debug - they will give birth much quicker this way
3
4 string sex = "1"; // make it male, use 2 for female
5
6
7 integer LINK_AGE_START = 800; // when quail is rezzed and secret_number, is sent by brain to breeder, eater and informatic get booted up
8 integer LINK_SEX = 932; // sex
9 integer LINK_MAGE = 940; // xs_brain sends, xs_ager consumes, adds str to age, if older than 7 days, will grow the animal
10
11 default
12 {
14 {
15 llMessageLinked(LINK_SET, LINK_MAGE, "1", ""); // force it to be 8 days old
16 llSleep(1);
17 llMessageLinked(LINK_SET, LINK_MAGE, "1", ""); // force it to be 8 days old
18 llSleep(1);
19 llMessageLinked(LINK_SET, LINK_MAGE, "1", ""); // force it to be 8 days old
20 llSleep(1);
21 llMessageLinked(LINK_SET, LINK_MAGE, "1", ""); // force it to be 8 days old
22 llSleep(1);
23 llMessageLinked(LINK_SET, LINK_MAGE, "1", ""); // force it to be 8 days old
24 llSleep(1);
25 llMessageLinked(LINK_SET, LINK_MAGE, "1", ""); // force it to be 8 days old
26 llSleep(1);
27 llMessageLinked(LINK_SET, LINK_MAGE, "1", ""); // force it to be 8 days old
28 llSleep(1);
29 llMessageLinked(LINK_SET, LINK_SEX, sex, ""); // make it male, should trigger LINK_GET_AGE and the 3 hour timers
30 }
31 }

XS Pet Robot

XS Pet xs_ager test script

Category: XS Pet
By : Ferd Frederix
Created: 2013-09-06 Edited: 2015-07-24
Worlds: Second Life


This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1
2 // xs_ager test script
3
4 // script by Ferd Frederix
5
6 // Put in the animal when the animal is sized as if it were just born, and then touch it.
7 // The animal will grow 10% a second for 7 seconds, then reset back to the original size.
8 // This represents how large the animal will get in 7 days.
9
10 // Unlike the original script, the xs_ager replacement allows arbitrary growth without any constants or prim limits.
11 // It includes 2 tunable parameters for aging time and maximum growth time
12
13
14
15
16 // START OF COPIED file 'Global Constants.txt' from the Debug folder. It has to be the same in all files
17 // If you change this in any script, change it in all of them, please. It works a lot better that way.
18
19 // This is code based on Version 0.50 01-30-2014
20 // For version history, see file revisions.txt
21 //
22 // LICENSE
23 /////////////////////////////////////////////////////////////////////
24 // This code is licensed as Creative Commons Attribution/NonCommercial/Share Alike
25 // See http://creativecommons.org/liceses/by-nc-sa/3.0/
26 // Noncommercial -- You may not use this work for commercial purposes, i.e., you cannot sell this script in any form, including derivatives.
27 // If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one.
28 // This means that you cannot sell this or derivative code by itself, but you may share and use this code in any object or virtual world.
29 // You must attribute authorship in the original scripts to Ferd Frederix and Xundra Snowpaw, and leave this notice intact.
30 // You do not have to give back to the community any changes you make, however, code changes would be greatly appreciated!
31 //
32 // Exception: I am allowing this script to be used in an original build and sold with the build.
33 // You are not selling the script, you are selling the build. If you want to sell these scripts, write your own or use the original at http://code.google.com/p/xspets/
34 // Note: Xundra Snowpaw's license was 'New BSD' license and adding additional licenses is allowed.
35
36 // Based on code from Xundra Snowpaw
37 // New BSD License: http://www.opensource.org/licenses/bsd-license.php
38 // Copyright (c) 2010, Xundra Snowpaw
39 // All rights reserved.
40 // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
41
42 //* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
43 //* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer
44 // in the documentationand/or other materials provided with the distribution.
45
46 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
47 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
48 // BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
49 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
50 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
51 // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
52 ////////////////////////////////////////////////////////////////////
53
54 // DEBUG - lets you see and hear wtf is happening
55 integer debug = FALSE; // set to TRUE TO hear a lot of chat
56
57
58 // This section has a few tuneable items that MUST be changed for any new pet
59
60 // SECURITY
61 string SECRET_PASSWORD = "top secret string"; // must use a password unique to any species of animal, when ENCRYPT= TRUE. Otherwise you will find Pet type A fucking pet type B.
62 integer SECRET_NUMBER = 99999; // any number thats a secret, not necessary to change usually, this is used when pets are born and eggs are rezzed to establish a comm channel.
63 integer ENCRYPT = TRUE; // set to TRUE to encrypt all data, Some Opensim worlds prefer FALSE due to parsing bugs, TRUE is the most secure. If FALSE you MUST change the FOOD_CHANNEL and other channels for different pets. or they will literally fuck each other.
64
65 // if you add the UUID for your avatar here, you can change it later
66 // and other alts or friends can change it too, and all of you can work on these pets.
67 // If you leave it blank, only the creator of the root prim can work on these pets.
68 key YOUR_UUID = "";
69
70 // PET NAMES - YOU MUST CHANGE THEM HERE AND IN THE ROOT PRIM OF THE OBJECT - THEY MUST MATCH EXACTLY
71 /////////////////////////
72 string MaleName = "Troubot"; // Must be the name of your animal
73 string FemaleName = "Troubot"; // The name of the female pet, if a different shape or prim count. Can be the same as the Male for pets like the robot that are unisex.
74 string Egg = "Nut and Bolt"; // was 'XS Egg', must be the name of your egg
75 string Crate = "Transport Spaceship"; // was XS-Cryocrate, must be the name of the crate you package pets in
76 string HomeObject = "Home Flag"; // was "XS Home Object", must be the name of your Home Post indicator
77 string EggCup = "Toolbox"; // was "XS Egg Cup", must be the name of your egg holder
78 // any other object names are 'do not cares'.
79
80 // NOTHING NEEDS TO BE CHANGED BELOW, BUT CAN BE CHANGED IF YOU DO IT EVERYWHERE
81
82 // misc tunables
83 float GROWTH_AMOUNT = 0.10; // 10% size increase each day for MaxAge days = 200% (double size after 7 days)
84 integer MaxAge = 7; // stop growing in seven days. 10% growth compounded daily means that your pet will be 194% larger ( 2x, basically) in 7 days.
85 integer UNITS_OF_FOOD = 168; // food bowl food qty, used by food bowl only
86 float secs_to_grow = 86400; // grow daily = 86400 seconds
87 float FOOD_BOWL_SCAN_INTERVAL = 1800.0; // look for food every 3 hours
88 float fPregnancy = 172800.0; // how many seconds to lay an egg = 2 days or 48 hours.
89 float MALE_TIMEOUT = 900.0 ; // in seconds, female waits this long in one spot for a male to arrive
90 float SEX_WAIT = 10800.0; // How often they desire sex = 3 hours
91 float fDaysToAdult = 7; // 7 days to become old enough to breed.
92 integer SECONDS_BETWEEN_FOOD_NORMAL = 14400; // number of seconds to get hungry = 4 hours
93 integer SECONDS_BETWEEN_FOOD_HUNGRY = 3600; // number of seconds before hunger count increases = 1 hour
94 integer MAXIMUM_HUNGER = 30; // They die after a month with no food.
95
96
97 // I control versions by Subversion Source Code Control. But the updater needs a version numbert in world.
98 // This is the Protocol version. If you change this, then all pets with a lower version will be updated by the updater
99 float VERSION = 0.50;
100
101
102
103 // the leg sizes are safe to leave alone or set to 0 if you use a thin base prim, these are from the original Quail
104 float LegLength = 0.064; // length of pet leg??? - not sure
105 float LegOffset = 0.052399; // This is added to the Post Z to position the pet
106
107 // the following are global constants and do not need to be changed
108 // Prim animation linkmessages are sent by scripts on Link Message number 1
109 // The strings are the names of the animations that are recorded.
110 // No need to change them unless you want to change names of the animations when you run the prim animator, or you add additional link messages
111 // If your pet walks, you need to record these names and save them in the notecard
112 //
113 // Example:
114 // llMessageLinked(LINK_SET, LINK_ANIMATE, ANI_STAND, "");
115 // The above line will play the pre-recorded 'stand up' animation "stand" using the animator script.
116 // The following animations are used in the pet. You can add your own.
117
118 string ANI_STAND = "stand"; // default standing animation
119 string ANI_WALKL = "left"; // triggers Left foot and Right arm walk animation
120 string ANI_WALKR = "right"; // triggers Right foot and Left arm walk animation
121 string ANI_SLEEP = "sleep"; // Sleeping
122 string ANI_WAVE = "wave"; // Calling for sex, needs help with food, etc.
123
124 // Channel assignments
125 // if you change any of these constants, change it everywhere and in the list in XS_Debug so it can print them
126 // If you turn encryption FALSE, you MUST change these between species of pets are they will fuck with each other. Literally.
127
128 integer FOOD_CHANNEL = -999191;
129 integer ANIMAL_CHANNEL = -999192;
130 integer EGG_CHANNEL = -999193;
131 integer HOME_CHANNEL = -999194;
132 integer BOX_CHANNEL = -999195;
133 integer ACC_CHANNEL = -999196;
134 integer UPDATE_CHANNEL = -999197;
135 integer API_CHANNEL = -999198;
136
137 // global link messages to control the animal, never any need to change these.
138 // They are exposed here so they will be the same everywhere. This uses a bit of RAM, but who cares?
139
140 integer LINK_ANIMATE = 1; // messages on num 1 are assumed to be directed at the prim animator.
141 integer DECREASE_FOOD = 100; // used in the food bowl.
142 integer LINK_AGE_START = 800; // when pety is rezzed and secret_number is sent by brain to breeder, eater and infomatic get booted up
143 integer LINK_TEXTURE = 801; // ask for a new texture, or paint a color
144 integer LINK_BREEDNAME = 802; // the name of the pet texture from the texture server notecard
145 integer LINK_FOOD_CONSUME = 900; // from movement to brain when close to food, brain then consumes a random amount up to 10000
146 integer LINK_FOODMINUS = 901; // xs_brain receives FOOD_CONSUME, decrement hunger (eat)
147 integer LINK_HUNGRY = 903; // sent by eater (string)hunger_amount, checks each hour
148 integer LINK_HAMOUNT = 904; // hunger_amount = (integer)str,m updates the hunger amount in scripts
149 integer LINK_SET_HOME = 910; // loc ^ dist
150 integer LINK_MOVER = 911; // tell mover to rest for str seconds
151 integer LINK_FOODIE_CLR = 920; // clear all food_bowl_keys and contents
152 integer LINK_FOODIE = 921; // send FOOD_LOCATION coordinates to movement
153 integer LINK_COLOR1 = 930; // colour1
154 integer LINK_COLOR2 = 931; // colour2
155 integer LINK_SEX = 932; // sex
156 integer LINK_SHINE = 933; // shine
157 integer LINK_GLOW = 934; // glow
158 integer LINK_GEN = 935; // generation
159 integer LINK_RESET_SIZE = 936; // reset size to 1
160 integer LINK_MAGE = 940; // xs_brain sends, xs_ager consumes, adds str to age, if older than 7 days, will grow the animal
161 integer LINK_DAYTIME = 941; // xs_ager consumes, starts a timer of 86,400 seconds in xs_ager
162 integer LINK_GET_AGE = 942; // get age from xs_ager and sent it on channel 943
163 integer LINK_PUT_AGE = 943; // print age from xs_ager
164 integer LINK_PACKAGE = 950; // look for a cryo_crate
165 integer LINK_SEEK_FEMALE = 960; // MALE_BREED_CALL
166 integer LINK_MALE_BREED_CALL = 961; // triggered by LINK_SEEK_FEMALE
167 integer LINK_SIGNAL_ELIGIBLE = 962; // sent by female when hears LINK_MALE_BREED_CALL
168 integer LINK_FEMALE_ELIGIBLE = 963; // sent when it hears in chat FEMALE_ELIGIBLE
169 integer LINK_CALL_MALE = 964; // if LINK_FEMALE_ELIGIBLE && looking_for_female
170 integer LINK_MALE_ON_THE_WAY = 965; // triggered by LINK_CALL_MALE
171 integer LINK_FEMALE_LOCATION = 966; // female location, sends coordinates of a female
172 integer LINK_RQST_BREED = 967; // sent when close enough to male/female
173 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.
174 integer LINK_MALE_INFO = 969; // Breeding failed, sent info
175 integer LINK_LAY_EGG = 970; // Rez Object(Egg...
176 integer LINK_BREED_FAIL = 971; // key = father, failed, timed out
177 integer LINK_PREGNANT = 972; // chick is preggers
178 integer LINK_SOUND_OFF= 974; // sound is off
179 integer LINK_SOUND_ON= 973; // sound is on
180 integer LINK_SLEEPING = 990; // close eyes
181 integer LINK_UNSLEEPING = 991; // open eyes
182 integer LINK_SOUND = 1001; // plays a sound if enabled
183 integer LINK_SPECIAL = 1010; // xs_special, if str = "Normal", removes script
184 integer LINK_EFFECTS_ON = 2000; // particle effects in the packger
185 integer LINK_PREGNANCY_TIME = 5000; // in seconds as str
186 integer LINK_SLEEP = 7999; // disable sleep by parameter
187 integer LINK_TIMER = 8000; // scan for food bowl about every 1800 seconds
188 integer LINK_DIE = 9999; // death
189
190 string Copyright = " (c)2014 by Ferd Frederix"; // You cannot change this line, but you can change the code that prints it!
191 // See License agreements above.
192 // Attribution is required, as these files are copyrighted.
193
194
195 DEBUG ( string msg){
196 if(debug) {
197 llOwnerSay(llGetScriptName() + ":" + msg);
198 }
199 }
200
201
202
203 ///////// end global Link constants ////////
204
205 // END OF COPIED CODE
206
207
208
209
210
211
212
213
214
215
216
217
218
219 default
220 {
222 {
223
224 }
225
226 touch_start(integer total_number)
227 {
228 llMessageLinked(LINK_SET,LINK_AGE_START,"","");
229 integer i;
230 for (i = 1; i < 8; i++)
231 {
232 llMessageLinked(LINK_SET,LINK_MAGE,"1","");
233 llSleep(1);
234 }
235
236 llMessageLinked(LINK_SET,LINK_RESET_SIZE,"","");
237
238 }
239 }

XS Pet Robot

XS Pet xs_debug

Category: XS Pet
By : Ferd Frederix
Created: 2013-09-06 Edited: 2015-07-24
Worlds: Second Life


This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1
2 // xs_debug
3
4 // The xs_debug script can be put into a pet or a prim nearby to see what is happening.
5 // If put into a prim nearby, xs_debug can only hear the chat back and forth as the animals communicate with food bowls and look for each other to have sex ( or find the home post).
6 // If put into the food bowl, it can hear any chat, as well as report on link messages inside the food bowl.
7 // When put inside a pet it gets very chatty, as it reports on the movement link messages as the pet tries to move.
8 // If you get anything that looks like pure gibberish, then check the encryption flag.
9 // The text that is output should look like this as an example : and XS_PET^FOOD_CONSUME^765643-39463845-65432-8231484^24623^.....
10 // You can then look in the code and see what is going on that matches these strings, or email the output to fred@mitsi.com and I can see that is happening.
11
12
13 // DEBUG:
14
15 // Here is a xs_debug dump of the pets being made:
16
17 // --------------------- PACKAGING the EGG--------------------
18 // an egg has been rezzed, this is what happens when you package it
19
20 // [11:15] Nut and Bolt whispers: Color: <0.00000, 1.00000, 0.00000>
21 // [11:15] Nut and Bolt whispers: Color: <0.00000, 0.00000, 1.00000>
22 // [11:15] Nut and Bolt whispers: Shine: None
23 // [11:15] Nut and Bolt whispers: Glow: 0%
24 // [11:15] Nut and Bolt whispers: Special: Normal
25 // [11:15] Nut and Bolt whispers: Generation: 0
26
27 // Now the egg has been packaged and unpacked, so there is a pet robot inside the pet robot and a new egg:
28 // UNPACKAGED NOW
29
30 // [11:15] Troubot: Troubot: LINK_AGE_START : string: : key:
31 // [11:15] Troubot: Troubot:channel:ANIMAL_CHANNEL:XSPET^CONFIG^9d1a7863-ae14-c23f-e8e0-526685e2588c^<0.00000, 1.00000, 0.00000>^<0.00000, 0.00000, 1.00000>^2^0^0.000000^0^0^0^Troubot^0^Normal
32 // [11:15] Troubot: Troubot: LINK_TEXTURE : string:<0.00000, 1.00000, 0.00000>^<0.00000, 0.00000, 1.00000>^2^0^0.000000^ : key:00000000-0000-0000-0000-000000000000
33 // [11:15] Troubot: Troubot: LINK_COLOR1 : string:<0.00000, 1.00000, 0.00000> : key:
34 // [11:15] Troubot: Troubot: LINK_COLOR2 : string:<0.00000, 0.00000, 1.00000> : key:
35 // [11:15] Troubot: Troubot: LINK_SEX : string:2 : key:
36 // [11:15] Troubot: Troubot: LINK_SHINE : string:0 : key:
37 // [11:15] Troubot: Troubot: LINK_GLOW : string:0.000000 : key:
38 // [11:15] Troubot: Troubot: LINK_GEN : string:0 : key:
39 // [11:15] Troubot: Troubot: LINK_MAGE : string:0 : key:
40 // [11:15] Troubot: Troubot: LINK_SPECIAL : string:Normal : key:
41 // [11:15] Troubot: Troubot: LINK_DAYTIME : string: : key:
42 // [11:15] Troubot: Troubot: LINK_GET_AGE : string: : key:
43 // [11:15] Troubot: Troubot: LINK_PUT_AGE : string:0 : key:
44 // [11:15] Troubot: Troubot:channel:ANIMAL_CHANNEL:XSPET^HOME_LOCATION^<33.24266, 211.12510, 600.72560>^2
45 // [11:16] Troubot: xs_Debug is loaded into this item.
46 // [11:16] Troubot whispers: Color1: <0.00000, 1.00000, 0.00000>
47 // [11:16] Troubot whispers: Color2: <0.00000, 0.00000, 1.00000>
48 // [11:16] Troubot whispers: Shine: None
49 // [11:16] Troubot whispers: Glow: 0%
50 // [11:16] Troubot whispers: Special: Normal
51 // [11:16] Troubot whispers: Sex: Female
52 // [11:16] Troubot whispers: Color2: <0.00000, 0.00000, 1.00000>
53 // [11:16] Troubot whispers: Age: 0 days
54 // [11:16] Troubot whispers: Generation: 0
55
56 // Now I click the flag:
57
58 // [11:16] Home Flag: Setting Home Location
59 // [11:16] Troubot: Troubot: LINK_SET_HOME : string:<33.24266, 211.12510, 600.72560>^10.000000 : key:
60
61 // At this point the pet starts moving:
62
63 // [11:16] Troubot: Troubot: ANIMATE_PRIM : string:stand : key:
64 // [11:16] Troubot: Troubot: ANIMATE_PRIM : string:wave : key:
65 // [11:16] Troubot: Troubot: ANIMATE_PRIM : string:stand : key:
66 // [11:16] Troubot: Troubot: LINK_SOUND : string: : key:
67 // [11:16] Troubot: Troubot: ANIMATE_PRIM : string:left : key:
68 // ....
69 // ....
70
71 // Now we package the pet into a transport UFO
72
73 // [11:17] Troubot whispers: Looking for a Transport UFO...
74 // [11:17] Troubot: Troubot:channel:ANIMAL_CHANNEL:XSPET^CRATE_PONG^9d1a7863-ae14-c23f-e8e0-526685e2588c^0.280000
75 // [11:17] Troubot: Troubot:channel:ANIMAL_CHANNEL:XSPET^CRATE_PONG^9d1a7863-ae14-c23f-e8e0-526685e2588c^0.280000
76
77 // Now we un-package the pet into a transport UFO
78
79
80 // [11:17] Transport UFO:Troubot whispers: Color 1: <0.00000, 1.00000, 0.00000>
81 // [11:17] Transport UFO:Troubot whispers: Color 2: <0.00000, 0.00000, 1.00000>
82 // [11:17] Transport UFO:Troubot whispers: Shine: None
83 // [11:17] Transport UFO:Troubot whispers: Glow: 0%
84 // [11:17] Transport UFO:Troubot whispers: Special: Normal
85 // [11:17] Transport UFO:Troubot whispers: Sex: Female
86 // [11:17] Transport UFO:Troubot whispers: Age: 0 days
87 // [11:17] Transport UFO:Troubot whispers: Generation: 0
88 // [11:17] Troubot: Troubot: LINK_AGE_START : string: : key:
89 // [11:17] Troubot: Troubot:channel:ANIMAL_CHANNEL:XSPET^CONFIG^a75001e9-4eae-e4f1-4728-be19cd7f5717^<0.00000, 1.00000, 0.00000>^<0.00000, 0.00000, 1.00000>^2^0^0.000000^0^0^0^Troubot^0^Normal
90 // [11:17] Troubot: Troubot: LINK_TEXTURE : string:<0.00000, 1.00000, 0.00000>^<0.00000, 0.00000, 1.00000>^2^0^0.000000^ : key:00000000-0000-0000-0000-000000000000
91 // [11:17] Troubot: Troubot: LINK_COLOR1 : string:<0.00000, 1.00000, 0.00000> : key:
92 // [11:17] Troubot: Troubot: LINK_COLOR2 : string:<0.00000, 0.00000, 1.00000> : key:
93 // [11:17] Troubot: Troubot: LINK_SEX : string:2 : key:
94 // [11:17] Troubot: Troubot: LINK_SHINE : string:0 : key:
95 // [11:17] Troubot: Troubot: LINK_GLOW : string:0.000000 : key:
96 // [11:17] Troubot: Troubot: LINK_GEN : string:0 : key:
97 // [11:17] Troubot: Troubot: LINK_MAGE : string:0 : key:
98 // [11:17] Troubot: Troubot: LINK_SPECIAL : string:Normal : key:
99 // [11:17] Troubot: Troubot: LINK_DAYTIME : string: : key:
100 // [11:17] Troubot: Troubot: LINK_GET_AGE : string: : key:
101 // [11:17] Troubot: Troubot: LINK_PUT_AGE : string:0 : key:
102 // [11:17] Troubot: Troubot:channel:ANIMAL_CHANNEL:XSPET^HOME_LOCATION^<33.24266, 211.12510, 600.72560>^10
103 // [11:17] Troubot: Troubot: LINK_SET_HOME : string:<33.24266, 211.12510, 600.72560>^10.000000 : key:
104 // [11:17] Troubot: Troubot: ANIMATE_PRIM : string:stand : key:
105 // [11:17] Troubot: Troubot: ANIMATE_PRIM : string:wave : key:
106 // [11:17] Troubot: Troubot: ANIMATE_PRIM : string:stand : key:
107 // [11:17] Troubot: Troubot: LINK_SOUND : string: : key:
108 // [11:17] Troubot: Troubot: ANIMATE_PRIM : string:left : key:
109 // [11:17] Troubot: Troubot: ANIMATE_PRIM : string:right : key:
110
111 // and off the pet walks....
112
113
114 // Pregnancy:
115
116 // [18:14] male whispers: male gets a gleam in his eye.
117 // [18:14] male: male: LINK_SEEK_FEMALE : string:: key:
118 // [18:14] female: female:channel:ANIMAL_CHANNEL:XSPET^MALE_BREED_CALL^c3c55ba1-b3f3-40e2-94ce-bb87dbe29d79
119 // [18:14] female whispers: female blushes then bobs her head up and down.
120 // [18:14] female: female: LINK_MALE_BREED_CALL : string:: key:
121 // [18:14] female: female: LINK_SIGNAL_ELIGIBLE : string:: key:
122 // [18:14] male: male:channel:ANIMAL_CHANNEL:XSPET^FEMALE_ELIGIBLE^<16.44526, 99.32597, 21.14289>
123 // [18:14] male: male: LINK_FEMALE_ELIGIBLE : string:: key:000cd83a-667d-4ab2-a08c-03011718fcfd
124 // [18:14] male: male: LINK_CALL_MALE : string:: key:000cd83a-667d-4ab2-a08c-03011718fcfd
125 // [18:14] female: female:channel:ANIMAL_CHANNEL:XSPET^MALE_ON_THE_WAY^000cd83a-667d-4ab2-a08c-03011718fcfd
126 // [18:14] female: female: LINK_MALE_ON_THE_WAY : string:: key:c3c55ba1-b3f3-40e2-94ce-bb87dbe29d79
127 // [18:14] female: female: LINK_MOVER : string:200.000000: key:
128 // [18:14] male: male:channel:ANIMAL_CHANNEL:XSPET^FEMALE_LOC^c3c55ba1-b3f3-40e2-94ce-bb87dbe29d79^<16.70987, 100.10620, 21.28637>
129 // [18:14] male: male: LINK_FEMALE_LOCATION : string:<16.70987, 100.10620, 21.28637>
130 // [18:14] male: male: ANIMATE_PRIM : string:wave: key:
131 // [18:16] female: female:channel:API_CHANNEL:XSPet^c3c55ba1-b3f3-40e2-94ce-bb87dbe29d79^<0.00000, 0.00000, 1.00000>^<1.00000, 0.00000, 0.00000>^0^0.000000^Normal
132 // [18:16] male: male: ANIMATE_PRIM : string:wave: key:
133 // [18:16] male: male: LINK_RQST_BREED : string:: key:
134 // [18:16] male: male: LINK_CALL_MALE_INFO : string:: key:000cd83a-667d-4ab2-a08c-03011718fcfd
135 // [18:16] male: male: LINK_MALE_INFO : string:: key:
136 // [18:16] male: male: LINK_GET_AGE : string:: key:
137 // [18:16] female: female:channel:ANIMAL_CHANNEL:XSPET^MALE_INFO^000cd83a-667d-4ab2-a08c-03011718fcfd^<0.00000, 0.00000, 1.00000>^<1.00000, 0.00000, 0.00000>^0^0.000000^0^0
138 // [18:16] male: male: LINK_PUT_AGE : string:7: key:
139 // [18:16] female: female: LINK_PREGNANT : string:: key:
140 // [18:16] male: male:channel:API_CHANNEL:I'm Pregnant!
141
142 // at this point the female is pregnant.If you touch it it will show in hovertext
143
144
145
146
147
148
149 // START OF COPIED file 'Global Constants.txt' from the Debug folder. It has to be the same in all files
150 // If you change this in any script, change it in all of them, please. It works a lot better that way.
151
152 // This is code based on Version 0.50 01-30-2014
153 // For version history, see file revisions.txt
154 //
155 // LICENSE
156 /////////////////////////////////////////////////////////////////////
157 // This code is licensed as Creative Commons Attribution/NonCommercial/Share Alike
158 // See http://creativecommons.org/liceses/by-nc-sa/3.0/
159 // Noncommercial -- You may not use this work for commercial purposes, i.e., you cannot sell this script in any form, including derivatives.
160 // If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one.
161 // This means that you cannot sell this or derivative code by itself, but you may share and use this code in any object or virtual world.
162 // You must attribute authorship in the original scripts to Ferd Frederix and Xundra Snowpaw, and leave this notice intact.
163 // You do not have to give back to the community any changes you make, however, code changes would be greatly appreciated!
164 //
165 // Exception: I am allowing this script to be used in an original build and sold with the build.
166 // You are not selling the script, you are selling the build. If you want to sell these scripts, write your own or use the original at http://code.google.com/p/xspets/
167 // Note: Xundra Snowpaw's license was 'New BSD' license and adding additional licenses is allowed.
168
169 // Based on code from Xundra Snowpaw
170 // New BSD License: http://www.opensource.org/licenses/bsd-license.php
171 // Copyright (c) 2010, Xundra Snowpaw
172 // All rights reserved.
173 // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
174
175 //* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
176 //* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer
177 // in the documentationand/or other materials provided with the distribution.
178
179 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
180 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
181 // BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
182 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
183 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
184 // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
185 ////////////////////////////////////////////////////////////////////
186
187 // DEBUG - lets you see and hear wtf is happening
188 integer debug = FALSE; // set to TRUE TO hear a lot of chat
189
190
191 // This section has a few tuneable items that MUST be changed for any new pet
192
193 // SECURITY
194 string SECRET_PASSWORD = "top secret string"; // must use a password unique to any species of animal, when ENCRYPT= TRUE. Otherwise you will find Pet type A fucking pet type B.
195 integer SECRET_NUMBER = 99999; // any number thats a secret, not necessary to change usually, this is used when pets are born and eggs are rezzed to establish a comm channel.
196 integer ENCRYPT = TRUE; // set to TRUE to encrypt all data, Some Opensim worlds prefer FALSE due to parsing bugs, TRUE is the most secure. If FALSE you MUST change the FOOD_CHANNEL and other channels for different pets. or they will literally fuck each other.
197
198 // if you add the UUID for your avatar here, you can change it later
199 // and other alts or friends can change it too, and all of you can work on these pets.
200 // If you leave it blank, only the creator of the root prim can work on these pets.
201 key YOUR_UUID = "";
202
203 // PET NAMES - YOU MUST CHANGE THEM HERE AND IN THE ROOT PRIM OF THE OBJECT - THEY MUST MATCH EXACTLY
204 /////////////////////////
205 string MaleName = "Troubot"; // Must be the name of your animal
206 string FemaleName = "Troubot"; // The name of the female pet, if a different shape or prim count. Can be the same as the Male for pets like the robot that are unisex.
207 string Egg = "Nut and Bolt"; // was 'XS Egg', must be the name of your egg
208 string Crate = "Transport Spaceship"; // was XS-Cryocrate, must be the name of the crate you package pets in
209 string HomeObject = "Home Flag"; // was "XS Home Object", must be the name of your Home Post indicator
210 string EggCup = "Toolbox"; // was "XS Egg Cup", must be the name of your egg holder
211 // any other object names are 'do not cares'.
212
213 // NOTHING NEEDS TO BE CHANGED BELOW, BUT CAN BE CHANGED IF YOU DO IT EVERYWHERE
214
215 // misc tunables
216 float GROWTH_AMOUNT = 0.10; // 10% size increase each day for MaxAge days = 200% (double size after 7 days)
217 integer MaxAge = 7; // stop growing in seven days. 10% growth compounded daily means that your pet will be 194% larger ( 2x, basically) in 7 days.
218 integer UNITS_OF_FOOD = 168; // food bowl food qty, used by food bowl only
219 float secs_to_grow = 86400; // grow daily = 86400 seconds
220 float FOOD_BOWL_SCAN_INTERVAL = 1800.0; // look for food every 3 hours
221 float fPregnancy = 172800.0; // how many seconds to lay an egg = 2 days or 48 hours.
222 float MALE_TIMEOUT = 900.0 ; // in seconds, female waits this long in one spot for a male to arrive
223 float SEX_WAIT = 10800.0; // How often they desire sex = 3 hours
224 float fDaysToAdult = 7; // 7 days to become old enough to breed.
225 integer SECONDS_BETWEEN_FOOD_NORMAL = 14400; // number of seconds to get hungry = 4 hours
226 integer SECONDS_BETWEEN_FOOD_HUNGRY = 3600; // number of seconds before hunger count increases = 1 hour
227 integer MAXIMUM_HUNGER = 30; // They die after a month with no food.
228
229
230 // I control versions by Subversion Source Code Control. But the updater needs a version numbert in world.
231 // This is the Protocol version. If you change this, then all pets with a lower version will be updated by the updater
232 float VERSION = 0.50;
233
234
235
236 // the leg sizes are safe to leave alone or set to 0 if you use a thin base prim, these are from the original Quail
237 float LegLength = 0.064; // length of pet leg??? - not sure
238 float LegOffset = 0.052399; // This is added to the Post Z to position the pet
239
240 // the following are global constants and do not need to be changed
241 // Prim animation linkmessages are sent by scripts on Link Message number 1
242 // The strings are the names of the animations that are recorded.
243 // No need to change them unless you want to change names of the animations when you run the prim animator, or you add additional link messages
244 // If your pet walks, you need to record these names and save them in the notecard
245 //
246 // Example:
247 // llMessageLinked(LINK_SET, LINK_ANIMATE, ANI_STAND, "");
248 // The above line will play the pre-recorded 'stand up' animation "stand" using the animator script.
249 // The following animations are used in the pet. You can add your own.
250
251 string ANI_STAND = "stand"; // default standing animation
252 string ANI_WALKL = "left"; // triggers Left foot and Right arm walk animation
253 string ANI_WALKR = "right"; // triggers Right foot and Left arm walk animation
254 string ANI_SLEEP = "sleep"; // Sleeping
255 string ANI_WAVE = "wave"; // Calling for sex, needs help with food, etc.
256
257 // Channel assignments
258 // if you change any of these constants, change it everywhere and in the list in XS_Debug so it can print them
259 // If you turn encryption FALSE, you MUST change these between species of pets are they will fuck with each other. Literally.
260
261 integer FOOD_CHANNEL = -999191;
262 integer ANIMAL_CHANNEL = -999192;
263 integer EGG_CHANNEL = -999193;
264 integer HOME_CHANNEL = -999194;
265 integer BOX_CHANNEL = -999195;
266 integer ACC_CHANNEL = -999196;
267 integer UPDATE_CHANNEL = -999197;
268 integer API_CHANNEL = -999198;
269
270 // global link messages to control the animal, never any need to change these.
271 // They are exposed here so they will be the same everywhere. This uses a bit of RAM, but who cares?
272
273 integer LINK_ANIMATE = 1; // messages on num 1 are assumed to be directed at the prim animator.
274 integer DECREASE_FOOD = 100; // used in the food bowl.
275 integer LINK_AGE_START = 800; // when pety is rezzed and secret_number is sent by brain to breeder, eater and infomatic get booted up
276 integer LINK_TEXTURE = 801; // ask for a new texture, or paint a color
277 integer LINK_BREEDNAME = 802; // the name of the pet texture from the texture server notecard
278 integer LINK_FOOD_CONSUME = 900; // from movement to brain when close to food, brain then consumes a random amount up to 10000
279 integer LINK_FOODMINUS = 901; // xs_brain receives FOOD_CONSUME, decrement hunger (eat)
280 integer LINK_HUNGRY = 903; // sent by eater (string)hunger_amount, checks each hour
281 integer LINK_HAMOUNT = 904; // hunger_amount = (integer)str,m updates the hunger amount in scripts
282 integer LINK_SET_HOME = 910; // loc ^ dist
283 integer LINK_MOVER = 911; // tell mover to rest for str seconds
284 integer LINK_FOODIE_CLR = 920; // clear all food_bowl_keys and contents
285 integer LINK_FOODIE = 921; // send FOOD_LOCATION coordinates to movement
286 integer LINK_COLOR1 = 930; // colour1
287 integer LINK_COLOR2 = 931; // colour2
288 integer LINK_SEX = 932; // sex
289 integer LINK_SHINE = 933; // shine
290 integer LINK_GLOW = 934; // glow
291 integer LINK_GEN = 935; // generation
292 integer LINK_RESET_SIZE = 936; // reset size to 1
293 integer LINK_MAGE = 940; // xs_brain sends, xs_ager consumes, adds str to age, if older than 7 days, will grow the animal
294 integer LINK_DAYTIME = 941; // xs_ager consumes, starts a timer of 86,400 seconds in xs_ager
295 integer LINK_GET_AGE = 942; // get age from xs_ager and sent it on channel 943
296 integer LINK_PUT_AGE = 943; // print age from xs_ager
297 integer LINK_PACKAGE = 950; // look for a cryo_crate
298 integer LINK_SEEK_FEMALE = 960; // MALE_BREED_CALL
299 integer LINK_MALE_BREED_CALL = 961; // triggered by LINK_SEEK_FEMALE
300 integer LINK_SIGNAL_ELIGIBLE = 962; // sent by female when hears LINK_MALE_BREED_CALL
301 integer LINK_FEMALE_ELIGIBLE = 963; // sent when it hears in chat FEMALE_ELIGIBLE
302 integer LINK_CALL_MALE = 964; // if LINK_FEMALE_ELIGIBLE && looking_for_female
303 integer LINK_MALE_ON_THE_WAY = 965; // triggered by LINK_CALL_MALE
304 integer LINK_FEMALE_LOCATION = 966; // female location, sends coordinates of a female
305 integer LINK_RQST_BREED = 967; // sent when close enough to male/female
306 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.
307 integer LINK_MALE_INFO = 969; // Breeding failed, sent info
308 integer LINK_LAY_EGG = 970; // Rez Object(Egg...
309 integer LINK_BREED_FAIL = 971; // key = father, failed, timed out
310 integer LINK_PREGNANT = 972; // chick is preggers
311 integer LINK_SOUND_OFF= 974; // sound is off
312 integer LINK_SOUND_ON= 973; // sound is on
313 integer LINK_SLEEPING = 990; // close eyes
314 integer LINK_UNSLEEPING = 991; // open eyes
315 integer LINK_SOUND = 1001; // plays a sound if enabled
316 integer LINK_SPECIAL = 1010; // xs_special, if str = "Normal", removes script
317 integer LINK_EFFECTS_ON = 2000; // particle effects in the packger
318 integer LINK_PREGNANCY_TIME = 5000; // in seconds as str
319 integer LINK_SLEEP = 7999; // disable sleep by parameter
320 integer LINK_TIMER = 8000; // scan for food bowl about every 1800 seconds
321 integer LINK_DIE = 9999; // death
322
323 string Copyright = " (c)2014 by Ferd Frederix"; // You cannot change this line, but you can change the code that prints it!
324 // See License agreements above.
325 // Attribution is required, as these files are copyrighted.
326
327
328 DEBUG ( string msg){
329 if(debug) {
330 llOwnerSay(llGetScriptName() + ":" + msg);
331 }
332 }
333
334
335
336 ///////// end global Link constants ////////
337
338 // END OF COPIED CODE
339
340
341
342
343
344
345
346
347
348
349 // tunable numbers to help you debug:
350
351 // put any commands you want to ignore here, this reduces spam.
352
353 list ignore = [
354 "left" , // animate prim
355 "right",
356 "stand",
357 1001, // this is LINK_SOUND
358 "blink",
359 "eye"
360 ];
361
362
363 // You can leave the rest alone:
364
365 // this must match and channel you might have changed, this is rarely done.
366 // list to print name instead of number for listener channels
367 list channels = [
368 "FOOD_CHANNEL" , -999191,
369 "ANIMAL_CHANNEL" , -999192,
370 "EGG_CHANNEL" , -999193,
371 "HOME_CHANNEL" , -999194,
372 "BOX_CHANNEL" , -999195,
373 "ACC_CHANNEL" , -999196,
374 "UPDATE_CHANNEL" , -999197,
375 "API_CHANNEL", -999198
376 ];
377
378
379
380 // list to print name instead of number of link messages. If you add a link message, it is a good idea to add it here, too
381 list messages = [
382 " LINK_ANIMATE", 1,
383 " DECREASE_FOOD", 100,
384 " LINK_AGE_START " , 800,
385 " LINK_TEXTURE ", 801,
386 " LINK_FOOD_CONSUME " , 900,
387 " LINK_FOODMINUS " , 901,
388 " LINK_HUNGRY " , 903,
389 " LINK_HAMOUNT " , 904,
390 " LINK_SET_HOME " , 910,
391 " LINK_MOVER " , 911,
392 " LINK_FOODIE_CLR " , 920,
393 " LINK_FOODIE " , 921,
394 " LINK_COLOR1 " , 930,
395 " LINK_COLOR2 " , 931,
396 " LINK_SEX " , 932,
397 " LINK_SHINE " , 933,
398 " LINK_GLOW " , 934,
399 " LINK_GEN " , 935,
400 " LINK_MAGE " , 940,
401 " LINK_DAYTIME " , 941,
402 " LINK_GET_AGE " , 942,
403 " LINK_PUT_AGE " , 943,
404 " LINK_PACKAGE " , 950,
405 " LINK_SEEK_FEMALE " , 960,
406 " LINK_MALE_BREED_CALL " , 961,
407 " LINK_SIGNAL_ELIGIBLE" , 962,
408 " LINK_FEMALE_ELIGIBLE " , 963,
409 " LINK_CALL_MALE " , 964,
410 " LINK_MALE_ON_THE_WAY " , 965,
411 " LINK_FEMALE_LOCATION " , 966,
412 " LINK_CALL_MALE_INFO " , 968,
413 " LINK_RQST_BREED ", 967,
414 " LINK_MALE_INFO " , 969,
415 " LINK_LAY_EGG " , 970,
416 " LINK_BREED_FAIL " , 971,
417 " LINK_PREGNANT " , 972,
418 " LINK_SOUND_ON ", 973,
419 " LINK_SOUND_OFF ", 974,
420 " LINK_SLEEPING " , 990,
421 " LINK_UNSLEEPING " , 991,
422 " LINK_SOUND " , 1001,
423 " LINK_SPECIAL " , 1010,
424 " LINK_EFFECTS_ON", 2000,
425 " LINK_PREGNANCY_TIME " , 5000,
426 " LINK_SLEEP " , 7999,
427 " LINK_TIMER " , 8000,
428 " LINK_DIE " , 9999
429 ];
430
431
432
433 // DON'T CHANGE THE FOLLOWING! (Unless you know what you are doing!)
434
435 integer XTEA_DELTA = 0x9E3779B9; // (sqrt(5) - 1) * 2^31
436 integer xtea_num_rounds = 6;
437 list xtea_key = [0, 0, 0, 0];
438
439 integer hex2int(string hex) {
440 if(llGetSubString(hex,0,1) == "0x")
441 return (integer)hex;
442 if(llGetSubString(hex,0,0) == "x")
443 return (integer)("0"+hex);
444 return(integer)("0x"+hex);
445 }
446
447
448 // Convers any string to a 32 char MD5 string and then to a list of
449 // 4 * 32 bit integers = 128 bit Key. MD5 ensures always a specific
450 // 128 bit key is generated for any string passed.
451 list xtea_key_from_string( string str )
452 {
453 str = llMD5String(str,0); // Use Nonce = 0
454 return [ hex2int(llGetSubString( str, 0, 7)),
455 hex2int(llGetSubString( str, 8, 15)),
456 hex2int(llGetSubString( str, 16, 23)),
457 hex2int(llGetSubString( str, 24, 31))];
458 }
459
460 // Encipher two integers and return the result as a 12-byte string
461 // containing two base64-encoded integers.
462 string xtea_encipher( integer v0, integer v1 )
463 {
464 integer num_rounds = xtea_num_rounds;
465 integer sum = 0;
466 do {
467 // LSL does not have unsigned integers, so when shifting right we
468 // have to mask out sign-extension bits.
469 v0 += (((v1 << 4) ^ ((v1 >> 5) & 0x07FFFFFF)) + v1) ^ (sum + llList2Integer(xtea_key, sum & 3));
470 sum += XTEA_DELTA;
471 v1 += (((v0 << 4) ^ ((v0 >> 5) & 0x07FFFFFF)) + v0) ^ (sum + llList2Integer(xtea_key, (sum >> 11) & 3));
472
473 } while( num_rounds = ~-num_rounds );
474 //return only first 6 chars to remove "=="'s and compact encrypted text.
475 return llGetSubString(llIntegerToBase64(v0),0,5) +
477 }
478
479 // Decipher two base64-encoded integers and return the FIRST 30 BITS of
480 // each as one 10-byte base64-encoded string.
481 string xtea_decipher( integer v0, integer v1 )
482 {
483 integer num_rounds = xtea_num_rounds;
484 integer sum = XTEA_DELTA*xtea_num_rounds;
485 do {
486 // LSL does not have unsigned integers, so when shifting right we
487 // have to mask out sign-extension bits.
488 v1 -= (((v0 << 4) ^ ((v0 >> 5) & 0x07FFFFFF)) + v0) ^ (sum + llList2Integer(xtea_key, (sum>>11) & 3));
489 sum -= XTEA_DELTA;
490 v0 -= (((v1 << 4) ^ ((v1 >> 5) & 0x07FFFFFF)) + v1) ^ (sum + llList2Integer(xtea_key, sum & 3));
491 } while( num_rounds = ~-num_rounds );
492
493 return llGetSubString(llIntegerToBase64(v0), 0, 4) +
495 }
496
497 // Encrypt a full string using XTEA.
498 string xtea_encrypt_string( string str ){
499 if(! ENCRYPT)
500 return str;
501
502 // encode string
503 str = llStringToBase64(str);
504 // remove trailing =s so we can do our own 0 padding
505 integer i = llSubStringIndex( str, "=" );
506 if( i != -1 )
507 str = llDeleteSubString( str, i, -1 );
508
509 // we don't want to process padding, so get length before adding it
510 integer len = llStringLength(str);
511
512 // zero pad
513 str += "AAAAAAAAAA=";
514
515 string result;
516 i = 0;
517
518 do {
519 // encipher 30 (5*6) bits at a time.
520 result += xtea_encipher(llBase64ToInteger(llGetSubString(str, i, i + 4) + "A="), llBase64ToInteger(llGetSubString(str, i+5, i + 9) + "A="));
521 i+=10;
522 } while( i < len );
523
524 return result;
525 }
526
527 // Decrypt a full string using XTEA
528 string xtea_decrypt_string( string str ) {
529 if(! ENCRYPT)
530 return str;
531
532 integer len = llStringLength(str);
533 integer i=0;
534 string result;
535 //llOwnerSay(str);
536 do {
537 integer v0;
538 integer v1;
539
540 v0 = llBase64ToInteger(llGetSubString(str, i, i + 5) + "==");
541 i+= 6;
542 v1 = llBase64ToInteger(llGetSubString(str, i, i + 5) + "==");
543 i+= 6;
544
545 result += xtea_decipher(v0, v1);
546 } while( i < len );
547
548 // Replace multiple trailing zeroes with a single one
549
550 i = llStringLength(result) - 1;
551 while( llGetSubString(result, i - 1, i) == "AA" ){
552 result = llDeleteSubString(result, i, i);
553 i--;
554 }
555 i = llStringLength(result) - 1;
556 // while(llGetSubString(result, i, i + 1) == "A" ) {
557 // i--;
558 // }
559 result = llGetSubString(result, 0, i+1);
560 i = llStringLength(result);
561 integer mod = i%4; //Depending on encoded length diffrent appends are needed
562 if(mod == 1) result += "A==";
563 else if(mod == 2 ) result += "==";
564 else if(mod == 3) result += "=";
565
566 return llBase64ToString(result);
567 }
568
569
570 ///////////////// Main code bgins /////////////////
571
572 default
573 {
575 {
576 xtea_key = xtea_key_from_string(SECRET_PASSWORD);
577 llListen(FOOD_CHANNEL,"","","");
578 llListen(ANIMAL_CHANNEL,"","","");
579 llListen(HOME_CHANNEL,"","","");
580 llListen(BOX_CHANNEL,"","","");
581 llListen(ACC_CHANNEL,"","","");
582 llListen(UPDATE_CHANNEL,"","","");
583 llListen(EGG_CHANNEL,"","","");
584 llListen(API_CHANNEL,"","","");
585 }
586
587
588
589 listen(integer channel,string name, key id, string message)
590 {
591 integer index = llListFindList(channels,[channel]); // see if a valid channel
592 string aname = "unkown";
593 if(index >= 0)
594 {
595 aname = llList2String(channels,index-1);
596 }
597 if(channel == API_CHANNEL || channel == HOME_CHANNEL)
598 llOwnerSay(llGetObjectName() + ":channel:" + aname + ":" + message ); // API is not encrypted
599 else
600 llOwnerSay(llGetObjectName() + ":channel:" + aname + ":" + xtea_decrypt_string(message) );
601 }
602
603
604 link_message(integer sender_num, integer num, string str, key id)
605 {
606 integer index = llListFindList(ignore,[str]); // see if a valid string
607 if(index >= 0)
608 return;
609
610 index = llListFindList(ignore,[num]); // see if a valid command
611 if(index >= 0)
612 return;
613
614
615 index = llListFindList(messages,[num]); // see if a valid channel
616 string aname = "*unknown channel:" + (string) num + ", please update the list in xs_Debug";
617 if(index >= 0)
618 {
619 aname = llList2String(messages,index-1);
620 }
621
622 llOwnerSay(llGetObjectName() + ":" + aname + " : string:" + str + ": key:" + (string) id);
623
624 }
625
626 touch_start(integer total_number)
627 {
628 llSay(0, "xs_Debug is loaded into this item. Do not forget to remove it.");
629 }
630
631 on_rez(integer param)
632 {
634 }
635 }

XS Pet Robot

XS Pet xs_eye script

Category: XS Pet
By : Ferd Frederix
Created: 2013-09-06 Edited: 2015-07-24
Worlds: Second Life


This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1
2 // xs_eye script
3
4 // blinking eye plug in script.lsl
5 // Use this with eyes made by the Gif2SL converter
6 /////////////////////////////////////////////////////////////////////
7 // This code is licensed as Creative Commons Attribution/NonCommercial/Share Alike
8
9 // See http://creativecommons.org/licenses/by-nc-sa/3.0/
10 // Noncommercial -- You may not use this work for commercial purposes
11 // If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one.
12 // This means that you cannot sell this code but you may share this code.
13 // You must attribute authorship to me and leave this notice intact.
14 //
15 // Exception: I am allowing this script to be sold inside an original build.
16 // You are not selling the script, you are selling the build.
17 // Ferd Frederix
18
19
20 // Put any texture converted by gif_2_SL_animation_v0.6.exe into a prim with this script to get it to play back automatically as a movie
21 //
22
23 integer nTextures;
24
25 integer animOn = TRUE; //Set to FALSE and call initAnim() again to stop the animation.
26 list effects = [LOOP]; // LOOP for GIF89 movies
27 integer movement = 0;
28 integer face = ALL_SIDES; //Number representing the side to activate the animation on.
29 integer sideX = 1; //Represents how many horizontal images (frames) are contained in your texture.
30 integer sideY = 1; //Same as sideX, except represents vertical images (frames).
31 float start = 0.0; //Frame to start animation on. (0 to start at the first frame of the texture)
32 float length = 0.0; //Number of frames to animate, set to 0 to animate all frames.
33 float speed = 10.0; //Frames per second to play.
34
35
36 integer i;
37
38 fetch()
39 {
43
45 llSetTexture(texture,ALL_SIDES);
46
47 llSleep(llFrand(5));
48
49 list data = llParseString2List(texture1,[";"],[]);
50 string X = llList2String(data,1);
51 string Y = llList2String(data,2);
52 string Z = llList2String(data,3);
53
54 sideX = (integer) X;
55 sideY = (integer) Y;
56 speed = (float) Z;
57
58 float tot = (float) (sideX * sideY);
59
60 llSetTextureAnim(ANIM_ON|LOOP,ALL_SIDES,sideX,sideY,start,length,speed);
61 llSetTexture(texture1,ALL_SIDES);
62 llSetTimerEvent(tot/10);
63 }
64
65
66 default
67 {
69 {
71 }
72 // touch the prim to switch to a pair of flipping textures, one of them a movie
74 {
75 i+=2;
76 if(i >= nTextures)
77 {
78 i = 0;
79 }
80 }
81
82 timer()
83 {
84 fetch();
85 }
86
87 }

XS Pet Robot

XS Pet xs_sleep

Category: XS Pet
By : Ferd Frederix
Created: 2013-09-06 Edited: 2015-07-24
Worlds: Second Life


This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1
2 // xs_sleep
3
4 // Particle plug in for XS_Pets.
5 // place this in the head of any animal. When it falls asleep, it will spit out Zzzzs
6 // only use this with xs_animated_eye script, as the xs_two_texture eye script has this built-in
7
8 // 9-17-3012 - made it so the eyes black out when sleeping
9
10 // tunables:
11 string texture = "Z"; // Texture used for particles. Texture must be in prim's inventory.
12 // thanks to Semi Sixpence for spotting this was 'key'
13 // could be key texture "SOME key copied from inventory but not a name";
14
15
16
17
18
19
20
21 // START OF COPIED file 'Global Constants.txt' from the Debug folder. It has to be the same in all files
22 // If you change this in any script, change it in all of them, please. It works a lot better that way.
23
24 // This is code based on Version 0.50 01-30-2014
25 // For version history, see file revisions.txt
26 //
27 // LICENSE
28 /////////////////////////////////////////////////////////////////////
29 // This code is licensed as Creative Commons Attribution/NonCommercial/Share Alike
30 // See http://creativecommons.org/liceses/by-nc-sa/3.0/
31 // Noncommercial -- You may not use this work for commercial purposes, i.e., you cannot sell this script in any form, including derivatives.
32 // If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one.
33 // This means that you cannot sell this or derivative code by itself, but you may share and use this code in any object or virtual world.
34 // You must attribute authorship in the original scripts to Ferd Frederix and Xundra Snowpaw, and leave this notice intact.
35 // You do not have to give back to the community any changes you make, however, code changes would be greatly appreciated!
36 //
37 // Exception: I am allowing this script to be used in an original build and sold with the build.
38 // You are not selling the script, you are selling the build. If you want to sell these scripts, write your own or use the original at http://code.google.com/p/xspets/
39 // Note: Xundra Snowpaw's license was 'New BSD' license and adding additional licenses is allowed.
40
41 // Based on code from Xundra Snowpaw
42 // New BSD License: http://www.opensource.org/licenses/bsd-license.php
43 // Copyright (c) 2010, Xundra Snowpaw
44 // All rights reserved.
45 // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
46
47 //* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
48 //* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer
49 // in the documentationand/or other materials provided with the distribution.
50
51 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
52 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
53 // BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
54 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
55 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
56 // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
57 ////////////////////////////////////////////////////////////////////
58
59 // DEBUG - lets you see and hear wtf is happening
60 integer debug = FALSE; // set to TRUE TO hear a lot of chat
61
62
63 // This section has a few tuneable items that MUST be changed for any new pet
64
65 // SECURITY
66 string SECRET_PASSWORD = "top secret string"; // must use a password unique to any species of animal, when ENCRYPT= TRUE. Otherwise you will find Pet type A fucking pet type B.
67 integer SECRET_NUMBER = 99999; // any number thats a secret, not necessary to change usually, this is used when pets are born and eggs are rezzed to establish a comm channel.
68 integer ENCRYPT = TRUE; // set to TRUE to encrypt all data, Some Opensim worlds prefer FALSE due to parsing bugs, TRUE is the most secure. If FALSE you MUST change the FOOD_CHANNEL and other channels for different pets. or they will literally fuck each other.
69
70 // if you add the UUID for your avatar here, you can change it later
71 // and other alts or friends can change it too, and all of you can work on these pets.
72 // If you leave it blank, only the creator of the root prim can work on these pets.
73 key YOUR_UUID = "";
74
75 // PET NAMES - YOU MUST CHANGE THEM HERE AND IN THE ROOT PRIM OF THE OBJECT - THEY MUST MATCH EXACTLY
76 /////////////////////////
77 string MaleName = "Troubot"; // Must be the name of your animal
78 string FemaleName = "Troubot"; // The name of the female pet, if a different shape or prim count. Can be the same as the Male for pets like the robot that are unisex.
79 string Egg = "Nut and Bolt"; // was 'XS Egg', must be the name of your egg
80 string Crate = "Transport Spaceship"; // was XS-Cryocrate, must be the name of the crate you package pets in
81 string HomeObject = "Home Flag"; // was "XS Home Object", must be the name of your Home Post indicator
82 string EggCup = "Toolbox"; // was "XS Egg Cup", must be the name of your egg holder
83 // any other object names are 'do not cares'.
84
85 // NOTHING NEEDS TO BE CHANGED BELOW, BUT CAN BE CHANGED IF YOU DO IT EVERYWHERE
86
87 // misc tunables
88 float GROWTH_AMOUNT = 0.10; // 10% size increase each day for MaxAge days = 200% (double size after 7 days)
89 integer MaxAge = 7; // stop growing in seven days. 10% growth compounded daily means that your pet will be 194% larger ( 2x, basically) in 7 days.
90 integer UNITS_OF_FOOD = 168; // food bowl food qty, used by food bowl only
91 float secs_to_grow = 86400; // grow daily = 86400 seconds
92 float FOOD_BOWL_SCAN_INTERVAL = 1800.0; // look for food every 3 hours
93 float fPregnancy = 172800.0; // how many seconds to lay an egg = 2 days or 48 hours.
94 float MALE_TIMEOUT = 900.0 ; // in seconds, female waits this long in one spot for a male to arrive
95 float SEX_WAIT = 10800.0; // How often they desire sex = 3 hours
96 float fDaysToAdult = 7; // 7 days to become old enough to breed.
97 integer SECONDS_BETWEEN_FOOD_NORMAL = 14400; // number of seconds to get hungry = 4 hours
98 integer SECONDS_BETWEEN_FOOD_HUNGRY = 3600; // number of seconds before hunger count increases = 1 hour
99 integer MAXIMUM_HUNGER = 30; // They die after a month with no food.
100
101
102 // I control versions by Subversion Source Code Control. But the updater needs a version numbert in world.
103 // This is the Protocol version. If you change this, then all pets with a lower version will be updated by the updater
104 float VERSION = 0.50;
105
106
107
108 // the leg sizes are safe to leave alone or set to 0 if you use a thin base prim, these are from the original Quail
109 float LegLength = 0.064; // length of pet leg??? - not sure
110 float LegOffset = 0.052399; // This is added to the Post Z to position the pet
111
112 // the following are global constants and do not need to be changed
113 // Prim animation linkmessages are sent by scripts on Link Message number 1
114 // The strings are the names of the animations that are recorded.
115 // No need to change them unless you want to change names of the animations when you run the prim animator, or you add additional link messages
116 // If your pet walks, you need to record these names and save them in the notecard
117 //
118 // Example:
119 // llMessageLinked(LINK_SET, LINK_ANIMATE, ANI_STAND, "");
120 // The above line will play the pre-recorded 'stand up' animation "stand" using the animator script.
121 // The following animations are used in the pet. You can add your own.
122
123 string ANI_STAND = "stand"; // default standing animation
124 string ANI_WALKL = "left"; // triggers Left foot and Right arm walk animation
125 string ANI_WALKR = "right"; // triggers Right foot and Left arm walk animation
126 string ANI_SLEEP = "sleep"; // Sleeping
127 string ANI_WAVE = "wave"; // Calling for sex, needs help with food, etc.
128
129 // Channel assignments
130 // if you change any of these constants, change it everywhere and in the list in XS_Debug so it can print them
131 // If you turn encryption FALSE, you MUST change these between species of pets are they will fuck with each other. Literally.
132
133 integer FOOD_CHANNEL = -999191;
134 integer ANIMAL_CHANNEL = -999192;
135 integer EGG_CHANNEL = -999193;
136 integer HOME_CHANNEL = -999194;
137 integer BOX_CHANNEL = -999195;
138 integer ACC_CHANNEL = -999196;
139 integer UPDATE_CHANNEL = -999197;
140 integer API_CHANNEL = -999198;
141
142 // global link messages to control the animal, never any need to change these.
143 // They are exposed here so they will be the same everywhere. This uses a bit of RAM, but who cares?
144
145 integer LINK_ANIMATE = 1; // messages on num 1 are assumed to be directed at the prim animator.
146 integer DECREASE_FOOD = 100; // used in the food bowl.
147 integer LINK_AGE_START = 800; // when pety is rezzed and secret_number is sent by brain to breeder, eater and infomatic get booted up
148 integer LINK_TEXTURE = 801; // ask for a new texture, or paint a color
149 integer LINK_BREEDNAME = 802; // the name of the pet texture from the texture server notecard
150 integer LINK_FOOD_CONSUME = 900; // from movement to brain when close to food, brain then consumes a random amount up to 10000
151 integer LINK_FOODMINUS = 901; // xs_brain receives FOOD_CONSUME, decrement hunger (eat)
152 integer LINK_HUNGRY = 903; // sent by eater (string)hunger_amount, checks each hour
153 integer LINK_HAMOUNT = 904; // hunger_amount = (integer)str,m updates the hunger amount in scripts
154 integer LINK_SET_HOME = 910; // loc ^ dist
155 integer LINK_MOVER = 911; // tell mover to rest for str seconds
156 integer LINK_FOODIE_CLR = 920; // clear all food_bowl_keys and contents
157 integer LINK_FOODIE = 921; // send FOOD_LOCATION coordinates to movement
158 integer LINK_COLOR1 = 930; // colour1
159 integer LINK_COLOR2 = 931; // colour2
160 integer LINK_SEX = 932; // sex
161 integer LINK_SHINE = 933; // shine
162 integer LINK_GLOW = 934; // glow
163 integer LINK_GEN = 935; // generation
164 integer LINK_RESET_SIZE = 936; // reset size to 1
165 integer LINK_MAGE = 940; // xs_brain sends, xs_ager consumes, adds str to age, if older than 7 days, will grow the animal
166 integer LINK_DAYTIME = 941; // xs_ager consumes, starts a timer of 86,400 seconds in xs_ager
167 integer LINK_GET_AGE = 942; // get age from xs_ager and sent it on channel 943
168 integer LINK_PUT_AGE = 943; // print age from xs_ager
169 integer LINK_PACKAGE = 950; // look for a cryo_crate
170 integer LINK_SEEK_FEMALE = 960; // MALE_BREED_CALL
171 integer LINK_MALE_BREED_CALL = 961; // triggered by LINK_SEEK_FEMALE
172 integer LINK_SIGNAL_ELIGIBLE = 962; // sent by female when hears LINK_MALE_BREED_CALL
173 integer LINK_FEMALE_ELIGIBLE = 963; // sent when it hears in chat FEMALE_ELIGIBLE
174 integer LINK_CALL_MALE = 964; // if LINK_FEMALE_ELIGIBLE && looking_for_female
175 integer LINK_MALE_ON_THE_WAY = 965; // triggered by LINK_CALL_MALE
176 integer LINK_FEMALE_LOCATION = 966; // female location, sends coordinates of a female
177 integer LINK_RQST_BREED = 967; // sent when close enough to male/female
178 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.
179 integer LINK_MALE_INFO = 969; // Breeding failed, sent info
180 integer LINK_LAY_EGG = 970; // Rez Object(Egg...
181 integer LINK_BREED_FAIL = 971; // key = father, failed, timed out
182 integer LINK_PREGNANT = 972; // chick is preggers
183 integer LINK_SOUND_OFF= 974; // sound is off
184 integer LINK_SOUND_ON= 973; // sound is on
185 integer LINK_SLEEPING = 990; // close eyes
186 integer LINK_UNSLEEPING = 991; // open eyes
187 integer LINK_SOUND = 1001; // plays a sound if enabled
188 integer LINK_SPECIAL = 1010; // xs_special, if str = "Normal", removes script
189 integer LINK_EFFECTS_ON = 2000; // particle effects in the packger
190 integer LINK_PREGNANCY_TIME = 5000; // in seconds as str
191 integer LINK_SLEEP = 7999; // disable sleep by parameter
192 integer LINK_TIMER = 8000; // scan for food bowl about every 1800 seconds
193 integer LINK_DIE = 9999; // death
194
195 string Copyright = " (c)2014 by Ferd Frederix"; // You cannot change this line, but you can change the code that prints it!
196 // See License agreements above.
197 // Attribution is required, as these files are copyrighted.
198
199
200 DEBUG ( string msg){
201 if(debug) {
202 llOwnerSay(llGetScriptName() + ":" + msg);
203 }
204 }
205
206
207
208 ///////// end global Link constants ////////
209
210 // END OF COPIED CODE
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225 // Original Particle Script 0.4j
226 // Created by Ama Omega 3-7-2004
227 // Updated by Jopsy Pendragon 5-11-2004
228 // For classes/tutorials/tricks, visit the Particle Labratory in Teal
229 // Values marked with (*) are defaults.
230
231 // SECTION ONE: APPEARANCE -- These settings affect how each particle LOOKS.
232 integer glow = TRUE; // TRUE or FALSE(*)
233 vector startColor = <1,1,1>; // RGB color, black<0,0,0> to white<1,1,1>(*)
234 vector endColor = <1,1,1>; //
235 float startAlpha = 1.0; // 0.0 to 1.0(*), lower = more transparent
236 float endAlpha = 1.0; //
237 vector startSize = <0.1,0.1,0>; // <0.04,0.04,0>(min) to <10,10,0>(max>, <1,1,0>(*)
238 vector endSize = <.3,.3,0>; // (Z part of vector is discarded)
239
240
241 // SECTION TWO: FLOW -- These settings affect how Many, how Quickly, and for how Long particles are created.
242 // Note,
243 integer count = 1; // Number of particles created per burst, 1(*) to 4096
244 float rate = 1.0; // Delay between bursts of new particles, 0.0 to 60, 0.1(*)
245 float age = 5.0; // How long each particle lives, 0.1 to 60, 10.0(*)
246 float life = 0.0; // When to stop creating new particles. never stops if 0.0(*)
247
248 // SECTION THREE: PLACEMENT -- Where are new particles created, and what direction are they facing?
249 float radius = .30; // 0.0(default) to 64? Distance from Emitter where new particles are created.
250 float innerAngle = 0.75; // "spread", for all ANGLE patterns, 0(default) to PI
251 float outerAngle = 0.0; // "tilt", for ANGLE patterns, 0(default) to TWO_PI, can use PI_BY_TWO or PI as well.
252 integer pattern = PSYS_SRC_PATTERN_ANGLE_CONE; // Choose one of the following:
253 // PSYS_SRC_PATTERN_EXPLODE (sends particles in all directions)
254 // PSYS_SRC_PATTERN_DROP (ignores minSpeed and maxSpeed. Don't bother with count>1 )
255 // PSYS_SRC_PATTERN_ANGLE_CONE (set innerangle/outerange to make rings/cones of particles)
256 // PSYS_SRC_PATTERN_ANGLE (set innerangle/outerangle to make flat fanshapes of particles)
257 vector omega = <0,0,0>; // How much to rotate the emitter around the <X,Y,Z> axises. <0,0,0>(*)
258 // Warning, there's no way to RESET the emitter direction once you use Omega!!
259 // You must attach the script to a new prim to clear the effect of omega.
260
261 // SECTION FOUR: MOVEMENT -- How do the particles move once they're created?
262 integer followSource = FALSE; // TRUE or FALSE(*), Particles move as the emitter moves, (TRUE disables radius!)
263 integer followVel = FALSE; // TRUE or FALSE(*), Particles rotate towards their direction
264 integer wind = FALSE; // TRUE or FALSE(*), Particles get blown away by wind in the sim
265 integer bounce = TRUE; // TRUE or FALSE(*), Make particles bounce on Z altitude of emitter
266 float minSpeed = 0.1; // 0.01 to ? Min speed each particle is spit out at, 1.0(*)
267 float maxSpeed = 0.2; // 0.01 to ? Max speed each particle is spit out at, 1.0(*)
268 vector push = <0,0,-0.3>; // Continuous force pushed on particles, use small settings for long lived particles
269 key target = ""; // Select a target for particles to arrive at when they die
270 // can be "self" (emitter), "owner" (you), "" or any prim/persons KEY.
271
272 // SECTION FIVE: Ama's "Create Short Particle Settings List"
273 integer enableoutput = FALSE; // If this is TRUE, clicking on your emitter prim will cause it to speak
274 // very terse "shorthand" version of your particle settings. You can cut'n'paste
275 // this abbreviated version into a call to llParticleSystem([ ]); in another script.
276 // Pros: Takes up far less scripting space, letting you focus on the rest of your code.
277 // Cons: makes tune your settings afterwards rather awkward
278
279 // === Don't muck about below this line unless you're comfortable with the LSL scripting language ====
280
281 // Script variables
282 integer flags;
283
284 updateParticles()
285 {
286 flags = 0;
287 if(target == "owner") target = llGetOwner();
288 if(target == "self") target = llGetKey();
289 if(glow) flags = flags | PSYS_PART_EMISSIVE_MASK;
290 if(bounce) flags = flags | PSYS_PART_BOUNCE_MASK;
291 if(startColor != endColor) flags = flags | PSYS_PART_INTERP_COLOR_MASK;
292 if(startSize != endSize) flags = flags | PSYS_PART_INTERP_SCALE_MASK;
293 if(wind) flags = flags | PSYS_PART_WIND_MASK;
294 if(followSource) flags = flags | PSYS_PART_FOLLOW_SRC_MASK;
295 if(followVel) flags = flags | PSYS_PART_FOLLOW_VELOCITY_MASK;
296 if(target != "") flags = flags | PSYS_PART_TARGET_POS_MASK;
297 list sys = [ PSYS_PART_MAX_AGE,age,
298 PSYS_PART_FLAGS,flags,
299 PSYS_PART_START_COLOR, startColor,
300 PSYS_PART_END_COLOR, endColor,
301 PSYS_PART_START_SCALE,startSize,
302 PSYS_PART_END_SCALE,endSize,
303 PSYS_SRC_PATTERN, pattern,
305 PSYS_SRC_ACCEL, push,
311 PSYS_SRC_INNERANGLE,innerAngle,
312 PSYS_SRC_OUTERANGLE,outerAngle,
313 PSYS_SRC_OMEGA, omega,
314 PSYS_SRC_MAX_AGE, life,
315 PSYS_SRC_TEXTURE, texture,
316 PSYS_PART_START_ALPHA, startAlpha,
317 PSYS_PART_END_ALPHA, endAlpha
318 ];
319 float newrate = rate;
320 if(newrate == 0.0) newrate=.01;
321 if( (age/rate)*count < 4096) llParticleSystem(sys);
322 else {
323 llInstantMessage(llGetOwner(),"Your particle system creates too many concurrent particles.");
324 llInstantMessage(llGetOwner(),"Reduce count or age, or increate rate.");
325 llParticleSystem( [ ] );
326 }
327 }
328
329
330
331 default
332 {
334 {
335 llParticleSystem( [ ] ); // no particles
336 }
337
338 on_rez(integer num)
339 {
341 }
342
343 link_message(integer sender, integer num, string str, key id)
344 {
345 if(num == 1 && str==ANI_SLEEP) {
346 llSetColor(<0,0,0>,ALL_SIDES); // black out the eyes
347 updateParticles();
348 }
349 else if(num == 1 && str == ANI_STAND) {
350 llParticleSystem( [ ] );
351 llSetColor(<1,1,1>,ALL_SIDES);
352 }
353 }
354
355 }

XS Pet Robot

XS Pet xs_texture-two eyes

Category: XS Pet
By : Ferd Frederix
Created: 2013-09-06 Edited: 2015-07-24
Worlds: Second Life


This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1
2 // xs_texture-two eyes
3
4
5 // the names of the textures for eyes that shut and close by flipping between them.
6 string OPEN = "eyes open"; // awake
7 string CLOSED = "eyes closed"; // sleeping
8 string DEAD = "eyes dead"; // could be a copy of eyes closed, or (X)(X)
9
10
11 string ANI_DIE = "death"; // a string taught to the pet by the animator when the animal is to die.
12 string ANI_SLEEP = "sleep"; // Sleeping
13 string ANI_STAND = "stand"; // default standing animation
14
15 integer flags;
16 // Original Particle Script 0.4j
17 // Created by Ama Omega 3-7-2004
18 // Updated by Jopsy Pendragon 5-11-2004
19 // For classes/tutorials/tricks, visit the Particle Labratory in Teal
20 // Values marked with (*) are defaults.
21
22 // SECTION ONE: APPEARANCE -- These settings affect how each particle LOOKS.
23 integer glow = TRUE; // TRUE or FALSE(*)
24 vector startColor = <1,1,1>; // RGB color, black<0,0,0> to white<1,1,1>(*)
25 vector endColor = <1,1,1>; //
26 float startAlpha = 1.0; // 0.0 to 1.0(*), lower = more transparent
27 float endAlpha = 1.0; //
28 vector startSize = <0.1,0.1,0>; // <0.04,0.04,0>(min) to <10,10,0>(max>, <1,1,0>(*)
29 vector endSize = <.3,.3,0>; // (Z part of vector is discarded)
30 key texture = "f9b67edf-d837-e507-361b-0d34f4c64396"; // Texture used for particles. Texture must be in prim's inventory.
31
32 // SECTION TWO: FLOW -- These settings affect how Many, how Quickly, and for how Long particles are created.
33 // Note,
34 integer count = 1; // Number of particles created per burst, 1(*) to 4096
35 float rate = 1.0; // Delay between bursts of new particles, 0.0 to 60, 0.1(*)
36 float age = 5.0; // How long each particle lives, 0.1 to 60, 10.0(*)
37 float life = 0.0; // When to stop creating new particles. never stops if 0.0(*)
38
39 // SECTION THREE: PLACEMENT -- Where are new particles created, and what direction are they facing?
40 float radius = .30; // 0.0(default) to 64? Distance from Emitter where new particles are created.
41 float innerAngle = 0.75; // "spread", for all ANGLE patterns, 0(default) to PI
42 float outerAngle = 0.0; // "tilt", for ANGLE patterns, 0(default) to TWO_PI, can use PI_BY_TWO or PI as well.
43 integer pattern = PSYS_SRC_PATTERN_ANGLE_CONE; // Choose one of the following:
44 // PSYS_SRC_PATTERN_EXPLODE (sends particles in all directions)
45 // PSYS_SRC_PATTERN_DROP (ignores minSpeed and maxSpeed. Don't bother with count>1 )
46 // PSYS_SRC_PATTERN_ANGLE_CONE (set innerangle/outerange to make rings/cones of particles)
47 // PSYS_SRC_PATTERN_ANGLE (set innerangle/outerangle to make flat fanshapes of particles)
48 vector omega = <0,0,0>; // How much to rotate the emitter around the <X,Y,Z> axises. <0,0,0>(*)
49 // Warning, there's no way to RESET the emitter direction once you use Omega!!
50 // You must attach the script to a new prim to clear the effect of omega.
51
52 // SECTION FOUR: MOVEMENT -- How do the particles move once they're created?
53 integer followSource = FALSE; // TRUE or FALSE(*), Particles move as the emitter moves, (TRUE disables radius!)
54 integer followVel = FALSE; // TRUE or FALSE(*), Particles rotate towards their direction
55 integer wind = FALSE; // TRUE or FALSE(*), Particles get blown away by wind in the sim
56 integer bounce = TRUE; // TRUE or FALSE(*), Make particles bounce on Z altitude of emitter
57 float minSpeed = 0.1; // 0.01 to ? Min speed each particle is spit out at, 1.0(*)
58 float maxSpeed = 0.2; // 0.01 to ? Max speed each particle is spit out at, 1.0(*)
59 vector push = <0,0,-0.3>; // Continuous force pushed on particles, use small settings for long lived particles
60 key target = ""; // Select a target for particles to arrive at when they die
61 // can be "self" (emitter), "owner" (you), "" or any prim/persons KEY.
62
63 list sys;
64
65 updateParticles()
66 {
67 flags = 0;
68 if(target == "owner") target = llGetOwner();
69 if(target == "self") target = llGetKey();
70 if(glow) flags = flags | PSYS_PART_EMISSIVE_MASK;
71 if(bounce) flags = flags | PSYS_PART_BOUNCE_MASK;
72 if(startColor != endColor) flags = flags | PSYS_PART_INTERP_COLOR_MASK;
73 if(startSize != endSize) flags = flags | PSYS_PART_INTERP_SCALE_MASK;
74 if(wind) flags = flags | PSYS_PART_WIND_MASK;
75 if(followSource) flags = flags | PSYS_PART_FOLLOW_SRC_MASK;
76 if(followVel) flags = flags | PSYS_PART_FOLLOW_VELOCITY_MASK;
77 if(target != "") flags = flags | PSYS_PART_TARGET_POS_MASK;
78 sys = [ PSYS_PART_MAX_AGE,age,
79 PSYS_PART_FLAGS,flags,
80 PSYS_PART_START_COLOR, startColor,
81 PSYS_PART_END_COLOR, endColor,
82 PSYS_PART_START_SCALE,startSize,
83 PSYS_PART_END_SCALE,endSize,
84 PSYS_SRC_PATTERN, pattern,
86 PSYS_SRC_ACCEL, push,
92 PSYS_SRC_INNERANGLE,innerAngle,
93 PSYS_SRC_OUTERANGLE,outerAngle,
94 PSYS_SRC_OMEGA, omega,
95 PSYS_SRC_MAX_AGE, life,
96 PSYS_SRC_TEXTURE, texture,
97 PSYS_PART_START_ALPHA, startAlpha,
98 PSYS_PART_END_ALPHA, endAlpha
99 ];
100 float newrate = rate;
101 if(newrate == 0.0) newrate=.01;
102 if( (age/rate)*count < 4096) llParticleSystem(sys);
103 else {
104 llInstantMessage(llGetOwner(),"Your particle system creates too many concurrent particles.");
105 llInstantMessage(llGetOwner(),"Reduce count or age, or increate rate.");
106 llParticleSystem( [ ] );
107 }
108 }
109
110
111
112 default
113 {
114
115 on_rez(integer startparam)
116 {
118 }
119
121 {
122 llSetTexture(OPEN, ALL_SIDES); // open
124 }
125
126
127 timer()
128 {
129 llSetTexture(CLOSED, ALL_SIDES); // closed
130 llSleep(llFrand(0.2) + .1); // sometimes blink a little faster, from 0.2 to 0.3
131 llSetTexture(OPEN, ALL_SIDES); // open
132 llSetTimerEvent(llFrand(3) + 3); // make them blink randomly
133 }
134
135
136 link_message(integer sender, integer num, string str, key id)
137 {
138 if(num == 1 && str == ANI_SLEEP )
139 {
140 llSetTexture(CLOSED, ALL_SIDES); //closed
141 updateParticles(); // turn on particle Zzzz's
142 llSetTimerEvent(0); // no blink
143 }
144
145 else if(num == 1 && str == ANI_STAND)
146 {
147 llParticleSystem( [] ); // turn off particle ZZZ's by sending an empty list
148 llSetTexture(OPEN, ALL_SIDES); //open
150
151 }
152 else if(num == 1 && str == ANI_DIE)
153 {
154 llSetTexture(DEAD ,ALL_SIDES) ; // dead eye (X)(X) texture
155 llParticleSystem( [ ] ); // turn off particle ZZZ's
156 llSetTimerEvent(0); // no blink
157 }
158 }
159 }

XS Pet Robot

XS Pet globe rotator

Category: XS Pet
By : Ferd Frederix
Created: 2013-09-06 Edited: 2015-07-24
Worlds: Second Life


This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1
2
3
4 default
5 {
7 {
8 // llSetTextureAnim() is a function that animates a texture on a face.
9 llSetTextureAnim(ANIM_ON | SMOOTH | LOOP, ALL_SIDES,0,1,1.0, 0.5,1);
10 // animate the script to scroll across all the faces.
11 }
12
13 }

XS Pet Robot

XS Pet

Category: XS Pet
By : Ferd Frederix
Created: 2013-09-06 Edited: 2015-07-24
Worlds: Second Life


This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1
2 // waving flag script
3 // Version 0.32 12-03-2011
4
5
6 // added ENCRYPT global variable
7
8 /////////////////////////////////////////////////////////////////////
9 // This code is licensed as Creative Commons Attribution/NonCommercial/Share Alike
10
11 // See http://creativecommons.org/licenses/by-nc-sa/3.0/
12 // Noncommercial -- You may not use this work for commercial purposes
13 // If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one.
14 // This means that you cannot sell this code but you may share this code.
15 // You must attribute authorship to me and leave this notice intact.
16 //
17 // Exception: I am allowing this script to be sold inside an original build.
18 // You are not selling the script, you are selling the build.
19 // Ferd Frederix
20
21 // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
22
23 //* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
24 //* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer
25 // in the documentationand/or other materials provided with the distribution.
26
27 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
28 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
29 // BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
32 // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 ////////////////////////////////////////////////////////////////////
34
35 // Put any texture converted by gif_2_SL_animation_v0.6.exe into a prim with this script to get it to play back automatically as a movie
36
37 integer animOn = TRUE; //Set to FALSE and call initAnim() again to stop the animation.
38 list effects = [LOOP]; // LOOP for GIF89 movies
39 integer movement = 0;
40 integer face = ALL_SIDES; //Number representing the side to activate the animation on.
41 integer sideX = 1; //Represents how many horizontal images (frames) are contained in your texture.
42 integer sideY = 1; //Same as sideX, except represents vertical images (frames).
43 float start = 0.0; //Frame to start animation on. (0 to start at the first frame of the texture)
44 float length = 0.0; //Number of frames to animate, set to 0 to animate all frames.
45 float speed = 10.0; //Frames per second to play.
46
47
48 fetch()
49 {
50 string texture = llGetInventoryName(INVENTORY_TEXTURE,0);
51 list data = llParseString2List(texture,[";"],[]);
52 string X = llList2String(data,1);
53 string Y = llList2String(data,2);
54 string Z = llList2String(data,3);
55
56 sideX = (integer) X;
57 sideY = (integer) Y;
58 speed = (float) Z;
59
60 float tot = (float) (sideX * sideY);
61
62 llSetTextureAnim(ANIM_ON|LOOP,ALL_SIDES,sideX,sideY,start,length,speed);
63 llSetTexture(texture,ALL_SIDES);
64 }
65
66
67 default
68 {
69 state_entry()
70 {
71 fetch();
72 }
73 }
74
75

XS Pet Robot

XS Pet xs_home

Category: XS Pet
By : Ferd Frederix
Created: 2013-09-06 Edited: 2015-07-24
Worlds: Second Life


This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1
2 // xs_home
3
4
5
6
7
8
9 // START OF COPIED file 'Global Constants.txt' from the Debug folder. It has to be the same in all files
10 // If you change this in any script, change it in all of them, please. It works a lot better that way.
11
12 // This is code based on Version 0.50 01-30-2014
13 // For version history, see file revisions.txt
14 //
15 // LICENSE
16 /////////////////////////////////////////////////////////////////////
17 // This code is licensed as Creative Commons Attribution/NonCommercial/Share Alike
18 // See http://creativecommons.org/liceses/by-nc-sa/3.0/
19 // Noncommercial -- You may not use this work for commercial purposes, i.e., you cannot sell this script in any form, including derivatives.
20 // If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one.
21 // This means that you cannot sell this or derivative code by itself, but you may share and use this code in any object or virtual world.
22 // You must attribute authorship in the original scripts to Ferd Frederix and Xundra Snowpaw, and leave this notice intact.
23 // You do not have to give back to the community any changes you make, however, code changes would be greatly appreciated!
24 //
25 // Exception: I am allowing this script to be used in an original build and sold with the build.
26 // You are not selling the script, you are selling the build. If you want to sell these scripts, write your own or use the original at http://code.google.com/p/xspets/
27 // Note: Xundra Snowpaw's license was 'New BSD' license and adding additional licenses is allowed.
28
29 // Based on code from Xundra Snowpaw
30 // New BSD License: http://www.opensource.org/licenses/bsd-license.php
31 // Copyright (c) 2010, Xundra Snowpaw
32 // All rights reserved.
33 // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
34
35 //* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
36 //* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer
37 // in the documentationand/or other materials provided with the distribution.
38
39 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
40 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
41 // BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
42 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
43 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
44 // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45 ////////////////////////////////////////////////////////////////////
46
47 // DEBUG - lets you see and hear wtf is happening
48 integer debug = FALSE; // set to TRUE TO hear a lot of chat
49
50
51 // This section has a few tuneable items that MUST be changed for any new pet
52
53 // SECURITY
54 string SECRET_PASSWORD = "top secret string"; // must use a password unique to any species of animal, when ENCRYPT= TRUE. Otherwise you will find Pet type A fucking pet type B.
55 integer SECRET_NUMBER = 99999; // any number thats a secret, not necessary to change usually, this is used when pets are born and eggs are rezzed to establish a comm channel.
56 integer ENCRYPT = TRUE; // set to TRUE to encrypt all data, Some Opensim worlds prefer FALSE due to parsing bugs, TRUE is the most secure. If FALSE you MUST change the FOOD_CHANNEL and other channels for different pets. or they will literally fuck each other.
57
58 // if you add the UUID for your avatar here, you can change it later
59 // and other alts or friends can change it too, and all of you can work on these pets.
60 // If you leave it blank, only the creator of the root prim can work on these pets.
61 key YOUR_UUID = "";
62
63 // PET NAMES - YOU MUST CHANGE THEM HERE AND IN THE ROOT PRIM OF THE OBJECT - THEY MUST MATCH EXACTLY
64 /////////////////////////
65 string MaleName = "Troubot"; // Must be the name of your animal
66 string FemaleName = "Troubot"; // The name of the female pet, if a different shape or prim count. Can be the same as the Male for pets like the robot that are unisex.
67 string Egg = "Nut and Bolt"; // was 'XS Egg', must be the name of your egg
68 string Crate = "Transport Spaceship"; // was XS-Cryocrate, must be the name of the crate you package pets in
69 string HomeObject = "Home Flag"; // was "XS Home Object", must be the name of your Home Post indicator
70 string EggCup = "Toolbox"; // was "XS Egg Cup", must be the name of your egg holder
71 // any other object names are 'do not cares'.
72
73 // NOTHING NEEDS TO BE CHANGED BELOW, BUT CAN BE CHANGED IF YOU DO IT EVERYWHERE
74
75 // misc tunables
76 float GROWTH_AMOUNT = 0.10; // 10% size increase each day for MaxAge days = 200% (double size after 7 days)
77 integer MaxAge = 7; // stop growing in seven days. 10% growth compounded daily means that your pet will be 194% larger ( 2x, basically) in 7 days.
78 integer UNITS_OF_FOOD = 168; // food bowl food qty, used by food bowl only
79 float secs_to_grow = 86400; // grow daily = 86400 seconds
80 float FOOD_BOWL_SCAN_INTERVAL = 1800.0; // look for food every 3 hours
81 float fPregnancy = 172800.0; // how many seconds to lay an egg = 2 days or 48 hours.
82 float MALE_TIMEOUT = 900.0 ; // in seconds, female waits this long in one spot for a male to arrive
83 float SEX_WAIT = 10800.0; // How often they desire sex = 3 hours
84 float fDaysToAdult = 7; // 7 days to become old enough to breed.
85 integer SECONDS_BETWEEN_FOOD_NORMAL = 14400; // number of seconds to get hungry = 4 hours
86 integer SECONDS_BETWEEN_FOOD_HUNGRY = 3600; // number of seconds before hunger count increases = 1 hour
87 integer MAXIMUM_HUNGER = 30; // They die after a month with no food.
88
89
90 // I control versions by Subversion Source Code Control. But the updater needs a version numbert in world.
91 // This is the Protocol version. If you change this, then all pets with a lower version will be updated by the updater
92 float VERSION = 0.50;
93
94
95
96 // the leg sizes are safe to leave alone or set to 0 if you use a thin base prim, these are from the original Quail
97 float LegLength = 0.064; // length of pet leg??? - not sure
98 float LegOffset = 0.052399; // This is added to the Post Z to position the pet
99
100 // the following are global constants and do not need to be changed
101 // Prim animation linkmessages are sent by scripts on Link Message number 1
102 // The strings are the names of the animations that are recorded.
103 // No need to change them unless you want to change names of the animations when you run the prim animator, or you add additional link messages
104 // If your pet walks, you need to record these names and save them in the notecard
105 //
106 // Example:
107 // llMessageLinked(LINK_SET, LINK_ANIMATE, ANI_STAND, "");
108 // The above line will play the pre-recorded 'stand up' animation "stand" using the animator script.
109 // The following animations are used in the pet. You can add your own.
110
111 string ANI_STAND = "stand"; // default standing animation
112 string ANI_WALKL = "left"; // triggers Left foot and Right arm walk animation
113 string ANI_WALKR = "right"; // triggers Right foot and Left arm walk animation
114 string ANI_SLEEP = "sleep"; // Sleeping
115 string ANI_WAVE = "wave"; // Calling for sex, needs help with food, etc.
116
117 // Channel assignments
118 // if you change any of these constants, change it everywhere and in the list in XS_Debug so it can print them
119 // If you turn encryption FALSE, you MUST change these between species of pets are they will fuck with each other. Literally.
120
121 integer FOOD_CHANNEL = -999191;
122 integer ANIMAL_CHANNEL = -999192;
123 integer EGG_CHANNEL = -999193;
124 integer HOME_CHANNEL = -999194;
125 integer BOX_CHANNEL = -999195;
126 integer ACC_CHANNEL = -999196;
127 integer UPDATE_CHANNEL = -999197;
128 integer API_CHANNEL = -999198;
129
130 // global link messages to control the animal, never any need to change these.
131 // They are exposed here so they will be the same everywhere. This uses a bit of RAM, but who cares?
132
133 integer LINK_ANIMATE = 1; // messages on num 1 are assumed to be directed at the prim animator.
134 integer DECREASE_FOOD = 100; // used in the food bowl.
135 integer LINK_AGE_START = 800; // when pety is rezzed and secret_number is sent by brain to breeder, eater and infomatic get booted up
136 integer LINK_TEXTURE = 801; // ask for a new texture, or paint a color
137 integer LINK_BREEDNAME = 802; // the name of the pet texture from the texture server notecard
138 integer LINK_FOOD_CONSUME = 900; // from movement to brain when close to food, brain then consumes a random amount up to 10000
139 integer LINK_FOODMINUS = 901; // xs_brain receives FOOD_CONSUME, decrement hunger (eat)
140 integer LINK_HUNGRY = 903; // sent by eater (string)hunger_amount, checks each hour
141 integer LINK_HAMOUNT = 904; // hunger_amount = (integer)str,m updates the hunger amount in scripts
142 integer LINK_SET_HOME = 910; // loc ^ dist
143 integer LINK_MOVER = 911; // tell mover to rest for str seconds
144 integer LINK_FOODIE_CLR = 920; // clear all food_bowl_keys and contents
145 integer LINK_FOODIE = 921; // send FOOD_LOCATION coordinates to movement
146 integer LINK_COLOR1 = 930; // colour1
147 integer LINK_COLOR2 = 931; // colour2
148 integer LINK_SEX = 932; // sex
149 integer LINK_SHINE = 933; // shine
150 integer LINK_GLOW = 934; // glow
151 integer LINK_GEN = 935; // generation
152 integer LINK_RESET_SIZE = 936; // reset size to 1
153 integer LINK_MAGE = 940; // xs_brain sends, xs_ager consumes, adds str to age, if older than 7 days, will grow the animal
154 integer LINK_DAYTIME = 941; // xs_ager consumes, starts a timer of 86,400 seconds in xs_ager
155 integer LINK_GET_AGE = 942; // get age from xs_ager and sent it on channel 943
156 integer LINK_PUT_AGE = 943; // print age from xs_ager
157 integer LINK_PACKAGE = 950; // look for a cryo_crate
158 integer LINK_SEEK_FEMALE = 960; // MALE_BREED_CALL
159 integer LINK_MALE_BREED_CALL = 961; // triggered by LINK_SEEK_FEMALE
160 integer LINK_SIGNAL_ELIGIBLE = 962; // sent by female when hears LINK_MALE_BREED_CALL
161 integer LINK_FEMALE_ELIGIBLE = 963; // sent when it hears in chat FEMALE_ELIGIBLE
162 integer LINK_CALL_MALE = 964; // if LINK_FEMALE_ELIGIBLE && looking_for_female
163 integer LINK_MALE_ON_THE_WAY = 965; // triggered by LINK_CALL_MALE
164 integer LINK_FEMALE_LOCATION = 966; // female location, sends coordinates of a female
165 integer LINK_RQST_BREED = 967; // sent when close enough to male/female
166 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.
167 integer LINK_MALE_INFO = 969; // Breeding failed, sent info
168 integer LINK_LAY_EGG = 970; // Rez Object(Egg...
169 integer LINK_BREED_FAIL = 971; // key = father, failed, timed out
170 integer LINK_PREGNANT = 972; // chick is preggers
171 integer LINK_SOUND_OFF= 974; // sound is off
172 integer LINK_SOUND_ON= 973; // sound is on
173 integer LINK_SLEEPING = 990; // close eyes
174 integer LINK_UNSLEEPING = 991; // open eyes
175 integer LINK_SOUND = 1001; // plays a sound if enabled
176 integer LINK_SPECIAL = 1010; // xs_special, if str = "Normal", removes script
177 integer LINK_EFFECTS_ON = 2000; // particle effects in the packger
178 integer LINK_PREGNANCY_TIME = 5000; // in seconds as str
179 integer LINK_SLEEP = 7999; // disable sleep by parameter
180 integer LINK_TIMER = 8000; // scan for food bowl about every 1800 seconds
181 integer LINK_DIE = 9999; // death
182
183 string Copyright = " (c)2014 by Ferd Frederix"; // You cannot change this line, but you can change the code that prints it!
184 // See License agreements above.
185 // Attribution is required, as these files are copyrighted.
186
187
188 DEBUG ( string msg){
189 if(debug) {
190 llOwnerSay(llGetScriptName() + ":" + msg);
191 }
192 }
193
194
195
196 ///////// end global Link constants ////////
197
198 // END OF COPIED CODE
199
200
201
202
203
204
205
206
207
208
209 // DON'T CHANGE THE FOLLOWING! (Unless you know what you are doing!)
210
211 integer XTEA_DELTA = 0x9E3779B9; // (sqrt(5) - 1) * 2^31
212 integer xtea_num_rounds = 6;
213 list xtea_key = [0, 0, 0, 0];
214
215 integer hex2int(string hex) {
216 if(llGetSubString(hex,0,1) == "0x")
217 return (integer)hex;
218 if(llGetSubString(hex,0,0) == "x")
219 return (integer)("0"+hex);
220 return(integer)("0x"+hex);
221 }
222
223
224 // Convers any string to a 32 char MD5 string and then to a list of
225 // 4 * 32 bit integers = 128 bit Key. MD5 ensures always a specific
226 // 128 bit key is generated for any string passed.
227 list xtea_key_from_string( string str )
228 {
229 str = llMD5String(str,0); // Use Nonce = 0
230 return [ hex2int(llGetSubString( str, 0, 7)),
231 hex2int(llGetSubString( str, 8, 15)),
232 hex2int(llGetSubString( str, 16, 23)),
233 hex2int(llGetSubString( str, 24, 31))];
234 }
235
236 // Encipher two integers and return the result as a 12-byte string
237 // containing two base64-encoded integers.
238 string xtea_encipher( integer v0, integer v1 )
239 {
240 integer num_rounds = xtea_num_rounds;
241 integer sum = 0;
242 do {
243 // LSL does not have unsigned integers, so when shifting right we
244 // have to mask out sign-extension bits.
245 v0 += (((v1 << 4) ^ ((v1 >> 5) & 0x07FFFFFF)) + v1) ^ (sum + llList2Integer(xtea_key, sum & 3));
246 sum += XTEA_DELTA;
247 v1 += (((v0 << 4) ^ ((v0 >> 5) & 0x07FFFFFF)) + v0) ^ (sum + llList2Integer(xtea_key, (sum >> 11) & 3));
248
249 } while( num_rounds = ~-num_rounds );
250 //return only first 6 chars to remove "=="'s and compact encrypted text.
251 return llGetSubString(llIntegerToBase64(v0),0,5) +
253 }
254
255 // Decipher two base64-encoded integers and return the FIRST 30 BITS of
256 // each as one 10-byte base64-encoded string.
257 string xtea_decipher( integer v0, integer v1 )
258 {
259 integer num_rounds = xtea_num_rounds;
260 integer sum = XTEA_DELTA*xtea_num_rounds;
261 do {
262 // LSL does not have unsigned integers, so when shifting right we
263 // have to mask out sign-extension bits.
264 v1 -= (((v0 << 4) ^ ((v0 >> 5) & 0x07FFFFFF)) + v0) ^ (sum + llList2Integer(xtea_key, (sum>>11) & 3));
265 sum -= XTEA_DELTA;
266 v0 -= (((v1 << 4) ^ ((v1 >> 5) & 0x07FFFFFF)) + v1) ^ (sum + llList2Integer(xtea_key, sum & 3));
267 } while( num_rounds = ~-num_rounds );
268
269 return llGetSubString(llIntegerToBase64(v0), 0, 4) +
271 }
272
273 // Encrypt a full string using XTEA.
274 string xtea_encrypt_string( string str )
275 {
276 if(! ENCRYPT)
277 return str;
278 // encode string
279 str = llStringToBase64(str);
280 // remove trailing =s so we can do our own 0 padding
281 integer i = llSubStringIndex( str, "=" );
282 if( i != -1 )
283 str = llDeleteSubString( str, i, -1 );
284
285 // we don't want to process padding, so get length before adding it
286 integer len = llStringLength(str);
287
288 // zero pad
289 str += "AAAAAAAAAA=";
290
291 string result;
292 i = 0;
293
294 do {
295 // encipher 30 (5*6) bits at a time.
296 result += xtea_encipher(llBase64ToInteger(llGetSubString(str, i, i + 4) + "A="), llBase64ToInteger(llGetSubString(str, i+5, i + 9) + "A="));
297 i+=10;
298 } while( i < len );
299
300 return result;
301 }
302
303 // Decrypt a full string using XTEA
304 string xtea_decrypt_string( string str ) {
305 if(! ENCRYPT)
306 return str;
307 integer len = llStringLength(str);
308 integer i=0;
309 string result;
310 //llOwnerSay(str);
311 do {
312 integer v0;
313 integer v1;
314
315 v0 = llBase64ToInteger(llGetSubString(str, i, i + 5) + "==");
316 i+= 6;
317 v1 = llBase64ToInteger(llGetSubString(str, i, i + 5) + "==");
318 i+= 6;
319
320 result += xtea_decipher(v0, v1);
321 } while( i < len );
322
323 // Replace multiple trailing zeroes with a single one
324
325 i = llStringLength(result) - 1;
326 while( llGetSubString(result, i - 1, i) == "AA" ){
327 result = llDeleteSubString(result, i, i);
328 i--;
329 }
330 i = llStringLength(result) - 1;
331 // while(llGetSubString(result, i, i + 1) == "A" ) {
332 // i--;
333 // }
334 result = llGetSubString(result, 0, i+1);
335 i = llStringLength(result);
336 integer mod = i%4; //Depending on encoded length diffrent appends are needed
337 if(mod == 1) result += "A==";
338 else if(mod == 2 ) result += "==";
339 else if(mod == 3) result += "=";
340
341 return llBase64ToString(result);
342 }
343
344 string base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
345
346
347 default
348 {
350 {
351 if(((integer) llGetObjectDesc()) == 0)
352 {
353 llOwnerSay("Distance set to 10 meters (default)");
354 llSetObjectDesc("10");
355 }
356
357
358 xtea_key = xtea_key_from_string(SECRET_PASSWORD);
359 llListen(HOME_CHANNEL, "", "", "XSPET_PING_HOME"); // listen for a pet to say XSPET_PING_HOME - Mod by Ferd to listen to HOME_CHANNEL, not -237918
360
361 }
362
363 touch_start(integer total_number)
364 {
365 if(llDetectedKey(0) == llGetOwner()) {
366 vector size = llGetScale();
367 vector pos = llGetPos();
368
369 pos.z = pos.z - size.z / 2;
370
371 llSay(ANIMAL_CHANNEL, xtea_encrypt_string("XSPET^HOME_LOCATION^" + (string)pos + "^" + llGetObjectDesc()));
372 }
373 llOwnerSay("Setting Home Location");
374 }
375
376 listen(integer channel, string name, key id, string msg)
377 {
378 vector size = llGetScale();
379 vector pos = llGetPos();
380
381 pos.z = pos.z - size.z / 2;
382
383 llSay(ANIMAL_CHANNEL, xtea_encrypt_string("XSPET^HOME_LOCATION^" + (string)pos + "^" + llGetObjectDesc()));
384 }
385
386 // set a default distance
387 on_rez(integer start_param)
388 {
389
391 }
392
393 }

XS Pet Robot

XS Pet moonlet pose ball

Category: XS Pet
By : Ferd Frederix
Created: 2013-09-06 Edited: 2015-07-24
Worlds: Second Life


This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1
2 // moonlet pose ball
3 // Version 0.32 12-03-2011
4 // Put this in a sphereical prim and set it on the ground near the moonlet
5 // Anyone who sits on the pose ball will get an automatic walking tour of your sphere world
6
7
8
9
10
11
12 // START OF COPIED file 'Global Constants.txt' from the Debug folder. It has to be the same in all files
13 // If you change this in any script, change it in all of them, please. It works a lot better that way.
14
15 // This is code based on Version 0.50 01-30-2014
16 // For version history, see file revisions.txt
17 //
18 // LICENSE
19 /////////////////////////////////////////////////////////////////////
20 // This code is licensed as Creative Commons Attribution/NonCommercial/Share Alike
21 // See http://creativecommons.org/liceses/by-nc-sa/3.0/
22 // Noncommercial -- You may not use this work for commercial purposes, i.e., you cannot sell this script in any form, including derivatives.
23 // If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one.
24 // This means that you cannot sell this or derivative code by itself, but you may share and use this code in any object or virtual world.
25 // You must attribute authorship in the original scripts to Ferd Frederix and Xundra Snowpaw, and leave this notice intact.
26 // You do not have to give back to the community any changes you make, however, code changes would be greatly appreciated!
27 //
28 // Exception: I am allowing this script to be used in an original build and sold with the build.
29 // You are not selling the script, you are selling the build. If you want to sell these scripts, write your own or use the original at http://code.google.com/p/xspets/
30 // Note: Xundra Snowpaw's license was 'New BSD' license and adding additional licenses is allowed.
31
32 // Based on code from Xundra Snowpaw
33 // New BSD License: http://www.opensource.org/licenses/bsd-license.php
34 // Copyright (c) 2010, Xundra Snowpaw
35 // All rights reserved.
36 // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
37
38 //* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
39 //* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer
40 // in the documentationand/or other materials provided with the distribution.
41
42 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
43 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
44 // BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
45 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
46 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
47 // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
48 ////////////////////////////////////////////////////////////////////
49
50 // DEBUG - lets you see and hear wtf is happening
51 integer debug = FALSE; // set to TRUE TO hear a lot of chat
52
53
54 // This section has a few tuneable items that MUST be changed for any new pet
55
56 // SECURITY
57 string SECRET_PASSWORD = "top secret string"; // must use a password unique to any species of animal, when ENCRYPT= TRUE. Otherwise you will find Pet type A fucking pet type B.
58 integer SECRET_NUMBER = 99999; // any number thats a secret, not necessary to change usually, this is used when pets are born and eggs are rezzed to establish a comm channel.
59 integer ENCRYPT = TRUE; // set to TRUE to encrypt all data, Some Opensim worlds prefer FALSE due to parsing bugs, TRUE is the most secure. If FALSE you MUST change the FOOD_CHANNEL and other channels for different pets. or they will literally fuck each other.
60
61 // if you add the UUID for your avatar here, you can change it later
62 // and other alts or friends can change it too, and all of you can work on these pets.
63 // If you leave it blank, only the creator of the root prim can work on these pets.
64 key YOUR_UUID = "";
65
66 // PET NAMES - YOU MUST CHANGE THEM HERE AND IN THE ROOT PRIM OF THE OBJECT - THEY MUST MATCH EXACTLY
67 /////////////////////////
68 string MaleName = "Troubot"; // Must be the name of your animal
69 string FemaleName = "Troubot"; // The name of the female pet, if a different shape or prim count. Can be the same as the Male for pets like the robot that are unisex.
70 string Egg = "Nut and Bolt"; // was 'XS Egg', must be the name of your egg
71 string Crate = "Transport Spaceship"; // was XS-Cryocrate, must be the name of the crate you package pets in
72 string HomeObject = "Home Flag"; // was "XS Home Object", must be the name of your Home Post indicator
73 string EggCup = "Toolbox"; // was "XS Egg Cup", must be the name of your egg holder
74 // any other object names are 'do not cares'.
75
76 // NOTHING NEEDS TO BE CHANGED BELOW, BUT CAN BE CHANGED IF YOU DO IT EVERYWHERE
77
78 // misc tunables
79 float GROWTH_AMOUNT = 0.10; // 10% size increase each day for MaxAge days = 200% (double size after 7 days)
80 integer MaxAge = 7; // stop growing in seven days. 10% growth compounded daily means that your pet will be 194% larger ( 2x, basically) in 7 days.
81 integer UNITS_OF_FOOD = 168; // food bowl food qty, used by food bowl only
82 float secs_to_grow = 86400; // grow daily = 86400 seconds
83 float FOOD_BOWL_SCAN_INTERVAL = 1800.0; // look for food every 3 hours
84 float fPregnancy = 172800.0; // how many seconds to lay an egg = 2 days or 48 hours.
85 float MALE_TIMEOUT = 900.0 ; // in seconds, female waits this long in one spot for a male to arrive
86 float SEX_WAIT = 10800.0; // How often they desire sex = 3 hours
87 float fDaysToAdult = 7; // 7 days to become old enough to breed.
88 integer SECONDS_BETWEEN_FOOD_NORMAL = 14400; // number of seconds to get hungry = 4 hours
89 integer SECONDS_BETWEEN_FOOD_HUNGRY = 3600; // number of seconds before hunger count increases = 1 hour
90 integer MAXIMUM_HUNGER = 30; // They die after a month with no food.
91
92
93 // I control versions by Subversion Source Code Control. But the updater needs a version numbert in world.
94 // This is the Protocol version. If you change this, then all pets with a lower version will be updated by the updater
95 float VERSION = 0.50;
96
97
98
99 // the leg sizes are safe to leave alone or set to 0 if you use a thin base prim, these are from the original Quail
100 float LegLength = 0.064; // length of pet leg??? - not sure
101 float LegOffset = 0.052399; // This is added to the Post Z to position the pet
102
103 // the following are global constants and do not need to be changed
104 // Prim animation linkmessages are sent by scripts on Link Message number 1
105 // The strings are the names of the animations that are recorded.
106 // No need to change them unless you want to change names of the animations when you run the prim animator, or you add additional link messages
107 // If your pet walks, you need to record these names and save them in the notecard
108 //
109 // Example:
110 // llMessageLinked(LINK_SET, LINK_ANIMATE, ANI_STAND, "");
111 // The above line will play the pre-recorded 'stand up' animation "stand" using the animator script.
112 // The following animations are used in the pet. You can add your own.
113
114 string ANI_STAND = "stand"; // default standing animation
115 string ANI_WALKL = "left"; // triggers Left foot and Right arm walk animation
116 string ANI_WALKR = "right"; // triggers Right foot and Left arm walk animation
117 string ANI_SLEEP = "sleep"; // Sleeping
118 string ANI_WAVE = "wave"; // Calling for sex, needs help with food, etc.
119
120 // Channel assignments
121 // if you change any of these constants, change it everywhere and in the list in XS_Debug so it can print them
122 // If you turn encryption FALSE, you MUST change these between species of pets are they will fuck with each other. Literally.
123
124 integer FOOD_CHANNEL = -999191;
125 integer ANIMAL_CHANNEL = -999192;
126 integer EGG_CHANNEL = -999193;
127 integer HOME_CHANNEL = -999194;
128 integer BOX_CHANNEL = -999195;
129 integer ACC_CHANNEL = -999196;
130 integer UPDATE_CHANNEL = -999197;
131 integer API_CHANNEL = -999198;
132
133 // global link messages to control the animal, never any need to change these.
134 // They are exposed here so they will be the same everywhere. This uses a bit of RAM, but who cares?
135
136 integer LINK_ANIMATE = 1; // messages on num 1 are assumed to be directed at the prim animator.
137 integer DECREASE_FOOD = 100; // used in the food bowl.
138 integer LINK_AGE_START = 800; // when pety is rezzed and secret_number is sent by brain to breeder, eater and infomatic get booted up
139 integer LINK_TEXTURE = 801; // ask for a new texture, or paint a color
140 integer LINK_BREEDNAME = 802; // the name of the pet texture from the texture server notecard
141 integer LINK_FOOD_CONSUME = 900; // from movement to brain when close to food, brain then consumes a random amount up to 10000
142 integer LINK_FOODMINUS = 901; // xs_brain receives FOOD_CONSUME, decrement hunger (eat)
143 integer LINK_HUNGRY = 903; // sent by eater (string)hunger_amount, checks each hour
144 integer LINK_HAMOUNT = 904; // hunger_amount = (integer)str,m updates the hunger amount in scripts
145 integer LINK_SET_HOME = 910; // loc ^ dist
146 integer LINK_MOVER = 911; // tell mover to rest for str seconds
147 integer LINK_FOODIE_CLR = 920; // clear all food_bowl_keys and contents
148 integer LINK_FOODIE = 921; // send FOOD_LOCATION coordinates to movement
149 integer LINK_COLOR1 = 930; // colour1
150 integer LINK_COLOR2 = 931; // colour2
151 integer LINK_SEX = 932; // sex
152 integer LINK_SHINE = 933; // shine
153 integer LINK_GLOW = 934; // glow
154 integer LINK_GEN = 935; // generation
155 integer LINK_RESET_SIZE = 936; // reset size to 1
156 integer LINK_MAGE = 940; // xs_brain sends, xs_ager consumes, adds str to age, if older than 7 days, will grow the animal
157 integer LINK_DAYTIME = 941; // xs_ager consumes, starts a timer of 86,400 seconds in xs_ager
158 integer LINK_GET_AGE = 942; // get age from xs_ager and sent it on channel 943
159 integer LINK_PUT_AGE = 943; // print age from xs_ager
160 integer LINK_PACKAGE = 950; // look for a cryo_crate
161 integer LINK_SEEK_FEMALE = 960; // MALE_BREED_CALL
162 integer LINK_MALE_BREED_CALL = 961; // triggered by LINK_SEEK_FEMALE
163 integer LINK_SIGNAL_ELIGIBLE = 962; // sent by female when hears LINK_MALE_BREED_CALL
164 integer LINK_FEMALE_ELIGIBLE = 963; // sent when it hears in chat FEMALE_ELIGIBLE
165 integer LINK_CALL_MALE = 964; // if LINK_FEMALE_ELIGIBLE && looking_for_female
166 integer LINK_MALE_ON_THE_WAY = 965; // triggered by LINK_CALL_MALE
167 integer LINK_FEMALE_LOCATION = 966; // female location, sends coordinates of a female
168 integer LINK_RQST_BREED = 967; // sent when close enough to male/female
169 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.
170 integer LINK_MALE_INFO = 969; // Breeding failed, sent info
171 integer LINK_LAY_EGG = 970; // Rez Object(Egg...
172 integer LINK_BREED_FAIL = 971; // key = father, failed, timed out
173 integer LINK_PREGNANT = 972; // chick is preggers
174 integer LINK_SOUND_OFF= 974; // sound is off
175 integer LINK_SOUND_ON= 973; // sound is on
176 integer LINK_SLEEPING = 990; // close eyes
177 integer LINK_UNSLEEPING = 991; // open eyes
178 integer LINK_SOUND = 1001; // plays a sound if enabled
179 integer LINK_SPECIAL = 1010; // xs_special, if str = "Normal", removes script
180 integer LINK_EFFECTS_ON = 2000; // particle effects in the packger
181 integer LINK_PREGNANCY_TIME = 5000; // in seconds as str
182 integer LINK_SLEEP = 7999; // disable sleep by parameter
183 integer LINK_TIMER = 8000; // scan for food bowl about every 1800 seconds
184 integer LINK_DIE = 9999; // death
185
186 string Copyright = " (c)2014 by Ferd Frederix"; // You cannot change this line, but you can change the code that prints it!
187 // See License agreements above.
188 // Attribution is required, as these files are copyrighted.
189
190
191 DEBUG ( string msg){
192 if(debug) {
193 llOwnerSay(llGetScriptName() + ":" + msg);
194 }
195 }
196
197
198
199 ///////// end global Link constants ////////
200
201 // END OF COPIED CODE
202
203
204
205
206
207
208
209
210
211
212 vector home_location;
213 vector destination;
214 integer rest;
215
216
217 // walk on a sphere
218
219
220 rotation gOrient;
221
222 integer gCounter;
223
224
225 // DON'T CHANGE THE FOLLOWING! (Unless you know what you are doing!)
226
227 integer XTEA_DELTA = 0x9E3779B9; // (sqrt(5) - 1) * 2^31
228 integer xtea_num_rounds = 6;
229 list xtea_key = [0, 0, 0, 0];
230
231 integer hex2int(string hex) {
232 if(llGetSubString(hex,0,1) == "0x")
233 return (integer)hex;
234 if(llGetSubString(hex,0,0) == "x")
235 return (integer)("0"+hex);
236 return(integer)("0x"+hex);
237 }
238
239
240 // Convers any string to a 32 char MD5 string and then to a list of
241 // 4 * 32 bit integers = 128 bit Key. MD5 ensures always a specific
242 // 128 bit key is generated for any string passed.
243 list xtea_key_from_string( string str )
244 {
245 str = llMD5String(str,0); // Use Nonce = 0
246 return [ hex2int(llGetSubString( str, 0, 7)),
247 hex2int(llGetSubString( str, 8, 15)),
248 hex2int(llGetSubString( str, 16, 23)),
249 hex2int(llGetSubString( str, 24, 31))];
250 }
251
252 // Encipher two integers and return the result as a 12-byte string
253 // containing two base64-encoded integers.
254 string xtea_encipher( integer v0, integer v1 )
255 {
256 integer num_rounds = xtea_num_rounds;
257 integer sum = 0;
258 do {
259 // LSL does not have unsigned integers, so when shifting right we
260 // have to mask out sign-extension bits.
261 v0 += (((v1 << 4) ^ ((v1 >> 5) & 0x07FFFFFF)) + v1) ^ (sum + llList2Integer(xtea_key, sum & 3));
262 sum += XTEA_DELTA;
263 v1 += (((v0 << 4) ^ ((v0 >> 5) & 0x07FFFFFF)) + v0) ^ (sum + llList2Integer(xtea_key, (sum >> 11) & 3));
264
265 } while( num_rounds = ~-num_rounds );
266 //return only first 6 chars to remove "=="'s and compact encrypted text.
267 return llGetSubString(llIntegerToBase64(v0),0,5) +
269 }
270
271 // Decipher two base64-encoded integers and return the FIRST 30 BITS of
272 // each as one 10-byte base64-encoded string.
273 string xtea_decipher( integer v0, integer v1 )
274 {
275 integer num_rounds = xtea_num_rounds;
276 integer sum = XTEA_DELTA*xtea_num_rounds;
277 do {
278 // LSL does not have unsigned integers, so when shifting right we
279 // have to mask out sign-extension bits.
280 v1 -= (((v0 << 4) ^ ((v0 >> 5) & 0x07FFFFFF)) + v0) ^ (sum + llList2Integer(xtea_key, (sum>>11) & 3));
281 sum -= XTEA_DELTA;
282 v0 -= (((v1 << 4) ^ ((v1 >> 5) & 0x07FFFFFF)) + v1) ^ (sum + llList2Integer(xtea_key, sum & 3));
283 } while( num_rounds = ~-num_rounds );
284
285 return llGetSubString(llIntegerToBase64(v0), 0, 4) +
287 }
288
289 // Encrypt a full string using XTEA.
290 string xtea_encrypt_string( string str )
291 {
292 // encode string
293 str = llStringToBase64(str);
294 // remove trailing =s so we can do our own 0 padding
295 integer i = llSubStringIndex( str, "=" );
296 if( i != -1 )
297 str = llDeleteSubString( str, i, -1 );
298
299 // we don't want to process padding, so get length before adding it
300 integer len = llStringLength(str);
301
302 // zero pad
303 str += "AAAAAAAAAA=";
304
305 string result;
306 i = 0;
307
308 do {
309 // encipher 30 (5*6) bits at a time.
310 result += xtea_encipher(llBase64ToInteger(llGetSubString(str, i, i + 4) + "A="), llBase64ToInteger(llGetSubString(str, i+5, i + 9) + "A="));
311 i+=10;
312 } while( i < len );
313
314 return result;
315 }
316
317 // Decrypt a full string using XTEA
318 string xtea_decrypt_string( string str ) {
319 integer len = llStringLength(str);
320 integer i=0;
321 string result;
322 //llOwnerSay(str);
323 do {
324 integer v0;
325 integer v1;
326
327 v0 = llBase64ToInteger(llGetSubString(str, i, i + 5) + "==");
328 i+= 6;
329 v1 = llBase64ToInteger(llGetSubString(str, i, i + 5) + "==");
330 i+= 6;
331
332 result += xtea_decipher(v0, v1);
333 } while( i < len );
334
335 // Replace multiple trailing zeroes with a single one
336
337 i = llStringLength(result) - 1;
338 while( llGetSubString(result, i - 1, i) == "AA" ){
339 result = llDeleteSubString(result, i, i);
340 i--;
341 }
342 i = llStringLength(result) - 1;
343 // while(llGetSubString(result, i, i + 1) == "A" ) {
344 // i--;
345 // }
346 result = llGetSubString(result, 0, i+1);
347 i = llStringLength(result);
348 integer mod = i%4; //Depending on encoded length diffrent appends are needed
349 if(mod == 1) result += "A==";
350 else if(mod == 2 ) result += "==";
351 else if(mod == 3) result += "=";
352
353 return llBase64ToString(result);
354 }
355
356
357
358 string ANIMATION;
359
360 key avatarKey;
361 float x ;
362 float y ;
363 float z ;
364 float gRADIUS;
365 float aRADIUS;
366
367
368 face_target(vector lookat) {
369
370
371 rotation rot = llGetRot() * llRotBetween(<1.0 ,0.0 ,0.0 > * llGetRot(), lookat - llGetPos());
372
373 llSetRot(rot);
374 // llSleep(.1);
375
376 rot = llGetRot() * llRotBetween(<0.0 ,0.0 ,1.0 > * llGetRot(), home_location - llGetPos());
377 llSetRot(rot);
378 }
379
380 key avatar;
381
382
383 warpPos( vector destpos )
384 { //R&D by Keknehv Psaltery, 05/25/2006
385 //with a little poking by Strife, and a bit more
386 //some more munging by Talarus Luan
387 //Final cleanup by Keknehv Psaltery
388 //Changed jump value to 411 (4096 ceiling) by Jesse Barnett
389 // Compute the number of jumps necessary
390 integer jumps = (integer)(llVecDist(destpos, llGetPos()) / 10.0) + 1;
391 // Try and avoid stack/heap collisions
392 if(jumps > 411)
393 jumps = 411;
394 list rules = [ PRIM_POSITION, destpos ]; //The start for the rules list
395 integer count = 1;
396 while( ( count = count << 1 ) < jumps)
397 rules += rules; //should tighten memory use.
398 llSetPrimitiveParams( rules + llList2List( rules, (count - jumps) << 1, count) );
399 if( llVecDist( llGetPos(), destpos ) > .001 ) //Failsafe
400 while( --jumps )
401 llSetPos( destpos );
402 }
403
404 vector Home;
405
406 default
407 {
408
410 {
412 }
413
415 {
416
417 Home = llGetPos();
418
420 llSetText("Fly to the moon",<1,1,1>,1);
421 vector rot = <0,180,180>;
422 rotation sitrot = llEuler2Rot(rot * DEG_TO_RAD);
423 llSitTarget(<0,0,0.01>,sitrot);
424
425 xtea_key = xtea_key_from_string(SECRET_PASSWORD);
426 llListen(ANIMAL_CHANNEL, "", "", "");
427 llShout(HOME_CHANNEL, "XSPET_PING_HOME");
428 }
429
430
431 listen(integer channel, string name, key id, string message)
432 {
433
434 if(channel == ANIMAL_CHANNEL) {
435 list data = llParseString2List(xtea_decrypt_string(message), ["^"], []);
436
437
438 if(llList2String(data, 0) == "XSPET")
439 {
440 if(llList2String(data, 1) == "HOME_LOCATION") {
441 vector n_home_loc = (vector)llList2String(data, 2);
442 float home_dis = llList2Float(data, 3);
443 vector my_loc = llGetPos();
444
445
446 if(llGetOwnerKey(id) == llGetOwner()) {
447 home_location = n_home_loc;
448 llOwnerSay("Orbit Set");
449 }
450 }
451 else if(llList2String(data, 1) == "HOME_RADIUS")
452 {
453 float dia = llList2Float(data, 2);
454
456 {
457 gRADIUS = dia/2;
458
459 //home_location.y -= dia/2;
460
461 //llOwnerSay("Home Radius:" + (string) gRADIUS);
462 state running;
463 }
464 }
465 }
466 }
467 }
468
469
470 }
471
472 state running
473 {
475 {
476 gOrient = ZERO_ROTATION;
477 destination = <0,0,0>;
478 vector current_loc = llGetPos();
479
480 llListen(ANIMAL_CHANNEL, "", "", "");
481 }
482
484 {
486 {
487 vector height = llGetAgentSize(avatarKey);
488
489 aRADIUS = gRADIUS + height.z * .85 ; // adjust for the agent size
490
491 llStopAnimation("sit");
492 llStartAnimation("walk");
493 ANIMATION = "walk";
495 llSetText("",<1,0,0>,1);
497 }
498 }
499
500
501
502
503 changed(integer change)
504 {
505 if(change & CHANGED_LINK)
506 {
507 avatar = llAvatarOnSitTarget();
508 if(avatar != NULL_KEY){
509 //SOMEONE SAT DOWN
510 avatarKey = avatar;
512 return;
513 }else{
514 //SOMEONE STOOD UP
516 {
518 llStopAnimation(ANIMATION);
519 llSetText("Orbit",<1,1,1>,1);
521 warpPos(Home);
522 }
523
524 return;
525 }
526 }
527 }
528
529
530
531 timer()
532 {
533 if(rest)
534 {
535 //llSetText((string) rest,<1,0,0>,1);
536 rest--;
537
538 rotation delta = llEuler2Rot(<x,y,z> * DEG_TO_RAD);
539
540 vector unitpos = llRot2Fwd( gOrient );
541 vector pos = home_location + unitpos * aRADIUS;
542
543 // llOwnerSay((string) llVecDist(home_location,llGetPos()));
544
545 gCounter++;
546 face_target(pos);
547 llSetPos(pos);
548
549 gOrient = gOrient * delta;
550
551 }
552 else
553 {
554 x = llFrand(5) + 5;
555 y = llFrand(5) + 5;
556 z = llFrand(5) + 5;
557
558 if(llFrand(2) > 1)
559 x = 1-x;
560 if(llFrand(2) > 1)
561 y = 1-z;
562 if(llFrand(2) > 1)
563 z = 1-z;
564
565 rest = (integer)llFrand(12.0) + 1;
566
567 }
568
569 }
570
571
572
573 }

XS Pet Robot

XS Pet rotate the globe

Category: XS Pet
By : Ferd Frederix
Created: 2013-09-06 Edited: 2015-07-24
Worlds: Second Life


This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1
2 default
3 {
5 {
6
7 llTargetOmega(<.5,0.0,0.0>*llGetRot(),0.1,0.01);
8 //llTargetOmega(<0,0.0,0.0>*llGetRot(),0.1,0.01); // uncomment to stop rotation
9 }
10
11
12 }

XS Pet Robot

XS Pet walk on a moon pose ball

Category: XS Pet
By : Ferd Frederix
Created: 2013-09-06 Edited: 2015-07-24
Worlds: Second Life


This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1
2 // walk on a moon pose ball
3 // Put this script into a pose ball and set it near your Sphere world.
4 // This allows the person to actually welk on your world using the arrow ketys
5
6 // Requires there to be one Walk animation in the inventory of the pose ball.
7
8
9
10
11
12
13
14 // START OF COPIED file 'Global Constants.txt' from the Debug folder. It has to be the same in all files
15 // If you change this in any script, change it in all of them, please. It works a lot better that way.
16
17 // This is code based on Version 0.50 01-30-2014
18 // For version history, see file revisions.txt
19 //
20 // LICENSE
21 /////////////////////////////////////////////////////////////////////
22 // This code is licensed as Creative Commons Attribution/NonCommercial/Share Alike
23 // See http://creativecommons.org/liceses/by-nc-sa/3.0/
24 // Noncommercial -- You may not use this work for commercial purposes, i.e., you cannot sell this script in any form, including derivatives.
25 // If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one.
26 // This means that you cannot sell this or derivative code by itself, but you may share and use this code in any object or virtual world.
27 // You must attribute authorship in the original scripts to Ferd Frederix and Xundra Snowpaw, and leave this notice intact.
28 // You do not have to give back to the community any changes you make, however, code changes would be greatly appreciated!
29 //
30 // Exception: I am allowing this script to be used in an original build and sold with the build.
31 // You are not selling the script, you are selling the build. If you want to sell these scripts, write your own or use the original at http://code.google.com/p/xspets/
32 // Note: Xundra Snowpaw's license was 'New BSD' license and adding additional licenses is allowed.
33
34 // Based on code from Xundra Snowpaw
35 // New BSD License: http://www.opensource.org/licenses/bsd-license.php
36 // Copyright (c) 2010, Xundra Snowpaw
37 // All rights reserved.
38 // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
39
40 //* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
41 //* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer
42 // in the documentationand/or other materials provided with the distribution.
43
44 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
45 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
46 // BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
47 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
48 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
49 // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
50 ////////////////////////////////////////////////////////////////////
51
52 // DEBUG - lets you see and hear wtf is happening
53 integer debug = FALSE; // set to TRUE TO hear a lot of chat
54
55
56 // This section has a few tuneable items that MUST be changed for any new pet
57
58 // SECURITY
59 string SECRET_PASSWORD = "top secret string"; // must use a password unique to any species of animal, when ENCRYPT= TRUE. Otherwise you will find Pet type A fucking pet type B.
60 integer SECRET_NUMBER = 99999; // any number thats a secret, not necessary to change usually, this is used when pets are born and eggs are rezzed to establish a comm channel.
61 integer ENCRYPT = TRUE; // set to TRUE to encrypt all data, Some Opensim worlds prefer FALSE due to parsing bugs, TRUE is the most secure. If FALSE you MUST change the FOOD_CHANNEL and other channels for different pets. or they will literally fuck each other.
62
63 // if you add the UUID for your avatar here, you can change it later
64 // and other alts or friends can change it too, and all of you can work on these pets.
65 // If you leave it blank, only the creator of the root prim can work on these pets.
66 key YOUR_UUID = "";
67
68 // PET NAMES - YOU MUST CHANGE THEM HERE AND IN THE ROOT PRIM OF THE OBJECT - THEY MUST MATCH EXACTLY
69 /////////////////////////
70 string MaleName = "Troubot"; // Must be the name of your animal
71 string FemaleName = "Troubot"; // The name of the female pet, if a different shape or prim count. Can be the same as the Male for pets like the robot that are unisex.
72 string Egg = "Nut and Bolt"; // was 'XS Egg', must be the name of your egg
73 string Crate = "Transport Spaceship"; // was XS-Cryocrate, must be the name of the crate you package pets in
74 string HomeObject = "Home Flag"; // was "XS Home Object", must be the name of your Home Post indicator
75 string EggCup = "Toolbox"; // was "XS Egg Cup", must be the name of your egg holder
76 // any other object names are 'do not cares'.
77
78 // NOTHING NEEDS TO BE CHANGED BELOW, BUT CAN BE CHANGED IF YOU DO IT EVERYWHERE
79
80 // misc tunables
81 float GROWTH_AMOUNT = 0.10; // 10% size increase each day for MaxAge days = 200% (double size after 7 days)
82 integer MaxAge = 7; // stop growing in seven days. 10% growth compounded daily means that your pet will be 194% larger ( 2x, basically) in 7 days.
83 integer UNITS_OF_FOOD = 168; // food bowl food qty, used by food bowl only
84 float secs_to_grow = 86400; // grow daily = 86400 seconds
85 float FOOD_BOWL_SCAN_INTERVAL = 1800.0; // look for food every 3 hours
86 float fPregnancy = 172800.0; // how many seconds to lay an egg = 2 days or 48 hours.
87 float MALE_TIMEOUT = 900.0 ; // in seconds, female waits this long in one spot for a male to arrive
88 float SEX_WAIT = 10800.0; // How often they desire sex = 3 hours
89 float fDaysToAdult = 7; // 7 days to become old enough to breed.
90 integer SECONDS_BETWEEN_FOOD_NORMAL = 14400; // number of seconds to get hungry = 4 hours
91 integer SECONDS_BETWEEN_FOOD_HUNGRY = 3600; // number of seconds before hunger count increases = 1 hour
92 integer MAXIMUM_HUNGER = 30; // They die after a month with no food.
93
94
95 // I control versions by Subversion Source Code Control. But the updater needs a version numbert in world.
96 // This is the Protocol version. If you change this, then all pets with a lower version will be updated by the updater
97 float VERSION = 0.50;
98
99
100
101 // the leg sizes are safe to leave alone or set to 0 if you use a thin base prim, these are from the original Quail
102 float LegLength = 0.064; // length of pet leg??? - not sure
103 float LegOffset = 0.052399; // This is added to the Post Z to position the pet
104
105 // the following are global constants and do not need to be changed
106 // Prim animation linkmessages are sent by scripts on Link Message number 1
107 // The strings are the names of the animations that are recorded.
108 // No need to change them unless you want to change names of the animations when you run the prim animator, or you add additional link messages
109 // If your pet walks, you need to record these names and save them in the notecard
110 //
111 // Example:
112 // llMessageLinked(LINK_SET, LINK_ANIMATE, ANI_STAND, "");
113 // The above line will play the pre-recorded 'stand up' animation "stand" using the animator script.
114 // The following animations are used in the pet. You can add your own.
115
116 string ANI_STAND = "stand"; // default standing animation
117 string ANI_WALKL = "left"; // triggers Left foot and Right arm walk animation
118 string ANI_WALKR = "right"; // triggers Right foot and Left arm walk animation
119 string ANI_SLEEP = "sleep"; // Sleeping
120 string ANI_WAVE = "wave"; // Calling for sex, needs help with food, etc.
121
122 // Channel assignments
123 // if you change any of these constants, change it everywhere and in the list in XS_Debug so it can print them
124 // If you turn encryption FALSE, you MUST change these between species of pets are they will fuck with each other. Literally.
125
126 integer FOOD_CHANNEL = -999191;
127 integer ANIMAL_CHANNEL = -999192;
128 integer EGG_CHANNEL = -999193;
129 integer HOME_CHANNEL = -999194;
130 integer BOX_CHANNEL = -999195;
131 integer ACC_CHANNEL = -999196;
132 integer UPDATE_CHANNEL = -999197;
133 integer API_CHANNEL = -999198;
134
135 // global link messages to control the animal, never any need to change these.
136 // They are exposed here so they will be the same everywhere. This uses a bit of RAM, but who cares?
137
138 integer LINK_ANIMATE = 1; // messages on num 1 are assumed to be directed at the prim animator.
139 integer DECREASE_FOOD = 100; // used in the food bowl.
140 integer LINK_AGE_START = 800; // when pety is rezzed and secret_number is sent by brain to breeder, eater and infomatic get booted up
141 integer LINK_TEXTURE = 801; // ask for a new texture, or paint a color
142 integer LINK_BREEDNAME = 802; // the name of the pet texture from the texture server notecard
143 integer LINK_FOOD_CONSUME = 900; // from movement to brain when close to food, brain then consumes a random amount up to 10000
144 integer LINK_FOODMINUS = 901; // xs_brain receives FOOD_CONSUME, decrement hunger (eat)
145 integer LINK_HUNGRY = 903; // sent by eater (string)hunger_amount, checks each hour
146 integer LINK_HAMOUNT = 904; // hunger_amount = (integer)str,m updates the hunger amount in scripts
147 integer LINK_SET_HOME = 910; // loc ^ dist
148 integer LINK_MOVER = 911; // tell mover to rest for str seconds
149 integer LINK_FOODIE_CLR = 920; // clear all food_bowl_keys and contents
150 integer LINK_FOODIE = 921; // send FOOD_LOCATION coordinates to movement
151 integer LINK_COLOR1 = 930; // colour1
152 integer LINK_COLOR2 = 931; // colour2
153 integer LINK_SEX = 932; // sex
154 integer LINK_SHINE = 933; // shine
155 integer LINK_GLOW = 934; // glow
156 integer LINK_GEN = 935; // generation
157 integer LINK_RESET_SIZE = 936; // reset size to 1
158 integer LINK_MAGE = 940; // xs_brain sends, xs_ager consumes, adds str to age, if older than 7 days, will grow the animal
159 integer LINK_DAYTIME = 941; // xs_ager consumes, starts a timer of 86,400 seconds in xs_ager
160 integer LINK_GET_AGE = 942; // get age from xs_ager and sent it on channel 943
161 integer LINK_PUT_AGE = 943; // print age from xs_ager
162 integer LINK_PACKAGE = 950; // look for a cryo_crate
163 integer LINK_SEEK_FEMALE = 960; // MALE_BREED_CALL
164 integer LINK_MALE_BREED_CALL = 961; // triggered by LINK_SEEK_FEMALE
165 integer LINK_SIGNAL_ELIGIBLE = 962; // sent by female when hears LINK_MALE_BREED_CALL
166 integer LINK_FEMALE_ELIGIBLE = 963; // sent when it hears in chat FEMALE_ELIGIBLE
167 integer LINK_CALL_MALE = 964; // if LINK_FEMALE_ELIGIBLE && looking_for_female
168 integer LINK_MALE_ON_THE_WAY = 965; // triggered by LINK_CALL_MALE
169 integer LINK_FEMALE_LOCATION = 966; // female location, sends coordinates of a female
170 integer LINK_RQST_BREED = 967; // sent when close enough to male/female
171 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.
172 integer LINK_MALE_INFO = 969; // Breeding failed, sent info
173 integer LINK_LAY_EGG = 970; // Rez Object(Egg...
174 integer LINK_BREED_FAIL = 971; // key = father, failed, timed out
175 integer LINK_PREGNANT = 972; // chick is preggers
176 integer LINK_SOUND_OFF= 974; // sound is off
177 integer LINK_SOUND_ON= 973; // sound is on
178 integer LINK_SLEEPING = 990; // close eyes
179 integer LINK_UNSLEEPING = 991; // open eyes
180 integer LINK_SOUND = 1001; // plays a sound if enabled
181 integer LINK_SPECIAL = 1010; // xs_special, if str = "Normal", removes script
182 integer LINK_EFFECTS_ON = 2000; // particle effects in the packger
183 integer LINK_PREGNANCY_TIME = 5000; // in seconds as str
184 integer LINK_SLEEP = 7999; // disable sleep by parameter
185 integer LINK_TIMER = 8000; // scan for food bowl about every 1800 seconds
186 integer LINK_DIE = 9999; // death
187
188 string Copyright = " (c)2014 by Ferd Frederix"; // You cannot change this line, but you can change the code that prints it!
189 // See License agreements above.
190 // Attribution is required, as these files are copyrighted.
191
192
193 DEBUG ( string msg){
194 if(debug) {
195 llOwnerSay(llGetScriptName() + ":" + msg);
196 }
197 }
198
199
200
201 ///////// end global Link constants ////////
202
203 // END OF COPIED CODE
204
205
206
207
208
209
210
211
212
213
214
215
216 vector home_location;
217 vector destination;
218
219 float increment = 0.1;
220
221 // DON'T CHANGE THE FOLLOWING! (Unless you know what you are doing!)
222
223 integer XTEA_DELTA = 0x9E3779B9; // (sqrt(5) - 1) * 2^31
224 integer xtea_num_rounds = 6;
225 list xtea_key = [0, 0, 0, 0];
226
227 integer hex2int(string hex) {
228 if(llGetSubString(hex,0,1) == "0x")
229 return (integer)hex;
230 if(llGetSubString(hex,0,0) == "x")
231 return (integer)("0"+hex);
232 return(integer)("0x"+hex);
233 }
234
235
236 // Convers any string to a 32 char MD5 string and then to a list of
237 // 4 * 32 bit integers = 128 bit Key. MD5 ensures always a specific
238 // 128 bit key is generated for any string passed.
239 list xtea_key_from_string( string str )
240 {
241 str = llMD5String(str,0); // Use Nonce = 0
242 return [ hex2int(llGetSubString( str, 0, 7)),
243 hex2int(llGetSubString( str, 8, 15)),
244 hex2int(llGetSubString( str, 16, 23)),
245 hex2int(llGetSubString( str, 24, 31))];
246 }
247
248 // Encipher two integers and return the result as a 12-byte string
249 // containing two base64-encoded integers.
250 string xtea_encipher( integer v0, integer v1 )
251 {
252 integer num_rounds = xtea_num_rounds;
253 integer sum = 0;
254 do {
255 // LSL does not have unsigned integers, so when shifting right we
256 // have to mask out sign-extension bits.
257 v0 += (((v1 << 4) ^ ((v1 >> 5) & 0x07FFFFFF)) + v1) ^ (sum + llList2Integer(xtea_key, sum & 3));
258 sum += XTEA_DELTA;
259 v1 += (((v0 << 4) ^ ((v0 >> 5) & 0x07FFFFFF)) + v0) ^ (sum + llList2Integer(xtea_key, (sum >> 11) & 3));
260
261 } while( num_rounds = ~-num_rounds );
262 //return only first 6 chars to remove "=="'s and compact encrypted text.
263 return llGetSubString(llIntegerToBase64(v0),0,5) +
265 }
266
267 // Decipher two base64-encoded integers and return the FIRST 30 BITS of
268 // each as one 10-byte base64-encoded string.
269 string xtea_decipher( integer v0, integer v1 )
270 {
271 integer num_rounds = xtea_num_rounds;
272 integer sum = XTEA_DELTA*xtea_num_rounds;
273 do {
274 // LSL does not have unsigned integers, so when shifting right we
275 // have to mask out sign-extension bits.
276 v1 -= (((v0 << 4) ^ ((v0 >> 5) & 0x07FFFFFF)) + v0) ^ (sum + llList2Integer(xtea_key, (sum>>11) & 3));
277 sum -= XTEA_DELTA;
278 v0 -= (((v1 << 4) ^ ((v1 >> 5) & 0x07FFFFFF)) + v1) ^ (sum + llList2Integer(xtea_key, sum & 3));
279 } while( num_rounds = ~-num_rounds );
280
281 return llGetSubString(llIntegerToBase64(v0), 0, 4) +
283 }
284
285 // Encrypt a full string using XTEA.
286 string xtea_encrypt_string( string str )
287 {
288 if(! ENCRYPT)
289 return str;
290 // encode string
291 str = llStringToBase64(str);
292 // remove trailing =s so we can do our own 0 padding
293 integer i = llSubStringIndex( str, "=" );
294 if( i != -1 )
295 str = llDeleteSubString( str, i, -1 );
296
297 // we don't want to process padding, so get length before adding it
298 integer len = llStringLength(str);
299
300 // zero pad
301 str += "AAAAAAAAAA=";
302
303 string result;
304 i = 0;
305
306 do {
307 // encipher 30 (5*6) bits at a time.
308 result += xtea_encipher(llBase64ToInteger(llGetSubString(str, i, i + 4) + "A="), llBase64ToInteger(llGetSubString(str, i+5, i + 9) + "A="));
309 i+=10;
310 } while( i < len );
311
312 return result;
313 }
314
315 // Decrypt a full string using XTEA
316 string xtea_decrypt_string( string str ) {
317 if(! ENCRYPT)
318 return str;
319 integer len = llStringLength(str);
320 integer i=0;
321 string result;
322 //llOwnerSay(str);
323 do {
324 integer v0;
325 integer v1;
326
327 v0 = llBase64ToInteger(llGetSubString(str, i, i + 5) + "==");
328 i+= 6;
329 v1 = llBase64ToInteger(llGetSubString(str, i, i + 5) + "==");
330 i+= 6;
331
332 result += xtea_decipher(v0, v1);
333 } while( i < len );
334
335 // Replace multiple trailing zeroes with a single one
336
337 i = llStringLength(result) - 1;
338 while( llGetSubString(result, i - 1, i) == "AA" ){
339 result = llDeleteSubString(result, i, i);
340 i--;
341 }
342 i = llStringLength(result) - 1;
343 // while(llGetSubString(result, i, i + 1) == "A" ) {
344 // i--;
345 // }
346 result = llGetSubString(result, 0, i+1);
347 i = llStringLength(result);
348 integer mod = i%4; //Depending on encoded length diffrent appends are needed
349 if(mod == 1) result += "A==";
350 else if(mod == 2 ) result += "==";
351 else if(mod == 3) result += "=";
352
353 return llBase64ToString(result);
354 }
355
356 // walk on a sphere
357
358 string Text = "Walk on the moon"; // the hovertext when noone is stting
359 string ANIMATION ; // change to a walk animation
360
361 vector Home;
362 rotation gOrient;
363
364
365
366 key avatarKey;
367 float x ;
368 float y ;
369 float z ;
370 float gRADIUS;
371 float aRADIUS;
372 string controls ;
373
374
375 face_target(vector lookat) {
376
377
378 // rotation rot = llGetRot() * llRotBetween(<1.0 ,0.0 ,0.0 > * llGetRot(), lookat - llGetPos());
379
380 // llSetRot(rot);
381 // llSleep(.1);
382
383 rotation rot = llGetRot() * llRotBetween(<0.0 ,0.0 ,1.0 > * llGetRot(), home_location - llGetPos());
384 llSetRot(rot);
385 }
386
387 key avatar;
388
389
390 warpPos( vector destpos )
391 { //R&D by Keknehv Psaltery, 05/25/2006
392 //with a little poking by Strife, and a bit more
393 //some more munging by Talarus Luan
394 //Final cleanup by Keknehv Psaltery
395 //Changed jump value to 411 (4096 ceiling) by Jesse Barnett
396 // Compute the number of jumps necessary
397 integer jumps = (integer)(llVecDist(destpos, llGetPos()) / 10.0) + 1;
398 // Try and avoid stack/heap collisions
399 if(jumps > 411)
400 jumps = 411;
401 list rules = [ PRIM_POSITION, destpos ]; //The start for the rules list
402 integer count = 1;
403 while( ( count = count << 1 ) < jumps)
404 rules += rules; //should tighten memory use.
405 llSetPrimitiveParams( rules + llList2List( rules, (count - jumps) << 1, count) );
406 if( llVecDist( llGetPos(), destpos ) > .001 ) //Failsafe
407 while( --jumps )
408 llSetPos( destpos );
409 }
410
411 default
412 {
413
415 {
417 }
418
420 {
421
422 ANIMATION = llGetInventoryName(INVENTORY_ANIMATION,0); // get the first animation we can find
423 Home = llGetPos();
424
426 llSetText(Text,<1,1,1>,1);
427 vector rot = <0,180,180>;
428 rotation sitrot = llEuler2Rot(rot * DEG_TO_RAD);
429 llSitTarget(<0,0,0.01>,sitrot);
430
431 xtea_key = xtea_key_from_string(SECRET_PASSWORD);
432 llListen(ANIMAL_CHANNEL, "", "", "");
433 llShout(HOME_CHANNEL, "XSPET_PING_HOME");
434 llSetCameraEyeOffset(<-4, 0, 3> * sitrot);
435 llSetCameraAtOffset(<2, 0, 1> * sitrot);
436 }
437
438
439 listen(integer channel, string name, key id, string message)
440 {
441 llOwnerSay(message);
442
443 if(channel == ANIMAL_CHANNEL) {
444 list data = llParseString2List(xtea_decrypt_string(message), ["^"], []);
445
446
447 if(llList2String(data, 0) == "XSPET")
448 {
449 if(llList2String(data, 1) == "HOME_LOCATION") {
450 vector n_home_loc = (vector)llList2String(data, 2);
451 float home_dis = llList2Float(data, 3);
452 vector my_loc = llGetPos();
453
454
455 if(llGetOwnerKey(id) == llGetOwner()) {
456 home_location = n_home_loc;
457 llOwnerSay("Homeworld located");
458 }
459 }
460 else if(llList2String(data, 1) == "HOME_RADIUS")
461 {
462 float dia = llList2Float(data, 2);
463
465 {
466 gRADIUS = dia/2;
467
468 //home_location.y -= dia/2;
469
470 //llOwnerSay("Home Radius:" + (string) gRADIUS);
471 state running;
472 }
473 }
474 }
475 }
476 }
477
478
479 }
480
481 state running
482 {
484 {
485 llOwnerSay("Ready");
486
487 gOrient = ZERO_ROTATION;
488 destination = <0,0,0>;
489 vector current_loc = llGetPos();
490
491 llListen(ANIMAL_CHANNEL, "", "", "");
492 }
493
494
495
496
497
498
499
500 changed(integer change)
501 {
502 if(change & CHANGED_LINK)
503 {
504 avatar = llAvatarOnSitTarget();
505 if(avatar != NULL_KEY){
506 //SOMEONE SAT DOWN
507 avatarKey = avatar;
509 return;
510 }else{
511 //SOMEONE STOOD UP
513 {
515 llStopAnimation(ANIMATION);
516 llSetText(Text,<1,1,1>,1);
518 warpPos(Home);
519 }
520
521 return;
522 }
523 }
524 }
525
527 {
529 {
530 vector height = llGetAgentSize(avatarKey);
531
532 aRADIUS = gRADIUS + height.z * .85 ; // adjust for the agent size
533
534 llStopAnimation("sit");
535 llStartAnimation(ANIMATION);
536
538 llSetText("",<1,0,0>,1);
540 }
542 {
543 //llOwnerSay("Controls Ready");
548 controls = "U";
549 }
550 }
551
552 timer()
553 {
554
555
556 if(llStringLength(controls) == 0)
557 {
558 llStopAnimation(ANIMATION);
559 return;
560 }
561
562 //llOwnerSay(controls);
563 controls = "";
564 llStartAnimation(ANIMATION);
565
566
567 rotation delta = llEuler2Rot(<x,y,z> * DEG_TO_RAD);
568
569 vector unitpos = llRot2Fwd( gOrient );
570 vector pos = home_location + unitpos * aRADIUS;
571
572 //llOwnerSay((string) llVecDist(home_location,llGetPos()));
573
574
575
576 face_target(pos);
577
578 //llSetRot(gOrient);
579
580 llRezObject("Primitive",pos,<0,0,0>,gOrient,1);
581
582 //llOwnerSay("Pos:" + ( string) pos);
583 llSetPos(pos);
584
585 gOrient = gOrient * delta;
586 }
587
588
589 control(key driver, integer levels, integer edge)
590 {
591
592 // integer start = levels & edge;
593 // integer end = ~levels & edge;
594 // integer held = levels & ~edge;
595 //integer untouched = ~(levels | edge);
596 //llOwnerSay(llList2CSV([levels, edge, start, end, held, untouched]));
597
598 //z = L/R
599 //y = U/d
600 x = 0;
601 y = 0;
602 z = 0;
603
604 float bump = 10;
605
606 if(levels & CONTROL_FWD)
607 {
608 y = bump;
609 controls = "U";
610 }
611 if(levels & CONTROL_BACK)
612 {
613 y = -bump;
614 controls = "D";
615 }
616 if(levels & CONTROL_ROT_LEFT)
617 {
618 z = bump ;
619 controls = "L";
620 }
621 if(levels & CONTROL_ROT_RIGHT)
622 {
623 z = -bump;
624 controls = "R";
625 }
626
627
628
629
630 }
631
632
633
634
635 }

XS Pet Robot

XS Pet xs_movement (for walking on a globe )

Category: XS Pet
By : Ferd Frederix
Created: 2013-09-06 Edited: 2015-07-24
Worlds: Second Life


This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1
2 // xs_movement ( for walking on a globe )
3 // this replaces xs_movement in xs+pets and lets them live on a sphere
4 // The prim animation must be flipped to the bottom of the root prim since the prim will face inwards.
5
6
7
8
9
10
11 // START OF COPIED file 'Global Constants.txt' from the Debug folder. It has to be the same in all files
12 // If you change this in any script, change it in all of them, please. It works a lot better that way.
13
14 // This is code based on Version 0.50 01-30-2014
15 // For version history, see file revisions.txt
16 //
17 // LICENSE
18 /////////////////////////////////////////////////////////////////////
19 // This code is licensed as Creative Commons Attribution/NonCommercial/Share Alike
20 // See http://creativecommons.org/liceses/by-nc-sa/3.0/
21 // Noncommercial -- You may not use this work for commercial purposes, i.e., you cannot sell this script in any form, including derivatives.
22 // If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one.
23 // This means that you cannot sell this or derivative code by itself, but you may share and use this code in any object or virtual world.
24 // You must attribute authorship in the original scripts to Ferd Frederix and Xundra Snowpaw, and leave this notice intact.
25 // You do not have to give back to the community any changes you make, however, code changes would be greatly appreciated!
26 //
27 // Exception: I am allowing this script to be used in an original build and sold with the build.
28 // You are not selling the script, you are selling the build. If you want to sell these scripts, write your own or use the original at http://code.google.com/p/xspets/
29 // Note: Xundra Snowpaw's license was 'New BSD' license and adding additional licenses is allowed.
30
31 // Based on code from Xundra Snowpaw
32 // New BSD License: http://www.opensource.org/licenses/bsd-license.php
33 // Copyright (c) 2010, Xundra Snowpaw
34 // All rights reserved.
35 // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
36
37 //* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
38 //* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer
39 // in the documentationand/or other materials provided with the distribution.
40
41 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
42 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
43 // BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
44 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
45 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
46 // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
47 ////////////////////////////////////////////////////////////////////
48
49 // DEBUG - lets you see and hear wtf is happening
50 integer debug = FALSE; // set to TRUE TO hear a lot of chat
51
52
53 // This section has a few tuneable items that MUST be changed for any new pet
54
55 // SECURITY
56 string SECRET_PASSWORD = "top secret string"; // must use a password unique to any species of animal, when ENCRYPT= TRUE. Otherwise you will find Pet type A fucking pet type B.
57 integer SECRET_NUMBER = 99999; // any number thats a secret, not necessary to change usually, this is used when pets are born and eggs are rezzed to establish a comm channel.
58 integer ENCRYPT = TRUE; // set to TRUE to encrypt all data, Some Opensim worlds prefer FALSE due to parsing bugs, TRUE is the most secure. If FALSE you MUST change the FOOD_CHANNEL and other channels for different pets. or they will literally fuck each other.
59
60 // if you add the UUID for your avatar here, you can change it later
61 // and other alts or friends can change it too, and all of you can work on these pets.
62 // If you leave it blank, only the creator of the root prim can work on these pets.
63 key YOUR_UUID = "";
64
65 // PET NAMES - YOU MUST CHANGE THEM HERE AND IN THE ROOT PRIM OF THE OBJECT - THEY MUST MATCH EXACTLY
66 /////////////////////////
67 string MaleName = "Troubot"; // Must be the name of your animal
68 string FemaleName = "Troubot"; // The name of the female pet, if a different shape or prim count. Can be the same as the Male for pets like the robot that are unisex.
69 string Egg = "Nut and Bolt"; // was 'XS Egg', must be the name of your egg
70 string Crate = "Transport Spaceship"; // was XS-Cryocrate, must be the name of the crate you package pets in
71 string HomeObject = "Home Flag"; // was "XS Home Object", must be the name of your Home Post indicator
72 string EggCup = "Toolbox"; // was "XS Egg Cup", must be the name of your egg holder
73 // any other object names are 'do not cares'.
74
75 // NOTHING NEEDS TO BE CHANGED BELOW, BUT CAN BE CHANGED IF YOU DO IT EVERYWHERE
76
77 // misc tunables
78 float GROWTH_AMOUNT = 0.10; // 10% size increase each day for MaxAge days = 200% (double size after 7 days)
79 integer MaxAge = 7; // stop growing in seven days. 10% growth compounded daily means that your pet will be 194% larger ( 2x, basically) in 7 days.
80 integer UNITS_OF_FOOD = 168; // food bowl food qty, used by food bowl only
81 float secs_to_grow = 86400; // grow daily = 86400 seconds
82 float FOOD_BOWL_SCAN_INTERVAL = 1800.0; // look for food every 3 hours
83 float fPregnancy = 172800.0; // how many seconds to lay an egg = 2 days or 48 hours.
84 float MALE_TIMEOUT = 900.0 ; // in seconds, female waits this long in one spot for a male to arrive
85 float SEX_WAIT = 10800.0; // How often they desire sex = 3 hours
86 float fDaysToAdult = 7; // 7 days to become old enough to breed.
87 integer SECONDS_BETWEEN_FOOD_NORMAL = 14400; // number of seconds to get hungry = 4 hours
88 integer SECONDS_BETWEEN_FOOD_HUNGRY = 3600; // number of seconds before hunger count increases = 1 hour
89 integer MAXIMUM_HUNGER = 30; // They die after a month with no food.
90
91
92 // I control versions by Subversion Source Code Control. But the updater needs a version numbert in world.
93 // This is the Protocol version. If you change this, then all pets with a lower version will be updated by the updater
94 float VERSION = 0.50;
95
96
97
98 // the leg sizes are safe to leave alone or set to 0 if you use a thin base prim, these are from the original Quail
99 float LegLength = 0.064; // length of pet leg??? - not sure
100 float LegOffset = 0.052399; // This is added to the Post Z to position the pet
101
102 // the following are global constants and do not need to be changed
103 // Prim animation linkmessages are sent by scripts on Link Message number 1
104 // The strings are the names of the animations that are recorded.
105 // No need to change them unless you want to change names of the animations when you run the prim animator, or you add additional link messages
106 // If your pet walks, you need to record these names and save them in the notecard
107 //
108 // Example:
109 // llMessageLinked(LINK_SET, LINK_ANIMATE, ANI_STAND, "");
110 // The above line will play the pre-recorded 'stand up' animation "stand" using the animator script.
111 // The following animations are used in the pet. You can add your own.
112
113 string ANI_STAND = "stand"; // default standing animation
114 string ANI_WALKL = "left"; // triggers Left foot and Right arm walk animation
115 string ANI_WALKR = "right"; // triggers Right foot and Left arm walk animation
116 string ANI_SLEEP = "sleep"; // Sleeping
117 string ANI_WAVE = "wave"; // Calling for sex, needs help with food, etc.
118
119 // Channel assignments
120 // if you change any of these constants, change it everywhere and in the list in XS_Debug so it can print them
121 // If you turn encryption FALSE, you MUST change these between species of pets are they will fuck with each other. Literally.
122
123 integer FOOD_CHANNEL = -999191;
124 integer ANIMAL_CHANNEL = -999192;
125 integer EGG_CHANNEL = -999193;
126 integer HOME_CHANNEL = -999194;
127 integer BOX_CHANNEL = -999195;
128 integer ACC_CHANNEL = -999196;
129 integer UPDATE_CHANNEL = -999197;
130 integer API_CHANNEL = -999198;
131
132 // global link messages to control the animal, never any need to change these.
133 // They are exposed here so they will be the same everywhere. This uses a bit of RAM, but who cares?
134
135 integer LINK_ANIMATE = 1; // messages on num 1 are assumed to be directed at the prim animator.
136 integer DECREASE_FOOD = 100; // used in the food bowl.
137 integer LINK_AGE_START = 800; // when pety is rezzed and secret_number is sent by brain to breeder, eater and infomatic get booted up
138 integer LINK_TEXTURE = 801; // ask for a new texture, or paint a color
139 integer LINK_BREEDNAME = 802; // the name of the pet texture from the texture server notecard
140 integer LINK_FOOD_CONSUME = 900; // from movement to brain when close to food, brain then consumes a random amount up to 10000
141 integer LINK_FOODMINUS = 901; // xs_brain receives FOOD_CONSUME, decrement hunger (eat)
142 integer LINK_HUNGRY = 903; // sent by eater (string)hunger_amount, checks each hour
143 integer LINK_HAMOUNT = 904; // hunger_amount = (integer)str,m updates the hunger amount in scripts
144 integer LINK_SET_HOME = 910; // loc ^ dist
145 integer LINK_MOVER = 911; // tell mover to rest for str seconds
146 integer LINK_FOODIE_CLR = 920; // clear all food_bowl_keys and contents
147 integer LINK_FOODIE = 921; // send FOOD_LOCATION coordinates to movement
148 integer LINK_COLOR1 = 930; // colour1
149 integer LINK_COLOR2 = 931; // colour2
150 integer LINK_SEX = 932; // sex
151 integer LINK_SHINE = 933; // shine
152 integer LINK_GLOW = 934; // glow
153 integer LINK_GEN = 935; // generation
154 integer LINK_RESET_SIZE = 936; // reset size to 1
155 integer LINK_MAGE = 940; // xs_brain sends, xs_ager consumes, adds str to age, if older than 7 days, will grow the animal
156 integer LINK_DAYTIME = 941; // xs_ager consumes, starts a timer of 86,400 seconds in xs_ager
157 integer LINK_GET_AGE = 942; // get age from xs_ager and sent it on channel 943
158 integer LINK_PUT_AGE = 943; // print age from xs_ager
159 integer LINK_PACKAGE = 950; // look for a cryo_crate
160 integer LINK_SEEK_FEMALE = 960; // MALE_BREED_CALL
161 integer LINK_MALE_BREED_CALL = 961; // triggered by LINK_SEEK_FEMALE
162 integer LINK_SIGNAL_ELIGIBLE = 962; // sent by female when hears LINK_MALE_BREED_CALL
163 integer LINK_FEMALE_ELIGIBLE = 963; // sent when it hears in chat FEMALE_ELIGIBLE
164 integer LINK_CALL_MALE = 964; // if LINK_FEMALE_ELIGIBLE && looking_for_female
165 integer LINK_MALE_ON_THE_WAY = 965; // triggered by LINK_CALL_MALE
166 integer LINK_FEMALE_LOCATION = 966; // female location, sends coordinates of a female
167 integer LINK_RQST_BREED = 967; // sent when close enough to male/female
168 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.
169 integer LINK_MALE_INFO = 969; // Breeding failed, sent info
170 integer LINK_LAY_EGG = 970; // Rez Object(Egg...
171 integer LINK_BREED_FAIL = 971; // key = father, failed, timed out
172 integer LINK_PREGNANT = 972; // chick is preggers
173 integer LINK_SOUND_OFF= 974; // sound is off
174 integer LINK_SOUND_ON= 973; // sound is on
175 integer LINK_SLEEPING = 990; // close eyes
176 integer LINK_UNSLEEPING = 991; // open eyes
177 integer LINK_SOUND = 1001; // plays a sound if enabled
178 integer LINK_SPECIAL = 1010; // xs_special, if str = "Normal", removes script
179 integer LINK_EFFECTS_ON = 2000; // particle effects in the packger
180 integer LINK_PREGNANCY_TIME = 5000; // in seconds as str
181 integer LINK_SLEEP = 7999; // disable sleep by parameter
182 integer LINK_TIMER = 8000; // scan for food bowl about every 1800 seconds
183 integer LINK_DIE = 9999; // death
184
185 string Copyright = " (c)2014 by Ferd Frederix"; // You cannot change this line, but you can change the code that prints it!
186 // See License agreements above.
187 // Attribution is required, as these files are copyrighted.
188
189
190 DEBUG ( string msg){
191 if(debug) {
192 llOwnerSay(llGetScriptName() + ":" + msg);
193 }
194 }
195
196
197
198 ///////// end global Link constants ////////
199
200 // END OF COPIED CODE
201
202
203
204
205
206
207
208
209
210
211
212
213 vector home_location;
214 float roam_distance;
215 list food_bowls;
216 list food_bowl_keys;
217 list food_bowl_time;
218
219 vector destination;
220
221 integer sex_dest = 0;
222 integer food_dest = 0;
223 float tolerance = 0.15;
224 float increment = 0.1;
225 integer rest;
226 integer age;
227 float zoffset;
228 integer sleep_last_check ;
229 integer sound_on;
230 integer sleep_disabled;
231
232
233 //new mover on a sphere
234 float RADIUS = 1.0;
235 rotation gOrient;
236 list gSilly_walks;
237 integer gCounter;
238
239
240
241 GetNewPos()
242 {
243 // start over and calc a new walk
244
245 gSilly_walks = [];
246
247
248 float x = llFrand(5) + 5;
249
250 float y = llFrand(5) + 5;
251
252 float z = llFrand(5) + 5;
253
254 if(llFrand(2) > 1)
255 x = 1-x;
256 if(llFrand(2) > 1)
257 y = 1-z;
258 if(llFrand(2) > 1)
259 z = 1-z;
260
261
262 rotation delta = llEuler2Rot(<x,y,z> * DEG_TO_RAD);
263
264 integer STEPS = llCeil( llFrand(10)) + 1;
265 integer i;
266 for (i = 0; i < STEPS; i++)
267 {
268 vector unitpos = llRot2Fwd( gOrient );
269 vector pos = home_location + unitpos * RADIUS;
270
271 gSilly_walks += pos;
272 gSilly_walks += gOrient;
273
274 gOrient = gOrient * delta;
275 }
276
277
278
279 }
280
281
282
283
284 face_target(vector lookat) {
285
286 rotation rot = llGetRot() * llRotBetween(<1.0 ,0.0 ,0.0 > * llGetRot(), lookat - llGetPos());
287
288
289 llMessageLinked(LINK_SET, LINK_ANIMATE, ANI_WALKL, "");
290 llMessageLinked(LINK_SET, LINK_ANIMATE, ANI_WALKR, "");
291
292 vector nine = <90,0,0> * DEG_TO_RAD;
293 rotation new = llEuler2Rot(nine);
294
295
296 llSetRot(rot * new);
297 llSleep(.1);
298
299 rot = llGetRot() * llRotBetween(<0.0 ,0.0 ,1.0 > * llGetRot(), home_location - llGetPos());
300 llSetRot(rot * new);
301 }
302
303 integer sleeping()
304 {
306 if(!sleep_disabled) {
307 if(sun.z < 0) {
308 if(sleep_last_check == 0) {
309 // close eyes
310 llMessageLinked(LINK_SET, LINK_SLEEPING, "", "");
311 llMessageLinked(LINK_SET, LINK_ANIMATE, ANI_SLEEP, "");
312 }
313 sleep_last_check = 1;
314 } else {
315 if(sleep_last_check == 1) {
316 // open eyes
317 llMessageLinked(LINK_SET, LINK_ANIMATE, ANI_STAND, "");
318 llMessageLinked(LINK_SET, LINK_UNSLEEPING, "", "");
319 }
320 sleep_last_check = 0;
321 }
322 return sleep_last_check;
323 } else {
324 if(sleep_last_check == 1) {
325 llMessageLinked(LINK_SET, LINK_ANIMATE, ANI_STAND, "");
326 llMessageLinked(LINK_SET, LINK_UNSLEEPING, "", "");
327 sleep_last_check = 0;
328 }
329 return 0;
330 }
331 }
332
333 default
334 {
335 link_message(integer sender, integer num, string str, key id)
336 {
337 if(num == LINK_AGE_START) {
338 state running;
339 }
340 }
341 }
342
343 state running
344 {
346 {
347 gOrient = ZERO_ROTATION;
348 home_location = <0,0,0>;
349 roam_distance = 0;
350 destination = <0,0,0>;
351 age = 0;
352 sleep_last_check = 0;
353 sound_on = 1;
354 }
355
356
357 timer()
358 {
359
360
361 if(!sleeping())
362 {
363 if(sound_on) {
364 llMessageLinked(LINK_SET, LINK_SOUND, "", "");
365 }
366 sound_on = !sound_on;
367
368 if(rest > 0) {
369 // llSetText((string) rest,<1,0,0>,1);
370 rest--;
371 return;
372 }
373
374 if(llVecDist( destination, llGetPos()) <= tolerance || destination == <0,0,0>)
375 {
376 // if at food_destination send 900 msg
377 if(food_dest > 0) {
378 llMessageLinked(LINK_SET, LINK_FOOD_CONSUME, (string)food_dest, llList2Key(food_bowl_keys, 0));
379 }
380
381 if(sex_dest > 0) {
382
383 llMessageLinked(LINK_SET, LINK_ANIMATE, ANI_WAVE, "");
384 llMessageLinked(LINK_SET, LINK_ANIMATE, ANI_STAND, "");
385 llMessageLinked(LINK_SET, LINK_RQST_BREED, "", "");
386
387 }
388 // pick a new destination
389 sex_dest = 0;
390 food_dest = 0;
391
392 }
393
394
395 integer walkLength = llGetListLength(gSilly_walks);
396 if( walkLength > 0)
397 {
398 vector pos = llList2Vector(gSilly_walks,0);
399 rotation orient = llList2Rot(gSilly_walks,1);
400
401 gCounter++;
402 face_target(pos);
403 llSetPos(pos);
404
405
406
407 //llSetRot(orient);
408
409 gSilly_walks = llDeleteSubList(gSilly_walks,0,1); // we have walked in those shoes
410 }
411 else
412 {
413 GetNewPos();
414
415 rest = (integer)llFrand(12.0); // 1 minute rest
416 //llOwnerSay("resting for " + (string) rest);
417 }
418
419 llMessageLinked(LINK_SET, LINK_ANIMATE, ANI_WALKL, "");
420 llMessageLinked(LINK_SET, LINK_ANIMATE, ANI_WALKR, "");
421 llMessageLinked(LINK_SET, LINK_ANIMATE, ANI_STAND, "");
422
423 }
424 }
425
426 link_message(integer sender, integer num, string str, key id)
427 {
428 if(num == LINK_HUNGRY) {
429 if(sex_dest == 0) {
430 // move to food bowl, then send 900
431 if(llGetListLength(food_bowl_keys) > 0) {
432 if(roam_distance == 0 || home_location == <0,0,0>) {
433 llOwnerSay("I'm hungry, but I'm not homed so I can not move! Attempting to use Jedi Mind Powers to teleport food to my belly.");
434 llMessageLinked(LINK_SET, LINK_FOOD_CONSUME, str, llList2Key(food_bowl_keys, 0));
435 llMessageLinked(LINK_SET, LINK_ANIMATE, ANI_STAND, "");
436 llMessageLinked(LINK_SET, LINK_ANIMATE, ANI_WAVE, "");
437 llMessageLinked(LINK_SET, LINK_ANIMATE, ANI_STAND, "");
438 } else {
439 // find nearest food bowl
440 integer i;
441 destination = (vector)llList2String(food_bowls, 0);
442 for (i=1;i<llGetListLength(food_bowls);i++) {
443 if(llVecDist(destination, llGetPos()) > llVecDist((vector)llList2String(food_bowls, i), llGetPos())) {
444 destination = (vector)llList2String(food_bowls, i);
445 }
446 }
447 destination.z = home_location.z + zoffset;
448 // set destination,
449 // face it
450 face_target(destination);
451 food_dest = (integer)str;
452 rest = 0;
453 //llMessageLinked(LINK_SET, LINK_FOOD_CONSUME, str, llList2Key(food_bowl_keys, 0));
454 }
455 } else {
456 llMessageLinked(LINK_SET, LINK_ANIMATE, ANI_STAND, "");
457 llMessageLinked(LINK_SET, LINK_ANIMATE, ANI_WAVE, "");
458 llMessageLinked(LINK_SET, LINK_ANIMATE, ANI_STAND, "");
459 llOwnerSay("I'm hungry, but I can't seem to find any food bowls at present.");
460 }
461 }
462 } else
463 if(num == LINK_SET_HOME) {
464 list values = llParseString2List(str, ["^"], []);
465 home_location = (vector)llList2String(values, 0);
466 roam_distance = llList2Float(values, 1);
467 vector current_loc = llGetPos();
468
469 food_bowls = [];
470 food_bowl_keys = [];
471 food_bowl_time = [];
472
473 destination = <0,0,0>;
474 food_dest = 0;
475 llMessageLinked(LINK_SET, LINK_ANIMATE, ANI_STAND, "");
476 llMessageLinked(LINK_SET, LINK_ANIMATE, ANI_WAVE, "");
477 llMessageLinked(LINK_SET, LINK_ANIMATE, ANI_STAND, "");
478
479 GetNewPos();
480 llSetTimerEvent(4.0);
481
482 llOwnerSay("Homed");
483
484 } else
485 if(num == LINK_MOVER) {
486 if(rest < (integer)str) {
487 rest = (integer)str;
488 }
489 } else
490 if(num == LINK_FOODIE_CLR) {
491 food_bowls = [];
492 food_bowl_keys = [];
493 food_bowl_time = [];
494 } else
495 if(num == LINK_FOODIE) {
496 vector food_loc = (vector)str;
497
498 if(llVecDist(home_location, food_loc) <= roam_distance && llFabs(llFabs(home_location.z) - llFabs(food_loc.z)) < 2) {
499 if(llListFindList(food_bowls, (list)str) == -1) {
500 integer id_pos = llListFindList(food_bowl_keys, (list)id);
501 if(id_pos == -1) {
502 food_bowls += str;
503 food_bowl_keys += id;
504 food_bowl_time += llGetUnixTime();
505 } else {
506 food_bowls = llListReplaceList(food_bowls, [str], id_pos, id_pos);
507 food_bowl_time = llListReplaceList(food_bowl_time, [llGetUnixTime()], id_pos, id_pos);
508 }
509 }
510
511 integer iter;
512
513 iter = 0;
514
515 while(iter<llGetListLength(food_bowls)) {
516 if(llGetUnixTime() - llList2Integer(food_bowl_time, iter) > 3600) {//3600
517 food_bowls = llDeleteSubList(food_bowls, iter, iter);
518 food_bowl_keys = llDeleteSubList(food_bowl_keys, iter, iter);
519 food_bowl_time = llDeleteSubList(food_bowl_time, iter, iter);
520 } else {
521 iter++;
522 }
523 }
524
525 if(llGetListLength(food_bowls) > 0) {
526 llMessageLinked(LINK_SET, LINK_TIMER, "", "");
527 }
528
529 }
530 } else
531 if(num == LINK_FEMALE_LOCATION) {
532 destination = (vector)str;
533 face_target(destination);
534 rest = 0;
535 food_dest = 0;
536 sex_dest = 1;
537 llMessageLinked(LINK_SET, LINK_ANIMATE, ANI_STAND, "");
538 llMessageLinked(LINK_SET, LINK_ANIMATE, ANI_WAVE, "");
539 llMessageLinked(LINK_SET, LINK_ANIMATE, ANI_STAND, "");
540 } else
541 if(num == LINK_MAGE) {
542 integer heightm;
543 age += (integer)str;
544 heightm = age;
545
546 if(heightm > MaxAge)
547 heightm = MaxAge;
548 float new_scale = (GROWTH_AMOUNT * heightm) + 1.0;
549
550 float legsz = 0.064 * new_scale; /// !!! does this need scaling?
551 float legso = 0.052399 * new_scale;
552
553 zoffset = 0 ;// no offset
554 } else
555 if(num == LINK_SLEEP) {
556 sleep_disabled = (integer)str;
557 }
558 }
559 }

XS Pet Robot

XS Pet Modified xs_home script for the sphere.

Category: XS Pet
By : Ferd Frederix
Created: 2013-09-06 Edited: 2015-07-24
Worlds: Second Life


This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1
2 // Modified xs_home script for the sphere.
3
4 // This lets you and your pets walk on the sphere
5
6
7
8
9
10
11 // START OF COPIED file 'Global Constants.txt' from the Debug folder. It has to be the same in all files
12 // If you change this in any script, change it in all of them, please. It works a lot better that way.
13
14 // This is code based on Version 0.50 01-30-2014
15 // For version history, see file revisions.txt
16 //
17 // LICENSE
18 /////////////////////////////////////////////////////////////////////
19 // This code is licensed as Creative Commons Attribution/NonCommercial/Share Alike
20 // See http://creativecommons.org/liceses/by-nc-sa/3.0/
21 // Noncommercial -- You may not use this work for commercial purposes, i.e., you cannot sell this script in any form, including derivatives.
22 // If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one.
23 // This means that you cannot sell this or derivative code by itself, but you may share and use this code in any object or virtual world.
24 // You must attribute authorship in the original scripts to Ferd Frederix and Xundra Snowpaw, and leave this notice intact.
25 // You do not have to give back to the community any changes you make, however, code changes would be greatly appreciated!
26 //
27 // Exception: I am allowing this script to be used in an original build and sold with the build.
28 // You are not selling the script, you are selling the build. If you want to sell these scripts, write your own or use the original at http://code.google.com/p/xspets/
29 // Note: Xundra Snowpaw's license was 'New BSD' license and adding additional licenses is allowed.
30
31 // Based on code from Xundra Snowpaw
32 // New BSD License: http://www.opensource.org/licenses/bsd-license.php
33 // Copyright (c) 2010, Xundra Snowpaw
34 // All rights reserved.
35 // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
36
37 //* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
38 //* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer
39 // in the documentationand/or other materials provided with the distribution.
40
41 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
42 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
43 // BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
44 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
45 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
46 // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
47 ////////////////////////////////////////////////////////////////////
48
49 // DEBUG - lets you see and hear wtf is happening
50 integer debug = FALSE; // set to TRUE TO hear a lot of chat
51
52
53 // This section has a few tuneable items that MUST be changed for any new pet
54
55 // SECURITY
56 string SECRET_PASSWORD = "top secret string"; // must use a password unique to any species of animal, when ENCRYPT= TRUE. Otherwise you will find Pet type A fucking pet type B.
57 integer SECRET_NUMBER = 99999; // any number thats a secret, not necessary to change usually, this is used when pets are born and eggs are rezzed to establish a comm channel.
58 integer ENCRYPT = TRUE; // set to TRUE to encrypt all data, Some Opensim worlds prefer FALSE due to parsing bugs, TRUE is the most secure. If FALSE you MUST change the FOOD_CHANNEL and other channels for different pets. or they will literally fuck each other.
59
60 // if you add the UUID for your avatar here, you can change it later
61 // and other alts or friends can change it too, and all of you can work on these pets.
62 // If you leave it blank, only the creator of the root prim can work on these pets.
63 key YOUR_UUID = "";
64
65 // PET NAMES - YOU MUST CHANGE THEM HERE AND IN THE ROOT PRIM OF THE OBJECT - THEY MUST MATCH EXACTLY
66 /////////////////////////
67 string MaleName = "Troubot"; // Must be the name of your animal
68 string FemaleName = "Troubot"; // The name of the female pet, if a different shape or prim count. Can be the same as the Male for pets like the robot that are unisex.
69 string Egg = "Nut and Bolt"; // was 'XS Egg', must be the name of your egg
70 string Crate = "Transport Spaceship"; // was XS-Cryocrate, must be the name of the crate you package pets in
71 string HomeObject = "Home Flag"; // was "XS Home Object", must be the name of your Home Post indicator
72 string EggCup = "Toolbox"; // was "XS Egg Cup", must be the name of your egg holder
73 // any other object names are 'do not cares'.
74
75 // NOTHING NEEDS TO BE CHANGED BELOW, BUT CAN BE CHANGED IF YOU DO IT EVERYWHERE
76
77 // misc tunables
78 float GROWTH_AMOUNT = 0.10; // 10% size increase each day for MaxAge days = 200% (double size after 7 days)
79 integer MaxAge = 7; // stop growing in seven days. 10% growth compounded daily means that your pet will be 194% larger ( 2x, basically) in 7 days.
80 integer UNITS_OF_FOOD = 168; // food bowl food qty, used by food bowl only
81 float secs_to_grow = 86400; // grow daily = 86400 seconds
82 float FOOD_BOWL_SCAN_INTERVAL = 1800.0; // look for food every 3 hours
83 float fPregnancy = 172800.0; // how many seconds to lay an egg = 2 days or 48 hours.
84 float MALE_TIMEOUT = 900.0 ; // in seconds, female waits this long in one spot for a male to arrive
85 float SEX_WAIT = 10800.0; // How often they desire sex = 3 hours
86 float fDaysToAdult = 7; // 7 days to become old enough to breed.
87 integer SECONDS_BETWEEN_FOOD_NORMAL = 14400; // number of seconds to get hungry = 4 hours
88 integer SECONDS_BETWEEN_FOOD_HUNGRY = 3600; // number of seconds before hunger count increases = 1 hour
89 integer MAXIMUM_HUNGER = 30; // They die after a month with no food.
90
91
92 // I control versions by Subversion Source Code Control. But the updater needs a version numbert in world.
93 // This is the Protocol version. If you change this, then all pets with a lower version will be updated by the updater
94 float VERSION = 0.50;
95
96
97
98 // the leg sizes are safe to leave alone or set to 0 if you use a thin base prim, these are from the original Quail
99 float LegLength = 0.064; // length of pet leg??? - not sure
100 float LegOffset = 0.052399; // This is added to the Post Z to position the pet
101
102 // the following are global constants and do not need to be changed
103 // Prim animation linkmessages are sent by scripts on Link Message number 1
104 // The strings are the names of the animations that are recorded.
105 // No need to change them unless you want to change names of the animations when you run the prim animator, or you add additional link messages
106 // If your pet walks, you need to record these names and save them in the notecard
107 //
108 // Example:
109 // llMessageLinked(LINK_SET, LINK_ANIMATE, ANI_STAND, "");
110 // The above line will play the pre-recorded 'stand up' animation "stand" using the animator script.
111 // The following animations are used in the pet. You can add your own.
112
113 string ANI_STAND = "stand"; // default standing animation
114 string ANI_WALKL = "left"; // triggers Left foot and Right arm walk animation
115 string ANI_WALKR = "right"; // triggers Right foot and Left arm walk animation
116 string ANI_SLEEP = "sleep"; // Sleeping
117 string ANI_WAVE = "wave"; // Calling for sex, needs help with food, etc.
118
119 // Channel assignments
120 // if you change any of these constants, change it everywhere and in the list in XS_Debug so it can print them
121 // If you turn encryption FALSE, you MUST change these between species of pets are they will fuck with each other. Literally.
122
123 integer FOOD_CHANNEL = -999191;
124 integer ANIMAL_CHANNEL = -999192;
125 integer EGG_CHANNEL = -999193;
126 integer HOME_CHANNEL = -999194;
127 integer BOX_CHANNEL = -999195;
128 integer ACC_CHANNEL = -999196;
129 integer UPDATE_CHANNEL = -999197;
130 integer API_CHANNEL = -999198;
131
132 // global link messages to control the animal, never any need to change these.
133 // They are exposed here so they will be the same everywhere. This uses a bit of RAM, but who cares?
134
135 integer LINK_ANIMATE = 1; // messages on num 1 are assumed to be directed at the prim animator.
136 integer DECREASE_FOOD = 100; // used in the food bowl.
137 integer LINK_AGE_START = 800; // when pety is rezzed and secret_number is sent by brain to breeder, eater and infomatic get booted up
138 integer LINK_TEXTURE = 801; // ask for a new texture, or paint a color
139 integer LINK_BREEDNAME = 802; // the name of the pet texture from the texture server notecard
140 integer LINK_FOOD_CONSUME = 900; // from movement to brain when close to food, brain then consumes a random amount up to 10000
141 integer LINK_FOODMINUS = 901; // xs_brain receives FOOD_CONSUME, decrement hunger (eat)
142 integer LINK_HUNGRY = 903; // sent by eater (string)hunger_amount, checks each hour
143 integer LINK_HAMOUNT = 904; // hunger_amount = (integer)str,m updates the hunger amount in scripts
144 integer LINK_SET_HOME = 910; // loc ^ dist
145 integer LINK_MOVER = 911; // tell mover to rest for str seconds
146 integer LINK_FOODIE_CLR = 920; // clear all food_bowl_keys and contents
147 integer LINK_FOODIE = 921; // send FOOD_LOCATION coordinates to movement
148 integer LINK_COLOR1 = 930; // colour1
149 integer LINK_COLOR2 = 931; // colour2
150 integer LINK_SEX = 932; // sex
151 integer LINK_SHINE = 933; // shine
152 integer LINK_GLOW = 934; // glow
153 integer LINK_GEN = 935; // generation
154 integer LINK_RESET_SIZE = 936; // reset size to 1
155 integer LINK_MAGE = 940; // xs_brain sends, xs_ager consumes, adds str to age, if older than 7 days, will grow the animal
156 integer LINK_DAYTIME = 941; // xs_ager consumes, starts a timer of 86,400 seconds in xs_ager
157 integer LINK_GET_AGE = 942; // get age from xs_ager and sent it on channel 943
158 integer LINK_PUT_AGE = 943; // print age from xs_ager
159 integer LINK_PACKAGE = 950; // look for a cryo_crate
160 integer LINK_SEEK_FEMALE = 960; // MALE_BREED_CALL
161 integer LINK_MALE_BREED_CALL = 961; // triggered by LINK_SEEK_FEMALE
162 integer LINK_SIGNAL_ELIGIBLE = 962; // sent by female when hears LINK_MALE_BREED_CALL
163 integer LINK_FEMALE_ELIGIBLE = 963; // sent when it hears in chat FEMALE_ELIGIBLE
164 integer LINK_CALL_MALE = 964; // if LINK_FEMALE_ELIGIBLE && looking_for_female
165 integer LINK_MALE_ON_THE_WAY = 965; // triggered by LINK_CALL_MALE
166 integer LINK_FEMALE_LOCATION = 966; // female location, sends coordinates of a female
167 integer LINK_RQST_BREED = 967; // sent when close enough to male/female
168 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.
169 integer LINK_MALE_INFO = 969; // Breeding failed, sent info
170 integer LINK_LAY_EGG = 970; // Rez Object(Egg...
171 integer LINK_BREED_FAIL = 971; // key = father, failed, timed out
172 integer LINK_PREGNANT = 972; // chick is preggers
173 integer LINK_SOUND_OFF= 974; // sound is off
174 integer LINK_SOUND_ON= 973; // sound is on
175 integer LINK_SLEEPING = 990; // close eyes
176 integer LINK_UNSLEEPING = 991; // open eyes
177 integer LINK_SOUND = 1001; // plays a sound if enabled
178 integer LINK_SPECIAL = 1010; // xs_special, if str = "Normal", removes script
179 integer LINK_EFFECTS_ON = 2000; // particle effects in the packger
180 integer LINK_PREGNANCY_TIME = 5000; // in seconds as str
181 integer LINK_SLEEP = 7999; // disable sleep by parameter
182 integer LINK_TIMER = 8000; // scan for food bowl about every 1800 seconds
183 integer LINK_DIE = 9999; // death
184
185 string Copyright = " (c)2014 by Ferd Frederix"; // You cannot change this line, but you can change the code that prints it!
186 // See License agreements above.
187 // Attribution is required, as these files are copyrighted.
188
189
190 DEBUG ( string msg){
191 if(debug) {
192 llOwnerSay(llGetScriptName() + ":" + msg);
193 }
194 }
195
196
197
198 ///////// end global Link constants ////////
199
200 // END OF COPIED CODE
201
202
203
204
205
206
207
208
209
210 /////// DON'T CHANGE THE FOLLOWING! (Unless you know what you are doing!)
211
212 integer XTEA_DELTA = 0x9E3779B9; // (sqrt(5) - 1) * 2^31
213 integer xtea_num_rounds = 6;
214 list xtea_key = [0, 0, 0, 0];
215
216 integer hex2int(string hex) {
217 if(llGetSubString(hex,0,1) == "0x")
218 return (integer)hex;
219 if(llGetSubString(hex,0,0) == "x")
220 return (integer)("0"+hex);
221 return(integer)("0x"+hex);
222 }
223
224
225 // Convers any string to a 32 char MD5 string and then to a list of
226 // 4 * 32 bit integers = 128 bit Key. MD5 ensures always a specific
227 // 128 bit key is generated for any string passed.
228 list xtea_key_from_string( string str )
229 {
230 str = llMD5String(str,0); // Use Nonce = 0
231 return [ hex2int(llGetSubString( str, 0, 7)),
232 hex2int(llGetSubString( str, 8, 15)),
233 hex2int(llGetSubString( str, 16, 23)),
234 hex2int(llGetSubString( str, 24, 31))];
235 }
236
237 // Encipher two integers and return the result as a 12-byte string
238 // containing two base64-encoded integers.
239 string xtea_encipher( integer v0, integer v1 )
240 {
241 integer num_rounds = xtea_num_rounds;
242 integer sum = 0;
243 do {
244 // LSL does not have unsigned integers, so when shifting right we
245 // have to mask out sign-extension bits.
246 v0 += (((v1 << 4) ^ ((v1 >> 5) & 0x07FFFFFF)) + v1) ^ (sum + llList2Integer(xtea_key, sum & 3));
247 sum += XTEA_DELTA;
248 v1 += (((v0 << 4) ^ ((v0 >> 5) & 0x07FFFFFF)) + v0) ^ (sum + llList2Integer(xtea_key, (sum >> 11) & 3));
249
250 } while( num_rounds = ~-num_rounds );
251 //return only first 6 chars to remove "=="'s and compact encrypted text.
252 return llGetSubString(llIntegerToBase64(v0),0,5) +
254 }
255
256 // Decipher two base64-encoded integers and return the FIRST 30 BITS of
257 // each as one 10-byte base64-encoded string.
258 string xtea_decipher( integer v0, integer v1 )
259 {
260 integer num_rounds = xtea_num_rounds;
261 integer sum = XTEA_DELTA*xtea_num_rounds;
262 do {
263 // LSL does not have unsigned integers, so when shifting right we
264 // have to mask out sign-extension bits.
265 v1 -= (((v0 << 4) ^ ((v0 >> 5) & 0x07FFFFFF)) + v0) ^ (sum + llList2Integer(xtea_key, (sum>>11) & 3));
266 sum -= XTEA_DELTA;
267 v0 -= (((v1 << 4) ^ ((v1 >> 5) & 0x07FFFFFF)) + v1) ^ (sum + llList2Integer(xtea_key, sum & 3));
268 } while( num_rounds = ~-num_rounds );
269
270 return llGetSubString(llIntegerToBase64(v0), 0, 4) +
272 }
273
274 // Encrypt a full string using XTEA.
275 string xtea_encrypt_string( string str )
276 {
277 if(! ENCRYPT)
278 return str;
279 // encode string
280 str = llStringToBase64(str);
281 // remove trailing =s so we can do our own 0 padding
282 integer i = llSubStringIndex( str, "=" );
283 if( i != -1 )
284 str = llDeleteSubString( str, i, -1 );
285
286 // we don't want to process padding, so get length before adding it
287 integer len = llStringLength(str);
288
289 // zero pad
290 str += "AAAAAAAAAA=";
291
292 string result;
293 i = 0;
294
295 do {
296 // encipher 30 (5*6) bits at a time.
297 result += xtea_encipher(llBase64ToInteger(llGetSubString(str, i, i + 4) + "A="), llBase64ToInteger(llGetSubString(str, i+5, i + 9) + "A="));
298 i+=10;
299 } while( i < len );
300
301 return result;
302 }
303
304 // Decrypt a full string using XTEA
305 string xtea_decrypt_string( string str ) {
306 if(! ENCRYPT)
307 return str;
308 integer len = llStringLength(str);
309 integer i=0;
310 string result;
311 //llOwnerSay(str);
312 do {
313 integer v0;
314 integer v1;
315
316 v0 = llBase64ToInteger(llGetSubString(str, i, i + 5) + "==");
317 i+= 6;
318 v1 = llBase64ToInteger(llGetSubString(str, i, i + 5) + "==");
319 i+= 6;
320
321 result += xtea_decipher(v0, v1);
322 } while( i < len );
323
324 // Replace multiple trailing zeroes with a single one
325
326 i = llStringLength(result) - 1;
327 while( llGetSubString(result, i - 1, i) == "AA" ){
328 result = llDeleteSubString(result, i, i);
329 i--;
330 }
331 i = llStringLength(result) - 1;
332 // while(llGetSubString(result, i, i + 1) == "A" ) {
333 // i--;
334 // }
335 result = llGetSubString(result, 0, i+1);
336 i = llStringLength(result);
337 integer mod = i%4; //Depending on encoded length diffrent appends are needed
338 if(mod == 1) result += "A==";
339 else if(mod == 2 ) result += "==";
340 else if(mod == 3) result += "=";
341
342 return llBase64ToString(result);
343 }
344
345 string base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
346
347 //tunables
348 integer world = TRUE;
349
350 default
351 {
353 {
354 xtea_key = xtea_key_from_string(SECRET_PASSWORD);
355 llListen(HOME_CHANNEL, "", "", "XSPET_PING_HOME"); // listen for a pet to say XSPET_PING_HOME - Mod by Ferd to listen to HOME_CHANNEL, not -237918
356
357 }
358
359 touch_start(integer total_number)
360 {
361 if(llDetectedKey(0) == llGetOwner()) {
362 vector size = llGetScale();
363 vector pos = llGetPos();
364 if(!world)
365 pos.z = pos.z - size.z / 2;
366
367 llShout(ANIMAL_CHANNEL, xtea_encrypt_string("XSPET^HOME_LOCATION^" + (string)pos + "^" + llGetObjectDesc()));
368 }
369 llOwnerSay("Setting Home Location");
370 }
371
372 listen(integer channel, string name, key id, string msg)
373 {
374 vector size = llGetScale();
375 vector pos = llGetPos();
376 if(!world)
377 pos.z = pos.z - size.z / 2;
378
379 llShout(ANIMAL_CHANNEL, xtea_encrypt_string("XSPET^HOME_LOCATION^" + (string)pos + "^" + llGetObjectDesc()));
380 }
381 }

XS Pet Robot

XS Pet xs_radius

Category: XS Pet
By : Ferd Frederix
Created: 2013-09-06 Edited: 2015-07-24
Worlds: Second Life


This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1
2 // xs_radius
3 // Version .28 11-26-2011
4
5
6 // add to the Sphere to send the radius of the moon
7 // by Ferd Frederix
8
9
10
11
12
13 // START OF COPIED file 'Global Constants.txt' from the Debug folder. It has to be the same in all files
14 // If you change this in any script, change it in all of them, please. It works a lot better that way.
15
16 // This is code based on Version 0.50 01-30-2014
17 // For version history, see file revisions.txt
18 //
19 // LICENSE
20 /////////////////////////////////////////////////////////////////////
21 // This code is licensed as Creative Commons Attribution/NonCommercial/Share Alike
22 // See http://creativecommons.org/liceses/by-nc-sa/3.0/
23 // Noncommercial -- You may not use this work for commercial purposes, i.e., you cannot sell this script in any form, including derivatives.
24 // If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one.
25 // This means that you cannot sell this or derivative code by itself, but you may share and use this code in any object or virtual world.
26 // You must attribute authorship in the original scripts to Ferd Frederix and Xundra Snowpaw, and leave this notice intact.
27 // You do not have to give back to the community any changes you make, however, code changes would be greatly appreciated!
28 //
29 // Exception: I am allowing this script to be used in an original build and sold with the build.
30 // You are not selling the script, you are selling the build. If you want to sell these scripts, write your own or use the original at http://code.google.com/p/xspets/
31 // Note: Xundra Snowpaw's license was 'New BSD' license and adding additional licenses is allowed.
32
33 // Based on code from Xundra Snowpaw
34 // New BSD License: http://www.opensource.org/licenses/bsd-license.php
35 // Copyright (c) 2010, Xundra Snowpaw
36 // All rights reserved.
37 // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
38
39 //* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
40 //* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer
41 // in the documentationand/or other materials provided with the distribution.
42
43 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
44 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
45 // BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
46 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
47 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
48 // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
49 ////////////////////////////////////////////////////////////////////
50
51 // DEBUG - lets you see and hear wtf is happening
52 integer debug = FALSE; // set to TRUE TO hear a lot of chat
53
54
55 // This section has a few tuneable items that MUST be changed for any new pet
56
57 // SECURITY
58 string SECRET_PASSWORD = "top secret string"; // must use a password unique to any species of animal, when ENCRYPT= TRUE. Otherwise you will find Pet type A fucking pet type B.
59 integer SECRET_NUMBER = 99999; // any number thats a secret, not necessary to change usually, this is used when pets are born and eggs are rezzed to establish a comm channel.
60 integer ENCRYPT = TRUE; // set to TRUE to encrypt all data, Some Opensim worlds prefer FALSE due to parsing bugs, TRUE is the most secure. If FALSE you MUST change the FOOD_CHANNEL and other channels for different pets. or they will literally fuck each other.
61
62 // if you add the UUID for your avatar here, you can change it later
63 // and other alts or friends can change it too, and all of you can work on these pets.
64 // If you leave it blank, only the creator of the root prim can work on these pets.
65 key YOUR_UUID = "";
66
67 // PET NAMES - YOU MUST CHANGE THEM HERE AND IN THE ROOT PRIM OF THE OBJECT - THEY MUST MATCH EXACTLY
68 /////////////////////////
69 string MaleName = "Troubot"; // Must be the name of your animal
70 string FemaleName = "Troubot"; // The name of the female pet, if a different shape or prim count. Can be the same as the Male for pets like the robot that are unisex.
71 string Egg = "Nut and Bolt"; // was 'XS Egg', must be the name of your egg
72 string Crate = "Transport Spaceship"; // was XS-Cryocrate, must be the name of the crate you package pets in
73 string HomeObject = "Home Flag"; // was "XS Home Object", must be the name of your Home Post indicator
74 string EggCup = "Toolbox"; // was "XS Egg Cup", must be the name of your egg holder
75 // any other object names are 'do not cares'.
76
77 // NOTHING NEEDS TO BE CHANGED BELOW, BUT CAN BE CHANGED IF YOU DO IT EVERYWHERE
78
79 // misc tunables
80 float GROWTH_AMOUNT = 0.10; // 10% size increase each day for MaxAge days = 200% (double size after 7 days)
81 integer MaxAge = 7; // stop growing in seven days. 10% growth compounded daily means that your pet will be 194% larger ( 2x, basically) in 7 days.
82 integer UNITS_OF_FOOD = 168; // food bowl food qty, used by food bowl only
83 float secs_to_grow = 86400; // grow daily = 86400 seconds
84 float FOOD_BOWL_SCAN_INTERVAL = 1800.0; // look for food every 3 hours
85 float fPregnancy = 172800.0; // how many seconds to lay an egg = 2 days or 48 hours.
86 float MALE_TIMEOUT = 900.0 ; // in seconds, female waits this long in one spot for a male to arrive
87 float SEX_WAIT = 10800.0; // How often they desire sex = 3 hours
88 float fDaysToAdult = 7; // 7 days to become old enough to breed.
89 integer SECONDS_BETWEEN_FOOD_NORMAL = 14400; // number of seconds to get hungry = 4 hours
90 integer SECONDS_BETWEEN_FOOD_HUNGRY = 3600; // number of seconds before hunger count increases = 1 hour
91 integer MAXIMUM_HUNGER = 30; // They die after a month with no food.
92
93
94 // I control versions by Subversion Source Code Control. But the updater needs a version numbert in world.
95 // This is the Protocol version. If you change this, then all pets with a lower version will be updated by the updater
96 float VERSION = 0.50;
97
98
99
100 // the leg sizes are safe to leave alone or set to 0 if you use a thin base prim, these are from the original Quail
101 float LegLength = 0.064; // length of pet leg??? - not sure
102 float LegOffset = 0.052399; // This is added to the Post Z to position the pet
103
104 // the following are global constants and do not need to be changed
105 // Prim animation linkmessages are sent by scripts on Link Message number 1
106 // The strings are the names of the animations that are recorded.
107 // No need to change them unless you want to change names of the animations when you run the prim animator, or you add additional link messages
108 // If your pet walks, you need to record these names and save them in the notecard
109 //
110 // Example:
111 // llMessageLinked(LINK_SET, LINK_ANIMATE, ANI_STAND, "");
112 // The above line will play the pre-recorded 'stand up' animation "stand" using the animator script.
113 // The following animations are used in the pet. You can add your own.
114
115 string ANI_STAND = "stand"; // default standing animation
116 string ANI_WALKL = "left"; // triggers Left foot and Right arm walk animation
117 string ANI_WALKR = "right"; // triggers Right foot and Left arm walk animation
118 string ANI_SLEEP = "sleep"; // Sleeping
119 string ANI_WAVE = "wave"; // Calling for sex, needs help with food, etc.
120
121 // Channel assignments
122 // if you change any of these constants, change it everywhere and in the list in XS_Debug so it can print them
123 // If you turn encryption FALSE, you MUST change these between species of pets are they will fuck with each other. Literally.
124
125 integer FOOD_CHANNEL = -999191;
126 integer ANIMAL_CHANNEL = -999192;
127 integer EGG_CHANNEL = -999193;
128 integer HOME_CHANNEL = -999194;
129 integer BOX_CHANNEL = -999195;
130 integer ACC_CHANNEL = -999196;
131 integer UPDATE_CHANNEL = -999197;
132 integer API_CHANNEL = -999198;
133
134 // global link messages to control the animal, never any need to change these.
135 // They are exposed here so they will be the same everywhere. This uses a bit of RAM, but who cares?
136
137 integer LINK_ANIMATE = 1; // messages on num 1 are assumed to be directed at the prim animator.
138 integer DECREASE_FOOD = 100; // used in the food bowl.
139 integer LINK_AGE_START = 800; // when pety is rezzed and secret_number is sent by brain to breeder, eater and infomatic get booted up
140 integer LINK_TEXTURE = 801; // ask for a new texture, or paint a color
141 integer LINK_BREEDNAME = 802; // the name of the pet texture from the texture server notecard
142 integer LINK_FOOD_CONSUME = 900; // from movement to brain when close to food, brain then consumes a random amount up to 10000
143 integer LINK_FOODMINUS = 901; // xs_brain receives FOOD_CONSUME, decrement hunger (eat)
144 integer LINK_HUNGRY = 903; // sent by eater (string)hunger_amount, checks each hour
145 integer LINK_HAMOUNT = 904; // hunger_amount = (integer)str,m updates the hunger amount in scripts
146 integer LINK_SET_HOME = 910; // loc ^ dist
147 integer LINK_MOVER = 911; // tell mover to rest for str seconds
148 integer LINK_FOODIE_CLR = 920; // clear all food_bowl_keys and contents
149 integer LINK_FOODIE = 921; // send FOOD_LOCATION coordinates to movement
150 integer LINK_COLOR1 = 930; // colour1
151 integer LINK_COLOR2 = 931; // colour2
152 integer LINK_SEX = 932; // sex
153 integer LINK_SHINE = 933; // shine
154 integer LINK_GLOW = 934; // glow
155 integer LINK_GEN = 935; // generation
156 integer LINK_RESET_SIZE = 936; // reset size to 1
157 integer LINK_MAGE = 940; // xs_brain sends, xs_ager consumes, adds str to age, if older than 7 days, will grow the animal
158 integer LINK_DAYTIME = 941; // xs_ager consumes, starts a timer of 86,400 seconds in xs_ager
159 integer LINK_GET_AGE = 942; // get age from xs_ager and sent it on channel 943
160 integer LINK_PUT_AGE = 943; // print age from xs_ager
161 integer LINK_PACKAGE = 950; // look for a cryo_crate
162 integer LINK_SEEK_FEMALE = 960; // MALE_BREED_CALL
163 integer LINK_MALE_BREED_CALL = 961; // triggered by LINK_SEEK_FEMALE
164 integer LINK_SIGNAL_ELIGIBLE = 962; // sent by female when hears LINK_MALE_BREED_CALL
165 integer LINK_FEMALE_ELIGIBLE = 963; // sent when it hears in chat FEMALE_ELIGIBLE
166 integer LINK_CALL_MALE = 964; // if LINK_FEMALE_ELIGIBLE && looking_for_female
167 integer LINK_MALE_ON_THE_WAY = 965; // triggered by LINK_CALL_MALE
168 integer LINK_FEMALE_LOCATION = 966; // female location, sends coordinates of a female
169 integer LINK_RQST_BREED = 967; // sent when close enough to male/female
170 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.
171 integer LINK_MALE_INFO = 969; // Breeding failed, sent info
172 integer LINK_LAY_EGG = 970; // Rez Object(Egg...
173 integer LINK_BREED_FAIL = 971; // key = father, failed, timed out
174 integer LINK_PREGNANT = 972; // chick is preggers
175 integer LINK_SOUND_OFF= 974; // sound is off
176 integer LINK_SOUND_ON= 973; // sound is on
177 integer LINK_SLEEPING = 990; // close eyes
178 integer LINK_UNSLEEPING = 991; // open eyes
179 integer LINK_SOUND = 1001; // plays a sound if enabled
180 integer LINK_SPECIAL = 1010; // xs_special, if str = "Normal", removes script
181 integer LINK_EFFECTS_ON = 2000; // particle effects in the packger
182 integer LINK_PREGNANCY_TIME = 5000; // in seconds as str
183 integer LINK_SLEEP = 7999; // disable sleep by parameter
184 integer LINK_TIMER = 8000; // scan for food bowl about every 1800 seconds
185 integer LINK_DIE = 9999; // death
186
187 string Copyright = " (c)2014 by Ferd Frederix"; // You cannot change this line, but you can change the code that prints it!
188 // See License agreements above.
189 // Attribution is required, as these files are copyrighted.
190
191
192 DEBUG ( string msg){
193 if(debug) {
194 llOwnerSay(llGetScriptName() + ":" + msg);
195 }
196 }
197
198
199
200 ///////// end global Link constants ////////
201
202 // END OF COPIED CODE
203
204
205
206
207
208
209
210
211
212
213 /////// DON'T CHANGE THE FOLLOWING! (Unless you know what you are doing!)
214
215 integer XTEA_DELTA = 0x9E3779B9; // (sqrt(5) - 1) * 2^31
216 integer xtea_num_rounds = 6;
217 list xtea_key = [0, 0, 0, 0];
218
219 integer hex2int(string hex) {
220 if(llGetSubString(hex,0,1) == "0x")
221 return (integer)hex;
222 if(llGetSubString(hex,0,0) == "x")
223 return (integer)("0"+hex);
224 return(integer)("0x"+hex);
225 }
226
227
228 // Convers any string to a 32 char MD5 string and then to a list of
229 // 4 * 32 bit integers = 128 bit Key. MD5 ensures always a specific
230 // 128 bit key is generated for any string passed.
231 list xtea_key_from_string( string str )
232 {
233 str = llMD5String(str,0); // Use Nonce = 0
234 return [ hex2int(llGetSubString( str, 0, 7)),
235 hex2int(llGetSubString( str, 8, 15)),
236 hex2int(llGetSubString( str, 16, 23)),
237 hex2int(llGetSubString( str, 24, 31))];
238 }
239
240 // Encipher two integers and return the result as a 12-byte string
241 // containing two base64-encoded integers.
242 string xtea_encipher( integer v0, integer v1 )
243 {
244 integer num_rounds = xtea_num_rounds;
245 integer sum = 0;
246 do {
247 // LSL does not have unsigned integers, so when shifting right we
248 // have to mask out sign-extension bits.
249 v0 += (((v1 << 4) ^ ((v1 >> 5) & 0x07FFFFFF)) + v1) ^ (sum + llList2Integer(xtea_key, sum & 3));
250 sum += XTEA_DELTA;
251 v1 += (((v0 << 4) ^ ((v0 >> 5) & 0x07FFFFFF)) + v0) ^ (sum + llList2Integer(xtea_key, (sum >> 11) & 3));
252
253 } while( num_rounds = ~-num_rounds );
254 //return only first 6 chars to remove "=="'s and compact encrypted text.
255 return llGetSubString(llIntegerToBase64(v0),0,5) +
257 }
258
259 // Decipher two base64-encoded integers and return the FIRST 30 BITS of
260 // each as one 10-byte base64-encoded string.
261 string xtea_decipher( integer v0, integer v1 )
262 {
263 integer num_rounds = xtea_num_rounds;
264 integer sum = XTEA_DELTA*xtea_num_rounds;
265 do {
266 // LSL does not have unsigned integers, so when shifting right we
267 // have to mask out sign-extension bits.
268 v1 -= (((v0 << 4) ^ ((v0 >> 5) & 0x07FFFFFF)) + v0) ^ (sum + llList2Integer(xtea_key, (sum>>11) & 3));
269 sum -= XTEA_DELTA;
270 v0 -= (((v1 << 4) ^ ((v1 >> 5) & 0x07FFFFFF)) + v1) ^ (sum + llList2Integer(xtea_key, sum & 3));
271 } while( num_rounds = ~-num_rounds );
272
273 return llGetSubString(llIntegerToBase64(v0), 0, 4) +
275 }
276
277 // Encrypt a full string using XTEA.
278 string xtea_encrypt_string( string str )
279 {
280 if(! ENCRYPT)
281 return str;
282 // encode string
283 str = llStringToBase64(str);
284 // remove trailing =s so we can do our own 0 padding
285 integer i = llSubStringIndex( str, "=" );
286 if( i != -1 )
287 str = llDeleteSubString( str, i, -1 );
288
289 // we don't want to process padding, so get length before adding it
290 integer len = llStringLength(str);
291
292 // zero pad
293 str += "AAAAAAAAAA=";
294
295 string result;
296 i = 0;
297
298 do {
299 // encipher 30 (5*6) bits at a time.
300 result += xtea_encipher(llBase64ToInteger(llGetSubString(str, i, i + 4) + "A="), llBase64ToInteger(llGetSubString(str, i+5, i + 9) + "A="));
301 i+=10;
302 } while( i < len );
303
304 return result;
305 }
306
307 // Decrypt a full string using XTEA
308 string xtea_decrypt_string( string str ) {
309 if(! ENCRYPT)
310 return str;
311 integer len = llStringLength(str);
312 integer i=0;
313 string result;
314 //llOwnerSay(str);
315 do {
316 integer v0;
317 integer v1;
318
319 v0 = llBase64ToInteger(llGetSubString(str, i, i + 5) + "==");
320 i+= 6;
321 v1 = llBase64ToInteger(llGetSubString(str, i, i + 5) + "==");
322 i+= 6;
323
324 result += xtea_decipher(v0, v1);
325 } while( i < len );
326
327 // Replace multiple trailing zeroes with a single one
328
329 i = llStringLength(result) - 1;
330 while( llGetSubString(result, i - 1, i) == "AA" ){
331 result = llDeleteSubString(result, i, i);
332 i--;
333 }
334 i = llStringLength(result) - 1;
335 // while(llGetSubString(result, i, i + 1) == "A" ) {
336 // i--;
337 // }
338 result = llGetSubString(result, 0, i+1);
339 i = llStringLength(result);
340 integer mod = i%4; //Depending on encoded length diffrent appends are needed
341 if(mod == 1) result += "A==";
342 else if(mod == 2 ) result += "==";
343 else if(mod == 3) result += "=";
344
345 return llBase64ToString(result);
346 }
347
348 string base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
349
350
351
352 default
353 {
355 {
356 xtea_key = xtea_key_from_string(SECRET_PASSWORD);
357 llListen(HOME_CHANNEL, "", "", "XSPET_PING_HOME"); // listen for a pet to say XSPET_PING_HOME - Mod by Ferd to listen to HOME_CHANNEL, not -237918
358 }
359
360 touch_start(integer total_number)
361 {
362 if(llDetectedKey(0) == llGetOwner()) {
363 vector size = llGetScale();
364 llSleep(2);
365 llOwnerSay((string) size.x);
366 llSay(ANIMAL_CHANNEL, xtea_encrypt_string("XSPET^HOME_RADIUS^" + (string)size.x ));
367 }
368 }
369
370 listen(integer channel, string name, key id, string msg)
371 {
372 vector size = llGetScale();
373 llSleep(2);
374 llSay(ANIMAL_CHANNEL, xtea_encrypt_string("XSPET^HOME_RADIUS^" + (string)size.x ));
375 }
376 }

XS Pet Robot

XS Pet xs _foodbowl

Category: XS Pet
By : Ferd Frederix
Created: 2013-09-06 Edited: 2015-07-24
Worlds: Second Life


This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1
2 //xs _foodbowl
3
4
5 // tunable numbers
6
7 integer FOOD_TYPE = 0;
8
9
10
11
12
13
14
15
16 // START OF COPIED file 'Global Constants.txt' from the Debug folder. It has to be the same in all files
17 // If you change this in any script, change it in all of them, please. It works a lot better that way.
18
19 // This is code based on Version 0.50 01-30-2014
20 // For version history, see file revisions.txt
21 //
22 // LICENSE
23 /////////////////////////////////////////////////////////////////////
24 // This code is licensed as Creative Commons Attribution/NonCommercial/Share Alike
25 // See http://creativecommons.org/liceses/by-nc-sa/3.0/
26 // Noncommercial -- You may not use this work for commercial purposes, i.e., you cannot sell this script in any form, including derivatives.
27 // If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one.
28 // This means that you cannot sell this or derivative code by itself, but you may share and use this code in any object or virtual world.
29 // You must attribute authorship in the original scripts to Ferd Frederix and Xundra Snowpaw, and leave this notice intact.
30 // You do not have to give back to the community any changes you make, however, code changes would be greatly appreciated!
31 //
32 // Exception: I am allowing this script to be used in an original build and sold with the build.
33 // You are not selling the script, you are selling the build. If you want to sell these scripts, write your own or use the original at http://code.google.com/p/xspets/
34 // Note: Xundra Snowpaw's license was 'New BSD' license and adding additional licenses is allowed.
35
36 // Based on code from Xundra Snowpaw
37 // New BSD License: http://www.opensource.org/licenses/bsd-license.php
38 // Copyright (c) 2010, Xundra Snowpaw
39 // All rights reserved.
40 // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
41
42 //* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
43 //* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer
44 // in the documentationand/or other materials provided with the distribution.
45
46 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
47 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
48 // BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
49 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
50 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
51 // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
52 ////////////////////////////////////////////////////////////////////
53
54 // DEBUG - lets you see and hear wtf is happening
55 integer debug = FALSE; // set to TRUE TO hear a lot of chat
56
57
58 // This section has a few tuneable items that MUST be changed for any new pet
59
60 // SECURITY
61 string SECRET_PASSWORD = "top secret string"; // must use a password unique to any species of animal, when ENCRYPT= TRUE. Otherwise you will find Pet type A fucking pet type B.
62 integer SECRET_NUMBER = 99999; // any number thats a secret, not necessary to change usually, this is used when pets are born and eggs are rezzed to establish a comm channel.
63 integer ENCRYPT = TRUE; // set to TRUE to encrypt all data, Some Opensim worlds prefer FALSE due to parsing bugs, TRUE is the most secure. If FALSE you MUST change the FOOD_CHANNEL and other channels for different pets. or they will literally fuck each other.
64
65 // if you add the UUID for your avatar here, you can change it later
66 // and other alts or friends can change it too, and all of you can work on these pets.
67 // If you leave it blank, only the creator of the root prim can work on these pets.
68 key YOUR_UUID = "";
69
70 // PET NAMES - YOU MUST CHANGE THEM HERE AND IN THE ROOT PRIM OF THE OBJECT - THEY MUST MATCH EXACTLY
71 /////////////////////////
72 string MaleName = "Troubot"; // Must be the name of your animal
73 string FemaleName = "Troubot"; // The name of the female pet, if a different shape or prim count. Can be the same as the Male for pets like the robot that are unisex.
74 string Egg = "Nut and Bolt"; // was 'XS Egg', must be the name of your egg
75 string Crate = "Transport Spaceship"; // was XS-Cryocrate, must be the name of the crate you package pets in
76 string HomeObject = "Home Flag"; // was "XS Home Object", must be the name of your Home Post indicator
77 string EggCup = "Toolbox"; // was "XS Egg Cup", must be the name of your egg holder
78 // any other object names are 'do not cares'.
79
80 // NOTHING NEEDS TO BE CHANGED BELOW, BUT CAN BE CHANGED IF YOU DO IT EVERYWHERE
81
82 // misc tunables
83 float GROWTH_AMOUNT = 0.10; // 10% size increase each day for MaxAge days = 200% (double size after 7 days)
84 integer MaxAge = 7; // stop growing in seven days. 10% growth compounded daily means that your pet will be 194% larger ( 2x, basically) in 7 days.
85 integer UNITS_OF_FOOD = 168; // food bowl food qty, used by food bowl only
86 float secs_to_grow = 86400; // grow daily = 86400 seconds
87 float FOOD_BOWL_SCAN_INTERVAL = 1800.0; // look for food every 3 hours
88 float fPregnancy = 172800.0; // how many seconds to lay an egg = 2 days or 48 hours.
89 float MALE_TIMEOUT = 900.0 ; // in seconds, female waits this long in one spot for a male to arrive
90 float SEX_WAIT = 10800.0; // How often they desire sex = 3 hours
91 float fDaysToAdult = 7; // 7 days to become old enough to breed.
92 integer SECONDS_BETWEEN_FOOD_NORMAL = 14400; // number of seconds to get hungry = 4 hours
93 integer SECONDS_BETWEEN_FOOD_HUNGRY = 3600; // number of seconds before hunger count increases = 1 hour
94 integer MAXIMUM_HUNGER = 30; // They die after a month with no food.
95
96
97 // I control versions by Subversion Source Code Control. But the updater needs a version numbert in world.
98 // This is the Protocol version. If you change this, then all pets with a lower version will be updated by the updater
99 float VERSION = 0.50;
100
101
102
103 // the leg sizes are safe to leave alone or set to 0 if you use a thin base prim, these are from the original Quail
104 float LegLength = 0.064; // length of pet leg??? - not sure
105 float LegOffset = 0.052399; // This is added to the Post Z to position the pet
106
107 // the following are global constants and do not need to be changed
108 // Prim animation linkmessages are sent by scripts on Link Message number 1
109 // The strings are the names of the animations that are recorded.
110 // No need to change them unless you want to change names of the animations when you run the prim animator, or you add additional link messages
111 // If your pet walks, you need to record these names and save them in the notecard
112 //
113 // Example:
114 // llMessageLinked(LINK_SET, LINK_ANIMATE, ANI_STAND, "");
115 // The above line will play the pre-recorded 'stand up' animation "stand" using the animator script.
116 // The following animations are used in the pet. You can add your own.
117
118 string ANI_STAND = "stand"; // default standing animation
119 string ANI_WALKL = "left"; // triggers Left foot and Right arm walk animation
120 string ANI_WALKR = "right"; // triggers Right foot and Left arm walk animation
121 string ANI_SLEEP = "sleep"; // Sleeping
122 string ANI_WAVE = "wave"; // Calling for sex, needs help with food, etc.
123
124 // Channel assignments
125 // if you change any of these constants, change it everywhere and in the list in XS_Debug so it can print them
126 // If you turn encryption FALSE, you MUST change these between species of pets are they will fuck with each other. Literally.
127
128 integer FOOD_CHANNEL = -999191;
129 integer ANIMAL_CHANNEL = -999192;
130 integer EGG_CHANNEL = -999193;
131 integer HOME_CHANNEL = -999194;
132 integer BOX_CHANNEL = -999195;
133 integer ACC_CHANNEL = -999196;
134 integer UPDATE_CHANNEL = -999197;
135 integer API_CHANNEL = -999198;
136
137 // global link messages to control the animal, never any need to change these.
138 // They are exposed here so they will be the same everywhere. This uses a bit of RAM, but who cares?
139
140 integer LINK_ANIMATE = 1; // messages on num 1 are assumed to be directed at the prim animator.
141 integer DECREASE_FOOD = 100; // used in the food bowl.
142 integer LINK_AGE_START = 800; // when pety is rezzed and secret_number is sent by brain to breeder, eater and infomatic get booted up
143 integer LINK_TEXTURE = 801; // ask for a new texture, or paint a color
144 integer LINK_BREEDNAME = 802; // the name of the pet texture from the texture server notecard
145 integer LINK_FOOD_CONSUME = 900; // from movement to brain when close to food, brain then consumes a random amount up to 10000
146 integer LINK_FOODMINUS = 901; // xs_brain receives FOOD_CONSUME, decrement hunger (eat)
147 integer LINK_HUNGRY = 903; // sent by eater (string)hunger_amount, checks each hour
148 integer LINK_HAMOUNT = 904; // hunger_amount = (integer)str,m updates the hunger amount in scripts
149 integer LINK_SET_HOME = 910; // loc ^ dist
150 integer LINK_MOVER = 911; // tell mover to rest for str seconds
151 integer LINK_FOODIE_CLR = 920; // clear all food_bowl_keys and contents
152 integer LINK_FOODIE = 921; // send FOOD_LOCATION coordinates to movement
153 integer LINK_COLOR1 = 930; // colour1
154 integer LINK_COLOR2 = 931; // colour2
155 integer LINK_SEX = 932; // sex
156 integer LINK_SHINE = 933; // shine
157 integer LINK_GLOW = 934; // glow
158 integer LINK_GEN = 935; // generation
159 integer LINK_RESET_SIZE = 936; // reset size to 1
160 integer LINK_MAGE = 940; // xs_brain sends, xs_ager consumes, adds str to age, if older than 7 days, will grow the animal
161 integer LINK_DAYTIME = 941; // xs_ager consumes, starts a timer of 86,400 seconds in xs_ager
162 integer LINK_GET_AGE = 942; // get age from xs_ager and sent it on channel 943
163 integer LINK_PUT_AGE = 943; // print age from xs_ager
164 integer LINK_PACKAGE = 950; // look for a cryo_crate
165 integer LINK_SEEK_FEMALE = 960; // MALE_BREED_CALL
166 integer LINK_MALE_BREED_CALL = 961; // triggered by LINK_SEEK_FEMALE
167 integer LINK_SIGNAL_ELIGIBLE = 962; // sent by female when hears LINK_MALE_BREED_CALL
168 integer LINK_FEMALE_ELIGIBLE = 963; // sent when it hears in chat FEMALE_ELIGIBLE
169 integer LINK_CALL_MALE = 964; // if LINK_FEMALE_ELIGIBLE && looking_for_female
170 integer LINK_MALE_ON_THE_WAY = 965; // triggered by LINK_CALL_MALE
171 integer LINK_FEMALE_LOCATION = 966; // female location, sends coordinates of a female
172 integer LINK_RQST_BREED = 967; // sent when close enough to male/female
173 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.
174 integer LINK_MALE_INFO = 969; // Breeding failed, sent info
175 integer LINK_LAY_EGG = 970; // Rez Object(Egg...
176 integer LINK_BREED_FAIL = 971; // key = father, failed, timed out
177 integer LINK_PREGNANT = 972; // chick is preggers
178 integer LINK_SOUND_OFF= 974; // sound is off
179 integer LINK_SOUND_ON= 973; // sound is on
180 integer LINK_SLEEPING = 990; // close eyes
181 integer LINK_UNSLEEPING = 991; // open eyes
182 integer LINK_SOUND = 1001; // plays a sound if enabled
183 integer LINK_SPECIAL = 1010; // xs_special, if str = "Normal", removes script
184 integer LINK_EFFECTS_ON = 2000; // particle effects in the packger
185 integer LINK_PREGNANCY_TIME = 5000; // in seconds as str
186 integer LINK_SLEEP = 7999; // disable sleep by parameter
187 integer LINK_TIMER = 8000; // scan for food bowl about every 1800 seconds
188 integer LINK_DIE = 9999; // death
189
190 string Copyright = " (c)2014 by Ferd Frederix"; // You cannot change this line, but you can change the code that prints it!
191 // See License agreements above.
192 // Attribution is required, as these files are copyrighted.
193
194
195 DEBUG ( string msg){
196 if(debug) {
197 llOwnerSay(llGetScriptName() + ":" + msg);
198 }
199 }
200
201
202
203 ///////// end global Link constants ////////
204
205 // END OF COPIED CODE
206
207
208
209
210
211
212
213
214
215
216
217
218
219 // DON'T CHANGE THE FOLLOWING! (Unless you know what you are doing!)
220
221 integer XTEA_DELTA = 0x9E3779B9; // (sqrt(5) - 1) * 2^31
222 integer xtea_num_rounds = 6;
223 list xtea_key = [0, 0, 0, 0];
224
225 integer hex2int(string hex) {
226 if(llGetSubString(hex,0,1) == "0x")
227 return (integer)hex;
228 if(llGetSubString(hex,0,0) == "x")
229 return (integer)("0"+hex);
230 return(integer)("0x"+hex);
231 }
232
233
234 // Convers any string to a 32 char MD5 string and then to a list of
235 // 4 * 32 bit integers = 128 bit Key. MD5 ensures always a specific
236 // 128 bit key is generated for any string passed.
237 list xtea_key_from_string( string str )
238 {
239 str = llMD5String(str,0); // Use Nonce = 0
240 return [ hex2int(llGetSubString( str, 0, 7)),
241 hex2int(llGetSubString( str, 8, 15)),
242 hex2int(llGetSubString( str, 16, 23)),
243 hex2int(llGetSubString( str, 24, 31))];
244 }
245
246 // Encipher two integers and return the result as a 12-byte string
247 // containing two base64-encoded integers.
248 string xtea_encipher( integer v0, integer v1 )
249 {
250 integer num_rounds = xtea_num_rounds;
251 integer sum = 0;
252 do {
253 // LSL does not have unsigned integers, so when shifting right we
254 // have to mask out sign-extension bits.
255 v0 += (((v1 << 4) ^ ((v1 >> 5) & 0x07FFFFFF)) + v1) ^ (sum + llList2Integer(xtea_key, sum & 3));
256 sum += XTEA_DELTA;
257 v1 += (((v0 << 4) ^ ((v0 >> 5) & 0x07FFFFFF)) + v0) ^ (sum + llList2Integer(xtea_key, (sum >> 11) & 3));
258
259 } while( num_rounds = ~-num_rounds );
260 //return only first 6 chars to remove "=="'s and compact encrypted text.
261 return llGetSubString(llIntegerToBase64(v0),0,5) +
263 }
264
265 // Decipher two base64-encoded integers and return the FIRST 30 BITS of
266 // each as one 10-byte base64-encoded string.
267 string xtea_decipher( integer v0, integer v1 )
268 {
269 integer num_rounds = xtea_num_rounds;
270 integer sum = XTEA_DELTA*xtea_num_rounds;
271 do {
272 // LSL does not have unsigned integers, so when shifting right we
273 // have to mask out sign-extension bits.
274 v1 -= (((v0 << 4) ^ ((v0 >> 5) & 0x07FFFFFF)) + v0) ^ (sum + llList2Integer(xtea_key, (sum>>11) & 3));
275 sum -= XTEA_DELTA;
276 v0 -= (((v1 << 4) ^ ((v1 >> 5) & 0x07FFFFFF)) + v1) ^ (sum + llList2Integer(xtea_key, sum & 3));
277 } while( num_rounds = ~-num_rounds );
278
279 return llGetSubString(llIntegerToBase64(v0), 0, 4) +
281 }
282
283 // Encrypt a full string using XTEA.
284 string xtea_encrypt_string( string str )
285 {
286 if(! ENCRYPT)
287 return str;
288 // encode string
289 str = llStringToBase64(str);
290 // remove trailing =s so we can do our own 0 padding
291 integer i = llSubStringIndex( str, "=" );
292 if( i != -1 )
293 str = llDeleteSubString( str, i, -1 );
294
295 // we don't want to process padding, so get length before adding it
296 integer len = llStringLength(str);
297
298 // zero pad
299 str += "AAAAAAAAAA=";
300
301 string result;
302 i = 0;
303
304 do {
305 // encipher 30 (5*6) bits at a time.
306 result += xtea_encipher(llBase64ToInteger(llGetSubString(str, i, i + 4) + "A="), llBase64ToInteger(llGetSubString(str, i+5, i + 9) + "A="));
307 i+=10;
308 } while( i < len );
309
310 return result;
311 }
312
313 // Decrypt a full string using XTEA
314 string xtea_decrypt_string( string str ) {
315 if(! ENCRYPT)
316 return str;
317 integer len = llStringLength(str);
318 integer i=0;
319 string result;
320 //llOwnerSay(str);
321 do {
322 integer v0;
323 integer v1;
324
325 v0 = llBase64ToInteger(llGetSubString(str, i, i + 5) + "==");
326 i+= 6;
327 v1 = llBase64ToInteger(llGetSubString(str, i, i + 5) + "==");
328 i+= 6;
329
330 result += xtea_decipher(v0, v1);
331 } while( i < len );
332
333 // Replace multiple trailing zeroes with a single one
334
335 i = llStringLength(result) - 1;
336 while( llGetSubString(result, i - 1, i) == "AA" ){
337 result = llDeleteSubString(result, i, i);
338 i--;
339 }
340 i = llStringLength(result) - 1;
341 // while(llGetSubString(result, i, i + 1) == "A" ) {
342 // i--;
343 // }
344 result = llGetSubString(result, 0, i+1);
345 i = llStringLength(result);
346 integer mod = i%4; //Depending on encoded length diffrent appends are needed
347 if(mod == 1) result += "A==";
348 else if(mod == 2 ) result += "==";
349 else if(mod == 3) result += "=";
350
351 return llBase64ToString(result);
352 }
353
354 string base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
355
356
357
358
359 integer food_left;
360
361 // allow either a UUID to be entered, or not, and still maintain security
362 integer CheckPerms()
363 {
364 if(YOUR_UUID != "" && llGetOwner() != YOUR_UUID)
365 return 1;
366
368 return 1;
369
370 return 0;
371 }
372
373
374 default
375 {
377 {
378 if( CheckPerms() ) {
379 // someone not the creator reset the script. That's naughty.
380 state dead;
381 }
382
383 llSetText("", <1,1,1>, 1.0);
384 xtea_key = xtea_key_from_string(SECRET_PASSWORD);
385 food_left = UNITS_OF_FOOD;
386 llListen(FOOD_CHANNEL, "", "", "");
387 }
388
389 touch_start(integer total_number)
390 {
391 llSetTimerEvent(20.0);
392 llSetText((string)food_left + " remaining.", <1,1,1>, 1.0);
393 }
394
395 timer()
396 {
397 llSetTimerEvent(0.0);
398 llSetText("", <1,1,1>, 1.0);
399 }
400
401 listen(integer channel, string name, key id, string message)
402 {
403 list data = llParseString2List(xtea_decrypt_string(message), ["^"] , []);
404 if(llList2String(data, 0) == "XSPET") {
405 if(llList2String(data, 1) == "FOOD_LOCATION") {
406 integer random_key = (integer) llList2String(data, 2); // 0.43
407 key animal_key = (key) llList2String(data, 3);
408 llSay(ANIMAL_CHANNEL, xtea_encrypt_string("XSPET^FOOD_LOCATION^" + (string)random_key + "^" + (string)llGetPos() + "^" + (string)animal_key));
409 }
410 if(llList2String(data, 1) == "FOOD_CONSUME") {
411 if((key) llList2String(data, 2) == llGetKey()) {
412 integer random_key = (integer) llList2String(data, 3);
413 key animal_key = (key) llList2String(data, 4);
414 food_left--;
415 llMessageLinked(LINK_SET, DECREASE_FOOD, "1", "");
416 llSay(ANIMAL_CHANNEL, xtea_encrypt_string("XSPET^FOOD_CONSUME^" + (string)random_key + "^" + (string)animal_key + "^" + (string)FOOD_TYPE));
417 if(food_left <= 0) {
418 state empty;
419 }
420 }
421 }
422 }
423 }
424 }
425
426 state dead
427 {
429 {
430 llSetText("This " + llGetObjectName() + " has been broken.", <1,0,0>, 1.0);
431 }
432 }
433
434 state empty
435 {
437 {
438 llSetObjectName(llGetObjectName() + " (Empty)");
439 llSetText("Empty", <1,0,0>, 1.0);
440 }
441 }

XS Pet Robot

XS Pet xs_foodbowl_anim

Category: XS Pet
By : Ferd Frederix
Created: 2013-09-06 Edited: 2015-07-24
Worlds: Second Life


This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1
2 // xs_foodbowl_anim
3
4
5 // tunable constants
6
7 integer PIE = FALSE; // set to TRUE for pie slices, set to FALSE for Vertical liquid/plasma effect
8
9
10
11
12
13
14
15
16 // START OF COPIED file 'Global Constants.txt' from the Debug folder. It has to be the same in all files
17 // If you change this in any script, change it in all of them, please. It works a lot better that way.
18
19 // This is code based on Version 0.50 01-30-2014
20 // For version history, see file revisions.txt
21 //
22 // LICENSE
23 /////////////////////////////////////////////////////////////////////
24 // This code is licensed as Creative Commons Attribution/NonCommercial/Share Alike
25 // See http://creativecommons.org/liceses/by-nc-sa/3.0/
26 // Noncommercial -- You may not use this work for commercial purposes, i.e., you cannot sell this script in any form, including derivatives.
27 // If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one.
28 // This means that you cannot sell this or derivative code by itself, but you may share and use this code in any object or virtual world.
29 // You must attribute authorship in the original scripts to Ferd Frederix and Xundra Snowpaw, and leave this notice intact.
30 // You do not have to give back to the community any changes you make, however, code changes would be greatly appreciated!
31 //
32 // Exception: I am allowing this script to be used in an original build and sold with the build.
33 // You are not selling the script, you are selling the build. If you want to sell these scripts, write your own or use the original at http://code.google.com/p/xspets/
34 // Note: Xundra Snowpaw's license was 'New BSD' license and adding additional licenses is allowed.
35
36 // Based on code from Xundra Snowpaw
37 // New BSD License: http://www.opensource.org/licenses/bsd-license.php
38 // Copyright (c) 2010, Xundra Snowpaw
39 // All rights reserved.
40 // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
41
42 //* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
43 //* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer
44 // in the documentationand/or other materials provided with the distribution.
45
46 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
47 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
48 // BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
49 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
50 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
51 // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
52 ////////////////////////////////////////////////////////////////////
53
54 // DEBUG - lets you see and hear wtf is happening
55 integer debug = FALSE; // set to TRUE TO hear a lot of chat
56
57
58 // This section has a few tuneable items that MUST be changed for any new pet
59
60 // SECURITY
61 string SECRET_PASSWORD = "top secret string"; // must use a password unique to any species of animal, when ENCRYPT= TRUE. Otherwise you will find Pet type A fucking pet type B.
62 integer SECRET_NUMBER = 99999; // any number thats a secret, not necessary to change usually, this is used when pets are born and eggs are rezzed to establish a comm channel.
63 integer ENCRYPT = TRUE; // set to TRUE to encrypt all data, Some Opensim worlds prefer FALSE due to parsing bugs, TRUE is the most secure. If FALSE you MUST change the FOOD_CHANNEL and other channels for different pets. or they will literally fuck each other.
64
65 // if you add the UUID for your avatar here, you can change it later
66 // and other alts or friends can change it too, and all of you can work on these pets.
67 // If you leave it blank, only the creator of the root prim can work on these pets.
68 key YOUR_UUID = "";
69
70 // PET NAMES - YOU MUST CHANGE THEM HERE AND IN THE ROOT PRIM OF THE OBJECT - THEY MUST MATCH EXACTLY
71 /////////////////////////
72 string MaleName = "Troubot"; // Must be the name of your animal
73 string FemaleName = "Troubot"; // The name of the female pet, if a different shape or prim count. Can be the same as the Male for pets like the robot that are unisex.
74 string Egg = "Nut and Bolt"; // was 'XS Egg', must be the name of your egg
75 string Crate = "Transport Spaceship"; // was XS-Cryocrate, must be the name of the crate you package pets in
76 string HomeObject = "Home Flag"; // was "XS Home Object", must be the name of your Home Post indicator
77 string EggCup = "Toolbox"; // was "XS Egg Cup", must be the name of your egg holder
78 // any other object names are 'do not cares'.
79
80 // NOTHING NEEDS TO BE CHANGED BELOW, BUT CAN BE CHANGED IF YOU DO IT EVERYWHERE
81
82 // misc tunables
83 float GROWTH_AMOUNT = 0.10; // 10% size increase each day for MaxAge days = 200% (double size after 7 days)
84 integer MaxAge = 7; // stop growing in seven days. 10% growth compounded daily means that your pet will be 194% larger ( 2x, basically) in 7 days.
85 integer UNITS_OF_FOOD = 168; // food bowl food qty, used by food bowl only
86 float secs_to_grow = 86400; // grow daily = 86400 seconds
87 float FOOD_BOWL_SCAN_INTERVAL = 1800.0; // look for food every 3 hours
88 float fPregnancy = 172800.0; // how many seconds to lay an egg = 2 days or 48 hours.
89 float MALE_TIMEOUT = 900.0 ; // in seconds, female waits this long in one spot for a male to arrive
90 float SEX_WAIT = 10800.0; // How often they desire sex = 3 hours
91 float fDaysToAdult = 7; // 7 days to become old enough to breed.
92 integer SECONDS_BETWEEN_FOOD_NORMAL = 14400; // number of seconds to get hungry = 4 hours
93 integer SECONDS_BETWEEN_FOOD_HUNGRY = 3600; // number of seconds before hunger count increases = 1 hour
94 integer MAXIMUM_HUNGER = 30; // They die after a month with no food.
95
96
97 // I control versions by Subversion Source Code Control. But the updater needs a version numbert in world.
98 // This is the Protocol version. If you change this, then all pets with a lower version will be updated by the updater
99 float VERSION = 0.50;
100
101
102
103 // the leg sizes are safe to leave alone or set to 0 if you use a thin base prim, these are from the original Quail
104 float LegLength = 0.064; // length of pet leg??? - not sure
105 float LegOffset = 0.052399; // This is added to the Post Z to position the pet
106
107 // the following are global constants and do not need to be changed
108 // Prim animation linkmessages are sent by scripts on Link Message number 1
109 // The strings are the names of the animations that are recorded.
110 // No need to change them unless you want to change names of the animations when you run the prim animator, or you add additional link messages
111 // If your pet walks, you need to record these names and save them in the notecard
112 //
113 // Example:
114 // llMessageLinked(LINK_SET, LINK_ANIMATE, ANI_STAND, "");
115 // The above line will play the pre-recorded 'stand up' animation "stand" using the animator script.
116 // The following animations are used in the pet. You can add your own.
117
118 string ANI_STAND = "stand"; // default standing animation
119 string ANI_WALKL = "left"; // triggers Left foot and Right arm walk animation
120 string ANI_WALKR = "right"; // triggers Right foot and Left arm walk animation
121 string ANI_SLEEP = "sleep"; // Sleeping
122 string ANI_WAVE = "wave"; // Calling for sex, needs help with food, etc.
123
124 // Channel assignments
125 // if you change any of these constants, change it everywhere and in the list in XS_Debug so it can print them
126 // If you turn encryption FALSE, you MUST change these between species of pets are they will fuck with each other. Literally.
127
128 integer FOOD_CHANNEL = -999191;
129 integer ANIMAL_CHANNEL = -999192;
130 integer EGG_CHANNEL = -999193;
131 integer HOME_CHANNEL = -999194;
132 integer BOX_CHANNEL = -999195;
133 integer ACC_CHANNEL = -999196;
134 integer UPDATE_CHANNEL = -999197;
135 integer API_CHANNEL = -999198;
136
137 // global link messages to control the animal, never any need to change these.
138 // They are exposed here so they will be the same everywhere. This uses a bit of RAM, but who cares?
139
140 integer LINK_ANIMATE = 1; // messages on num 1 are assumed to be directed at the prim animator.
141 integer DECREASE_FOOD = 100; // used in the food bowl.
142 integer LINK_AGE_START = 800; // when pety is rezzed and secret_number is sent by brain to breeder, eater and infomatic get booted up
143 integer LINK_TEXTURE = 801; // ask for a new texture, or paint a color
144 integer LINK_BREEDNAME = 802; // the name of the pet texture from the texture server notecard
145 integer LINK_FOOD_CONSUME = 900; // from movement to brain when close to food, brain then consumes a random amount up to 10000
146 integer LINK_FOODMINUS = 901; // xs_brain receives FOOD_CONSUME, decrement hunger (eat)
147 integer LINK_HUNGRY = 903; // sent by eater (string)hunger_amount, checks each hour
148 integer LINK_HAMOUNT = 904; // hunger_amount = (integer)str,m updates the hunger amount in scripts
149 integer LINK_SET_HOME = 910; // loc ^ dist
150 integer LINK_MOVER = 911; // tell mover to rest for str seconds
151 integer LINK_FOODIE_CLR = 920; // clear all food_bowl_keys and contents
152 integer LINK_FOODIE = 921; // send FOOD_LOCATION coordinates to movement
153 integer LINK_COLOR1 = 930; // colour1
154 integer LINK_COLOR2 = 931; // colour2
155 integer LINK_SEX = 932; // sex
156 integer LINK_SHINE = 933; // shine
157 integer LINK_GLOW = 934; // glow
158 integer LINK_GEN = 935; // generation
159 integer LINK_RESET_SIZE = 936; // reset size to 1
160 integer LINK_MAGE = 940; // xs_brain sends, xs_ager consumes, adds str to age, if older than 7 days, will grow the animal
161 integer LINK_DAYTIME = 941; // xs_ager consumes, starts a timer of 86,400 seconds in xs_ager
162 integer LINK_GET_AGE = 942; // get age from xs_ager and sent it on channel 943
163 integer LINK_PUT_AGE = 943; // print age from xs_ager
164 integer LINK_PACKAGE = 950; // look for a cryo_crate
165 integer LINK_SEEK_FEMALE = 960; // MALE_BREED_CALL
166 integer LINK_MALE_BREED_CALL = 961; // triggered by LINK_SEEK_FEMALE
167 integer LINK_SIGNAL_ELIGIBLE = 962; // sent by female when hears LINK_MALE_BREED_CALL
168 integer LINK_FEMALE_ELIGIBLE = 963; // sent when it hears in chat FEMALE_ELIGIBLE
169 integer LINK_CALL_MALE = 964; // if LINK_FEMALE_ELIGIBLE && looking_for_female
170 integer LINK_MALE_ON_THE_WAY = 965; // triggered by LINK_CALL_MALE
171 integer LINK_FEMALE_LOCATION = 966; // female location, sends coordinates of a female
172 integer LINK_RQST_BREED = 967; // sent when close enough to male/female
173 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.
174 integer LINK_MALE_INFO = 969; // Breeding failed, sent info
175 integer LINK_LAY_EGG = 970; // Rez Object(Egg...
176 integer LINK_BREED_FAIL = 971; // key = father, failed, timed out
177 integer LINK_PREGNANT = 972; // chick is preggers
178 integer LINK_SOUND_OFF= 974; // sound is off
179 integer LINK_SOUND_ON= 973; // sound is on
180 integer LINK_SLEEPING = 990; // close eyes
181 integer LINK_UNSLEEPING = 991; // open eyes
182 integer LINK_SOUND = 1001; // plays a sound if enabled
183 integer LINK_SPECIAL = 1010; // xs_special, if str = "Normal", removes script
184 integer LINK_EFFECTS_ON = 2000; // particle effects in the packger
185 integer LINK_PREGNANCY_TIME = 5000; // in seconds as str
186 integer LINK_SLEEP = 7999; // disable sleep by parameter
187 integer LINK_TIMER = 8000; // scan for food bowl about every 1800 seconds
188 integer LINK_DIE = 9999; // death
189
190 string Copyright = " (c)2014 by Ferd Frederix"; // You cannot change this line, but you can change the code that prints it!
191 // See License agreements above.
192 // Attribution is required, as these files are copyrighted.
193
194
195 DEBUG ( string msg){
196 if(debug) {
197 llOwnerSay(llGetScriptName() + ":" + msg);
198 }
199 }
200
201
202
203 ///////// end global Link constants ////////
204
205 // END OF COPIED CODE
206
207
208
209
210
211
212
213
214
215 // globals
216
217 integer food_left;
218 // code
219
220 // allow either a UUID to be entered, or not, and still maintain security
221 integer CheckPerms()
222 {
223 if(YOUR_UUID != "" && llGetOwner() != YOUR_UUID)
224 return 1;
225
227 return 1;
228
229 return 0;
230 }
231 default
232 {
234 {
235 food_left = UNITS_OF_FOOD;
236
237 if( ! CheckPerms() ) // V .30 was backwards, needed the !
238 {
239 float i = 0 ;
240 while(i <= 1.01)
241 {
242 if(PIE)
243 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>]);
244 else
245 llOffsetTexture(1,1 - i/2,ALL_SIDES);
246
247 llSleep(.5);
248 i += .1 ;
249 }
251 }
252 }
253
254 link_message(integer sender, integer number, string str, key id)
255 {
256 if(number == DECREASE_FOOD) {
257 // its a decrease message
258 integer amount = (integer)str;
259
260 food_left = food_left - amount;
261
262
263 if(PIE)
264 {
265 // do the pie slice thing
266 float cut_amount = ((float)food_left / (float)UNITS_OF_FOOD) * 0.95;
267 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>]);
268 }
269 else
270 {
271 // do the vertical plasma draining effect
272
273 float offset_amount = 1 - ((float)food_left / (float)UNITS_OF_FOOD) /2;
274
275 llOffsetTexture(1,offset_amount,ALL_SIDES); // slide the texture
276 }
277 }
278 }
279 }

XS Pet Robot

XS Pet xs_egg

Category: XS Pet
By : Ferd Frederix
Created: 2013-09-06 Edited: 2015-07-24
Worlds: Second Life


This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1
2 // xs_egg
3
4 // this egg script will color a 2-prim egg when rezzed.
5 // When born from a pet, it will accept a new pet and egg from the Mama.
6 // The only thing ever needed to start with in an egg is this script , as it get the rest of the contents from the egg crate or Mama.
7
8 // 11-30-2012 added AUTO_HATCH variable. If set to TRUE, rthe egg will auto-hatch when laid. Default: FALSE. If FALSE, you have to touch and hatch the egg manually
9 // 4-10-2013 V 0.43 Lots of casting to fix Opensim 0.7.4 failures to parse llList2Float and llList2Integer when there are strings in the list
10 // Version 0.45 7-31-2013 List2Float and list2Integer do not parse strings in Opensim worlds the same. Converted in xs_egg and xs_eggcup
11
12 // 0.53 07-15-2014 bug in init - did not switch to state state rezzed;
13
14
15 /// tunables:
16 string SPECIAL = "Normal"; // change this to trigger the xs_special script in the pet. See xs_special documentation in the pet
17 vector Position = <0.0, 0.0, 0.25>; // how far above the egg to rez the pet.
18 vector Rot = <0,0,0>; // the rotation of the pet when rezzed
19 integer AUTO_HATCH = FALSE; //If set to TRUE, rthe egg will auto-hatch when laid. Default: FALSE. If FALSE, you have to touch and hatch the egg manually
20
21
22
23 // START OF COPIED file 'Global Constants.txt' from the Debug folder. It has to be the same in all files
24 // If you change this in any script, change it in all of them, please. It works a lot better that way.
25
26 // This is code based on Version 0.50 01-30-2014
27 // For version history, see file revisions.txt
28 //
29 // LICENSE
30 /////////////////////////////////////////////////////////////////////
31 // This code is licensed as Creative Commons Attribution/NonCommercial/Share Alike
32 // See http://creativecommons.org/liceses/by-nc-sa/3.0/
33 // Noncommercial -- You may not use this work for commercial purposes, i.e., you cannot sell this script in any form, including derivatives.
34 // If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one.
35 // This means that you cannot sell this or derivative code by itself, but you may share and use this code in any object or virtual world.
36 // You must attribute authorship in the original scripts to Ferd Frederix and Xundra Snowpaw, and leave this notice intact.
37 // You do not have to give back to the community any changes you make, however, code changes would be greatly appreciated!
38 //
39 // Exception: I am allowing this script to be used in an original build and sold with the build.
40 // You are not selling the script, you are selling the build. If you want to sell these scripts, write your own or use the original at http://code.google.com/p/xspets/
41 // Note: Xundra Snowpaw's license was 'New BSD' license and adding additional licenses is allowed.
42
43 // Based on code from Xundra Snowpaw
44 // New BSD License: http://www.opensource.org/licenses/bsd-license.php
45 // Copyright (c) 2010, Xundra Snowpaw
46 // All rights reserved.
47 // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
48
49 //* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
50 //* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer
51 // in the documentationand/or other materials provided with the distribution.
52
53 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
54 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
55 // BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
56 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
57 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
58 // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
59 ////////////////////////////////////////////////////////////////////
60
61 // DEBUG - lets you see and hear wtf is happening
62 integer debug = FALSE; // set to TRUE TO hear a lot of chat
63
64
65 // This section has a few tuneable items that MUST be changed for any new pet
66
67 // SECURITY
68 string SECRET_PASSWORD = "top secret string"; // must use a password unique to any species of animal, when ENCRYPT= TRUE. Otherwise you will find Pet type A fucking pet type B.
69 integer SECRET_NUMBER = 99999; // any number thats a secret, not necessary to change usually, this is used when pets are born and eggs are rezzed to establish a comm channel.
70 integer ENCRYPT = TRUE; // set to TRUE to encrypt all data, Some Opensim worlds prefer FALSE due to parsing bugs, TRUE is the most secure. If FALSE you MUST change the FOOD_CHANNEL and other channels for different pets. or they will literally fuck each other.
71
72 // if you add the UUID for your avatar here, you can change it later
73 // and other alts or friends can change it too, and all of you can work on these pets.
74 // If you leave it blank, only the creator of the root prim can work on these pets.
75 key YOUR_UUID = "";
76
77 // PET NAMES - YOU MUST CHANGE THEM HERE AND IN THE ROOT PRIM OF THE OBJECT - THEY MUST MATCH EXACTLY
78 /////////////////////////
79 string MaleName = "Troubot"; // Must be the name of your animal
80 string FemaleName = "Troubot"; // The name of the female pet, if a different shape or prim count. Can be the same as the Male for pets like the robot that are unisex.
81 string Egg = "Nut and Bolt"; // was 'XS Egg', must be the name of your egg
82 string Crate = "Transport Spaceship"; // was XS-Cryocrate, must be the name of the crate you package pets in
83 string HomeObject = "Home Flag"; // was "XS Home Object", must be the name of your Home Post indicator
84 string EggCup = "Toolbox"; // was "XS Egg Cup", must be the name of your egg holder
85 // any other object names are 'do not cares'.
86
87 // NOTHING NEEDS TO BE CHANGED BELOW, BUT CAN BE CHANGED IF YOU DO IT EVERYWHERE
88
89 // misc tunables
90 float GROWTH_AMOUNT = 0.10; // 10% size increase each day for MaxAge days = 200% (double size after 7 days)
91 integer MaxAge = 7; // stop growing in seven days. 10% growth compounded daily means that your pet will be 194% larger ( 2x, basically) in 7 days.
92 integer UNITS_OF_FOOD = 168; // food bowl food qty, used by food bowl only
93 float secs_to_grow = 86400; // grow daily = 86400 seconds
94 float FOOD_BOWL_SCAN_INTERVAL = 1800.0; // look for food every 3 hours
95 float fPregnancy = 172800.0; // how many seconds to lay an egg = 2 days or 48 hours.
96 float MALE_TIMEOUT = 900.0 ; // in seconds, female waits this long in one spot for a male to arrive
97 float SEX_WAIT = 10800.0; // How often they desire sex = 3 hours
98 float fDaysToAdult = 7; // 7 days to become old enough to breed.
99 integer SECONDS_BETWEEN_FOOD_NORMAL = 14400; // number of seconds to get hungry = 4 hours
100 integer SECONDS_BETWEEN_FOOD_HUNGRY = 3600; // number of seconds before hunger count increases = 1 hour
101 integer MAXIMUM_HUNGER = 30; // They die after a month with no food.
102
103
104 // I control versions by Subversion Source Code Control. But the updater needs a version numbert in world.
105 // This is the Protocol version. If you change this, then all pets with a lower version will be updated by the updater
106 float VERSION = 0.50;
107
108
109
110 // the leg sizes are safe to leave alone or set to 0 if you use a thin base prim, these are from the original Quail
111 float LegLength = 0.064; // length of pet leg??? - not sure
112 float LegOffset = 0.052399; // This is added to the Post Z to position the pet
113
114 // the following are global constants and do not need to be changed
115 // Prim animation linkmessages are sent by scripts on Link Message number 1
116 // The strings are the names of the animations that are recorded.
117 // No need to change them unless you want to change names of the animations when you run the prim animator, or you add additional link messages
118 // If your pet walks, you need to record these names and save them in the notecard
119 //
120 // Example:
121 // llMessageLinked(LINK_SET, LINK_ANIMATE, ANI_STAND, "");
122 // The above line will play the pre-recorded 'stand up' animation "stand" using the animator script.
123 // The following animations are used in the pet. You can add your own.
124
125 string ANI_STAND = "stand"; // default standing animation
126 string ANI_WALKL = "left"; // triggers Left foot and Right arm walk animation
127 string ANI_WALKR = "right"; // triggers Right foot and Left arm walk animation
128 string ANI_SLEEP = "sleep"; // Sleeping
129 string ANI_WAVE = "wave"; // Calling for sex, needs help with food, etc.
130
131 // Channel assignments
132 // if you change any of these constants, change it everywhere and in the list in XS_Debug so it can print them
133 // If you turn encryption FALSE, you MUST change these between species of pets are they will fuck with each other. Literally.
134
135 integer FOOD_CHANNEL = -999191;
136 integer ANIMAL_CHANNEL = -999192;
137 integer EGG_CHANNEL = -999193;
138 integer HOME_CHANNEL = -999194;
139 integer BOX_CHANNEL = -999195;
140 integer ACC_CHANNEL = -999196;
141 integer UPDATE_CHANNEL = -999197;
142 integer API_CHANNEL = -999198;
143
144 // global link messages to control the animal, never any need to change these.
145 // They are exposed here so they will be the same everywhere. This uses a bit of RAM, but who cares?
146
147 integer LINK_ANIMATE = 1; // messages on num 1 are assumed to be directed at the prim animator.
148 integer DECREASE_FOOD = 100; // used in the food bowl.
149 integer LINK_COLOR1_GET = 101; // to xs_egg color plugin.
150 integer LINK_COLOR2_GET = 102; // to xs_egg color plugin.
151 integer LINK_COLOR1_PUT = 103; // to xs_egg color plugin.
152 integer LINK_COLOR2_PUT = 104; // to xs_egg color plugin.
153 integer LINK_AGE_START = 800; // when pety is rezzed and secret_number is sent by brain to breeder, eater and infomatic get booted up
154 integer LINK_TEXTURE = 801; // ask for a new texture, or paint a color
155 integer LINK_BREEDNAME = 802; // the name of the pet texture from the texture server notecard
156 integer LINK_FOOD_CONSUME = 900; // from movement to brain when close to food, brain then consumes a random amount up to 10000
157 integer LINK_FOODMINUS = 901; // xs_brain receives FOOD_CONSUME, decrement hunger (eat)
158 integer LINK_HUNGRY = 903; // sent by eater (string)hunger_amount, checks each hour
159 integer LINK_HAMOUNT = 904; // hunger_amount = (integer)str,m updates the hunger amount in scripts
160 integer LINK_SET_HOME = 910; // loc ^ dist
161 integer LINK_MOVER = 911; // tell mover to rest for str seconds
162 integer LINK_FOODIE_CLR = 920; // clear all food_bowl_keys and contents
163 integer LINK_FOODIE = 921; // send FOOD_LOCATION coordinates to movement
164 integer LINK_COLOR1 = 930; // colour1
165 integer LINK_COLOR2 = 931; // colour2
166 integer LINK_SEX = 932; // sex
167 integer LINK_SHINE = 933; // shine
168 integer LINK_GLOW = 934; // glow
169 integer LINK_GEN = 935; // generation
170 integer LINK_RESET_SIZE = 936; // reset size to 1
171 integer LINK_MAGE = 940; // xs_brain sends, xs_ager consumes, adds str to age, if older than 7 days, will grow the animal
172 integer LINK_DAYTIME = 941; // xs_ager consumes, starts a timer of 86,400 seconds in xs_ager
173 integer LINK_GET_AGE = 942; // get age from xs_ager and sent it on channel 943
174 integer LINK_PUT_AGE = 943; // print age from xs_ager
175 integer LINK_PACKAGE = 950; // look for a cryo_crate
176 integer LINK_SEEK_FEMALE = 960; // MALE_BREED_CALL
177 integer LINK_MALE_BREED_CALL = 961; // triggered by LINK_SEEK_FEMALE
178 integer LINK_SIGNAL_ELIGIBLE = 962; // sent by female when hears LINK_MALE_BREED_CALL
179 integer LINK_FEMALE_ELIGIBLE = 963; // sent when it hears in chat FEMALE_ELIGIBLE
180 integer LINK_CALL_MALE = 964; // if LINK_FEMALE_ELIGIBLE && looking_for_female
181 integer LINK_MALE_ON_THE_WAY = 965; // triggered by LINK_CALL_MALE
182 integer LINK_FEMALE_LOCATION = 966; // female location, sends coordinates of a female
183 integer LINK_RQST_BREED = 967; // sent when close enough to male/female
184 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.
185 integer LINK_MALE_INFO = 969; // Breeding failed, sent info
186 integer LINK_LAY_EGG = 970; // Rez Object(Egg...
187 integer LINK_BREED_FAIL = 971; // key = father, failed, timed out
188 integer LINK_PREGNANT = 972; // chick is preggers
189 integer LINK_SOUND_OFF= 974; // sound is off
190 integer LINK_SOUND_ON= 973; // sound is on
191 integer LINK_SLEEPING = 990; // close eyes
192 integer LINK_UNSLEEPING = 991; // open eyes
193 integer LINK_SOUND = 1001; // plays a sound if enabled
194 integer LINK_SPECIAL = 1010; // xs_special, if str = "Normal", removes script
195 integer LINK_EFFECTS_ON = 2000; // particle effects in the packger
196 integer LINK_PREGNANCY_TIME = 5000; // in seconds as str
197 integer LINK_SLEEP = 7999; // disable sleep by parameter
198 integer LINK_TIMER = 8000; // scan for food bowl about every 1800 seconds
199 integer LINK_DIE = 9999; // death
200
201 string Copyright = " (c)2014 by Ferd Frederix"; // You cannot change this line, but you can change the code that prints it!
202 // See License agreements above.
203 // Attribution is required, as these files are copyrighted.
204
205
206 DEBUG ( string msg){
207 if(debug) {
208 llOwnerSay(llGetScriptName() + ":" + msg);
209 }
210 }
211
212
213
214 ///////// end global Link constants ////////
215
216 // END OF COPIED CODE
217
218
219
220
221
222
223
224
225
226
227 // DON'T CHANGE THE FOLLOWING! (Unless you know what you are doing!)
228
229 integer XTEA_DELTA = 0x9E3779B9; // (sqrt(5) - 1) * 2^31
230 integer xtea_num_rounds = 6;
231 list xtea_key = [0, 0, 0, 0];
232
233 integer hex2int(string hex) {
234 if(llGetSubString(hex,0,1) == "0x")
235 return (integer)hex;
236 if(llGetSubString(hex,0,0) == "x")
237 return (integer)("0"+hex);
238 return(integer)("0x"+hex);
239 }
240
241
242 // Convers any string to a 32 char MD5 string and then to a list of
243 // 4 * 32 bit integers = 128 bit Key. MD5 ensures always a specific
244 // 128 bit key is generated for any string passed.
245 list xtea_key_from_string( string str )
246 {
247 str = llMD5String(str,0); // Use Nonce = 0
248 return [ hex2int(llGetSubString( str, 0, 7)),
249 hex2int(llGetSubString( str, 8, 15)),
250 hex2int(llGetSubString( str, 16, 23)),
251 hex2int(llGetSubString( str, 24, 31))];
252 }
253
254 // Encipher two integers and return the result as a 12-byte string
255 // containing two base64-encoded integers.
256 string xtea_encipher( integer v0, integer v1 )
257 {
258 integer num_rounds = xtea_num_rounds;
259 integer sum = 0;
260 do {
261 // LSL does not have unsigned integers, so when shifting right we
262 // have to mask out sign-extension bits.
263 v0 += (((v1 << 4) ^ ((v1 >> 5) & 0x07FFFFFF)) + v1) ^ (sum + llList2Integer(xtea_key, sum & 3));
264 sum += XTEA_DELTA;
265 v1 += (((v0 << 4) ^ ((v0 >> 5) & 0x07FFFFFF)) + v0) ^ (sum + llList2Integer(xtea_key, (sum >> 11) & 3));
266
267 } while( num_rounds = ~-num_rounds );
268 //return only first 6 chars to remove "=="'s and compact encrypted text.
269 return llGetSubString(llIntegerToBase64(v0),0,5) +
271 }
272
273 // Decipher two base64-encoded integers and return the FIRST 30 BITS of
274 // each as one 10-byte base64-encoded string.
275 string xtea_decipher( integer v0, integer v1 )
276 {
277 integer num_rounds = xtea_num_rounds;
278 integer sum = XTEA_DELTA*xtea_num_rounds;
279 do {
280 // LSL does not have unsigned integers, so when shifting right we
281 // have to mask out sign-extension bits.
282 v1 -= (((v0 << 4) ^ ((v0 >> 5) & 0x07FFFFFF)) + v0) ^ (sum + llList2Integer(xtea_key, (sum>>11) & 3));
283 sum -= XTEA_DELTA;
284 v0 -= (((v1 << 4) ^ ((v1 >> 5) & 0x07FFFFFF)) + v1) ^ (sum + llList2Integer(xtea_key, sum & 3));
285 } while( num_rounds = ~-num_rounds );
286
287 return llGetSubString(llIntegerToBase64(v0), 0, 4) +
289 }
290
291 // Encrypt a full string using XTEA.
292 string xtea_encrypt_string( string str )
293 {
294 if(! ENCRYPT)
295 return str;
296 // encode string
297 str = llStringToBase64(str);
298 // remove trailing =s so we can do our own 0 padding
299 integer i = llSubStringIndex( str, "=" );
300 if( i != -1 )
301 str = llDeleteSubString( str, i, -1 );
302
303 // we don't want to process padding, so get length before adding it
304 integer len = llStringLength(str);
305
306 // zero pad
307 str += "AAAAAAAAAA=";
308
309 string result;
310 i = 0;
311
312 do {
313 // encipher 30 (5*6) bits at a time.
314 result += xtea_encipher(llBase64ToInteger(llGetSubString(str, i, i + 4) + "A="), llBase64ToInteger(llGetSubString(str, i+5, i + 9) + "A="));
315 i+=10;
316 } while( i < len );
317
318 return result;
319 }
320
321 // Decrypt a full string using XTEA
322 string xtea_decrypt_string( string str ) {
323 if(! ENCRYPT)
324 return str;
325 integer len = llStringLength(str);
326 integer i=0;
327 string result;
328 //llOwnerSay(str);
329 do {
330 integer v0;
331 integer v1;
332
333 v0 = llBase64ToInteger(llGetSubString(str, i, i + 5) + "==");
334 i+= 6;
335 v1 = llBase64ToInteger(llGetSubString(str, i, i + 5) + "==");
336 i+= 6;
337
338 result += xtea_decipher(v0, v1);
339 } while( i < len );
340
341 // Replace multiple trailing zeroes with a single one
342
343 i = llStringLength(result) - 1;
344 while( llGetSubString(result, i - 1, i) == "AA" ){
345 result = llDeleteSubString(result, i, i);
346 i--;
347 }
348 i = llStringLength(result) - 1;
349 // while(llGetSubString(result, i, i + 1) == "A" ) {
350 // i--;
351 // }
352 result = llGetSubString(result, 0, i+1);
353 i = llStringLength(result);
354 integer mod = i%4; //Depending on encoded length diffrent appends are needed
355 if(mod == 1) result += "A==";
356 else if(mod == 2 ) result += "==";
357 else if(mod == 3) result += "=";
358
359 return llBase64ToString(result);
360 }
361
362 string base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
363
364
365
366
367 // EGG code begins again, see tunables up above
368
369 integer unpackaged = FALSE; // Opensim has issues with establishing a on_rez, so we use a timer to fix the bug
370
371 // breedable params
372 vector colour1;
373 vector colour2;
374 integer sex;
375 integer gen;
376 integer shine;
377 float glow;
378
379 // globals
380 string colourName1; // new string to hold color name version 0.52
381 string colourName2;
382
383 integer api_listener; // holds the API listener id so we can remove it
384 integer locked; // only hear 1 PONG from a crate
385 integer owner_touch; // flag set when ower has touched the prim
386 integer menu_listener; // integer of the listener so we can remove it.
387
388 // allow either a UUID to be entered, or not, and still maintain security
389 integer CheckPerms()
390 {
391 if(YOUR_UUID != "" && llGetOwner() != YOUR_UUID)
392 return 1;
393
395 return 1;
396
397 return 0;
398 }
399
400
401 set_colours(vector c1, vector c2, integer shine, float glow)
402 {
403 // set the root prim (the egg top), skip the base, and then do the egg bottom half
404 // Link order is top Egg half, Base, then bottom of the egg half
405
406 // IN CASE YOU ARE USING THE TEXTURE PLUG IN:
407 string msg = (string) c1 + "^" +
408 (string) c2 + "^" +
409 "0^" + // sex is unknown in an egg
410 (string) shine + "^" +
411 (string) glow + "^";
412
413 llMessageLinked(LINK_SET,LINK_TEXTURE,msg,NULL_KEY); // tell the optional texture plugin to fetch the textures
414
417 llMessageLinked(LINK_SET,LINK_COLOR1_GET,(string) colour1,""); // V 0.52 send colors to plug in
418 llMessageLinked(LINK_SET,LINK_COLOR2_GET,(string) colour2,"");
419
420 }
421
422 say_details()
423 {
424
425 string myshine;
426
427 if(shine == 0) {
428 myshine = "None";
429 } else
430 if(shine == 1) {
431 myshine = "Low";
432 } else
433 if(shine == 2) {
434 myshine = "Medium";
435 } else
436 if(shine == 3) {
437 myshine = "High";
438 }
439
440 llWhisper(0, "Color: " + colourName1);
441 llWhisper(0, "Color: " + colourName2);
442 llWhisper(0, "Shine: " + myshine);
443 llWhisper(0, "Glow: " + (string)((integer)(glow * 100)) + "%");
444 llWhisper(0, "Special: " + SPECIAL);
445 llWhisper(0, "Generation: " + (string)gen);
446 llSay(API_CHANNEL, "XSPet^" + (string)llGetKey() + "^" + (string)colour1 + "^" + (string)colour2 + "^" + (string)shine + "^" + (string)glow + "^" + SPECIAL + "^" + (string)gen + "^XSPetEnd");
447 }
448
449 default
450 {
452 {
453 DEBUG("RESET");
454 llSetText("", <1,1,1>, 1.0); // no white text
455 llSetColor(<1,1,1>, ALL_SIDES); // all white egg
456 llSetLinkColor(2, <1,1,1>, ALL_SIDES); // white egg link 2
457 llParticleSystem([]); // no particles, beats me why, somebody once had an egg that spewed so I am leaving it.
458 xtea_key = xtea_key_from_string(SECRET_PASSWORD);
459 }
460
461 // the egg accepts inventory from crates and mama
462 changed(integer change) {
463 if(change & CHANGED_ALLOWED_DROP) {
466 }
467 }
468 }
469
470 on_rez(integer param)
471 {
472 DEBUG("REZZING");
473 llSetText("Rezzing...", <1,0,0>, 1.0); // Rez Rezzing.. text
474
475 // if param = 0, then someone rezzed an egg. It had better be the creator or someone who has put their UUID in the script.
476 // all colors start in GEN 0 as primary colors here
477
478 if(param == 0) {
479
480 DEBUG("CREATOR REZZED ME");
481 if(! CheckPerms() ) {
482 integer colour = (integer)llFrand(9.0) + 1;
483