Difference between revisions of "LlFleeFrom"

From Second Life Wiki
Jump to navigation Jump to search
m
m (Replaced <source> with <syntaxhighlight>; added haiku, generated with the Poem Generator)
 
(13 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{{Pathfinding alpha}}
{{LSL_Function
{{LSL_Function|
|inject-2={{LSL Function/position|position|region=*}}
inject-2={{LSL Function/position|source|region=*}}|
|func=llFleeFrom
func=llFleeFrom|
|func_desc=Directs a character to keep a specific {{LSLP|distance}} from a specific {{LSLP|position}} in the region or adjacent regions.
func_desc=Directs an object to keep away from a defined position in the region or adjacent regions.|
|p1_type=vector
p1_type=vector|
|p1_name=position
p1_name=source|
|p1_desc=&#32;from which to flee.
p1_desc=&#32;from which to flee.|
|p1_hover=&#32;from which to flee.
p1_hover=&#32;from which to flee.|
|p2_type=float
p2_type=float|
|p2_name=distance
p2_name=distance|
|p2_desc=Distance in meters to flee from {{LSLP|position}}.
p2_desc=Distance in meters to flee from the source.|
|p2_hover=Distance in meters to flee from 'position'.
p3_type=list|
|p3_type=list
p3_name=options|
|p3_subtype=instructions
p3_desc=No options available at this time.|
|p3_name=options
caveats=
|p3_desc=No options available at this time.
|caveats=
* Must use llCreateCharacter or script won't compile.
* Must use llCreateCharacter or script won't compile.
* The position to flee from must be near the nav mesh; otherwise, this behavior will fail with PU_FAILURE_INVALID_GOAL.
* The {{LSLP|position}} to flee from must be near the nav mesh; otherwise, this behavior will fail and trigger [[path update]] with {{LSL Const|PU_FAILURE_INVALID_GOAL|ihex=3|hex=0x03|nolink=*}}.
* If you want to avoid an agent or object as per the example below, it's much more elegant and less sim resource intensive to use [[llEvade]] instead.|
* If you want to avoid an agent or object as per the example below, it's much more elegant and less sim resource intensive to use [[llEvade]] instead.
examples=
|examples=
<lsl>
<syntaxhighlight lang="lsl2">
vector last_touched_pos;
vector last_touched_pos;
key last_touched_key;
key last_touched_key;
Line 25: Line 26:
default
default
{
{
state_entry()
    state_entry()
{
    {
        llCreateCharacter([CHARACTER_DESIRED_SPEED, 50.0]);
}
    }


touch_start(integer total_number)
    touch_start(integer total_number)
{
    {
last_touched_key = llDetectedKey(0);
last_touched_key = llDetectedKey(0);
last_touched_pos = llList2Vector(llGetObjectDetails(last_touched_key, [OBJECT_POS]), 0);
last_touched_pos = llDetectedPos(0);
llFleeFrom(last_touched_pos, 10, []);
llFleeFrom(last_touched_pos, 10, []);
llSetTimerEvent(0.2);
llSetTimerEvent(0.2);
}
    }
timer()
    timer()
    {
vector last_touched_pos_now = llList2Vector(llGetObjectDetails(last_touched_key, [OBJECT_POS]), 0);
if ( llVecDist(last_touched_pos, last_touched_pos_now) > 1 )
{
{
vector last_touched_pos_now = llList2Vector(llGetObjectDetails(last_touched_key, [OBJECT_POS]), 0);
    last_touched_pos = last_touched_pos_now;
if ( llVecDist(owner_pos, last_owner_pos) > 1 )
    llFleeFrom(last_touched_pos, 10, []);
{
last_touched_pos = last_touched_pos_now;
llFleeFrom(last_touched_pos, 10, []);
}
}
}
    }
}
}
</lsl> |
</syntaxhighlight>  
notes= The position vector can be set outside the current region by using extended range region coordinates: e.g., to avoid the SE corner of the region to the East of the current one, you could llFleeFrom(<0.0, 512.0, 0.0>, []); |
|notes= The position vector can be set outside the current region by using extended range region coordinates: e.g., to avoid the SE corner of the region to the East of the current one, you could <syntaxhighlight lang="lsl2">llFleeFrom(<0.0, 512.0, 0.0>, 20.0, []);</syntaxhighlight>
also_functions=
|also_functions=
* [[llCreateCharacter]]
* [[llCreateCharacter]]
* [[llDeleteCharacter]]
* [[llDeleteCharacter]]
Line 61: Line 62:
* [[llPursue]]
* [[llPursue]]
* [[llUpdateCharacter]]
* [[llUpdateCharacter]]
* [[llWanderWithin]]|
* [[llWanderWithin]]
also_events=
|also_events=
* [[path_update]]
* [[path_update]]
|history = Date of Release  [[ Release_Notes/Second_Life_Server/12#12.07.31.262785 | 31/07/2012 ]]
|cat1=Pathfinding
|haiku={{Haiku|Alarming nighttime|A bitter, enemy flees|before the vector}}
}}
}}

Latest revision as of 11:01, 17 April 2022

Summary

Function: llFleeFrom( vector position, float distance, list options );

Directs a character to keep a specific distance from a specific position in the region or adjacent regions.

• vector position position in region coordinates from which to flee.
• float distance Distance in meters to flee from position.
• list options No options available at this time.

Caveats

  • Must use llCreateCharacter or script won't compile.
  • The position to flee from must be near the nav mesh; otherwise, this behavior will fail and trigger path update with PU_FAILURE_INVALID_GOAL.
  • If you want to avoid an agent or object as per the example below, it's much more elegant and less sim resource intensive to use llEvade instead.

Examples

vector last_touched_pos;
key last_touched_key;

default
{
    state_entry()
    {
        llCreateCharacter([CHARACTER_DESIRED_SPEED, 50.0]);
    }

    touch_start(integer total_number)
    {
	last_touched_key = llDetectedKey(0);
	last_touched_pos = llDetectedPos(0);
	llFleeFrom(last_touched_pos, 10, []);
	llSetTimerEvent(0.2);
    }
	
    timer()
    {
	vector last_touched_pos_now = llList2Vector(llGetObjectDetails(last_touched_key, [OBJECT_POS]), 0);
	if ( llVecDist(last_touched_pos, last_touched_pos_now) > 1 )
	{
	    last_touched_pos = last_touched_pos_now;
	    llFleeFrom(last_touched_pos, 10, []);
	}
    }
}

Notes

The position vector can be set outside the current region by using extended range region coordinates: e.g., to avoid the SE corner of the region to the East of the current one, you could
llFleeFrom(<0.0, 512.0, 0.0>, 20.0, []);

Deep Notes

History

Date of Release 31/07/2012

Signature

function void llFleeFrom( vector position, float distance, list options );

Haiku

Alarming nighttime
A bitter, enemy flees
before the vector