Skills System Documentation
Hyperscape implements a comprehensive OSRS-style skills system with 17 skills, XP progression, and level requirements.Overview
Total Skills: 17 (7 combat, 3 gathering, 7 production) Level Range: 1-99 for all skills XP Formula: Uses OSRS XP table formula:Skill Categories
Combat Skills
Gathering Skills
Production Skills
Production Skills Details
Cooking
Mechanics:- Cook raw food at fires or ranges
- Burn chance decreases with level
- Stop-burn level varies by food and heat source (ranges have lower stop-burn)
- Grants cooking XP per successful cook
packages/server/world/assets/manifests/recipes/cooking.json
Example Recipe:
Smithing
Mechanics:- Smelting: Combine ores + coal at furnaces → bars (4 ticks, success rate varies)
- Forging: Use bars at anvils → weapons/armor/tools (4 ticks)
- Multi-output support: Arrowtips produce 15 per bar
- Grants smithing XP per item made
packages/server/world/assets/manifests/recipes/smelting.jsonpackages/server/world/assets/manifests/recipes/smithing.json
Crafting
Mechanics:- Leather Armor: Use needle + thread + leather/dragonhide
- Jewelry: Use mould + gold bar at furnace
- Gem Cutting: Use chisel on uncut gems
- Thread has 5 uses before being consumed
- Always succeeds (no failure rate)
- Grants crafting XP per item made
packages/server/world/assets/manifests/recipes/crafting.json
Example Recipe:
Fletching
Mechanics:- Arrow Shafts: Knife + logs → 15 arrow shafts per log
- Bows: Knife + logs → unstrung bow, then bowstring + unstrung bow → strung bow
- Arrows: Arrowtips + headless arrows → finished arrows (multi-output)
- Headless Arrows: Arrow shafts + feathers → headless arrows (multi-output)
- Always succeeds (no failure rate)
- Multi-output support (15 shafts per log, 15 arrows per set)
- Grants fletching XP per action (total for all items produced)
packages/server/world/assets/manifests/recipes/fletching.json
Example Recipe (multi-output):
Runecrafting
Mechanics:- Click altar to instantly convert all carried essence → runes
- Two essence types:
rune_essence(basic runes),pure_essence(all runes) - Multi-rune crafting at higher levels (e.g., 2x air runes at level 11, 3x at level 22)
- Grants runecrafting XP per essence consumed
- No tick delay (instant conversion)
packages/server/world/assets/manifests/recipes/runecrafting.json
Example Recipe:
- Base: 1 rune per essence
- Each threshold in
multiRuneLevelsadds +1 rune per essence - Example: At level 22, air runes produce 3 per essence (base + 2 thresholds)
Tanning
Mechanics:- Talk to tanner NPC to instantly convert hides → leather
- Costs coins per hide tanned
- No level requirement
- No XP reward
- Instant conversion (no tick delay)
packages/server/world/assets/manifests/recipes/tanning.json
Example Recipe:
Skill Guide Panel
Feature (added in PR #711):- Click any skill icon in the skills panel to open the guide
- Shows all unlocks for that skill at each level
- Visual indicators:
- ✓ Green: Unlocked (player meets level requirement)
- ➤ Yellow: Next unlock (closest level above player)
- 🔒 Gray: Locked (future unlocks)
- Displays levels to next unlock
- Shows unlock type badges (item, ability, location, etc.)
packages/shared/src/data/skill-unlocks.ts
Example Unlock Data:
ProcessingDataProvider API
Location:packages/shared/src/data/ProcessingDataProvider.ts
Purpose: Centralized recipe data provider for all processing skills. Loads recipes from JSON manifests and provides lookup methods.
Initialization
Cooking Methods
Smithing Methods
Smelting Methods
Crafting Methods
Fletching Methods
Runecrafting Methods
Tanning Methods
System Architecture
SkillsSystem
Location:packages/shared/src/systems/shared/character/SkillsSystem.ts
Responsibilities:
- XP tracking and level calculation
- Level-up detection and events
- Combat level calculation
- Total level tracking
- Skill milestone detection
- XP drop visualization
SKILLS_XP_GAINED: XP awarded to a skillSKILLS_LEVEL_UP: Skill leveled upSKILLS_MILESTONE: Skill milestone reached (50, 92, 99)SKILLS_UPDATED: Skills data changed (for UI sync)COMBAT_LEVEL_CHANGED: Combat level changedTOTAL_LEVEL_CHANGED: Total level changedXP_DROP_BROADCAST: XP drop for visual feedback
Processing Systems
All processing systems follow a common pattern:- Listen for interaction events (player clicks station/uses item)
- Validate player level and materials
- Create tick-based session (or instant for runecrafting)
- Process on tick completion (consume materials, add output, grant XP)
- Cancel on movement/combat (OSRS behavior)
- Emit completion events (for UI feedback and logging)
CookingSystem- Food preparationFiremakingSystem- Fire lightingSmeltingSystem- Ore smeltingSmithingSystem- Item forgingCraftingSystem- Leather/jewelry/gemsFletchingSystem- Bows/arrowsRunecraftingSystem- Rune creationTanningSystem- Hide tanning
- Server-authoritative (all systems run on server)
- Rate limiting (prevent spam)
- Audit logging (economic tracking)
- Idempotency checks (prevent duplicate actions)
- Inventory validation (re-check materials before consumption)
- Session management (one active session per player)
Database Schema
Character Skills (stored incharacters table):
Each skill has two columns:
{skill}Level- Current level (1-99){skill}Xp- Current XP (0-200,000,000)
- 0029: Added crafting skill columns
- 0030: Added fletching skill columns
- 0031: Added runecrafting skill columns
Adding New Skills
To add a new skill to Hyperscape:1. Update SkillsSystem
Add skill constant toSkill object:
Skills type in packages/shared/src/types/core/core.ts:
SkillsSystem.ts:
2. Create Processing System
CreateHerbloreSystem.ts following the pattern in CraftingSystem.ts:
- Extend
SystemBase - Listen for interaction events
- Validate level and materials
- Create tick-based sessions
- Process on tick completion
- Cancel on movement/combat
- Emit completion events
3. Add Recipe Manifest
Createpackages/server/world/assets/manifests/recipes/herblore.json:
4. Update ProcessingDataProvider
Add methods to load and access herblore recipes:5. Add Database Migration
Create migration to add skill columns:6. Update UI
Add skill icon topackages/shared/src/data/skill-icons.ts:
packages/shared/src/data/skill-unlocks.ts:
7. Register System
Add to world initialization inpackages/shared/src/runtime/createServerWorld.ts:
Testing
All skill systems have comprehensive unit tests: Test Files:packages/shared/src/systems/shared/interaction/__tests__/CraftingSystem.test.tspackages/shared/src/systems/shared/interaction/__tests__/FletchingSystem.test.tspackages/shared/src/systems/shared/interaction/__tests__/RunecraftingSystem.test.tspackages/shared/src/data/__tests__/ProcessingDataProvider.test.ts
- Recipe loading and validation
- Level requirement checks
- Material consumption
- XP calculation
- Multi-output handling (fletching, smithing arrowtips)
- Consumable tracking (thread uses)
- Multi-rune multipliers (runecrafting)
- Session management (start, complete, cancel)
- Edge cases (out of materials, level too low, invalid recipes)
Performance Optimizations
Memory Management:- Pre-allocated buffers for inventory counting (avoids Map allocations in hot paths)
- Reusable arrays for tick processing (avoids per-frame allocations)
- Skill level caching (reduces entity lookups)
- Once-per-tick processing guard (prevents duplicate processing)
- Batch completion checks (collect completed sessions, then process)
- Early exits for empty sessions
Manifest-Driven Design
All skill recipes are defined in JSON manifests, not hardcoded in TypeScript: Recipe Manifests:packages/server/world/assets/manifests/recipes/cooking.jsonpackages/server/world/assets/manifests/recipes/firemaking.jsonpackages/server/world/assets/manifests/recipes/smelting.jsonpackages/server/world/assets/manifests/recipes/smithing.jsonpackages/server/world/assets/manifests/recipes/crafting.jsonpackages/server/world/assets/manifests/recipes/fletching.jsonpackages/server/world/assets/manifests/recipes/runecrafting.jsonpackages/server/world/assets/manifests/recipes/tanning.json
- Add new recipes without code changes
- Easy balancing (edit JSON, reload)
- Content creators can add recipes
- Validation on load (detailed error reporting)
- Fallback to embedded item data (backwards compatibility)
- Required fields present and correct types
- Level in range [1, 99]
- XP > 0, ticks > 0
- All item IDs exist in ITEMS manifest
- Input amounts >= 1
- Tool IDs valid
- Consumable uses >= 1
UI Components
SkillsPanel
Location:packages/client/src/game/panels/SkillsPanel.tsx
Features:
- Displays all 17 skills with icons, levels, and XP
- Click skill icon to open Skill Guide Panel
- Shows XP progress bars
- Displays combat level and total level
- Real-time updates via SKILLS_UPDATED events
SkillGuidePanel
Location:packages/client/src/game/panels/SkillGuidePanel.tsx
Features (new in PR #711):
- Modal window showing all unlocks for a skill
- Sorted by level (ascending)
- Visual unlock status (unlocked/next/locked)
- Shows levels to next unlock
- Type badges (item, ability, location, etc.)
- Progress indicator (X/Y unlocked)
Processing Panels
Panels:CraftingPanel.tsx- Leather/jewelry/gemsFletchingPanel.tsx- Bows/arrowsSmithingPanel.tsx- Metal itemsSmeltingPanel.tsx- Ore smeltingTanningPanel.tsx- Hide tanning
- Category grouping (e.g., leather, studded, dragonhide)
- Recipe filtering by available materials
- Level requirement indicators (red = too low, green = can make)
- Material count display
- Quantity selection (1, 5, 10, All)
- Output quantity display (for multi-output recipes)
Event Flow
Crafting Example
Runecrafting Example (Instant)
Common Pitfalls
1. Forgetting to Register Skills in Multiple Places
When adding a new skill, you must update:Skillconstants inSkillsSystem.tsSkillstype intypes/core/core.ts- Skill arrays in
getTotalLevel()andgetTotalXP() - Database migration (add columns)
SKILL_ICONSinskill-icons.tsSKILL_UNLOCKSinskill-unlocks.ts
2. Not Handling Multi-Output Recipes
Fletching and smithing arrowtips produce multiple items per action:- Use
outputQuantityfield in recipe - Grant XP once per action (not per item)
- Display output quantity in UI
3. Forgetting Movement/Combat Cancellation
All processing systems must cancel on:MOVEMENT_CLICK_TO_MOVEeventCOMBAT_STARTEDevent
4. Not Validating Materials Before Consumption
Always re-check inventory before consuming materials:5. Hardcoding Recipe Data
Never hardcode recipe data in system files:Additional Resources
- README.md - Full project documentation
- .cursor/rules/ - Detailed development rules
- packages/shared/ - Core engine source
- Game Design Document: See
.cursor/rules/gdd.mdc - OSRS Wiki: https://oldschool.runescape.wiki (reference for mechanics)