Skip to main content

Enums

Named constant tables for every value that appears in Vetra's public API.

Access via Vetra.Enums:

local Vetra = require(ReplicatedStorage.Vetra)

-- Drag model for the BehaviorBuilder
local DragModel     = Vetra.Enums.DragModel
local TerminateReason = Vetra.Enums.TerminateReason

BehaviorBuilder.DragModel is a direct re-export of Vetra.Enums.DragModel , they are the same table. You can use either reference interchangeably.

Why enums instead of raw strings or numbers?

Passing BehaviorBuilder.DragModel.G7 instead of the integer 10 or the string "G7" means a typo is a nil-index warning at the call site rather than a silent wrong value or a validation error at :Build() time. If an enum value is ever renamed, every reference site produces an error rather than silently passing the wrong value.

Properties​

DragModel​

enum
Enums.DragModel: {[string]: number}

Integer identifiers for the drag model used to compute aerodynamic deceleration each DragSegmentInterval seconds.

Stored as integers rather than strings so the physics hot path uses integer comparison rather than string comparison. BehaviorBuilder.DragModel is a direct re-export of this table.

Pass values from this table to :Drag():Model() and :SpeedProfiles():Supersonic():DragModel().

local Behavior = BehaviorBuilder.new()
    :Drag()
        :Coefficient(0.003)
        :Model(BehaviorBuilder.DragModel.G7)
    :Done()
    :Build()

Analytic models, mathematically defined drag curves:

Key Value Description
Quadratic 1 Deceleration proportional to speed^2, default; most accurate for subsonic bullets
Linear 2 Deceleration proportional to speed

G-series empirical models, Mach-indexed Cd lookup tables derived from ballistic reference projectiles. The DragCoefficient field acts as a scalar multiplier on top of the table value, 1.0 is physically accurate, lower values give a more arcade feel:

Key Value Description
G1 4 Flat-base spitzer, general-purpose standard
G2 5 Aberdeen J projectile, large-calibre / atypical shapes
G3 6 Finnish reference projectile, rarely used in practice
G4 7 Seldom-used reference, included for completeness
G5 8 Boat-tail spitzer, mid-range rifles
G6 9 Semi-spitzer flat-base, shotgun slugs / blunt rounds
G7 10 Long boat-tail, modern long-range / sniper standard
G8 11 Flat-base semi-spitzer, hollow points / pistols
GL 12 Lead round ball, cannons / muskets / buckshot

User-supplied:

Key Value Description
Custom 13 Requires CustomMachTable = { {mach, cd}, ... } on the behavior
Choosing a model

For most modern rifles and pistols, G7 or G8 respectively are the most physically accurate choices. Quadratic is the default and is sufficient for gameplay-tuned weapons where exact ballistic fidelity isn't required. GL gives a distinctly heavy, arcing feel suited to cannons or muskets.

TerminateReason​

enum
Enums.TerminateReason: {[string]: string}

Reason strings identifying why a cast terminated. Compare against these rather than hardcoding raw strings, if a value is ever renamed, every reference site produces a detectable nil rather than silently passing the wrong string.

OnTerminated receives the reason as its second argument, for every value below. OnPreTermination also receives it, but sees every value except Manual, which is only produced by the manual Terminate() path that skips the hook.

local Signals = Solver:GetSignals()

Signals.OnPreTermination:Connect(function(context, reason, mutate)
    if reason == Vetra.Enums.TerminateReason.Hit then
        -- bullet struck a surface, optionally cancel termination
        if context.UserData.HasShield then
            mutate(true, nil)  -- cancelled
        end
    elseif reason == Vetra.Enums.TerminateReason.CornerTrap then
        -- corner-trap detection triggered, termination cannot be cancelled
    end
end)
Key Value When fired
Hit "hit" Bullet struck a surface and was not pierced or bounced
Distance "distance" MaxDistance was reached
Speed "speed" Speed dropped below MinSpeed or exceeded MaxSpeed
CornerTrap "corner_trap" Corner-trap detection terminated the cast
Manual "manual" VetraCast:Terminate() was called, or the solver was destroyed. Never seen by OnPreTermination
CornerTrap cannot be cancelled

OnPreTermination with reason = TerminateReason.CornerTrap fires the mutate callback, but cancelling a corner-trap termination has no effect, the bullet is force-terminated regardless. The callback fires for observability only.

