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
Animal Breedable_Animal_Pets_Script  

Breedable_Animal_Pets_Script

Adding these scripts to objects will create a breedable pet. You need to read each script and add your own information in order for them to work.

In particular, the pet itself will die unless it is rezzed from another object and given a start_param. The only way to give a script a start parameter is to rez it from another object, when you rez it yourself the parameter is always 0. if you set the secret number to 0, then it will always work, buit be unsecure.

Category: Animal
By : Xundra Snowpaw
Created: 2011-07-25 Edited: 2011-07-25
Worlds: Second Life

the Zip file

Download all files for Breedable_Animal_Pets_Script
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Breedable_Animal_Pets_Script_1.lsl
Get file # 2. Breedable_Animal_Pets_Script_10.lsl
Get file # 3. Breedable_Animal_Pets_Script_11.lsl
Get file # 4. Breedable_Animal_Pets_Script_12.lsl
Get file # 5. Breedable_Animal_Pets_Script_13.lsl
Get file # 6. Breedable_Animal_Pets_Script_14.lsl
Get file # 7. Breedable_Animal_Pets_Script_15.lsl
Get file # 8. Breedable_Animal_Pets_Script_16.lsl
Get file # 9. Breedable_Animal_Pets_Script_17.lsl
Get file # 10. Breedable_Animal_Pets_Script_2.lsl
Get file # 11. Breedable_Animal_Pets_Script_3.lsl
Get file # 12. Breedable_Animal_Pets_Script_4.lsl
Get file # 13. Breedable_Animal_Pets_Script_5.lsl
Get file # 14. Breedable_Animal_Pets_Script_6.lsl
Get file # 15. Breedable_Animal_Pets_Script_7.lsl
Get file # 16. Breedable_Animal_Pets_Script_8.lsl
Get file # 17. Breedable_Animal_Pets_Script_9.lsl
1 There are 6 categories of scripts:
2 Animal:
3 Egg
4 EggCup
5 FoodBowl
6 Home
7 Transport Crate

Breedable_Animal_Pets_Script

Animal: xs_ager.lsl

Category: Animal
By : Xundra Snowpaw
Created: 2011-07-25 Edited: 2011-07-25
Worlds: Second Life

1 integer age;
2 float GROWTH_AMOUNT = 0.10;
3
4 // body
5 // x = 0.124
6 // y = 0.082
7 // z = 0.096
8
9 // head <0.042349,-0.000059,0.055298> 8
10 // x = 0.082
11 // y = 0.082
12 // z = 0.082
13
14 // tail <-0.032043,-0.000061,0.009560> 7
15 // x = 0.082
16 // y = 0.082
17 // z = 0.082
18
19 // left wing <-0.004141,0.034098,0.008184> 3
20 // x = 0.058
21 // y = 0.079
22 // z = 0.023
23
24 // right wing <-0.011113,-0.034257,0.008841> 2
25 // x = 0.058
26 // y = 0.079
27 // z = 0.023
28
29 // left leg <0.009700,0.020261,-0.052318> 9
30 // x = 0.010
31 // y = 0.010
32 // z = 0.064
33
34 // right leg <0.009747,-0.022943,-0.052399> 10
35 // x = 0.010
36 // y = 0.010
37 // z = 0.064
38
39 // left eye <0.067205,0.018735,0.070143> 5
40 // x = 0.024
41 // y = 0.024
42 // z = 0.024
43
44 // right eye <0.067265,-0.017552,0.070217> 6
45 // x = 0.024
46 // y = 0.024
47 // z = 0.024
48
49 // beak <0.086439,-0.000059,0.049794> 4
50 // x = 0.043
51 // y = 0.043
52 // z = 0.043
53
54 default
55 {
56 link_message(integer sender, integer num, string str, key id)
57 {
58 if(num == 800) {
59 state running;
60 }
61 }
62 }
63
64 state running
65 {
67 {
68 age = 0;
69 }
70
71 timer()
72 {
73 llMessageLinked(LINK_SET, 940, "1", "");
74 }
75
76 link_message(integer sender, integer num, string str, key id)
77 {
78 if(num == 942) {
79 llMessageLinked(LINK_SET, 943, (string)age, "");
80 } else
81 if(num == 941) {
82 llSetTimerEvent(86400.0); // 86400.0
83 } else
84 if(num == 940) {
85 integer prev_age = age;
86 integer size_age;
87
88 age += (integer)str;
89
90 if(prev_age == 0 && age > 7) {
91 size_age = 7;
92 } else {
93 size_age = age;
94 }
95
96 if(size_age > 0 && size_age <= 7) {
97 // grow to the correct proportion
98 llMessageLinked(LINK_SET, 911, "1", ""); // tell mover to rest for 5 seconds
99
100
101 float new_scale = (GROWTH_AMOUNT * size_age) + 1.0;
102
103 vector new_size;
104 vector new_pos;
105
106 // -> body
107
108 new_size = <0.124, 0.082, 0.096> * new_scale;
109
111
112 // -> body -> tail <-0.032043,-0.000061,0.009560> 9
113
114 new_size = <0.082, 0.082, 0.082> * new_scale;
115 new_pos = <-0.032043,-0.000061,0.009560> * new_scale;
116 llSetLinkPrimitiveParams(9, [PRIM_SIZE, new_size, PRIM_POSITION, new_pos]);
117
118 // -> body -> left wing <-0.004141,0.034098,0.008184> 7
119 new_size = <0.058, 0.079, 0.023> * new_scale;
120 new_pos = <-0.004141,0.034098,0.008184> * new_scale;
121
122 llSetLinkPrimitiveParams(7, [PRIM_SIZE, new_size, PRIM_POSITION, new_pos]);
123
124 // -> body -> right wing <-0.011113,-0.034257,0.008841> 4
125 new_size = <0.058, 0.079, 0.023> * new_scale;
126 new_pos = <-0.011113,-0.034257,0.008841> * new_scale;
127
128 llSetLinkPrimitiveParams(4, [PRIM_SIZE, new_size, PRIM_POSITION, new_pos]);
129
130 // -> body -> left leg <0.009700,0.020261,-0.052318> 6
131 new_size = <0.01, 0.01, 0.064> * new_scale;
132 new_pos = <0.009700,0.020261,-0.052318> * new_scale;
133
134 llSetLinkPrimitiveParams(6, [PRIM_SIZE, new_size, PRIM_POSITION, new_pos]);
135
136 // -> body -> right leg <0.009747,-0.022943,-0.052399> 10
137 new_size = <0.01, 0.01, 0.064> * new_scale;
138 new_pos = <0.009747,-0.022943,-0.052399> * new_scale;
139
140 llSetLinkPrimitiveParams(10, [PRIM_SIZE, new_size, PRIM_POSITION, new_pos]);
141
142 // -> body -> head <0.042349,-0.000059,0.055298> 5
143 new_size = <0.082, 0.082, 0.082> * new_scale;
144 new_pos = <0.042349,-0.000059,0.055298> * new_scale;
145
146 llSetLinkPrimitiveParams(5, [PRIM_SIZE, new_size, PRIM_POSITION, new_pos]);
147 // -> body -> head -> left eye <0.067205,0.018735,0.070143> 8
148 new_size = <0.024, 0.024, 0.024> * new_scale;
149 new_pos = <0.067205,0.018735,0.070143> * new_scale;
150
151 llSetLinkPrimitiveParams(8, [PRIM_SIZE, new_size, PRIM_POSITION, new_pos]);
152
153 // -> body -> head -> right eye <0.067265,-0.017552,0.070217> 3
154 new_size = <0.024, 0.024, 0.024> * new_scale;
155 new_pos = <0.067265,-0.017552,0.070217> * new_scale;
156
157 llSetLinkPrimitiveParams(3, [PRIM_SIZE, new_size, PRIM_POSITION, new_pos]);
158
159 // -> body -> head -> beak <0.086439,-0.000059,0.049794> 2
160 new_size = <0.043, 0.043, 0.043> * new_scale;
161 new_pos = <0.086439,-0.000059,0.049794> * new_scale;
162
163 llSetLinkPrimitiveParams(2, [PRIM_SIZE, new_size, PRIM_POSITION, new_pos]);
164
165 }
166 }
167 }
168 }

Breedable_Animal_Pets_Script

Animal: xs_brain.lsl

Category: Animal
By : Xundra Snowpaw
Created: 2011-07-25 Edited: 2011-07-25
Worlds: Second Life

