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 Quail XS Pet Quail Modified  

XS Pet Quail Modified

XS Quail

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

the Zip file

Download all files for XS Pet Quail Modified
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Readme.txt
Get file # 2. bird assembly.lsl
Get file # 3. bird_sound.wav
Get file # 4. Test pregnancy script.lsl
Get file # 5. xs_ager.lsl
Get file # 6. xs_brain.lsl
Get file # 7. xs_breeding.lsl
Get file # 8. xs_eater.lsl
Get file # 9. xs_infomatic.lsl
Get file # 10. xs_movement.lsl
Get file # 11. xs_special.lsl
Get file # 12. Global constants and notes.txt
Get file # 13. xs_Debug.lsl
Get file # 14. xs_egg.lsl
Get file # 15. xs_eggcup.lsl
Get file # 16. [45941 bytes] bird food label.jpg
Get file # 17. [125790 bytes] Brushed_Steel_Texture_by_amdillon.jpg
Get file # 18. [73838 bytes] food texture for birdseed.jpg
Get file # 19. [906 bytes] food-bowl.png
Get file # 20. xs_foodbowl.lsl
Get file # 21. xs_foodbowl_anim.lsl
Get file # 22. [115881 bytes] bird feeder texture.jpg
Get file # 23. [1683 bytes] birdfeeder.png
Get file # 24. xs_home.lsl
Get file # 25. 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 // Version .24 10-3-2011
3
4 // script by Ferd Frederix
5 //
6
7 // New BSD License: http://www.opensource.org/licenses/bsd-license.php
8 // Copyright (c) 2010, Ferd Frederix
9 // All rights reserved.
10 //
11 // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
12
13 //* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
14 //* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
15
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
17 ////////////////////////////////////////////////////////////////////
18
19 default
20 {
22 {
23
24 float new_scale = 1.0;
25
26 vector new_size = <0.124, 0.082, 0.096> * new_scale;
27 vector new_pos;
28
30
31 // -> body -> tail <-0.032043,-0.000061,0.009560> 9
32
33 new_size = <0.082, 0.082, 0.082> * new_scale;
34 new_pos = <-0.032043,-0.000061,0.009560> * new_scale;
35 llSetLinkPrimitiveParams(9, [PRIM_SIZE, new_size, PRIM_POSITION, new_pos]);
36
37 // -> body -> left wing <-0.004141,0.034098,0.008184> 7
38 new_size = <0.058, 0.079, 0.023> * new_scale;
39 new_pos = <-0.004141,0.034098,0.008184> * new_scale;
40
41 llSetLinkPrimitiveParams(7, [PRIM_SIZE, new_size, PRIM_POSITION, new_pos]);
42
43 // -> body -> right wing <-0.011113,-0.034257,0.008841> 4
44 new_size = <0.058, 0.079, 0.023> * new_scale;
45 new_pos = <-0.011113,-0.034257,0.008841> * new_scale;
46
47 llSetLinkPrimitiveParams(4, [PRIM_SIZE, new_size, PRIM_POSITION, new_pos]);
48
49 // -> body -> left leg <0.009700,0.020261,-0.052318> 6
50 new_size = <0.01, 0.01, 0.064> * new_scale;
51 new_pos = <0.009700,0.020261,-0.052318> * new_scale;
52
53 llSetLinkPrimitiveParams(6, [PRIM_SIZE, new_size, PRIM_POSITION, new_pos]);
54
55 // -> body -> right leg <0.009747,-0.022943,-0.052399> 10
56 new_size = <0.01, 0.01, 0.064> * new_scale;
57 new_pos = <0.009747,-0.022943,-0.052399> * new_scale;
58
59 llSetLinkPrimitiveParams(10, [PRIM_SIZE, new_size, PRIM_POSITION, new_pos]);
60
61 // -> body -> head <0.042349,-0.000059,0.055298> 5
62 new_size = <0.082, 0.082, 0.082> * new_scale;
63 new_pos = <0.042349,-0.000059,0.055298> * new_scale;
64
65 llSetLinkPrimitiveParams(5, [PRIM_SIZE, new_size, PRIM_POSITION, new_pos]);
66 // -> body -> head -> left eye <0.067205,0.018735,0.070143> 8
67 new_size = <0.024, 0.024, 0.024> * new_scale;
68 new_pos = <0.067205,0.018735,0.070143> * new_scale;
69
70 llSetLinkPrimitiveParams(8, [PRIM_SIZE, new_size, PRIM_POSITION, new_pos]);
71
72 // -> body -> head -> right eye <0.067265,-0.017552,0.070217> 3
73 new_size = <0.024, 0.024, 0.024> * new_scale;
74 new_pos = <0.067265,-0.017552,0.070217> * new_scale;
75
76 llSetLinkPrimitiveParams(3, [PRIM_SIZE, new_size, PRIM_POSITION, new_pos]);
77
78 // -> body -> head -> beak <0.086439,-0.000059,0.049794> 2
79 new_size = <0.043, 0.043, 0.043> * new_scale;
80 new_pos = <0.086439,-0.000059,0.049794> * new_scale;
81
82 llSetLinkPrimitiveParams(2, [PRIM_SIZE, new_size, PRIM_POSITION, new_pos]);
83 }
84
85 }

XS Pet Quail Modified

Modified Pet Quail

Category: XS Quail
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 // Version .24 10-3-2011
3
4 // script by Ferd Frederix
5 //
6
7 // New BSD License: http://www.opensource.org/licenses/bsd-license.php
8 // Copyright (c) 2010, Ferd Frederix
9 // All rights reserved.
10 //
11 // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
12
13 //* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
14 //* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
15
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
17 ////////////////////////////////////////////////////////////////////
18
19
20
21 ///// GLOBAL LINK CONSTANTS extracted from original source //////
22 ///
23 // if you change anything, you change it everywhere and in a list in XS_Debug
24 ///
25
26 integer LINK_AGE_START = 800; // when quail is rezzed and secret_number, is sent by brain to breeder, eater and informatic get booted up
27 integer LINK_FOOD_CONSUME = 900; // from movement to brain when close to food, brain then consumes a random amount up to 10000
28 integer LINK_FOODMINUS = 901; // xs_brain receives FOOD_CONSUME, decrement hunger (eat)
29 integer LINK_HUNGRY = 903; // sent by eater (string)hunger_amount, checks each hour
30 integer LINK_HAMOUNT = 904; // hunger_amount = (integer)str,m updates the hunger amount in scripts
31 integer LINK_SET_HOME = 910; // loc ^ dist
32 integer LINK_MOVER = 911; // tell mover to rest for str seconds
33 integer LINK_FOODIE_CLR = 920; // clear all food_bowl_keys and contents
34 integer LINK_FOODIE = 921; // send FOOD_LOCATION coordinates to movement
35 integer LINK_COLOR1 = 930; // colour1
36 integer LINK_COLOR2 = 931; // colour2
37 integer LINK_SEX = 932; // sex
38 integer LINK_SHINE = 933; // shine
39 integer LINK_GLOW = 934; // glow
40 integer LINK_GEN = 935; // generation
41 integer LINK_MAGE = 940; // xs_brain sends, xs_ager consumes, adds str to age, if older than 7 days, will grow the animal
42 integer LINK_DAYTIME = 941; // xs_ager consumes, starts a timer of 86,400 seconds in xs_ager
43 integer LINK_GET_AGE = 942; // get age from xs_ager and sent it on channel 943
44 integer LINK_PUT_AGE = 943; // print age from xs_ager
45 integer LINK_PACKAGE = 950; // look for a cryo_crate
46 integer LINK_SEEK_FEMALE = 960; // MALE_BREED_CALL
47 integer LINK_MALE_BREED_CALL = 961; // triggered by LINK_SEEK_FEMALE
48 integer LINK_SIGNAL_ELIGIBLE = 962; // sent by female when hears LINK_MALE_BREED_CALL
49 integer LINK_FEMALE_ELIGIBLE = 963; // sent when it hears in chat FEMALE_ELIGIBLE
50 integer LINK_CALL_MALE = 964; // if LINK_FEMALE_ELIGIBLE && looking_for_female
51 integer LINK_MALE_ON_THE_WAY = 965; // triggered by LINK_CALL_MALE
52 integer LINK_FEMALE_LOCATION = 966; // female location, sends coordinates of a female
53 integer LINK_RQST_BREED = 967; // sent when close enough to male/female
54 integer LINK_CALL_MALE_INFO = 968; // ****** BUG ***** read, but never sent by anybody!!!!!
55 // see line 557 and 636 of xs_brain which make calls and also xs_breeding which receives LUNK_MALE_INFO.
56 integer LINK_MALE_INFO = 969;
57 integer LINK_LAY_EGG = 970; // llRezObject("XS Egg"
58 integer LINK_BREED_FAIL = 971; // key = father, failed, timed out
59 integer LINK_PREGNANT = 972; // chick is preggers
60 integer LINK_SLEEPING = 990; // close eyes
61 integer LINK_UNSLEEPING = 991; // open eyes
62 integer LINK_SOUND = 1001; // plays a sound if enabled
63 integer LINK_SPECIAL = 1010; // xs_special, is str = "Normal", removes script
64 integer LINK_PREGNANCY_TIME = 5000; // in seconds as str
65 integer LINK_SLEEP = 7999; // disable sleep by parameter
66 integer LINK_TIMER = 8000; // scan for food bowl about every 1800 seconds
67 integer LINK_DIE = 9999; // death
68
69 ///////// end global Link constants ////////
70
71 // END //
72
73
74 default
75 {
77 {
78 llMessageLinked(LINK_SET,LINK_SEX,"0",""); // make it into a female
79 llSleep(1);
80
81 llMessageLinked(LINK_SET,LINK_PUT_AGE,"8",""); // 8 days old
82 llSleep(1);
83
84 llMessageLinked(LINK_SET,LINK_SIGNAL_ELIGIBLE,"",""); // signal I am eligible
85 llSleep(1);
86
87 llMessageLinked(LINK_SET,LINK_MALE_ON_THE_WAY,"",""); // male on the way
88 llSleep(1);
89
90
91 integer times = llGetUnixTime() - 10; // make an egg in 10 seconds
92
93 llMessageLinked(LINK_SET,LINK_PREGNANCY_TIME,(string) times,""); // set preg time to 1
94
95
96 llMessageLinked(LINK_SET,LINK_PREGNANT,"8",""); // pregnant
97 llSleep(1);
98
99
100 }
101 }

XS Pet Quail Modified

XS Pet Modified Ager script

Category: XS Quail
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 // DESCRIPTION:
2 // Modified Pet Quail
3 // Version .24 10-3-2011
4
5 // script by Xundra Snowpaw
6 // mods by Ferd Frederix
7 // Allows arbitrary growth without any constants or prim limits
8 // 2 tunable parameters for aging time and maximum growth time
9
10 //
11 // New BSD License: http://www.opensource.org/licenses/bsd-license.php
12 // Copyright (c) 2010, Xundra Snowpaw
13 // All rights reserved.
14 //
15 // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
16
17 //* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
18 //* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
19
20 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
21 ////////////////////////////////////////////////////////////////////
22
23 // tunables - you can modify these based on your pet
24
25 float secs_to_grow = 86400; // grow daily = 86400
26 integer MAX = 7; // gorw for 7 days, then stop
27
28 ///// GLOBAL LINK CONSTANTS extracted from original source //////
29 ///
30 // if you change anything, you change it everywhere and in a list in XS_Debug
31 ///
32
33 integer LINK_AGE_START = 800; // when quail is rezzed and secret_number, is sent by brain to breeder, eater and informatic get booted up
34 integer LINK_FOOD_CONSUME = 900; // from movement to brain when close to food, brain then consumes a random amount up to 10000
35 integer LINK_FOODMINUS = 901; // xs_brain receives FOOD_CONSUME, decrement hunger (eat)
36 integer LINK_HUNGRY = 903; // sent by eater (string)hunger_amount, checks each hour
37 integer LINK_HAMOUNT = 904; // hunger_amount = (integer)str,m updates the hunger amount in scripts
38 integer LINK_SET_HOME = 910; // loc ^ dist
39 integer LINK_MOVER = 911; // tell mover to rest for str seconds
40 integer LINK_FOODIE_CLR = 920; // clear all food_bowl_keys and contents
41 integer LINK_FOODIE = 921; // send FOOD_LOCATION coordinates to movement
42 integer LINK_COLOR1 = 930; // colour1
43 integer LINK_COLOR2 = 931; // colour2
44 integer LINK_SEX = 932; // sex
45 integer LINK_SHINE = 933; // shine
46 integer LINK_GLOW = 934; // glow
47 integer LINK_GEN = 935; // generation
48 integer LINK_RESET_SIZE = 936; // reset size to 1
49 integer LINK_MAGE = 940; // xs_brain sends, xs_ager consumes, adds str to age, if older than 7 days, will grow the animal
50 integer LINK_DAYTIME = 941; // xs_ager consumes, starts a timer of 86,400 seconds in xs_ager
51 integer LINK_GET_AGE = 942; // get age from xs_ager and sent it on channel 943
52 integer LINK_PUT_AGE = 943; // print age from xs_ager
53 integer LINK_PACKAGE = 950; // look for a cryo_crate
54 integer LINK_SEEK_FEMALE = 960; // MALE_BREED_CALL
55 integer LINK_MALE_BREED_CALL = 961; // triggered by LINK_SEEK_FEMALE
56 integer LINK_SIGNAL_ELIGIBLE = 962; // sent by female when hears LINK_MALE_BREED_CALL
57 integer LINK_FEMALE_ELIGIBLE = 963; // sent when it hears in chat FEMALE_ELIGIBLE
58 integer LINK_CALL_MALE = 964; // if LINK_FEMALE_ELIGIBLE && looking_for_female
59 integer LINK_MALE_ON_THE_WAY = 965; // triggered by LINK_CALL_MALE
60 integer LINK_FEMALE_LOCATION = 966; // female location, sends coordinates of a female
61 integer LINK_RQST_BREED = 967; // sent when close enough to male/female
62 integer LINK_CALL_MALE_INFO = 968; // ****** BUG ***** read, but never sent by anybody!!!!!
63 // see line 557 and 636 of xs_brain which make calls and also xs_breeding which receives LINK_MALE_INFO.
64 integer LINK_MALE_INFO = 969;
65 integer LINK_LAY_EGG = 970; // llRezObject("XS Egg"
66 integer LINK_BREED_FAIL = 971; // key = father, failed, timed out
67 integer LINK_PREGNANT = 972; // chick is preggers
68 integer LINK_SLEEPING = 990; // close eyes
69 integer LINK_UNSLEEPING = 991; // open eyes
70 integer LINK_SOUND = 1001; // plays a sound if enabled
71 integer LINK_SPECIAL = 1010; // xs_special, is str = "Normal", removes script
72 integer LINK_PREGNANCY_TIME = 5000; // in seconds as str
73 integer LINK_SLEEP = 7999; // disable sleep by parameter
74 integer LINK_TIMER = 8000; // scan for food bowl about every 1800 seconds
75 integer LINK_DIE = 9999; // death
76 ///////// end global Link constants ////////
77
78 // END //
79
80 integer debug = FALSE;
81
82 integer age; // age in days
83 float GROWTH_AMOUNT = 0.10; // 10% size increase
84
85 DEBUG(string msg)
86 {
87 if(debug)
88 llOwnerSay(llGetScriptName() + " : " + msg);
89 }
90
91
92
93
94 float cur_scale = 1.0;
95
96
97 list link_scales = [];
98 list link_positions = [];
99
100
101
102 integer scanLinkset()
103 {
104 integer link_qty = llGetNumberOfPrims();
105 integer link_idx;
106 vector link_pos;
107 vector link_scale;
108
109 //script made specifically for linksets, not for single prims
110 if(link_qty > 1)
111 {
112 //link numbering in linksets starts with 1
113 for (link_idx=1; link_idx <= link_qty; link_idx++)
114 {
115 link_pos=llList2Vector(llGetLinkPrimitiveParams(link_idx,[PRIM_POSITION]),0);
116 link_scale=llList2Vector(llGetLinkPrimitiveParams(link_idx,[PRIM_SIZE]),0);
117
118 link_scales += [link_scale];
119 link_positions += [(link_pos-llGetRootPosition())/llGetRootRotation()];
120 }
121 }
122 else
123 {
124 llOwnerSay("error: this script doesn't work for non-linked objects");
125 return FALSE;
126 }
127
128
129 return TRUE;
130 }
131
132 resizeObject(float scale)
133 {
134 integer link_qty = llGetNumberOfPrims();
135 integer link_idx;
136 vector new_size;
137 vector new_pos;
138
139 if(link_qty > 1)
140 {
141 //link numbering in linksets starts with 1
142 for (link_idx=1; link_idx <= link_qty; link_idx++)
143 {
144 new_size = scale * llList2Vector(link_scales, link_idx-1);
145 new_pos = scale * llList2Vector(link_positions, link_idx-1);
146
147 if(link_idx == 1)
148 {
149 //because we don't really want to move the root prim as it moves the whole object
150 llSetLinkPrimitiveParamsFast(link_idx, [PRIM_SIZE, new_size]);
151 }
152 else
153 {
154 llSetLinkPrimitiveParamsFast(link_idx, [PRIM_SIZE, new_size, PRIM_POSITION, new_pos]);
155 }
156 }
157 }
158 }
159
160 default
161 {
163 {
164 scanLinkset();
165 }
166
167
168 link_message(integer sender, integer num, string str, key id)
169 {
170 if(num == LINK_AGE_START) {
171 state running;
172 }
173 }
174 }
175
176
177
178
179
180
181 state running
182 {
184 {
185 age = 0;
186 }
187
188
189 timer()
190 {
191 llMessageLinked(LINK_SET, LINK_MAGE, "1", "");
192 }
193
194 link_message(integer sender, integer num, string str, key id)
195 {
196 if(num == LINK_GET_AGE) {
197 llMessageLinked(LINK_SET, LINK_PUT_AGE, (string)age, "");
198 } else
199 if(num == LINK_DAYTIME) {
200 llSetTimerEvent(secs_to_grow); // 86400.0
201 } else
202 if(num == LINK_RESET_SIZE)
203 {
204 cur_scale = 1.0;
205 resizeObject(cur_scale);
206 age = 0;
207 }
208 if(num == LINK_MAGE) {
209 integer prev_age = age;
210 integer size_age;
211
212 age += (integer) str; // add 1, typically
213
214 if(prev_age == 0 && age > MAX) {
215 size_age = MAX;
216 } else {
217 size_age = age;
218 }
219
220 if(size_age > 0 && size_age <= 7) {
221 // grow to the correct proportion
222
223 llMessageLinked(LINK_SET, LINK_MOVER, "1", ""); // tell mover to rest for 5 seconds
224
225
226 cur_scale = cur_scale * (GROWTH_AMOUNT + 1.0); // new size is 110%, 120%, etc of the original size
227 DEBUG("Growing " + (string) cur_scale);
228
229 resizeObject(cur_scale);
230
231 }
232 }
233 }
234 }

