1 //originally written by Davide Byron
2 //this code is released under the GPLv3
4 // Reacts to E_SCRIPTED_POSITION and E_ACTIVE_POSITION events
5 // When the creature is very near an object it has a random
6 // chance to send a object to it.
7 // If the other object is a creature it may spawn a child with the new object
8 // or keep it for future usage.
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_SCRIPTED_POSITION
= 2;
14 integer E_ACTIVE_POSITION
= 4;
18 //global var, can be subject of evolution some day..
19 float SendingTreshold
= 0.95;
20 float PositionTreshold
= 1.0;
26 link_message( integer sender_num
, integer num
, string str
, key id
)
28 //if a detection has occurred
29 if( num
== E_ACTIVE_POSITION || num
== E_SCRIPTED_POSITION
)
31 vector objPos
= (vector)str
;
32 vector ourPos
= llGetPos();
34 //if the object is enough near
35 if( llFabs(ourPos
.x
- objPos
.x
) <= PositionTreshold
&&
36 llFabs(ourPos
.y
- objPos
.y
) <= PositionTreshold
&&
37 llFabs(ourPos
.z
- objPos
.z
) <= PositionTreshold
)
39 vector target
= (vector)str
;
40 //we have a chance to send an object
41 if( llFrand(1.0) > SendingTreshold
)
43 if( llGetInventoryNumber(INVENTORY_OBJECT
) > 0 )
45 //a random one among all we have
46 llGiveInventory(id
, llGetInventoryName(INVENTORY_OBJECT
, (integer)llFrand(
47 llGetInventoryNumber(INVENTORY_OBJECT
))) );