1 // Version .25 3-25-2013
2
3 // script by Xundra Snowpaw
4 // mods by Ferd Frederix
5 //
6 // New BSD License: http://www.opensource.org/licenses/bsd-license.php
7 // Copyright (c) 2010, Xundra Snowpaw
8 // All rights reserved.
9 //
10 // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
11
12 //* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
13 //* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
14
15 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
16 ////////////////////////////////////////////////////////////////////
17
18
19 ///// GLOBAL LINK CONSTANTS extracted from original source //////
20 ///
21 // if you change anything, you change it everywhere and in a list in XS_Debug
22 ///
23
24 integer LINK_AGE_START = 800; // when quail is rezzed and secret_number, is sent by brain to breeder, eater and informatic get booted up
25 integer LINK_FOOD_CONSUME = 900; // from movement to brain when close to food, brain then consumes a random amount up to 10000
26 integer LINK_FOODMINUS = 901; // xs_brain receives FOOD_CONSUME, decrement hunger (eat)
27 integer LINK_HUNGRY = 903; // sent by eater (string)hunger_amount, checks each hour
28 integer LINK_HAMOUNT = 904; // hunger_amount = (integer)str,m updates the hunger amount in scripts
29 integer LINK_SET_HOME = 910; // loc ^ dist
30 integer LINK_MOVER = 911; // tell mover to rest for str seconds
31 integer LINK_FOODIE_CLR = 920; // clear all food_bowl_keys and contents
32 integer LINK_FOODIE = 921; // send FOOD_LOCATION coordinates to movement
33 integer LINK_COLOR1 = 930; // colour1
34 integer LINK_COLOR2 = 931; // colour2
35 integer LINK_SEX = 932; // sex
36 integer LINK_SHINE = 933; // shine
37 integer LINK_GLOW = 934; // glow
38 integer LINK_GEN = 935; // generation
39 integer LINK_MAGE = 940; // xs_brain sends, xs_ager consumes, adds str to age, if older than 7 days, will grow the animal
40 integer LINK_DAYTIME = 941; // xs_ager consumes, starts a timer of 86,400 seconds in xs_ager
41 integer LINK_GET_AGE = 942; // get age from xs_ager and sent it on channel 943
42 integer LINK_PUT_AGE = 943; // print age from xs_ager
43 integer LINK_PACKAGE = 950; // look for a cryo_crate
44 integer LINK_SEEK_FEMALE = 960; // MALE_BREED_CALL
45 integer LINK_MALE_BREED_CALL = 961; // triggered by LINK_SEEK_FEMALE
46 integer LINK_SIGNAL_ELIGIBLE = 962; // sent by female when hears LINK_MALE_BREED_CALL
47 integer LINK_FEMALE_ELIGIBLE = 963; // sent when it hears in chat FEMALE_ELIGIBLE
48 integer LINK_CALL_MALE = 964; // if LINK_FEMALE_ELIGIBLE && looking_for_female
49 integer LINK_MALE_ON_THE_WAY = 965; // triggered by LINK_CALL_MALE
50 integer LINK_FEMALE_LOCATION = 966; // female location, sends coordinates of a female
51 integer LINK_RQST_BREED = 967; // sent when close enough to male/female
52 integer LINK_CALL_MALE_INFO = 968; // ****** BUG ***** read, but never sent by anybody!!!!!
53 // see line 557 and 636 of xs_brain which make calls and also xs_breeding which receives LUNK_MALE_INFO.
54 integer LINK_MALE_INFO = 969;
55 integer LINK_LAY_EGG = 970; // llRezObject("XS Egg"
56 integer LINK_BREED_FAIL = 971; // key = father, failed, timed out
57 integer LINK_PREGNANT = 972; // chick is preggers
58 integer LINK_SLEEPING = 990; // close eyes
59 integer LINK_UNSLEEPING = 991; // open eyes
60 integer LINK_SOUND = 1001; // plays a sound if enabled
61 integer LINK_SPECIAL = 1010; // xs_special, is str = "Normal", removes script
62 integer LINK_PREGNANCY_TIME = 5000; // in seconds as str
63 integer LINK_SLEEP = 7999; // disable sleep by parameter
64 integer LINK_TIMER = 8000; // scan for food bowl about every 1800 seconds
65 integer LINK_DIE = 9999; // death
66
67
68 ///////// end global Link constants ////////
69
70 // END //
71
72
73
74 float VERSION = 0.22;
75
76 string SECRET_PASSWORD = "top secret";
77 integer SECRET_NUMBER = 99999;
78
79 integer FOOD_CHANNEL = -999191;
80 integer ANIMAL_CHANNEL = -999192;
81 integer HOME_CHANNEL = -999194;
82 integer BOX_CHANNEL = -999195;
83 integer ACC_CHANNEL = -999196;
84 integer UPDATE_CHANNEL = -999197;
85 integer EGG_CHANNEL = -999193;
86
87 float FOOD_BOWL_SCAN_INTERVAL = 1800.0;
88
89 // DON'T CHANGE THE FOLLOWING! (Unless you know what you are doing!)
90
91 integer XTEA_DELTA = 0x9E3779B9; // (sqrt(5) - 1) * 2^31
92 integer xtea_num_rounds = 6;
93 list xtea_key = [0, 0, 0, 0];
94
95 integer hex2int(string hex) {
96 if(llGetSubString(hex,0,1) == "0x")
97 return (integer)hex;
98 if(llGetSubString(hex,0,0) == "x")
99 return (integer)("0"+hex);
100 return(integer)("0x"+hex);
101 }
102
103
104 // Convers any string to a 32 char MD5 string and then to a list of
105 // 4 * 32 bit integers = 128 bit Key. MD5 ensures always a specific
106 // 128 bit key is generated for any string passed.
107 list xtea_key_from_string( string str )
108 {
109 str = llMD5String(str,0); // Use Nonce = 0
110 return [ hex2int(llGetSubString( str, 0, 7)),
111 hex2int(llGetSubString( str, 8, 15)),
112 hex2int(llGetSubString( str, 16, 23)),
113 hex2int(llGetSubString( str, 24, 31))];
114 }
115
116 // Encipher two integers and return the result as a 12-byte string
117 // containing two base64-encoded integers.
118 string xtea_encipher( integer v0, integer v1 )
119 {
120 integer num_rounds = xtea_num_rounds;
121 integer sum = 0;
122 do {
123 // LSL does not have unsigned integers, so when shifting right we
124 // have to mask out sign-extension bits.
125 v0 += (((v1 << 4) ^ ((v1 >> 5) & 0x07FFFFFF)) + v1) ^ (sum + llList2Integer(xtea_key, sum & 3));
126 sum += XTEA_DELTA;
127 v1 += (((v0 << 4) ^ ((v0 >> 5) & 0x07FFFFFF)) + v0) ^ (sum + llList2Integer(xtea_key, (sum >> 11) & 3));
128
129 } while( num_rounds = ~-num_rounds );
130 //return only first 6 chars to remove "=="'s and compact encrypted text.
131 return llGetSubString(llIntegerToBase64(v0),0,5) +
133 }
134
135 // Decipher two base64-encoded integers and return the FIRST 30 BITS of
136 // each as one 10-byte base64-encoded string.
137 string xtea_decipher( integer v0, integer v1 )
138 {
139 integer num_rounds = xtea_num_rounds;
140 integer sum = XTEA_DELTA*xtea_num_rounds;
141 do {
142 // LSL does not have unsigned integers, so when shifting right we
143 // have to mask out sign-extension bits.
144 v1 -= (((v0 << 4) ^ ((v0 >> 5) & 0x07FFFFFF)) + v0) ^ (sum + llList2Integer(xtea_key, (sum>>11) & 3));
145 sum -= XTEA_DELTA;
146 v0 -= (((v1 << 4) ^ ((v1 >> 5) & 0x07FFFFFF)) + v1) ^ (sum + llList2Integer(xtea_key, sum & 3));
147 } while( num_rounds = ~-num_rounds );
148
149 return llGetSubString(llIntegerToBase64(v0), 0, 4) +
151 }
152
153 // Encrypt a full string using XTEA.
154 string xtea_encrypt_string( string str )
155 {
156 // encode string
157 str = llStringToBase64(str);
158 // remove trailing =s so we can do our own 0 padding
159 integer i = llSubStringIndex( str, "=" );
160 if( i != -1 )
161 str = llDeleteSubString( str, i, -1 );
162
163 // we don't want to process padding, so get length before adding it
164 integer len = llStringLength(str);
165
166 // zero pad
167 str += "AAAAAAAAAA=";
168
169 string result;
170 i = 0;
171
172 do {
173 // encipher 30 (5*6) bits at a time.
174 result += xtea_encipher(llBase64ToInteger(llGetSubString(str, i, i + 4) + "A="), llBase64ToInteger(llGetSubString(str, i+5, i + 9) + "A="));
175 i+=10;
176 } while( i < len );
177
178 return result;
179 }
180
181 // Decrypt a full string using XTEA
182 string xtea_decrypt_string( string str ) {
183 integer len = llStringLength(str);
184 integer i=0;
185 string result;
186 //llOwnerSay(str);
187 do {
188 integer v0;
189 integer v1;
190
191 v0 = llBase64ToInteger(llGetSubString(str, i, i + 5) + "==");
192 i+= 6;
193 v1 = llBase64ToInteger(llGetSubString(str, i, i + 5) + "==");
194 i+= 6;
195
196 result += xtea_decipher(v0, v1);
197 } while( i < len );
198
199 // Replace multiple trailing zeroes with a single one
200
201 i = llStringLength(result) - 1;
202 while( llGetSubString(result, i - 1, i) == "AA" ){
203 result = llDeleteSubString(result, i, i);
204 i--;
205 }
206 i = llStringLength(result) - 1;
207 // while(llGetSubString(result, i, i + 1) == "A" ) {
208 // i--;
209 // }
210 result = llGetSubString(result, 0, i+1);
211 i = llStringLength(result);
212 integer mod = i%4; //Depending on encoded length diffrent appends are needed
213 if(mod == 1) result += "A==";
214 else if(mod == 2 ) result += "==";
215 else if(mod == 3) result += "=";
216
217 return llBase64ToString(result);
218 }
219
220
221 integer setup = FALSE; // added to cure opensim rezzing issue
222
223 //integer food_left;
224 integer random_number;
225 integer random_number2;
226 //list food_bowl_keys;
227 //list food_bowl_locations;
228 integer hunger_amount;
229 vector colour1;
230 vector colour2;
231
232 integer sex;
233
234 integer shine;
235 float glow;
236
237 integer gen;
238 integer age;
239
240 vector mcolour1;
241 vector mcolour2;
242
243 integer mshine;
244 float mglow;
245
246 integer mgen;
247 vector home_loc;
248 key new_egg_key;
249
250 integer glow_gene;
251 string special;
252
253 integer mglow_gene;
254
255 integer locked;
256
257 integer pregnancy_time;
258
259 default
260 {
262 {
263 if(llGetOwner() != llGetCreator()) {
264 // someone not the creator reset the script. Thats naughty.
265 state dead;
266 }
267 llSetText("", <1,1,1>, 1.0);
268 random_number = 0;
269 random_number2 = 0;
270 hunger_amount = 0;
271 locked = 0;
272
273 xtea_key = xtea_key_from_string(SECRET_PASSWORD);
274 llListen(ANIMAL_CHANNEL, "", "", "");
275 }
276
277 changed(integer change)
278 {
279
280 if(change & CHANGED_ALLOWED_DROP) {
283 }
284 }
285
286 if(change & CHANGED_INVENTORY) {
287 if(llGetOwner() != llGetCreator()) {
288
290 integer extras = 3;
291
292
293 if(llGetInventoryType("xs_ager") == INVENTORY_NONE || !llGetScriptState("xs_ager")) {
294 state dead;
295 }
296 if(llGetInventoryType("xs_infomatic") == INVENTORY_NONE || !llGetScriptState("xs_infomatic")) {
297 state dead;
298 }
299 if(llGetInventoryType("xs_breeding") == INVENTORY_NONE || !llGetScriptState("xs_breeding")) {
300 state dead;
301 }
302 if(llGetInventoryType("xs_eater") == INVENTORY_NONE || !llGetScriptState("xs_eater")) {
303 state dead;
304 }
305 if(llGetInventoryType("xs_movement") == INVENTORY_NONE || !llGetScriptState("xs_movement")) {
306 state dead;
307 }
308 if(llGetInventoryType("bird_sound") == INVENTORY_NONE) {
309 state dead;
310 }
311
312
313 if(llGetInventoryType("xs_special") == INVENTORY_NONE) {
314 extras--;
315 }
316
318 extras--;
319 }
320
322 extras--;
323 }
324
325 if(llGetInventoryType("XS Home Object") == INVENTORY_NONE) {
326 state dead;
327 }
328
329 if(8 + extras != inventory_count) {
330 state dead;
331 }
332
333 }
334 }
335 }
336
337 timer()
338 {
339 // for OpenSIm to establish an on_rez, the durn thing does not for the onrez even in the egg unless the script goes idle
340 if(setup == TRUE)
341 {
342 llSay(EGG_CHANNEL, xtea_encrypt_string("XSPET^READY^" + (string)llGetKey() + "^XSPET"));
343 llSay(BOX_CHANNEL, xtea_encrypt_string("XSPET^READY^" + (string)llGetKey() + "^XSPET"));
344 setup = FALSE;
345 return;
346 }
347
348
349
350 llMessageLinked(LINK_SET, LINK_FOODIE_CLR, "", "");
351 // llWhisper(0, "Scanning for food bowls.");
352 random_number = (integer)(llFrand(10000.0) + 1);
353 llSay(FOOD_CHANNEL, xtea_encrypt_string("XSPET^FOOD_LOCATION^" + (string)random_number + "^" + (string)llGetKey()));
354 llSetTimerEvent(llFrand(60.0) + (FOOD_BOWL_SCAN_INTERVAL - 30.0));
355 }
356
357 listen(integer channel, string name, key id, string message)
358 {
359 if(channel == ANIMAL_CHANNEL) {
360 list data = llParseString2List(xtea_decrypt_string(message), ["^"], []);
361 if(llList2String(data, 0) == "XSPET") {
362 if(llList2String(data, 1) == "FOOD_LOCATION") {
363 llMessageLinked(LINK_SET, LINK_FOODIE, llList2String(data, 3), id);
364 } else
365 if(llList2String(data, 1) == "FOOD_CONSUME") {
366 if(llList2Integer(data, 2) == random_number2 && llList2Key(data, 3) == llGetKey()) {
367 hunger_amount--;
368 llMessageLinked(LINK_SET, LINK_FOODMINUS, "", "");
369 random_number2 = 0;
370 if(llList2Integer(data, 4) == 1 && glow_gene < 10) {
371 glow_gene ++;
372 }
373 }
374 } else
375 if(llList2String(data, 1) == "HOME_LOCATION") {
376 vector n_home_loc = (vector)llList2String(data, 2);
377 float home_dis = llList2Float(data, 3);
378 vector my_loc = llGetPos();
379 // llOwnerSay((string)llVecDist(home_loc, my_loc) + " " + (string)my_loc + (string)home_loc + (string)home_dis + llList2String(data, 2));
380 if(llVecDist(n_home_loc, my_loc) <= home_dis && llFabs(llFabs(n_home_loc.z) - llFabs(my_loc.z)) < 1) {
381 if(llGetOwnerKey(id) == llGetOwner()) {
382 home_loc = n_home_loc;
383 llMessageLinked(LINK_SET, LINK_SET_HOME, (string)n_home_loc + "^" + (string)home_dis, "");
384 }
385 }
386 } else
387 if(llList2String(data, 1) == "CONFIG" && llList2Key(data, 2) == llGetKey()) {
388 colour1 = (vector)llList2String(data, 3);;
389 colour2 = (vector)llList2String(data, 4);
390
391 sex = llList2Integer(data, 5);
392
393 shine = llList2Integer(data, 6);
394 glow = llList2Float(data, 7);
395
396 gen = llList2Integer(data, 8);
397 integer mage = llList2Integer(data, 9);
398 integer hamount = llList2Integer(data, 10);
399 string myname = llList2String(data, 11);
400 glow_gene = llList2Integer(data, 12);
401 special = llList2String(data, 13);
402
405
406 // llSetLinkColor(8, colour1, ALL_SIDES);
407 // llSetLinkColor(1, colour1, ALL_SIDES);
408
412 // llSetLinkColor(3, colour2, ALL_SIDES);
413 // llSetLinkColor(2, colour2, ALL_SIDES);
414 // llSetLinkColor(7, colour2, ALL_SIDES);
415
416 llSetTimerEvent(llFrand(60.0) + (FOOD_BOWL_SCAN_INTERVAL - 30.0));
417
418
419 llMessageLinked(LINK_SET, LINK_COLOR1, (string)colour1, "");
420 llMessageLinked(LINK_SET, LINK_COLOR2, (string)colour2, "");
421 llMessageLinked(LINK_SET, LINK_SEX, (string)sex, "");
422 llMessageLinked(LINK_SET, LINK_SHINE, (string)shine, "");
423 llMessageLinked(LINK_SET, LINK_GLOW, (string)glow, "");
424 llMessageLinked(LINK_SET, LINK_GEN, (string)gen, "");
425
426
427 llMessageLinked(LINK_SET, LINK_MAGE, (string)mage, "");
428
429
430 if(hamount > 0) {
431 llMessageLinked(LINK_SET, LINK_HAMOUNT, (string)hamount, "");
432 }
433
434 if(name != "Quail") {
435 llSetObjectName(myname);
436 }
437
438 llSetObjectDesc("XS Quail v" + (string)VERSION + " (c) 2010 Xundra Snowpaw");
439
440
441 llMessageLinked(LINK_SET, LINK_SPECIAL, special, "");
442
443 llMessageLinked(LINK_SET, LINK_DAYTIME, "", "");
444
445 llSay(HOME_CHANNEL, "XSPET_PING_HOME");
446
447 llSetText("", <1,1,1>, 1.0);
448 } else
449 if(llList2String(data, 1) == "UPDATE_CONFIG" && llList2Key(data, 2) == llGetKey()) {
450 colour1 = (vector)llList2String(data, 3);;
451 colour2 = (vector)llList2String(data, 4);
452
453 sex = llList2Integer(data, 5);
454
455 shine = llList2Integer(data, 6);
456 glow = llList2Float(data, 7);
457
458 gen = llList2Integer(data, 8);
459 integer mage = llList2Integer(data, 9);
460 integer hamount = llList2Integer(data, 10);
461 string myname = llList2String(data, 11);
462 glow_gene = llList2Integer(data, 12);
463 special = llList2String(data, 13);
464 mcolour1 = (vector)llList2String(data, 14);
465 mcolour2 = (vector)llList2String(data, 15);
466 mshine = llList2Integer(data, 16);
467 mglow = llList2Float(data, 17);
468 mgen = llList2Integer(data, 18);
469 mglow_gene = llList2Integer(data, 19);
470 pregnancy_time = llList2Integer(data, 20);
471
474
475 // llSetLinkColor(8, colour1, ALL_SIDES);
476 // llSetLinkColor(1, colour1, ALL_SIDES);
477
481 // llSetLinkColor(3, colour2, ALL_SIDES);
482 // llSetLinkColor(2, colour2, ALL_SIDES);
483 // llSetLinkColor(7, colour2, ALL_SIDES);
484
485 llSetTimerEvent(llFrand(60.0) + (FOOD_BOWL_SCAN_INTERVAL - 30.0));
486
487
488 llMessageLinked(LINK_SET, LINK_COLOR1, (string)colour1, "");
489 llMessageLinked(LINK_SET, LINK_COLOR2, (string)colour2, "");
490
491 if(sex == 1) {
492 llMessageLinked(LINK_SET, LINK_SEX, (string)sex, "");
493 } else {
494 llMessageLinked(LINK_SET, LINK_PREGNANCY_TIME, (string)pregnancy_time, "");
495 }
496
497 llMessageLinked(LINK_SET, LINK_SHINE, (string)shine, "");
498 llMessageLinked(LINK_SET, LINK_GLOW, (string)glow, "");
499 llMessageLinked(LINK_SET, LINK_GEN, (string)gen, "");
500
501
502 llMessageLinked(LINK_SET, LINK_MAGE, (string)mage, "");
503
504
505 if(hamount > 0) {
506 llMessageLinked(LINK_SET, LINK_HAMOUNT, (string)hamount, "");
507 }
508
509 if(name != "Quail") {
510 llSetObjectName(myname);
511 }
512
513 llSetObjectDesc("XS Quail v" + (string)VERSION + " (c) 2010 Xundra Snowpaw");
514
515
516 llMessageLinked(LINK_SET, LINK_SPECIAL, special, "");
517
518 llMessageLinked(LINK_SET, LINK_DAYTIME, "", "");
519
520
521
522 llSay(HOME_CHANNEL, "XSPET_PING_HOME");
523
524 llSetText("", <1,1,1>, 1.0);
525 } else
526 if(llList2String(data, 1) == "CRATE_PONG" && llList2Key(data, 2) == llGetKey()) {
527 if(llList2Float(data, 3) >= VERSION && locked == 0) {
528 locked = 1;
529 llSay(BOX_CHANNEL, xtea_encrypt_string("XSPET^" + (string)id + "^" + (string )colour1 + "^" + (string)colour2 + "^" + (string)shine + "^" + (string)glow + "^" + (string)gen + "^" + (string)sex + "^" + (string)age + "^" + (string)hunger_amount + "^" + llGetObjectName() + "^" + (string)glow_gene + "^" + special));
530 }
531 } else
532 if(llList2String(data, 1) == "CRATE_DIE" && llList2Key(data, 2) == llGetKey()) {
533 llDie();
534 } else
535 if(llList2String(data, 1) == "MALE_BREED_CALL") {
536 llMessageLinked(LINK_SET, LINK_MALE_BREED_CALL, "", "");
537 } else
538 if(llList2String(data, 1) == "FEMALE_ELIGIBLE" && home_loc == (vector)llList2String(data, 2)) {
539 llMessageLinked(LINK_SET, LINK_FEMALE_ELIGIBLE, "", id);
540 } else
541 if(llList2String(data, 1) == "MALE_ON_THE_WAY" && llList2Key(data, 2) == llGetKey()) {
542 llMessageLinked(LINK_SET, LINK_MALE_ON_THE_WAY, "", id);
543 llSay(ANIMAL_CHANNEL, xtea_encrypt_string("XSPET^FEMALE_LOC^" + (string)id + "^" + (string)llGetPos()));
544 } else
545 if(llList2String(data, 1) == "FEMALE_LOC" && (key) llList2String(data, 2) == llGetKey()) // missing key cast - Ferd
546 {
547 llMessageLinked(LINK_SET, LINK_FEMALE_LOCATION, llList2String(data, 3), "");
548 } else
549 if(llList2String(data, 1) == "MALE_INFO" && llList2Key(data, 2) == llGetKey()){
550 // pregnant
551 mcolour1 = (vector)llList2String(data, 3);
552 mcolour2 = (vector)llList2String(data, 4);
553
554 mshine = llList2Integer(data, 5);
555 mglow = llList2Float(data, 6);
556
557 mgen = llList2Integer(data, 7);
558 mglow_gene = llList2Integer(data, 8);
559 pregnancy_time = llGetUnixTime();
560 llMessageLinked(LINK_SET, LINK_PREGNANT, "", "");
561 } else
562 if(llList2String(data, 1) == "BREEDING_FAIL" && (key) llList2String(data, 2) == llGetKey()) // missing key cast - Ferd
563 {
564 llMessageLinked(LINK_SET, LINK_MALE_INFO, "", "");
565 } else
566 if(llList2String(data, 1) == "EGG_READY" && id == new_egg_key)
567 {
568 llGiveInventory(id, "XS Egg");
569 llGiveInventory(id, "Quail");
570
571 llSay(EGG_CHANNEL, xtea_encrypt_string("XSPET^" + (string)id + "^BORN^" + (string)colour1 + "^" + (string)colour2 + "^" + (string)gen + "^" + (string)shine + "^" + (string)glow + "^" + (string)glow_gene + "^" + (string)mcolour1 + "^" + (string)mcolour2 + "^" + (string)mgen + "^" + (string)mshine + "^" + (string)mglow + "^" + (string)mglow_gene));
572 } else
573 if(llList2String(data, 1) == "SHINE_GOO" && (key) llList2String(data, 2) == llGetKey()) { // missing key cast - Ferd
574 if(shine == 0) {
575 shine = 1;
576 llMessageLinked(LINK_SET, LINK_SHINE, (string)shine, "");
577 llSay(ACC_CHANNEL, xtea_encrypt_string("XSPET^" + (string)id + "^SHINE_GOO_DIE"));
580
581 // llSetLinkColor(8, colour1, ALL_SIDES);
582 // llSetLinkColor(1, colour1, ALL_SIDES);
583
587 if(sex == 1) {
588 llWhisper(0, "Look out ladies, Mr Slick has arrived!");
589 } else {
590 llWhisper(0, "Look out gentlemen! Miss Slick has arrived!");
591 }
592
593
594 } else {
595 llWhisper(0, "I'm already shiny!");
596 llSay(ACC_CHANNEL, xtea_encrypt_string("XSPET^" + (string)id + "^SHINE_GOO_FAIL"));
597
598 }
599 } else
600 if(llList2String(data, 1) == "DIE" && (key) llList2String(data, 2) == llGetKey()) { // missing key cast - Ferd
601 llDie();
602 } else
603 if(llList2String(data, 1) == "VERSION" && VERSION < llList2Float(data, 2) && llGetOwnerKey(id) == llGetOwner()) {
604 llShout(UPDATE_CHANNEL, "VERSION^" + (string)VERSION);
605 } else
606 if(llList2String(data, 1) == "UPDATE" && (key) llList2String(data, 2) == llGetKey() && llGetOwnerKey(id) == llGetOwner()) { // missing key cast - Ferd
607 state update;
608 }
609 }
610 }
611 }
612
613 link_message(integer sender, integer num, string str, key id)
614 {
615 if(num == LINK_HUNGRY || num == LINK_HAMOUNT) {
616 hunger_amount = (integer)str;
617 if(hunger_amount > 30) {
618 state dead;
619 }
620 } else
621 if(num == LINK_FOOD_CONSUME) {
622 random_number2 = (integer)(llFrand(10000.0) + 1);
623 llSay(FOOD_CHANNEL, xtea_encrypt_string("XSPET^FOOD_CONSUME^" + (string)id + "^" + (string)random_number2 + "^" + (string)llGetKey()));
624 } else
625 if(num == LINK_MAGE) {
626 age += (integer)str;
627 } else
628 if(num == LINK_PACKAGE) {
629 llWhisper(0, "Looking for a cryo-crate...");
630 llSay(BOX_CHANNEL, xtea_encrypt_string("XSPET^" + (string)llGetKey() + "^CRATE_PING^" + (string)VERSION));
631 } else
632 if(num == LINK_SEEK_FEMALE) {
633 llSay(ANIMAL_CHANNEL, xtea_encrypt_string("XSPET^MALE_BREED_CALL^" + (string)llGetKey()));
634 } else
635 if(num == LINK_SIGNAL_ELIGIBLE) {
636 llSay(ANIMAL_CHANNEL, xtea_encrypt_string("XSPET^FEMALE_ELIGIBLE^" + (string)home_loc));
637 } else
638 if(num == LINK_CALL_MALE) {
639 llSay(ANIMAL_CHANNEL, xtea_encrypt_string("XSPET^MALE_ON_THE_WAY^" + (string)id));
640 } else
641 if(num == LINK_CALL_MALE_INFO) {
642 llSay(ANIMAL_CHANNEL, xtea_encrypt_string("XSPET^MALE_INFO^" + (string)id + "^" + (string)colour1 + "^" + (string)colour2 + "^" + (string)shine + "^" + (string)glow + "^" + (string)gen + "^" + (string)glow_gene));
643 llMessageLinked(LINK_SET, LINK_MALE_INFO, "", "");
644 } else
645 if(num == LINK_LAY_EGG) {
646 // lay an egg
647 pregnancy_time = 0;
648 llRezObject("XS Egg", llGetPos() + <0.0, 0.0, 0.25>, ZERO_VECTOR, ZERO_ROTATION, SECRET_NUMBER);
649 } else
650 if(num == LINK_BREED_FAIL) {
651 llSay(ANIMAL_CHANNEL, xtea_encrypt_string("XSPET^BREEDING_FAIL^" + (string)id));
652 pregnancy_time = 0;
653 } else
654 if(num == LINK_SLEEPING) {
657 } else
658 if(num == LINK_UNSLEEPING) {
661 } else
662 if(num == LINK_DIE) {
663 state dead;
664 } else
665 if(num == LINK_TIMER) {
666 llSetTimerEvent(llFrand(60.0) + (FOOD_BOWL_SCAN_INTERVAL - 30.0));
667 }
668 }
669
670 object_rez(key id)
671 {
672 new_egg_key = id;
673 }
674
675 on_rez(integer param)
676 {
677 if(param == SECRET_NUMBER) {
678 llSetText("Rezzing...", <1,0,0>, 1.0);
679 llMessageLinked(LINK_SET, LINK_AGE_START, "", "");
680
681 setup = TRUE;
682
683 if(llGetOwner() != llGetCreator()) {
685 }
686
687 llSetTimerEvent(5.0);
688
689 } else {
690 llOwnerSay("I died in your inventory, please use a cryo-crate next time.");
691 state dead;
692 }
693 }
694 }
695
696 state dead
697 {
699 {
700 llSetText("Dead", <1,0,0>, 1.0);
701 llRemoveInventory("xs_ager");
702 llRemoveInventory("xs_breeding");
703 llRemoveInventory("xs_eater");
704 llRemoveInventory("xs_infomatic");
705 llRemoveInventory("xs_movement");
706 if(llGetInventoryType("xs_special") != INVENTORY_NONE) {
707 llRemoveInventory("xs_special");
708 }
709 llListen(ANIMAL_CHANNEL, "", "", "");
710 }
711
712 touch_start(integer number)
713 {
714 llWhisper(0, "I've died. You could re-animate me with a jar of Xtra Strong Mojo");
715 if(llDetectedKey(0) == llGetOwner()) {
716 llSay(ACC_CHANNEL, xtea_encrypt_string("XSPET^STRONG_MOJO^" + (string)llGetKey() + "^" + (string)colour1 + "^" + (string)colour2 + "^" + (string)shine + "^" + (string)glow + "^" + special + "^" + (string)gen + "^" + (string)sex + "^" + (string)age + "^" + (string)glow_gene + (string)VERSION));
717
718 }
719 }
720
721 listen(integer channel, string name, key id, string message) {
722 list data = llParseString2List(xtea_decrypt_string(message), ["^"], []);
723 if(llList2String(data, 0) == "XSPET") {
724 if(llList2String(data, 1) == "STRONG_MOJO_DIE" && llList2Key(data, 2) == llGetKey()) {
725 llDie();
726 }
727 }
728 }
729 }
730
731 state update
732 {
734 {
735 llSetText("Updating.", <1,0,0>, 1.0);
736 llRemoveInventory("Quail");
737 llRemoveInventory("XS Egg");
739 llShout(UPDATE_CHANNEL, "UPDATE_READY");
740 }
741
742 changed(integer change)
743 {
744 if(change & CHANGED_ALLOWED_DROP) {
747 llRezObject("Quail", llGetPos() + <0.0, 0.0, 0.25>, ZERO_VECTOR, ZERO_ROTATION, SECRET_NUMBER);
748 }
749 }
750
751 }
752 object_rez(key id)
753 {
754 llListen(BOX_CHANNEL, "", id, "");
755 }
756
757 listen(integer channel, string name, key id, string msg)
758 {
759 if(channel == BOX_CHANNEL) {
760 list data = llParseString2List(xtea_decrypt_string(msg), ["^"], []);
761 if(llList2String(data, 0) == "XSPET" && llList2String(data, 1) == "READY") {
762
763 llGiveInventory(id, "XS Egg");
764 llGiveInventory(id, "Quail");
765 llSay(ANIMAL_CHANNEL, xtea_encrypt_string("XSPET^UPDATE_CONFIG^" + (string)id + "^" + (string)colour1 + "^" + (string)colour2 + "^" + (string)sex + "^" + (string)shine + "^" + (string)glow + "^" + (string)gen + "^" + (string)age + "^" + (string)hunger_amount + "^" + llGetObjectName() + "^" + (string)glow_gene + "^" + special + "^" + (string)mcolour1 + "^" + (string)mcolour2 + "^" + (string)mshine + "^" + (string)mglow + "^" + (string)mgen + "^" + (string)mglow_gene + "^" + (string)pregnancy_time));
766 llDie();
767 }
768 }
769 }
770 }

