Files
LonaRPG-Online-Games/ModScripts/_Mods/LonaCraft/docs/SEWER_QUESTS.md
T
2026-10-29 21:59:06 +04:00

4.1 KiB

Repeatable quests in the Deep Sewer

The Deep Sewer (Maps/LonaCraftDeepSewer.rvdata2, Scripts/130_Sewer.rb) is set up for repeatable quests without touching the map file. No quest is built yet; this page says where one plugs in.

What the map reserves

Point (-point-...) n Kind (Sewer.quest_point(kind)) Where
LonaCraftSewerQuest_1 1 :goblin_den inside the goblin den (region 4)
LonaCraftSewerQuest_2 2 :homeless_camp inside the homeless camp (region 3)
LonaCraftSewerQuest_3 3 :flooded_basin in the flooded basin room
LonaCraftSewerQuest_4 4 :dead_end at the end of a dead-end stub
LonaCraftSewerQuest_5 5 :tunnel_mouth just inside a tunnel mouth
LonaCraftSewerQuest_6 6 :bridge on a bridge in the middle of the tunnels
  • Region 5 (Sewer::QUEST_REGION): walkway tiles around points 3 and 4, kept for quest spawns. The population roller never uses it. It counts as walkway for the base rules (no wall may cut it).
  • The points are ordinary story points, so get_storypoint("LonaCraftSewerQuest_3") works as on any game map.

The API (LonaCraft::Sewer)

Call Returns / does
quest_points {n => [x, y, event id]} on the live map (empty when Lona is not in the Deep Sewer)
quest_point(kind) [x, y] of one point by kind (table above), or nil
quest_tiles the region-5 tiles [[x, y], ...] on the live map
map? true while Lona is in the Deep Sewer
on_enter {|interp, map| ... } runs when Lona comes down a grate, after the vermin, hobos and goblins are placed
on_setup {|interp, map| ... } runs after every setup of the map: entry and after each nap
on_nap {|interp, map| ... } runs when Lona sleeps there, before the sewer's own danger roll; return :skip_roll to skip that roll (no tunnel group this nap)

The callbacks run inside the map's BIOS / NapEvent interpreter, so interp can use call_msg, $game_map.reserve_summon_event(name, x, y) (or EvLib.sum), optain_item and so on. An error in a callback is caught and written to the console ("LonaCraft Sewer enter hook error ...").

How a modder adds a repeatable quest

  1. Put a script in your own mod that loads after LonaCraft (Scripts/130_Sewer.rb must exist: check defined?(LonaCraft::Sewer)).
  2. Keep the quest state in $story_stats under your own keys (the game saves them).
  3. Register on_enter (or on_setup if the quest should survive a nap) and place the quest's events there, at quest_point(...) or on quest_tiles.
  4. Give the quest out where the game gives repeatable work: the tavern quest board script HCGframes/event/NoerTavernQuestBoard.rb builds tmpQuestList from rows gated by $story_stats["GuildQuestCurrent"] == 0, GuildQuestBeforeAccept and a cool-down on $game_date.dateAmt. RolePlayS adds its own repeatable guild quests the same way (its copy of that file, rows such as ChoppingFirewood with QuProg...AMT + 2 days). A sewer quest adds one row there (or in its own copy of the file) and a when branch that sets the accepted quest.
  5. On success, set your progress key so the board row shows again after the cool-down. That is what makes it repeatable.

Worked example (prose only)

"Clear the goblin den": the board row shows when GuildQuestCurrent == 0, the player has never taken it or its cool-down of three days has passed. Accepting it sets $story_stats["MyModSewerDen"] = 1. The mod registers LonaCraft::Sewer.on_enter { |i, m| ... }. When the quest is active, the block reserves two extra GoblinCommoner at quest_point(:goblin_den) with the summon data {:MyModSewerDen => true}, so they can be counted. An on_setup block checks after each setup whether any event with that tag is still alive. When none is, it sets MyModSewerDen = 2 and shows a line. Back at the board, the when branch pays the reward, sets the key back to 0 and stores dateAmt for the cool-down. The map file is never changed. The six points and region 5 stay where they are in every later version of the map.