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

Search dozens of selected web sites for OpenSim and LSL script

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

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

Home   Show All
Category: Contributor: Creator
XS Pet XS Pet Xundra Snowpaw Original Quail  

XS Pet Xundra Snowpaw Original Quail

XS Pet

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

the Zip file

Download all files for XS Pet Xundra Snowpaw Original Quail
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Readme.txt
Get file # 2. xs_ager.lsl
Get file # 3. xs_brain.lsl
Get file # 4. xs_breeding.lsl
Get file # 5. xs_eater.lsl
Get file # 6. xs_infomatic.lsl
Get file # 7. xs_movement.lsl
Get file # 8. xs_special.lsl
Get file # 9. xs_egg.lsl
Get file # 10. Lay Egg Test Script.lsl
Get file # 11. xs_foodbowl.lsl
Get file # 12. xs_foodbowl_anim.lsl
Get file # 13. xs_home.lsl
Get file # 14. xs_cryocrate.lsl

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

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

XS Pet Xundra Snowpaw Original Quail

Original Pet Quail

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


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

1
2 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 FOOD_CHANNEL = -999191;
8 integer ANIMAL_CHANNEL = -999192;
9 integer EGG_CHANNEL = -999193;
10 float FOOD_BOWL_SCAN_INTERVAL = 1800.0;
11 integer HOME_CHANNEL = -999194;
12 integer BOX_CHANNEL = -999195;
13 integer ACC_CHANNEL = -999196;
14 integer UPDATE_CHANNEL = -999197;
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 integer food_left;
149 integer random_number;
150 integer random_number2;
151 //list food_bowl_keys;
152 //list food_bowl_locations;
153 integer hunger_amount;
154 vector colour1;
155 vector colour2;
156
157 integer sex;
158
159 integer shine;
160 float glow;
161
162 integer gen;
163 integer age;
164
165 vector mcolour1;
166 vector mcolour2;
167
168 integer mshine;
169 float mglow;
170
171 integer mgen;
172 vector home_loc;
173 key new_egg_key;
174
175 integer glow_gene;
176 string special;
177
178 integer mglow_gene;
179
180 integer locked;
181
182 integer pregnancy_time;
183
184 default
185 {
187 {
188 if(llGetOwner() != YOUR_UUID) {
189 // someone not the creator reset the script. Thats naughty.
190 state dead;
191 }
192 llSetText("", <1,1,1>, 1.0);
193 random_number = 0;
194 random_number2 = 0;
195 hunger_amount = 0;
196 locked = 0;
197
198 xtea_key = xtea_key_from_string(SECRET_PASSWORD);
199 llListen(ANIMAL_CHANNEL, "", "", "");
200 }
201
202 changed(integer change)
203 {
204
205 if(change & CHANGED_ALLOWED_DROP) {
208 }
209 }
210
211 if(change & CHANGED_INVENTORY) {
212 if(llGetOwner() != YOUR_UUID) {
213
215 integer extras = 3;
216
217
218 if(llGetInventoryType("xs_ager") == INVENTORY_NONE || !llGetScriptState("xs_ager")) {
219 state dead;
220 }
221 if(llGetInventoryType("xs_infomatic") == INVENTORY_NONE || !llGetScriptState("xs_infomatic")) {
222 state dead;
223 }
224 if(llGetInventoryType("xs_breeding") == INVENTORY_NONE || !llGetScriptState("xs_breeding")) {
225 state dead;
226 }
227 if(llGetInventoryType("xs_eater") == INVENTORY_NONE || !llGetScriptState("xs_eater")) {
228 state dead;
229 }
230 if(llGetInventoryType("xs_movement") == INVENTORY_NONE || !llGetScriptState("xs_movement")) {
231 state dead;
232 }
233 if(llGetInventoryType("bird_sound") == INVENTORY_NONE) {
234 state dead;
235 }
236
237
238 if(llGetInventoryType("xs_special") == INVENTORY_NONE) {
239 extras--;
240 }
241
243 extras--;
244 }
245
247 extras--;
248 }
249
250 if(llGetInventoryType("XS Home Object") == INVENTORY_NONE) {
251 state dead;
252 }
253
254 if(8 + extras != inventory_count) {
255 state dead;
256 }
257
258 }
259 }
260 }
261
262 timer()
263 {
264
265 llMessageLinked(LINK_SET, 920, "", "");
266 // llWhisper(0, "Scanning for food bowls.");
267 random_number = (integer)(llFrand(10000.0) + 1);
268 llSay(FOOD_CHANNEL, xtea_encrypt_string("XSPET^FOOD_LOCATION^" + (string)random_number + "^" + (string)llGetKey()));
269 llSetTimerEvent(llFrand(60.0) + (FOOD_BOWL_SCAN_INTERVAL - 30.0));
270 }
271
272 listen(integer channel, string name, key id, string message)
273 {
274 if(channel == ANIMAL_CHANNEL) {
275 list data = llParseString2List(xtea_decrypt_string(message), ["^"], []);
276 if(llList2String(data, 0) == "XSPET") {
277 if(llList2String(data, 1) == "FOOD_LOCATION") {
278 llMessageLinked(LINK_SET, 921, llList2String(data, 3), id);
279 } else
280 if(llList2String(data, 1) == "FOOD_CONSUME") {
281 if(llList2Integer(data, 2) == random_number2 && llList2Key(data, 3) == llGetKey()) {
282 hunger_amount--;
283 llMessageLinked(LINK_SET, 901, "", "");
284 random_number2 = 0;
285 if(llList2Integer(data, 4) == 1 && glow_gene < 10) {
286 glow_gene ++;
287 }
288 }
289 } else
290 if(llList2String(data, 1) == "HOME_LOCATION") {
291 vector n_home_loc = (vector)llList2String(data, 2);
292 float home_dis = llList2Float(data, 3);
293 vector my_loc = llGetPos();
294 // llOwnerSay((string)llVecDist(home_loc, my_loc) + " " + (string)my_loc + (string)home_loc + (string)home_dis + llList2String(data, 2));
295 if(llVecDist(n_home_loc, my_loc) <= home_dis && llFabs(llFabs(n_home_loc.z) - llFabs(my_loc.z)) < 1) {
296 if(llGetOwnerKey(id) == llGetOwner()) {
297 home_loc = n_home_loc;
298 llMessageLinked(LINK_SET, 910, (string)n_home_loc + "^" + (string)home_dis, "");
299 }
300 }
301 } else
302 if(llList2String(data, 1) == "CONFIG" && llList2Key(data, 2) == llGetKey()) {
303 colour1 = (vector)llList2String(data, 3);;
304 colour2 = (vector)llList2String(data, 4);
305
306 sex = llList2Integer(data, 5);
307
308 shine = llList2Integer(data, 6);
309 glow = llList2Float(data, 7);
310
311 gen = llList2Integer(data, 8);
312 integer mage = llList2Integer(data, 9);
313 integer hamount = llList2Integer(data, 10);
314 string myname = llList2String(data, 11);
315 glow_gene = llList2Integer(data, 12);
316 special = llList2String(data, 13);
317
320
321 // llSetLinkColor(8, colour1, ALL_SIDES);
322 // llSetLinkColor(1, colour1, ALL_SIDES);
323
327 // llSetLinkColor(3, colour2, ALL_SIDES);
328 // llSetLinkColor(2, colour2, ALL_SIDES);
329 // llSetLinkColor(7, colour2, ALL_SIDES);
330
331 llSetTimerEvent(llFrand(60.0) + (FOOD_BOWL_SCAN_INTERVAL - 30.0));
332
333
334 llMessageLinked(LINK_SET, 930, (string)colour1, "");
335 llMessageLinked(LINK_SET, 931, (string)colour2, "");
336 llMessageLinked(LINK_SET, 932, (string)sex, "");
337 llMessageLinked(LINK_SET, 933, (string)shine, "");
338 llMessageLinked(LINK_SET, 934, (string)glow, "");
339 llMessageLinked(LINK_SET, 935, (string)gen, "");
340
341
342 llMessageLinked(LINK_SET, 940, (string)mage, "");
343
344
345 if(hamount > 0) {
346 llMessageLinked(LINK_SET, 904, (string)hamount, "");
347 }
348
349 if(name != "Quail") {
350 llSetObjectName(myname);
351 }
352
353 llSetObjectDesc("XS Quail v" + (string)VERSION + " (c) 2010 Xundra Snowpaw");
354
355
356 llMessageLinked(LINK_SET, 1010, special, "");
357
358 llMessageLinked(LINK_SET, 941, "", "");
359
360 llSay(HOME_CHANNEL, "XSPET_PING_HOME");
361
362 llSetText("", <1,1,1>, 1.0);
363 } else
364 if(llList2String(data, 1) == "UPDATE_CONFIG" && llList2Key(data, 2) == llGetKey()) {
365 colour1 = (vector)llList2String(data, 3);;
366 colour2 = (vector)llList2String(data, 4);
367
368 sex = llList2Integer(data, 5);
369
370 shine = llList2Integer(data, 6);
371 glow = llList2Float(data, 7);
372
373 gen = llList2Integer(data, 8);
374 integer mage = llList2Integer(data, 9);
375 integer hamount = llList2Integer(data, 10);
376 string myname = llList2String(data, 11);
377 glow_gene = llList2Integer(data, 12);
378 special = llList2String(data, 13);
379 mcolour1 = (vector)llList2String(data, 14);
380 mcolour2 = (vector)llList2String(data, 15);
381 mshine = llList2Integer(data, 16);
382 mglow = llList2Float(data, 17);
383 mgen = llList2Integer(data, 18);
384 mglow_gene = llList2Integer(data, 19);
385 pregnancy_time = llList2Integer(data, 20);
386
389
390 // llSetLinkColor(8, colour1, ALL_SIDES);
391 // llSetLinkColor(1, colour1, ALL_SIDES);
392
396 // llSetLinkColor(3, colour2, ALL_SIDES);
397 // llSetLinkColor(2, colour2, ALL_SIDES);
398 // llSetLinkColor(7, colour2, ALL_SIDES);
399
400 llSetTimerEvent(llFrand(60.0) + (FOOD_BOWL_SCAN_INTERVAL - 30.0));
401
402
403 llMessageLinked(LINK_SET, 930, (string)colour1, "");
404 llMessageLinked(LINK_SET, 931, (string)colour2, "");
405
406 if(sex == 1) {
407 llMessageLinked(LINK_SET, 932, (string)sex, "");
408 } else {
409 llMessageLinked(LINK_SET, 5000, (string)pregnancy_time, "");
410 }
411
412 llMessageLinked(LINK_SET, 933, (string)shine, "");
413 llMessageLinked(LINK_SET, 934, (string)glow, "");
414 llMessageLinked(LINK_SET, 935, (string)gen, "");
415
416
417 llMessageLinked(LINK_SET, 940, (string)mage, "");
418
419
420 if(hamount > 0) {
421 llMessageLinked(LINK_SET, 904, (string)hamount, "");
422 }
423
424 if(name != "Quail") {
425 llSetObjectName(myname);
426 }
427
428 llSetObjectDesc("XS Quail v" + (string)VERSION + " (c) 2010 Xundra Snowpaw");
429
430
431 llMessageLinked(LINK_SET, 1010, special, "");
432
433 llMessageLinked(LINK_SET, 941, "", "");
434
435
436
437 llSay(HOME_CHANNEL, "XSPET_PING_HOME");
438
439 llSetText("", <1,1,1>, 1.0);
440 } else
441 if(llList2String(data, 1) == "CRATE_PONG" && llList2Key(data, 2) == llGetKey()) {
442 if(llList2Float(data, 3) >= VERSION && locked == 0) {
443 locked = 1;
444 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));
445 }
446 } else
447 if(llList2String(data, 1) == "CRATE_DIE" && llList2Key(data, 2) == llGetKey()) {
448 llDie();
449 } else
450 if(llList2String(data, 1) == "MALE_BREED_CALL") {
451 llMessageLinked(LINK_SET, 961, "", "");
452 } else
453 if(llList2String(data, 1) == "FEMALE_ELIGIBLE" && home_loc == (vector)llList2String(data, 2)) {
454 llMessageLinked(LINK_SET, 963, "", id);
455 } else
456 if(llList2String(data, 1) == "MALE_ON_THE_WAY" && llList2Key(data, 2) == llGetKey()) {
457 llMessageLinked(LINK_SET, 965, "", id);
458 llSay(ANIMAL_CHANNEL, xtea_encrypt_string("XSPET^FEMALE_LOC^" + (string)id + "^" + (string)llGetPos()));
459 } else
460 if(llList2String(data, 1) == "FEMALE_LOC" && llList2String(data, 2) == llGetKey())
461 {
462 llMessageLinked(LINK_SET, 966, llList2String(data, 3), "");
463 } else
464 if(llList2String(data, 1) == "MALE_INFO" && llList2Key(data, 2) == llGetKey()){
465 // pregnant
466 mcolour1 = (vector)llList2String(data, 3);
467 mcolour2 = (vector)llList2String(data, 4);
468
469 mshine = llList2Integer(data, 5);
470 mglow = llList2Float(data, 6);
471
472 mgen = llList2Integer(data, 7);
473 mglow_gene = llList2Integer(data, 8);
474 pregnancy_time = llGetUnixTime();
475 llMessageLinked(LINK_SET, 972, "", "");
476 } else
477 if(llList2String(data, 1) == "BREEDING_FAIL" && llList2String(data, 2) == llGetKey())
478 {
479 llMessageLinked(LINK_SET, 969, "", "");
480 } else
481 if(llList2String(data, 1) == "EGG_READY" && id == new_egg_key)
482 {
483 llGiveInventory(id, "XS Egg");
484 llGiveInventory(id, "Quail");
485
486 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));
487 } else
488 if(llList2String(data, 1) == "SHINE_GOO" && llList2String(data, 2) == llGetKey()) {
489 if(shine == 0) {
490 shine = 1;
491 llMessageLinked(LINK_SET, 933, (string)shine, "");
492 llSay(ACC_CHANNEL, xtea_encrypt_string("XSPET^" + (string)id + "^SHINE_GOO_DIE"));
495
496 // llSetLinkColor(8, colour1, ALL_SIDES);
497 // llSetLinkColor(1, colour1, ALL_SIDES);
498
502 if(sex == 1) {
503 llWhisper(0, "Look out ladies, Mr Slick has arrived!");
504 } else {
505 llWhisper(0, "Look out gentlemen! Miss Slick has arrived!");
506 }
507
508
509 } else {
510 llWhisper(0, "I'm already shiny!");
511 llSay(ACC_CHANNEL, xtea_encrypt_string("XSPET^" + (string)id + "^SHINE_GOO_FAIL"));
512
513 }
514 } else
515 if(llList2String(data, 1) == "DIE" && llList2String(data, 2) == llGetKey()) {
516 llDie();
517 } else
518 if(llList2String(data, 1) == "VERSION" && VERSION < llList2Float(data, 2) && llGetOwnerKey(id) == llGetOwner()) {
519 llShout(UPDATE_CHANNEL, "VERSION^" + (string)VERSION);
520 } else
521 if(llList2String(data, 1) == "UPDATE" && llList2String(data, 2) == llGetKey() && llGetOwnerKey(id) == llGetOwner()) {
522 state update;
523 }
524 }
525 }
526 }
527
528 link_message(integer sender, integer num, string str, key id)
529 {
530 if(num == 903 || num == 904) {
531 hunger_amount = (integer)str;
532 if(hunger_amount > 30) {
533 state dead;
534 }
535 } else
536 if(num == 900) {
537 random_number2 = (integer)(llFrand(10000.0) + 1);
538 llSay(FOOD_CHANNEL, xtea_encrypt_string("XSPET^FOOD_CONSUME^" + (string)id + "^" + (string)random_number2 + "^" + (string)llGetKey()));
539 } else
540 if(num == 940) {
541 age += (integer)str;
542 } else
543 if(num == 950) {
544 llWhisper(0, "Looking for a cryo-crate...");
545 llSay(BOX_CHANNEL, xtea_encrypt_string("XSPET^" + (string)llGetKey() + "^CRATE_PING^" + (string)VERSION));
546 } else
547 if(num == 960) {
548 llSay(ANIMAL_CHANNEL, xtea_encrypt_string("XSPET^MALE_BREED_CALL^" + (string)llGetKey()));
549 } else
550 if(num == 962) {
551 llSay(ANIMAL_CHANNEL, xtea_encrypt_string("XSPET^FEMALE_ELIGIBLE^" + (string)home_loc));
552 } else
553 if(num == 964) {
554 llSay(ANIMAL_CHANNEL, xtea_encrypt_string("XSPET^MALE_ON_THE_WAY^" + (string)id));
555 } else
556 if(num == 968) {
557 llSay(ANIMAL_CHANNEL, xtea_encrypt_string("XSPET^MALE_INFO^" + (string)id + "^" + (string)colour1 + "^" + (string)colour2 + "^" + (string)shine + "^" + (string)glow + "^" + (string)gen + "^" + (string)glow_gene));
558 llMessageLinked(LINK_SET, 969, "", "");
559 } else
560 if(num == 970) {
561 // lay an egg
562 pregnancy_time = 0;
563 llRezObject("XS Egg", llGetPos() + <0.0, 0.0, 0.25>, ZERO_VECTOR, ZERO_ROTATION, SECRET_NUMBER);
564 } else
565 if(num == 971) {
566 llSay(ANIMAL_CHANNEL, xtea_encrypt_string("XSPET^BREEDING_FAIL^" + (string)id));
567 pregnancy_time = 0;
568 } else
569 if(num == 990) {
572 } else
573 if(num == 991) {
576 } else
577 if(num == 9999) {
578 state dead;
579 } else
580 if(num == 8000) {
581 llSetTimerEvent(llFrand(60.0) + (FOOD_BOWL_SCAN_INTERVAL - 30.0));
582 }
583 }
584
585 object_rez(key id)
586 {
587 new_egg_key = id;
588 }
589
590 on_rez(integer param)
591 {
592 if(param == SECRET_NUMBER) {
593 llSetText("Rezzing...", <1,0,0>, 1.0);
594 llMessageLinked(LINK_SET, 800, "", "");
595
596 llSleep(5.0);
597 if(llGetOwner() != YOUR_UUID) {
599 }
600 llSay(EGG_CHANNEL, xtea_encrypt_string("XSPET^READY^" + (string)llGetKey() + "^XSPET"));
601 llSay(BOX_CHANNEL, xtea_encrypt_string("XSPET^READY^" + (string)llGetKey() + "^XSPET"));
602 } else {
603 llOwnerSay("I died in your inventory, please use a cryo-crate next time.");
604 state dead;
605 }
606 }
607 }
608
609 state dead
610 {
612 {
613 llSetText("Dead", <1,0,0>, 1.0);
614 llRemoveInventory("xs_ager");
615 llRemoveInventory("xs_breeding");
616 llRemoveInventory("xs_eater");
617 llRemoveInventory("xs_infomatic");
618 llRemoveInventory("xs_movement");
619 if(llGetInventoryType("xs_special") != INVENTORY_NONE) {
620 llRemoveInventory("xs_special");
621 }
622 llListen(ANIMAL_CHANNEL, "", "", "");
623 }
624
625 touch_start(integer number)
626 {
627 llWhisper(0, "I've died. You could re-animate me with a jar of Xtra Strong Mojo");
628 if(llDetectedKey(0) == llGetOwner()) {
629 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));
630
631 }
632 }
633
634 listen(integer channel, string name, key id, string message) {
635 list data = llParseString2List(xtea_decrypt_string(message), ["^"], []);
636 if(llList2String(data, 0) == "XSPET") {
637 if(llList2String(data, 1) == "STRONG_MOJO_DIE" && llList2Key(data, 2) == llGetKey()) {
638 llDie();
639 }
640 }
641 }
642 }
643
644 state update
645 {
647 {
648 llSetText("Updating.", <1,0,0>, 1.0);
649 llRemoveInventory("Quail");
650 llRemoveInventory("XS Egg");
652 llShout(UPDATE_CHANNEL, "UPDATE_READY");
653 }
654
655 changed(integer change)
656 {
657 if(change & CHANGED_ALLOWED_DROP) {
660 llRezObject("Quail", llGetPos() + <0.0, 0.0, 0.25>, ZERO_VECTOR, ZERO_ROTATION, SECRET_NUMBER);
661 }
662 }
663
664 }
665 object_rez(key id)
666 {
667 llListen(BOX_CHANNEL, "", id, "");
668 }
669
670 listen(integer channel, string name, key id, string msg)
671 {
672 if(channel == BOX_CHANNEL) {
673 list data = llParseString2List(xtea_decrypt_string(msg), ["^"], []);
674 if(llList2String(data, 0) == "XSPET" && llList2String(data, 1) == "READY") {
675
676 llGiveInventory(id, "XS Egg");
677 llGiveInventory(id, "Quail");
678 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));
679 llDie();
680 }
681 }
682 }
683 }