Breedable_Animal_Pets_Script

Animal: xs_breeding.lsl

Category: Animal
By : Xundra Snowpaw
Created: 2011-07-25 Edited: 2011-07-25
Worlds: Second Life

1 integer age;
2 integer looking_for_female;
3
4 key father;
5 key mother;
6
7 integer preg_time;
8
9 default
10 {
11 link_message(integer sender, integer num, string str, key id)
12 {
13 if(num == 800) {
14 state running;
15 }
16 }
17 }
18
19 state running
20 {
22 {
23 age = 0;
24 }
25
26 link_message(integer sender, integer num, string str, key id)
27 {
28 if(num == 932) {
29 if(str == "1") {
30 state male;
31 } else {
32 state female;
33 }
34 } else
35 if(num == 940) {
36 age += (integer)str;
37 } else
38 if(num == 5000) {
39 preg_time = (integer)str;
40 if(preg_time != 0) {
41 state pregnant;
42 } else {
43 state female;
44 }
45 }
46 }
47 }
48
49 state male
50 {
52 {
53 looking_for_female = 0;
54
55 mother = NULL_KEY;
56 father = NULL_KEY;
57
58 llMessageLinked(LINK_SET, 942, "", "");
59
60 if(age >= 7) {
61 llSetTimerEvent(10800.0);
62 }
63 }
64 link_message(integer sender, integer num, string str, key id)
65 {
66 if(num == 943) {
67 age = (integer)str;
68 if(age >= 7) {
69 llSetTimerEvent(10800.0);
70 }
71 } else
72 if(num == 940) {
73
74 age += (integer)str;
75 if(age >= 7) {
76 llSetTimerEvent(10800.0);
77 }
78 } else
79 if(num == 963) {
80 if(looking_for_female == 1) {
81 looking_for_female = 0;
82 mother = id;
83 father = llGetKey();
84 llMessageLinked(LINK_SET, 964, "", mother);
85 }
86 } else
87 if(num == 967) {
88 if(mother != NULL_KEY) {
89 llMessageLinked(LINK_SET, 968, "", mother);
90 }
91 } else
92 if(num == 969) {
93 state male;
94 }
95
96 }
97
98 timer()
99 {
100 looking_for_female = 1;
101 // look for an eligible female.
102 llWhisper(0, llGetObjectName() + " gets a gleam in his eye.");
103 llMessageLinked(LINK_SET, 960, "", "");
104 }
105 }
106
107 state female
108 {
110 {
111 mother = NULL_KEY;
112 father = NULL_KEY;
113
114 if(age == 0) {
115 llMessageLinked(LINK_SET, 942, "", "");
116 }
117 }
118
119 link_message(integer sender, integer num, string str, key id)
120 {
121 if(num == 940) {
122 age += (integer)str;
123 } else
124 if(num == 961) {
125 // signal I am eligible
126 if(age >= 7 && father == NULL_KEY) {
127 llWhisper(0, llGetObjectName() + " blushes then bobs her head up and down.");
128 llMessageLinked(LINK_SET, 962, "", "");
129 }
130 } else
131 if(num == 965) {
132 // male on the way, rest for 20m
133 llSetTimerEvent(900.0);
134 father = id;
135 mother = llGetKey();
136 llMessageLinked(LINK_SET, 911, "1200", "");
137 } else
138 if(num == 972) {
139 // pregnant
141 preg_time = 0;
142 state pregnant;
143 } else
144 if(num == 969) {
146 state female;
147 } else
148 if(num == 943) {
149 age = (integer)str;
150 } else
151 if(num == 5000) {
152 preg_time = (integer)str;
153 if(preg_time != 0) {
154 state pregnant;
155 }
156 }
157
158 }
159
160 timer()
161 {
163 // fail
164 llMessageLinked(LINK_SET, 971, "", father);
165 state female;
166 }
167 }
168
169 state pregnant
170 {
172 {
173 if(preg_time != 0) {
174 llSetTimerEvent(172800.0 - (float)(llGetUnixTime() - preg_time));
175 } else {
176 llSetTimerEvent(172800.0);
177 }
178 }
179 timer()
180 {
181 // lay egg.
183 llMessageLinked(LINK_SET, 970, "", "");
184 state female;
185 }
186 }

Breedable_Animal_Pets_Script

Animal: xs_eater.lsl

Category: Animal
By : Xundra Snowpaw
Created: 2011-07-25 Edited: 2011-07-25
Worlds: Second Life

1 integer SECONDS_BETWEEN_FOOD_NORMAL = 14400;
2 integer SECONDS_BETWEEN_FOOD_HUNGRY = 3600;
3
4 integer hunger_amount;
5 integer seconds_elapsed_normal;
6 integer seconds_elapsed_hungry;
7
8 default
9 {
10 link_message(integer sender, integer num, string str, key id)
11 {
12 if(num == 800) {
13 state running;
14 }
15 }
16 }
17
18 state running
19 {
21 {
22 hunger_amount = 0;
23 seconds_elapsed_normal = 0;
24 seconds_elapsed_hungry = 0;
25 llSetTimerEvent(1.0);
26 }
27
28 timer()
29 {
30 integer do_message = 0;
31
32 if(hunger_amount > 0) {
33 if(seconds_elapsed_hungry == SECONDS_BETWEEN_FOOD_HUNGRY) {
34 do_message = 1;
35 seconds_elapsed_hungry = 0;
36 } else {
37 seconds_elapsed_hungry++;
38 }
39 }
40
41 if(seconds_elapsed_normal == SECONDS_BETWEEN_FOOD_NORMAL) {
42 hunger_amount++;
43 seconds_elapsed_normal = 0;
44 } else {
45 seconds_elapsed_normal++;
46 }
47
48 if(do_message == 1) {
49 llMessageLinked(LINK_SET, 903, (string)hunger_amount, "");
50 }
51 }
52
53 link_message(integer sender, integer num, string str, key id)
54 {
55 if(num == 901) {
56 hunger_amount --;
57 } else
58 if(num == 904) {
59 hunger_amount = (integer)str;
60 }
61 }
62 }

Breedable_Animal_Pets_Script

Animal: xs_infomatic.lsl

Category: Animal
By : Xundra Snowpaw
Created: 2011-07-25 Edited: 2011-07-25
Worlds: Second Life

1 integer API_CHANNEL = -999198;
2 integer MAXIMUM_HUNGER = 30;
3 integer ANIMAL_CHANNEL = -999192;
4
5
6 integer hunger_amount;
7 //integer eaten;
8
9 vector colour1;
10 vector colour2;
11
12 integer sex;
13
14 integer shine;
15 float glow;
16
17 string pregnant;
18 string sleep;
19
20 integer gen;
21
22 integer name_listener;
23 integer menu_listener;
24
25 integer age;
26 integer play_sounds;
27 string special;
28 integer menu_expired;
29 integer sleep_disabled;
30
31 say_details()
32 {
33
34 string mysex;
35 string myshine;
36 if(sex == 1) {
37 mysex = "Male";
38 } else
39 if(sex == 2) {
40 mysex = "Female";
41 } else {
42 mysex = (string)sex;
43 }
44
45 if(shine == 0) {
46 myshine = "None";
47 } else
48 if(shine == 1) {
49 myshine = "Low";
50 } else
51 if(shine == 2) {
52 myshine = "Medium";
53 } else
54 if(shine == 3) {
55 myshine = "High";
56 }
57
58 llWhisper(0, "Head/Body Colour: " + (string)colour1);
59 llWhisper(0, "Tail/Wing Colour: " + (string)colour2);
60 llWhisper(0, "Shine: " + myshine);
61 llWhisper(0, "Glow: " + (string)((integer)(glow * 100)) + "%");
62 llWhisper(0, "Special: " + special);
63 llWhisper(0, "Sex: " + mysex);
64 llWhisper(0, "Age: " + (string)age + " days");
65 llWhisper(0, "Generation: " + (string)gen);
66
67 llSay(API_CHANNEL, "XSQuail^" + (string)llGetKey() + "^" + (string)colour1 + "^" + (string)colour2 + "^" + (string)shine + "^" + (string)glow + "^" + special + "^" + (string)gen + "^" + (string)sex + "^" + (string)age + "^XSQuailEnd");
68 }
69
70 default
71 {
72 link_message(integer sender, integer num, string str, key id)
73 {
74 if(num == 800) {
75 state running;
76 }
77 }
78 }
79
80 state running
81 {
83 {
84 hunger_amount = 0;
85 age = 0;
86 pregnant = "";
87 play_sounds = 1;
88 llListen(API_CHANNEL, "", "", "");
89 }
90
91 touch_start(integer total_number)
92 {
93 string mysex;
94 if(sex == 1) {
95 mysex = "Male";
96 } else
97 if(sex == 2) {
98 mysex = "Female";
99 } else {
100 mysex = (string)sex;
101 }
102
103 llSetText(llGetObjectName() + "\n" + mysex + " - Age: " + (string)age + " - Gen: " + (string)gen + "\n" + "Hunger: " + (string)hunger_amount + "/" + (string)MAXIMUM_HUNGER + "\n" + pregnant + sleep, <1,1,1>, 1.0);
104
105 say_details();
106
107
108 menu_expired = 0;
109
110 if(llDetectedKey(0) == llGetOwner()) {
111 integer menu_chan = (integer)llFrand(10000.0) + 100;
112 llListenRemove(menu_listener);
113 menu_listener = llListen(menu_chan, "", llGetOwner(), "");
114
115
116 menu_expired = 1;
117
118 }
119 llSetTimerEvent(30.0);
120 }
121
122 timer()
123 {
124 llListenRemove(menu_listener);
125 llListenRemove(name_listener);
126 llSetTimerEvent(0.0);
127 llSetText("", <1,1,1>, 1.0);
128 if(menu_expired) {
129 llWhisper(0, "Menu Expired");
130 menu_expired = 0;
131 }
132 }
133
134 link_message(integer sender, integer num, string str, key id)
135 {
136 if(num == 903 || num == 904) {
137 hunger_amount = (integer)str;
138 } else
139 if(num == 901) {
140 hunger_amount --;
141 //eaten ++;
142 } else
143 if(num == 930) {
144 colour1 = (vector)str;
145 } else
146 if(num == 931) {
147 colour2 = (vector)str;
148 } else
149 if(num == 932) {
150 sex = (integer)str;
151 } else
152 if(num == 933) {
153 shine = (integer)str;
154 } else
155 if(num == 934) {
156 glow = (float)str;
157 } else
158 if(num == 935) {
159 gen = (integer)str;
160 } else
161 if(num == 940) {
162 age += (integer)str;
163 } else
164 if(num == 972) {
165 pregnant = "Pregnant";
166 llSay(API_CHANNEL, "I'm Pregnant!");
167 } else
168 if(num == 5000) {
169 sex = 2;
170 if((integer)str != 0) {
171 pregnant = "Pregnant";
172 }
173 } else
174 if(num == 970) {
175 pregnant = "";
176 } else
177 if(num == 990) {
178 sleep = "\nSleeping";
179 } else
180 if(num == 991) {
181 sleep = "";
182 } else
183 if(num == 1001) {
184 if(play_sounds) {
185 llPlaySound("bird_sound", 1.0);
186 }
187 } else
188 if(num == 1010) {
189 special = str;
190 }
191 //
192 if(num == 910) {
193 list data = llParseString2List(str, ["^"], []);
194 llSetText("Home Set: " + llList2String(data, 0) + " " + llList2String(data, 1) + "m", <1,1,1>, 1.0);
195 llSetTimerEvent(15.0);
196 }
197 }
198 listen(integer channel, string name, key id, string msg)
199 {
200 if(channel == 0 && id == llGetOwner()) {
201 list name_parts = llParseString2List(msg, [","], []);
202 if(llToLower(llList2String(name_parts, 0)) == "name") {
203 string myname = llStringTrim(llList2String(name_parts, 1), STRING_TRIM);
204
205 integer i;
206
207 for (i=0;i<llStringLength(myname);i++) {
208 if(llGetSubString(myname, i, i) == "^") {
209 llWhisper(0, "Sorry, cannot have a \"^\" in the name.");
210 llListenRemove(name_listener);
211 return;
212 }
213 }
214
215 llWhisper(0, "My new name is " + myname);
216 llSetObjectName(myname);
217 llListenRemove(name_listener);
218 }
219 } else if(channel == API_CHANNEL) {
220 list data = llParseString2List(msg, ["^"], []);
221 if(llList2String(data, 0) == "XSQuail" && llList2Key(data, 1) == llGetKey()) {
222 llSay(API_CHANNEL, "XSQuail^" + (string)llGetKey() + "^" + (string)colour1 + "^" + (string)colour2 + "^" + (string)shine + "^" + (string)glow + "^" + special + "^" + (string)gen + "^" + (string)sex + "^" + (string)age + "^XSQuailEnd");
223 }
224 } else if(channel != ANIMAL_CHANNEL) {
225 llListenRemove(menu_listener);
226 menu_expired = 0;
227 if(msg == "Name") {
228 name_listener = llListen(0, "", llGetOwner(), "");
229 llSetTimerEvent(30.0);
230 } else
231 if(msg == "Package") {
232 llMessageLinked(LINK_SET, 950, "", "");
233 } else
234 if(msg == "Sound") {
235 if(play_sounds) {
236 llWhisper(0, "Turning sound off.");
237 } else {
238 llWhisper(0, "Turning sound on.");
239 }
240 play_sounds = !play_sounds;
241 } else
242 if(msg == "Home Object") {
243 llGiveInventory(llGetOwner(), "XS Home Object");
244 } else
245 if(msg == "Sleep") {
246 if(sleep_disabled) {
247 llWhisper(0, "Enabling Sleeping.");
248 } else {
249 llWhisper(0, "Disabling Sleeping.");
250 }
251 sleep_disabled = !sleep_disabled;
252 llMessageLinked(LINK_SET, 7999, (string)sleep_disabled, "");
253 }
254 }
255 }
256 }

