xavieran / BaKGL

Remake of Betrayal at Krondor using OpenGL
GNU General Public License v3.0
41 stars 2 forks source link

Figure out complex event states #21

Closed xavieran closed 3 years ago

xavieran commented 3 years ago

Most events are simply setting a flag, but some are more complicated.

e.g. Captain Belfort at Lamut Garrison:

Text [  The Garrison was impressive.
        Sitting high on a hill overlooking LaMut, the military outpost had been constructed years earlier to head off a possible moredhel assault on the western border of the kingdom.
        They followed a road that snaked through town and up the rocky hill upon which the garrison sat. After speaking with the sentries at the gate, they were lead under the fortress's massive iron portcullis. ]
Next [ Offset { 19 @ 0xe69 } ]

dac0 -> 400 | ff01 Offset { 19 @ 0x1381 } (0)
dac0 -> 101 | ff01 Offset { 19 @ 0x995 } (1)
0 -> 0 | 0 Offset { 19 @ 0xe69 } (2)

This goes to

++ SetFlag {dac0, rest[ff 01 00 00 00 00]}
++ SetFlag {16, rest[00 00 00 00 01 00]}
Text [  Captain Belford stood as they entered the room.
        "It's good to see you once again, @4," he said, extending his hand.
        "I share that sentiment. What news have you? How is Earl Kasumi?" @4 asked as the men shook hands.
        They sat in hard wooden chairs as Belford replied. "He's well, but he's off taking care of some business with a few new guards come through the rift from Kelewan. As for the rest of us, we're looking for a group of grey warriors from Kelewan who slipped through the rift just before it closed."
        @4 looked a little puzzled. "King Lyam and Emperor Ichindar granted the grey warriors freedom and new status in the Kingdom."
        "Yes, but the agreement doesn't allow for the nationalization of stolen goods. Seems they may have absconded with a valuable ruby from Makala's entourage," said Belford.
        "Makala? The Tsurani Great One?" @3 asked.
        Belford smiled. "Yes. He has been talking to Prince Arutha about establishing a permanent rift to encourage trade between the Kingdom and Kelewan. He's really throwing his weight around trying to get his ruby back. If you should happen to come across it, bring it back here -- he's offering a reward!"
        They thanked him for his information and left. ]
Next [ None ]

The "SetFlag {dac0, [01ff]}" seems to set a full value rather than just a boolean flag.

xavieran commented 3 years ago

State flag is a bit more complicated than usual Following table of offsets was found:

dac0:b09 set to 0x01
daca:b0a set
dacf:Nothing set, presumably this is only used for reading a particular offset
dacf: Seems to shift right by 1...
dad4:b0b set (this doesn't actually exist)
dade:b0c set
dae8:b0d set
daf2:b0e set
db7e:b1c set
dc32:b2e set
dc3c:b2f set
dc46:b30 set

Looks like the address in the save can be found by dividing by 10 and adding -2775 (-ad7). This points to the single byte associated with the event.

xavieran commented 3 years ago
xavieran commented 3 years ago

Disassembly for doing complex event choices explained how they work. Just need to finish off with partial reads/partial writes (dacc/dacf)

xavieran commented 3 years ago

Done. Refer RunDialog: 0x23c7 for evaluating complex events and RunDialog: 0x1607 for writing complex events