XS Pet Quail Modified

Modified Pet Quail

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

XS Pet Quail Modified

Modified Pet Quail

Category: XS Quail
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 // Version .25 12-15-2011
3 // revision history
4 // xs_breeding: LINK_CALL_MALE_INFO was in error on line 159, was LINK_CALL_MALE, should be LINK_CALL_MALE_INFO
5
6 // script by Xundra Snowpaw
7 // mods by Ferd Frederix
8 //
9 // New BSD License: http://www.opensource.org/licenses/bsd-license.php
10 // Copyright (c) 2010, Xundra Snowpaw
11 // All rights reserved.
12 //
13 // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
14
15 //* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
16 //* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
17
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
19 ////////////////////////////////////////////////////////////////////
20
21
22 ///// GLOBAL LINK CONSTANTS extracted from original source //////
23 ///
24 // if you change anything, you change it everywhere and in a list in XS_Debug
25 ///
26
27 integer LINK_AGE_START = 800; // when quail is rezzed and secret_number, is sent by brain to breeder, eater and informatic get booted up
28 integer LINK_FOOD_CONSUME = 900; // from movement to brain when close to food, brain then consumes a random amount up to 10000
29 integer LINK_FOODMINUS = 901; // xs_brain receives FOOD_CONSUME, decrement hunger (eat)
30 integer LINK_HUNGRY = 903; // sent by eater (string)hunger_amount, checks each hour
31 integer LINK_HAMOUNT = 904; // hunger_amount = (integer)str,m updates the hunger amount in scripts
32 integer LINK_SET_HOME = 910; // loc ^ dist
33 integer LINK_MOVER = 911; // tell mover to rest for str seconds
34 integer LINK_FOODIE_CLR = 920; // clear all food_bowl_keys and contents
35 integer LINK_FOODIE = 921; // send FOOD_LOCATION coordinates to movement
36 integer LINK_COLOR1 = 930; // colour1
37 integer LINK_COLOR2 = 931; // colour2
38 integer LINK_SEX = 932; // sex
39 integer LINK_SHINE = 933; // shine
40 integer LINK_GLOW = 934; // glow
41 integer LINK_GEN = 935; // generation
42 integer LINK_MAGE = 940; // xs_brain sends, xs_ager consumes, adds str to age, if older than 7 days, will grow the animal
43 integer LINK_DAYTIME = 941; // xs_ager consumes, starts a timer of 86,400 seconds in xs_ager
44 integer LINK_GET_AGE = 942; // get age from xs_ager and sent it on channel 943
45 integer LINK_PUT_AGE = 943; // print age from xs_ager
46 integer LINK_PACKAGE = 950; // look for a cryo_crate
47 integer LINK_SEEK_FEMALE = 960; // MALE_BREED_CALL
48 integer LINK_MALE_BREED_CALL = 961; // triggered by LINK_SEEK_FEMALE
49 integer LINK_SIGNAL_ELIGIBLE = 962; // sent by female when hears LINK_MALE_BREED_CALL
50 integer LINK_FEMALE_ELIGIBLE = 963; // sent when it hears in chat FEMALE_ELIGIBLE
51 integer LINK_CALL_MALE = 964; // if LINK_FEMALE_ELIGIBLE && looking_for_female
52 integer LINK_MALE_ON_THE_WAY = 965; // triggered by LINK_CALL_MALE
53 integer LINK_FEMALE_LOCATION = 966; // female location, sends coordinates of a female
54 integer LINK_RQST_BREED = 967; // sent when close enough to male/female
55 integer LINK_CALL_MALE_INFO = 968; // ****** BUG ***** read, but never sent by anybody!!!!!
56 // see line 557 and 636 of xs_brain which make calls and also xs_breeding which receives LUNK_MALE_INFO.
57 integer LINK_MALE_INFO = 969;
58 integer LINK_LAY_EGG = 970; // llRezObject("XS Egg"
59 integer LINK_BREED_FAIL = 971; // key = father, failed, timed out
60 integer LINK_PREGNANT = 972; // chick is preggers
61 integer LINK_SLEEPING = 990; // close eyes
62 integer LINK_UNSLEEPING = 991; // open eyes
63 integer LINK_SOUND = 1001; // plays a sound if enabled
64 integer LINK_SPECIAL = 1010; // xs_special, is str = "Normal", removes script
65 integer LINK_PREGNANCY_TIME = 5000; // in seconds as str
66 integer LINK_SLEEP = 7999; // disable sleep by parameter
67 integer LINK_TIMER = 8000; // scan for food bowl about every 1800 seconds
68 integer LINK_DIE = 9999; // death
69
70 ///////// end global Link constants ////////
71
72 // END //
73
74 integer age;
75 integer looking_for_female;
76
77 key father;
78 key mother;
79
80 integer preg_time;
81
82 default
83 {
84 link_message(integer sender, integer num, string str, key id)
85 {
86 if(num == LINK_AGE_START) {
87 state running;
88 }
89 }
90 }
91
92 state running
93 {
95 {
96 age = 0;
97 }
98
99 link_message(integer sender, integer num, string str, key id)
100 {
101 if(num == LINK_SEX) {
102 if(str == "1") {
103 state male;
104 } else {
105 state female;
106 }
107 } else
108 if(num == LINK_MAGE) {
109 age += (integer)str;
110 } else
111 if(num == LINK_PREGNANCY_TIME) {
112 preg_time = (integer)str;
113 if(preg_time != 0) {
114 state pregnant;
115 } else {
116 state female;
117 }
118 }
119 }
120 }
121
122 state male
123 {
125 {
126 looking_for_female = 0;
127
128 mother = NULL_KEY;
129 father = NULL_KEY;
130
131 llMessageLinked(LINK_SET, LINK_GET_AGE, "", "");
132
133 if(age >= 7) {
134 llSetTimerEvent(10800.0);
135 }
136 }
137 link_message(integer sender, integer num, string str, key id)
138 {
139 if(num == LINK_PUT_AGE) {
140 age = (integer)str;
141 if(age >= 7) {
142 llSetTimerEvent(10800.0);
143 }
144 } else
145 if(num == LINK_MAGE) {
146
147 age += (integer)str;
148 if(age >= 7) {
149 llSetTimerEvent(10800.0);
150 }
151 } else
152 if(num == LINK_FEMALE_ELIGIBLE) {
153 if(looking_for_female == 1) {
154 looking_for_female = 0;
155 mother = id;
156 father = llGetKey();
157 llMessageLinked(LINK_SET, LINK_CALL_MALE, "", mother);
158 }
159 } else
160 if(num == LINK_RQST_BREED) {
161 if(mother != NULL_KEY) {
162 llMessageLinked(LINK_SET, LINK_CALL_MALE_INFO, "", mother); // error by Ferd, was LINK_CALL-MALE, should be LINK_CALL_MALE_INFO
163 }
164 } else
165 if(num == LINK_MALE_INFO) {
166 state male;
167 }
168
169 }
170
171 timer()
172 {
173 looking_for_female = 1;
174 // look for an eligible female.
175 llWhisper(0, llGetObjectName() + " gets a gleam in his eye.");
176 llMessageLinked(LINK_SET, LINK_SEEK_FEMALE, "", "");
177 }
178 }
179
180 state female
181 {
183 {
184 mother = NULL_KEY;
185 father = NULL_KEY;
186
187 if(age == 0) {
188 llMessageLinked(LINK_SET, LINK_GET_AGE, "", "");
189 }
190 }
191
192 link_message(integer sender, integer num, string str, key id)
193 {
194 if(num == LINK_MAGE) {
195 age += (integer)str;
196 } else
197 if(num == LINK_MALE_BREED_CALL) {
198 // signal I am eligible
199 if(age >= 7 && father == NULL_KEY) {
200 llWhisper(0, llGetObjectName() + " blushes then bobs her head up and down.");
201 llMessageLinked(LINK_SET, LINK_SIGNAL_ELIGIBLE, "", "");
202 }
203 } else
204 if(num == LINK_MALE_ON_THE_WAY) {
205 // male on the way, rest for 20m
206 llSetTimerEvent(900.0);
207 father = id;
208 mother = llGetKey();
209 llMessageLinked(LINK_SET, LINK_MOVER, "1200", "");
210 } else
211 if(num == LINK_PREGNANT) {
212 // pregnant
214 preg_time = 0;
215 state pregnant;
216 } else
217 if(num == LINK_MALE_INFO) {
219 state female;
220 } else
221 if(num == LINK_PUT_AGE) {
222 age = (integer)str;
223 } else
224 if(num == LINK_PREGNANCY_TIME) {
225 preg_time = (integer)str;
226 if(preg_time != 0) {
227 state pregnant;
228 }
229 }
230
231 }
232
233 timer()
234 {
236 // fail
237 llMessageLinked(LINK_SET, LINK_BREED_FAIL, "", father);
238 state female;
239 }
240 }
241
242 state pregnant
243 {
245 {
246 if(preg_time != 0) {
247 llSetTimerEvent(172800.0 - (float)(llGetUnixTime() - preg_time));
248 } else {
249 llSetTimerEvent(172800.0);
250 }
251 }
252 timer()
253 {
254 // lay egg.
256 llMessageLinked(LINK_SET, LINK_LAY_EGG, "", "");
257 state female;
258 }
259 }

XS Pet Quail Modified

Modified Pet Quail

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

XS Pet Quail Modified

Modified Pet Quail

