Entry 496
A story dungeon's fieldrand after Generate is the game's: each floor's draw and SetAllGim's story rolls at construction, and the gimPos headings ported
20mworld
Documented in Dungeon generation.
This entry answers what was left open by question 31 of Open questions after the triage: towns, fields and dungeons.
Filescrates/piney-world/src/dungeon_area.rscrates/piney-world/examples/dungeon_probe.rstools/test_dungeon_rt.pydocs/engine/dungeon.md
Open question 157: the port's fieldrand after a story dungeon's
Generate was not the game's. tools/test_dungeon_rt.py worked around it
by copying the game's state into the probe after make.
What the game draws (INF gcmn DUNGEON::Generate 0x005c12a0):
- A story dungeon (an edit table) runs
MakeRealMapten times, with no draws. - Then, as a random dungeon does, it draws
fieldrand(5)before each floor'sMakeFloor: ten floors, or one for a lake. - The story
MakeFloor(0x005c0148) passes every row toMakeRoom(ROOMDATA *)(0x005bcbb0), which runsSetAllGim(0x005bb340) on the room's model. - There, an item box asks
CheckEntryItemBox(0x005cf800). It keeps no box, and draws nothing, where aGIMMICKDATArow of type 0-4 or aROOMDATArow with an event (+0x20) names the room; otherwise it keeps one onfieldrand(100) >= 20. - A magic circle asks
CheckEntryCircle(0x005cf690): the same test for types 1-4, with no draw. - The special objects draw as in a random room.
The port made these rolls only when
gim_slotsran, atEntryGimmick, and never drew the tenfieldrand(5)s.
The fix.
DungeonArea::story_rollsmakes the draws at construction, inGenerate's order: each floor'sfieldrand(5), then each built room's dummies inMakeRoom's order, rolled bystory_keep. It stores them as the room'srolls, as a random room's are, sogim_slotsdraws nothing.- With
gimPosnow compared, its headings differed. They are ported fromSetAllGim(gim_heading);pis the point 150 down the dummy's y axis:- a box:
atan2in doubles of (x, -y) ofpless the dummy's place (0x005bb5c0); - a magic circle:
atan2f(p.x, p.y)ofpitself, which overwrites the first heading it takes (0x005bb8a4); - the statue, fountain and special objects:
atan2fof the x axis (0x005bbb74).
- a box:
Checked. tools/test_dungeon_rt.py:
test_dungeonscompares every dungeon's dressing andfieldrandafterSetRoom(0, 0)with no copying for story dungeons, and everygimPosslot (773: place, heading, floor, room, type) through the probe's newgims;test_special_roomschecks the 15 story dungeons'fieldrandandgimPosafterGenerate;test_leavesno longer syncsfieldrand. All 12 tests pass. So do piney-world's tests and piney-game's suite (335).
Docs: dungeon.md (gimPos, its headings, the story rolls, the checks; the
open line removed), UNKNOWNS.md.
Still unknown: nothing