Skip to main content

Eating & Healing System

The eating system provides OSRS-accurate food consumption with proper eat delays, combat integration, and server-authoritative validation.
Eating code lives in packages/shared/src/systems/shared/character/EatDelayManager.ts and integrates with InventorySystem and PlayerSystem.

Overview

Food consumption follows Old School RuneScape mechanics:
  • 3-tick eat delay (1.8 seconds) between eating
  • Instant healing when food is consumed
  • Combat integration - eating delays your next attack
  • Server-authoritative - all validation happens server-side
  • Works at full health - shows message and applies delay even when HP is full

How to Eat

Inventory Context Menu

Right-click food in your inventory and select Eat:

Left-Click Primary Action

Left-click food to eat immediately (if “Eat” is the primary action in the manifest).

Eat Delay Mechanics

OSRS-Accurate Timing

EatDelayManager

The EatDelayManager tracks eat cooldowns per player:

Server-Authoritative Flow

1. Client Initiates

Player clicks “Eat” on food item:

2. Server Validates

Server receives useItem message and validates:

3. InventorySystem Processes

4. PlayerSystem Heals


Combat Integration

Attack Delay

Eating applies a 3-tick delay to your next attack:

PvP Gear + Eat Combos

OSRS allows rapid gear switching + eating combos. The system uses a separate rate limiter for consume actions to prevent abuse while allowing legitimate combos:

Food Types

Food items are defined in items.json manifest with healAmount:

Common Foods


Event Flow


Testing

The eating system has comprehensive test coverage:
Integration tests verify the full flow:


API Reference

EatDelayManager

Events


Configuration

Constants

Item Manifest

Food items require healAmount and type: "consumable":

Security Features

Server-Side Validation

All eating validation happens server-side:
  1. Slot verification - Item must exist at claimed slot
  2. Item matching - Item ID must match slot contents
  3. Eat delay check - Enforced via EatDelayManager
  4. Rate limiting - Separate consume rate limiter (100ms minimum)

Rate Limiting


OSRS Behavior Parity

Eating at Full Health

OSRS allows eating at full health (shows message, applies delay):

Combat Interaction

Eating during combat:
  1. Delays next attack by 3 ticks
  2. Does not cancel combat - auto-retaliate continues
  3. Instant healing - HP updates immediately
  4. No animation interrupt - combat animations continue

Implementation Details

Event-Driven Architecture

The eating system uses event-driven flow to avoid tight coupling:

Health Bar Updates

Health bars are event-driven only to prevent stale snapshot race conditions: