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 script to it. If the other object is a creature
7 // with the remote loading script enabler he will receive the script
10 // this will allow for complex evolution to take place, as every script codes
11 // a specific behaviour. Other creatures will be able to acquire new behaviours
12 // and try to get more fit to the world.
13 // this is a powerful and armful tool tough, be careful as it could drive things
14 // out of control pretty quick.
16 //dedicated to Mealea, thanks for the passion you put into things and for being able to pass it on to me :)
20 integer E_SCRIPTED_POSITION
= 2;
21 integer E_ACTIVE_POSITION
= 4;
25 //global vars, may be subjected to evolution one day...
26 float SendingTreshold
= 0.95;
27 float PositionTreshold
= 1.0;
34 //listens for messages
35 link_message( integer sender_num
, integer num
, string str
, key id
)
37 //if a detection has occurred
38 if( num
== E_ACTIVE_POSITION || num
== E_SCRIPTED_POSITION
)
40 vector objPos
= (vector)str
;
41 vector ourPos
= llGetPos();
43 //if the object is enough near
44 if( llFabs(ourPos
.x
- objPos
.x
) <= PositionTreshold
&&
45 llFabs(ourPos
.y
- objPos
.y
) <= PositionTreshold
&&
46 llFabs(ourPos
.z
- objPos
.z
) <= PositionTreshold
)
48 vector target
= (vector)str
;
49 //the creature has a given probability of sending one of its scripts
50 if( llFrand(1.0) > SendingTreshold
)
52 integer isRunning
= TRUE
;
53 llRemoteLoadScriptPin(id
, llGetInventoryName(INVENTORY_SCRIPT
, (integer)llFrand(
54 llGetInventoryNumber(INVENTORY_SCRIPT
))), PIN
, isRunning
, 0 );