Ultima Underworld/technical/conversations/221
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 #221 // string block 0x0edd (3805), name imp // // 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; private[5] = 0; private[6] = 0; private[7] = 0; private[8] = 0; private[9] = 0; private[10] = 0; private[11] = 0; private[12] = 0; private[13] = 0; } // end if func_02eb(); } // end func void func_02eb() { int locals[22]; say( "Searching for something are we?\n" " Need to find a path?\n" " Slip-up and you'll be wormfood.\n" " Victim of Tyball's wrath." ); locals[1] = 2; // "Who art thou?" locals[2] = 3; // "What dost thou mean?" locals[3] = 4; // "I've no time for thy games." locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0347(); break; case 2: func_0403(); break; case 3: func_0a17(); break; } // end switch } // end func void func_0347() { int locals[44]; say( "A thief I am, a thief I'll be.\n" " With a very great prize.\n" " Have something you want, something you need.\n" " It'll open up your eyes." ); private[2] = 1; if ( private[4] == 0 ) { locals[1] = 6; // "What do you have that I need?" locals[2] = 7; // "Open up my eyes?" locals[3] = 8; // "Why would you give me anything?" locals[4] = 9; // "I've had enough of your riddles." locals[5] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_04ab(); break; case 2: func_05c9(); break; case 3: func_0403(); break; case 4: func_0a17(); } // end if } else { break; } // end switch locals[23] = 10; // "Open up my eyes?" locals[24] = 11; // "I've had enough of your riddles." locals[25] = 0; // "" locals[44] = babl_menu( 0, &locals[23] ); switch ( locals[44] ) { case 1: func_05c9(); break; case 2: func_0a17(); break; } // end switch } // end func void func_0403() { int locals[44]; say( "The evil one, very bad.\n" " Here to hurt us all.\n" " We'll give you a gift if you're wise enough.\n" " Just to see him fall." ); private[3] = 1; if ( private[2] == 0 ) { locals[1] = 13; // "What gift?" locals[2] = 14; // "Who art thou?" locals[3] = 15; // "I've had enough of thy riddles." locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_04ab(); break; case 2: func_0347(); break; case 3: func_0a17(); } // end if } else { break; } // end switch locals[23] = 16; // "What gift?" locals[24] = 17; // "I've had enough of thy riddles." locals[25] = 0; // "" locals[44] = babl_menu( 0, &locals[23] ); switch ( locals[44] ) { case 1: func_04ab(); break; case 2: func_0a17(); break; } // end switch } // end func void func_04ab() { int locals[66]; say( "A crown it is, that's what we offer.\n" " The only thing for you in this room.\n" " The rest of the treasure is not yours to have.\n" " To steal it will mean your doom." ); private[4] = 1; if ( private[3] == 0 && private[5] == 0 ) { locals[1] = 19; // "My doom?" locals[2] = 20; // "What's so special about this crown?" locals[3] = 21; // "Why dost thou offer me this?" locals[4] = 22; // "Don't threaten me, runt." locals[5] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_06b8(); break; case 2: func_0719(); break; case 3: func_07d2(); break; case 4: func_0a17(); } // end if } else { break; } // end switch if ( private[3] == 0 ) { locals[23] = 23; // "My doom?" locals[24] = 24; // "Why dost thou offer me this?" locals[25] = 25; // "Don't threaten me, runt." locals[26] = 0; // "" locals[44] = babl_menu( 0, &locals[23] ); switch ( locals[44] ) { case 1: func_06b8(); break; case 2: func_07d2(); break; case 3: func_0a17(); } // end if } else { break; } // end switch locals[45] = 26; // "My doom?" locals[46] = 27; // "Don't threaten me, runt." locals[47] = 0; // "" locals[66] = babl_menu( 0, &locals[45] ); switch ( locals[66] ) { case 1: func_06b8(); break; case 2: func_0a17(); break; } // end switch } // end func void func_05c9() { int locals[66]; say( "A maze it is, you'll want to get through.\n" " Though many a fool it did swallow.\n" " What I have will enhance your eyes.\n" " And show you the yellow to follow." ); private[5] = 1; if ( private[4] == 0 ) { locals[1] = 29; // "So what is this item?" locals[2] = 30; // "Why art thou helping me?" locals[3] = 31; // "Bah, I don't need thy help." locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_04ab(); break; case 2: func_07d2(); break; case 3: func_0a17(); } // end if } else { break; } // end switch if ( private[8] == 0 ) { locals[23] = 32; // "Why art thou helping me?" locals[24] = 33; // "Bah, I don't need thy help." locals[25] = 0; // "" locals[44] = babl_menu( 0, &locals[23] ); switch ( locals[44] ) { case 1: func_07d2(); break; case 2: func_0a17(); } // end if } else { break; } // end switch locals[45] = 34; // "So where is this item?" locals[46] = 35; // "Bah, I don't need thy help." locals[47] = 0; // "" locals[66] = babl_menu( 0, &locals[45] ); switch ( locals[66] ) { case 1: func_0752(); break; case 2: func_0a17(); break; } // end switch } // end func void func_06b8() { int locals[22]; say( "Our possessions have a magic upon them.\n" " To protect them from those who would take.\n" " Touching the wrong thing could mean instant death.\n" " Or at the least - a headache." ); private[6] = 1; locals[1] = 37; // "So how do I know which one to take?" locals[2] = 38; // "How could an imp like you stop me from taking it all?" locals[3] = 39; // "I'm sick of this game." locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0752(); break; case 2: func_08b3(); break; case 3: func_0a17(); break; } // end switch } // end func void func_0719() { int locals[22]; say( "A maze it is, you'll want to get through.\n" " Though many a fool it did swallow.\n" " What I have will enhance your eyes.\n" " And show you the yellow to follow." ); private[7] = 1; locals[1] = 41; // "So how do I know which one to take?" locals[2] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); if ( locals[22] == 1 ) { func_0752(); } // end if } // end func void func_0752() { int locals[44]; say( "That's the question, is it not?\n" " And one you'll have to figure.\n" " Its one eye to help you is not bloodshot.\n" " And its size is smaller, not bigger." ); private[9] = 1; if ( private[10] == 0 ) { locals[1] = 43; // "How is it that you have this crown?" locals[2] = 44; // "What if I just take them all?" locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0866(); break; case 2: func_08b3(); } // end if } else { break; } // end switch locals[23] = 45; // "How is it that you have this crown?" locals[24] = 0; // "" locals[44] = babl_menu( 0, &locals[23] ); if ( locals[44] == 1 ) { func_0866(); } // end if } // end func void func_07d2() { int locals[44]; say( "The evil one, very bad.\n" " Here to hurt us all.\n" " We'll give you a gift if you're wise enough.\n" " Just to see him fall." ); private[8] = 1; if ( private[2] == 0 ) { locals[1] = 47; // "Who art thou?" locals[2] = 48; // "I've had enough of thy riddles." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0347(); break; case 2: func_0a17(); } // end if } else { break; } // end switch locals[23] = 49; // "So where is this crown?" locals[24] = 50; // "I've had enough of thy riddles." locals[25] = 0; // "" locals[44] = babl_menu( 0, &locals[23] ); switch ( locals[44] ) { case 1: func_0752(); break; case 2: func_0a17(); break; } // end switch } // end func void func_0866() { int locals[22]; say( "A thief I told you, is what I am.\n" " And a grand theft it was, I suppose.\n" " Heisted the crown, slick as can be.\n" " Right from under the evil one's nose." ); private[11] = 1; locals[1] = 52; // "So why not just give me this crown?" locals[2] = 53; // "I don't believe you. I'll just take whatever I want." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0966(); break; case 2: func_0a17(); break; } // end switch } // end func void func_08b3() { int locals[66]; say( "Take just what you need.\n" " Some items are cursed.\n" " The golems guard others.\n" " So much the worse." ); private[10] = 1; if ( private[13] == 1 ) { locals[1] = 55; // "Is that all then?" locals[2] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); if ( locals[22] == 1 ) { func_09ab(); } // end if } else { } // end if if ( private[9] == 0 ) { locals[23] = 56; // "So how do I know which crown it is?" locals[24] = 57; // "How is it that thou hast this crown?" locals[25] = 0; // "" locals[44] = babl_menu( 0, &locals[23] ); switch ( locals[44] ) { case 1: func_0752(); break; case 2: func_0866(); } // end if } else { break; } // end switch locals[45] = 58; // "How is it that thou hast this crown?" locals[46] = 0; // "" locals[66] = babl_menu( 0, &locals[45] ); if ( locals[66] == 1 ) { func_0866(); } // end if } // end func void func_0966() { int locals[22]; say( "Can't just give it to anyone.\n" " My clues you must heed.\n" " Prove yourself worthy.\n" " And control your greed." ); private[13] = 1; locals[1] = 60; // "What other clues canst thou give me?" locals[2] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); if ( locals[22] == 1 ) { if ( private[7] == 0 ) { func_0719(); } else { func_09ab(); } // end if } // end if } // end func void func_09ab() { int locals[22]; say( "That's all I can tell you.\n" " It should be enough.\n" " Its really quite simple.\n" " If you're too dumb? - That's tough!" ); locals[1] = 62; // "Wait, thou must tell me more." locals[2] = 63; // "That's not very nice." locals[3] = 64; // "Thank thee." locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0a07(); break; case 2: func_0a07(); break; case 3: func_0a07(); break; } // end switch } // end func void func_0a07() { say( "Heh heh heh... We'll be watching." ); remove_talker( 0 ); } // end func void func_0a17() { say( "Heh heh heh... Suit thyself, fool." ); remove_talker( 0 ); } // end func void func_0a27() { int locals[44]; setup_to_barter( 0 ); while ( !private[1] ) { locals[1] = 67; // "I make thee this offer." locals[2] = 68; // "I demand thou givest me these items." locals[3] = 69; // "Excuse me, I must think about this deal." locals[4] = 70; // "I do not wish to barter any further." locals[5] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0ad8(); break; case 2: func_0b32(); break; case 3: do_judgement( 0 ); break; case 4: do_decline( 0 ); private[1] = 1; break; } // end switch } // while locals[23] = 71; // "Farewell." locals[24] = 0; // "" locals[44] = babl_menu( 0, &locals[23] ); if ( locals[44] == 1 ) { private[1] = 1; } // end if } // end func void func_0ad8() { int locals[15]; locals[0] = -1; locals[6] = -1; locals[11] = 72; // "I accept thy offer." locals[12] = 73; // "No, I do not like this deal." locals[13] = 74; // "Dost thou take me for a fool?" locals[14] = 75; // "I am weary of this haggling." locals[15] = 76; // "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_0b32() { int locals[24]; say( "Dost thou intend to rob me?" ); locals[1] = 78; // "Yes, I must." locals[2] = 79; // "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] = 80; // "If thou dost insist, thou canst have them." locals[24] = 81; // "No! Thou shalt not take them!" if ( do_demand( 2, &locals[24], &locals[23] ) ) { private[1] = 1; } else { func_008b(); } // end if } // end func