1 //originally written by Davide Byron
2 //this code is released under the GPLv3
4 // Reacts to E_MONEY_QTY_KEY event
5 // spawns a new child with the first object in inventory as the body
6 // and sends to him all his scripts (but not objects, etc...)
8 // WARNING: if there are no objecs in the creature inventory the reproduction will fail
9 // and the user has paid for nothing... this is not very good...
11 //dedicated to Mealea, thanks for the passion you put into things and for being able to pass it on to me :)
14 integer E_MONEY_QTY_KEY
= 8;
16 //cage boundaries expressed in region absolute coords
17 integer CAGE_MIN_X
= 1;
18 integer CAGE_MAX_X
= 249;
19 integer CAGE_MIN_Y
= 1;
20 integer CAGE_MAX_Y
= 249;
21 integer CAGE_MIN_Z
= 1;
22 integer CAGE_MAX_Z
= 100;
27 //deny moving out of a definite cage
28 //mostly used for debug
29 vector checkCageLimit( vector pos
)
31 if( pos
.x
< CAGE_MIN_X
)
33 if( pos
.x
> CAGE_MAX_X
)
35 if( pos
.y
< CAGE_MIN_Y
)
37 if( pos
.y
> CAGE_MAX_Y
)
39 if( pos
.z
< CAGE_MIN_Z
)
41 if( llGround( pos
- llGetPos() ) > pos
.z
)
42 pos
.z
= llGround( pos
- llGetPos() ) + 0.1;
43 if( pos
.z
> CAGE_MAX_Z
)
52 //generates a random float number ranging from -range to range
53 float myRand( float range
)
55 float sign
= llFrand(2.1);
56 float random
= llFrand( range
+ 0.1 );
79 //this should help humans knows what this creature can do
80 llSetObjectDesc( llGetObjectDesc() + "pay for me to reproduce-" );
87 //if this state needs to know something from the other states
88 //this is the right place.
89 link_message(integer sender_num
, integer num
, string msg
, key id
)
91 //if an avatar has touched us
92 if( num
== E_MONEY_QTY_KEY
)
94 //and we don't have an object into our inventory
95 if( llGetInventoryNumber(INVENTORY_OBJECT
) == 0 )
97 llShout(0, "Please put a full perm object into my inventory and pay me again");
99 //and we have an object into our inventory
102 vector pos
= llGetPos() + <myRand(2.0), myRand(2.0), myRand(2.0)>;
103 pos
= checkCageLimit( pos
);
104 llRezAtRoot(llGetInventoryName(INVENTORY_OBJECT
, (integer)llFrand(llGetInventoryNumber(INVENTORY_OBJECT
))), pos
, llGetVel(), llGetRot(), 0);
112 //after the new creature has been spawned we send all our scripts to it
115 integer scriptCount
= llGetInventoryNumber(INVENTORY_SCRIPT
);
118 integer isRunning
= TRUE
;
120 llGiveInventory(id
, llGetInventoryName(INVENTORY_OBJECT
, 0) );
122 for( ; i
< scriptCount
; i
++ )
124 script
= llGetInventoryName(INVENTORY_SCRIPT
, i
);
125 llRemoteLoadScriptPin(id
, script
, PIN
, isRunning
, 0 );