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 logicpackages/shared/src/data/PrayerDataProvider.ts- Prayer manifest loadingpackages/server/src/systems/ServerNetwork/handlers/prayer.ts- Network handlerspackages/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:- Praying at altars - Restores to maximum instantly
- Prayer potions (not yet implemented)
- 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 inmanifests/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
- 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:- Burying bones - Primary training method
- Using bones on altars (not yet implemented)
- 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:Server → Client
Prayer State Sync:Security Features
Input Validation
Rate Limiting
- 5 toggles per second - Prevents spam
- 100ms cooldown - Minimum time between toggles
Validation Checks
Before activating a prayer, the system validates:- Prayer exists in manifest
- Player meets level requirement
- Player has prayer points remaining
- Not already active
- Not exceeding max active prayers (currently 5)
Database Schema
Prayer state is persisted to thecharacters table:
Active Prayers Format
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 inpackages/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:Type Safety
All prayer operations use type guards for runtime validation:Display Points Rounding
Prayer points are displayed usingMath.ceil() to prevent showing 0 when points are low but not empty:
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