Ultima Underworld/technical/conversations/13
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 #13 // string block 0x0e0d (3597), name Morlock // // 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]; if ( private[0] ) { func_0860(); } else { private[5] = 0; private[2] = 0; private[3] = 0; private[4] = 0; private[6][1] = 0; private[6][2] = 0; private[9] = 0; private[10] = 0; private[11] = 0; say( "Hail to thee, bold traveller. I am Morlock." ); locals[1] = 2; // "Excuse me, I must be going." locals[2] = 3; // "What canst thou tell me of thy people?" locals[3] = 4; // "I have something for thee." locals[4] = 5; // "I am in search of adventure." locals[5] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: locals[23] = 2; func_00b1( &locals[23] ); break; case 2: func_0352(); break; case 3: func_0432(); break; case 4: func_03b7(); } // end if break; } // end switch } // end func void func_0352() { int locals[23]; say( "Well, I can tell thee that one of my comrades, the mage Bronus, has need of thy services. Deliver to me an object of his, and thou shalt be rewarded." ); locals[1] = 7; // "In fact, I have already acquired that object from him." locals[2] = 8; // "Perhaps I shall run across him." locals[3] = 9; // "I have no interest in running errands." locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0432(); break; case 2: locals[23] = 2; func_00b1( &locals[23] ); break; case 3: func_041c(); break; } // end switch } // end func void func_03b7() { int locals[23]; say( "Ah! Well, I believe that my fellow mage Bronus has something for me. If thou wouldst deliver it to me, perhaps I can help thee further." ); locals[1] = 11; // "In fact, I have already acquired that object from him." locals[2] = 12; // "Perhaps I shall run across him." locals[3] = 13; // "I have no interest in running errands." locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0432(); break; case 2: locals[23] = 3; func_00b1( &locals[23] ); break; case 3: func_041c(); break; } // end switch } // end func void func_041c() { int locals[1]; say( "That is too bad. If thou changest thy mind, do not hesitate to talk to me again!" ); locals[1] = 2; func_00b1( &locals[1] ); } // end func void func_0432() { int locals[102]; locals[15] = 0; locals[13] = show_inv( 2, &locals[6], &locals[1] ); while ( locals[13] > 0 ) { locals[14] = 1; if ( locals[14] <= locals[13] ) { if ( locals[0] == 276 ) { locals[15] = locals[14]; locals[11] = locals[5]; } // end if locals[14] = locals[14] + 1; } // while } // end if if ( locals[15] > 0 ) { locals[16] = 1; give_to_npc( 2, &locals[11], &locals[16] ); private[5] = 1; say( "Ah! Thou hast brought my book! Excellent!" ); func_058b(); } else { if ( locals[13] == 0 ) { say( "Thou sayest thou hast something for me?" ); locals[38] = 1; locals[17] = 17; // "Yes, here it is." locals[39] = 1; locals[18] = 18; // "No, thou dost misunderstand." locals[19] = 0; // "" locals[59] = babl_fmenu( 0, &locals[17], &locals[38] ); switch ( locals[59] ) { case 17: func_0432(); break; case 18: func_0575(); } // end if } else { break; } // end switch say( "None of this is mine. Dost thou really have an item of mine?" ); locals[81] = 1; locals[60] = 20; // "Yes, here it is." locals[82] = 1; locals[61] = 21; // "No, I'm afraid not." locals[62] = 0; // "" locals[102] = babl_fmenu( 0, &locals[60], &locals[81] ); switch ( locals[102] ) { case 20: func_0432(); break; case 21: func_0575(); } // end if break; } // end switch } // end func void func_0563() { private[5] = 1; say( "Perhaps the errand was too difficult for thee. But no matter." ); func_058b(); } // end func void func_0575() { int locals[1]; say( "Well, if thou dost acquire that object, please do not delay in bringing it to me." ); locals[1] = 2; func_00b1( &locals[1] ); } // end func void func_058b() { int locals[43]; say( "Thou art @GS8, art thou not?" ); locals[22] = 1; locals[1] = 25; // "Aye, that is my name." locals[23] = 1; locals[2] = 26; // "Nay. I have not heard of this @GS8." locals[24] = private[4]; locals[3] = 27; // "Thou knowest I am." locals[4] = 0; // "" locals[43] = babl_fmenu( 0, &locals[1], &locals[22] ); switch ( locals[43] ) { case 25: func_0603(); break; case 26: func_065d(); break; case 27: func_0603(); break; } // end switch } // end func void func_0603() { int locals[22]; private[4] = 1; if ( private[11] ) { say( "Ah! Why didst thou not say so?" ); private[11] = 0; } // end if say( "I was simply going to reward thee for bringing me my book, but now I hear that thou hast met and slain the fearsome Fire Hydra. That eight-headed monster has long menaced our peaceable folk. Well done! Thou hast earned an even greater reward!" ); locals[1] = 30; // "Assuredly. I was wondering from whom I might get my reward." locals[2] = 31; // "I beg thy pardon. I slew no such beast." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0750(); break; case 2: func_07ab(); break; } // end switch } // end func void func_065d() { int locals[25]; locals[1] = sex( 2, &locals[3], &locals[2] ); locals[2] = 32; locals[3] = 33; say( "A pity. I have heard much good said of @SS1." ); locals[4] = 35; // "Oh, THAT @GS8! Ah, yes, that is me." locals[5] = 36; // "What hast thou heard?" locals[6] = 0; // "" locals[25] = babl_menu( 0, &locals[4] ); switch ( locals[25] ) { case 1: func_0743(); break; case 2: func_06c0(); break; } // end switch } // end func void func_06c0() { int locals[27]; locals[1] = sex( 2, &locals[3], &locals[2] ); locals[2] = 37; locals[3] = 38; say( "Only that @SS1 was a paragon of honesty." ); locals[1] = sex( 2, &locals[5], &locals[4] ); locals[4] = 40; // "him" locals[5] = 41; // "her" locals[6] = 42; // "Ah, thou didst speak of me, then. Thou didst mispronounce my name so badly that I misunderstood thee." locals[7] = 43; // "Well, if I should meet @GS8, I shall greet @SS1 for thee. Goodbye." locals[8] = 0; // "" locals[27] = babl_menu( 0, &locals[6] ); switch ( locals[27] ) { case 1: func_0743(); break; case 2: private[11] = 1; func_00c2(); break; } // end switch } // end func void func_0743() { say( "Ah, I had thought as much. Thou didst fit the description." ); func_0603(); } // end func void func_0750() { int locals[23]; private[2] = 1; func_00ea( 37 ); say( "Thy reward shall be a powerful book. Thou shalt find it in a room behind a secret door in the Library." ); locals[1] = 46; // "Thank thee. I shall be on my way to collect my reward." locals[2] = 47; // "Hmm. Well, excuse me, I must be going." 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_00e0(); break; } // end switch } // end func void func_07ab() { int locals[23]; private[3] = 1; func_00ea( 37 ); say( "Thy honesty is commendable, and thy reward shall be the Book of Honesty. As Honesty and Truth are beyond Time, thou shalt find it by the key behind the hourglass." ); locals[1] = 49; // "Well, I thank thee. I shall be off to retrieve it now." locals[2] = 50; // "What can thou tell me of this Book?" locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: locals[23] = 3; func_00b1( &locals[23] ); break; case 2: func_0806(); break; } // end switch } // end func void func_0806() { int locals[24]; say( "The book was one of Sir Cabirus' Talismans. 'Twas written by Ravenhurst of Moonglow, who collected great works of honesty and essays upon Truth. It hath great power, both intrinsically and for the wisdom contained therein." ); locals[1] = 52; // "Well, I thank thee. I shall be off to retrieve it now." locals[2] = 53; // "Thank thee." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: locals[23] = 3; func_00b1( &locals[23] ); break; case 2: locals[24] = 3; func_00b1( &locals[24] ); break; } // end switch } // end func void func_0860() { if ( private[9] ) { func_0b2e(); } else { if ( private[3] ) { func_0ab7(); } else { if ( private[2] ) { func_0968(); } else { if ( private[5] ) { func_0900(); } else { func_088e(); } // end if } // end if } // end if } // end if } // end func void func_088e() { int locals[22]; say( "Hello again. Hast thou an object for me?" ); locals[1] = 55; // "Yes, here it is." locals[2] = 56; // "No, I do not." locals[3] = 57; // "Of what object dost thou speak?" locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0432(); break; case 2: func_0575(); break; case 3: func_08ea(); break; } // end switch } // end func void func_08ea() { int locals[1]; say( "My fellow mage Bronus wishes to deliver something to me. Seek him out. If thou bringst the object to me, I may reward thee." ); locals[1] = 2; func_00b1( &locals[1] ); } // end func void func_0900() { int locals[22]; if ( private[4] ) { say( "Ah, it is @GS8 again." ); func_0603(); } else { if ( private[11] ) { say( "Greetings once more. Hast thou found @GS8 yet?" ); locals[1] = 61; // "Actually, I am @GS8." locals[2] = 62; // "No, I have not." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0603(); break; case 2: func_095d(); } // end if } else { break; } // end switch func_058b(); } // end if } // end func void func_095d() { say( "Well, if thou findest @GS8, please let me know. I am looking for him." ); } // end func void func_0968() { int locals[44]; if ( private[10] ) { say( "Hello again. What dost thou want from me now?" ); locals[1] = 65; // "I merely wanted to thank thee again." locals[2] = 66; // "I was just stopping by to say hello." locals[3] = 67; // "I must admit that I slew no Fire Hydra." locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0a1f(); break; case 2: func_0a1f(); break; case 3: func_0a73(); } // end if } else { break; } // end switch say( "Hello, @GS8! Hast thou found thy reward?" ); locals[23] = 69; // "Yes, and I thank thee." locals[24] = 70; // "No, not yet." locals[25] = 71; // "I must admit that I do not deserve this reward. I slew no Fire Hydra." locals[26] = 0; // "" locals[44] = babl_menu( 0, &locals[23] ); switch ( locals[44] ) { case 1: func_0a35(); break; case 2: func_0a50(); break; case 3: func_0a73(); break; } // end switch } // end func void func_0a1f() { int locals[1]; say( "How kind of thee. I wish thee continued luck with thy quests." ); locals[1] = 2; func_00b1( &locals[1] ); } // end func void func_0a35() { int locals[1]; private[10] = 1; say( "I hope thou useth it well, for thou richly deserveth it." ); locals[1] = 2; func_00b1( &locals[1] ); } // end func void func_0a50() { int locals[1]; say( "It should not be hard to find." ); if ( private[3] ) { say( "Remember, it lies with the key behind the hourglass." ); } else { say( "Remember, it is behind a secret door in the Library." ); } // end if locals[1] = 2; func_00b1( &locals[1] ); } // end func void func_0a73() { int locals[23]; say( "Ah! The truth is out! Well, at least thou wert honest eventually. I am not sure whether thou really deservest the Book of Honesty, but perhaps thou hast learned from thy mistakes. As Honesty and Truth are beyond Time, thou shalt find it by the key behind the hourglass." ); private[3] = 1; locals[1] = 78; // "Thank thee, and farewell." locals[2] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); if ( locals[22] == 1 ) { func_00e0(); } // end if locals[23] = 2; func_00b1( &locals[23] ); } // end func void func_0ab7() { int locals[22]; say( "Hello, @GS8! Hast thou found thy reward?" ); locals[1] = 80; // "Yes, and I thank thee kindly." locals[2] = 81; // "No, not yet." locals[3] = 82; // "Thy directions were quite confusing." locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0b13(); break; case 2: func_0a50(); break; case 3: func_0a50(); break; } // end switch } // end func void func_0b13() { int locals[1]; private[9] = 1; say( "Congratulations! I hope that it will prove useful to thee." ); locals[1] = 3; func_00b1( &locals[1] ); } // end func void func_0b2e() { int locals[1]; say( "Congratulations again on thy discovery. I wish thee luck in thy continuing quest." ); locals[1] = 3; func_00b1( &locals[1] ); } // end func void func_0b44() { int locals[44]; setup_to_barter( 0 ); while ( !private[1] ) { locals[1] = 85; // "I make thee this offer." locals[2] = 86; // "I demand thou givest me these items." locals[3] = 87; // "Excuse me, I must think about this deal." locals[4] = 88; // "I do not wish to barter any further." locals[5] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0bf5(); break; case 2: func_0c4f(); break; case 3: do_judgement( 0 ); break; case 4: do_decline( 0 ); private[1] = 1; break; } // end switch } // while locals[23] = 89; // "Farewell." locals[24] = 0; // "" locals[44] = babl_menu( 0, &locals[23] ); if ( locals[44] == 1 ) { private[1] = 1; } // end if } // end func void func_0bf5() { int locals[15]; locals[0] = -1; locals[6] = -1; locals[11] = 90; // "I accept thy offer." locals[12] = 91; // "No, I do not like this deal." locals[13] = 92; // "Dost thou take me for a fool?" locals[14] = 93; // "I am weary of this haggling." locals[15] = 94; // "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_0c4f() { int locals[24]; say( "Dost thou intend to rob me?" ); locals[1] = 96; // "Yes, I must." locals[2] = 97; // "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] = 98; // "If thou dost insist, thou canst have them." locals[24] = 99; // "No! Thou shalt not take them!" if ( do_demand( 2, &locals[24], &locals[23] ) ) { private[1] = 1; } else { func_008b(); } // end if } // end func