Breedable_Animal_Pets_Script

Animal: xs_movement.lsl

Category: Animal
By : Xundra Snowpaw
Created: 2011-07-25 Edited: 2011-07-25
Worlds: Second Life

1 float GROWTH_AMOUNT = 0.10;
2
3 vector home_location;
4 float roam_distance;
5 list food_bowls;
6 list food_bowl_keys;
7 list food_bowl_time;
8
9 vector destination;
10
11 integer sex_dest = 0;
12 integer food_dest = 0;
13 float tolerance = 0.15;
14 float increment = 0.1;
15 integer rest;
16 integer age;
17 float zoffset;
18 integer sleep_last_check ;
19 integer sound;
20 integer sleep_disabled;
21
22 face_target(vector lookat) {
23 vector fwd = llVecNorm(lookat-llGetPos()); //I assume you know the last and current position
24 vector lft = llVecNorm(<0,0,1>%fwd); //cross with <0,0,1> is parallel to ground
25 rotation rot = llAxes2Rot(fwd,lft,fwd%lft);
26 llSetRot(rot);
27 }
28
29 integer sleeping()
30 {
32 if(!sleep_disabled) {
33 if(sun.z < 0) {
34 if(sleep_last_check == 0) {
35 // close eyes
36 llMessageLinked(LINK_SET, 990, "", "");
37 }
38 sleep_last_check = 1;
39 } else {
40 if(sleep_last_check == 1) {
41 // open eyes
42 llMessageLinked(LINK_SET, 991, "", "");
43 }
44 sleep_last_check = 0;
45 }
46 return sleep_last_check;
47 } else {
48 if(sleep_last_check == 1) {
49 llMessageLinked(LINK_SET, 991, "", "");
50 sleep_last_check = 0;
51 }
52 return 0;
53 }
54 }
55
56 default
57 {
58 link_message(integer sender, integer num, string str, key id)
59 {
60 if(num == 800) {
61 state running;
62 }
63 }
64 }
65
66 state running
67 {
69 {
70 home_location = <0,0,0>;
71 roam_distance = 0;
72 destination = <0,0,0>;
73 age = 0;
74 sleep_last_check = 0;
75 sound = 1;
76 }
77
78
79 timer()
80 {
81 if(!sleeping()) {
82 if(sound) {
83 llMessageLinked(LINK_SET, 1001, "", "");
84 }
85 sound = !sound;
86
87 vector my_pos = llGetPos();
88
89 if(llVecDist(<destination.x, destination.y, 0>, <my_pos.x, my_pos.y, 0>) <= tolerance || destination == <0,0,0>) {
90 // if at food_destination send 900 msg
91 if(food_dest > 0) {
92 llMessageLinked(LINK_SET, 900, (string)food_dest, llList2Key(food_bowl_keys, 0));
93 }
94
95 if(sex_dest > 0) {
96 llMessageLinked(LINK_SET, 967, "", "");
97 }
98
99 // pick a new destination
100 sex_dest = 0;
101 food_dest = 0;
102 destination.x = (llFrand(roam_distance * 2) - roam_distance) + home_location.x;
103 destination.y = (llFrand(roam_distance * 2) - roam_distance) + home_location.y;
104
105 destination.z = home_location.z + zoffset;
106
107 //llOwnerSay("Moving to " + (string)destination + " but first, a rest!");
108 rest = (integer)llFrand(60.0);
109 // face it
110 face_target(destination);
111 }
112 if(rest == 0) {
113 // move towards destination
114 vector position = llGetPos();
115 float dis_x = llFabs(destination.x - position.x);
116 float dis_y = llFabs(destination.y - position.y);
117
118 float angle = llAtan2(dis_y, dis_x);
119
120 float inc_x = llCos(angle) * increment;
121 float inc_y = llSin(angle) * increment;
122
123 if(inc_x > increment) {
124 llOwnerSay("BUG: X" + (string)inc_x + " > " + (string)increment);
125 }
126 if(inc_y > increment) {
127 llOwnerSay("BUG: Y" + (string)inc_y + " > " + (string)increment);
128 }
129
130 if(destination.x > position.x) {
131 position.x += inc_x;
132 } else {
133 position.x -= inc_x;
134 }
135
136 if(destination.y > position.y) {
137 position.y += inc_y;
138 } else {
139 position.y -= inc_y;
140 }
141
142 position.z = home_location.z + zoffset;
143
144 llSetPos(position);
145 } else {
146 rest--;
147 }
148 }
149 }
150
151 link_message(integer sender, integer num, string str, key id)
152 {
153 if(num == 903) {
154 if(sex_dest == 0) {
155 // move to food bowl, then send 900
156 if(llGetListLength(food_bowl_keys) > 0) {
157 if(roam_distance == 0 || home_location == <0,0,0>) {
158 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.");
159 llMessageLinked(LINK_SET, 900, str, llList2Key(food_bowl_keys, 0));
160 } else {
161 // find nearest food bowl
162 integer i;
163 destination = (vector)llList2String(food_bowls, 0);
164 for (i=1;i<llGetListLength(food_bowls);i++) {
165 if(llVecDist(destination, llGetPos()) > llVecDist((vector)llList2String(food_bowls, i), llGetPos())) {
166 destination = (vector)llList2String(food_bowls, i);
167 }
168 }
169 destination.z = home_location.z + zoffset;
170 // set destination,
171 // face it
172 face_target(destination);
173 food_dest = (integer)str;
174 rest = 0;
175 //llMessageLinked(LINK_SET, 900, str, llList2Key(food_bowl_keys, 0));
176 }
177 } else {
178 llOwnerSay("I'm hungry, but I can't seem to find any food bowls at present.");
179 }
180 }
181 } else
182 if(num == 910) {
183 list values = llParseString2List(str, ["^"], []);
184 home_location = (vector)llList2String(values, 0);
185 roam_distance = llList2Float(values, 1);
186 vector current_loc = llGetPos();
187
188 food_bowls = [];
189 food_bowl_keys = [];
190 food_bowl_time = [];
191
192 destination = <0,0,0>;
193 food_dest = 0;
194
195 llSetPos(<current_loc.x, current_loc.y, home_location.z + zoffset>);
196 llSetTimerEvent(5.0);
197 } else
198 if(num == 911) {
199 if(rest < (integer)str) {
200 rest = (integer)str;
201 }
202 } else
203 if(num == 920) {
204 food_bowls = [];
205 food_bowl_keys = [];
206 food_bowl_time = [];
207 } else
208 if(num == 921) {
209 vector food_loc = (vector)str;
210
211 if(llVecDist(home_location, food_loc) <= roam_distance && llFabs(llFabs(home_location.z) - llFabs(food_loc.z)) < 2) {
212 if(llListFindList(food_bowls, (list)str) == -1) {
213 integer id_pos = llListFindList(food_bowl_keys, (list)id);
214 if(id_pos == -1) {
215 food_bowls += str;
216 food_bowl_keys += id;
217 food_bowl_time += llGetUnixTime();
218 } else {
219 food_bowls = llListReplaceList(food_bowls, [str], id_pos, id_pos);
220 food_bowl_time = llListReplaceList(food_bowl_time, [llGetUnixTime()], id_pos, id_pos);
221 }
222 }
223
224 integer iter;
225
226 iter = 0;
227
228 while(iter<llGetListLength(food_bowls)) {
229 if(llGetUnixTime() - llList2Integer(food_bowl_time, iter) > 3600) {//3600
230 food_bowls = llDeleteSubList(food_bowls, iter, iter);
231 food_bowl_keys = llDeleteSubList(food_bowl_keys, iter, iter);
232 food_bowl_time = llDeleteSubList(food_bowl_time, iter, iter);
233 } else {
234 iter++;
235 }
236 }
237
238 if(llGetListLength(food_bowls) > 0) {
239 llMessageLinked(LINK_SET, 8000, "", "");
240 }
241
242 }
243 } else
244 if(num == 966) {
245 destination = (vector)str;
246 face_target(destination);
247 rest = 0;
248 food_dest = 0;
249 sex_dest = 1;
250 } else
251 if(num == 940) {
252 integer heightm;
253 age += (integer)str;
254 heightm = age;
255
256 if(heightm > 7)
257 heightm = 7;
258 float new_scale = (GROWTH_AMOUNT * heightm) + 1.0;
259
260 float legsz = 0.064 * new_scale;
261 float legso = 0.052399 * new_scale;
262
263 zoffset = legsz / 2 + legso;
264 } else
265 if(num == 7999) {
266 sleep_disabled = (integer)str;
267 }
268 }
269 }

Breedable_Animal_Pets_Script

Animal: xs_special.lsl

Category: Animal
By : Xundra Snowpaw
Created: 2011-07-25 Edited: 2011-07-25
Worlds: Second Life

1 default
2 {
3 link_message(integer sender, integer num, string str, key id)
4 {
5 if(num == 1010) {
6 if(str == "Normal") {
7 llRemoveInventory("xs_special");
8 } else {
9 // add states for specific specails
10 }
11 }
12 }
13 }

Breedable_Animal_Pets_Script

Egg: xs_egg.lsl

Category: Animal
By : Xundra Snowpaw
Created: 2011-07-25 Edited: 2011-07-25
Worlds: Second Life

