1 //originally written by Davide Byron
2 //this code is released under the GPLv3
4 // Reacts to E_TOUCH_ID 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 // if there are no objects in the creature inventory it will ask for one
10 //dedicated to Mealea, thanks for the passion you put into things and for being able to pass it on to me :)
13 integer E_TOUCH_ID
= 7;
15 //cage boundaries expressed in region absolute coords
16 integer CAGE_MIN_X
= 1;
17 integer CAGE_MAX_X
= 249;
18 integer CAGE_MIN_Y
= 1;
19 integer CAGE_MAX_Y
= 249;
20 integer CAGE_MIN_Z
= 1;
21 integer CAGE_MAX_Z
= 100;
26 //deny moving out of a definite cage
27 //mostly used for debug
28 vector checkCageLimit( vector pos
)
30 if( pos
.x
< CAGE_MIN_X
)
32 if( pos
.x
> CAGE_MAX_X
)
34 if( pos
.y
< CAGE_MIN_Y
)
36 if( pos
.y
> CAGE_MAX_Y
)
38 if( pos
.z
< CAGE_MIN_Z
)
40 if( llGround( pos
- llGetPos() ) > pos
.z
)
41 pos
.z
= llGround( pos
- llGetPos() ) + 0.1;
42 if( pos
.z
> CAGE_MAX_Z
)
51 //generates a random float number ranging from -range to range
52 float myRand( float range
)
54 float sign
= llFrand(2.1);
55 float random
= llFrand( range
+ 0.1 );
78 //this should attract users, maybe...
79 llSetText("Don't touch me, absolutely!", <llFrand(1.1), llFrand(1.1), llFrand(1.1)>, 1.0 );
80 //this should help humans knows what this creature can do
81 llSetObjectDesc( llGetObjectDesc() + "touch for me to reproduce-" );
88 //if this state needs to know something from the other states
89 //this is the right place.
90 link_message(integer sender_num
, integer num
, string msg
, key id
)
92 //if an avatar has touched us
93 if( num
== E_TOUCH_ID
)
95 //and we don't have an object into our inventory
96 if( llGetInventoryNumber(INVENTORY_OBJECT
) == 0 )
98 llShout(0, "Please put a full perm object into my inventory and touch me again");
100 //and we have an object into our inventory
103 vector pos
= llGetPos() + <myRand(2.0), myRand(2.0), myRand(2.0)>;
104 pos
= checkCageLimit( pos
);
106 llRezAtRoot(llGetInventoryName(INVENTORY_OBJECT
, (integer)llFrand(llGetInventoryNumber(INVENTORY_OBJECT
))), pos
, llGetVel(), llGetRot(), 0);
114 //after the new creature has been spawned we send all our scripts to it
117 integer scriptCount
= llGetInventoryNumber(INVENTORY_SCRIPT
);
120 integer isRunning
= TRUE
;
122 llGiveInventory(id
, llGetInventoryName(INVENTORY_OBJECT
, 0) );
124 for( ; i
< scriptCount
; i
++ )
126 script
= llGetInventoryName(INVENTORY_SCRIPT
, i
);
127 llRemoteLoadScriptPin(id
, script
, PIN
, isRunning
, 0 );