{"id":107,"date":"2014-05-24T18:16:41","date_gmt":"2014-05-24T18:16:41","guid":{"rendered":"https:\/\/blogs.scummvm.org\/josejx\/?p=107"},"modified":"2022-05-21T18:28:41","modified_gmt":"2022-05-21T18:28:41","slug":"leaving-pegnose-petes-house","status":"publish","type":"post","link":"https:\/\/blogs.scummvm.org\/josejx\/2014\/05\/24\/leaving-pegnose-petes-house\/","title":{"rendered":"Leaving Pegnose Pete&#8217;s House"},"content":{"rendered":"<p>In the set <i>pph<\/i>, Guybrush walks towards Pegnose Pete&#8217;s house when he hears voices through the window. Unfortunately, it&#8217;s impossible for Guybrush to leave the scene after this unless you can solve the puzzle. In the retail version, this isn&#8217;t the case, Guybrush is free to go get any missing puzzle items he needs. Clearly, a bug!<\/p>\n<figure id=\"attachment_109\" aria-describedby=\"caption-attachment-109\" style=\"width: 640px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/blogs.scummvm.org\/josejx\/wp-content\/uploads\/sites\/23\/2014\/05\/CantLeave.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-109\" src=\"https:\/\/blogs.scummvm.org\/josejx\/wp-content\/uploads\/sites\/23\/2014\/05\/CantLeave.png\" alt=\"\" width=\"640\" height=\"480\" srcset=\"https:\/\/blogs.scummvm.org\/josejx\/wp-content\/uploads\/sites\/23\/2014\/05\/CantLeave.png 640w, https:\/\/blogs.scummvm.org\/josejx\/wp-content\/uploads\/sites\/23\/2014\/05\/CantLeave-300x225.png 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><figcaption id=\"caption-attachment-109\" class=\"wp-caption-text\">You&#8217;re welcome to enter the scene, but you can&#8217;t leave!<\/figcaption><\/figure>\n<p>In EMI, each area that you visit is represented by a <i>set<\/i>. I&#8217;ve added a <a href=\"http:\/\/wiki.residualvm.org\/index.php\/Escape_From_Monkey_Island_Debug_Mode#Sets\" target=\"_blank\" rel=\"noopener\">list of sets<\/a> to the ResidualVM Wiki, and you can switch between them using the following Lua command:<\/p>\n<ul>\n<li>switch_to_set(&#8220;set&#8221;)<\/li>\n<\/ul>\n<p>It&#8217;s really only appropriate to switch sets like this if you&#8217;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 <i>emi_jump <\/i>command in ResidualVM. A <a href=\"http:\/\/wiki.residualvm.org\/index.php\/Escape_From_Monkey_Island_Debug_Mode#Jump_targets\" target=\"_blank\" rel=\"noopener\">list of the jump targets<\/a> has also been added to the ResidualVM Wiki.<\/p>\n<p>In each set, there&#8217;s at least one setup. A setup is the view used in the current set. For example, in Pegnose Pete&#8217;s House (the set <i>pph, from file pph.lua<\/i>) there are three setups representing the view of Guybrush paddling in, a closeup on the dock and the closeup of the house. There&#8217;s also an additional setup that&#8217;s a topdown view of the set, but it doesn&#8217;t appear to be used in the game and has no background. To switch between setups, use the following Lua command:<\/p>\n<ul>\n<li>set:current_setup(setup)<\/li>\n<\/ul>\n<p>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 <a href=\"https:\/\/github.com\/residualvm\/residualvm\/pull\/882\" target=\"_blank\" rel=\"noopener\">here<\/a>.<\/p>\n<p>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&#8217;t tripped when Guybrush walks away. Let&#8217;s first investigate how switching between these setups is supposed to work.<\/p>\n<p>In EMI, the sets can be found in the <i>local.m4b<\/i> file. When extracted, they are the files ending with the <i>.setb<\/i> 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&#8217;s inspect the format of the sets, starting with the <i>section<\/i> tag. In each set, there are sections, which designate which part of the set is being described. These section tags are: <i>colormaps<\/i>, <i>setups<\/i>, <i>lights<\/i> and <i>sectors<\/i>. For this work, we&#8217;re mostly interested in the <i>setups<\/i> and <i>sectors <\/i>tags.<\/p>\n<p>The <i>setups<\/i> section of a set describes each of the setups (or views) in the set. For instance, in the set <i>pph<\/i> there are four sets, as previously described: <i>pph_wide<\/i>, <i>pph_close<\/i>, <i>pph_closer<\/i> and <i>pph_topdown<\/i>. 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.<\/p>\n<p>The <i>sectors<\/i> 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.<\/p>\n<p>So, what&#8217;s going wrong in the the scene <i>pph<\/i> when we try to leave the setup <i>pph_closer<\/i>? If we put a breakpoint in <i>set.cpp<\/i>, to break whenever the set setup changes, we find that the set change is triggered by a call to the function <i>MakeCurrentSetup<\/i> from the Lua scripts. Following its users and those functions, we ultimately find that there&#8217;s a Lua function that&#8217;s continuously running called <i>TrackGuybrush<\/i>.\u00a0 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 <i>cameraman_box_name<\/i>, and see that ResidualVM found that Guybrush is in the setup <i>pph_close<\/i>, but the retail version has him in the setup <i>pph_closer<\/i>. This would explain the bug! In the next post, I&#8217;ll discuss how to fix the issue.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the set pph, Guybrush walks towards Pegnose Pete&#8217;s house when he hears voices through the window. Unfortunately, it&#8217;s impossible for Guybrush to leave the scene after this unless you can solve the puzzle. In the retail version, this isn&#8217;t the case, Guybrush is free to go get any missing puzzle items he needs. Clearly, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-107","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blogs.scummvm.org\/josejx\/wp-json\/wp\/v2\/posts\/107","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.scummvm.org\/josejx\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.scummvm.org\/josejx\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/josejx\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/josejx\/wp-json\/wp\/v2\/comments?post=107"}],"version-history":[{"count":2,"href":"https:\/\/blogs.scummvm.org\/josejx\/wp-json\/wp\/v2\/posts\/107\/revisions"}],"predecessor-version":[{"id":110,"href":"https:\/\/blogs.scummvm.org\/josejx\/wp-json\/wp\/v2\/posts\/107\/revisions\/110"}],"wp:attachment":[{"href":"https:\/\/blogs.scummvm.org\/josejx\/wp-json\/wp\/v2\/media?parent=107"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/josejx\/wp-json\/wp\/v2\/categories?post=107"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/josejx\/wp-json\/wp\/v2\/tags?post=107"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}