Category: XS Quail
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 // Version .24 10-3-2011
3
4 // script by Xundra Snowpaw
5 // mods by Ferd Frederix
6 //
7 // New BSD License: http://www.opensource.org/licenses/bsd-license.php
8 // Copyright (c) 2010, Xundra Snowpaw
9 // All rights reserved.
10 //
11 // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
12
13 //* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
14 //* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
15
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
17 ////////////////////////////////////////////////////////////////////
18
19
20 ///// GLOBAL LINK CONSTANTS extracted from original source //////
21 ///
22 // if you change anything, you change it everywhere and in a list in XS_Debug
23 ///
24
25 integer LINK_AGE_START = 800; // when quail is rezzed and secret_number, is sent by brain to breeder, eater and informatic get booted up
26 integer LINK_FOOD_CONSUME = 900; // from movement to brain when close to food, brain then consumes a random amount up to 10000
27 integer LINK_FOODMINUS = 901; // xs_brain receives FOOD_CONSUME, decrement hunger (eat)
28 integer LINK_HUNGRY = 903; // sent by eater (string)hunger_amount, checks each hour
29 integer LINK_HAMOUNT = 904; // hunger_amount = (integer)str,m updates the hunger amount in scripts
30 integer LINK_SET_HOME = 910; // loc ^ dist
31 integer LINK_MOVER = 911; // tell mover to rest for str seconds
32 integer LINK_FOODIE_CLR = 920; // clear all food_bowl_keys and contents
33 integer LINK_FOODIE = 921; // send FOOD_LOCATION coordinates to movement
34 integer LINK_COLOR1 = 930; // colour1
35 integer LINK_COLOR2 = 931; // colour2
36 integer LINK_SEX = 932; // sex
37 integer LINK_SHINE = 933; // shine
38 integer LINK_GLOW = 934; // glow
39 integer LINK_GEN = 935; // generation
40 integer LINK_MAGE = 940; // xs_brain sends, xs_ager consumes, adds str to age, if older than 7 days, will grow the animal
41 integer LINK_DAYTIME = 941; // xs_ager consumes, starts a timer of 86,400 seconds in xs_ager
42 integer LINK_GET_AGE = 942; // get age from xs_ager and sent it on channel 943
43 integer LINK_PUT_AGE = 943; // print age from xs_ager
44 integer LINK_PACKAGE = 950; // look for a cryo_crate
45 integer LINK_SEEK_FEMALE = 960; // MALE_BREED_CALL
46 integer LINK_MALE_BREED_CALL = 961; // triggered by LINK_SEEK_FEMALE
47 integer LINK_SIGNAL_ELIGIBLE = 962; // sent by female when hears LINK_MALE_BREED_CALL
48 integer LINK_FEMALE_ELIGIBLE = 963; // sent when it hears in chat FEMALE_ELIGIBLE
49 integer LINK_CALL_MALE = 964; // if LINK_FEMALE_ELIGIBLE && looking_for_female
50 integer LINK_MALE_ON_THE_WAY = 965; // triggered by LINK_CALL_MALE
51 integer LINK_FEMALE_LOCATION = 966; // female location, sends coordinates of a female
52 integer LINK_RQST_BREED = 967; // sent when close enough to male/female
53 integer LINK_CALL_MALE_INFO = 968; // ****** BUG ***** read, but never sent by anybody!!!!!
54 // see line 557 and 636 of xs_brain which make calls and also xs_breeding which receives LUNK_MALE_INFO.
55 integer LINK_MALE_INFO = 969;
56 integer LINK_LAY_EGG = 970; // llRezObject("XS Egg"
57 integer LINK_BREED_FAIL = 971; // key = father, failed, timed out
58 integer LINK_PREGNANT = 972; // chick is preggers
59 integer LINK_SLEEPING = 990; // close eyes
60 integer LINK_UNSLEEPING = 991; // open eyes
61 integer LINK_SOUND = 1001; // plays a sound if enabled
62 integer LINK_SPECIAL = 1010; // xs_special, is str = "Normal", removes script
63 integer LINK_PREGNANCY_TIME = 5000; // in seconds as str
64 integer LINK_SLEEP = 7999; // disable sleep by parameter
65 integer LINK_TIMER = 8000; // scan for food bowl about every 1800 seconds
66 integer LINK_DIE = 9999; // death
67
68 ///////// end global Link constants ////////
69
70 // END //
71
72
73
74 integer API_CHANNEL = -999198;
75 integer MAXIMUM_HUNGER = 30;
76 integer ANIMAL_CHANNEL = -999192;
77
78
79 integer hunger_amount;
80 //integer eaten;
81
82 vector colour1;
83 vector colour2;
84
85 integer sex;
86
87 integer shine;
88 float glow;
89
90 string pregnant;
91 string sleep;
92
93 integer gen;
94
95 integer name_listener;
96 integer menu_listener;
97
98 integer age;
99 integer play_sounds;
100 string special;
101 integer menu_expired;
102 integer sleep_disabled;
103
104 say_details()
105 {
106
107 string mysex;
108 string myshine;
109 if(sex == 1) {
110 mysex = "Male";
111 } else
112 if(sex == 2) {
113 mysex = "Female";
114 } else {
115 mysex = (string)sex;
116 }
117
118 if(shine == 0) {
119 myshine = "None";
120 } else
121 if(shine == 1) {
122 myshine = "Low";
123 } else
124 if(shine == 2) {
125 myshine = "Medium";
126 } else
127 if(shine == 3) {
128 myshine = "High";
129 }
130
131 llWhisper(0, "Head/Body Colour: " + (string)colour1);
132 llWhisper(0, "Tail/Wing Colour: " + (string)colour2);
133 llWhisper(0, "Shine: " + myshine);
134 llWhisper(0, "Glow: " + (string)((integer)(glow * 100)) + "%");
135 llWhisper(0, "Special: " + special);
136 llWhisper(0, "Sex: " + mysex);
137 llWhisper(0, "Age: " + (string)age + " days");
138 llWhisper(0, "Generation: " + (string)gen);
139
140 llSay(API_CHANNEL, "XSQuail^" + (string)llGetKey() + "^" + (string)colour1 + "^" + (string)colour2 + "^" + (string)shine + "^" + (string)glow + "^" + special + "^" + (string)gen + "^" + (string)sex + "^" + (string)age + "^XSQuailEnd");
141 }
142
143 default
144 {
145 link_message(integer sender, integer num, string str, key id)
146 {
147 if(num == LINK_AGE_START) {
148 state running;
149 }
150 }
151 }
152
153 state running
154 {
156 {
157 hunger_amount = 0;
158 age = 0;
159 pregnant = "";
160 play_sounds = 1;
161 llListen(API_CHANNEL, "", "", "");
162 }
163
164 touch_start(integer total_number)
165 {
166 string mysex;
167 if(sex == 1) {
168 mysex = "Male";
169 } else
170 if(sex == 2) {
171 mysex = "Female";
172 } else {
173 mysex = (string)sex;
174 }
175
176 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);
177
178 say_details();
179
180
181 menu_expired = 0;
182
183 if(llDetectedKey(0) == llGetOwner()) {
184 integer menu_chan = (integer)llFrand(10000.0) + 100;
185 llListenRemove(menu_listener);
186 menu_listener = llListen(menu_chan, "", llGetOwner(), "");
187
188
189 menu_expired = 1;
190
191 }
192 llSetTimerEvent(30.0);
193 }
194
195 timer()
196 {
197 llListenRemove(menu_listener);
198 llListenRemove(name_listener);
199 llSetTimerEvent(0.0);
200 llSetText("", <1,1,1>, 1.0);
201 if(menu_expired) {
202 llWhisper(0, "Menu Expired");
203 menu_expired = 0;
204 }
205 }
206
207 link_message(integer sender, integer num, string str, key id)
208 {
209 if(num == LINK_HUNGRY || num == LINK_HAMOUNT) {
210 hunger_amount = (integer)str;
211 } else
212 if(num == LINK_FOODMINUS) {
213 hunger_amount --;
214 //eaten ++;
215 } else
216 if(num == LINK_COLOR1) {
217 colour1 = (vector)str;
218 } else
219 if(num == LINK_COLOR2) {
220 colour2 = (vector)str;
221 } else
222 if(num == LINK_SEX) {
223 sex = (integer)str;
224 } else
225 if(num == LINK_SHINE) {
226 shine = (integer)str;
227 } else
228 if(num == LINK_GLOW) {
229 glow = (float)str;
230 } else
231 if(num == LINK_GEN) {
232 gen = (integer)str;
233 } else
234 if(num == LINK_MAGE) {
235 age += (integer)str;
236 } else
237 if(num == LINK_PREGNANT) {
238 pregnant = "Pregnant";
239 llSay(API_CHANNEL, "I'm Pregnant!");
240 } else
241 if(num == LINK_PREGNANCY_TIME) {
242 sex = 2;
243 if((integer)str != 0) {
244 pregnant = "Pregnant";
245 }
246 } else
247 if(num == LINK_LAY_EGG) {
248 pregnant = "";
249 } else
250 if(num == LINK_SLEEPING) {
251 sleep = "\nSleeping";
252 } else
253 if(num == LINK_UNSLEEPING) {
254 sleep = "";
255 } else
256 if(num == LINK_SOUND) {
257 if(play_sounds) {
258 llPlaySound("bird_sound", 1.0);
259 }
260 } else
261 if(num == LINK_SPECIAL) {
262 special = str;
263 }
264 //
265 if(num == LINK_SET_HOME) {
266 list data = llParseString2List(str, ["^"], []);
267 llSetText("Home Set: " + llList2String(data, 0) + " " + llList2String(data, 1) + "m", <1,1,1>, 1.0);
268 llSetTimerEvent(15.0);
269 }
270 }
271 listen(integer channel, string name, key id, string msg)
272 {
273 if(channel == 0 && id == llGetOwner()) {
274 list name_parts = llParseString2List(msg, [","], []);
275 if(llToLower(llList2String(name_parts, 0)) == "name") {
276 string myname = llStringTrim(llList2String(name_parts, 1), STRING_TRIM);
277
278 integer i;
279
280 for (i=0;i<llStringLength(myname);i++) {
281 if(llGetSubString(myname, i, i) == "^") {
282 llWhisper(0, "Sorry, cannot have a \"^\" in the name.");
283 llListenRemove(name_listener);
284 return;
285 }
286 }
287
288 llWhisper(0, "My new name is " + myname);
289 llSetObjectName(myname);
290 llListenRemove(name_listener);
291 }
292 } else if(channel == API_CHANNEL) {
293 list data = llParseString2List(msg, ["^"], []);
294 if(llList2String(data, 0) == "XSQuail" && llList2Key(data, 1) == llGetKey()) {
295 llSay(API_CHANNEL, "XSQuail^" + (string)llGetKey() + "^" + (string)colour1 + "^" + (string)colour2 + "^" + (string)shine + "^" + (string)glow + "^" + special + "^" + (string)gen + "^" + (string)sex + "^" + (string)age + "^XSQuailEnd");
296 }
297 } else if(channel != ANIMAL_CHANNEL) {
298 llListenRemove(menu_listener);
299 menu_expired = 0;
300 if(msg == "Name") {
301 name_listener = llListen(0, "", llGetOwner(), "");
302 llSetTimerEvent(30.0);
303 } else
304 if(msg == "Package") {
305 llMessageLinked(LINK_SET, LINK_PACKAGE, "", "");
306 } else
307 if(msg == "Sound") {
308 if(play_sounds) {
309 llWhisper(0, "Turning sound off.");
310 } else {
311 llWhisper(0, "Turning sound on.");
312 }
313 play_sounds = !play_sounds;
314 } else
315 if(msg == "Home Object") {
316 llGiveInventory(llGetOwner(), "XS Home Object");
317 } else
318 if(msg == "Sleep") {
319 if(sleep_disabled) {
320 llWhisper(0, "Enabling Sleeping.");
321 } else {
322 llWhisper(0, "Disabling Sleeping.");
323 }
324 sleep_disabled = !sleep_disabled;
325 llMessageLinked(LINK_SET, LINK_SLEEP, (string)sleep_disabled, "");
326 }
327 }
328 }
329 }

XS Pet Quail Modified

Modified Pet Quail

