{"id":124,"date":"2014-06-02T18:34:01","date_gmt":"2014-06-02T18:34:01","guid":{"rendered":"https:\/\/blogs.scummvm.org\/josejx\/?p=124"},"modified":"2022-05-21T18:36:18","modified_gmt":"2022-05-21T18:36:18","slug":"herman-doesnt-want-to-talk","status":"publish","type":"post","link":"https:\/\/blogs.scummvm.org\/josejx\/2014\/06\/02\/herman-doesnt-want-to-talk\/","title":{"rendered":"Herman Doesn&#8217;t Want to Talk"},"content":{"rendered":"<p>When Guybrush enters Herman Toothrot&#8217;s camp (the set <i>toc<\/i>) for the first time, Guybrush should be able to trigger a conversation with Herman by walking up towards him. In ResidualVM, this conversation is never triggered! Let&#8217;s find out why.<\/p>\n<figure id=\"attachment_126\" aria-describedby=\"caption-attachment-126\" style=\"width: 640px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/blogs.scummvm.org\/josejx\/wp-content\/uploads\/sites\/23\/2014\/06\/Herman.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-126\" src=\"https:\/\/blogs.scummvm.org\/josejx\/wp-content\/uploads\/sites\/23\/2014\/06\/Herman.png\" alt=\"\" width=\"640\" height=\"480\" srcset=\"https:\/\/blogs.scummvm.org\/josejx\/wp-content\/uploads\/sites\/23\/2014\/06\/Herman.png 640w, https:\/\/blogs.scummvm.org\/josejx\/wp-content\/uploads\/sites\/23\/2014\/06\/Herman-300x225.png 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><figcaption id=\"caption-attachment-126\" class=\"wp-caption-text\">Guybrush can&#8217;t get Herman&#8217;s attention!<\/figcaption><\/figure>\n<p>In this scene, there&#8217;s a function to control the setup changes, including the closeup for the conversation Herman. This function checks if Guybrush is in the setup <i>toc_log<\/i> and if the conversation has already happened. So, why doesn&#8217;t the standard &#8220;Talk to Herman&#8221; come up when we approach? In this script, the range for this pop-up is reduced to 0, which prevents it from coming up. Setting it with:<\/p>\n<ul>\n<li>toc.herman_obj.range = 4.3<\/li>\n<\/ul>\n<p>Makes this behavior work as intended, and indeed, the script does this after Guybrush has the initial conversation with Herman. We can also check the state of the conversation, just to make sure this isn&#8217;t the problem either (using my pop up <a href=\"https:\/\/github.com\/JoseJX\/random_tools\/blob\/master\/controls.patch\" target=\"_blank\" rel=\"noopener\">lua injector<\/a>):<\/p>\n<ul>\n<li>dd = glob.herman_talk_status<\/li>\n<\/ul>\n<p>And as expected, it has the correct value, 0. Let&#8217;s check Guybrush&#8217;s current setup now:<\/p>\n<ul>\n<li>dd = toc:current_setup()<\/li>\n<\/ul>\n<p>Which returns 1, the ID for <i>toc_wide<\/i>. So it seems that Guybrush never enters the setup <i>toc_log<\/i>, which is required to trigger the conversation.<\/p>\n<p>First of all, are we sure that the <i>setup_change <\/i>function is being run? Yes! We can prove this by checking the range on Herman&#8217;s note in this scene. If we check from the setup <i>toc_wide<\/i>, the interaction range for the note is 0, but when we change to the setup <i>toc_close<\/i>, the interaction range is changed to 1.8. This change is implemented in the <i>setup_change<\/i> function, so it&#8217;s certainly being run.<\/p>\n<p>How about if we force the current setup to <i>toc_log<\/i>?<\/p>\n<ul>\n<li>toc:current_setup(toc_log)<\/li>\n<\/ul>\n<figure id=\"attachment_127\" aria-describedby=\"caption-attachment-127\" style=\"width: 640px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/blogs.scummvm.org\/josejx\/wp-content\/uploads\/sites\/23\/2014\/06\/Closeup.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-127\" src=\"https:\/\/blogs.scummvm.org\/josejx\/wp-content\/uploads\/sites\/23\/2014\/06\/Closeup.png\" alt=\"\" width=\"640\" height=\"480\" srcset=\"https:\/\/blogs.scummvm.org\/josejx\/wp-content\/uploads\/sites\/23\/2014\/06\/Closeup.png 640w, https:\/\/blogs.scummvm.org\/josejx\/wp-content\/uploads\/sites\/23\/2014\/06\/Closeup-300x225.png 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><figcaption id=\"caption-attachment-127\" class=\"wp-caption-text\">Talking to Herman, with a bit of hackery&#8230;<\/figcaption><\/figure>\n<p>That works, and we&#8217;re treated to the conversation with Herman. So, it seems that Guybrush isn&#8217;t moving into the setup <i>toc_log<\/i>. As with the previous bug at Pegnose Pete&#8217;s House, there is a problem moving between setups, but this time, it&#8217;s impossible to move into the setup <i>toc_log<\/i>.<\/p>\n<p>Let&#8217;s check to see what sector Guybrush is in with find_sector_type:<\/p>\n<ul>\n<li>system.currentActor:find_sector_type(CAMERA)<\/li>\n<\/ul>\n<p>We find that the sector reported when we&#8217;re near the log is actually <i>toc_log<\/i>.<\/p>\n<p>How about <i>IsActorInSector()<\/i>? Both <i>toc_wide<\/i> and <i>toc_log<\/i> both are matched as valid setups when Guybrush is near the log. However, in the retail version, only toc_log matches, with <i>IsActorInSector(ActorHandle, &#8220;toc_wide&#8221;) <\/i>returning a <i>nil<\/i>, even when the setup<i> toc_wide<\/i> is showing! Trying this test again with the set <i>gpt<\/i> also resulted in <i>nil<\/i> values for <i>IsActorInSector<\/i> when in setups <i>gtp_arial<\/i> and <i>gpt_dock<\/i>, while ResidualVM reported that Guybrush was in the sectors of the same name.<\/p>\n<p>First, let&#8217;s see if the sectors actually overlap. To visualize the sectors in a set, I rewrote a utility in perl from <i>residualvm-tools<\/i> to work with EMI and GRIM. This new version can be found <a href=\"https:\/\/github.com\/JoseJX\/random_tools\/blob\/master\/draw_sectors.pl\" target=\"_blank\" rel=\"noopener\">here<\/a>. The input of this tool is a text based set (so you&#8217;ll have to convert binary sets with <i>setb2set<\/i> first), and the output is a fig file, compatible with <a href=\"http:\/\/xfig.org\/userman\/\" target=\"_blank\" rel=\"noopener\">xfig<\/a>. I also added the ability to filter by sector type.<\/p>\n<p>For the set <i>toc<\/i>, I filtered by type <i>camera<\/i>, which is the type used to pick the view and got the following result:<\/p>\n<figure id=\"attachment_128\" aria-describedby=\"caption-attachment-128\" style=\"width: 497px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/blogs.scummvm.org\/josejx\/wp-content\/uploads\/sites\/23\/2014\/06\/CameraSectors.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-128\" src=\"https:\/\/blogs.scummvm.org\/josejx\/wp-content\/uploads\/sites\/23\/2014\/06\/CameraSectors.png\" alt=\"\" width=\"497\" height=\"700\" srcset=\"https:\/\/blogs.scummvm.org\/josejx\/wp-content\/uploads\/sites\/23\/2014\/06\/CameraSectors.png 497w, https:\/\/blogs.scummvm.org\/josejx\/wp-content\/uploads\/sites\/23\/2014\/06\/CameraSectors-213x300.png 213w\" sizes=\"auto, (max-width: 497px) 100vw, 497px\" \/><\/a><figcaption id=\"caption-attachment-128\" class=\"wp-caption-text\">Camera Sectors in the Set toc<\/figcaption><\/figure>\n<p>From this, we can easily see that the sector <i>toc_log (sector 19)<\/i>, overlaps one of the <i>toc_wide<\/i> <i>(sector 0)<\/i> sectors. After going through all of the sets, I found that this set is the only set in which the camera sector is almost <b>completely <\/b>overlapped, aside from the set <i>cpt<\/i>. In the set cpt, the two overlapping sectors have the same name.<\/p>\n<p>So, why does this bug arise? When the camera change function is called, it checks to see if Guybrush is still in the same sector by calling <i>IsActorInSector()<\/i>. This call succeeds when it should fail because the sectors are overlapped, so the camera change function thinks Guybrush hasn&#8217;t left the sector.<\/p>\n<p>This post is going on a bit long, so in the next post, we&#8217;ll come up with a solution to this problem.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When Guybrush enters Herman Toothrot&#8217;s camp (the set toc) for the first time, Guybrush should be able to trigger a conversation with Herman by walking up towards him. In ResidualVM, this conversation is never triggered! Let&#8217;s find out why. In this scene, there&#8217;s a function to control the setup changes, including the closeup for the [&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-124","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blogs.scummvm.org\/josejx\/wp-json\/wp\/v2\/posts\/124","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=124"}],"version-history":[{"count":2,"href":"https:\/\/blogs.scummvm.org\/josejx\/wp-json\/wp\/v2\/posts\/124\/revisions"}],"predecessor-version":[{"id":129,"href":"https:\/\/blogs.scummvm.org\/josejx\/wp-json\/wp\/v2\/posts\/124\/revisions\/129"}],"wp:attachment":[{"href":"https:\/\/blogs.scummvm.org\/josejx\/wp-json\/wp\/v2\/media?parent=124"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/josejx\/wp-json\/wp\/v2\/categories?post=124"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/josejx\/wp-json\/wp\/v2\/tags?post=124"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}