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-tools

Quest 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:
  1. Iterates active quests for the player.
  2. Matches the event against current step objectives.
  3. 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.

2. NPC Talked

  • Location: api-game/src/handlers/interaction.rs (handle_interact_with_player)
  • Trigger: Interaction with object_type starting with npc_.
  • 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, and FishingManager use u32 item IDs to match ItemDatabase.