quest-system-loader
Guide for quest-system-loader
Quest System Loader & Event System
Overview
This document details the implementation of the quest ingestion pipeline and the server-side quest event system.
Ingestion Pipeline
Goal
Populate the database with quest definitions from Markdown files in the Knowledge Base.
Implementation
- Tool:
crates/content-tools(Rust binary) - Source:
knowledge-base/quests/*.md - Tables:
quests: definitions (JSONB steps, requirements)quest_progress: per-player state
Spec
See QUEST_INGESTION_SPEC.md for format details.
Usage
cargo run -p content-toolsQuest Event System
Core Design
The event system decouples game actions from quest logic using the
QuestEvent enum.Event Types in
crates/logic-core/src/quests/events.rs:NpcKilled { npc_id }ItemCollected { item_id, count }NpcTalked { npc_id }LocationReached { x, y, z }SkillLeveled { skill, new_level }
Processing Logic
QuestManager::handle_event:- Iterates active quests for the player.
- Matches the event against current step objectives.
- Updates progress and handles step completion/rewards.
Hook Integration
1. Item Collected
- Location:
api-game/src/handlers/skills.rs(handle_chop_tree) - Trigger: Successful resource gathering.
- Action:
- Adds item to DB via
InventoryRepository. - Dispatches
QuestEvent::ItemCollected.
- Adds item to DB via
2. NPC Talked
- Location:
api-game/src/handlers/interaction.rs(handle_interact_with_player) - Trigger: Interaction with
object_typestarting withnpc_. - Action: Dispatches
QuestEvent::NpcTalked.
3. NPC Killed
- Location:
logic-core/src/game_state.rs - Trigger: NPC death in combat loop.
- Action: Dispatches
QuestEvent::NpcKilled.
Data Consistency
- Gathering Skills:
WoodcuttingManager,MiningManager, andFishingManageruseu32item IDs to matchItemDatabase.