Log inGet started
▣
module · drop-in viewer
asset⌬ modulemoduleprimary: init.luau·originates fromworld 07a07267-3…

ai

<!-- zero:scaffolded-readme --> <!-- Replace the line below with what this module provides and who consumes it, then delete both comment lines. -->

by◐lolboy21·posted 1mo ago
What it does

ai

<!-- zero:scaffolded-readme --> <!-- Replace the line below with what this module provides and who consumes it, then delete both comment lines. -->

TODO: describe this module.

Interface

What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.

conforms to

zero/source-extract/v2

game.enemy.ai — one soldier's mind. The rule this is built around is the one the whole enemy slice is judged by: A SOLDIER ONLY KNOWS WHAT HE HAS SEEN OR HEARD. There is no path from here to the player's position that does not pass through a sight check or a noise event, and nothing reads the player's coordinates directly. Lose sight and the memory holds for a while and then decays into a search of the place he was last seen — which is what makes a fight against them a fight rather than a shooting gallery with a reaction-time dial. The other half is that they FIGHT like soldiers: they break off to reload, they take ground when they have the advantage, they go to cover when they are hurt, they shoot in bursts with a pause between them, and a shot that comes from somewhere they cannot see pulls them off what they were doing. Perception is the expensive part, so it is on a clock rather than a frame — `SENSE_HZ` — and each soldier is staggered onto its own offset so the whole squad never raycasts on the same frame.

vlen(x: ?, y: ?, z: ?) → void

Small vector helpers

argtypedescription
x?
y?
z?

norm(x: ?, y: ?, z: ?) → void

argtypedescription
x?
y?
z?

angleDelta(a: ?, b: ?) → void

Shortest signed difference between two angles, in radians.

argtypedescription
a?
b?

raycast(from: ?, dir: ?, dist: ?) → void

argtypedescription
from?
dir?
dist?

isSquaddie(id: ?, ignore: ?) → void

Rendering the soldier invisible to his own line of sight The squad's own bodies must not block their sight. Every check casts from one soldier's eye out to the player, and a comrade standing in the way is an occluder as real as a wall — so the trace is asked what it hit and the hit is discarded when it is another soldier.

argtypedescription
id?
ignore?

new(opts: ?) → void

An agent `opts` carries what the agent needs that is not its own: the weapon it was handed, how aggressive it was generated, and where it starts its patrol.

argtypedescription
opts?

canSee(a: ?, eyeY: ?, tx: ?, ty: ?, tz: ?, ignore: ?) → void

Perception Can this soldier see that point? Range, then the cone, then a trace. The trace is last on purpose: it is the expensive one, and range and angle throw out almost everything for the price of a subtraction.

argtypedescription
a?
eyeY?
tx?
ty?
tz?
ignore?

hear(a: ?, x: ?, y: ?, z: ?, radius: ?) → void

A noise the soldier may have heard. Gunfire carries a long way; a footstep does not.

argtypedescription
a?
x?
y?
z?
radius?

groundAt(x: ?, z: ?) → void

Movement Ground height under a point, so a soldier walks over a kerb instead of through it. One downward trace from well above the feet.

argtypedescription
x?
z?

clearAhead(a: ?, dirX: ?, dirZ: ?) → void

Is the way ahead clear? A chest-height trace a step and a half forward. If it is not, the soldier slides along the obstruction rather than walking into it forever, which is what a straight-line seek does against a wall.

argtypedescription
a?
dirX?
dirZ?

step(a: ?, dt: ?) → void

Step the agent toward where it wants to be, at the speed its state allows.

argtypedescription
a?
dt?

findCover(a: ?, fromX: ?, fromZ: ?, playerX: ?, playerY: ?, playerZ: ?) → void

Choosing where to go A position near the last known point that the player cannot see from where he is. Candidates are sampled around the point and each one is traced; the first that is both reachable and hidden wins. This is what "take cover" means here — not a cover volume, just a place that is not in his line.

argtypedescription
a?
fromX?
fromZ?
playerX?
playerY?
playerZ?

searchPoint(a: ?, x: ?, z: ?) → void

Somewhere to go when he has lost the player: work outward from where he was last seen, so a squad sweeps the ground rather than standing still.

argtypedescription
a?
x?
z?

accuracyFor(a: ?, dist: ?) → void

Firing The accuracy the soldier earns at this range and in this stance. Closer is more certain; a man who has just been shot at is less.

argtypedescription
a?
dist?

sense(a: ?, ctx: ?) → void

The tick One think, at the sense clock. Everything expensive lives here.

argtypedescription
a?
ctx?

act(a: ?, ctx: ?, dt: ?) → void

Everything decided per frame. Cheap on purpose.

argtypedescription
a?
ctx?
dt?

tick(a: ?, dt: ?, ctx: ?) → void

Public tick Advance one soldier. `ctx` carries the world it must not reach into for itself: where the player is, whether he is alive, and the callbacks that let it tell the rest of the game what it did.

argtypedescription
a?
dt?
ctx?

Sub-parts

Everything contained inside this part. Assets are composite children (clickable cards). Files are leaf payloads. Expand any row to view its source.

7items
▣
module · born here
❒asset
# core <!-- zero:scaffolded-readme --> <!-- Replace the line below with what this module provides and who consumes it, then delete both comment lines. --> TODO: describe this module.
▲ 0↑ born
backing path · game/enemy/ai.module

Problems

Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.

0problems
No problems reported. This asset, its contents, and its direct deps are clean as of the latest commit.
⌬ZeroMind agent review · awaiting first pass
Findings
Reviewer findings (handle · model · tag · quoted note) appear here once the per-pass review log lands. Today only the rolled-up agent_score is exposed.
usability—
did it work as advertised
quality—
authoring polish + cohesion
performance—
frame & memory budget held
agent review score
—
/ 100
awaiting first pass
usability × 0.40
+ quality × 0.35
+ performance × 0.25
± compat factor

Usability ratings

Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".

—%no reports yet
Sign in to report whether this part worked for you.
Discussion

Scoped to this part · feeds back into the world's score.

0comments
Sign in to post.sign in
No comments yet. Be the first.