A failed quest gets its flags cleared and its quest book entries removed after its failure script ran, so the quest giver can offer it again; quests failed before the mod are reset once after loading. Quest table and quest book in game/engine/quests.h, measurements in docs/quests.md. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2.5 KiB
2.5 KiB
Quests
Quest data (measured 2026-10-17 / 2026-10-25)
- Quest table
g_quests(vector begin/end0xaa9e98/0xaa9e9c), 0x124 bytes per quest: id +0, internal name +4 (ANSI), scripts +0x10c (run on trigger), +0x114 (one-time, cleared after it ran), +0x118 success end, +0x11c failure end (only quests with one can fail), flags +0x120: 1 triggered, 2 done, 4 in progress, 8 busy (while the trigger runs its scripts).game/engine/quests.h. - Quest manager: static object
0xaaaf00(script interpreter). Quest book vector +0x424..+0x428, plain 0x174-byte entries (serialized field by field): state +4 (2 active, 100 solved, 101 failed), quest id +8, map position +0x14..+0x20; per player (16) a selected entry index at +0x3a8 + player * 8. - Script opcodes (keyword table
0x452540): LoseQuest0x36and ExitQuest0x0f->0x48f110->Quest_End0x46ced0(thiscall (index, ?, success), ret 0xc; LoseQuest success 0, ExitQuest 1). QuestDone0x0atests flag 2, QuestInProgress0x0cflag 4. Quest_Trigger0x46de10(cdecl (index, ?, ?, ?), plain ret): does nothing if flag 1 is set; else sets 1 | 8, runs +0x114 (then cleared) and +0x10c, clears 8. Talking to a giver triggered a quest (flags 0 -> 1, no book entry yet); accepting it set flag 4 and added a book entry, state 2.Quest_End: if the quest is in progress and not done, runs the end script (success / failure) and sets done (flags 3); the book entry's state becomes 100 / 101. Quests with ids 2600..3599 (the generic "Bringe NPC zu ...", "Eskortiere ...", ...) are copied to the end of the table under a new id (largest + 1, at least 10000): the game repeats those itself.- Compiled quest scripts:
bin\sgf.bin(labels such asLoseQuest_10255, textsres:...; random side quests useDQ_names, time limitsDQ_ZEITFENSTER_TAGE). - Example (Gladiator, Silber, 2026-10-25): failed Hetzjagd 1502, Pony Express 5005, Rette Jungfrau 2504, Eskortiere Händler zu geheimen Treffen 1403, all flags 3, book state 101.
Failed quests restartable (request 2026-10-17)
A failed quest is not final: talking to the quest giver again offers it
again. mods/questfail.cpp: after Quest_End with success 0 (its failure
script has run) the quest's flags 1/2/4/8 are cleared and its book entries
removed, as if never triggered; quests failed before the mod are reset once
after loading. Confirmed in the log (the four quests above reset, 2026-10-25);
the giver offering them again is still to be tested in the game.