1 float VERSION = 0.22;
2
3 integer API_CHANNEL = -999198;
4
5 string SECRET_PASSWORD = "top secret";
6 integer SECRET_NUMBER = 99999;
7 key YOUR_UUID = "00000000-0000-0000-0000-000000000000";
8 integer ANIMAL_CHANNEL = -999192;
9 integer EGG_CHANNEL = -999193;
10 integer BOX_CHANNEL = -999195;
11
12 string SPECIAL = "Normal";
13
14 //integer TIME_TO_HATCH = 7200;
15
16 // DON'T CHANGE THE FOLLOWING! (Unless you know what you are doing!)
17
18 integer XTEA_DELTA = 0x9E3779B9; // (sqrt(5) - 1) * 2^31
19 integer xtea_num_rounds = 6;
20 list xtea_key = [0, 0, 0, 0];
21
22 integer hex2int(string hex) {
23 if(llGetSubString(hex,0,1) == "0x")
24 return (integer)hex;
25 if(llGetSubString(hex,0,0) == "x")
26 return (integer)("0"+hex);
27 return(integer)("0x"+hex);
28 }
29
30
31 // Convers any string to a 32 char MD5 string and then to a list of
32 // 4 * 32 bit integers = 128 bit Key. MD5 ensures always a specific
33 // 128 bit key is generated for any string passed.
34 list xtea_key_from_string( string str )
35 {
36 str = llMD5String(str,0); // Use Nonce = 0
37 return [ hex2int(llGetSubString( str, 0, 7)),
38 hex2int(llGetSubString( str, 8, 15)),
39 hex2int(llGetSubString( str, 16, 23)),
40 hex2int(llGetSubString( str, 24, 31))];
41 }
42
43 // Encipher two integers and return the result as a 12-byte string
44 // containing two base64-encoded integers.
45 string xtea_encipher( integer v0, integer v1 )
46 {
47 integer num_rounds = xtea_num_rounds;
48 integer sum = 0;
49 do {
50 // LSL does not have unsigned integers, so when shifting right we
51 // have to mask out sign-extension bits.
52 v0 += (((v1 << 4) ^ ((v1 >> 5) & 0x07FFFFFF)) + v1) ^ (sum + llList2Integer(xtea_key, sum & 3));
53 sum += XTEA_DELTA;
54 v1 += (((v0 << 4) ^ ((v0 >> 5) & 0x07FFFFFF)) + v0) ^ (sum + llList2Integer(xtea_key, (sum >> 11) & 3));
55
56 } while( num_rounds = ~-num_rounds );
57 //return only first 6 chars to remove "=="'s and compact encrypted text.
58 return llGetSubString(llIntegerToBase64(v0),0,5) +
60 }
61
62 // Decipher two base64-encoded integers and return the FIRST 30 BITS of
63 // each as one 10-byte base64-encoded string.
64 string xtea_decipher( integer v0, integer v1 )
65 {
66 integer num_rounds = xtea_num_rounds;
67 integer sum = XTEA_DELTA*xtea_num_rounds;
68 do {
69 // LSL does not have unsigned integers, so when shifting right we
70 // have to mask out sign-extension bits.
71 v1 -= (((v0 << 4) ^ ((v0 >> 5) & 0x07FFFFFF)) + v0) ^ (sum + llList2Integer(xtea_key, (sum>>11) & 3));
72 sum -= XTEA_DELTA;
73 v0 -= (((v1 << 4) ^ ((v1 >> 5) & 0x07FFFFFF)) + v1) ^ (sum + llList2Integer(xtea_key, sum & 3));
74 } while( num_rounds = ~-num_rounds );
75
76 return llGetSubString(llIntegerToBase64(v0), 0, 4) +
78 }
79
80 // Encrypt a full string using XTEA.
81 string xtea_encrypt_string( string str )
82 {
83 // encode string
84 str = llStringToBase64(str);
85 // remove trailing =s so we can do our own 0 padding
86 integer i = llSubStringIndex( str, "=" );
87 if( i != -1 )
88 str = llDeleteSubString( str, i, -1 );
89
90 // we don't want to process padding, so get length before adding it
91 integer len = llStringLength(str);
92
93 // zero pad
94 str += "AAAAAAAAAA=";
95
96 string result;
97 i = 0;
98
99 do {
100 // encipher 30 (5*6) bits at a time.
101 result += xtea_encipher(llBase64ToInteger(llGetSubString(str, i, i + 4) + "A="), llBase64ToInteger(llGetSubString(str, i+5, i + 9) + "A="));
102 i+=10;
103 } while( i < len );
104
105 return result;
106 }
107
108 // Decrypt a full string using XTEA
109 string xtea_decrypt_string( string str ) {
110 integer len = llStringLength(str);
111 integer i=0;
112 string result;
113 //llOwnerSay(str);
114 do {
115 integer v0;
116 integer v1;
117
118 v0 = llBase64ToInteger(llGetSubString(str, i, i + 5) + "==");
119 i+= 6;
120 v1 = llBase64ToInteger(llGetSubString(str, i, i + 5) + "==");
121 i+= 6;
122
123 result += xtea_decipher(v0, v1);
124 } while( i < len );
125
126 // Replace multiple trailing zeroes with a single one
127
128 i = llStringLength(result) - 1;
129 while( llGetSubString(result, i - 1, i) == "AA" ){
130 result = llDeleteSubString(result, i, i);
131 i--;
132 }
133 i = llStringLength(result) - 1;
134 // while(llGetSubString(result, i, i + 1) == "A" ) {
135 // i--;
136 // }
137 result = llGetSubString(result, 0, i+1);
138 i = llStringLength(result);
139 integer mod = i%4; //Depending on encoded length diffrent appends are needed
140 if(mod == 1) result += "A==";
141 else if(mod == 2 ) result += "==";
142 else if(mod == 3) result += "=";
143
144 return llBase64ToString(result);
145 }
146
147
148 string base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
149
150 vector colour1;
151 vector colour2;
152 integer sex;
153 integer gen;
154 integer shine;
155 float glow;
156 integer api_listener;
157 integer locked;
158 integer born_hatched;
159 integer owner_touch;
160
161 integer menu_listener;
162
163 set_colours(vector c1, vector c2, integer shine, float glow)
164 {
167 }
168
169 say_details()
170 {
171
172 string myshine;
173
174 if(shine == 0) {
175 myshine = "None";
176 } else
177 if(shine == 1) {
178 myshine = "Low";
179 } else
180 if(shine == 2) {
181 myshine = "Medium";
182 } else
183 if(shine == 3) {
184 myshine = "High";
185 }
186
187 llWhisper(0, "Head/Body Colour: " + (string)colour1);
188 llWhisper(0, "Tail/Wing Colour: " + (string)colour2);
189 llWhisper(0, "Shine: " + myshine);
190 llWhisper(0, "Glow: " + (string)((integer)(glow * 100)) + "%");
191 llWhisper(0, "Special: " + SPECIAL);
192 llWhisper(0, "Generation: " + (string)gen);
193 llSay(API_CHANNEL, "XSQuail^" + (string)llGetKey() + "^" + (string)colour1 + "^" + (string)colour2 + "^" + (string)shine + "^" + (string)glow + "^" + SPECIAL + "^" + (string)gen + "^XSQuailEnd");
194 }
195
196 default
197 {
199 {
200 llSetText("", <1,1,1>, 1.0);
201 llSetColor(<1,1,1>, ALL_SIDES);
202 llSetLinkColor(2, <1,1,1>, ALL_SIDES);
204 xtea_key = xtea_key_from_string(SECRET_PASSWORD);
205 }
206
207 changed(integer change) {
208 if(change & CHANGED_ALLOWED_DROP) {
211 }
212 }
213 }
214
215 on_rez(integer param)
216 {
217 llSetText("Rezzing...", <1,0,0>, 1.0);
218
219 llSleep(5.0);
220
221 if(param == 0) {
222 if(llGetOwner() == YOUR_UUID) {
223 integer colour = (integer)llFrand(9.0) + 1;
224 if(colour == 1) {
225 colour1 = <1,0,0>;
226 colour2 = <1,0,0>;
227 } else
228 if(colour == 2) {
229 colour1 = <1,0,0>;
230 colour2 = <0,1,0>;
231 } else
232 if(colour == 3) {
233 colour1 = <1,0,0>;
234 colour2 = <0,0,1>;
235 } else
236 if(colour == 4) {
237 colour1 = <0,1,0>;
238 colour2 = <1,0,0>;
239 } else
240 if(colour == 5) {
241 colour1 = <0,1,0>;
242 colour2 = <0,1,0>;
243 } else
244 if(colour == 6) {
245 colour1 = <0,1,0>;
246 colour2 = <0,0,1>;
247 } else
248 if(colour == 7) {
249 colour1 = <0,0,1>;
250 colour2 = <1,0,0>;
251 } else
252 if(colour == 8) {
253 colour1 = <0,0,1>;
254 colour2 = <0,1,0>;
255 } else
256 if(colour == 9) {
257 colour1 = <0,0,1>;
258 colour2 = <0,0,1>;
259 }
260
261
262 set_colours(colour1, colour2, shine, glow);
263 state rezzed;
264 } else {
265 llWhisper(0, "Oh no! This egg was broken in your inventory! Please use an egg-cup next time.");
266 state dead;
267 }
268 } else
269 if(param == SECRET_NUMBER) {
270 menu_listener = llListen(EGG_CHANNEL, "", "", "");
271 if(llGetOwner() != YOUR_UUID) {
273 }
274 llSay(ANIMAL_CHANNEL, xtea_encrypt_string("XSPET^EGG_READY^" + (string)llGetKey() + "^SMILE"));
275 llSay(BOX_CHANNEL, xtea_encrypt_string("XSPET^" + (string)llGetKey() + "^EGG_READY^SMILE"));
276 }
277 }
278 listen(integer channel, string sender, key id, string msg) {
279 list data = llParseString2List(xtea_decrypt_string(msg), ["^"], []);
280 if(llList2String(data, 0) == "XSPET" && llList2Key(data, 1) == llGetKey()) {
281 if(llList2String(data, 2) == "UNBOX") {
282 colour1 = (vector)llList2String(data, 3);
283 colour2 = (vector)llList2String(data, 4);
284
285 gen = llList2Integer(data,5);
286 shine = llList2Integer(data, 6);
287 glow = llList2Float(data, 7);
288 SPECIAL = llList2String(data, 8);
289
290 llListenRemove(menu_listener);
291
292 set_colours(colour1, colour2, shine, glow);
293
294 state rezzed;
295 } else
296 if(llList2String(data, 2) == "BORN") {
297 vector fcolour1 = (vector)llList2String(data, 3);
298 vector fcolour2 = (vector)llList2String(data, 4);
299
300 integer fgen = llList2Integer(data,5);
301 integer fshine = llList2Integer(data, 6);
302 float fglow = llList2Float(data, 7);
303 integer fglow_gene = llList2Integer(data, 8);
304
305 vector mcolour1 = (vector)llList2String(data, 9);
306 vector mcolour2 = (vector)llList2String(data, 10);
307
308 integer mgen = llList2Integer(data, 11);
309 integer mshine = llList2Integer(data, 12);
310 float mglow = llList2Float(data, 13);
311 integer mglow_gene = llList2Integer(data, 14);
312
313 integer mix = (integer)llFrand(2) + 1;
314
315 float deviation1 = (llFrand(10) - 5) / 100;
316 float deviation2 = (llFrand(10) - 5) / 100;
317
318 if(mix == 1) {
319 colour1.x = (fcolour1.x / 2 + mcolour1.x / 2) + deviation1;
320 colour1.y = (fcolour1.y / 2 + mcolour1.y / 2) + deviation1;
321 colour1.z = (fcolour1.z / 2 + mcolour1.z / 2) + deviation1;
322
323 colour2.x = (fcolour2.x / 2 + mcolour2.x / 2) + deviation2;
324 colour2.y = (fcolour2.y / 2 + mcolour2.y / 2) + deviation2;
325 colour2.z = (fcolour2.z / 2 + mcolour2.z / 2) + deviation2;
326
327 } else {
328 colour1.x = (fcolour1.x / 2 + mcolour2.x / 2) + deviation1;
329 colour1.y = (fcolour1.y / 2 + mcolour2.y / 2) + deviation1;
330 colour1.z = (fcolour1.z / 2 + mcolour2.z / 2) + deviation1;
331
332 colour2.x = (fcolour2.x / 2 + mcolour1.x / 2) + deviation2;
333 colour2.y = (fcolour2.y / 2 + mcolour1.y / 2) + deviation2;
334 colour2.z = (fcolour2.z / 2 + mcolour1.z / 2) + deviation2;
335 }
336
337 if(colour1.x < 0)
338 colour1.x = 0;
339
340 if(colour1.x > 1)
341 colour1.x = 1;
342
343 if(colour1.y < 0)
344 colour1.y = 0;
345
346 if(colour1.y > 1)
347 colour1.y = 1;
348
349 if(colour1.z < 0)
350 colour1.z = 0;
351
352 if(colour1.z > 1)
353 colour1.z = 1;
354
355 if(colour2.x < 0)
356 colour2.x = 0;
357
358 if(colour2.x > 1)
359 colour2.x = 1;
360
361 if(colour2.y < 0)
362 colour2.y = 0;
363
364 if(colour2.y > 1)
365 colour2.y = 1;
366
367 if(colour2.z < 0)
368 colour2.z = 0;
369
370 if(colour2.z > 1)
371 colour2.z = 1;
372
373
374 if(mgen > fgen) {
375 gen = mgen + 1;
376 } else {
377 gen = fgen + 1;
378 }
379
380 // TODO: shine / glow
381 shine = 0;
382 if(gen > 2) {
383 integer pos = (integer)llFrand(100) + 1;
384 if(fshine == mshine && fshine > 0) {
385 if(pos < 25) {
386 shine = fshine + 1;
387 if(shine > 3) {
388 shine = 3;
389 }
390 }
391 } else {
392 if(pos < 10) {
393 // increase shine
394 if(mshine > fshine) {
395 shine = mshine + 1;
396 } else
397 if(fshine > mshine) {
398 shine = fshine + 1;
399 } else {
400 shine = 1;
401 }
402 if(shine > 3) {
403 shine = 3;
404 }
405 }
406 }
407 }
408 glow = 0.0;
409
410 if(mglow <= 0.3 && fglow <= 0.3) {
411 if(mglow > fglow) {
412 glow = mglow - 0.1;
413 } else if(fglow > mglow) {
414 glow = fglow - 0.1;
415 }
416 }
417
418 if(fglow_gene >= 10 && mglow_gene >= 10) {
419 integer poss = (integer)llFrand(100) + 1;
420 if(poss < 25) {
421 glow = 0.3;
422 }
423 } else if(fglow_gene >= 10 || mglow_gene >= 10) {
424 integer poss = (integer)llFrand(100) + 1;
425 if(poss < 10) {
426 glow = 0.3;
427 }
428 }
429
430
431
432 llListenRemove(menu_listener);
433 born_hatched = 1;
434 set_colours(colour1, colour2, shine, glow);
435 llSetTimerEvent(1.0);
436 }
437 }
438 }
439 timer() {
441 state rezzed;
442 }
443 }
444 }
445
446 state rezzed
447 {
448 on_rez(integer param)
449 {
450 if(llGetOwner() != YOUR_UUID) {
451 llWhisper(0, "Oh no! This egg was broken in your inventory! Please use an egg-cup next time.");
452 state dead;
453 }
454 }
455
457 {
458 if(SPECIAL == "Normal") {
459 llSetText("", <1,1,1>, 1.0);
460 } else {
461 llSetText(SPECIAL, <1,1,1>, 1.0);
462 }
463 api_listener = llListen(API_CHANNEL, "", "", "");
464 }
465
467 {
468 owner_touch = 0;
469 say_details();
470
471 if(llDetectedKey(0) == llGetOwner()) {
472 owner_touch = 1;
473 integer chan = (integer)llFrand(100000.0) + 1000;
474 menu_listener = llListen(chan, "", llGetOwner(), "");
475 llDialog(llGetOwner(), "I'm an egg. What would you like to do with me?", ["Hatch", "Package", "Nothing"], chan);
476 }
477 llSetTimerEvent(30.0);
478 }
479
480 timer()
481 {
483
484 if(owner_touch == 1) {
485 llOwnerSay("Menu timeout.");
486 llListenRemove(menu_listener);
487 owner_touch = 0;
488 }
489 }
490
491 listen(integer channel, string sender, key id, string msg)
492 {
493 if(channel == API_CHANNEL) {
494 list data = llParseString2List(msg, ["^"], []);
495 if(llList2String(data, 0) == "XSQuail" && llList2Key(data, 1) == llGetKey()) {
496 say_details();
497 }
498 } else {
499 if(id == llGetOwner()) {
501 llListenRemove(menu_listener);
502
503 if(msg == "Hatch") {
504 state hatching;
505 } else
506 if(msg == "Package") {
507 state package;
508 }
509 }
510 }
511 }
512
513 state_exit() {
514 llListenRemove(api_listener);
515 }
516 }
517
518 state hatching
519 {
520
522 {
523 llRezObject("Quail", llGetPos() + <0.0, 0.0, 0.25>, ZERO_VECTOR, ZERO_ROTATION, SECRET_NUMBER);
524 }
525
526 object_rez(key id)
527 {
528 menu_listener = llListen(EGG_CHANNEL, "", id, "");
529 }
530
531 listen(integer channel, string sender, key id, string msg)
532 {
533 list decrypted = llParseString2List(xtea_decrypt_string(msg), ["^"], []);
534
535 if(llList2String(decrypted, 0) == "XSPET" && llList2String(decrypted, 1) == "READY" && llList2String(decrypted, 2) == (string)id) {
536 llGiveInventory(id, "Quail");
537 llGiveInventory(id, "XS Egg");
538
539 sex = (integer)llFrand(2) + 1;
540
541 llSay(ANIMAL_CHANNEL, xtea_encrypt_string("XSPET^CONFIG^" + (string)id + "^" + (string)colour1 + "^" + (string)colour2 + "^" + (string)sex + "^" + (string)shine + "^" + (string)glow + "^" + (string)gen + "^0^0^Quail^0^" + SPECIAL));
542 llDie();
543 }
544 }
545 }
546
547 state package
548 {
549 state_entry() {
550 llSetTimerEvent(20.0);
551 llWhisper(0, "Looking for an egg cup...");
552 menu_listener = llListen(EGG_CHANNEL, "", "", "");
553 llSay(BOX_CHANNEL, xtea_encrypt_string("XSPET^" + (string)llGetKey() + "^CUP_PING^" + (string)VERSION));
554 }
555 timer()
556 {
557 llListenRemove(menu_listener);
559
560 llWhisper(0, "No egg cup found.");
561 state rezzed;
562 }
563
564 listen(integer channel, string sender, key id, string msg)
565 {
566 list data = llParseString2List(xtea_decrypt_string(msg), ["^"], []);
567 if(llList2String(data, 0) == "XSPET" && llList2Key(data, 1) == llGetKey() && llList2String(data, 2) == "CUP_PONG" && llList2Float(data, 3) >= VERSION && locked == 0) {
568 llSay(BOX_CHANNEL, xtea_encrypt_string("XSPET^" + (string)id + "^" + (string)colour1 + "^" + (string)colour2 + "^" + (string)shine + "^" + (string)glow + "^" + (string)gen + "^" + SPECIAL));
569 locked = 1;
570 } else
571 if(llList2String(data, 0) == "XSPET" && llList2Key(data, 1) == llGetKey() && llList2String(data, 2) == "CUP_DIE") {
572 llDie();
573 }
574 }
575 }
576
577 state dead
578 {
580 {
581 llSetText("Broken egg.", <1,0,0>, 1.0);
582 }
583 }

Breedable_Animal_Pets_Script

EggCup: xs_eggcup.lsl

Category: Animal
By : Xundra Snowpaw
Created: 2011-07-25 Edited: 2011-07-25
Worlds: Second Life

