Overview
AimForge is a four-stage real-time pipeline. Understanding the stages — and where your script fits in — is the fastest way to write useful scripts.
The pipeline
Capture → Inference → Script(s) → Output
| Stage | What happens |
|---|---|
| Capture | Screen frames are grabbed at the configured FPS (typically 240 Hz). |
| Inference | The active YOLO model runs on the latest frame. Detections (x, y, w, h, confidence, etc.) are produced. |
| Script(s) | Your .afp script(s) receive the detection plus all runtime state, and produce an output tuple (x, y, z). |
| Output | The output tuple is sent to the active input device (controller, makcu, mouse, keyboard). |
The script stage is the only part that's user-programmable. Everything before it gives you data; everything after it acts on what you return.
Per-frame execution
Your script runs once per detection (or once per output cycle if no detection is present, depending on settings). All the built-in variables — detection, confidence, dt, controller, etc. — are repopulated each call. Your job is:
- Read the current state
- Decide what to output (the X/Y aim adjustment, and optionally
zrestriction) -
return (x, y);orreturn (x, y, z);
if (confidence > 0.6) {
x = detection.x - center_x;
y = detection.y - center_y;
}
return (x, y);
Multiple scripts in a pipeline
You can chain several scripts together. Each script receives the output of the previous one as its starting x, y, z. Common pattern:
| Slot | Role |
|---|---|
| Slot 1 | "Targeting" — pick which detection to follow, set base x/y |
| Slot 2 | "Smoothing" — apply PID, EMA, or curves to x/y |
| Slot 3 | "Restriction" — gate output by FOV, button state, etc. |
| Slot 4 | "Output shaping" — scale to device, apply final clamps |
Use shared.* to coordinate state between scripts (see State & persistence).
State at a glance
Three persistence layers, each with different scope:
-
state.*— survives frame-to-frame, scoped to this script. Use for PID accumulators, smoothing history, frame counters. -
shared.*— survives across all scripts in the same pipeline. Use for cross-script flags and coordination. -
settings.*— values from GUI controls (//!gui:slider,//!gui:dropdown, etc.). Persisted to a.inipreset file.
A minimal complete script
//!gui:slider var=strength label="Aim Strength" min=0 max=1 default=0.5
// Skip if no confident detection
if (confidence < 0.5) {
return (0, 0);
}
// Compute the aim offset, scaled by the strength slider
x = (detection.x - center_x) * settings.strength;
y = (detection.y - center_y) * settings.strength;
return (x, y);
That's a real, working aim-assist script. It exposes a Strength slider in the GUI, checks for a confident detection, and returns a scaled offset toward the target.
Where to next
- Your first script — write it line-by-line, with explanations
-
Scripting language reference — the full
.afpsyntax - Built-in variables — every implicit global you can read
- Examples — production-ready scripts to copy from