Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ existing libs stand ([COMPLIANCE.md](COMPLIANCE.md)).
5. Template: an example of a lib-owned store (SPEC.md section 6, "Lib-owned
world state") once the Splatoon lib starts.
6. inklib-net and inklib-arena: spec only; start code when two libs comply.
7. Template: implement the host hooks (SPEC.md section 14) and loadout
(section 12) as a reference, with snapshot tests. Spec only so far.
8. COMPLIANCE.md: add an sp2 (Splatoon 2) table once its repo can be read.
4 changes: 4 additions & 0 deletions COMPLIANCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ C API v7 only. Every ❔ needs a look in the repo.
| 6 State hash | 🟡 A hash exists for the lockstep check (what it covers ❔). | Expose it as `fc_state_hash` = FNV-1a 64 over the snapshot bytes. The hash changes, so old lockstep peers do not match new ones (API v8 anyway). |
| 6 Event ids | ❔ | `id` (same on resimulation) and `tick` on every event. |
| 6 Input quantisation | ✅ The game reads PS1 pad bytes. | Make the stick handling depend only on `round(stick * 127)` (map it onto the pad byte), so inklib-net can send 4 stick bytes. |
| 12 Loadout | 🟡 Weapons per slot exist (15 VS weapons, 3 slots, `rearm`). List/equip shape unknown. | `fc_loadout_list`, `fc_equip`, `fc_equipped` in the weapons module; equipped weapons in the snapshot. |
| 14 Host hooks | unknown | Teleport, impulse, hurt (with `invulnerable_ticks`, HURT event), mount/unmount (libfc's pilot/park may map onto it), action enum, aim offset, in `fc_hooks.h`. |
| 13 Netcode out of the lib | ❔ The lockstep 1v1 code: inside libfc or in the host? | If it is inside libfc, move it out: it becomes the first piece of inklib-net (lockstep = the zero-rollback case). libfc keeps only snapshot, hash, events and replays. |
| 7 Camera | 🟡 The game's chase camera is in the state: position, pitch/yaw/roll, rotation rows. | `fc_char_camera`: `style` (`CHASE` / `TOP_DOWN`), `position`, `target`, `up`, `fov_y`. Pitch/yaw/roll and rows may stay as fields after the standard ones. Look input through `look_x/y`. |
| 8 Provenance | ❔ | `[Verified]` / `[Unverified]` on every tuning number, the tests, MEASURE.md. |
Expand Down Expand Up @@ -77,6 +79,8 @@ Read from OctoAlgo/libray3 at commit `484385e` (2026-10-31).
| 6 Event ids | ❌ No events yet. | Add events with `id` and `tick` from the start. |
| 6 Input quantisation | ❌ Stick floats are used as given. | Quantise to `round(stick * 127) / 127` in `ray3_char_input`. |
| 13 Netcode out of the lib | ✅ None. | None. |
| 12 Loadout | unknown (power-ups exist in the game: copter, big fist, ...). | `ray3_loadout_list` / `ray3_equip` / `ray3_equipped` for the power-ups. |
| 14 Host hooks | 🟡 Built for InkArena as C API 21-26: teleport + add impulse (21) and hurt (22) merged; mount (23), HURT event (24), action (25), aim offset (26) pending merge (libray3 #34-#37). | Check the names and return values against section 14 (hurt: 1 / 0 / -1), add `invulnerable_ticks` to the state, HURT = event type 5, action values from the common core, move the hooks into `ray3_hooks.h` + `ray3_get_hooks_api()`, and put their state in the snapshot. |
| 7 Camera | ❌ Out of scope in PLAN.md. MEASURE M6 notes that turning is done by the camera's script. | Ship Rayman 3's third-person camera (`THIRD_PERSON`): research, look input, `ray3_char_camera`. This is the largest piece of new work. |
| 8 Provenance | ✅ `[Verified]` / `[Unverified]` on every tuning field, `ProvenanceTests`, header comments checked by `HeaderTests`. | Add the "every UNVERIFIED field is in MEASURE.md" test. Today `CoyoteGroundGravity` and `LedgeGrabAllSides` are not named as `Tuning.X` there. |
| 9 Data rules | ✅ No game files, no copied code (CLAUDE.md rules 3-4), `.gitignore` backstop. | Add the CI data check. |
Expand Down
84 changes: 84 additions & 0 deletions SPEC.md
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,28 @@ gets its own standard when it starts:

Arena rules (meeting characters, scoring, unit scale between games) MUST NOT appear in a core lib.

### Loadout (optional)

The lib lists what its game offers and equips it from the user's game data. Examples: libfc's 15 VS
weapons in 3 slots; libray3's power-ups (copter, big fist, ...); sp2's kits (main + sub; the special
stays the host's "ultimate"). Durations, cooldowns, balance and UI are the host's job.

```c
typedef struct <p>_loadout_item {
uint32_t size;
int32_t id; /* lib-owned, stable, 1 or more */
int32_t slot; /* lib-defined slot number, 0 or more */
int32_t available; /* 1 if the user's data has it, 0 if not */
char name[64]; /* UTF-8, NUL-terminated, the game's name */
} <p>_loadout_item;

int32_t <p>_loadout_list(const <p>_world *world, <p>_loadout_item *out, int32_t max); /* count; max 0 = just count */
int32_t <p>_equip(<p>_world *world, int32_t char_id, int32_t slot, int32_t item_id); /* item 0 = empty the slot */
int32_t <p>_equipped(const <p>_world *world, int32_t char_id, int32_t slot); /* item id, 0 = empty */
```

What is equipped is part of the snapshot. Equipping uses the game's own rules for what the item does.

## 13. inklib-net (optional add-on, planned)

inklib-net is a later, separate add-on for online play. It is described here so every lib is built
Expand Down Expand Up @@ -456,3 +478,65 @@ It is GGPO-style rollback over any inklib (or several), through the function tab

What inklib-net does not do: matchmaking, NAT punch-through, accounts, voice. Those belong to the host.

## 14. Host hooks (optional)

Hosts that put a character into their own game (the InkArena battler is the first) need a few ways in.
They are optional: a lib MAY offer them; they cost nothing when unused; their state (hurt timers,
seat, aim offsets) is part of the snapshot. They live in `<p>_hooks.h` with a table from
`<p>_get_hooks_api()` (NULL if the lib has none). All values are in the world's unit convention.
Every lib documents in its header what each hook does in its game, and its own numbers are tagged
VERIFIED or UNVERIFIED like any tuning (UNVERIFIED until recorded in the game).

```c
/* Moves the character without making a new one. Works in the air: it stands if there is ground under
feet and velocity is not upwards, else it falls. Running sequences (a jump, a climb) end;
equipment stays. reset_camera 1 puts the camera back behind the character. */
int32_t <p>_teleport(<p>_world *w, int32_t id, const <p>_vec3 *feet, const <p>_vec3 *velocity,
double yaw, int32_t reset_camera);

/* Velocity change. In the air it adds. On the ground only an upward part counts: if there is one, the
whole impulse applies and the character leaves the ground; if not, nothing happens. */
int32_t <p>_add_impulse(<p>_world *w, int32_t id, const <p>_vec3 *impulse);

/* Hurts the character: a hurt state with knockback along direction (unit vector) scaled by strength,
then no-control ticks and invulnerable ticks (lib values). Returns 1 if hurt, 0 if invulnerable,
-1 on error (last error set). Emits <P>_EVENT_HURT. */
int32_t <p>_hurt(<p>_world *w, int32_t id, const <p>_vec3 *direction, double strength);

/* Pins the character to a seat (vehicles, rides). Call every tick before <p>_world_tick while seated.
Velocity becomes the seat's motion; movement input is ignored. Whether attacks stay allowed and
whether a hurt unmounts are the lib's choice, documented in its header. */
int32_t <p>_mount(<p>_world *w, int32_t id, const <p>_vec3 *seat, double yaw);
int32_t <p>_unmount(<p>_world *w, int32_t id, const <p>_vec3 *impulse); /* impulse may be NULL */

/* The animation the character shows this tick: <P>_ACTION_*, -1 on error. */
int32_t <p>_get_action(const <p>_world *w, int32_t id);

/* Where to aim at a host target (target = the host's id, as in <p>_hit.actor): the game's rule plus
offset. NULL offset goes back to the game's rule alone. */
int32_t <p>_set_aim_offset(<p>_world *w, int32_t id, int32_t target, const <p>_vec3 *offset);
```

- **Invulnerability.** `<p>_state` gains `invulnerable_ticks` (ticks left, 0 = can be hurt), appended
at the end like any new field.
- **HURT event.** `<P>_EVENT_HURT` = 5 (standard). `position` = where, `a` = strength x 1000 rounded,
`b` = invulnerable ticks given.
- **Action.** A lib-owned enum next to the movement state, for the host's animation. It is never the
game's own state numbers (those may change as a lib learns more). Recommended common core, so hosts
can share animation sets; a lib uses the ones its game has and adds its own from 256:

| Value | Name | Value | Name |
|---|---|---|---|
| 0 | `IDLE` | 9 | `JUMP_APEX` |
| 1 | `MOVE_START` | 10 | `FALL` |
| 2 | `MOVE` | 11 | `LAND` |
| 3 | `MOVE_STOP` | 12 | `HARD_LAND` |
| 4 | `STRAFE_FORWARD` | 13 | `HURT` |
| 5 | `STRAFE_BACK` | 14 | `MOUNTED` |
| 6 | `STRAFE_LEFT` | 15 | `ATTACK_CHARGE` |
| 7 | `STRAFE_RIGHT` | 16 | `ATTACK` |
| 8 | `JUMP_RISE` | | |

- `<p>_hurt` returns 0 for "invulnerable", which is not an error: this is the one exception to the
return rule in section 2, and -1 is its error.

Loading