Skip to main content

Systems Architecture

Hyperscape game logic is implemented through Systems — classes that process entities and components each game tick. Systems are organized by domain and split between client, server, and shared execution contexts.

System Base Class

All systems extend SystemBase which provides:
  • Dependency management (required/optional systems)
  • Lifecycle hooks (init, update, cleanup)
  • World reference for entity queries
  • Auto-cleanup on destroy

Core Game Systems

Combat System

Location: systems/shared/combat/ The combat system implements OSRS-style tick-based combat with 20+ supporting files:
Combat runs on a 600ms tick cycle, matching Old School RuneScape exactly.

Duel Arena System

Location: packages/server/src/systems/DuelSystem/ Player-vs-player dueling with stakes and customizable rules: Features:
  • 10 toggleable combat rules (no ranged, no food, no forfeit, etc.)
  • 11 equipment slot restrictions
  • Item staking with anti-scam protection
  • 6 dedicated arenas with wall collision
  • Disconnect handling (30s grace period)
  • Comprehensive unit tests (1700+ lines)
See Duel Arena System for complete documentation.

Economy Systems

Location: systems/shared/economy/ Handles all economic interactions:
  • Banking — Deposit, withdraw, note conversion (480-slot bank with tabs)
  • Shops — Buy/sell with general stores
  • Trading — Player-to-player item exchange (see TradingSystem)
  • Inventory — 28-slot management with stacking
  • Loot — Item drops and ground items

Movement & Collision System

Location: systems/shared/movement/ Implements tile-based movement and OSRS-accurate collision:
  • TileSystem.ts — Grid-based coordinate system
  • CollisionMatrix.ts — Zone-based collision storage (8×8 tile zones)
  • CollisionFlags.ts — Bitmask flags (BLOCKED, WATER, OCCUPIED, walls)
  • EntityOccupancyMap.ts — Entity tracking with collision integration
  • BFSPathfinder.ts — Breadth-first search pathfinding around obstacles
  • ChasePathfinding.ts — Combat chase behavior
  • WanderBehavior.ts — NPC wandering AI
Collision Features:
  • Static object blocking (trees, rocks, stations)
  • Multi-tile footprints (2×2 furnaces, large resources)
  • Directional walls (for future dungeons)
  • Network synchronization (zone serialization)
  • Safespotting mechanics (OSRS-accurate)

World Systems

Location: systems/shared/world/ Manages world generation and environment:
  • TerrainSystem.ts — Procedural terrain with flat zones for stations (see Terrain System)
  • WaterSystem.ts — Water rendering and physics
  • VegetationSystem.ts — Procedural tree/rock placement
  • RoadNetworkSystem.ts — Road generation between towns
  • SkySystem.ts — Day/night cycle
  • Environment.ts — Lighting and atmosphere
Terrain Features:
  • Noise-based procedural generation (50m max height)
  • Flat zones under stations with smooth blending
  • Spatial indexing for O(1) flat zone lookup
  • Biome-based height modulation
  • Water threshold detection

Character Systems

Location: systems/shared/character/ Player character management:
  • Stats tracking — Levels, XP, combat level
  • Equipment — Gear slots and bonuses
  • Skills — 13 trainable skills (6 combat, 3 gathering, 4 artisan)

Progression Systems

Location: systems/shared/progression/ Player progression and achievement tracking:
  • Quest System — OSRS-style quests with multi-stage objectives, requirements, and rewards
  • Quest Points — Accumulated from quest completions
  • XP Lamps — Quest reward items that grant XP to chosen skill

Quest System

Location: systems/shared/progression/QuestSystem.ts OSRS-style quest system with multi-stage quests:
  • Quest definitions — JSON manifest-driven quest content
  • Progress tracking — Per-player database persistence
  • Stage types — Dialogue, kill, gather, interact, craft
  • Quest points — Accumulated across completions
  • Security — HMAC kill token validation, audit logging
  • Performance — O(1) stage lookups, object spread elimination

Duel Arena System

Location: systems/server/DuelSystem/ Server-authoritative PvP dueling system with OSRS-accurate mechanics:
  • Challenge Management — 30-second challenge requests with distance validation
  • Arena Pooling — 6 dedicated arenas with automatic reservation
  • Rules Negotiation — 10 combat rules + 11 equipment restrictions
  • Stake System — Item staking with anti-scam protections
  • Combat Resolution — Death handling, forfeit mechanics, stake transfers
  • Audit Logging — Complete economic tracking for all duel outcomes
Key Components:
  • DuelSystem.ts — Main orchestrator (1,609 lines)
  • PendingDuelManager.ts — Challenge lifecycle management
  • ArenaPoolManager.ts — Arena reservation and collision
  • DuelSessionManager.ts — Session CRUD operations
  • DuelCombatResolver.ts — Outcome resolution and stake transfers
See the Duel Arena documentation for complete implementation details.

Combat Constants

The combat system uses OSRS-accurate constants:

Level Constants


Skills System

Hyperscape implements 14 skills with OSRS-accurate mechanics:

Combat Skills

Gathering Skills

Artisan Skills

Support Skills

Each skill has independent XP tracking and levels 1-99 following OSRS XP curves. Agility is unique in that it trains passively as you move around the world.

Quest System

Location: systems/shared/progression/ OSRS-style quest system with multi-stage progression: Features:
  • Multi-stage quests (kill, gather, interact, dialogue)
  • Quest requirements (prerequisite quests, skill levels, items)
  • Quest points and rewards (items, XP)
  • HMAC kill token validation (prevents spoofing)
  • Rate limiting (5/sec list, 10/sec detail, 3/sec accept)
  • Quest audit logging for security
  • O(1) stage lookup caches for performance
Database Tables:
  • quest_progress — Player quest state (status, current stage, progress)
  • quest_audit_log — Immutable audit trail for all quest actions
  • characters.questPoints — Total quest points earned

Attack Styles

Players choose how combat XP is distributed:

Mob Aggression


Event System

Systems communicate through typed events:


Detailed Documentation

Combat System

OSRS-accurate damage formulas, attack styles, aggro system, and death mechanics.

Duel Arena

Player-vs-player dueling with rules, stakes, arenas, and anti-scam protections.

Skills & Progression

RuneScape XP curves, leveling, combat level formula, and skill requirements.

Trading System

Player-to-player trading with two-screen confirmation and security features.

Social System

Friend management, private messaging, and player interactions.

Tile Movement

Discrete tile-based movement, pathfinding, and OSRS melee range rules.