Category: XS Quail
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 // Version .24 10-3-2011
5
6 // script by Xundra Snowpaw
7 // mods by Ferd Frederix
8 //
9 // New BSD License: http://www.opensource.org/licenses/bsd-license.php
10 // Copyright (c) 2010, Xundra Snowpaw
11 // All rights reserved.
12 //
13 // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
14
15 //* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
16 //* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
17
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
19 ////////////////////////////////////////////////////////////////////
20
21
22 ///// GLOBAL LINK CONSTANTS extracted from original source //////
23 ///
24 // if you change anything, you change it everywhere and in a list in XS_Debug
25 ///
26
27 integer LINK_AGE_START = 800; // when quail is rezzed and secret_number, is sent by brain to breeder, eater and informatic get booted up
28 integer LINK_FOOD_CONSUME = 900; // from movement to brain when close to food, brain then consumes a random amount up to 10000
29 integer LINK_FOODMINUS = 901; // xs_brain receives FOOD_CONSUME, decrement hunger (eat)
30 integer LINK_HUNGRY = 903; // sent by eater (string)hunger_amount, checks each hour
31 integer LINK_HAMOUNT = 904; // hunger_amount = (integer)str,m updates the hunger amount in scripts
32 integer LINK_SET_HOME = 910; // loc ^ dist
33 integer LINK_MOVER = 911; // tell mover to rest for str seconds
34 integer LINK_FOODIE_CLR = 920; // clear all food_bowl_keys and contents
35 integer LINK_FOODIE = 921; // send FOOD_LOCATION coordinates to movement
36 integer LINK_COLOR1 = 930; // colour1
37 integer LINK_COLOR2 = 931; // colour2
38 integer LINK_SEX = 932; // sex
39 integer LINK_SHINE = 933; // shine
40 integer LINK_GLOW = 934; // glow
41 integer LINK_GEN = 935; // generation
42 integer LINK_MAGE = 940; // xs_brain sends, xs_ager consumes, adds str to age, if older than 7 days, will grow the animal
43 integer LINK_DAYTIME = 941; // xs_ager consumes, starts a timer of 86,400 seconds in xs_ager
44 integer LINK_GET_AGE = 942; // get age from xs_ager and sent it on channel 943
45 integer LINK_PUT_AGE = 943; // print age from xs_ager
46 integer LINK_PACKAGE = 950; // look for a cryo_crate
47 integer LINK_SEEK_FEMALE = 960; // MALE_BREED_CALL
48 integer LINK_MALE_BREED_CALL = 961; // triggered by LINK_SEEK_FEMALE
49 integer LINK_SIGNAL_ELIGIBLE = 962; // sent by female when hears LINK_MALE_BREED_CALL
50 integer LINK_FEMALE_ELIGIBLE = 963; // sent when it hears in chat FEMALE_ELIGIBLE
51 integer LINK_CALL_MALE = 964; // if LINK_FEMALE_ELIGIBLE && looking_for_female
52 integer LINK_MALE_ON_THE_WAY = 965; // triggered by LINK_CALL_MALE
53 integer LINK_FEMALE_LOCATION = 966; // female location, sends coordinates of a female
54 integer LINK_RQST_BREED = 967; // sent when close enough to male/female
55 integer LINK_CALL_MALE_INFO = 968; // ****** BUG ***** read, but never sent by anybody!!!!!
56 // see line 557 and 636 of xs_brain which make calls and also xs_breeding which receives LUNK_MALE_INFO.
57 integer LINK_MALE_INFO = 969;
58 integer LINK_LAY_EGG = 970; // llRezObject("XS Egg"
59 integer LINK_BREED_FAIL = 971; // key = father, failed, timed out
60 integer LINK_PREGNANT = 972; // chick is preggers
61 integer LINK_SLEEPING = 990; // close eyes
62 integer LINK_UNSLEEPING = 991; // open eyes
63 integer LINK_SOUND = 1001; // plays a sound if enabled
64 integer LINK_SPECIAL = 1010; // xs_special, is str = "Normal", removes script
65 integer LINK_PREGNANCY_TIME = 5000; // in seconds as str
66 integer LINK_SLEEP = 7999; // disable sleep by parameter
67 integer LINK_TIMER = 8000; // scan for food bowl about every 1800 seconds
68 integer LINK_DIE = 9999; // death
69 ///////// end global Link constants ////////
70
71 // END //
72
73
74 float GROWTH_AMOUNT = 0.10;
75
76 vector home_location;
77 float roam_distance;
78 list food_bowls;
79 list food_bowl_keys;
80 list food_bowl_time;
81
82 vector destination;
83
84 integer sex_dest = 0;
85 integer food_dest = 0;
86 float tolerance = 0.15;
87 float increment = 0.1;
88 integer rest;
89 integer age;
90 float zoffset;
91 integer sleep_last_check ;
92 integer sound;
93 integer sleep_disabled;
94
95
96 face_target(vector lookat) {
97 vector fwd = llVecNorm(lookat-llGetPos()); //I assume you know the last and current position
98 vector lft = llVecNorm(<0,0,1>%fwd); //cross with <0,0,1> is parallel to ground
99 rotation rot = llAxes2Rot(fwd,lft,fwd%lft);
100 llSetRot(rot);
101 }
102
103 integer sleeping()
104 {
106 if(!sleep_disabled) {
107 if(sun.z < 0) {
108 if(sleep_last_check == 0) {
109 // close eyes
110 llMessageLinked(LINK_SET, LINK_SLEEPING, "", "");
111 }
112 sleep_last_check = 1;
113 } else {
114 if(sleep_last_check == 1) {
115 // open eyes
116 llMessageLinked(LINK_SET, LINK_UNSLEEPING, "", "");
117 }
118 sleep_last_check = 0;
119 }
120 return sleep_last_check;
121 } else {
122 if(sleep_last_check == 1) {
123 llMessageLinked(LINK_SET, LINK_UNSLEEPING, "", "");
124 sleep_last_check = 0;
125 }
126 return 0;
127 }
128 }
129
130 default
131 {
132 link_message(integer sender, integer num, string str, key id)
133 {
134 if(num == 800) {
135 state running;
136 }
137 }
138 }
139
140 state running
141 {
143 {
144 home_location = <0,0,0>;
145 roam_distance = 0;
146 destination = <0,0,0>;
147 age = 0;
148 sleep_last_check = 0;
149 sound = 1;
150 }
151
152
153 timer()
154 {
155 if(!sleeping()) {
156 if(sound) {
157 llMessageLinked(LINK_SET, LINK_SOUND, "", "");
158 }
159 sound = !sound;
160
161 vector my_pos = llGetPos();
162
163 if(llVecDist(<destination.x, destination.y, 0>, <my_pos.x, my_pos.y, 0>) <= tolerance || destination == <0,0,0>) {
164 // if at food_destination send 900 msg
165 if(food_dest > 0) {
166 llMessageLinked(LINK_SET, LINK_FOOD_CONSUME, (string)food_dest, llList2Key(food_bowl_keys, 0));
167 }
168
169 if(sex_dest > 0) {
170 llMessageLinked(LINK_SET, LINK_RQST_BREED, "", "");
171 }
172
173 // pick a new destination
174 sex_dest = 0;
175 food_dest = 0;
176 destination.x = (llFrand(roam_distance * 2) - roam_distance) + home_location.x;
177 destination.y = (llFrand(roam_distance * 2) - roam_distance) + home_location.y;
178
179 destination.z = home_location.z + zoffset;
180
181 //llOwnerSay("Moving to " + (string)destination + " but first, a rest!");
182 rest = (integer)llFrand(60.0);
183 // face it
184 face_target(destination);
185 }
186 if(rest == 0) {
187 // move towards destination
188 vector position = llGetPos();
189 float dis_x = llFabs(destination.x - position.x);
190 float dis_y = llFabs(destination.y - position.y);
191
192 float angle = llAtan2(dis_y, dis_x);
193
194 float inc_x = llCos(angle) * increment;
195 float inc_y = llSin(angle) * increment;
196
197 if(inc_x > increment) {
198 llOwnerSay("BUG: X" + (string)inc_x + " > " + (string)increment);
199 }
200 if(inc_y > increment) {
201 llOwnerSay("BUG: Y" + (string)inc_y + " > " + (string)increment);
202 }
203
204 if(destination.x > position.x) {
205 position.x += inc_x;
206 } else {
207 position.x -= inc_x;
208 }
209
210 if(destination.y > position.y) {
211 position.y += inc_y;
212 } else {
213 position.y -= inc_y;
214 }
215
216 position.z = home_location.z + zoffset;
217
218 llSetPos(position);
219 } else {
220 rest--;
221 }
222 }
223 }
224
225 link_message(integer sender, integer num, string str, key id)
226 {
227 if(num == LINK_HUNGRY) {
228 if(sex_dest == 0) {
229 // move to food bowl, then send 900
230 if(llGetListLength(food_bowl_keys) > 0) {
231 if(roam_distance == 0 || home_location == <0,0,0>) {
232 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.");
233 llMessageLinked(LINK_SET, LINK_FOOD_CONSUME, str, llList2Key(food_bowl_keys, 0));
234 } else {
235 // find nearest food bowl
236 integer i;
237 destination = (vector)llList2String(food_bowls, 0);
238 for (i=1;i<llGetListLength(food_bowls);i++) {
239 if(llVecDist(destination, llGetPos()) > llVecDist((vector)llList2String(food_bowls, i), llGetPos())) {
240 destination = (vector)llList2String(food_bowls, i);
241 }
242 }
243 destination.z = home_location.z + zoffset;
244 // set destination,
245 // face it
246 face_target(destination);
247 food_dest = (integer)str;
248 rest = 0;
249 //llMessageLinked(LINK_SET, LINK_FOOD_CONSUME, str, llList2Key(food_bowl_keys, 0));
250 }
251 } else {
252 llOwnerSay("I'm hungry, but I can't seem to find any food bowls at present.");
253 }
254 }
255 } else
256 if(num == LINK_SET_HOME) {
257 list values = llParseString2List(str, ["^"], []);
258 home_location = (vector)llList2String(values, 0);
259 roam_distance = llList2Float(values, 1);
260 vector current_loc = llGetPos();
261
262 food_bowls = [];
263 food_bowl_keys = [];
264 food_bowl_time = [];
265
266 destination = <0,0,0>;
267 food_dest = 0;
268
269 llSetPos(<current_loc.x, current_loc.y, home_location.z + zoffset>);
270 llSetTimerEvent(5.0);
271 } else
272 if(num == LINK_MOVER) {
273 if(rest < (integer)str) {
274 rest = (integer)str;
275 }
276 } else
277 if(num == LINK_FOODIE_CLR) {
278 food_bowls = [];
279 food_bowl_keys = [];
280 food_bowl_time = [];
281 } else
282 if(num == LINK_FOODIE) {
283 vector food_loc = (vector)str;
284
285 if(llVecDist(home_location, food_loc) <= roam_distance && llFabs(llFabs(home_location.z) - llFabs(food_loc.z)) < 2) {
286 if(llListFindList(food_bowls, (list)str) == -1) {
287 integer id_pos = llListFindList(food_bowl_keys, (list)id);
288 if(id_pos == -1) {
289 food_bowls += str;
290 food_bowl_keys += id;
291 food_bowl_time += llGetUnixTime();
292 } else {
293 food_bowls = llListReplaceList(food_bowls, [str], id_pos, id_pos);
294 food_bowl_time = llListReplaceList(food_bowl_time, [llGetUnixTime()], id_pos, id_pos);
295 }
296 }
297
298 integer iter;
299
300 iter = 0;
301
302 while(iter<llGetListLength(food_bowls)) {
303 if(llGetUnixTime() - llList2Integer(food_bowl_time, iter) > 3600) {//3600
304 food_bowls = llDeleteSubList(food_bowls, iter, iter);
305 food_bowl_keys = llDeleteSubList(food_bowl_keys, iter, iter);
306 food_bowl_time = llDeleteSubList(food_bowl_time, iter, iter);
307 } else {
308 iter++;
309 }
310 }
311
312 if(llGetListLength(food_bowls) > 0) {
313 llMessageLinked(LINK_SET, LINK_TIMER, "", "");
314 }
315
316 }
317 } else
318 if(num == LINK_FEMALE_LOCATION) {
319 destination = (vector)str;
320 face_target(destination);
321 rest = 0;
322 food_dest = 0;
323 sex_dest = 1;
324 } else
325 if(num == LINK_MAGE) {
326 integer heightm;
327 age += (integer)str;
328 heightm = age;
329
330 if(heightm > 7)
331 heightm = 7;
332 float new_scale = (GROWTH_AMOUNT * heightm) + 1.0;
333
334 float legsz = 0.064 * new_scale;
335 float legso = 0.052399 * new_scale;
336
337 zoffset = legsz / 2 + legso;
338 } else
339 if(num == LINK_SLEEP) {
340 sleep_disabled = (integer)str;
341 }
342 }
343 }

XS Pet Quail Modified

Modified Pet Quail

Category: XS Quail
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 // Version .24 10-3-2011
5
6 // script by Xundra Snowpaw
7 // mods by Ferd Frederix
8 //
9 // New BSD License: http://www.opensource.org/licenses/bsd-license.php
10 // Copyright (c) 2010, Xundra Snowpaw
11 // All rights reserved.
12 //
13 // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
14
15 //* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
16 //* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
17
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
19 ////////////////////////////////////////////////////////////////////
20
21
22
23 integer LINK_SPECIAL = 1010; // xs_special, is str = "Normal", removes script
24
25
26 default
27 {
28 link_message(integer sender, integer num, string str, key id)
29 {
30 if(num == LINK_SPECIAL) {
31 if(str == "Normal") {
32 llRemoveInventory("xs_special");
33 } else {
34 // add states for specific specails
35 }
36 }
37 }
38 }

XS Pet Quail Modified

XS Quail

Category: XS Quail
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 \xFF\xFE// CATEGORY:XS Pet
3 // AUTHOR:Xundra Snowpaw, Ferd Frederix
4 // WORLD: Second Life, Opensim
5 // DESCRIPTION:
6 // Modified Pet Quail
7 // CODE
8
9 // xs_ager test script
10 // Version .24 11-13-2011
11 // script by Ferd Frederix
12
13
14 // Put in the animal when the animal is sized as if it were just born, and then touch it.
15 // The animal will grow 10% a second for 7 seconds, then reset back to the original size.
16 // This represents how large the animal will get in 7 days.
17
18 // Unlike the original script, this xs_ager replacement allows arbitrary growth without any constants or prim limits.
19 // It includes 2 tunable parameters for aging time and maximum growth time
20
21 // Copyright (c) 2011, Ferd Frederix
22 // This software is covered by the GPL License 2.0 from http://www.opensource.org/licenses/gpl-2.0.php
23
24 // This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; using version 2 of the License.
25
26 //This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
27
28 // This script is both FREE and OPEN SOURCE.
29 // Scripts under GPL license cannot be sold. A small fee is allowed to cover the costs of distributing. This is just like the Linux Operating System, where you can charge for a CD and shipping, but you cannot charge for the software itself. The Marketplace for Second Life allows scripts such as this to be sold for a maximum of $25 Linden.
30
31 //
32 // You are allowed to sell derivative items, such as pets, that are made with this script.
33 //
34
35
36 // from debug script, these are GLOBAL constants in all scripts
37
38 integer LINK_AGE_START = 800; // when quail is rezzed and secret_number, is sent by brain to breeder, eater and
39 integer LINK_MAGE = 940; // xs_brain sends, xs_ager consumes, adds str to age, if older than 7 days, will grow the animal
40 integer LINK_RESET_SIZE = 936; // reset size to 1
41
42 default
43 {
44 state_entry()
45 {
46
47 }
48
49 touch_start(integer total_number)
50 {
51 llMessageLinked(LINK_SET,LINK_AGE_START,"","");
52 integer i;
53 for (i = 1; i < 8; i++)
54 {
55 llMessageLinked(LINK_SET,LINK_MAGE,"1","");
56 llSleep(1);
57 }
58
59 llMessageLinked(LINK_SET,LINK_RESET_SIZE,"","");
60
61 }
62 }

XS Pet Quail Modified

Modified Pet Quail

Category: XS Quail
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 // Version .24 10-3-2011
3
4 // script by Ferd Frederix
5 //
6 // New BSD License: http://www.opensource.org/licenses/bsd-license.php
7 // Copyright (c) 2010, Ferd Frederix// All rights reserved.
8 //
9 // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
10
11 //* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
12 //* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
13
14 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15 ////////////////////////////////////////////////////////////////////
16
17 // You must modify thios to match your other scripts
18 string SECRET_PASSWORD = "top secret";
19 integer SECRET_NUMBER = 99999;
20
21
22 // This is a list of all known channels. Copy and past all this into every script
23 // Version .24
24 integer FOOD_CHANNEL = -999191;
25 integer ANIMAL_CHANNEL = -999192;
26 integer UPDATE_CHANNEL = -999197;
27 integer EGG_CHANNEL = -999193;
28 integer HOME_CHANNEL = -999194;
29 integer BOX_CHANNEL = -999195;
30 integer ACC_CHANNEL = -999196;
31
32
33 // list to print name instead of number of listener channels
34 list channels = [
35 "FOOD_CHANNEL" , -999191,
36 "ANIMAL_CHANNEL" , -999192,
37 "EGG_CHANNEL" , -999193,
38 "HOME_CHANNEL" , -999194,
39 "BOX_CHANNEL" , -999195,
40 "ACC_CHANNEL" , -999196,
41 "UPDATE_CHANNEL" , -999197
42 ];
43
44 // list to print name instead of number of link messages
45 list messages = [
46 " LINK_AGE_START " , 800,
47 " LINK_FOOD_CONSUME " , 900,
48 " LINK_FOODMINUS " , 901,
49 " LINK_HUNGRY " , 903,
50 " LINK_HAMOUNT " , 904,
51 " LINK_SET_HOME " , 910,
52 " LINK_MOVER " , 911,
53 " LINK_FOODIE_CLR " , 920,
54 " LINK_FOODIE " , 921,
55 " LINK_COLOR1 " , 930,
56 " LINK_COLOR2 " , 931,
57 " LINK_SEX " , 932,
58 " LINK_SHINE " , 933,
59 " LINK_GLOW " , 934,
60 " LINK_GEN " , 935,
61 " LINK_MAGE " , 940,
62 " LINK_DAYTIME " , 941,
63 " LINK_GET_AGE " , 942,
64 " LINK_PUT_AGE " , 943,
65 " LINK_PACKAGE " , 950,
66 " LINK_SEEK_FEMALE " , 960,
67 " LINK_MALE_BREED_CALL " , 961,
68 " LINK_SIGNAL_ELIGIBLE" , 962,
69 " LINK_FEMALE_ELIGIBLE " , 963,
70 " LINK_CALL_MALE " , 964,
71 " LINK_MALE_ON_THE_WAY " , 965,
72 " LINK_FEMALE_LOCATION " , 966,
73 " LINK_CALL_MALE_INFO " , 968,
74 " LINK_RQST_BREED ", 967,
75 " LINK_MALE_INFO " , 969,
76 " LINK_LAY_EGG " , 970,
77 " LINK_BREED_FAIL " , 971,
78 " LINK_PREGNANT " , 972,
79 " LINK_SLEEPING " , 990,
80 " LINK_UNSLEEPING " , 991,
81 " LINK_SOUND " , 1001,
82 " LINK_SPECIAL " , 1010,
83 " LINK_PREGNANCY_TIME " , 5000,
84 " LINK_SLEEP " , 7999,
85 " LINK_TIMER " , 8000,
86 " LINK_DIE " , 9999
87 ];
88
89
90
91
92
93
94 // DON'T CHANGE THE FOLLOWING! (Unless you know what you are doing!)
95
96 integer XTEA_DELTA = 0x9E3779B9; // (sqrt(5) - 1) * 2^31
97 integer xtea_num_rounds = 6;
98 list xtea_key = [0, 0, 0, 0];
99
100 integer hex2int(string hex) {
101 if(llGetSubString(hex,0,1) == "0x")
102 return (integer)hex;
103 if(llGetSubString(hex,0,0) == "x")
104 return (integer)("0"+hex);
105 return(integer)("0x"+hex);
106 }
107
108
109 // Convers any string to a 32 char MD5 string and then to a list of
110 // 4 * 32 bit integers = 128 bit Key. MD5 ensures always a specific
111 // 128 bit key is generated for any string passed.
112 list xtea_key_from_string( string str )
113 {
114 str = llMD5String(str,0); // Use Nonce = 0
115 return [ hex2int(llGetSubString( str, 0, 7)),
116 hex2int(llGetSubString( str, 8, 15)),
117 hex2int(llGetSubString( str, 16, 23)),
118 hex2int(llGetSubString( str, 24, 31))];
119 }
120
121 // Encipher two integers and return the result as a 12-byte string
122 // containing two base64-encoded integers.
123 string xtea_encipher( integer v0, integer v1 )
124 {
125 integer num_rounds = xtea_num_rounds;
126 integer sum = 0;
127 do {
128 // LSL does not have unsigned integers, so when shifting right we
129 // have to mask out sign-extension bits.
130 v0 += (((v1 << 4) ^ ((v1 >> 5) & 0x07FFFFFF)) + v1) ^ (sum + llList2Integer(xtea_key, sum & 3));
131 sum += XTEA_DELTA;
132 v1 += (((v0 << 4) ^ ((v0 >> 5) & 0x07FFFFFF)) + v0) ^ (sum + llList2Integer(xtea_key, (sum >> 11) & 3));
133
134 } while( num_rounds = ~-num_rounds );
135 //return only first 6 chars to remove "=="'s and compact encrypted text.
136 return llGetSubString(llIntegerToBase64(v0),0,5) +
138 }
139
140 // Decipher two base64-encoded integers and return the FIRST 30 BITS of
141 // each as one 10-byte base64-encoded string.
142 string xtea_decipher( integer v0, integer v1 )
143 {
144 integer num_rounds = xtea_num_rounds;
145 integer sum = XTEA_DELTA*xtea_num_rounds;
146 do {
147 // LSL does not have unsigned integers, so when shifting right we
148 // have to mask out sign-extension bits.
149 v1 -= (((v0 << 4) ^ ((v0 >> 5) & 0x07FFFFFF)) + v0) ^ (sum + llList2Integer(xtea_key, (sum>>11) & 3));
150 sum -= XTEA_DELTA;
151 v0 -= (((v1 << 4) ^ ((v1 >> 5) & 0x07FFFFFF)) + v1) ^ (sum + llList2Integer(xtea_key, sum & 3));
152 } while( num_rounds = ~-num_rounds );
153
154 return llGetSubString(llIntegerToBase64(v0), 0, 4) +
156 }
157
158 // Encrypt a full string using XTEA.
159 string xtea_encrypt_string( string str )
160 {
161 // encode string
162 str = llStringToBase64(str);
163 // remove trailing =s so we can do our own 0 padding
164 integer i = llSubStringIndex( str, "=" );
165 if( i != -1 )
166 str = llDeleteSubString( str, i, -1 );
167
168 // we don't want to process padding, so get length before adding it
169 integer len = llStringLength(str);
170
171 // zero pad
172 str += "AAAAAAAAAA=";
173
174 string result;
175 i = 0;
176
177 do {
178 // encipher 30 (5*6) bits at a time.
179 result += xtea_encipher(llBase64ToInteger(llGetSubString(str, i, i + 4) + "A="), llBase64ToInteger(llGetSubString(str, i+5, i + 9) + "A="));
180 i+=10;
181 } while( i < len );
182
183 return result;
184 }
185
186 // Decrypt a full string using XTEA
187 string xtea_decrypt_string( string str ) {
188 integer len = llStringLength(str);
189 integer i=0;
190 string result;
191 //llOwnerSay(str);
192 do {
193 integer v0;
194 integer v1;
195
196 v0 = llBase64ToInteger(llGetSubString(str, i, i + 5) + "==");
197 i+= 6;
198 v1 = llBase64ToInteger(llGetSubString(str, i, i + 5) + "==");
199 i+= 6;
200
201 result += xtea_decipher(v0, v1);
202 } while( i < len );
203
204 // Replace multiple trailing zeroes with a single one
205
206 i = llStringLength(result) - 1;
207 while( llGetSubString(result, i - 1, i) == "AA" ){
208 result = llDeleteSubString(result, i, i);
209 i--;
210 }
211 i = llStringLength(result) - 1;
212 // while(llGetSubString(result, i, i + 1) == "A" ) {
213 // i--;
214 // }
215 result = llGetSubString(result, 0, i+1);
216 i = llStringLength(result);
217 integer mod = i%4; //Depending on encoded length diffrent appends are needed
218 if(mod == 1) result += "A==";
219 else if(mod == 2 ) result += "==";
220 else if(mod == 3) result += "=";
221
222 return llBase64ToString(result);
223 }
224
225
226 ///////////////// Main code bgins /////////////////
227
228 default
229 {
231 {
232 xtea_key = xtea_key_from_string(SECRET_PASSWORD);
233 llListen(FOOD_CHANNEL,"","","");
234 llListen(ANIMAL_CHANNEL,"","","");
235 llListen(HOME_CHANNEL,"","","");
236 llListen(BOX_CHANNEL,"","","");
237 llListen(ACC_CHANNEL,"","","");
238 llListen(UPDATE_CHANNEL,"","","");
239 llListen(EGG_CHANNEL,"","","");
240 }
241
242 listen(integer channel,string name, key id, string message)
243 {
244 integer index = llListFindList(channels,[channel]); // see if a valid channel
245 string aname = "unkown";
246 if(index >= 0)
247 {
248 aname = llList2String(channels,index-1);
249 }
250 llOwnerSay(llGetObjectName() + ":channel:" + aname + ":" + xtea_decrypt_string(message) );
251 }
252
253
254 link_message(integer sender_num, integer num, string str, key id)
255 {
256 integer index = llListFindList(messages,[num]); // see if a valid channel
257 string aname = "unkown";
258 if(index >= 0)
259 {
260 aname = llList2String(messages,index-1);
261 }
262
263 llOwnerSay(llGetObjectName() + ":" + aname + " : string:" + str + " : key:" + (string) id);
264
265 }
266
267 touch_start(integer total_number)
268 {
269 llSay(0, "xs_Debug is loaded into this item.");
270 }
271 }

XS Pet Quail Modified

Modified Pet Quail

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

XS Pet Quail Modified

Modified Pet Quail