XS Pet Xundra Snowpaw Original Quail

Original Pet Quail

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


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

XS Pet Xundra Snowpaw Original Quail

Original Pet Quail

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


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

1
2 integer SECONDS_BETWEEN_FOOD_NORMAL = 14400;
3 integer SECONDS_BETWEEN_FOOD_HUNGRY = 3600;
4
5 integer hunger_amount;
6 integer seconds_elapsed_normal;
7 integer seconds_elapsed_hungry;
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 hunger_amount = 0;
24 seconds_elapsed_normal = 0;
25 seconds_elapsed_hungry = 0;
26 llSetTimerEvent(1.0);
27 }
28
29 timer()
30 {
31 integer do_message = 0;
32
33 if(hunger_amount > 0) {
34 if(seconds_elapsed_hungry == SECONDS_BETWEEN_FOOD_HUNGRY) {
35 do_message = 1;
36 seconds_elapsed_hungry = 0;
37 } else {
38 seconds_elapsed_hungry++;
39 }
40 }
41
42 if(seconds_elapsed_normal == SECONDS_BETWEEN_FOOD_NORMAL) {
43 hunger_amount++;
44 seconds_elapsed_normal = 0;
45 } else {
46 seconds_elapsed_normal++;
47 }
48
49 if(do_message == 1) {
50 llMessageLinked(LINK_SET, 903, (string)hunger_amount, "");
51 }
52 }
53
54 link_message(integer sender, integer num, string str, key id)
55 {
56 if(num == 901) {
57 hunger_amount --;
58 } else
59 if(num == 904) {
60 hunger_amount = (integer)str;
61 }
62 }
63 }

XS Pet Xundra Snowpaw Original Quail

Original Pet Quail

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


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

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

XS Pet Xundra Snowpaw Original Quail

Original Pet Quail

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


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

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

XS Pet Xundra Snowpaw Original Quail

Original Pet Quail

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


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

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

XS Pet Xundra Snowpaw Original Quail

Original Pet Quail

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


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

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

XS Pet Xundra Snowpaw Original Quail

Original Pet Quail

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


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

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

XS Pet Xundra Snowpaw Original Quail

XS Pet

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


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

1
2
3 default
4 {
6 {
7 llRezObject("XS Egg",llGetPos() + <0,0,0.5>,<0,0,0>,<0,0,0,1>,1);
8 }
9 }

XS Pet Xundra Snowpaw Original Quail

Original Pet Quail

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


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

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

XS Pet Xundra Snowpaw Original Quail

Original Pet Quail

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


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

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

XS Pet Xundra Snowpaw Original Quail

Original Pet Quail

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


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

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

XS Pet Xundra Snowpaw Original Quail

Original Pet Quail

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


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

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

XS Pet Xundra Snowpaw Original Quail

Global constants and notes

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


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

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

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