user-gearAdding Player Logic

In All Out, the player is a first-class gameplay object. Your Player :: class : Player_Base is where you put per-player state (health, loadouts, cooldowns, UI toggles, progression, etc).

circle-exclamation

Per-player state

Store gameplay state on the player or objects owned by the player.

Player :: class : Player_Base {
    health: int;
    inventory_open: bool;
}

Server + client: what runs where?

All Out automatically syncs gameplay state from the server to clients. You still need to decide what code should run on server vs what can be local-only.

Two common checks:

  • is_local_or_server(): gameplay UI + input handling (runs on server + local client)

  • is_local(): purely cosmetic UI/effects (runs only on the local client)

Player :: class : Player_Base {
    ao_late_update :: method(dt: float) {
        // Gameplay UI + input handling (server + local client)
        if is_local_or_server() {
            // draw_ability_button(this, Shoot_Ability, 0);
            // Handle taps/presses that change game state
        }

        // Cosmetic-only UI (local client only)
        if is_local() {
            // UI.text(..., "Waiting for host...");
            // Particles, screen shake, etc.
        }
    }
}
circle-info

If something affects the world (damage, rewards, spawning, win conditions), treat it as server-authoritative. If it’s just presentation (UI/particles), keep it local.

Player identity and profile data

Player_Base exposes identity fields you’ll use often:

  • p->get_username() -> string

  • p->get_user_id() -> string

  • p.avatar_color

  • p.device_kind (.PHONE, .TABLET, .PC)

Persistence: where to store player progress

  • Economy: currencies (coins/gems/xp) with automatic persistence + creator portal editing See Economy.

  • Save: general key/value persistence (settings, quest state, unlock lists, etc) See Save System.

  • Inventory: item stacks/instances in a player inventory (optionally auto-saved) See Inventory.

Common pattern: load saved values in ao_start

Best practices

  • Keep per-player state on Player. Avoid globals for anything player-specific.

  • Separate gameplay vs cosmetics. Use is_local_or_server() for gameplay input/UI, is_local() for local-only visuals.

  • Prefer the built-in persistence APIs instead of rolling your own (Economy/Save/Inventory).

Player_Base reference

See reference/player-base.md for commonly used fields and methods.

Last updated