Show raw api
{
    "functions": [],
    "properties": [
        {
            "name": "DragModel",
            "desc": "Integer identifiers for the drag model used to compute aerodynamic\ndeceleration each `DragSegmentInterval` seconds.\n\nStored as integers rather than strings so the physics hot path uses integer\ncomparison rather than string comparison. `BehaviorBuilder.DragModel` is a\ndirect re-export of this table.\n\nPass values from this table to `:Drag():Model()` and\n`:SpeedProfiles():Supersonic():DragModel()`.\n\n```lua\nlocal Behavior = BehaviorBuilder.new()\n    :Drag()\n        :Coefficient(0.003)\n        :Model(BehaviorBuilder.DragModel.G7)\n    :Done()\n    :Build()\n```\n\n**Analytic models**, mathematically defined drag curves:\n\n| Key | Value | Description |\n|-----|-------|-------------|\n| `Quadratic` | `1` | Deceleration proportional to speed^2, default; most accurate for subsonic bullets |\n| `Linear` | `2` | Deceleration proportional to speed |\n\n**G-series empirical models**, Mach-indexed Cd lookup tables derived from\nballistic reference projectiles. The `DragCoefficient` field acts as a scalar\nmultiplier on top of the table value, `1.0` is physically accurate, lower\nvalues give a more arcade feel:\n\n| Key | Value | Description |\n|-----|-------|-------------|\n| `G1` | `4` | Flat-base spitzer, general-purpose standard |\n| `G2` | `5` | Aberdeen J projectile, large-calibre / atypical shapes |\n| `G3` | `6` | Finnish reference projectile, rarely used in practice |\n| `G4` | `7` | Seldom-used reference, included for completeness |\n| `G5` | `8` | Boat-tail spitzer, mid-range rifles |\n| `G6` | `9` | Semi-spitzer flat-base, shotgun slugs / blunt rounds |\n| `G7` | `10` | Long boat-tail, modern long-range / sniper standard |\n| `G8` | `11` | Flat-base semi-spitzer, hollow points / pistols |\n| `GL` | `12` | Lead round ball, cannons / muskets / buckshot |\n\n**User-supplied:**\n\n| Key | Value | Description |\n|-----|-------|-------------|\n| `Custom` | `13` | Requires `CustomMachTable = { {mach, cd}, ... }` on the behavior |\n\n:::tip Choosing a model\nFor most modern rifles and pistols, `G7` or `G8` respectively are the most\nphysically accurate choices. `Quadratic` is the default and is sufficient\nfor gameplay-tuned weapons where exact ballistic fidelity isn't required.\n`GL` gives a distinctly heavy, arcing feel suited to cannons or muskets.\n:::",
            "lua_type": "{ [string]: number }",
            "tags": [
                "enum"
            ],
            "source": {
                "line": 92,
                "path": "docs/Enums.lua"
            }
        },
        {
            "name": "TerminateReason",
            "desc": "Reason strings identifying why a cast terminated. Compare against these rather\nthan hardcoding raw strings, if a value is ever renamed, every reference site\nproduces a detectable nil rather than silently passing the wrong string.\n\n`OnTerminated` receives the reason as its second argument, for every value below.\n`OnPreTermination` also receives it, but sees every value **except** `Manual`, which is\nonly produced by the manual `Terminate()` path that skips the hook.\n\n```lua\nlocal Signals = Solver:GetSignals()\n\nSignals.OnPreTermination:Connect(function(context, reason, mutate)\n    if reason == Vetra.Enums.TerminateReason.Hit then\n        -- bullet struck a surface, optionally cancel termination\n        if context.UserData.HasShield then\n            mutate(true, nil)  -- cancelled\n        end\n    elseif reason == Vetra.Enums.TerminateReason.CornerTrap then\n        -- corner-trap detection triggered, termination cannot be cancelled\n    end\nend)\n```\n\n| Key | Value | When fired |\n|-----|-------|------------|\n| `Hit` | `\"hit\"` | Bullet struck a surface and was not pierced or bounced |\n| `Distance` | `\"distance\"` | `MaxDistance` was reached |\n| `Speed` | `\"speed\"` | Speed dropped below `MinSpeed` or exceeded `MaxSpeed` |\n| `CornerTrap` | `\"corner_trap\"` | Corner-trap detection terminated the cast |\n| `Manual` | `\"manual\"` | `VetraCast:Terminate()` was called, or the solver was destroyed. Never seen by `OnPreTermination` |\n\n:::caution CornerTrap cannot be cancelled\n`OnPreTermination` with `reason = TerminateReason.CornerTrap` fires the\nmutate callback, but cancelling a corner-trap termination has no effect,\nthe bullet is force-terminated regardless. The callback fires for\nobservability only.\n:::",
            "lua_type": "{ [string]: string }",
            "tags": [
                "enum"
            ],
            "source": {
                "line": 139,
                "path": "docs/Enums.lua"
            }
        }
    ],
    "types": [],
    "name": "Enums",
    "desc": "Named constant tables for every value that appears in Vetra's public API.\n\nAccess via `Vetra.Enums`:\n\n```lua\nlocal Vetra = require(ReplicatedStorage.Vetra)\n\n-- Drag model for the BehaviorBuilder\nlocal DragModel     = Vetra.Enums.DragModel\nlocal TerminateReason = Vetra.Enums.TerminateReason\n```\n\n`BehaviorBuilder.DragModel` is a direct re-export of `Vetra.Enums.DragModel`\n, they are the same table. You can use either reference interchangeably.\n\n:::tip Why enums instead of raw strings or numbers?\nPassing `BehaviorBuilder.DragModel.G7` instead of the integer `10` or the\nstring `\"G7\"` means a typo is a nil-index warning at the call site rather\nthan a silent wrong value or a validation error at `:Build()` time.\nIf an enum value is ever renamed, every reference site produces an error\nrather than silently passing the wrong value.\n:::",
    "source": {
        "line": 27,
        "path": "docs/Enums.lua"
    }
}