Anchor functions

Anchor

Spawns an invisible entity, and sets the pointer to it.

Syntax

Anchor true,[type] -- Spawns Anchor, [type] is optional

Anchor false,[type] -- Removes Anchor from the game, [type] is optional

Note

[type] is an object type, like target, caller, owner, ...

If [type] is not specified, it will execute on the current entity the script being ran from.

If [type] is specified and it's not self, it will save the script executioner's location to [type].

Example


// This example shows you how to make an NPC run to it's target, and back to it's last known location.
st_somestate
{
    Group Alert
    Patterns
    {
        pt_default
        {
            actions
            {
                TargetCaller 1
                // Save this location!
                Anchor true
                // Run to my current target!
                MoveToTarget run,1

                Pattern pt_loop
            }
        }

        pt_loop
        {
            actions
            {
                IfAttr "Object:target != Object:NULL Block begin"
                    // We pretty much reached our target
                    IfAttr "Object:target != Object:anchor Block begin"
                        IfAttr "DistTo:target <= 52 Pattern pt_goback"
                    Block end

                    // We are targeting our anchor!
                    IfAttr "Object:target == Object:anchor Block begin"
                        IfAttr "DistTo:target <= 52 Block begin"
                            // We pretty much reached our target
                            FreeMovement walk,reset
                            State st_start
                        Block end
                    Block end
                Block end

                Repeat 0
            }
        }

        pt_goback
        {
            actions
            {
                // Target our Anchor we saved earlier in pt_default!
                TargetAnchor 1
                // Run to it!
                MoveToTarget run,1

                Pattern pt_loop
            }
        }
    }
}


TargetAnchor

Sets internal target to entity's saved Anchor, if there's any.

Syntax

TargetAnchor 1 -- Sets internal target to Anchor

Note

To get an entity's Anchor other than the script executioner's, you will have to use SetTarget.