Ultima Underworld/technical/conversations/222
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 #222 // string block 0x0ede (3806), name guard // // 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() { if ( private[0] == 0 ) { private[2] = 0; private[3] = 0; private[4] = 0; } // end if if ( private[0] == 1 ) { func_0332(); } else { func_02ca(); } // end if } // end func void func_02ca() { int locals[25]; say( "Show medallion to pass." ); locals[1] = 2; // "Ha, I go where I want, with or without any medallion." locals[2] = 3; // "Here it is." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: locals[23] = 9; locals[24] = 0; locals[25] = 6; set_race_attitude( 3, &locals[25], &locals[24], &locals[23] ); func_008b(); break; case 2: func_03a6(); break; } // end switch } // end func void func_0332() { int locals[5]; if ( private[4] == 1 ) { say( "Ok! You not listen! We teach you lesson!" ); locals[1] = 9; locals[2] = 0; locals[3] = 6; set_race_attitude( 3, &locals[3], &locals[2], &locals[1] ); locals[4] = 222; locals[5] = 0; set_attitude( 2, &locals[5], &locals[4] ); func_0695(); } else { if ( private[3] == 1 ) { say( "You not hear good. Medallion allow pass, south door!" ); private[4] = 1; func_0607(); } else { if ( private[2] == 1 ) { say( "Go on, door open for you, you leave. Git! Git!" ); private[3] = 1; func_0607(); } // end if } // end if } // end if } // end func void func_03a6() { int locals[85]; locals[13] = 0; label_03b0:; label_03b0:; locals[11] = show_inv( 2, &locals[6], &locals[1] ); if ( locals[11] > 0 ) { locals[12] = 1; while ( locals[12] <= locals[11] ) { if ( locals[0] == 300 ) { say( "Okay, through door to south is way. Go now." ); locals[14] = 29; locals[15] = 21; locals[16] = 0; gronk_door( 3, &locals[16], &locals[15], &locals[14] ); private[2] = 1; func_071e(); } // end if locals[12] = locals[12] + 1; } // while if ( locals[13] > 2 ) { } else { say( "That no medallion... show me medallion OR DIE!!" ); locals[17] = 9; // "I bge your pardon. Here it is." locals[18] = 10; // "Wait here. I shall be right back with my medallion." locals[19] = 12; // "No, YOU die!!" locals[20] = 0; // "" locals[38] = babl_menu( 0, &locals[17] ); switch ( locals[38] ) { case 1: locals[13] = locals[13] + 1; goto label_03b0; break; case 2: say( "You no have medallion now, you die!" ); locals[39] = 9; locals[40] = 0; locals[41] = 6; set_race_attitude( 3, &locals[41], &locals[40], &locals[39] ); locals[42] = 222; locals[43] = 0; set_attitude( 2, &locals[43], &locals[42] ); func_008b(); break; case 3: locals[44] = 9; locals[45] = 0; locals[46] = 6; set_race_attitude( 3, &locals[46], &locals[45], &locals[44] ); locals[47] = 222; locals[48] = 0; set_attitude( 2, &locals[48], &locals[47] ); func_008b(); } // end if } else { break; } // end switch if ( locals[13] > 2 ) { } else { say( "What?... you think me stupid, I see no medallion." ); locals[49] = 14; // "I beg your pardon. Here it is. " locals[50] = 15; // "Wait here. I shall return with my medallion." locals[51] = 17; // "Yes, I do think thou'rt stupid!" locals[52] = 0; // "" locals[70] = babl_menu( 0, &locals[49] ); switch ( locals[70] ) { case 1: locals[13] = locals[13] + 1; goto label_03b0; break; case 2: say( "You no have medallion now, you die!" ); locals[71] = 9; locals[72] = 0; locals[73] = 6; set_race_attitude( 3, &locals[73], &locals[72], &locals[71] ); locals[74] = 222; locals[75] = 0; set_attitude( 2, &locals[75], &locals[74] ); func_008b(); break; case 3: locals[76] = 9; locals[77] = 0; locals[78] = 6; set_race_attitude( 3, &locals[78], &locals[77], &locals[76] ); locals[79] = 222; locals[80] = 0; set_attitude( 2, &locals[80], &locals[79] ); func_008b(); } // end if } // end if break; } // end switch say( "Me tired of this. You die now!" ); locals[81] = 9; locals[82] = 0; locals[83] = 6; set_race_attitude( 3, &locals[83], &locals[82], &locals[81] ); locals[84] = 222; locals[85] = 0; set_attitude( 2, &locals[85], &locals[84] ); func_008b(); } // end func void func_0607() { int locals[27]; locals[1] = 19; // "Pardon me. I'll be on my way now." locals[2] = 20; // "Don't tell ME what to do, goblin, or I'll remove your head." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0683(); break; case 2: locals[23] = 9; locals[24] = 0; locals[25] = 6; set_race_attitude( 3, &locals[25], &locals[24], &locals[23] ); locals[26] = 222; locals[27] = 0; set_attitude( 2, &locals[27], &locals[26] ); func_008b(); break; } // end switch } // end func void func_0683() { say( "You better be." ); npc_goal = 7; func_00e0(); } // end func void func_0695() { int locals[22]; locals[1] = 22; // "No, please wait!" locals[2] = 23; // "Ha, we shall see." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_06da(); break; case 2: func_06da(); break; } // end switch } // end func void func_06da() { int locals[5]; say( "GRRAAARRRGGH!!!" ); locals[1] = 9; locals[2] = 0; locals[3] = 6; set_race_attitude( 3, &locals[3], &locals[2], &locals[1] ); locals[4] = 222; locals[5] = 0; set_attitude( 2, &locals[5], &locals[4] ); func_008b(); } // end func void func_071e() { int locals[22]; locals[1] = 25; // "Thank you, kind goblin." locals[2] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); if ( locals[22] == 1 ) { remove_talker( 0 ); func_00e0(); } // end if } // end func void func_0754() { int locals[44]; setup_to_barter( 0 ); while ( !private[1] ) { locals[1] = 26; // "I make thee this offer." locals[2] = 27; // "I demand thou givest me these items." locals[3] = 28; // "Excuse me, I must think about this deal." locals[4] = 29; // "I do not wish to barter any further." locals[5] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0805(); break; case 2: func_085f(); break; case 3: do_judgement( 0 ); break; case 4: do_decline( 0 ); private[1] = 1; break; } // end switch } // while locals[23] = 30; // "Farewell." locals[24] = 0; // "" locals[44] = babl_menu( 0, &locals[23] ); if ( locals[44] == 1 ) { private[1] = 1; } // end if } // end func void func_0805() { int locals[15]; locals[0] = -1; locals[6] = -1; locals[11] = 31; // "I accept thy offer." locals[12] = 32; // "No, I do not like this deal." locals[13] = 33; // "Dost thou take me for a fool?" locals[14] = 34; // "I am weary of this haggling." locals[15] = 35; // "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_085f() { int locals[24]; say( "Dost thou intend to rob me?" ); locals[1] = 37; // "Yes, I must." locals[2] = 38; // "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] = 39; // "If thou dost insist, thou canst have them." locals[24] = 40; // "No! Thou shalt not take them!" if ( do_demand( 2, &locals[24], &locals[23] ) ) { private[1] = 1; } else { func_008b(); } // end if } // end func