Category: XS Quail
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 // Version 0.35 5-22-2012
3
4
5 // script by Xundra Snowpaw
6 // mods by Ferd Frederix
7 //
8 // New BSD License: http://www.opensource.org/licenses/bsd-license.php
9 // Copyright (c) 2010, Xundra Snowpaw
10 // All rights reserved.
11 //
12 // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
13
14 //* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
15 //* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
16
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
18 ////////////////////////////////////////////////////////////////////
19
20
21 ///////////////////////////////////////////////
22 // COPY FROM GLOBAL CONSTANTS FILE LOCATED IN Debug Folder
23 // INCLUDE THESE IN ALL SCRIPTS //
24 // XS_pet constants and names
25
26 ///// GLOBAL CONSTANTS extracted from original source //////
27 //
28 // if you change any of these constants, change it everywhere and in a list in XS_Debug so it can print them
29 //
30 // 0.24 is the original Pet Quail
31 // 0.25 is the modified Pet Quail
32 // 0.26 is the Robot code, which is generic
33
34 float VERSION = 0.25;
35
36 string Animal = "Quail"; // was 'Quail', must be the name of your animal
37 string Egg = "XS Egg"; // was 'XS Egg', must be the name of your egg
38 string Crate = "Transport Crate"; // was XS-Cryocrate
39 string HomeObject = "Home Post"; // was "XS Home Object
40 string sound = "robot_sound";
41 string SECRET_PASSWORD = "top secret"; // must use one unique to any animal
42 integer SECRET_NUMBER = 99999; // any number thats a secret
43
44 integer MaxAge = 7; // can get prggers in 7 days
45 integer UNITS_OF_FOOD = 168; // food bowl food
46 float secs_to_grow = 86400; // grow daily = 86400
47
48 // global listeners
49
50 integer FOOD_CHANNEL = -999191;
51 integer ANIMAL_CHANNEL = -999192;
52 integer EGG_CHANNEL = -999193;
53 integer HOME_CHANNEL = -999194;
54 integer BOX_CHANNEL = -999195;
55 integer ACC_CHANNEL = -999196;
56 integer UPDATE_CHANNEL = -999197;
57 integer API_CHANNEL = -999198;
58
59 // global prim animation linkmessages on channel 1
60 // these are the prim animations played for each type of possible animation
61
62 string ANI_STAND = "stand"; // default standing animation
63 string ANI_WALKL = "left"; // triggers Left foot anbd righrt arm walk animation
64 string ANI_WALKR = "right"; // triggers Right foot and left arm walk animation
65 string ANI_SLEEP = "sleep"; // Sleeping
66 string ANI_WAVE = "wave"; // Calling for sex, needs help with food, etc.
67
68
69
70 // global link messages to control the animal
71 integer LINK_AGE_START = 800; // when quail is rezzed and secret_number, is sent by brain to breeder, eater and informatic get booted up
72 integer LINK_FOOD_CONSUME = 900; // from movement to brain when close to food, brain then consumes a random amount up to 10000
73 integer LINK_FOODMINUS = 901; // xs_brain receives FOOD_CONSUME, decrement hunger (eat)
74 integer LINK_HUNGRY = 903; // sent by eater (string)hunger_amount, checks each hour
75 integer LINK_HAMOUNT = 904; // hunger_amount = (integer)str,m updates the hunger amount in scripts
76 integer LINK_SET_HOME = 910; // loc ^ dist
77 integer LINK_MOVER = 911; // tell mover to rest for str seconds
78 integer LINK_FOODIE_CLR = 920; // clear all food_bowl_keys and contents
79 integer LINK_FOODIE = 921; // send FOOD_LOCATION coordinates to movement
80 integer LINK_COLOR1 = 930; // colour1
81 integer LINK_COLOR2 = 931; // colour2
82 integer LINK_SEX = 932; // sex
83 integer LINK_SHINE = 933; // shine
84 integer LINK_GLOW = 934; // glow
85 integer LINK_GEN = 935; // generation
86 integer LINK_RESET_SIZE = 936; // reset size to 1
87 integer LINK_MAGE = 940; // xs_brain sends, xs_ager consumes, adds str to age, if older than 7 days, will grow the animal
88 integer LINK_DAYTIME = 941; // xs_ager consumes, starts a timer of 86,400 seconds in xs_ager
89 integer LINK_GET_AGE = 942; // get age from xs_ager and sent it on channel 943
90 integer LINK_PUT_AGE = 943; // print age from xs_ager
91 integer LINK_PACKAGE = 950; // look for a cryo_crate
92 integer LINK_SEEK_FEMALE = 960; // MALE_BREED_CALL
93 integer LINK_MALE_BREED_CALL = 961; // triggered by LINK_SEEK_FEMALE
94 integer LINK_SIGNAL_ELIGIBLE = 962; // sent by female when hears LINK_MALE_BREED_CALL
95 integer LINK_FEMALE_ELIGIBLE = 963; // sent when it hears in chat FEMALE_ELIGIBLE
96 integer LINK_CALL_MALE = 964; // if LINK_FEMALE_ELIGIBLE && looking_for_female
97 integer LINK_MALE_ON_THE_WAY = 965; // triggered by LINK_CALL_MALE
98 integer LINK_FEMALE_LOCATION = 966; // female location, sends coordinates of a female
99 integer LINK_RQST_BREED = 967; // sent when close enough to male/female
100 integer LINK_CALL_MALE_INFO = 968; // sent by xs_breeding, this line of code was in error in v.24 of xs_breeding
101 // see line 557 and 636 of xs_brain which make calls and also xs_breeding which receives LINK_MALE_INFO.
102 integer LINK_MALE_INFO = 969;
103 integer LINK_LAY_EGG = 970; // llRezObject("XS Egg"
104 integer LINK_BREED_FAIL = 971; // key = father, failed, timed out
105 integer LINK_PREGNANT = 972; // chick is preggers
106 integer LINK_SLEEPING = 990; // close eyes
107 integer LINK_UNSLEEPING = 991; // open eyes
108 integer LINK_SOUND = 1001; // plays a sound if enabled
109 integer LINK_SPECIAL = 1010; // xs_special, is str = "Normal", removes script
110 integer LINK_PREGNANCY_TIME = 5000; // in seconds as str
111 integer LINK_SLEEP = 7999; // disable sleep by parameter
112 integer LINK_TIMER = 8000; // scan for food bowl about every 1800 seconds
113 integer LINK_DIE = 9999; // death
114
115
116 ///////// end global Link constants ////////
117
118
119
120
121
122
123 ////////////////////////////////////////////////////////////////////
124
125 // DON'T CHANGE THE FOLLOWING! (Unless you know what you are doing!)
126
127 integer XTEA_DELTA = 0x9E3779B9; // (sqrt(5) - 1) * 2^31
128 integer xtea_num_rounds = 6;
129 list xtea_key = [0, 0, 0, 0];
130
131 integer hex2int(string hex) {
132 if(llGetSubString(hex,0,1) == "0x")
133 return (integer)hex;
134 if(llGetSubString(hex,0,0) == "x")
135 return (integer)("0"+hex);
136 return(integer)("0x"+hex);
137 }
138
139
140 // Convers any string to a 32 char MD5 string and then to a list of
141 // 4 * 32 bit integers = 128 bit Key. MD5 ensures always a specific
142 // 128 bit key is generated for any string passed.
143 list xtea_key_from_string( string str )
144 {
145 str = llMD5String(str,0); // Use Nonce = 0
146 return [ hex2int(llGetSubString( str, 0, 7)),
147 hex2int(llGetSubString( str, 8, 15)),
148 hex2int(llGetSubString( str, 16, 23)),
149 hex2int(llGetSubString( str, 24, 31))];
150 }
151
152 // Encipher two integers and return the result as a 12-byte string
153 // containing two base64-encoded integers.
154 string xtea_encipher( integer v0, integer v1 )
155 {
156 integer num_rounds = xtea_num_rounds;
157 integer sum = 0;
158 do {
159 // LSL does not have unsigned integers, so when shifting right we
160 // have to mask out sign-extension bits.
161 v0 += (((v1 << 4) ^ ((v1 >> 5) & 0x07FFFFFF)) + v1) ^ (sum + llList2Integer(xtea_key, sum & 3));
162 sum += XTEA_DELTA;
163 v1 += (((v0 << 4) ^ ((v0 >> 5) & 0x07FFFFFF)) + v0) ^ (sum + llList2Integer(xtea_key, (sum >> 11) & 3));
164
165 } while( num_rounds = ~-num_rounds );
166 //return only first 6 chars to remove "=="'s and compact encrypted text.
167 return llGetSubString(llIntegerToBase64(v0),0,5) +
169 }
170
171 // Decipher two base64-encoded integers and return the FIRST 30 BITS of
172 // each as one 10-byte base64-encoded string.
173 string xtea_decipher( integer v0, integer v1 )
174 {
175 integer num_rounds = xtea_num_rounds;
176 integer sum = XTEA_DELTA*xtea_num_rounds;
177 do {
178 // LSL does not have unsigned integers, so when shifting right we
179 // have to mask out sign-extension bits.
180 v1 -= (((v0 << 4) ^ ((v0 >> 5) & 0x07FFFFFF)) + v0) ^ (sum + llList2Integer(xtea_key, (sum>>11) & 3));
181 sum -= XTEA_DELTA;
182 v0 -= (((v1 << 4) ^ ((v1 >> 5) & 0x07FFFFFF)) + v1) ^ (sum + llList2Integer(xtea_key, sum & 3));
183 } while( num_rounds = ~-num_rounds );
184
185 return llGetSubString(llIntegerToBase64(v0), 0, 4) +
187 }
188
189 // Encrypt a full string using XTEA.
190 string xtea_encrypt_string( string str )
191 {
192 // encode string
193 str = llStringToBase64(str);
194 // remove trailing =s so we can do our own 0 padding
195 integer i = llSubStringIndex( str, "=" );
196 if( i != -1 )
197 str = llDeleteSubString( str, i, -1 );
198
199 // we don't want to process padding, so get length before adding it
200 integer len = llStringLength(str);
201
202 // zero pad
203 str += "AAAAAAAAAA=";
204
205 string result;
206 i = 0;
207
208 do {
209 // encipher 30 (5*6) bits at a time.
210 result += xtea_encipher(llBase64ToInteger(llGetSubString(str, i, i + 4) + "A="), llBase64ToInteger(llGetSubString(str, i+5, i + 9) + "A="));
211 i+=10;
212 } while( i < len );
213
214 return result;
215 }
216
217 // Decrypt a full string using XTEA
218 string xtea_decrypt_string( string str ) {
219 integer len = llStringLength(str);
220 integer i=0;
221 string result;
222 //llOwnerSay(str);
223 do {
224 integer v0;
225 integer v1;
226
227 v0 = llBase64ToInteger(llGetSubString(str, i, i + 5) + "==");
228 i+= 6;
229 v1 = llBase64ToInteger(llGetSubString(str, i, i + 5) + "==");
230 i+= 6;
231
232 result += xtea_decipher(v0, v1);
233 } while( i < len );
234
235 // Replace multiple trailing zeroes with a single one
236
237 i = llStringLength(result) - 1;
238 while( llGetSubString(result, i - 1, i) == "AA" ){
239 result = llDeleteSubString(result, i, i);
240 i--;
241 }
242 i = llStringLength(result) - 1;
243 // while(llGetSubString(result, i, i + 1) == "A" ) {
244 // i--;
245 // }
246 result = llGetSubString(result, 0, i+1);
247 i = llStringLength(result);
248 integer mod = i%4; //Depending on encoded length diffrent appends are needed
249 if(mod == 1) result += "A==";
250 else if(mod == 2 ) result += "==";
251 else if(mod == 3) result += "=";
252
253 return llBase64ToString(result);
254 }
255
256 string base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
257
258
259 // tunables
260 integer up_down = FALSE ; // set to TRUE to rez above the egg cup, set to false to rez below the UFO
261 vector colour1;
262 vector colour2;
263 integer gen;
264 integer shine;
265 float glow;
266 key uuid;
267 integer listener;
268 integer owner_touch;
269 string special;
270
271 say_details()
272 {
273
274 string myshine;
275
276 if(shine == 0) {
277 myshine = "None";
278 } else
279 if(shine == 1) {
280 myshine = "Low";
281 } else
282 if(shine == 2) {
283 myshine = "Medium";
284 } else
285 if(shine == 3) {
286 myshine = "High";
287 }
288
289 llWhisper(0, "Color: " + (string)colour1);
290 llWhisper(0, "Color: " + (string)colour2);
291 llWhisper(0, "Shine: " + myshine);
292 llWhisper(0, "Glow: " + (string)((integer)(glow * 100)) + "%");
293 llWhisper(0, "Special: " + special);
294 llWhisper(0, "Generation: " + (string)gen);
295
296 llSay(API_CHANNEL, "XSQuail^" + (string)llGetKey() + "^"+ (string)colour1 + "^" + (string)colour2 + "^" + (string)shine + "^" + (string)glow + "^" + special + "^" + (string)gen + "^XSQuailEnd");
297 }
298
299 set_colours(vector c1, vector c2, integer shine, float glow)
300 {
303 }
304
305 default
306 {
308 {
309 xtea_key = xtea_key_from_string(SECRET_PASSWORD);
310 uuid = NULL_KEY;
311 listener = llListen(BOX_CHANNEL, "", "", "");
312 }
313
314 listen(integer channel, string name, key id, string msg)
315 {
316
317 if(llGetOwnerKey(id) != llGetOwner()) {
318 return;
319 }
320
321 list data = llParseString2List(xtea_decrypt_string(msg), ["^"], []);
322
323 if(uuid == NULL_KEY) {
324 if(llList2String(data, 0) == "XSPET" && llList2String(data, 2) == "CUP_PING") {
325 uuid = id;
326 llSay(EGG_CHANNEL, xtea_encrypt_string("XSPET^" + (string)id + "^CUP_PONG^" + (string)VERSION));
327 llSetTimerEvent(15.0);
328 }
329 } else if(uuid == id) {
330 if(llList2String(data, 0) == "XSPET" && llList2Key(data, 1) == llGetKey()) {
331 llSetTimerEvent(0.0);
332 colour1 = (vector)llList2String(data, 2);
333 colour2 = (vector)llList2String(data, 3);
334 shine = llList2Integer(data, 4);
335 glow = llList2Float(data, 5);
336 gen = llList2Integer(data, 6);
337 special = llList2String(data, 7);
338 llListenRemove(listener);
339 llSay(EGG_CHANNEL, xtea_encrypt_string("XSPET^" + (string)id + "^CUP_DIE^"));
340 state full;
341 } else
342 if(llList2String(data, 0) == "XSPET" && llList2Key(data, 1) != llGetKey()) {
343 uuid = NULL_KEY;
344 }
345 }
346 }
347 timer()
348 {
349 llSetTimerEvent(0.0);
350 uuid = NULL_KEY;
351 }
352 }
353
354 state full
355 {
357 {
358 string my_special = "";
359 if(special != "Normal") {
360 my_special = "(" + special + ") ";
361 }
362 llSetObjectName("XS Egg Cup: " + my_special + "S:" + (string)shine + " G:" + (string)((integer)(glow * 100)) + "% <" + llGetSubString((string)colour1.x, 0, 3) + "," + llGetSubString((string)colour1.y, 0, 3) + "," + llGetSubString((string)colour1.z, 0, 3) + ">/<" + llGetSubString((string)colour2.x, 0, 3) + "," + llGetSubString((string)colour2.y, 0, 3) + "," + llGetSubString((string)colour2.z, 0, 3) + ">");
363 set_colours(colour1, colour2, shine, glow);
364 llListen(API_CHANNEL, "", "", "");
365 if(special != "Normal") {
366 llSetText(special, <1,1,1>, 1.0);
367 }
368 }
369
371 {
372 owner_touch = 0;
373
374 say_details();
375
376 if(llDetectedKey(0) == llGetOwner()) {
377 owner_touch = 1;
378 integer chan = (integer)llFrand(10000.0) + 1000;
379 listener = llListen(chan, "", llGetOwner(), "");
380
381 llDialog(llGetOwner(), "Would you like to unpackage me?", ["Yes", "No"], chan);
382 }
383 llSetTimerEvent(20.0);
384 }
385
386 timer()
387 {
388 //llOwnerSay("Menu timeout.");
389 if(owner_touch == 1) {
390 llListenRemove(listener);
391 }
392 llSetTimerEvent(0.0);
393 }
394
395 listen(integer channel, string name, key id, string msg)
396 {
397 if(channel == API_CHANNEL) {
398 list data = llParseString2List(msg, ["^"], []);
399 if(llList2String(data, 0) == "XSQuail" && llList2Key(data, 1) == llGetKey()) {
400 llSay(API_CHANNEL, "XSQuail^" + (string)llGetKey() + "^"+ (string)colour1 + "^" + (string)colour2 + "^" + (string)shine + "^" + (string)glow + "^" + special + "^" + (string)gen + "^XSQuailEnd");
401 }
402 } else {
403 llListenRemove(listener);
404 if(msg == "Yes") {
405 state unbox;
406 }
407 }
408 }
409 }
410
411 state unbox
412 {
414 {
415 listener = llListen(BOX_CHANNEL, "", "", "");
416 if(up_down)
417 llRezObject(Egg, llGetPos() + <0.0, 0.0, 0.25>, ZERO_VECTOR, ZERO_ROTATION, SECRET_NUMBER);
418 else
419 {
420 llMessageLinked(LINK_SET,-2000,"",""); // turn on the particle effects
421
422 llRezObject(Egg, llGetPos() + <0.0, 0.0,-0.1>, ZERO_VECTOR, ZERO_ROTATION, SECRET_NUMBER);
423
424 }
425 }
426
427 object_rez(key id)
428 {
429 vector pos = llGetPos();
430 pos.z += .2;
431 llSetPos(pos);
432 }
433
434 listen(integer channel, string name, key id, string msg)
435 {
436 if(channel == BOX_CHANNEL) {
437 list data = llParseString2List(xtea_decrypt_string(msg), ["^"], []);
438 if(llList2String(data, 0) == "XSPET" && llList2String(data, 2) == "EGG_READY") {
439
440 llGiveInventory(id, Egg );
441 llGiveInventory(id, Animal);
442
443 llSay(EGG_CHANNEL, xtea_encrypt_string("XSPET^" + (string)id + "^UNBOX^" + (string)colour1 + "^" + (string)colour2 + "^" + (string)gen + "^" + (string)shine + "^" + (string)glow + "^" + special));
444 llDie();
445 }
446 }
447 }
448 }

XS Pet Quail Modified

Modified Pet Quail

