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
- Put a script in your own mod that loads after LonaCraft (
Scripts/130_Sewer.rbmust exist: checkdefined?(LonaCraft::Sewer)). - Keep the quest state in
$story_statsunder your own keys (the game saves them). - Register
on_enter(oron_setupif the quest should survive a nap) and place the quest's events there, atquest_point(...)or onquest_tiles. - Give the quest out where the game gives repeatable work: the tavern quest board script
HCGframes/event/NoerTavernQuestBoard.rbbuildstmpQuestListfrom rows gated by$story_stats["GuildQuestCurrent"] == 0,GuildQuestBeforeAcceptand a cool-down on$game_date.dateAmt. RolePlayS adds its own repeatable guild quests the same way (its copy of that file, rows such asChoppingFirewoodwithQuProg...AMT + 2days). A sewer quest adds one row there (or in its own copy of the file) and awhenbranch that sets the accepted quest. - 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.