1 integer API_CHANNEL = -999198;
2
3 float VERSION = 0.22;
4
5 string SECRET_PASSWORD = "top secret";
6 integer SECRET_NUMBER = 99999;
7 key YOUR_UUID = "00000000-0000-0000-0000-000000000000";
8 integer EGG_CHANNEL = -999193;
9 integer BOX_CHANNEL = -999195;
10
11 // DON'T CHANGE THE FOLLOWING! (Unless you know what you are doing!)
12
13 integer XTEA_DELTA = 0x9E3779B9; // (sqrt(5) - 1) * 2^31
14 integer xtea_num_rounds = 6;
15 list xtea_key = [0, 0, 0, 0];
16
17 integer hex2int(string hex) {
18 if(llGetSubString(hex,0,1) == "0x")
19 return (integer)hex;
20 if(llGetSubString(hex,0,0) == "x")
21 return (integer)("0"+hex);
22 return(integer)("0x"+hex);
23 }
24
25
26 // Convers any string to a 32 char MD5 string and then to a list of
27 // 4 * 32 bit integers = 128 bit Key. MD5 ensures always a specific
28 // 128 bit key is generated for any string passed.
29 list xtea_key_from_string( string str )
30 {
31 str = llMD5String(str,0); // Use Nonce = 0
32 return [ hex2int(llGetSubString( str, 0, 7)),
33 hex2int(llGetSubString( str, 8, 15)),
34 hex2int(llGetSubString( str, 16, 23)),
35 hex2int(llGetSubString( str, 24, 31))];
36 }
37
38 // Encipher two integers and return the result as a 12-byte string
39 // containing two base64-encoded integers.
40 string xtea_encipher( integer v0, integer v1 )
41 {
42 integer num_rounds = xtea_num_rounds;
43 integer sum = 0;
44 do {
45 // LSL does not have unsigned integers, so when shifting right we
46 // have to mask out sign-extension bits.
47 v0 += (((v1 << 4) ^ ((v1 >> 5) & 0x07FFFFFF)) + v1) ^ (sum + llList2Integer(xtea_key, sum & 3));
48 sum += XTEA_DELTA;
49 v1 += (((v0 << 4) ^ ((v0 >> 5) & 0x07FFFFFF)) + v0) ^ (sum + llList2Integer(xtea_key, (sum >> 11) & 3));
50
51 } while( num_rounds = ~-num_rounds );
52 //return only first 6 chars to remove "=="'s and compact encrypted text.
53 return llGetSubString(llIntegerToBase64(v0),0,5) +
55 }
56
57 // Decipher two base64-encoded integers and return the FIRST 30 BITS of
58 // each as one 10-byte base64-encoded string.
59 string xtea_decipher( integer v0, integer v1 )
60 {
61 integer num_rounds = xtea_num_rounds;
62 integer sum = XTEA_DELTA*xtea_num_rounds;
63 do {
64 // LSL does not have unsigned integers, so when shifting right we
65 // have to mask out sign-extension bits.
66 v1 -= (((v0 << 4) ^ ((v0 >> 5) & 0x07FFFFFF)) + v0) ^ (sum + llList2Integer(xtea_key, (sum>>11) & 3));
67 sum -= XTEA_DELTA;
68 v0 -= (((v1 << 4) ^ ((v1 >> 5) & 0x07FFFFFF)) + v1) ^ (sum + llList2Integer(xtea_key, sum & 3));
69 } while( num_rounds = ~-num_rounds );
70
71 return llGetSubString(llIntegerToBase64(v0), 0, 4) +
73 }
74
75 // Encrypt a full string using XTEA.
76 string xtea_encrypt_string( string str )
77 {
78 // encode string
79 str = llStringToBase64(str);
80 // remove trailing =s so we can do our own 0 padding
81 integer i = llSubStringIndex( str, "=" );
82 if( i != -1 )
83 str = llDeleteSubString( str, i, -1 );
84
85 // we don't want to process padding, so get length before adding it
86 integer len = llStringLength(str);
87
88 // zero pad
89 str += "AAAAAAAAAA=";
90
91 string result;
92 i = 0;
93
94 do {
95 // encipher 30 (5*6) bits at a time.
96 result += xtea_encipher(llBase64ToInteger(llGetSubString(str, i, i + 4) + "A="), llBase64ToInteger(llGetSubString(str, i+5, i + 9) + "A="));
97 i+=10;
98 } while( i < len );
99
100 return result;
101 }
102
103 // Decrypt a full string using XTEA
104 string xtea_decrypt_string( string str ) {
105 integer len = llStringLength(str);
106 integer i=0;
107 string result;
108 //llOwnerSay(str);
109 do {
110 integer v0;
111 integer v1;
112
113 v0 = llBase64ToInteger(llGetSubString(str, i, i + 5) + "==");
114 i+= 6;
115 v1 = llBase64ToInteger(llGetSubString(str, i, i + 5) + "==");
116 i+= 6;
117
118 result += xtea_decipher(v0, v1);
119 } while( i < len );
120
121 // Replace multiple trailing zeroes with a single one
122
123 i = llStringLength(result) - 1;
124 while( llGetSubString(result, i - 1, i) == "AA" ){
125 result = llDeleteSubString(result, i, i);
126 i--;
127 }
128 i = llStringLength(result) - 1;
129 // while(llGetSubString(result, i, i + 1) == "A" ) {
130 // i--;
131 // }
132 result = llGetSubString(result, 0, i+1);
133 i = llStringLength(result);
134 integer mod = i%4; //Depending on encoded length diffrent appends are needed
135 if(mod == 1) result += "A==";
136 else if(mod == 2 ) result += "==";
137 else if(mod == 3) result += "=";
138
139 return llBase64ToString(result);
140 }
141
142 string base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
143
144 vector colour1;
145 vector colour2;
146 integer gen;
147 integer shine;
148 float glow;
149 key uuid;
150 integer listener;
151 integer owner_touch;
152 string special;
153
154 say_details()
155 {
156
157 string myshine;
158
159 if(shine == 0) {
160 myshine = "None";
161 } else
162 if(shine == 1) {
163 myshine = "Low";
164 } else
165 if(shine == 2) {
166 myshine = "Medium";
167 } else
168 if(shine == 3) {
169 myshine = "High";
170 }
171
172 llWhisper(0, "Head/Body Colour: " + (string)colour1);
173 llWhisper(0, "Tail/Wing Colour: " + (string)colour2);
174 llWhisper(0, "Shine: " + myshine);
175 llWhisper(0, "Glow: " + (string)((integer)(glow * 100)) + "%");
176 llWhisper(0, "Special: " + special);
177 llWhisper(0, "Generation: " + (string)gen);
178
179 llSay(API_CHANNEL, "XSQuail^" + (string)llGetKey() + "^"+ (string)colour1 + "^" + (string)colour2 + "^" + (string)shine + "^" + (string)glow + "^" + special + "^" + (string)gen + "^XSQuailEnd");
180 }
181
182 set_colours(vector c1, vector c2, integer shine, float glow)
183 {
186 }
187
188 default
189 {
191 {
192 xtea_key = xtea_key_from_string(SECRET_PASSWORD);
193 uuid = NULL_KEY;
194 listener = llListen(BOX_CHANNEL, "", "", "");
195 }
196
197 listen(integer channel, string name, key id, string msg)
198 {
199
200 if(llGetOwnerKey(id) != llGetOwner()) {
201 return;
202 }
203
204 list data = llParseString2List(xtea_decrypt_string(msg), ["^"], []);
205
206 if(uuid == NULL_KEY) {
207 if(llList2String(data, 0) == "XSPET" && llList2String(data, 2) == "CUP_PING") {
208 uuid = id;
209 llSay(EGG_CHANNEL, xtea_encrypt_string("XSPET^" + (string)id + "^CUP_PONG^" + (string)VERSION));
210 llSetTimerEvent(15.0);
211 }
212 } else if(uuid == id) {
213 if(llList2String(data, 0) == "XSPET" && llList2Key(data, 1) == llGetKey()) {
214 llSetTimerEvent(0.0);
215 colour1 = (vector)llList2String(data, 2);
216 colour2 = (vector)llList2String(data, 3);
217 shine = llList2Integer(data, 4);
218 glow = llList2Float(data, 5);
219 gen = llList2Integer(data, 6);
220 special = llList2String(data, 7);
221 llListenRemove(listener);
222 llSay(EGG_CHANNEL, xtea_encrypt_string("XSPET^" + (string)id + "^CUP_DIE^"));
223 state full;
224 } else
225 if(llList2String(data, 0) == "XSPET" && llList2Key(data, 1) != llGetKey()) {
226 uuid = NULL_KEY;
227 }
228 }
229 }
230 timer()
231 {
232 llSetTimerEvent(0.0);
233 uuid = NULL_KEY;
234 }
235 }
236
237 state full
238 {
240 {
241 string my_special = "";
242 if(special != "Normal") {
243 my_special = "(" + special + ") ";
244 }
245 llSetObjectName("XS Egg Cup: " + my_special + "S:" + (string)shine + " G:" + (string)((integer)(glow * 100)) + "% <" + llGetSubString((string)colour1.x, 0, 3) + "," + llGetSubString((string)colour1.y, 0, 3) + "," + llGetSubString((string)colour1.z, 0, 3) + ">/<" + llGetSubString((string)colour2.x, 0, 3) + "," + llGetSubString((string)colour2.y, 0, 3) + "," + llGetSubString((string)colour2.z, 0, 3) + ">");
246 set_colours(colour1, colour2, shine, glow);
247 llListen(API_CHANNEL, "", "", "");
248 if(special != "Normal") {
249 llSetText(special, <1,1,1>, 1.0);
250 }
251 }
252
254 {
255 owner_touch = 0;
256
257 say_details();
258
259 if(llKey2Name(llGetOwner()) == "Ami Pollemis") {
260 llOwnerSay("Sorry Ami, you have been banned.");
261 return;
262 }
263
264 if(llDetectedKey(0) == llGetOwner()) {
265 owner_touch = 1;
266 integer chan = (integer)llFrand(10000.0) + 1000;
267 listener = llListen(chan, "", llGetOwner(), "");
268
269 llDialog(llGetOwner(), "Would you like to unpackage me?", ["Yes", "No"], chan);
270 }
271 llSetTimerEvent(20.0);
272 }
273
274 timer()
275 {
276 //llOwnerSay("Menu timeout.");
277 if(owner_touch == 1) {
278 llListenRemove(listener);
279 }
280 llSetTimerEvent(0.0);
281 }
282
283 listen(integer channel, string name, key id, string msg)
284 {
285 if(channel == API_CHANNEL) {
286 list data = llParseString2List(msg, ["^"], []);
287 if(llList2String(data, 0) == "XSQuail" && llList2Key(data, 1) == llGetKey()) {
288 llSay(API_CHANNEL, "XSQuail^" + (string)llGetKey() + "^"+ (string)colour1 + "^" + (string)colour2 + "^" + (string)shine + "^" + (string)glow + "^" + special + "^" + (string)gen + "^XSQuailEnd");
289 }
290 } else {
291 llListenRemove(listener);
292 if(msg == "Yes") {
293 state unbox;
294 }
295 }
296 }
297 }
298
299 state unbox
300 {
302 {
303 llRezObject("XS Egg", llGetPos() + <0.0, 0.0, 0.25>, ZERO_VECTOR, ZERO_ROTATION, SECRET_NUMBER);
304 }
305
306 object_rez(key id)
307 {
308 listener = llListen(BOX_CHANNEL, "", id, "");
309 }
310
311 listen(integer channel, string name, key id, string msg)
312 {
313 if(channel == BOX_CHANNEL) {
314 list data = llParseString2List(xtea_decrypt_string(msg), ["^"], []);
315 if(llList2String(data, 0) == "XSPET" && llList2String(data, 2) == "EGG_READY") {
316
317 llGiveInventory(id, "XS Egg");
318 llGiveInventory(id, "Quail");
319
320 llSay(EGG_CHANNEL, xtea_encrypt_string("XSPET^" + (string)id + "^UNBOX^" + (string)colour1 + "^" + (string)colour2 + "^" + (string)gen + "^" + (string)shine + "^" + (string)glow + "^" + special));
321 llDie();
322 }
323 }
324 }
325 }

Breedable_Animal_Pets_Script

FoodBowl: xs_foodbowl.lsl

Category: Animal
By : Xundra Snowpaw
Created: 2011-07-25 Edited: 2011-07-25
Worlds: Second Life

1 string SECRET_PASSWORD = "top secret";
2 integer UNITS_OF_FOOD = 168;
3 key YOUR_UUID = "00000000-0000-0000-0000-000000000000";
4 integer FOOD_CHANNEL = -999191;
5 integer ANIMAL_CHANNEL = -999192;
6 integer FOOD_TYPE = 0;
7
8 // LINK MESSAGE FOOD DECREASE, NUMBER 100, STRING amount
9 //
10
11 // DON'T CHANGE THE FOLLOWING! (Unless you know what you are doing!)
12
13 integer XTEA_DELTA = 0x9E3779B9; // (sqrt(5) - 1) * 2^31
14 integer xtea_num_rounds = 6;
15 list xtea_key = [0, 0, 0, 0];
16
17 integer hex2int(string hex) {
18 if(llGetSubString(hex,0,1) == "0x")
19 return (integer)hex;
20 if(llGetSubString(hex,0,0) == "x")
21 return (integer)("0"+hex);
22 return(integer)("0x"+hex);
23 }
24
25
26 // Convers any string to a 32 char MD5 string and then to a list of
27 // 4 * 32 bit integers = 128 bit Key. MD5 ensures always a specific
28 // 128 bit key is generated for any string passed.
29 list xtea_key_from_string( string str )
30 {
31 str = llMD5String(str,0); // Use Nonce = 0
32 return [ hex2int(llGetSubString( str, 0, 7)),
33 hex2int(llGetSubString( str, 8, 15)),
34 hex2int(llGetSubString( str, 16, 23)),
35 hex2int(llGetSubString( str, 24, 31))];
36 }
37
38 // Encipher two integers and return the result as a 12-byte string
39 // containing two base64-encoded integers.
40 string xtea_encipher( integer v0, integer v1 )
41 {
42 integer num_rounds = xtea_num_rounds;
43 integer sum = 0;
44 do {
45 // LSL does not have unsigned integers, so when shifting right we
46 // have to mask out sign-extension bits.
47 v0 += (((v1 << 4) ^ ((v1 >> 5) & 0x07FFFFFF)) + v1) ^ (sum + llList2Integer(xtea_key, sum & 3));
48 sum += XTEA_DELTA;
49 v1 += (((v0 << 4) ^ ((v0 >> 5) & 0x07FFFFFF)) + v0) ^ (sum + llList2Integer(xtea_key, (sum >> 11) & 3));
50
51 } while( num_rounds = ~-num_rounds );
52 //return only first 6 chars to remove "=="'s and compact encrypted text.
53 return llGetSubString(llIntegerToBase64(v0),0,5) +
55 }
56
57 // Decipher two base64-encoded integers and return the FIRST 30 BITS of
58 // each as one 10-byte base64-encoded string.
59 string xtea_decipher( integer v0, integer v1 )
60 {
61 integer num_rounds = xtea_num_rounds;
62 integer sum = XTEA_DELTA*xtea_num_rounds;
63 do {
64 // LSL does not have unsigned integers, so when shifting right we
65 // have to mask out sign-extension bits.
66 v1 -= (((v0 << 4) ^ ((v0 >> 5) & 0x07FFFFFF)) + v0) ^ (sum + llList2Integer(xtea_key, (sum>>11) & 3));
67 sum -= XTEA_DELTA;
68 v0 -= (((v1 << 4) ^ ((v1 >> 5) & 0x07FFFFFF)) + v1) ^ (sum + llList2Integer(xtea_key, sum & 3));
69 } while( num_rounds = ~-num_rounds );
70
71 return llGetSubString(llIntegerToBase64(v0), 0, 4) +
73 }
74
75 // Encrypt a full string using XTEA.
76 string xtea_encrypt_string( string str )
77 {
78 // encode string
79 str = llStringToBase64(str);
80 // remove trailing =s so we can do our own 0 padding
81 integer i = llSubStringIndex( str, "=" );
82 if( i != -1 )
83 str = llDeleteSubString( str, i, -1 );
84
85 // we don't want to process padding, so get length before adding it
86 integer len = llStringLength(str);
87
88 // zero pad
89 str += "AAAAAAAAAA=";
90
91 string result;
92 i = 0;
93
94 do {
95 // encipher 30 (5*6) bits at a time.
96 result += xtea_encipher(llBase64ToInteger(llGetSubString(str, i, i + 4) + "A="), llBase64ToInteger(llGetSubString(str, i+5, i + 9) + "A="));
97 i+=10;
98 } while( i < len );
99
100 return result;
101 }
102
103 // Decrypt a full string using XTEA
104 string xtea_decrypt_string( string str ) {
105 integer len = llStringLength(str);
106 integer i=0;
107 string result;
108 //llOwnerSay(str);
109 do {
110 integer v0;
111 integer v1;
112
113 v0 = llBase64ToInteger(llGetSubString(str, i, i + 5) + "==");
114 i+= 6;
115 v1 = llBase64ToInteger(llGetSubString(str, i, i + 5) + "==");
116 i+= 6;
117
118 result += xtea_decipher(v0, v1);
119 } while( i < len );
120
121 // Replace multiple trailing zeroes with a single one
122
123 i = llStringLength(result) - 1;
124 while( llGetSubString(result, i - 1, i) == "AA" ){
125 result = llDeleteSubString(result, i, i);
126 i--;
127 }
128 i = llStringLength(result) - 1;
129 // while(llGetSubString(result, i, i + 1) == "A" ) {
130 // i--;
131 // }
132 result = llGetSubString(result, 0, i+1);
133 i = llStringLength(result);
134 integer mod = i%4; //Depending on encoded length diffrent appends are needed
135 if(mod == 1) result += "A==";
136 else if(mod == 2 ) result += "==";
137 else if(mod == 3) result += "=";
138
139 return llBase64ToString(result);
140 }
141
142 string base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
143
144
145 integer food_left;
146
147 default
148 {
150 {
151 if(llGetOwner() != YOUR_UUID) {
152 // someone not the creator reset the script. Thats naughty.
153 state dead;
154 }
155 llSetText("", <1,1,1>, 1.0);
156 xtea_key = xtea_key_from_string(SECRET_PASSWORD);
157 food_left = UNITS_OF_FOOD;
158 llListen(FOOD_CHANNEL, "", "", "");
159 }
160
161 touch_start(integer total_number)
162 {
163 llSetTimerEvent(20.0);
164 llSetText((string)food_left + " servings remaining.", <1,1,1>, 1.0);
165 }
166
167 timer()
168 {
169 llSetTimerEvent(0.0);
170 llSetText("", <1,1,1>, 1.0);
171 }
172
173 listen(integer channel, string name, key id, string message)
174 {
175 list data = llParseString2List(xtea_decrypt_string(message), ["^"] , []);
176 if(llList2String(data, 0) == "XSPET") {
177 if(llList2String(data, 1) == "FOOD_LOCATION") {
178 integer random_key = llList2Integer(data, 2);
179 key animal_key = llList2Key(data, 3);
180 llSay(ANIMAL_CHANNEL, xtea_encrypt_string("XSPET^FOOD_LOCATION^" + (string)random_key + "^" + (string)llGetPos() + "^" + (string)animal_key));
181 }
182 if(llList2String(data, 1) == "FOOD_CONSUME") {
183 if(llList2Key(data, 2) == llGetKey()) {
184 integer random_key = llList2Integer(data, 3);
185 key animal_key = llList2Key(data, 4);
186 food_left--;
187 llMessageLinked(LINK_SET, 100, "1", "");
188 llSay(ANIMAL_CHANNEL, xtea_encrypt_string("XSPET^FOOD_CONSUME^" + (string)random_key + "^" + (string)animal_key + "^" + (string)FOOD_TYPE));
189 if(food_left <= 0) {
190 state empty;
191 }
192 }
193 }
194 }
195 }
196 }
197
198 state dead
199 {
201 {
202 llSetText("This food bowl has been broken.", <1,0,0>, 1.0);
203 }
204 }
205
206 state empty
207 {
209 {
210 llSetObjectName("XS Food Bowl (Empty)");
211 llSetText("Empty", <1,0,0>, 1.0);
212 }
213 }

Breedable_Animal_Pets_Script

FoodBowl: xs_foodbowl_anim.lsl

Category: Animal
By : Xundra Snowpaw
Created: 2011-07-25 Edited: 2011-07-25
Worlds: Second Life

1 integer UNITS_OF_FOOD = 168;
2
3 integer food_left;
4
5 default
6 {
8 {
9 food_left = UNITS_OF_FOOD;
10 }
11
12 link_message(integer sender, integer number, string str, key id)
13 {
14 if(number == 100) {
15 // its a decrease message
16 integer amount = (integer)str;
17
18 food_left = food_left - amount;
19
20 // do the pie slice thing
21 float cut_amount = ((float)food_left / (float)UNITS_OF_FOOD) * 0.95;
22 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>]);
23 }
24 }
25 }

Breedable_Animal_Pets_Script

Home: xs_home.lsl

Category: Animal
By : Xundra Snowpaw
Created: 2011-07-25 Edited: 2011-07-25
Worlds: Second Life

