Skip to main content

CornerTrapBuilder

Sub-builder for corner-trap detection. Opened via BehaviorBuilder:CornerTrap. Call :Done() to return to the root BehaviorBuilder.

Corner-trap detection terminates bullets stuck bouncing infinitely between opposing surfaces. Four independent passes run on every bounce, any single pass firing is sufficient to declare a trap:

  • Pass 1, Temporal: Two bounces within CornerTimeThreshold seconds.
  • Pass 2, Velocity EMA: Velocity direction EMA falls below CornerEMAThreshold.
  • Pass 3, Spatial: Successive bounce contact points within CornerDisplacementThreshold studs.
  • Pass 4, Minimum progress: Bullet fails to advance CornerMinProgressPerBounce studs from its first bounce contact.

Functions

TimeThreshold

CornerTrapBuilder:TimeThreshold(valuenumber) → CornerTrapBuilder

Minimum seconds between successive bounces (Pass 1).

Default: 0.002

PositionHistorySize

CornerTrapBuilder:PositionHistorySize(valuenumber) → CornerTrapBuilder

Bounce contact point history size. Must be a positive integer.

Default: 4

DisplacementThreshold

CornerTrapBuilder:DisplacementThreshold(valuenumber) → CornerTrapBuilder

Minimum stud distance between successive contact points (Pass 3).

Default: 0.5

EMAAlpha

CornerTrapBuilder:EMAAlpha(valuenumber) → CornerTrapBuilder

EMA smoothing factor for velocity direction tracking (Pass 2). Must be in (0, 1).

CAUTION

EMAThreshold must be > |1 − 2 · EMAAlpha|. Changing this value requires updating EMAThreshold. :Build() enforces the constraint.

Default: 0.4

EMAThreshold

CornerTrapBuilder:EMAThreshold(valuenumber) → CornerTrapBuilder

EMA magnitude threshold below which oscillation is declared (Pass 2). Must be > |1 − 2 · EMAAlpha|.

Default: 0.25

MinProgressPerBounce

CornerTrapBuilder:MinProgressPerBounce(valuenumber) → CornerTrapBuilder

Minimum studs of progress per bounce over the history window (Pass 4). Set to 0 to disable Pass 4.

Default: 0.3

Done

CornerTrapBuilder:Done() → BehaviorBuilder

Returns the root BehaviorBuilder.

Show raw api
{
    "functions": [
        {
            "name": "TimeThreshold",
            "desc": "Minimum seconds between successive bounces (Pass 1).\n\nDefault: `0.002`",
            "params": [
                {
                    "name": "value",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "CornerTrapBuilder"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 477,
                "path": "docs/SubBuilders.lua"
            }
        },
        {
            "name": "PositionHistorySize",
            "desc": "Bounce contact point history size. Must be a positive integer.\n\nDefault: `4`",
            "params": [
                {
                    "name": "value",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "CornerTrapBuilder"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 487,
                "path": "docs/SubBuilders.lua"
            }
        },
        {
            "name": "DisplacementThreshold",
            "desc": "Minimum stud distance between successive contact points (Pass 3).\n\nDefault: `0.5`",
            "params": [
                {
                    "name": "value",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "CornerTrapBuilder"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 497,
                "path": "docs/SubBuilders.lua"
            }
        },
        {
            "name": "EMAAlpha",
            "desc": "EMA smoothing factor for velocity direction tracking (Pass 2). Must be in `(0, 1)`.\n\n:::caution\n`EMAThreshold` must be `> |1 − 2 · EMAAlpha|`. Changing this value requires\nupdating `EMAThreshold`. `:Build()` enforces the constraint.\n:::\n\nDefault: `0.4`",
            "params": [
                {
                    "name": "value",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "CornerTrapBuilder"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 512,
                "path": "docs/SubBuilders.lua"
            }
        },
        {
            "name": "EMAThreshold",
            "desc": "EMA magnitude threshold below which oscillation is declared (Pass 2).\nMust be `> |1 − 2 · EMAAlpha|`.\n\nDefault: `0.25`",
            "params": [
                {
                    "name": "value",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "CornerTrapBuilder"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 523,
                "path": "docs/SubBuilders.lua"
            }
        },
        {
            "name": "MinProgressPerBounce",
            "desc": "Minimum studs of progress per bounce over the history window (Pass 4).\nSet to `0` to disable Pass 4.\n\nDefault: `0.3`",
            "params": [
                {
                    "name": "value",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "CornerTrapBuilder"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 534,
                "path": "docs/SubBuilders.lua"
            }
        },
        {
            "name": "Done",
            "desc": "Returns the root [BehaviorBuilder].",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "BehaviorBuilder"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 540,
                "path": "docs/SubBuilders.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "CornerTrapBuilder",
    "desc": "Sub-builder for corner-trap detection. Opened via [BehaviorBuilder:CornerTrap].\nCall `:Done()` to return to the root [BehaviorBuilder].\n\nCorner-trap detection terminates bullets stuck bouncing infinitely between\nopposing surfaces. Four independent passes run on every bounce, any single\npass firing is sufficient to declare a trap:\n\n- **Pass 1, Temporal:** Two bounces within `CornerTimeThreshold` seconds.\n- **Pass 2, Velocity EMA:** Velocity direction EMA falls below `CornerEMAThreshold`.\n- **Pass 3, Spatial:** Successive bounce contact points within `CornerDisplacementThreshold` studs.\n- **Pass 4, Minimum progress:** Bullet fails to advance `CornerMinProgressPerBounce` studs from its first bounce contact.",
    "source": {
        "line": 467,
        "path": "docs/SubBuilders.lua"
    }
}