Category: XS Quail
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 // Version .24 10-3-2011
3
4 // script by Xundra Snowpaw
5 // mods by Ferd Frederix
6
7 //
8 // New BSD License: http://www.opensource.org/licenses/bsd-license.php
9 // Copyright (c) 2010, Xundra Snowpaw
10 // All rights reserved.
11 //
12 // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
13
14 //* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
15 //* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
16
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
18 ////////////////////////////////////////////////////////////////////
19
20 // change these in all scripts to match
21 integer FOOD_CHANNEL = -999191;
22 integer ANIMAL_CHANNEL = -999192;
23 string SECRET_PASSWORD = "top secret";
24
25 // tunable numbers
26 integer UNITS_OF_FOOD = 168;
27 integer FOOD_TYPE = 0;
28
29 // globals
30
31
32 // LINK MESSAGE FOOD DECREASE, NUMBER 100, STRING amount
33 //
34
35 // DON'T CHANGE THE FOLLOWING! (Unless you know what you are doing!)
36
37 integer XTEA_DELTA = 0x9E3779B9; // (sqrt(5) - 1) * 2^31
38 integer xtea_num_rounds = 6;
39 list xtea_key = [0, 0, 0, 0];
40
41 integer hex2int(string hex) {
42 if(llGetSubString(hex,0,1) == "0x")
43 return (integer)hex;
44 if(llGetSubString(hex,0,0) == "x")
45 return (integer)("0"+hex);
46 return(integer)("0x"+hex);
47 }
48
49
50 // Convers any string to a 32 char MD5 string and then to a list of
51 // 4 * 32 bit integers = 128 bit Key. MD5 ensures always a specific
52 // 128 bit key is generated for any string passed.
53 list xtea_key_from_string( string str )
54 {
55 str = llMD5String(str,0); // Use Nonce = 0
56 return [ hex2int(llGetSubString( str, 0, 7)),
57 hex2int(llGetSubString( str, 8, 15)),
58 hex2int(llGetSubString( str, 16, 23)),
59 hex2int(llGetSubString( str, 24, 31))];
60 }
61
62 // Encipher two integers and return the result as a 12-byte string
63 // containing two base64-encoded integers.
64 string xtea_encipher( integer v0, integer v1 )
65 {
66 integer num_rounds = xtea_num_rounds;
67 integer sum = 0;
68 do {
69 // LSL does not have unsigned integers, so when shifting right we
70 // have to mask out sign-extension bits.
71 v0 += (((v1 << 4) ^ ((v1 >> 5) & 0x07FFFFFF)) + v1) ^ (sum + llList2Integer(xtea_key, sum & 3));
72 sum += XTEA_DELTA;
73 v1 += (((v0 << 4) ^ ((v0 >> 5) & 0x07FFFFFF)) + v0) ^ (sum + llList2Integer(xtea_key, (sum >> 11) & 3));
74
75 } while( num_rounds = ~-num_rounds );
76 //return only first 6 chars to remove "=="'s and compact encrypted text.
77 return llGetSubString(llIntegerToBase64(v0),0,5) +
79 }
80
81 // Decipher two base64-encoded integers and return the FIRST 30 BITS of
82 // each as one 10-byte base64-encoded string.
83 string xtea_decipher( integer v0, integer v1 )
84 {
85 integer num_rounds = xtea_num_rounds;
86 integer sum = XTEA_DELTA*xtea_num_rounds;
87 do {
88 // LSL does not have unsigned integers, so when shifting right we
89 // have to mask out sign-extension bits.
90 v1 -= (((v0 << 4) ^ ((v0 >> 5) & 0x07FFFFFF)) + v0) ^ (sum + llList2Integer(xtea_key, (sum>>11) & 3));
91 sum -= XTEA_DELTA;
92 v0 -= (((v1 << 4) ^ ((v1 >> 5) & 0x07FFFFFF)) + v1) ^ (sum + llList2Integer(xtea_key, sum & 3));
93 } while( num_rounds = ~-num_rounds );
94
95 return llGetSubString(llIntegerToBase64(v0), 0, 4) +
97 }
98
99 // Encrypt a full string using XTEA.
100 string xtea_encrypt_string( string str )
101 {
102 // encode string
103 str = llStringToBase64(str);
104 // remove trailing =s so we can do our own 0 padding
105 integer i = llSubStringIndex( str, "=" );
106 if( i != -1 )
107 str = llDeleteSubString( str, i, -1 );
108
109 // we don't want to process padding, so get length before adding it
110 integer len = llStringLength(str);
111
112 // zero pad
113 str += "AAAAAAAAAA=";
114
115 string result;
116 i = 0;
117
118 do {
119 // encipher 30 (5*6) bits at a time.
120 result += xtea_encipher(llBase64ToInteger(llGetSubString(str, i, i + 4) + "A="), llBase64ToInteger(llGetSubString(str, i+5, i + 9) + "A="));
121 i+=10;
122 } while( i < len );
123
124 return result;
125 }
126
127 // Decrypt a full string using XTEA
128 string xtea_decrypt_string( string str ) {
129 integer len = llStringLength(str);
130 integer i=0;
131 string result;
132 //llOwnerSay(str);
133 do {
134 integer v0;
135 integer v1;
136
137 v0 = llBase64ToInteger(llGetSubString(str, i, i + 5) + "==");
138 i+= 6;
139 v1 = llBase64ToInteger(llGetSubString(str, i, i + 5) + "==");
140 i+= 6;
141
142 result += xtea_decipher(v0, v1);
143 } while( i < len );
144
145 // Replace multiple trailing zeroes with a single one
146
147 i = llStringLength(result) - 1;
148 while( llGetSubString(result, i - 1, i) == "AA" ){
149 result = llDeleteSubString(result, i, i);
150 i--;
151 }
152 i = llStringLength(result) - 1;
153 // while(llGetSubString(result, i, i + 1) == "A" ) {
154 // i--;
155 // }
156 result = llGetSubString(result, 0, i+1);
157 i = llStringLength(result);
158 integer mod = i%4; //Depending on encoded length diffrent appends are needed
159 if(mod == 1) result += "A==";
160 else if(mod == 2 ) result += "==";
161 else if(mod == 3) result += "=";
162
163 return llBase64ToString(result);
164 }
165
166 string base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
167
168
169 integer food_left;
170
171 default
172 {
174 {
175 if(llGetOwner() != llGetCreator()) {
176 // someone not the creator reset the script. Thats naughty.
177 state dead;
178 }
179
180
181 llSetText("", <1,1,1>, 1.0);
182 xtea_key = xtea_key_from_string(SECRET_PASSWORD);
183 food_left = UNITS_OF_FOOD;
184 llListen(FOOD_CHANNEL, "", "", "");
185 }
186
187 touch_start(integer total_number)
188 {
189 llSetTimerEvent(20.0);
190 llSetText((string)food_left + " servings remaining.", <1,1,1>, 1.0);
191 }
192
193 timer()
194 {
195 llSetTimerEvent(0.0);
196 llSetText("", <1,1,1>, 1.0);
197 }
198
199 listen(integer channel, string name, key id, string message)
200 {
201 list data = llParseString2List(xtea_decrypt_string(message), ["^"] , []);
202 if(llList2String(data, 0) == "XSPET") {
203 if(llList2String(data, 1) == "FOOD_LOCATION") {
204 integer random_key = llList2Integer(data, 2);
205 key animal_key = llList2Key(data, 3);
206 llSay(ANIMAL_CHANNEL, xtea_encrypt_string("XSPET^FOOD_LOCATION^" + (string)random_key + "^" + (string)llGetPos() + "^" + (string)animal_key));
207 }
208 if(llList2String(data, 1) == "FOOD_CONSUME") {
209 if(llList2Key(data, 2) == llGetKey()) {
210 integer random_key = llList2Integer(data, 3);
211 key animal_key = llList2Key(data, 4);
212 food_left--;
213 llMessageLinked(LINK_SET, 100, "1", "");
214 llSay(ANIMAL_CHANNEL, xtea_encrypt_string("XSPET^FOOD_CONSUME^" + (string)random_key + "^" + (string)animal_key + "^" + (string)FOOD_TYPE));
215 if(food_left <= 0) {
216 state empty;
217 }
218 }
219 }
220 }
221 }
222 }
223
224 state dead
225 {
227 {
228 llSetText("This food bowl has been broken.", <1,0,0>, 1.0);
229 }
230 }
231
232 state empty
233 {
235 {
236 llSetObjectName("XS Food Bowl (Empty)");
237 llSetText("Empty", <1,0,0>, 1.0);
238 }
239 }

XS Pet Quail Modified

Xs FoodBowl Animation

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

XS Pet Quail Modified

Modified Pet Quail

Category: XS Quail
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 // Version .24 10-3-2011
3
4 // script by Xundra Snowpaw
5 // mods by Ferd Frederix
6 //
7 // New BSD License: http://www.opensource.org/licenses/bsd-license.php
8 // Copyright (c) 2010, Xundra Snowpaw
9 // All rights reserved.
10 //
11 // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
12
13 //* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
14 //* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
15
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
17 ////////////////////////////////////////////////////////////////////
18
19
20 // revisions:
21 // 10-3-2011 Mod by Ferd to listen to HOME_CHANNEL, not -237918, the original src has no other reference to that channel.
22
23 // change these in all scripts to match
24 string SECRET_PASSWORD = "top secret";
25 integer ANIMAL_CHANNEL = -999192;
26 integer HOME_CHANNEL = -999194;
27
28 // DON'T CHANGE THE FOLLOWING! (Unless you know what you are doing!)
29
30 integer XTEA_DELTA = 0x9E3779B9; // (sqrt(5) - 1) * 2^31
31 integer xtea_num_rounds = 6;
32 list xtea_key = [0, 0, 0, 0];
33
34 integer hex2int(string hex) {
35 if(llGetSubString(hex,0,1) == "0x")
36 return (integer)hex;
37 if(llGetSubString(hex,0,0) == "x")
38 return (integer)("0"+hex);
39 return(integer)("0x"+hex);
40 }
41
42
43 // Convers any string to a 32 char MD5 string and then to a list of
44 // 4 * 32 bit integers = 128 bit Key. MD5 ensures always a specific
45 // 128 bit key is generated for any string passed.
46 list xtea_key_from_string( string str )
47 {
48 str = llMD5String(str,0); // Use Nonce = 0
49 return [ hex2int(llGetSubString( str, 0, 7)),
50 hex2int(llGetSubString( str, 8, 15)),
51 hex2int(llGetSubString( str, 16, 23)),
52 hex2int(llGetSubString( str, 24, 31))];
53 }
54
55 // Encipher two integers and return the result as a 12-byte string
56 // containing two base64-encoded integers.
57 string xtea_encipher( integer v0, integer v1 )
58 {
59 integer num_rounds = xtea_num_rounds;
60 integer sum = 0;
61 do {
62 // LSL does not have unsigned integers, so when shifting right we
63 // have to mask out sign-extension bits.
64 v0 += (((v1 << 4) ^ ((v1 >> 5) & 0x07FFFFFF)) + v1) ^ (sum + llList2Integer(xtea_key, sum & 3));
65 sum += XTEA_DELTA;
66 v1 += (((v0 << 4) ^ ((v0 >> 5) & 0x07FFFFFF)) + v0) ^ (sum + llList2Integer(xtea_key, (sum >> 11) & 3));
67
68 } while( num_rounds = ~-num_rounds );
69 //return only first 6 chars to remove "=="'s and compact encrypted text.
70 return llGetSubString(llIntegerToBase64(v0),0,5) +
72 }
73
74 // Decipher two base64-encoded integers and return the FIRST 30 BITS of
75 // each as one 10-byte base64-encoded string.
76 string xtea_decipher( integer v0, integer v1 )
77 {
78 integer num_rounds = xtea_num_rounds;
79 integer sum = XTEA_DELTA*xtea_num_rounds;
80 do {
81 // LSL does not have unsigned integers, so when shifting right we
82 // have to mask out sign-extension bits.
83 v1 -= (((v0 << 4) ^ ((v0 >> 5) & 0x07FFFFFF)) + v0) ^ (sum + llList2Integer(xtea_key, (sum>>11) & 3));
84 sum -= XTEA_DELTA;
85 v0 -= (((v1 << 4) ^ ((v1 >> 5) & 0x07FFFFFF)) + v1) ^ (sum + llList2Integer(xtea_key, sum & 3));
86 } while( num_rounds = ~-num_rounds );
87
88 return llGetSubString(llIntegerToBase64(v0), 0, 4) +
90 }
91
92 // Encrypt a full string using XTEA.
93 string xtea_encrypt_string( string str )
94 {
95 // encode string
96 str = llStringToBase64(str);
97 // remove trailing =s so we can do our own 0 padding
98 integer i = llSubStringIndex( str, "=" );
99 if( i != -1 )
100 str = llDeleteSubString( str, i, -1 );
101
102 // we don't want to process padding, so get length before adding it
103 integer len = llStringLength(str);
104
105 // zero pad
106 str += "AAAAAAAAAA=";
107
108 string result;
109 i = 0;
110
111 do {
112 // encipher 30 (5*6) bits at a time.
113 result += xtea_encipher(llBase64ToInteger(llGetSubString(str, i, i + 4) + "A="), llBase64ToInteger(llGetSubString(str, i+5, i + 9) + "A="));
114 i+=10;
115 } while( i < len );
116
117 return result;
118 }
119
120 // Decrypt a full string using XTEA
121 string xtea_decrypt_string( string str ) {
122 integer len = llStringLength(str);
123 integer i=0;
124 string result;
125 //llOwnerSay(str);
126 do {
127 integer v0;
128 integer v1;
129
130 v0 = llBase64ToInteger(llGetSubString(str, i, i + 5) + "==");
131 i+= 6;
132 v1 = llBase64ToInteger(llGetSubString(str, i, i + 5) + "==");
133 i+= 6;
134
135 result += xtea_decipher(v0, v1);
136 } while( i < len );
137
138 // Replace multiple trailing zeroes with a single one
139
140 i = llStringLength(result) - 1;
141 while( llGetSubString(result, i - 1, i) == "AA" ){
142 result = llDeleteSubString(result, i, i);
143 i--;
144 }
145 i = llStringLength(result) - 1;
146 // while(llGetSubString(result, i, i + 1) == "A" ) {
147 // i--;
148 // }
149 result = llGetSubString(result, 0, i+1);
150 i = llStringLength(result);
151 integer mod = i%4; //Depending on encoded length diffrent appends are needed
152 if(mod == 1) result += "A==";
153 else if(mod == 2 ) result += "==";
154 else if(mod == 3) result += "=";
155
156 return llBase64ToString(result);
157 }
158
159 string base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
160
161
162
163 default
164 {
166 {
167 xtea_key = xtea_key_from_string(SECRET_PASSWORD);
168 llListen(HOME_CHANNEL, "", "", "XSPET_PING_HOME"); // listen for a pet to say XSPET_PING_HOME - Mod by Ferd to listen to HOME_CHANNEL, not -237918
169
170 }
171
172 touch_start(integer total_number)
173 {
174 if(llDetectedKey(0) == llGetOwner()) {
175 vector size = llGetScale();
176 vector pos = llGetPos();
177
178 pos.z = pos.z - size.z / 2;
179
180 llSay(ANIMAL_CHANNEL, xtea_encrypt_string("XSPET^HOME_LOCATION^" + (string)pos + "^" + llGetObjectDesc()));
181 }
182 llOwnerSay("Setting Home Location");
183 }
184
185 listen(integer channel, string name, key id, string msg)
186 {
187 vector size = llGetScale();
188 vector pos = llGetPos();
189
190 pos.z = pos.z - size.z / 2;
191
192 llSay(ANIMAL_CHANNEL, xtea_encrypt_string("XSPET^HOME_LOCATION^" + (string)pos + "^" + llGetObjectDesc()));
193 }
194 }

XS Pet Quail Modified

Modified Pet Quail