1 string SECRET_PASSWORD = "top secret";
2 integer ANIMAL_CHANNEL = -999192;
3 integer HOME_CHANNEL = -999194;
4
5 // DON'T CHANGE THE FOLLOWING! (Unless you know what you are doing!)
6
7 integer XTEA_DELTA = 0x9E3779B9; // (sqrt(5) - 1) * 2^31
8 integer xtea_num_rounds = 6;
9 list xtea_key = [0, 0, 0, 0];
10
11 integer hex2int(string hex) {
12 if(llGetSubString(hex,0,1) == "0x")
13 return (integer)hex;
14 if(llGetSubString(hex,0,0) == "x")
15 return (integer)("0"+hex);
16 return(integer)("0x"+hex);
17 }
18
19
20 // Convers any string to a 32 char MD5 string and then to a list of
21 // 4 * 32 bit integers = 128 bit Key. MD5 ensures always a specific
22 // 128 bit key is generated for any string passed.
23 list xtea_key_from_string( string str )
24 {
25 str = llMD5String(str,0); // Use Nonce = 0
26 return [ hex2int(llGetSubString( str, 0, 7)),
27 hex2int(llGetSubString( str, 8, 15)),
28 hex2int(llGetSubString( str, 16, 23)),
29 hex2int(llGetSubString( str, 24, 31))];
30 }
31
32 // Encipher two integers and return the result as a 12-byte string
33 // containing two base64-encoded integers.
34 string xtea_encipher( integer v0, integer v1 )
35 {
36 integer num_rounds = xtea_num_rounds;
37 integer sum = 0;
38 do {
39 // LSL does not have unsigned integers, so when shifting right we
40 // have to mask out sign-extension bits.
41 v0 += (((v1 << 4) ^ ((v1 >> 5) & 0x07FFFFFF)) + v1) ^ (sum + llList2Integer(xtea_key, sum & 3));
42 sum += XTEA_DELTA;
43 v1 += (((v0 << 4) ^ ((v0 >> 5) & 0x07FFFFFF)) + v0) ^ (sum + llList2Integer(xtea_key, (sum >> 11) & 3));
44
45 } while( num_rounds = ~-num_rounds );
46 //return only first 6 chars to remove "=="'s and compact encrypted text.
47 return llGetSubString(llIntegerToBase64(v0),0,5) +
49 }
50
51 // Decipher two base64-encoded integers and return the FIRST 30 BITS of
52 // each as one 10-byte base64-encoded string.
53 string xtea_decipher( integer v0, integer v1 )
54 {
55 integer num_rounds = xtea_num_rounds;
56 integer sum = XTEA_DELTA*xtea_num_rounds;
57 do {
58 // LSL does not have unsigned integers, so when shifting right we
59 // have to mask out sign-extension bits.
60 v1 -= (((v0 << 4) ^ ((v0 >> 5) & 0x07FFFFFF)) + v0) ^ (sum + llList2Integer(xtea_key, (sum>>11) & 3));
61 sum -= XTEA_DELTA;
62 v0 -= (((v1 << 4) ^ ((v1 >> 5) & 0x07FFFFFF)) + v1) ^ (sum + llList2Integer(xtea_key, sum & 3));
63 } while( num_rounds = ~-num_rounds );
64
65 return llGetSubString(llIntegerToBase64(v0), 0, 4) +
67 }
68
69 // Encrypt a full string using XTEA.
70 string xtea_encrypt_string( string str )
71 {
72 // encode string
73 str = llStringToBase64(str);
74 // remove trailing =s so we can do our own 0 padding
75 integer i = llSubStringIndex( str, "=" );
76 if( i != -1 )
77 str = llDeleteSubString( str, i, -1 );
78
79 // we don't want to process padding, so get length before adding it
80 integer len = llStringLength(str);
81
82 // zero pad
83 str += "AAAAAAAAAA=";
84
85 string result;
86 i = 0;
87
88 do {
89 // encipher 30 (5*6) bits at a time.
90 result += xtea_encipher(llBase64ToInteger(llGetSubString(str, i, i + 4) + "A="), llBase64ToInteger(llGetSubString(str, i+5, i + 9) + "A="));
91 i+=10;
92 } while( i < len );
93
94 return result;
95 }
96
97 // Decrypt a full string using XTEA
98 string xtea_decrypt_string( string str ) {
99 integer len = llStringLength(str);
100 integer i=0;
101 string result;
102 //llOwnerSay(str);
103 do {
104 integer v0;
105 integer v1;
106
107 v0 = llBase64ToInteger(llGetSubString(str, i, i + 5) + "==");
108 i+= 6;
109 v1 = llBase64ToInteger(llGetSubString(str, i, i + 5) + "==");
110 i+= 6;
111
112 result += xtea_decipher(v0, v1);
113 } while( i < len );
114
115 // Replace multiple trailing zeroes with a single one
116
117 i = llStringLength(result) - 1;
118 while( llGetSubString(result, i - 1, i) == "AA" ){
119 result = llDeleteSubString(result, i, i);
120 i--;
121 }
122 i = llStringLength(result) - 1;
123 // while(llGetSubString(result, i, i + 1) == "A" ) {
124 // i--;
125 // }
126 result = llGetSubString(result, 0, i+1);
127 i = llStringLength(result);
128 integer mod = i%4; //Depending on encoded length diffrent appends are needed
129 if(mod == 1) result += "A==";
130 else if(mod == 2 ) result += "==";
131 else if(mod == 3) result += "=";
132
133 return llBase64ToString(result);
134 }
135
136 string base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
137
138
139
140 default
141 {
143 {
144 xtea_key = xtea_key_from_string(SECRET_PASSWORD);
145 llListen(-237918, "", "", "XSPET_PING_HOME");
146 }
147
148 touch_start(integer total_number)
149 {
150 if(llDetectedKey(0) == llGetOwner()) {
151 vector size = llGetScale();
152 vector pos = llGetPos();
153
154 pos.z = pos.z - size.z / 2;
155 // llOwnerSay("XSPET^HOME_LOCATION^" + (string)llGetPos() + "^" + llGetObjectDesc());
156 llSay(ANIMAL_CHANNEL, xtea_encrypt_string("XSPET^HOME_LOCATION^" + (string)pos + "^" + llGetObjectDesc()));
157 }
158 }
159
160 listen(integer channel, string name, key id, string msg)
161 {
162 vector size = llGetScale();
163 vector pos = llGetPos();
164
165 pos.z = pos.z - size.z / 2;
166 // llOwnerSay("XSPET^HOME_LOCATION^" + (string)llGetPos() + "^" + llGetObjectDesc());
167 llSay(ANIMAL_CHANNEL, xtea_encrypt_string("XSPET^HOME_LOCATION^" + (string)pos + "^" + llGetObjectDesc())); }
168 }

Breedable_Animal_Pets_Script

Transport Crate:xs_cryocrate.lsl

Category: Animal
By : Xundra Snowpaw
Created: 2011-07-25 Edited: 2011-07-25
Worlds: Second Life

1 integer API_CHANNEL = -999198;
2 float VERSION = 0.22;
3
4 string SECRET_PASSWORD = "top secret";
5 integer SECRET_NUMBER = 99999;
6 key YOUR_UUID = "00000000-0000-0000-0000-000000000000";
7 integer ANIMAL_CHANNEL = -999192;
8 integer BOX_CHANNEL = -999195;
9
10 // DON'T CHANGE THE FOLLOWING! (Unless you know what you are doing!)
11
12 integer XTEA_DELTA = 0x9E3779B9; // (sqrt(5) - 1) * 2^31
13 integer xtea_num_rounds = 6;
14 list xtea_key = [0, 0, 0, 0];
15
16 integer hex2int(string hex) {
17 if(llGetSubString(hex,0,1) == "0x")
18 return (integer)hex;
19 if(llGetSubString(hex,0,0) == "x")
20 return (integer)("0"+hex);
21 return(integer)("0x"+hex);
22 }
23
24
25 // Convers any string to a 32 char MD5 string and then to a list of
26 // 4 * 32 bit integers = 128 bit Key. MD5 ensures always a specific
27 // 128 bit key is generated for any string passed.
28 list xtea_key_from_string( string str )
29 {
30 str = llMD5String(str,0); // Use Nonce = 0
31 return [ hex2int(llGetSubString( str, 0, 7)),
32 hex2int(llGetSubString( str, 8, 15)),
33 hex2int(llGetSubString( str, 16, 23)),
34 hex2int(llGetSubString( str, 24, 31))];
35 }
36
37 // Encipher two integers and return the result as a 12-byte string
38 // containing two base64-encoded integers.
39 string xtea_encipher( integer v0, integer v1 )
40 {
41 integer num_rounds = xtea_num_rounds;
42 integer sum = 0;
43 do {
44 // LSL does not have unsigned integers, so when shifting right we
45 // have to mask out sign-extension bits.
46 v0 += (((v1 << 4) ^ ((v1 >> 5) & 0x07FFFFFF)) + v1) ^ (sum + llList2Integer(xtea_key, sum & 3));
47 sum += XTEA_DELTA;
48 v1 += (((v0 << 4) ^ ((v0 >> 5) & 0x07FFFFFF)) + v0) ^ (sum + llList2Integer(xtea_key, (sum >> 11) & 3));
49
50 } while( num_rounds = ~-num_rounds );
51 //return only first 6 chars to remove "=="'s and compact encrypted text.
52 return llGetSubString(llIntegerToBase64(v0),0,5) +
54 }
55
56 // Decipher two base64-encoded integers and return the FIRST 30 BITS of
57 // each as one 10-byte base64-encoded string.
58 string xtea_decipher( integer v0, integer v1 )
59 {
60 integer num_rounds = xtea_num_rounds;
61 integer sum = XTEA_DELTA*xtea_num_rounds;
62 do {
63 // LSL does not have unsigned integers, so when shifting right we
64 // have to mask out sign-extension bits.
65 v1 -= (((v0 << 4) ^ ((v0 >> 5) & 0x07FFFFFF)) + v0) ^ (sum + llList2Integer(xtea_key, (sum>>11) & 3));
66 sum -= XTEA_DELTA;
67 v0 -= (((v1 << 4) ^ ((v1 >> 5) & 0x07FFFFFF)) + v1) ^ (sum + llList2Integer(xtea_key, sum & 3));
68 } while( num_rounds = ~-num_rounds );
69
70 return llGetSubString(llIntegerToBase64(v0), 0, 4) +
72 }
73
74 // Encrypt a full string using XTEA.
75 string xtea_encrypt_string( string str )
76 {
77 // encode string
78 str = llStringToBase64(str);
79 // remove trailing =s so we can do our own 0 padding
80 integer i = llSubStringIndex( str, "=" );
81 if( i != -1 )
82 str = llDeleteSubString( str, i, -1 );
83
84 // we don't want to process padding, so get length before adding it
85 integer len = llStringLength(str);
86
87 // zero pad
88 str += "AAAAAAAAAA=";
89
90 string result;
91 i = 0;
92
93 do {
94 // encipher 30 (5*6) bits at a time.
95 result += xtea_encipher(llBase64ToInteger(llGetSubString(str, i, i + 4) + "A="), llBase64ToInteger(llGetSubString(str, i+5, i + 9) + "A="));
96 i+=10;
97 } while( i < len );
98
99 return result;
100 }
101
102 // Decrypt a full string using XTEA
103 string xtea_decrypt_string( string str ) {
104 integer len = llStringLength(str);
105 integer i=0;
106 string result;
107 //llOwnerSay(str);
108 do {
109 integer v0;
110 integer v1;
111
112 v0 = llBase64ToInteger(llGetSubString(str, i, i + 5) + "==");
113 i+= 6;
114 v1 = llBase64ToInteger(llGetSubString(str, i, i + 5) + "==");
115 i+= 6;
116
117 result += xtea_decipher(v0, v1);
118 } while( i < len );
119
120 // Replace multiple trailing zeroes with a single one
121
122 i = llStringLength(result) - 1;
123 while( llGetSubString(result, i - 1, i) == "AA" ){
124 result = llDeleteSubString(result, i, i);
125 i--;
126 }
127 i = llStringLength(result) - 1;
128 // while(llGetSubString(result, i, i + 1) == "A" ) {
129 // i--;
130 // }
131 result = llGetSubString(result, 0, i+1);
132 i = llStringLength(result);
133 integer mod = i%4; //Depending on encoded length diffrent appends are needed
134 if(mod == 1) result += "A==";
135 else if(mod == 2 ) result += "==";
136 else if(mod == 3) result += "=";
137
138 return llBase64ToString(result);
139 }
140 string base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
141
142 vector colour1;
143 vector colour2;
144 integer gen;
145 integer shine;
146 float glow;
147 key uuid;
148 integer listener;
149 integer owner_touch;
150 integer sex;
151 integer age;
152 integer hunger;
153 string myname;
154 integer glow_gene;
155 string special;
156
157 say_details()
158 {
159
160 string mysex;
161 string myshine;
162 if(sex == 1) {
163 mysex = "Male";
164 } else
165 if(sex == 2) {
166 mysex = "Female";
167 } else {
168 mysex = (string)sex;
169 }
170
171 if(shine == 0) {
172 myshine = "None";
173 } else
174 if(shine == 1) {
175 myshine = "Low";
176 } else
177 if(shine == 2) {
178 myshine = "Medium";
179 } else
180 if(shine == 3) {
181 myshine = "High";
182 }
183
184 llWhisper(0, "Head/Body Colour: " + (string)colour1);
185 llWhisper(0, "Tail/Wing Colour: " + (string)colour2);
186 llWhisper(0, "Shine: " + myshine);
187 llWhisper(0, "Glow: " + (string)((integer)(glow * 100)) + "%");
188 llWhisper(0, "Special: " + special);
189 llWhisper(0, "Sex: " + mysex);
190 llWhisper(0, "Age: " + (string)age + " days");
191 llWhisper(0, "Generation: " + (string)gen);
192
193 llSay(API_CHANNEL, "XSQuail^" + (string)llGetKey() + "^" + (string)colour1 + "^" + (string)colour2 + "^" + (string)shine + "^" + (string)glow + "^" + special + "^" + (string)gen + "^" + (string)sex + "^" + (string)age + "^XSQuailEnd");
194 }
195
196 set_colours(vector c1, vector c2, integer shine, float glow)
197 {
198 llSetPrimitiveParams([PRIM_COLOR, 0, c1, 1.0, PRIM_COLOR, 1, c1, 1.0, PRIM_COLOR, 3, c1, 1.0, PRIM_COLOR, 5, c1, 1.0, PRIM_COLOR, 2, c2, 1.0, PRIM_COLOR, 4, c2, 1.0, PRIM_BUMP_SHINY, ALL_SIDES, shine, PRIM_BUMP_NONE, PRIM_GLOW, ALL_SIDES, glow]);
199 }
200
201 default
202 {
204 {
205 xtea_key = xtea_key_from_string(SECRET_PASSWORD);
206 uuid = NULL_KEY;
207 listener = llListen(BOX_CHANNEL, "", "", "");
208 }
209
211 {
212 llWhisper(0, "This Cryo-Crate is v" + (string)VERSION);
213 }
214
215 listen(integer channel, string name, key id, string msg)
216 {
217 if(llGetOwnerKey(id) != llGetOwner()) {
218 return;
219 }
220
221 list data = llParseString2List(xtea_decrypt_string(msg), ["^"], []);
222
223 if(uuid == NULL_KEY) {
224 if(llList2String(data, 0) == "XSPET" && llList2String(data, 2) == "CRATE_PING") {
225 uuid = id;
226 llSay(ANIMAL_CHANNEL, xtea_encrypt_string("XSPET^CRATE_PONG^" + (string)id + "^" + (string)VERSION));
227 llSetTimerEvent(15.0);
228 }
229 } else if(uuid == id) {
230 if(llList2String(data, 0) == "XSPET" && llList2Key(data, 1) == llGetKey()) {
231 llSetTimerEvent(0.0);
232 colour1 = (vector)llList2String(data, 2);
233 colour2 = (vector)llList2String(data, 3);
234 shine = llList2Integer(data, 4);
235 glow = llList2Float(data, 5);
236 gen = llList2Integer(data, 6);
237 sex = llList2Integer(data, 7);
238 age = llList2Integer(data, 8);
239 hunger = llList2Integer(data, 9);
240 myname = llList2String(data, 10);
241 glow_gene = llList2Integer(data, 11);
242 special = llList2String(data, 12);
243 llListenRemove(listener);
244 llSay(ANIMAL_CHANNEL, xtea_encrypt_string("XSPET^CRATE_DIE^" + (string)id + "^" + (string)VERSION));
245
246 state full;
247 } else
248 if(llList2String(data, 0) == "XSPET" && llList2Key(data, 1) != llGetKey()) {
249 uuid = NULL_KEY;
250 }
251 }
252 }
253 timer()
254 {
255 llSetTimerEvent(0.0);
256 uuid = NULL_KEY;
257 }
258 }
259
260 state full
261 {
263 {
264 llSetObjectName("XS Cryo-Crate: " + myname);
265 set_colours(colour1, colour2, shine, glow);
266 llListen(API_CHANNEL, "", "", "");
267 }
268
270 {
271 owner_touch = 0;
272 say_details();
273
274
275 if(llDetectedKey(0) == llGetOwner()) {
276 owner_touch = 1;
277 integer chan = (integer)llFrand(10000.0) + 1000;
278 listener = llListen(chan, "", llGetOwner(), "");
279
280 llDialog(llGetOwner(), "Would you like to unpackage me?", ["Yes", "No"], chan);
281 }
282 llSetTimerEvent(20.0);
283 }
284
285 timer()
286 {
287 //llOwnerSay("Menu timeout.");
288 if(owner_touch == 1) {
289 llListenRemove(listener);
290 }
291 llSetTimerEvent(0.0);
292 }
293
294 listen(integer channel, string name, key id, string msg)
295 {
296 if(channel == API_CHANNEL) {
297 list data = llParseString2List(msg, ["^"], []);
298 if(llList2String(data, 0) == "XSQuail" && llList2Key(data, 1) == llGetKey()) {
299 llSay(API_CHANNEL, "XSQuail^" + (string)llGetKey() + "^" + (string)colour1 + "^" + (string)colour2 + "^" + (string)shine + "^" + (string)glow + "^" + special + "^" + (string)gen + "^" + (string)sex + "^" + (string)age + "^XSQuailEnd");
300 }
301 } else {
302 llListenRemove(listener);
303 if(msg == "Yes") {
304 state unbox;
305 }
306 }
307 }
308 }
309
310 state unbox
311 {
313 {
314 llRezObject("Quail", llGetPos() + <0.0, 0.0, 0.25>, ZERO_VECTOR, ZERO_ROTATION, SECRET_NUMBER);
315 }
316
317 object_rez(key id)
318 {
319 listener = llListen(BOX_CHANNEL, "", id, "");
320 }
321
322 listen(integer channel, string name, key id, string msg)
323 {
324 if(channel == BOX_CHANNEL) {
325 list data = llParseString2List(xtea_decrypt_string(msg), ["^"], []);
326 if(llList2String(data, 0) == "XSPET" && llList2String(data, 1) == "READY") {
327
328 llGiveInventory(id, "XS Egg");
329 llGiveInventory(id, "Quail");
330
331 llSay(ANIMAL_CHANNEL, xtea_encrypt_string("XSPET^CONFIG^" + (string)id + "^" + (string)colour1 + "^" + (string)colour2 + "^" + (string)sex + "^" + (string)shine + "^" + (string)glow + "^" + (string)gen + "^" +(string)age + "^" + (string)hunger + "^" + myname + "^" + (string)glow_gene + "^" + special));
332 llDie();
333 }
334 }
335 }
336 }

Breedable_Animal_Pets_Script

