Saturday, May 24, 2014

Leaving Pegnose Pete's House

In the set pph, Guybrush walks towards Pegnose Pete's house when he hears voices through the window. Unfortunately, it's impossible for Guybrush to leave the scene after this unless you can solve the puzzle. In the retail version, this isn't the case, Guybrush is free to go get any missing puzzle items he needs. Clearly, a bug!
You're welcome to enter the scene, but you can't leave!
In EMI, each area that you visit is represented by a set. I've added a list of sets to the ResidualVM Wiki, and you can switch between them using the following Lua command:
  • switch_to_set("set")
It's really only appropriate to switch sets like this if you're in the same act of the game with the appropriate inventory items, otherwise unexpected things can happen! To be sure, jump to the correct part of the story using the emi_jump command in ResidualVM. A list of the jump targets has also been added to the ResidualVM Wiki.

In each set, there's at least one setup. A setup is the view used in the current set. For example, in Pegnose Pete's House (the set pph, from file pph.lua) there are three setups representing the view of Guybrush paddling in, a closeup on the dock and the closeup of the house. There's also an additional setup that's a topdown view of the set, but it doesn't appear to be used in the game and has no background. To switch between setups, use the following Lua command:
  • set:current_setup(setup)
In the process of testing this, I found that ResidualVM crashed in the case where there is no background for a set instead of showing the default image. A pull request was submitted to fix this issue, and can be found here.

So, to get back to the problem: the trigger to move from one setup (the closeup of the house) to the next setup (the closeup of the dock) isn't tripped when Guybrush walks away. Let's first investigate how switching between these setups is supposed to work.

In EMI, the sets can be found in the local.m4b file. When extracted, they are the files ending with the .setb extension. Unlike Grim Fandango, these files are in a binary format. Luckily, ResidualVM provides a tool for converting from this binary format to the text format used in Grim Fandango. Let's inspect the format of the sets, starting with the section tag. In each set, there are sections, which designate which part of the set is being described. These section tags are: colormaps, setups, lights and sectors. For this work, we're mostly interested in the setups and sectors tags.

The setups section of a set describes each of the setups (or views) in the set. For instance, in the set pph there are four sets, as previously described: pph_wide, pph_close, pph_closer and pph_topdown. Each of these describes where the camera is placed when switching to the setup. This allows the game to leave the actor in the set, but change our perspective and background to the new camera angle.

The sectors section of a set describes areas of the set with specific behaviors, like the bounding box for each setup, objects to avoid for path finding and other information important to the scene.

So, what's going wrong in the the scene pph when we try to leave the setup pph_closer? If we put a breakpoint in set.cpp, to break whenever the set setup changes, we find that the set change is triggered by a call to the function MakeCurrentSetup from the Lua scripts. Following its users and those functions, we ultimately find that there's a Lua function that's continuously running called TrackGuybrush.  This function, amongst other things, updates the camera position when Guybrush moves into a new setup. It does this by checking if the actor is in the current sector. If not, it forces a camera change. When in the scene shown above, we check the variable cameraman_box_name, and see that ResidualVM found that Guybrush is in the setup pph_close, but the retail version has him in the setup pph_closer. This would explain the bug! In the next post, I'll discuss how to fix the issue.

No comments:

Post a Comment