Skip to main content

SafeWatch

A Types.Sense for players in SafeAreas. Writes SafeTarget, SafePosition and SafeDistance for the nearest player it can see standing in an enabled safe area, so a brain can stop and stare (States.Stare) rather than try the door. With Evict (the default) it also moves its own agent out of a safe area that was switched on around it.

:AddSense(VluxyAI.Senses.SafeWatch.new({ Spots = graph }))

Types​

SafeWatchOptions​

interface SafeWatchOptions {
Range: number?--

Studs within which a player in a safe area is noticed, with a clear line to them. Default 60.

EyeOffset: Vector3?--

Added to the entity's pivot to get the eye. Default Vector3.zero.

Evict: boolean?--

Move the agent out when it finds itself in an enabled safe area. Default true.

Spots: ({Vector3} | {GetNodes: (self: any) → {{Position: Vector3}}})?--

Where an evicted agent may go: floor positions, or a Graph whose nodes are used. The nearest one outside every safe area is chosen. Without it the agent is pushed out through the nearest face of the area's box.

Height: number?--

Studs above a spot's floor to put the body. Default 3, a humanoid's root.

Remember: number?--

Seconds a player stays "the one being chased" after Sight last wrote them as SeenTarget. Such a player in a safe area counts even with no line to them. Default 10.

Forget: boolean?--

When the player in the safe area is one being chased, Sight.Forget the sighting, so the chase has nothing left to follow. Default true.

SightPrefix: string?--

The Prefix of the Sight whose keys are read and forgotten. Default "".

Prefix: string?--

Prepended to every key this sense writes. Default "".

}

Functions​

new​

SafeWatch.new(options: SafeWatchOptions?) → SafeWatch

Errors

TypeDescription
"unknown option"
"Range must be zero or more"

PushOut​

SafeWatch.PushOut(
cframe: CFrame,--

The safe area's box.

size: Vector3,
point: Vector3,--

A point inside it.

margin: number--

Studs past the face to land.

) → Vector3--

point moved out through the nearest side face (never the top or bottom).

The fallback when no spots were given. Pure.

Tick​

SafeWatch.Tick(
self: SafeWatch,
agent: Agent,
deltaTime: number
) → ()

Evicts the agent when it is in a safe area, then writes the keys listed above.

Destroy​

SafeWatch.Destroy(self: SafeWatch) → ()

Nothing to release.

Configure​

SafeWatch.Configure() → ()

Changes options after construction.

Errors

TypeDescription
"unknown option"
Show raw api
{
    "functions": [
        {
            "name": "new",
            "desc": "",
            "params": [
                {
                    "name": "options",
                    "desc": "",
                    "lua_type": "SafeWatchOptions?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "SafeWatch"
                }
            ],
            "function_type": "static",
            "errors": [
                {
                    "lua_type": "\"unknown option\"",
                    "desc": ""
                },
                {
                    "lua_type": "\"Range must be zero or more\"",
                    "desc": ""
                }
            ],
            "source": {
                "line": 122,
                "path": "lib/Senses/SafeWatch.luau"
            }
        },
        {
            "name": "PushOut",
            "desc": "The fallback when no spots were given. Pure.",
            "params": [
                {
                    "name": "cframe",
                    "desc": "The safe area's box.",
                    "lua_type": "CFrame"
                },
                {
                    "name": "size",
                    "desc": "",
                    "lua_type": "Vector3"
                },
                {
                    "name": "point",
                    "desc": "A point inside it.",
                    "lua_type": "Vector3"
                },
                {
                    "name": "margin",
                    "desc": "Studs past the face to land.",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "`point` moved out through the nearest side face (never the top or bottom).",
                    "lua_type": "Vector3"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 162,
                "path": "lib/Senses/SafeWatch.luau"
            }
        },
        {
            "name": "Tick",
            "desc": "Evicts the agent when it is in a safe area, then writes the keys listed above.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "SafeWatch"
                },
                {
                    "name": "agent",
                    "desc": "",
                    "lua_type": "Agent"
                },
                {
                    "name": "deltaTime",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 211,
                "path": "lib/Senses/SafeWatch.luau"
            }
        },
        {
            "name": "Destroy",
            "desc": "Nothing to release.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "SafeWatch"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 287,
                "path": "lib/Senses/SafeWatch.luau"
            }
        },
        {
            "name": "Configure",
            "desc": "Changes options after construction.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "SafeWatch"
                },
                {
                    "name": "patch",
                    "desc": "",
                    "lua_type": "SafeWatchOptions"
                }
            ],
            "returns": [],
            "function_type": "static",
            "errors": [
                {
                    "lua_type": "\"unknown option\"",
                    "desc": ""
                }
            ],
            "source": {
                "line": 298,
                "path": "lib/Senses/SafeWatch.luau"
            }
        }
    ],
    "properties": [],
    "types": [
        {
            "name": "SafeWatchOptions",
            "desc": "",
            "fields": [
                {
                    "name": "Range",
                    "lua_type": "number?",
                    "desc": "Studs within which a player in a safe area is noticed, with a clear line to them. Default `60`."
                },
                {
                    "name": "EyeOffset",
                    "lua_type": "Vector3?",
                    "desc": "Added to the entity's pivot to get the eye. Default `Vector3.zero`."
                },
                {
                    "name": "Evict",
                    "lua_type": "boolean?",
                    "desc": "Move the agent out when it finds itself in an enabled safe area. Default `true`."
                },
                {
                    "name": "Spots",
                    "lua_type": "({ Vector3 } | { GetNodes: (self: any) -> { { Position: Vector3 } } })?",
                    "desc": "Where an evicted agent may go: floor positions, or a [Graph] whose nodes are used. The nearest one outside every safe area is chosen. Without it the agent is pushed out through the nearest face of the area's box."
                },
                {
                    "name": "Height",
                    "lua_type": "number?",
                    "desc": "Studs above a spot's floor to put the body. Default `3`, a humanoid's root."
                },
                {
                    "name": "Remember",
                    "lua_type": "number?",
                    "desc": "Seconds a player stays \"the one being chased\" after [Sight] last wrote them as `SeenTarget`. Such a player in a safe area counts even with no line to them. Default `10`."
                },
                {
                    "name": "Forget",
                    "lua_type": "boolean?",
                    "desc": "When the player in the safe area is one being chased, [Sight.Forget] the sighting, so the chase has nothing left to follow. Default `true`."
                },
                {
                    "name": "SightPrefix",
                    "lua_type": "string?",
                    "desc": "The `Prefix` of the [Sight] whose keys are read and forgotten. Default `\"\"`."
                },
                {
                    "name": "Prefix",
                    "lua_type": "string?",
                    "desc": "Prepended to every key this sense writes. Default `\"\"`."
                }
            ],
            "source": {
                "line": 67,
                "path": "lib/Senses/SafeWatch.luau"
            }
        }
    ],
    "name": "SafeWatch",
    "desc": "A [Types.Sense] for players in [SafeAreas]. Writes `SafeTarget`, `SafePosition` and\n`SafeDistance` for the nearest player it can see standing in an enabled safe area, so a brain\ncan stop and stare ([States.Stare]) rather than try the door. With `Evict` (the default) it\nalso moves its own agent out of a safe area that was switched on around it.\n\n```lua\n:AddSense(VluxyAI.Senses.SafeWatch.new({ Spots = graph }))\n```",
    "source": {
        "line": 114,
        "path": "lib/Senses/SafeWatch.luau"
    }
}