Ultima Underworld/technical/conversations/190
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 #190 // string block 0x0ebe (3774), name Bronus // // 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[23]; private[4] = get_quest( 1, &locals[1] ); locals[1] = 8; if ( private[0] ) { func_0405(); } else { private[2] = 0; private[3] = 0; say( "Hello, adventurer. I have a book I must deliver to my fellow mage Morlock, but I have not the time to give it to him in person. Wilt thou take it to him for me?" ); locals[2] = 2; // "It would be my pleasure." locals[3] = 3; // "I don't have the time either." locals[4] = 4; // "In what way might I benefit from such an act?" locals[5] = 0; // "" locals[23] = babl_menu( 0, &locals[2] ); switch ( locals[23] ) { case 1: func_037c(); break; case 2: func_031e(); break; case 3: func_0334(); } // end if break; } // end switch } // end func void func_031e() { int locals[1]; say( "I am sorry to hear that." ); locals[1] = 1; func_00b1( &locals[1] ); } // end func void func_0334() { int locals[22]; say( "Just the satisfaction of a job well done." ); locals[1] = 7; // "Very well, I will do this errand for thee." locals[2] = 8; // "I don't think so." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_037c(); break; case 2: func_031e(); break; } // end switch } // end func void func_037c() { int locals[22]; say( "This book contains very powerful magic that is meant only for Morlock. Thou must promise not to open it." ); locals[1] = 10; // "Yes, I promise." locals[2] = 11; // "I'm sorry, I can't help thee." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_03c4(); break; case 2: func_031e(); break; } // end switch } // end func void func_03c4() { int locals[3]; locals[1] = take_from_npc( 1, &locals[2] ); locals[2] = 276; if ( (locals[1] == 1 || locals[1] == 2) ) { private[2] = 1; say( "Here is the book. Please give it to Morlock, and remember not to open it!" ); } else { say( "I'm sorry, I seem to have misplaced it." ); } // end if locals[3] = 2; func_00b1( &locals[3] ); } // end func void func_0405() { int locals[68]; locals[1] = private[3]; if ( 2 == locals[1] ) { say( "I have no more use for thee." ); locals[2] = 1; func_00b1( &locals[2] ); } else { if ( 1 == locals[1] ) { say( "It was very kind of thee to run that errand, but I have no more time to talk to thee." ); locals[3] = 2; func_00b1( &locals[3] ); } else { if ( 0 == locals[1] ) { if ( private[2] ) { say( "Hello again. Didst thou give that book to Morlock?" ); locals[25] = 1; locals[4] = 17; // "Not yet." locals[26] = 1; locals[5] = 18; // "Yes." locals[27] = private[4]; locals[6] = 19; // "No... I had a small accident." locals[7] = 0; // "" locals[46] = babl_fmenu( 0, &locals[4], &locals[25] ); switch ( locals[46] ) { case 17: func_0505(); break; case 18: func_051b(); break; case 19: func_0536(); } // end if } else { break; } // end switch say( "Hello again. Hast thou reconsidered performing that small errand?" ); locals[47] = 21; // "Yes." locals[48] = 22; // "No, I still would rather not." locals[49] = 0; // "" locals[68] = babl_menu( 0, &locals[47] ); switch ( locals[68] ) { case 1: func_037c(); break; case 2: func_031e(); break; } // end switch } // end if } // end if } // end if } // end func void func_0505() { int locals[1]; say( "Then do so, please!" ); locals[1] = 1; func_00b1( &locals[1] ); } // end func void func_051b() { int locals[1]; private[3] = 1; say( "I thank thee very much." ); locals[1] = 3; func_00b1( &locals[1] ); } // end func void func_0536() { int locals[7]; if ( private[5] ) { private[3] = 2; say( "I should have known better than to trust thee a second time. Perhaps thou shouldst run less dangerous errands in the future." ); locals[2] = 1; func_00b1( &locals[2] ); } // end if private[3] = 0; private[5] = 1; locals[3] = 8; locals[4] = 1; set_quest( 2, &locals[4], &locals[3] ); say( "A little curious, wert thou? I expected as much, to be honest. It is well that I happened to have a second copy of the book. Please, be more careful with this one!" ); locals[1] = do_inv_create( 1, &locals[5] ); locals[5] = 276; locals[6] = 276; take_from_npc( 1, &locals[6] ); locals[7] = 2; func_00b1( &locals[7] ); } // end func void func_05a5() { int locals[44]; setup_to_barter( 0 ); while ( !private[1] ) { locals[1] = 27; // "I make thee this offer." locals[2] = 28; // "I demand thou givest me these items." locals[3] = 29; // "Excuse me, I must think about this deal." locals[4] = 30; // "I do not wish to barter any further." locals[5] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0656(); break; case 2: func_06b0(); break; case 3: do_judgement( 0 ); break; case 4: do_decline( 0 ); private[1] = 1; break; } // end switch } // while locals[23] = 31; // "Farewell." locals[24] = 0; // "" locals[44] = babl_menu( 0, &locals[23] ); if ( locals[44] == 1 ) { private[1] = 1; } // end if } // end func void func_0656() { int locals[15]; locals[0] = -1; locals[6] = -1; locals[11] = 32; // "I accept thy offer." locals[12] = 33; // "No, I do not like this deal." locals[13] = 34; // "Dost thou take me for a fool?" locals[14] = 35; // "I am weary of this haggling." locals[15] = 36; // "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_06b0() { int locals[24]; say( "Dost thou intend to rob me?" ); locals[1] = 38; // "Yes, I must." locals[2] = 39; // "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] = 40; // "If thou dost insist, thou canst have them." locals[24] = 41; // "No! Thou shalt not take them!" if ( do_demand( 2, &locals[24], &locals[23] ) ) { private[1] = 1; } else { func_008b(); } // end if } // end func