Ultima Underworld/technical/conversations/263

From Ultima Codex
Jump to navigation Jump to search

Technical Details Warning

While the encyclopedic nature of the codex means that many articles will have information that could spoil some minor aspects of the game for newer players, this article is known to contain technical information about the game, game engine, data files, logic, etc. This information is not generally useful to the typical game players.

Continue reading at your own discretion.

This page contains decompiled conversation code from Ultima Underworld. The original files came from Paul Carr and are currently archived here.

This file has been modified from that source (by Sir Robin) in the following ways:

  • local variables holding pointers to string text have had that string text specified in a comment on that same line. This should make the conversation code easier to read.
  • strings (both dereferenced ones in the code and also the ones added to comments as specified above) have been highlighted for easier reading
  • function definitions have been anchored and function calls have been linked, to make it easier to follow the flow of the code

Start viewing the flow at main

// cnvdasm - ultima underworld conversation script disassembler / decompiler // // loading game strings // // conversation #263 // string block 0x0f07 (3847), critter #7, goblin // // converting to graph // searching functions // replacing expression opcodes // folding expressions // adding control structures // fixing up functions extern int private[31]; void main() { private[1] = 0; func_029d(); func_0012(); } // end func void func_0012() { private[0] = 1; } // end func void func_0020() { int locals[1]; if ( (((npc_goal == 5 || npc_goal == 6) || npc_goal == 9) && npc_gtarg == 1 || npc_attitude == 0) ) { locals[1] = 0; } else { locals[1] = 1; } // end if return locals[1]; } // end func void func_0063() { npc_gtarg = 1; npc_attitude = 1; npc_goal = 6; func_0012(); } // end func void func_007c() { npc_goal = 1; func_0012(); } // end func void func_008b() { npc_gtarg = 1; npc_goal = 5; npc_attitude = 1; func_0012(); } // end func void func_00a4() { npc_attitude = 6; } // end func void func_00b1() { npc_attitude = param1[0]play_hunger; func_0012(); } // end func void func_00c2() { npc_attitude = 2; func_0012(); } // end func void func_00d1() { npc_attitude = 1; func_0012(); } // end func void func_00e0() { func_0012(); } // end func void func_00ea() { param1[1] = game_days; param1[2] = game_mins; } // end func void func_0106() { int locals[4]; locals[2] = game_days - param2[1]; locals[3] = game_mins - param2[2]; if ( locals[3] < 0 ) { locals[3] = locals[3] + 1440; locals[2] = locals[2] - 1; } // end if if ( locals[2] >= param1[1] && locals[3] >= param1[2] ) { locals[1] = 1; } else { locals[1] = 0; } // end if return locals[1]; } // end func void func_018f() { param1[1] = game_days - param3[1]; param1[2] = game_mins - param3[2]; if ( param1[2] < 0 ) { param1[2] = param1[2] + 1440; param1[1] = param1[1] - 1; } // end if param1[1] = param2[1] - param1[1]; param1[2] = param2[2] - param1[2]; if ( param1[2] < 0 ) { param1[2] = param1[2] + 1440; param1[1] = param1[1] - 1; } // end if } // end func void func_0243() { param1[1] = game_days - param2[1]; param1[2] = game_mins - param2[2]; if ( param1[2] < 0 ) { param1[2] = param1[2] + 1440; param1[1] = param1[1] - 1; } // end if } // end func void func_029d() { int locals[108]; if ( private[0] ) { say( "You again. You got nothing better to do?" ); } else { say( "Hey, you not goblin! Why you here?" ); } // end if private[2] = 1; private[3] = 1; locals[1] = 3; // "Canst thou tell me of the Goblins?" locals[2] = 4; // "Where is thy leader?" locals[3] = 5; // "I wish to trade with thee." locals[4] = 6; // "I must be on my way." locals[5] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: goto label_031e; break; case 2: goto label_0393; break; case 3: goto label_0408; break; case 4: func_00e0(); break; } // end switch label_031e:; label_031e:; say( "Green Goblins, yes, good. We are strongest and bravest in Abyss. Gray Goblins, they nasty and weak. You no want talk to them. Also watch out for some mean Goblins, not like our settlement. They wear red. Good Goblins near banners with funny marks. Like me." ); private[2] = 0; locals[44] = private[3]; locals[23] = 8; // "Where is thy leader?" locals[45] = 1; locals[24] = 9; // "I would like to trade some items with thee." locals[46] = 1; locals[25] = 10; // "I thank thee kindly for thy information. Farewell." locals[26] = 0; // "" locals[65] = babl_fmenu( 0, &locals[23], &locals[44] ); switch ( locals[65] ) { case 8: goto label_0393; break; case 9: goto label_0408; break; case 10: func_00e0(); break; } // end switch label_0393:; label_0393:; say( "Yah, Vernix, he king. Maybe you want talk to bodyguard Lanugo first. They in northwest, at end of high overhang path." ); private[3] = 0; locals[87] = private[2]; locals[66] = 12; // "And what canst thou tell me of thy people?" locals[88] = 1; locals[67] = 13; // "Perhaps we can exchange some goods." locals[89] = 1; locals[68] = 14; // "Thank thee. I will seek him out." locals[69] = 0; // "" locals[108] = babl_fmenu( 0, &locals[66], &locals[87] ); switch ( locals[108] ) { case 12: goto label_031e; break; case 13: goto label_0408; break; case 14: func_00e0(); break; } // end switch label_0408:; label_0408:; label_0408:; if ( !func_0020() ) { say( "No, not now. Some other Goblin maybe." ); func_00e0(); } else { say( "Maybe. What you got?" ); } // end if func_0422(); say( "Okay, goodbye." ); func_00e0(); } // end func void func_0422() { int locals[44]; setup_to_barter( 0 ); while ( !private[1] ) { locals[1] = 18; // "I make thee this offer." locals[2] = 19; // "I demand thou givest me these items." locals[3] = 20; // "Excuse me, I must think about this deal." locals[4] = 21; // "I do not wish to barter any further." locals[5] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_04d3(); break; case 2: func_052d(); break; case 3: do_judgement( 0 ); break; case 4: do_decline( 0 ); private[1] = 1; break; } // end switch } // while locals[23] = 22; // "Farewell." locals[24] = 0; // "" locals[44] = babl_menu( 0, &locals[23] ); if ( locals[44] == 1 ) { private[1] = 1; } // end if } // end func void func_04d3() { int locals[15]; locals[0] = -1; locals[6] = -1; locals[11] = 23; // "Yeah, we trade this." locals[12] = 24; // "No, I no like." locals[13] = 25; // "You think me stupid?" locals[14] = 26; // "I tired of this, go away." locals[15] = 27; // "You make no sense." if ( do_offer( 7, &locals[15], &locals[14], &locals[13], &locals[12], &locals[11], &locals[6], &locals[1] ) ) { private[1] = 1; } // end if } // end func void func_052d() { int locals[24]; say( "You think you just take this from me?" ); locals[1] = 29; // "Yes, I must." locals[2] = 30; // "No, thou dost misunderstand me." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: break; case 2: return; break; } // end switch locals[23] = 31; // "You not very fair." locals[24] = 32; // "Ha! Nobody take from Goblin!" if ( do_demand( 2, &locals[24], &locals[23] ) ) { private[1] = 1; } else { func_008b(); } // end if } // end func