1---2name: godot-genre-fighting3description: Expert blueprint for fighting games including frame data (startup/active/recovery frames, advantage on hit/block), hitbox/hurtbox systems, input buffering (5-10 frames), motion input detection (QCF, DP), combo systems (damage scaling, cancel hierarchy), character states (idle/attacking/hitstun/blockstun), and rollback netcode. Based on FGC competitive design. Trigger keywords: fighting_game, frame_data, hitbox_hurtbox, input_buffer, motion_inputs, combo_system, rollback_netcode, cancel_system, advantage_frames.4---5
6## NEVER Do (Expert Anti-Patterns)
7
8### Frame-Data & Logic
9- NEVER use variable framerates; strictly lock logic to a **Deterministic Fixed Loop** (using `_physics_process` with a frame-counter) and call **`reset_physics_interpolation()`** on teleport.
10- NEVER use standard Physics for hit detection; strictly use **`PhysicsDirectSpaceState.intersect_shape()`** to query hitboxes instantly without Area2D signal lag.
11- NEVER skip **Damage Scaling**; strictly apply 10% reduction per hit in a combo to prevent infinite matches.
12- NEVER make all moves safe on block; strictly ensure high-reward moves have **Recovery Windows** where the attacker is punishable.
13- NEVER rely on `Area2D.get_overlapping_areas()`; strictly use **`intersect_shape()`** for immediate, frame-perfect resolution.
14- NEVER forget **Hitbox Proximity (Proximity Guard)**; strictly trigger guard states when a hitbox enters a nearby zone, even if it hasn't landed.
15
16### Character & Animation
17- NEVER use simple parenting (`scale.x = -1`) for character flip; strictly adjust the dedicated **Visuals node** while managing hitbox offsets programmatically.
18- NEVER use string-based animation triggers; strictly use `AnimationMixer` with `ADVANCE_MANUAL` for frame-synced playback.
19- NEVER use `yield` or `await` for frame-critical logic; strictly use **Integer Frame Counting** within state machines to manage recovery/startup windows perfectly.
20- NEVER store frame data in raw scripts; strictly use **`Resource` files (.tres)** with delegated logic for damage scaling, cancels, and combo-state tracking.
21- NEVER use deep node hierarchies for character parts; strictly keep skeletons shallow to reduce transformation overhead.
22
23### Input & Networking
24- NEVER skip **Input Buffering**; strictly implement a 5-10 frame buffer to ensure lenient, responsive execution for the player.
25- NEVER leave `Input.use_accumulated_input` enabled; strictly disable it to preserve sub-frame timing for precise combo links.
26- NEVER use client-side hit detection for netplay; strictly use **rollback netcode** or server validation to prevent desyncs.
27- NEVER use standard TCP for multiplayer; strictly use **UDP/ENet** to avoid head-of-line blocking during latency spikes.
28- NEVER rely on the SceneTree for fighter transforms in netplay; strictly manage positions in a **serializable data buffer**.
29
30---
31
32## 🛠 Expert Components (scripts/)
33
34> **MANDATORY reads** before implementing the matching system:
35> 1. [fighting_input_buffer.gd](scripts/fighting_input_buffer.gd) — buffers + motion (QCF/DP)
36> 2. [direct_hitbox_query.gd](scripts/direct_hitbox_query.gd) — **exclusive** hit resolution path (`intersect_shape`)
37> 3. [rollback_state_serializer.gd](scripts/rollback_state_serializer.gd) — snapshot/restore for netplay
38
39### Original Expert Patterns
40- [fighting_input_buffer.gd](scripts/fighting_input_buffer.gd) - Frame-locked input engine (60fps) with motion command fuzzy matching (QCF/DP).
41- [hitbox_component.gd](scripts/hitbox_component.gd) - Hitbox/hurtbox volume helper (layers High/Low/Throw) — resolve hits via **direct_hitbox_query**, not Area signals.
42
43### Modular Components
44- [deterministic_physics_loop.gd](scripts/deterministic_physics_loop.gd) - Custom loop pattern for frame-perfect game state progression.
45- [direct_hitbox_query.gd](scripts/direct_hitbox_query.gd) - PhysicsServer shape-casting for immediate collision resolution.
46- [hit_stop_controller.gd](scripts/hit_stop_controller.gd) - Dynamic time-scale manipulation for "impact" feel.
47- [manual_animation_advancer.gd](scripts/manual_animation_advancer.gd) - Frame-synced animation control via manual delta processing.
48- [rollback_state_serializer.gd](scripts/rollback_state_serializer.gd) - Serialization logic for managing discrete game state snapshots.
49- [bitwise_state_flags.gd](scripts/bitwise_state_flags.gd) - High-performance bitwise flags for fighter state tracking.
50- [input_accumulation_control.gd](scripts/input_accumulation_control.gd) - Toggle for disabling Godot's input accumulation for sub-frame timing.
51- [raw_byte_network_sync.gd](scripts/raw_byte_network_sync.gd) - UDP-based state synchronization for netplay efficiency.
52- [string_name_optimization.gd](scripts/string_name_optimization.gd) - Pattern for using pointer-level `StringName` comparisons in AI states.
53- [round_timer_logic.gd](scripts/round_timer_logic.gd) - Logic for frame-synced match timers and timeout triggers.
54
55### Restored from baseline (load on demand)
56- [attack_resource.gd](scripts/attack_resource.gd) - `.tres` frame-data Resource (startup/active/recovery, advantage).
57- [combo_tracker.gd](scripts/combo_tracker.gd) - Damage scaling (~10%/hit) and combo state.
58- [fighter_state_machine.gd](scripts/fighter_state_machine.gd) - IDLE/ATTACKING/HITSTUN with integer `state_frame`.
59- [fight_game_state.gd](scripts/fight_game_state.gd) - Serializable rollback snapshot shell (pair with [rollback_state_serializer.gd](scripts/rollback_state_serializer.gd)).
60- [move_set_loader.gd](scripts/move_set_loader.gd) - JSON move-list loader for designer iteration.
61- [frame_advancer.gd](scripts/frame_advancer.gd) - `@tool` editor frame scrubber for hitbox alignment.
62- [fighter_balance_profile.gd](scripts/fighter_balance_profile.gd) - Per-roster damage/movement/defense scaling Resource.
63
64---
65
66## Core Loop
67
68`Neutral → Confirm Hit → Combo → Advantage → Repeat`
69
70## Decision Trees (no Area2D / inline system dumps)
71
72### Frames & fixed loop
73| Need | Action |
74|------|--------|
75| Attack timing Resource | `.tres` with startup/active/recovery/advantage — not script constants |
76| 60fps sim step | [deterministic_physics_loop.gd](scripts/deterministic_physics_loop.gd) |
77| Anim sync to frames | [manual_animation_advancer.gd](scripts/manual_animation_advancer.gd) (`ADVANCE_MANUAL`) |
78
79### Input
80| Need | Action |
81|------|--------|
82| 5–10f buffer + QCF/DP | **MANDATORY** [fighting_input_buffer.gd](scripts/fighting_input_buffer.gd) |
83| Sub-frame links | [input_accumulation_control.gd](scripts/input_accumulation_control.gd) — disable accumulated input |
84
85### Hitboxes
86| Need | Action |
87|------|--------|
88| Frame-perfect hit | **MANDATORY exclusively** [direct_hitbox_query.gd](scripts/direct_hitbox_query.gd) |
89| Volume authoring helper | [hitbox_component.gd](scripts/hitbox_component.gd) for shapes/layers — **never** `area_entered` / `get_overlapping_areas` for resolution |
90| Proximity guard | Query expanded shape before active frames land |
91
92### Combos / cancels
93| Need | Action |
94|------|--------|
95| Damage scaling ~10%/hit | Track in combo state; store cancel hierarchy on Attack Resources |
96| States | IDLE/ATTACKING/HITSTUN/BLOCKSTUN… with integer `state_frame` — peer [godot-state-machine-advanced](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-state-machine-advanced/SKILL.md) |
97
98### Netcode
99| Need | Action |
100|------|--------|
101| Snapshots | **MANDATORY** [rollback_state_serializer.gd](scripts/rollback_state_serializer.gd) |
102| Transport | UDP/ENet via [raw_byte_network_sync.gd](scripts/raw_byte_network_sync.gd); peer [godot-multiplayer-networking](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-multiplayer-networking/SKILL.md) |
103
104---
105
106## Balance Guidelines
107
108| Element | Guideline |
109|---------|-----------|
110| Health | 10,000-15,000 for ~20 second rounds |
111| Combo damage | Max 30-40% of health per touch |
112| Fastest moves | 3-5 frames startup (jabs) |
113| Slowest moves | 20-40 frames (supers, overheads) |
114| Throw range | Short but reliable |
115| Meter gain | Full bar in ~2 combos received |
116
117For roster / matchup simulation, use [godot-monte-carlo-balancer](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-monte-carlo-balancer/SKILL.md).
118
119## Common Pitfalls
120
121| Pitfall | Solution |
122|---------|----------|
123| Infinite combos | Hitstun decay + gravity scaling |
124| Area2D signal hits | Replace with [direct_hitbox_query.gd](scripts/direct_hitbox_query.gd) |
125| Lag input drops | Buffer 8+ frames |
126| Desync | Deterministic loop + rollback serializer |
127
128## Expert knowledge (on demand)
129
130> **LLM-ignorance rule:** If a general agent would not know it before reading, load the reference — never delete expert deltas.
131
132- [expert-fighting-patterns.md](references/expert-fighting-patterns.md) — restored baseline pedagogy (architecture, WHY, implementation depth)
133- [attack_resource.gd](scripts/attack_resource.gd)
134- [combo_tracker.gd](scripts/combo_tracker.gd)
135- [fighter_state_machine.gd](scripts/fighter_state_machine.gd)
136- [fight_game_state.gd](scripts/fight_game_state.gd)
137- [move_set_loader.gd](scripts/move_set_loader.gd)
138- [frame_advancer.gd](scripts/frame_advancer.gd)
139- [fighter_balance_profile.gd](scripts/fighter_balance_profile.gd)
140
141## Reference
142
143> Progressive disclosure: open Official Documentation links only when researching a specific API;
144> load Related Skills when routing work to a peer domain — do not preload the whole lattice.
145
146### Official Documentation
147- [Idle and physics processing](https://docs.godotengine.org/en/stable/tutorials/scripting/idle_and_physics_processing.html) — Fighting logic must run on a fixed physics tick (or custom frame counter), not variable `_process` deltas.
148- [Input](https://docs.godotengine.org/en/stable/classes/class_input.html) — Disable `use_accumulated_input` and sample actions per frame so buffers and motion windows stay deterministic.
149- [Input examples](https://docs.godotengine.org/en/stable/tutorials/inputs/input_examples.html) — Action maps and event handling patterns behind 5–10 frame buffers and motion detection.
150- [Controllers, gamepads, and joysticks](https://docs.godotengine.org/en/stable/tutorials/inputs/controllers_gamepads_joysticks.html) — Stick deadzones and digital gate thresholds for clean QCF/DP direction history.
151- [Using Area2D](https://docs.godotengine.org/en/stable/tutorials/physics/using_area_2d.html) — Hitbox/hurtbox volumes, monitoring vs monitorable, and why signal lag is often too late for frame-perfect trades.
152- [Physics introduction](https://docs.godotengine.org/en/stable/tutorials/physics/physics_introduction.html) — Collision layers/masks for High/Low/Throw filtering instead of string groups in the hot path.
153- [PhysicsDirectSpaceState2D](https://docs.godotengine.org/en/stable/classes/class_physicsdirectspacestate2d.html) — Immediate `intersect_shape` hit resolution without waiting on `Area2D` overlap signals.
154- [PhysicsShapeQueryParameters2D](https://docs.godotengine.org/en/stable/classes/class_physicsshapequeryparameters2d.html) — Shape query setup (mask, exclude, collide_with_areas) for direct hitbox checks.
155- [AnimationMixer](https://docs.godotengine.org/en/stable/classes/class_animationmixer.html) — `ADVANCE_MANUAL` / callback mode so attack clips advance in lockstep with integer frame data.
156- [Resources](https://docs.godotengine.org/en/stable/tutorials/scripting/resources.html) — Store startup/active/recovery, cancels, and balance profiles as `.tres` data—not hardcoded script constants.
157- [High-level multiplayer](https://docs.godotengine.org/en/stable/tutorials/networking/high_level_multiplayer.html) — Authority, RPCs, and peer roles when adding netplay around a deterministic fighter sim.
158- [ENetMultiplayerPeer](https://docs.godotengine.org/en/stable/classes/class_enetmultiplayerpeer.html) — UDP/ENet transport for rollback-friendly input exchange without TCP head-of-line blocking.
159
160### Related Skills
161
162#### Prerequisites
163- [godot-project-foundations](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-project-foundations/SKILL.md) — Physics tick rate, input map, and project defaults must be locked before frame-data systems stay deterministic.
164- [godot-input-handling](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-input-handling/SKILL.md) — Action sampling, device mapping, and buffer-friendly input plumbing under motion commands and cancels.
165- [godot-2d-physics](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-2d-physics/SKILL.md) — Layers/masks and direct space queries are the substrate for hitbox/hurtbox resolution without Area signal lag.
166- [godot-characterbody-2d](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-characterbody-2d/SKILL.md) — Grounded movement, facing, and teleport/`reset_physics_interpolation` contracts fighters still need outside pure hit detection.
167
168#### Complements
169- [godot-combat-system](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-combat-system/SKILL.md) — Shared DamageData / hit confirm patterns that fighting frame data specializes into startup-active-recovery windows.
170- [godot-animation-player](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-animation-player/SKILL.md) — Hitbox enable tracks, cancel frames, and recovery locks driven from animation rather than free-running timers.
171- [godot-state-machine-advanced](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-state-machine-advanced/SKILL.md) — IDLE/ATTACKING/HITSTUN/BLOCKSTUN FSMs with integer `state_frame` counters instead of `await`-based recovery.
172- [godot-resource-data-patterns](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-resource-data-patterns/SKILL.md) — Move lists, cancel tables, and FighterBalanceProfile resources with safe duplication per fighter instance.
173- [godot-signal-architecture](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-signal-architecture/SKILL.md) — Hit confirm, round end, and HUD events without coupling the sim loop to presentation nodes.
174- [godot-multiplayer-networking](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-multiplayer-networking/SKILL.md) — Peer sync, RPC discipline, and authoritative validation around rollback or delayed-input netcode.
175- [godot-adapt-single-to-multiplayer](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-adapt-single-to-multiplayer/SKILL.md) — Prediction, reconciliation, and lobby/late-join patterns when a local fighter becomes netplay-ready.
176
177#### Downstream / consumers
178- [godot-monte-carlo-balancer](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-monte-carlo-balancer/SKILL.md) — Simulate matchup matrices, damage scaling, and punish windows across the roster instead of guessing from AFK→pro PvE bands.
179
180#### Master
181- [godot-master](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-master/SKILL.md) — Library router and mirrored module entry for discovering fighting peers and syncing shared script mirrors.