Skip to main content

Prayer System

The prayer system provides temporary combat and utility bonuses at the cost of prayer points. Prayers drain over time and can be recharged at altars. The system uses OSRS-accurate drain formulas and manifest-driven prayer definitions.
Prayer code lives in:
  • packages/shared/src/systems/shared/character/PrayerSystem.ts - Core prayer logic
  • packages/shared/src/data/PrayerDataProvider.ts - Prayer manifest loading
  • packages/server/src/systems/ServerNetwork/handlers/prayer.ts - Network handlers
  • packages/server/world/assets/manifests/prayers.json - Prayer definitions

Overview

Prayers are temporary buffs that:
  • Provide combat bonuses (attack, strength, defense)
  • Drain prayer points over time
  • Can be toggled on/off via the Skills panel
  • Require specific Prayer levels to activate
  • Conflict with other prayers in the same category

Prayer Points

Maximum Prayer Points

Prayer points scale with Prayer level using the OSRS formula:

Recharging Prayer Points

Prayer points can be recharged by:
  1. Praying at altars - Restores to maximum instantly
  2. Prayer potions (not yet implemented)
  3. Leveling up Prayer - Restores to new maximum

Prayer Drain

Prayers drain points over time based on their drain effect and your prayer bonus.

Drain Formula

Drain Examples

With 0 prayer bonus (no equipment): With +10 prayer bonus (holy symbol):
Prayer bonus from equipment reduces drain rate. Each +1 prayer bonus adds 2 to drain resistance.

Drain Processing

The system processes drain every game tick (600ms):

Available Prayers

Prayers are defined in manifests/prayers.json and loaded via PrayerDataProvider.

Defensive Prayers

Offensive Prayers

More prayers can be added by editing manifests/prayers.json without code changes.

Prayer Bonuses

Prayers modify effective combat levels for damage and accuracy calculations:

Bonus Application

Bonuses are applied to effective levels before damage calculation:

Example Calculation

Without prayer:
  • Strength level: 70
  • Effective strength: 70 + 8 + 3 = 81
  • Max hit: 18
With Burst of Strength (+5%):
  • Strength level: 70
  • Effective strength: (70 + 8 + 3) × 1.05 = 85
  • Max hit: 19

Prayer Conflicts

Prayers in the same category conflict with each other. Activating a new prayer automatically deactivates conflicting prayers.

Conflict Resolution


Prayer Altars

Altars are interactable entities that restore prayer points to maximum.

Altar Entity

Interaction

Players can:
  • Left-click: Pray at altar (restores prayer points)
  • Right-click: Context menu with “Pray Altar” and “Examine Altar”

Prayer Training

Prayer XP is gained by:
  1. Burying bones - Primary training method
  2. Using bones on altars (not yet implemented)
  3. Offering bones at gilded altars (not yet implemented)

Bone Burying

Burying bones grants Prayer XP with a 2-tick (1.2s) delay:

Bone Types

Bone types are defined in manifests/items.json with prayerXp property.

Network Protocol

Client → Server

Toggle Prayer:
Pray at Altar:
Deactivate All:

Server → Client

Prayer State Sync:
Prayer Toggled:
Prayer Points Changed:

Security Features

Input Validation

Rate Limiting

Limits:
  • 5 toggles per second - Prevents spam
  • 100ms cooldown - Minimum time between toggles

Validation Checks

Before activating a prayer, the system validates:
  1. Prayer exists in manifest
  2. Player meets level requirement
  3. Player has prayer points remaining
  4. Not already active
  5. Not exceeding max active prayers (currently 5)

Database Schema

Prayer state is persisted to the characters table:

Active Prayers Format

The activePrayers column stores a JSON array of prayer ID strings. IDs must match valid entries in prayers.json.

Prayer Events


API Reference

PrayerSystem

PrayerDataProvider


Adding New Prayers

Prayers are defined in packages/server/world/assets/manifests/prayers.json:

Prayer Definition Fields

Bonus Multipliers

Bonuses are multipliers applied to effective combat levels:

Client UI

Skills Panel Prayer Tab

The prayer tab displays:
  • Prayer points bar - Current/max with color coding
  • Prayer cards - Organized by category (offensive, defensive, utility)
  • Lock indicators - Prayers above player level show 🔒
  • Active state - Green border for active prayers
  • Tooltips - Hover for description and drain rate

Prayer Card States


Implementation Details

Memory Optimization

The system uses pre-allocated buffers to avoid allocations in hot paths:
Do not store references to these buffers - contents change between calls.

Type Safety

All prayer operations use type guards for runtime validation:

Display Points Rounding

Prayer points are displayed using Math.ceil() to prevent showing 0 when points are low but not empty:
This prevents the UI from showing “0 / 10” when the player still has 0.98 points remaining.

Testing

The prayer system includes 62 unit tests covering:
  • Type guard validation (all edge cases)
  • Bounds checking (overflow, underflow, NaN, Infinity)
  • Prayer ID format validation (security)
  • Rate limiting behavior
  • Input validation for all payload types
  • Drain calculations
  • Conflict resolution
  • Altar interactions