Ultima Underworld/technical/conversations/28
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 #28 // string block 0x0e1c (3612), name Zak // // 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[24]; if ( !private[0] ) { global[0] = 0; } // end if if ( global[0] ) { private[38] = play_name; } else { private[38] = 1; } // end if if ( private[0] == 1 ) { func_0405(); } // end if say( "Hello. My name is Zak. What be thine?" ); locals[1] = 10; locals[2] = 1; set_quest( 2, &locals[2], &locals[1] ); locals[3] = 3; // "I am @GS9." locals[4] = 4; // "None of thy business." locals[5] = 0; // "" locals[24] = babl_menu( 0, &locals[3] ); switch ( locals[24] ) { case 1: global[0] = 1; func_03b8(); break; case 2: func_0328(); break; } // end switch } // end func void func_0328() { int locals[22]; say( "Well, come on in and SHUT THE DOOR, won't thou?" ); locals[1] = 6; // "Certainly." locals[2] = 7; // "What door?" locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_05ba(); break; case 2: func_0370(); break; } // end switch } // end func void func_0370() { int locals[22]; say( "Art thou crazy? There be no door here!" ); locals[1] = 9; // "Ah, yes. Whatever thou sayest." locals[2] = 10; // "Thou madman!" locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_05ba(); break; case 2: func_0778(); break; } // end switch } // end func void func_03b8() { int locals[22]; say( "Greetings to thee, adventurer. Did I tell thee I am Zak?" ); locals[1] = 12; // "Well met, Zak. I am @GS9." locals[2] = 13; // "Ah, yes. I am pleased to meet thee." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: global[0] = 1; func_0405(); break; case 2: func_0610(); break; } // end switch } // end func void func_0405() { int locals[71]; locals[2] = 0; locals[1] = random( 1, &locals[4] ); locals[4] = 3; locals[5] = locals[1]; if ( 1 == locals[5] ) { func_0328(); } else { if ( 2 == locals[5] ) { say( "Do I know thee from somewhere?" ); } else { if ( 3 == locals[5] ) { if ( global[0] ) { say( "Greetings to thee, Zak! I am @GS9." ); } else { say( "Greetings to thee, Zak!" ); } // end if locals[2] = 1; } // end if } // end if } // end if locals[3] = !locals[2]; locals[27] = 1; locals[6] = 17; // "Pardon, I must be going." locals[28] = locals[3]; locals[7] = 18; // "A hale and hearty hello to thee, Zak!" locals[29] = locals[2]; locals[8] = 19; // "No, thou art not. Thou art Zak. I am @GS9." locals[9] = 0; // "" locals[48] = babl_fmenu( 0, &locals[6], &locals[27] ); switch ( locals[48] ) { case 17: locals[49] = 3; func_00b1( &locals[49] ); break; case 18: break; case 19: global[0] = 1; func_0569(); break; } // end switch say( "Hale? How strange a word. Is it very dark in here? I try to keep it well lighted, as darkness creeps in." ); locals[50] = 21; // "How dost thou do that?" locals[51] = 22; // "Good for thee. I must leave now." locals[52] = 0; // "" locals[71] = babl_menu( 0, &locals[50] ); switch ( locals[71] ) { case 1: func_0730(); break; case 2: func_00e0(); break; } // end switch } // end func void func_0521() { int locals[22]; say( "Indeed one can combat the darkness! With weapons and armor of light!" ); locals[1] = 24; // "What dost thou mean by this?" locals[2] = 25; // "Thou art mad!" locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0730(); break; case 2: func_0778(); break; } // end switch } // end func void func_0569() { int locals[23]; say( "Very well, "@GS9." Thou canst call me "Zak" if thou wish." ); locals[1] = 27; // "I thank thee. What art thou doing here, Zak?" locals[2] = 28; // "Excuse me, I must be going." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0730(); break; case 2: locals[23] = 3; func_00b1( &locals[23] ); break; } // end switch } // end func void func_05ba() { int locals[23]; say( "Very good. Now, what brings thee here, Zak?" ); locals[1] = 30; // "My name's not Zak. It's @GS9." locals[2] = 31; // "I was just leaving." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: global[0] = 1; func_0569(); break; case 2: locals[23] = 3; func_00b1( &locals[23] ); break; } // end switch } // end func void func_0610() { int locals[22]; say( "What dost thou fear, @GS70?" ); locals[1] = 33; // "I am afraid of nothing!" locals[2] = 34; // "Many things. What frightens thee, Zak?" locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_06a0(); break; case 2: func_0658(); break; } // end switch } // end func void func_0658() { int locals[22]; say( "Oh, I fear only the darkness." ); locals[1] = 36; // "Dost fear the dark, or what might lie within it?" locals[2] = 37; // "Such a childish notion!" locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_06e8(); break; case 2: func_0778(); break; } // end switch } // end func void func_06a0() { int locals[22]; say( "Truly? Then thou art mad. Some things everyone should fear." ); locals[1] = 39; // "Such as?" locals[2] = 40; // "Nay, those who fear anything are but cowards." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_06e8(); break; case 2: func_0778(); break; } // end switch } // end func void func_06e8() { int locals[22]; say( "Darkness! It is the root and reason of all fear!" ); locals[1] = 42; // "Surely 'tis no foe that can hurt thee?" locals[2] = 43; // "That fear I understand. Hast thou a remedy for darkness?" locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0521(); break; case 2: func_0730(); break; } // end switch } // end func void func_0730() { int locals[22]; say( "I collect torches, lamps, and tapers. Wouldst care to see?" ); locals[1] = 45; // "Certainly!" locals[2] = 46; // "Nay, I thank thee. Perhaps some other time." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_07c9(); break; case 2: func_00c2(); break; } // end switch } // end func void func_0778() { int locals[23]; say( "Clearly thou art a fool! Begone, mad one, lest thy madness prove catching." ); locals[1] = 48; // "Hmph! Good-bye!" locals[2] = 49; // "Wait! I spoke hastily! Forgive me!" locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: locals[23] = 2; func_00b1( &locals[23] ); break; case 2: func_05ba(); break; } // end switch } // end func void func_07c9() { int locals[23]; if ( !func_0836() ) { func_00e0(); } // end if setup_to_barter( 0 ); say( "See? I can even trade some with thee if thou desirest." ); locals[1] = 51; // "Very well." locals[2] = 52; // "Nay, but I thank thee." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: break; case 2: do_decline( 0 ); func_00c2(); break; } // end switch say( "Oh good, as hunger gnaws at me and makes me as afraid as the darkness." ); func_091b(); private[37] = 0; locals[23] = 3; func_00b1( &locals[23] ); } // end func void func_0836() { int locals[4]; if ( private[0] == 0 ) { private[2][1] = 1011; private[2][2] = 1009; private[2][3] = -1; private[18][1] = 1000; private[18][2] = 1010; private[18][3] = 1002; private[18][4] = 1003; private[18][5] = 1001; private[18][6] = 1018; private[18][7] = 1012; private[18][8] = 1013; private[18][9] = 1017; private[18][10] = 1016; private[18][11] = 1019; private[18][12] = 147; private[18][13] = -1; set_likes_dislikes( 2, 50, 34 ); private[37] = 1; } // end if locals[2] = 0; locals[3] = 60 * 6; if ( !private[37] && !func_0106( &locals[2], 66 ) ) { say( "Hey, dost thou think me crazy? I have already traded with thee! Come back tomorrow or the next day or the day after!" ); locals[1] = 0; } else { func_00ea( 66 ); locals[1] = 1; } // end if return locals[1]; } // end func void func_091b() { int locals[44]; setup_to_barter( 0 ); while ( !private[1] ) { locals[1] = 55; // "I make thee this offer." locals[2] = 56; // "I demand thou givest me these items." locals[3] = 57; // "Excuse me, I must think about this deal." locals[4] = 58; // "I do not wish to barter any further." locals[5] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_09cc(); break; case 2: func_0a26(); break; case 3: do_judgement( 0 ); break; case 4: do_decline( 0 ); private[1] = 1; break; } // end switch } // while locals[23] = 59; // "Farewell." locals[24] = 0; // "" locals[44] = babl_menu( 0, &locals[23] ); if ( locals[44] == 1 ) { private[1] = 1; } // end if } // end func void func_09cc() { int locals[15]; locals[0] = -1; locals[6] = -1; locals[11] = 60; // "I accept thy offer." locals[12] = 61; // "No, I do not like this deal." locals[13] = 62; // "Dost thou take me for a fool?" locals[14] = 63; // "I am weary of this haggling." locals[15] = 64; // "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_0a26() { int locals[24]; say( "Dost thou intend to rob me?" ); locals[1] = 66; // "Yes, I must." locals[2] = 67; // "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] = 68; // "If thou dost insist, thou canst have them." locals[24] = 69; // "No! Thou shalt not take them!" if ( do_demand( 2, &locals[24], &locals[23] ) ) { private[1] = 1; } else { func_0521(); } // end if } // end func