Skip to main content

Claims

A shared "who is on what" table for a group of agents, so two enemies never chase the same player or investigate the same noise unless you want them to. Exposed as VluxyAI.Claims. Make one per group and hand it to each enemy through SetData.

local claims = VluxyAI.Claims.new()
-- in a state
local target = agent.Blackboard.SeenTarget
if target and claims:Claim(target, agent) then
	agent:MoveTo(target.Position)
end
-- in a Utility.Best call, so a claimed player scores low for everyone else
{ Input = claims:Consideration(0.2) }

Claims are released by the owner, by ReleaseAll, or when the owning agent is destroyed.

Functions​

new​

Claims.new() → Claims

ClaimedBy​

Claims.ClaimedBy(
self: Claims,
thing: any--

A root, a position key, a door: anything usable as a table key.

) → Agent?--

The live agent holding it, or nil when it is free.

Claim​

Claims.Claim(
self: Claims,
thing: any,
agent: Agent
) → boolean--

true when agent holds it now: it was free, or already theirs.

Takes thing for agent unless another live agent holds it.

IsFree​

Claims.IsFree(
self: Claims,
thing: any,
agent: Agent
) → boolean--

true when thing is free or held by agent.

Release​

Claims.Release(
self: Claims,
thing: any,
agent: Agent--

Only the holder can release.

) → ()

ReleaseAll​

Claims.ReleaseAll(
self: Claims,
agent: Agent
) → ()

Releases everything agent holds. Called for you when the agent is destroyed.

Owned​

Claims.Owned(
self: Claims,
agent: Agent
) → {any}--

Everything agent holds, in no particular order.

Consideration​

Claims.Consideration(
self: Claims,
takenScore: number?--

The input for a candidate another agent holds. Default 0, a veto.

) → Consideration<any>--

1 for a free candidate or one this agent holds, takenScore otherwise.

For Utility.Best and [Utility.Weighted]: makes the scoring prefer targets nobody else is on.

Destroy​

Claims.Destroy(self: Claims) → ()

Forgets every claim and stops watching every agent.

Show raw api
{
    "functions": [
        {
            "name": "new",
            "desc": "",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Claims"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 53,
                "path": "lib/Group/Claims.luau"
            }
        },
        {
            "name": "ClaimedBy",
            "desc": "",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "Claims"
                },
                {
                    "name": "thing",
                    "desc": "A root, a position key, a door: anything usable as a table key.",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "The live agent holding it, or `nil` when it is free.",
                    "lua_type": "Agent?"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 96,
                "path": "lib/Group/Claims.luau"
            }
        },
        {
            "name": "Claim",
            "desc": "Takes `thing` for `agent` unless another live agent holds it.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "Claims"
                },
                {
                    "name": "thing",
                    "desc": "",
                    "lua_type": "any"
                },
                {
                    "name": "agent",
                    "desc": "",
                    "lua_type": "Agent"
                }
            ],
            "returns": [
                {
                    "desc": "`true` when `agent` holds it now: it was free, or already theirs.",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 113,
                "path": "lib/Group/Claims.luau"
            }
        },
        {
            "name": "IsFree",
            "desc": "",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "Claims"
                },
                {
                    "name": "thing",
                    "desc": "",
                    "lua_type": "any"
                },
                {
                    "name": "agent",
                    "desc": "",
                    "lua_type": "Agent"
                }
            ],
            "returns": [
                {
                    "desc": "`true` when `thing` is free or held by `agent`.",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 130,
                "path": "lib/Group/Claims.luau"
            }
        },
        {
            "name": "Release",
            "desc": "",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "Claims"
                },
                {
                    "name": "thing",
                    "desc": "",
                    "lua_type": "any"
                },
                {
                    "name": "agent",
                    "desc": "Only the holder can release.",
                    "lua_type": "Agent"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 140,
                "path": "lib/Group/Claims.luau"
            }
        },
        {
            "name": "ReleaseAll",
            "desc": "Releases everything `agent` holds. Called for you when the agent is destroyed.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "Claims"
                },
                {
                    "name": "agent",
                    "desc": "",
                    "lua_type": "Agent"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 152,
                "path": "lib/Group/Claims.luau"
            }
        },
        {
            "name": "Owned",
            "desc": "",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "Claims"
                },
                {
                    "name": "agent",
                    "desc": "",
                    "lua_type": "Agent"
                }
            ],
            "returns": [
                {
                    "desc": "Everything `agent` holds, in no particular order.",
                    "lua_type": "{ any }"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 171,
                "path": "lib/Group/Claims.luau"
            }
        },
        {
            "name": "Consideration",
            "desc": "For [Utility.Best] and [Utility.Weighted]: makes the scoring prefer targets nobody else is on.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "Claims"
                },
                {
                    "name": "takenScore",
                    "desc": "The input for a candidate another agent holds. Default `0`, a veto.",
                    "lua_type": "number?"
                }
            ],
            "returns": [
                {
                    "desc": "`1` for a free candidate or one this agent holds, `takenScore` otherwise.",
                    "lua_type": "Consideration<any>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 188,
                "path": "lib/Group/Claims.luau"
            }
        },
        {
            "name": "Destroy",
            "desc": "Forgets every claim and stops watching every agent.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "Claims"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 202,
                "path": "lib/Group/Claims.luau"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "Claims",
    "desc": "A shared \"who is on what\" table for a group of agents, so two enemies never chase the same\nplayer or investigate the same noise unless you want them to. Exposed as\n`VluxyAI.Claims`. Make one per group and hand it to each enemy through `SetData`.\n\n```lua\nlocal claims = VluxyAI.Claims.new()\n-- in a state\nlocal target = agent.Blackboard.SeenTarget\nif target and claims:Claim(target, agent) then\n\tagent:MoveTo(target.Position)\nend\n-- in a Utility.Best call, so a claimed player scores low for everyone else\n{ Input = claims:Consideration(0.2) }\n```\n\nClaims are released by the owner, by `ReleaseAll`, or when the owning agent is destroyed.",
    "source": {
        "line": 48,
        "path": "lib/Group/Claims.luau"
    }
}