Bed bugs and other usecode stuff

NOTICE: This forum is archived as read only.
Please use the Github Discussions at https://github.com/exult/exult/discussions
Forum rules
NOTICE: This forum is archived as read only.
Please use the Github Discussions at https://github.com/exult/exult/discussions
Locked
Aerick
Posts: 22
Joined: Thu May 14, 2020 1:34 pm

Bed bugs and other usecode stuff

Post by Aerick »

First off, I'm not making a bug report in the tracker cuz I'm trying to resolve the issue myself. Here's the scenario:

Double-clicking on Spark's dad's bed(the upstairs one) causes the avatar to use Spark's bed, which is one story directly below it. A bit of debugging shows that the correct bed is being located inside the Game_window::double_clicked() method and obj->activate() is performed on the right object. activate calls the correct usecode function for shape 0x02B8 which simply checks if the event which called it was a double-click and if so, it calls function 0x0800. 0x0800 seems to be a bed-related function which checks the combat status and has one of the party members bitch at you if you try to sleep while in combat, otherwise it "does stuff". My problem is, I don't know enough about usecode to decipher exactly what's going on here. I could really use some help by answering a few questions I have...

1. What's the best tool(s) to use to disassemble usecode? I've used "wud" so far. Is there an existing way to use labels to help name known functions with wud or other tools?
2. Are there any docs that describe usecode in the form output by said tool(s)?

A few observations I've made about this bug:

If I remove the bedding from the bed downstairs:
1. Double-clicking on the upstairs bed works fine then.
2. Double-clicking on the downstairs bed causes the Avatar to use the upstairs bed.

Removing the bedding from both beds makes both beds work as they should..
Malignant Manor
Site Admin
Posts: 985
Joined: Thu May 14, 2020 1:34 pm

Re: Bed bugs and other usecode stuff

Post by Malignant Manor »

It isn't anything to do with the usecode of the original game (original game engine works properly). The original usecode for the bed is being called from USECODE_INTRINSIC(nap_time) in the file "/usecode/"intrinsics.cc" after pathfinding to the bed using the sleep schedule in schedule.cc.
Malignant Manor
Site Admin
Posts: 985
Joined: Thu May 14, 2020 1:34 pm

Re: Bed bugs and other usecode stuff

Post by Malignant Manor »

Sorry, quick testing (now that I have time) shows that USECODE_INTRINSIC(nap_time) can be commented out and not affect pathfinding to the bed.
Verlaine
Posts: 16
Joined: Thu May 14, 2020 1:34 pm

Re: Bed bugs and other usecode stuff

Post by Verlaine »

Upper floor beds have always been a little buggy since the beginning, and not just with the PC. I've done a lot of playing around with NPC schedules and that has it's own bugs. I think the issue is that the shceduler wasn't coded to consider elevation just the flat coordinates. It was that way in the Original I'd already started monkeying with schedules back then.

Many activities don't quite work right on upper floors. Tell an NPC to do desk work in the upper floor of Fawn Palace and he'll sit downstairs in the dining room.

Also ap erson sleeping upstairs who wakes up will magically appear on the lower floor.

Sorry you're talking about PC interaction and I got off on a tangent about NPC activities and their own Upper floor buggies.

But yeah all this is nothing new to exult
drcode
Site Admin
Posts: 2267
Joined: Thu May 14, 2020 1:34 pm

Re: Bed bugs and other usecode stuff

Post by drcode »

It's probably an Exult bug, and I'm sure I've seen it before. But I can't remember if it has to do with finding the bed or our implementation of the 'nap_time' intrinsic. I'll have a look when I get the chance.
Kensu

Re: Bed bugs and other usecode stuff

Post by Kensu »

What's it called when you aren't in Trinsic? :)
Locked