Ultima Underworld/technical/conversations/217

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 #217 // string block 0x0ed9 (3801), name Gurstang // // 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]global[0]; 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[23]; global[1] = get_quest( 1, &locals[1] ); locals[1] = 9; if ( private[0] == 1 ) { func_03f7(); } else { global[0] = 0; say( "Ahh...So thou must be the one who has vanquished Tyball. Good...good...I sensed his passing but feared I would die here, forgotten." ); locals[2] = 2; // "Who art thou?" locals[3] = 3; // "Rest easy, now. He is gone." locals[4] = 0; // "" locals[23] = babl_menu( 0, &locals[2] ); switch ( locals[23] ) { case 1: func_0308(); break; case 2: func_047d(); } // end if break; } // end switch } // end func void func_0308() { int locals[43]; say( "I am Gurstang. I ventured down here searching for the Key of Truth." ); locals[22] = global[1]; locals[1] = 5; // "Gurstang? I met thy colleague Illomo. He is worried about thee." locals[23] = 1; locals[2] = 6; // "I, too, seek the Key." locals[3] = 0; // "" locals[43] = babl_fmenu( 0, &locals[1], &locals[22] ); switch ( locals[43] ) { case 5: func_0364(); break; case 6: func_0376(); break; } // end switch } // end func void func_0364() { global[0] = 1; say( "Illomo! So, Illomo told thee about me. Good, that means I can trust thee. I think I've discovered the whereabouts of the key. Tell Illomo 'Folanae.' He'll know where to look, and explain what to do. As for myself, I have other matters to attend to down here. Farewell." ); func_044c(); } // end func void func_0376() { int locals[22]; global[0] = 1; say( "A noble quest, indeed, and one that should be fulfilled, even though I am no longer the man to do it. Hmm. I shall have to take a risk and trust thee. Seek out a man in the area of the Seers of the Moonstone. His name is Illomo. When thou dost meet him, tell him I recommend thee to him, and say this word: "Folanae." He will know what to do next." ); locals[1] = 9; // "Why, I thank thee." locals[2] = 10; // "I have better things to do than run thy errands! Good-bye!" locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_03c3(); break; case 2: func_00c2(); break; } // end switch } // end func void func_03c3() { int locals[22]; say( "No thanks are necessary, as long as thou dost succeed in the quest. Now, go!" ); locals[1] = 12; // "Farewell." locals[2] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); if ( locals[22] == 1 ) { func_00e0(); } // end if } // end func void func_03f7() { int locals[3]; if ( !global[0] ) { say( "Thou art back!" ); func_0308(); } else { locals[1] = random( 1, &locals[2] ); locals[2] = 3; locals[3] = locals[1]; if ( 1 == locals[3] ) { say( "I've other business. Farewell." ); } else { if ( 2 == locals[3] ) { say( "Continue thy quest! I shall be all right." ); } else { if ( 3 == locals[3] ) { say( "Farewell! I'm too busy to talk!" ); } // end if } // end if } // end if } // end if } // end func void func_044c() { int locals[22]; locals[1] = 17; // "Farewell." locals[2] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); if ( locals[22] == 1 ) { func_00e0(); } // end if } // end func void func_047d() { int locals[22]; say( "Gone? Yes, I imagine he is. But his malice lingers, does it not?" ); locals[1] = 19; // "Yes. I have unfinished business." locals[2] = 20; // "That is my problem. What brought thee here?" locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_04c5(); break; case 2: func_0308(); break; } // end switch } // end func void func_04c5() { int locals[22]; say( "Dost thou seek the Key of Truth? It may help thee." ); locals[1] = 22; // "Indeed I do." locals[2] = 23; // "No, I do not." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0376(); break; case 2: func_0376(); break; } // end switch } // end func void func_050d() { int locals[44]; setup_to_barter( 0 ); while ( !private[1] ) { locals[1] = 24; // "I make thee this offer." locals[2] = 25; // "I demand thou givest me these items." locals[3] = 26; // "Excuse me, I must think about this deal." locals[4] = 27; // "I do not wish to barter any further." locals[5] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_05be(); break; case 2: func_0618(); break; case 3: do_judgement( 0 ); break; case 4: do_decline( 0 ); private[1] = 1; break; } // end switch } // while locals[23] = 28; // "Farewell." locals[24] = 0; // "" locals[44] = babl_menu( 0, &locals[23] ); if ( locals[44] == 1 ) { private[1] = 1; } // end if } // end func void func_05be() { int locals[15]; locals[0] = -1; locals[6] = -1; locals[11] = 29; // "I accept thy offer." locals[12] = 30; // "No, I do not like this deal." locals[13] = 31; // "Dost thou take me for a fool?" locals[14] = 32; // "I am weary of this haggling." locals[15] = 33; // "Surely thou art joking." 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_0618() { int locals[24]; say( "Dost thou intend to rob me?" ); locals[1] = 35; // "Yes, I must." locals[2] = 36; // "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] = 37; // "If thou dost insist, thou canst have them." locals[24] = 38; // "No! Thou shalt not take them!" if ( do_demand( 2, &locals[24], &locals[23] ) ) { private[1] = 1; } else { func_008b(); } // end if } // end func