This script can be used to set the quail into it's initial size. Once this script has been loaded into the root prim of the quail and run, it can be deleted
Author Ferd Frederix

Category: Animal
By : Xundra Snowpaw
Created: 2011-07-25 Edited: 2011-07-25
Worlds: Second Life

1 default
2 {
4 {
5
6 float new_scale = 1.0;
7
8 vector new_size = <0.124, 0.082, 0.096> * new_scale;
9 vector new_pos;
10
12
13 // -> body -> tail <-0.032043,-0.000061,0.009560> 9
14
15 new_size = <0.082, 0.082, 0.082> * new_scale;
16 new_pos = <-0.032043,-0.000061,0.009560> * new_scale;
17 llSetLinkPrimitiveParams(9, [PRIM_SIZE, new_size, PRIM_POSITION, new_pos]);
18
19 // -> body -> left wing <-0.004141,0.034098,0.008184> 7
20 new_size = <0.058, 0.079, 0.023> * new_scale;
21 new_pos = <-0.004141,0.034098,0.008184> * new_scale;
22
23 llSetLinkPrimitiveParams(7, [PRIM_SIZE, new_size, PRIM_POSITION, new_pos]);
24
25 // -> body -> right wing <-0.011113,-0.034257,0.008841> 4
26 new_size = <0.058, 0.079, 0.023> * new_scale;
27 new_pos = <-0.011113,-0.034257,0.008841> * new_scale;
28
29 llSetLinkPrimitiveParams(4, [PRIM_SIZE, new_size, PRIM_POSITION, new_pos]);
30
31 // -> body -> left leg <0.009700,0.020261,-0.052318> 6
32 new_size = <0.01, 0.01, 0.064> * new_scale;
33 new_pos = <0.009700,0.020261,-0.052318> * new_scale;
34
35 llSetLinkPrimitiveParams(6, [PRIM_SIZE, new_size, PRIM_POSITION, new_pos]);
36
37 // -> body -> right leg <0.009747,-0.022943,-0.052399> 10
38 new_size = <0.01, 0.01, 0.064> * new_scale;
39 new_pos = <0.009747,-0.022943,-0.052399> * new_scale;
40
41 llSetLinkPrimitiveParams(10, [PRIM_SIZE, new_size, PRIM_POSITION, new_pos]);
42
43 // -> body -> head <0.042349,-0.000059,0.055298> 5
44 new_size = <0.082, 0.082, 0.082> * new_scale;
45 new_pos = <0.042349,-0.000059,0.055298> * new_scale;
46
47 llSetLinkPrimitiveParams(5, [PRIM_SIZE, new_size, PRIM_POSITION, new_pos]);
48 // -> body -> head -> left eye <0.067205,0.018735,0.070143> 8
49 new_size = <0.024, 0.024, 0.024> * new_scale;
50 new_pos = <0.067205,0.018735,0.070143> * new_scale;
51
52 llSetLinkPrimitiveParams(8, [PRIM_SIZE, new_size, PRIM_POSITION, new_pos]);
53
54 // -> body -> head -> right eye <0.067265,-0.017552,0.070217> 3
55 new_size = <0.024, 0.024, 0.024> * new_scale;
56 new_pos = <0.067265,-0.017552,0.070217> * new_scale;
57
58 llSetLinkPrimitiveParams(3, [PRIM_SIZE, new_size, PRIM_POSITION, new_pos]);
59
60 // -> body -> head -> beak <0.086439,-0.000059,0.049794> 2
61 new_size = <0.043, 0.043, 0.043> * new_scale;
62 new_pos = <0.086439,-0.000059,0.049794> * new_scale;
63
64 llSetLinkPrimitiveParams(2, [PRIM_SIZE, new_size, PRIM_POSITION, new_pos]);
65 }
66
67 }

Breedable_Animal_Pets_Script

xs_debug - a script tointercept messages inside and outside your bird
Version 2, 10-2-2011 by Ferd Frederix
Prints out the channel and the link number

Category: Animal
By : Xundra Snowpaw
Created: 2011-07-25 Edited: 2011-07-25
Worlds: Second Life

1 integer FOOD_CHANNEL = -999191;
2 integer ANIMAL_CHANNEL = -999192;
3 integer HOME_CHANNEL = -999194;
4 integer BOX_CHANNEL = -999195;
5 integer ACC_CHANNEL = -999196;
6 integer UPDATE_CHANNEL = -999197;
7 integer EGG_CHANNEL = -999193;
8
9
10 list channels = [
11 "FOOD_CHANNEL" , -999191,
12 "ANIMAL_CHANNEL" , -999192,
13 "HOME_CHANNEL" , -999194,
14 "BOX_CHANNEL" , -999195,
15 "ACC_CHANNEL" , -999196,
16 "UPDATE_CHANNEL" , -999197,
17 "EGG_CHANNEL" , -999193
18 ];
19
20 list messages = [
21 " LINK_AGE_START " , 800,
22 " LINK_FOOD_CONSUME " , 900,
23 " LINK_FOODMINUS " , 901,
24 " LINK_HUNGRY " , 903,
25 " LINK_HAMOUNT " , 904,
26 " LINK_SET_HOME " , 910,
27 " LINK_MOVER " , 911,
28 " LINK_FOODIE_CLR " , 920,
29 " LINK_FOODIE " , 921,
30 " LINK_COLOR1 " , 930,
31 " LINK_COLOR2 " , 931,
32 " LINK_SEX " , 932,
33 " LINK_SHINE " , 933,
34 " LINK_GLOW " , 934,
35 " LINK_GEN " , 935,
36 " LINK_MAGE " , 940,
37 " LINK_DAYTIME " , 941,
38 " LINK_GET_AGE " , 942,
39 " LINK_PUT_AGE " , 943,
40 " LINK_PACKAGE " , 950,
41 " LINK_SEEK_FEMALE " , 960,
42 " LINK_MALE_BREED_CALL " , 961,
43 " LINK_SIGNAL_ELIGIBLE" , 962,
44 " LINK_FEMALE_ELIGIBLE " , 963,
45 " LINK_CALL_MALE " , 964,
46 " LINK_MALE_ON_THE_WAY " , 965,
47 " LINK_FEMALE_LOCATION " , 966,
48 " LINK_CALL_MALE_INFO " , 968,
49 " LINK_RQST_BREED ", 967,
50 " LINK_MALE_INFO " , 969,
51 " LINK_LAY_EGG " , 970,
52 " LINK_BREED_FAIL " , 971,
53 " LINK_PREGNANT " , 972,
54 " LINK_SLEEPING " , 990,
55 " LINK_UNSLEEPING " , 991,
56 " LINK_SOUND " , 1001,
57 " LINK_SPECIAL " , 1010,
58 " LINK_PREGNANCY_TIME " , 5000,
59 " LINK_SLEEP " , 7999,
60 " LINK_TIMER " , 8000,
61 " LINK_DIE " , 9999
62 ];
63
64
65
66
67 string SECRET_PASSWORD = "top secret";
68 integer SECRET_NUMBER = 99999;
69
70
71 // DON'T CHANGE THE FOLLOWING! (Unless you know what you are doing!)
72
73 integer XTEA_DELTA = 0x9E3779B9; // (sqrt(5) - 1) * 2^31
74 integer xtea_num_rounds = 6;
75 list xtea_key = [0, 0, 0, 0];
76
77 integer hex2int(string hex) {
78 if(llGetSubString(hex,0,1) == "0x")
79 return (integer)hex;
80 if(llGetSubString(hex,0,0) == "x")
81 return (integer)("0"+hex);
82 return(integer)("0x"+hex);
83 }
84
85
86 // Convers any string to a 32 char MD5 string and then to a list of
87 // 4 * 32 bit integers = 128 bit Key. MD5 ensures always a specific
88 // 128 bit key is generated for any string passed.
89 list xtea_key_from_string( string str )
90 {
91 str = llMD5String(str,0); // Use Nonce = 0
92 return [ hex2int(llGetSubString( str, 0, 7)),
93 hex2int(llGetSubString( str, 8, 15)),
94 hex2int(llGetSubString( str, 16, 23)),
95 hex2int(llGetSubString( str, 24, 31))];
96 }
97
98 // Encipher two integers and return the result as a 12-byte string
99 // containing two base64-encoded integers.
100 string xtea_encipher( integer v0, integer v1 )
101 {
102 integer num_rounds = xtea_num_rounds;
103 integer sum = 0;
104 do {
105 // LSL does not have unsigned integers, so when shifting right we
106 // have to mask out sign-extension bits.
107 v0 += (((v1 << 4) ^ ((v1 >> 5) & 0x07FFFFFF)) + v1) ^ (sum + llList2Integer(xtea_key, sum & 3));
108 sum += XTEA_DELTA;
109 v1 += (((v0 << 4) ^ ((v0 >> 5) & 0x07FFFFFF)) + v0) ^ (sum + llList2Integer(xtea_key, (sum >> 11) & 3));
110
111 } while( num_rounds = ~-num_rounds );
112 //return only first 6 chars to remove "=="'s and compact encrypted text.
113 return llGetSubString(llIntegerToBase64(v0),0,5) +
115 }
116
117 // Decipher two base64-encoded integers and return the FIRST 30 BITS of
118 // each as one 10-byte base64-encoded string.
119 string xtea_decipher( integer v0, integer v1 )
120 {
121 integer num_rounds = xtea_num_rounds;
122 integer sum = XTEA_DELTA*xtea_num_rounds;
123 do {
124 // LSL does not have unsigned integers, so when shifting right we
125 // have to mask out sign-extension bits.
126 v1 -= (((v0 << 4) ^ ((v0 >> 5) & 0x07FFFFFF)) + v0) ^ (sum + llList2Integer(xtea_key, (sum>>11) & 3));
127 sum -= XTEA_DELTA;
128 v0 -= (((v1 << 4) ^ ((v1 >> 5) & 0x07FFFFFF)) + v1) ^ (sum + llList2Integer(xtea_key, sum & 3));
129 } while( num_rounds = ~-num_rounds );
130
131 return llGetSubString(llIntegerToBase64(v0), 0, 4) +
133 }
134
135 // Encrypt a full string using XTEA.
136 string xtea_encrypt_string( string str )
137 {
138 // encode string
139 str = llStringToBase64(str);
140 // remove trailing =s so we can do our own 0 padding
141 integer i = llSubStringIndex( str, "=" );
142 if( i != -1 )
143 str = llDeleteSubString( str, i, -1 );
144
145 // we don't want to process padding, so get length before adding it
146 integer len = llStringLength(str);
147
148 // zero pad
149 str += "AAAAAAAAAA=";
150
151 string result;
152 i = 0;
153
154 do {
155 // encipher 30 (5*6) bits at a time.
156 result += xtea_encipher(llBase64ToInteger(llGetSubString(str, i, i + 4) + "A="), llBase64ToInteger(llGetSubString(str, i+5, i + 9) + "A="));
157 i+=10;
158 } while( i < len );
159
160 return result;
161 }
162
163 // Decrypt a full string using XTEA
164 string xtea_decrypt_string( string str ) {
165 integer len = llStringLength(str);
166 integer i=0;
167 string result;
168 //llOwnerSay(str);
169 do {
170 integer v0;
171 integer v1;
172
173 v0 = llBase64ToInteger(llGetSubString(str, i, i + 5) + "==");
174 i+= 6;
175 v1 = llBase64ToInteger(llGetSubString(str, i, i + 5) + "==");
176 i+= 6;
177
178 result += xtea_decipher(v0, v1);
179 } while( i < len );
180
181 // Replace multiple trailing zeroes with a single one
182
183 i = llStringLength(result) - 1;
184 while( llGetSubString(result, i - 1, i) == "AA" ){
185 result = llDeleteSubString(result, i, i);
186 i--;
187 }
188 i = llStringLength(result) - 1;
189 // while(llGetSubString(result, i, i + 1) == "A" ) {
190 // i--;
191 // }
192 result = llGetSubString(result, 0, i+1);
193 i = llStringLength(result);
194 integer mod = i%4; //Depending on encoded length diffrent appends are needed
195 if(mod == 1) result += "A==";
196 else if(mod == 2 ) result += "==";
197 else if(mod == 3) result += "=";
198
199 return llBase64ToString(result);
200 }
201
202 default
203 {
205 {
206 xtea_key = xtea_key_from_string(SECRET_PASSWORD);
207 llListen(FOOD_CHANNEL,"","","");
208 llListen(ANIMAL_CHANNEL,"","","");
209 llListen(HOME_CHANNEL,"","","");
210 llListen(BOX_CHANNEL,"","","");
211 llListen(ACC_CHANNEL,"","","");
212 llListen(UPDATE_CHANNEL,"","","");
213 llListen(EGG_CHANNEL,"","","");
214 }
215
216 listen(integer channel,string name, key id, string message)
217 {
218 integer index = llListFindList(channels,[channel]); // see if a valid channel
219 string aname = "unkown";
220 if(index >= 0)
221 {
222 aname = llList2String(channels,index-1);
223 }
224 llOwnerSay(llGetObjectName() + ":channel:" + aname + ":" + xtea_decrypt_string(message) );
225 }
226
227
228 link_message(integer sender_num, integer num, string str, key id)
229 {
230 integer index = llListFindList(messages,[num]); // see if a valid channel
231 string aname = "unkown";
232 if(index >= 0)
233 {
234 aname = llList2String(messages,index-1);
235 }
236
237 llOwnerSay(llGetObjectName() + ":" + aname + " : string:" + str + " : key:" + (string) id);
238
239 }
240
241 touch_start(integer total_number)
242 {
243 llSay(0, "Touched.");
244 }
245 }

Breedable_Animal_Pets_Script

Globals - taken from the Quail

Category: Animal
By : Xundra Snowpaw
Created: 2011-07-25 Edited: 2011-07-25
Worlds: Second Life

1 // Revisions:
2 //
3 // 10/2/2011
4 // changed all Link messages to these constants in this file in the Quail
5 // removed the YOUR_UUID and replaced it with llGetCreator()
6
7
8 // INCLUDE //
9 // XS_Quail constants
10
11 ///// GLOBAL LINK CONSTANTS extracted from original source //////
12 //
13 // if you change any of these constants, change it everywhere and in a list in XS_Debug so it can print them
14 //
15
16 integer LINK_AGE_START = 800; // when quail is rezzed and secret_number, is sent by brain to breeder, eater and informatic get booted up
17 integer LINK_FOOD_CONSUME = 900; // from movement to brain when close to food, brain then consumes a random amount up to 10000
18 integer LINK_FOODMINUS = 901; // xs_brain receives FOOD_CONSUME, decrement hunger (eat)
19 integer LINK_HUNGRY = 903; // sent by eater (string)hunger_amount, checks each hour
20 integer LINK_HAMOUNT = 904; // hunger_amount = (integer)str,m updates the hunger amount in scripts
21 integer LINK_SET_HOME = 910; // loc ^ dist
22 integer LINK_MOVER = 911; // tell mover to rest for str seconds
23 integer LINK_FOODIE_CLR = 920; // clear all food_bowl_keys and contents
24 integer LINK_FOODIE = 921; // send FOOD_LOCATION coordinates to movement
25 integer LINK_COLOR1 = 930; // colour1
26 integer LINK_COLOR2 = 931; // colour2
27 integer LINK_SEX = 932; // sex
28 integer LINK_SHINE = 933; // shine
29 integer LINK_GLOW = 934; // glow
30 integer LINK_GEN = 935; // generation
31 integer LINK_MAGE = 940; // xs_brain sends, xs_ager consumes, adds str to age, if older than 7 days, will grow the animal
32 integer LINK_DAYTIME = 941; // xs_ager consumes, starts a timer of 86,400 seconds in xs_ager
33 integer LINK_GET_AGE = 942; // get age from xs_ager and sent it on channel 943
34 integer LINK_PUT_AGE = 943; // print age from xs_ager
35 integer LINK_PACKAGE = 950; // look for a cryo_crate
36 integer LINK_SEEK_FEMALE = 960; // MALE_BREED_CALL
37 integer LINK_MALE_BREED_CALL = 961; // triggered by LINK_SEEK_FEMALE
38 integer LINK_SIGNAL_ELIGIBLE = 962; // sent by female when hears LINK_MALE_BREED_CALL
39 integer LINK_FEMALE_ELIGIBLE = 963; // sent when it hears in chat FEMALE_ELIGIBLE
40 integer LINK_CALL_MALE = 964; // if LINK_FEMALE_ELIGIBLE && looking_for_female
41 integer LINK_MALE_ON_THE_WAY = 965; // triggered by LINK_CALL_MALE
42 integer LINK_FEMALE_LOCATION = 966; // female location, sends coordinates of a female
43 integer LINK_RQST_BREED = 967; // sent when close enough to male/female
44 integer LINK_CALL_MALE_INFO = 968; // ****** BUG ***** read, but never sent by anybody!!!!!
45 // see line 557 and 636 of xs_brain which make calls and also xs_breeding which receives LUNK_MALE_INFO.
46 integer LINK_MALE_INFO = 969;
47 integer LINK_LAY_EGG = 970; // llRezObject("XS Egg"
48 integer LINK_BREED_FAIL = 971; // key = father, failed, timed out
49 integer LINK_PREGNANT = 972; // chick is preggers
50 integer LINK_SLEEPING = 990; // close eyes
51 integer LINK_UNSLEEPING = 991; // open eyes
52 integer LINK_SOUND = 1001; // plays a sound if enabled
53 integer LINK_SPECIAL = 1010; // xs_special, is str = "Normal", removes script
54 integer LINK_PREGNANCY_TIME = 5000; // in seconds as str
55 integer LINK_SLEEP = 7999; // disable sleep by parameter
56 integer LINK_TIMER = 8000; // scan for food bowl about every 1800 seconds
57 integer LINK_DIE = 9999; // death
58
59
60 ///////// end global Link constants ////////
61
62 // END //

Back to the Best Free Tools in Second Life and OpenSim.