Category: XS Quail
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 // Version .24 10-3-2011
3
4 // script by Xundra Snowpaw
5 // mods by Ferd Frederix
6 //
7 // New BSD License: http://www.opensource.org/licenses/bsd-license.php
8 // Copyright (c) 2010, Xundra Snowpaw
9 // All rights reserved.
10 //
11 // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
12
13 //* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
14 //* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
15
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
17 ////////////////////////////////////////////////////////////////////
18
19
20
21 integer API_CHANNEL = -999198;
22 float VERSION = 0.23;
23
24 string SECRET_PASSWORD = "top secret";
25 integer SECRET_NUMBER = 99999;
26 integer ANIMAL_CHANNEL = -999192;
27 integer BOX_CHANNEL = -999195;
28
29 // DON'T CHANGE THE FOLLOWING! (Unless you know what you are doing!)
30
31 integer XTEA_DELTA = 0x9E3779B9; // (sqrt(5) - 1) * 2^31
32 integer xtea_num_rounds = 6;
33 list xtea_key = [0, 0, 0, 0];
34
35 integer hex2int(string hex) {
36 if(llGetSubString(hex,0,1) == "0x")
37 return (integer)hex;
38 if(llGetSubString(hex,0,0) == "x")
39 return (integer)("0"+hex);
40 return(integer)("0x"+hex);
41 }
42
43
44 // Convers any string to a 32 char MD5 string and then to a list of
45 // 4 * 32 bit integers = 128 bit Key. MD5 ensures always a specific
46 // 128 bit key is generated for any string passed.
47 list xtea_key_from_string( string str )
48 {
49 str = llMD5String(str,0); // Use Nonce = 0
50 return [ hex2int(llGetSubString( str, 0, 7)),
51 hex2int(llGetSubString( str, 8, 15)),
52 hex2int(llGetSubString( str, 16, 23)),
53 hex2int(llGetSubString( str, 24, 31))];
54 }
55
56 // Encipher two integers and return the result as a 12-byte string
57 // containing two base64-encoded integers.
58 string xtea_encipher( integer v0, integer v1 )
59 {
60 integer num_rounds = xtea_num_rounds;
61 integer sum = 0;
62 do {
63 // LSL does not have unsigned integers, so when shifting right we
64 // have to mask out sign-extension bits.
65 v0 += (((v1 << 4) ^ ((v1 >> 5) & 0x07FFFFFF)) + v1) ^ (sum + llList2Integer(xtea_key, sum & 3));
66 sum += XTEA_DELTA;
67 v1 += (((v0 << 4) ^ ((v0 >> 5) & 0x07FFFFFF)) + v0) ^ (sum + llList2Integer(xtea_key, (sum >> 11) & 3));
68
69 } while( num_rounds = ~-num_rounds );
70 //return only first 6 chars to remove "=="'s and compact encrypted text.
71 return llGetSubString(llIntegerToBase64(v0),0,5) +
73 }
74
75 // Decipher two base64-encoded integers and return the FIRST 30 BITS of
76 // each as one 10-byte base64-encoded string.
77 string xtea_decipher( integer v0, integer v1 )
78 {
79 integer num_rounds = xtea_num_rounds;
80 integer sum = XTEA_DELTA*xtea_num_rounds;
81 do {
82 // LSL does not have unsigned integers, so when shifting right we
83 // have to mask out sign-extension bits.
84 v1 -= (((v0 << 4) ^ ((v0 >> 5) & 0x07FFFFFF)) + v0) ^ (sum + llList2Integer(xtea_key, (sum>>11) & 3));
85 sum -= XTEA_DELTA;
86 v0 -= (((v1 << 4) ^ ((v1 >> 5) & 0x07FFFFFF)) + v1) ^ (sum + llList2Integer(xtea_key, sum & 3));
87 } while( num_rounds = ~-num_rounds );
88
89 return llGetSubString(llIntegerToBase64(v0), 0, 4) +
91 }
92
93 // Encrypt a full string using XTEA.
94 string xtea_encrypt_string( string str )
95 {
96 // encode string
97 str = llStringToBase64(str);
98 // remove trailing =s so we can do our own 0 padding
99 integer i = llSubStringIndex( str, "=" );
100 if( i != -1 )
101 str = llDeleteSubString( str, i, -1 );
102
103 // we don't want to process padding, so get length before adding it
104 integer len = llStringLength(str);
105
106 // zero pad
107 str += "AAAAAAAAAA=";
108
109 string result;
110 i = 0;
111
112 do {
113 // encipher 30 (5*6) bits at a time.
114 result += xtea_encipher(llBase64ToInteger(llGetSubString(str, i, i + 4) + "A="), llBase64ToInteger(llGetSubString(str, i+5, i + 9) + "A="));
115 i+=10;
116 } while( i < len );
117
118 return result;
119 }
120
121 // Decrypt a full string using XTEA
122 string xtea_decrypt_string( string str ) {
123 integer len = llStringLength(str);
124 integer i=0;
125 string result;
126 //llOwnerSay(str);
127 do {
128 integer v0;
129 integer v1;
130
131 v0 = llBase64ToInteger(llGetSubString(str, i, i + 5) + "==");
132 i+= 6;
133 v1 = llBase64ToInteger(llGetSubString(str, i, i + 5) + "==");
134 i+= 6;
135
136 result += xtea_decipher(v0, v1);
137 } while( i < len );
138
139 // Replace multiple trailing zeroes with a single one
140
141 i = llStringLength(result) - 1;
142 while( llGetSubString(result, i - 1, i) == "AA" ){
143 result = llDeleteSubString(result, i, i);
144 i--;
145 }
146 i = llStringLength(result) - 1;
147 // while(llGetSubString(result, i, i + 1) == "A" ) {
148 // i--;
149 // }
150 result = llGetSubString(result, 0, i+1);
151 i = llStringLength(result);
152 integer mod = i%4; //Depending on encoded length diffrent appends are needed
153 if(mod == 1) result += "A==";
154 else if(mod == 2 ) result += "==";
155 else if(mod == 3) result += "=";
156
157 return llBase64ToString(result);
158 }
159 string base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
160
161 vector colour1;
162 vector colour2;
163 integer gen;
164 integer shine;
165 float glow;
166 key uuid;
167 integer listener;
168 integer owner_touch;
169 integer sex;
170 integer age;
171 integer hunger;
172 string myname;
173 integer glow_gene;
174 string special;
175
176 say_details()
177 {
178
179 string mysex;
180 string myshine;
181 if(sex == 1) {
182 mysex = "Male";
183 } else
184 if(sex == 2) {
185 mysex = "Female";
186 } else {
187 mysex = (string)sex;
188 }
189
190 if(shine == 0) {
191 myshine = "None";
192 } else
193 if(shine == 1) {
194 myshine = "Low";
195 } else
196 if(shine == 2) {
197 myshine = "Medium";
198 } else
199 if(shine == 3) {
200 myshine = "High";
201 }
202
203 llWhisper(0, "Head/Body Colour: " + (string)colour1);
204 llWhisper(0, "Tail/Wing Colour: " + (string)colour2);
205 llWhisper(0, "Shine: " + myshine);
206 llWhisper(0, "Glow: " + (string)((integer)(glow * 100)) + "%");
207 llWhisper(0, "Special: " + special);
208 llWhisper(0, "Sex: " + mysex);
209 llWhisper(0, "Age: " + (string)age + " days");
210 llWhisper(0, "Generation: " + (string)gen);
211
212 llSay(API_CHANNEL, "XSQuail^" + (string)llGetKey() + "^" + (string)colour1 + "^" + (string)colour2 + "^" + (string)shine + "^" + (string)glow + "^" + special + "^" + (string)gen + "^" + (string)sex + "^" + (string)age + "^XSQuailEnd");
213 }
214
215 set_colours(vector c1, vector c2, integer shine, float glow)
216 {
217 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]);
218 }
219
220 default
221 {
223 {
224 xtea_key = xtea_key_from_string(SECRET_PASSWORD);
225 uuid = NULL_KEY;
226 listener = llListen(BOX_CHANNEL, "", "", "");
227 }
228
230 {
231 llWhisper(0, "This Cryo-Crate is v" + (string)VERSION);
232 }
233
234 listen(integer channel, string name, key id, string msg)
235 {
236 if(llGetOwnerKey(id) != llGetOwner()) {
237 return;
238 }
239
240 list data = llParseString2List(xtea_decrypt_string(msg), ["^"], []);
241
242 if(uuid == NULL_KEY) {
243 if(llList2String(data, 0) == "XSPET" && llList2String(data, 2) == "CRATE_PING") {
244 uuid = id;
245 llSay(ANIMAL_CHANNEL, xtea_encrypt_string("XSPET^CRATE_PONG^" + (string)id + "^" + (string)VERSION));
246 llSetTimerEvent(15.0);
247 }
248 } else if(uuid == id) {
249 if(llList2String(data, 0) == "XSPET" && llList2Key(data, 1) == llGetKey()) {
250 llSetTimerEvent(0.0);
251 colour1 = (vector)llList2String(data, 2);
252 colour2 = (vector)llList2String(data, 3);
253 shine = llList2Integer(data, 4);
254 glow = llList2Float(data, 5);
255 gen = llList2Integer(data, 6);
256 sex = llList2Integer(data, 7);
257 age = llList2Integer(data, 8);
258 hunger = llList2Integer(data, 9);
259 myname = llList2String(data, 10);
260 glow_gene = llList2Integer(data, 11);
261 special = llList2String(data, 12);
262 llListenRemove(listener);
263 llSay(ANIMAL_CHANNEL, xtea_encrypt_string("XSPET^CRATE_DIE^" + (string)id + "^" + (string)VERSION));
264
265 state full;
266 } else
267 if(llList2String(data, 0) == "XSPET" && llList2Key(data, 1) != llGetKey()) {
268 uuid = NULL_KEY;
269 }
270 }
271 }
272 timer()
273 {
274 llSetTimerEvent(0.0);
275 uuid = NULL_KEY;
276 }
277 }
278
279 state full
280 {
282 {
283 llSetObjectName("XS Cryo-Crate: " + myname);
284 set_colours(colour1, colour2, shine, glow);
285 llListen(API_CHANNEL, "", "", "");
286 }
287
289 {
290 owner_touch = 0;
291 say_details();
292
293
294 if(llDetectedKey(0) == llGetOwner()) {
295 owner_touch = 1;
296 integer chan = (integer)llFrand(10000.0) + 1000;
297 listener = llListen(chan, "", llGetOwner(), "");
298
299 llDialog(llGetOwner(), "Would you like to unpackage me?", ["Yes", "No"], chan);
300 }
301 llSetTimerEvent(20.0);
302 }
303
304 timer()
305 {
306 //llOwnerSay("Menu timeout.");
307 if(owner_touch == 1) {
308 llListenRemove(listener);
309 }
310 llSetTimerEvent(0.0);
311 }
312
313 listen(integer channel, string name, key id, string msg)
314 {
315 if(channel == API_CHANNEL) {
316 list data = llParseString2List(msg, ["^"], []);
317 if(llList2String(data, 0) == "XSQuail" && llList2Key(data, 1) == llGetKey()) {
318 llSay(API_CHANNEL, "XSQuail^" + (string)llGetKey() + "^" + (string)colour1 + "^" + (string)colour2 + "^" + (string)shine + "^" + (string)glow + "^" + special + "^" + (string)gen + "^" + (string)sex + "^" + (string)age + "^XSQuailEnd");
319 }
320 } else {
321 llListenRemove(listener);
322 if(msg == "Yes") {
323 state unbox;
324 }
325 }
326 }
327 }
328
329 state unbox
330 {
332 {
333 llRezObject("Quail", llGetPos() + <0.0, 0.0, 0.25>, ZERO_VECTOR, ZERO_ROTATION, SECRET_NUMBER);
334 }
335
336 object_rez(key id)
337 {
338 listener = llListen(BOX_CHANNEL, "", id, "");
339 }
340
341 listen(integer channel, string name, key id, string msg)
342 {
343 if(channel == BOX_CHANNEL) {
344 list data = llParseString2List(xtea_decrypt_string(msg), ["^"], []);
345 if(llList2String(data, 0) == "XSPET" && llList2String(data, 1) == "READY") {
346
347 llGiveInventory(id, "XS Egg");
348 llGiveInventory(id, "Quail");
349
350 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));
351 llDie();
352 }
353 }
354 }
355 }

XS Pet Quail Modified

Global constants and notes

Category: XS Quail
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, Ferd Frederix
3 // WORLD: Second Life, Opensim
4 // DESCRIPTION:
5 // Modified Pet Quail
6 // CODE
7
8 // Version .24 10-3-2011
9 // by Ferd Frederix
10 //
11 // New BSD License: http://www.opensource.org/licenses/bsd-license.php
12 // Copyright (c) 2010, Ferd Frederix
13 // All rights reserved.
14 //
15 // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
16 // Please note that this is Open SOurce, and changes are required to be public as well.
17 // You may not sell these scripts.
18
19 //* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
20 //* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
21
22 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 ////////////////////////////////////////////////////////////////////
24
25
26 // Project Revisions:
27 //
28 // 10-2-2011
29 // changed all Link messages to these constants in this file in the Animal (Quail)
30 // removed the YOUR_UUID and replaced it with llGetCreator() in all scripts.
31 // xs_foodbowl_animation modified to show food bowl filling for creator only.
32 // xs_eggcup.lsl - Mod by Ferd removed ban on Ami Pollemis
33 // xs_home.lsl - Mod by Ferd to listen to HOME_CHANNEL, not -237918, the original src has no other reference to that channel.
34
35 // Version 0.23 10-3-2011
36 // Checked all link constants against original SVN src - all are okay (update 11-15-2011, no, one was bad, see below )
37
38 // Version 0.24 11/12/2011
39 // new xs_ager to allow other than Quail
40
41 // Version 0.25 11/15/2011
42 // xs_breeding: LINK_CALL_MALE_INFO was in error on line 159, was LINK_CALL_MALE, should be LINK_CALL_MALE_INFO
43
44 ///////////////////////////////////////////////
45
46 // INCLUDE THESE IN ALL SCRIPTS //
47 // XS_Quail constants
48
49 ///// GLOBAL LINK CONSTANTS extracted from original source //////
50 //
51 // if you change any of these constants, change it everywhere and in a list in XS_Debug so it can print them
52 //
53
54 integer LINK_AGE_START = 800; // when quail is rezzed and secret_number, is sent by brain to breeder, eater and informatic get booted up
55 integer LINK_FOOD_CONSUME = 900; // from movement to brain when close to food, brain then consumes a random amount up to 10000
56 integer LINK_FOODMINUS = 901; // xs_brain receives FOOD_CONSUME, decrement hunger (eat)
57 integer LINK_HUNGRY = 903; // sent by eater (string)hunger_amount, checks each hour
58 integer LINK_HAMOUNT = 904; // hunger_amount = (integer)str,m updates the hunger amount in scripts
59 integer LINK_SET_HOME = 910; // loc ^ dist
60 integer LINK_MOVER = 911; // tell mover to rest for str seconds
61 integer LINK_FOODIE_CLR = 920; // clear all food_bowl_keys and contents
62 integer LINK_FOODIE = 921; // send FOOD_LOCATION coordinates to movement
63 integer LINK_COLOR1 = 930; // colour1
64 integer LINK_COLOR2 = 931; // colour2
65 integer LINK_SEX = 932; // sex
66 integer LINK_SHINE = 933; // shine
67 integer LINK_GLOW = 934; // glow
68 integer LINK_GEN = 935; // generation
69 integer LINK_RESET_SIZE = 936; // reset size to 1
70 integer LINK_MAGE = 940; // xs_brain sends, xs_ager consumes, adds str to age, if older than 7 days, will grow the animal
71 integer LINK_DAYTIME = 941; // xs_ager consumes, starts a timer of 86,400 seconds in xs_ager
72 integer LINK_GET_AGE = 942; // get age from xs_ager and sent it on channel 943
73 integer LINK_PUT_AGE = 943; // print age from xs_ager
74 integer LINK_PACKAGE = 950; // look for a cryo_crate
75 integer LINK_SEEK_FEMALE = 960; // MALE_BREED_CALL
76 integer LINK_MALE_BREED_CALL = 961; // triggered by LINK_SEEK_FEMALE
77 integer LINK_SIGNAL_ELIGIBLE = 962; // sent by female when hears LINK_MALE_BREED_CALL
78 integer LINK_FEMALE_ELIGIBLE = 963; // sent when it hears in chat FEMALE_ELIGIBLE
79 integer LINK_CALL_MALE = 964; // if LINK_FEMALE_ELIGIBLE && looking_for_female
80 integer LINK_MALE_ON_THE_WAY = 965; // triggered by LINK_CALL_MALE
81 integer LINK_FEMALE_LOCATION = 966; // female location, sends coordinates of a female
82 integer LINK_RQST_BREED = 967; // sent when close enough to male/female
83 integer LINK_CALL_MALE_INFO = 968; // sent by xs_breeding, this line of code was in error in v.24 of xs_breeding
84 // see line 557 and 636 of xs_brain which make calls and also xs_breeding which receives LINK_MALE_INFO.
85 integer LINK_MALE_INFO = 969;
86 integer LINK_LAY_EGG = 970; // llRezObject("XS Egg"
87 integer LINK_BREED_FAIL = 971; // key = father, failed, timed out
88 integer LINK_PREGNANT = 972; // chick is preggers
89 integer LINK_SLEEPING = 990; // close eyes
90 integer LINK_UNSLEEPING = 991; // open eyes
91 integer LINK_SOUND = 1001; // plays a sound if enabled
92 integer LINK_SPECIAL = 1010; // xs_special, is str = "Normal", removes script
93 integer LINK_PREGNANCY_TIME = 5000; // in seconds as str
94 integer LINK_SLEEP = 7999; // disable sleep by parameter
95 integer LINK_TIMER = 8000; // scan for food bowl about every 1800 seconds
96 integer LINK_DIE = 9999; // death
97
98
99 ///////// end global Link constants ////////
100
101 // END //

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