Ultima Underworld/technical/conversations/3

From Ultima Codex
Jump to navigation Jump to search

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 #3 // string block 0x0e03 (3587), name Goldthirst // // 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[6] = get_quest( 1, &locals[1] ); locals[1] = 4; if ( private[0] == 1 ) { func_09f7(); } else { private[2] = 1; private[4] = 0; private[3] = 0; private[5] = 0; say( "Greetings, Traveller. I am Goldthirst, leader of the Mountain-folk. Welcome to our hall." ); locals[2] = 2; // "Well met, Lord Goldthirst." locals[3] = 3; // "Thank thee, O Dwarf-King." locals[4] = 4; // "Greetings, your Majesty." locals[5] = 0; // "" locals[23] = babl_menu( 0, &locals[2] ); switch ( locals[23] ) { case 1: func_0373(); break; case 2: func_03bb(); break; case 3: func_032b(); } // end if break; } // end switch } // end func void func_032b() { int locals[22]; say( "Majesty, is it? Well, thou art good at flattery, if nothing else!" ); locals[1] = 6; // "It would be difficult to flatter one so noble as thee, your Majesty." locals[2] = 7; // "I beg thy pardon. I did not intend to insult thy intelligence with flattery." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_03c8(); break; case 2: func_046c(); break; } // end switch } // end func void func_0373() { int locals[22]; say( "Thou hast a fine tongue, and a sense of courtesy. Hast thou other Virtues as well?" ); locals[1] = 9; // "I am a paragon, embodying every Virtue, my Lord." locals[2] = 10; // "None worth mentioning, milord." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_07f6(); break; case 2: func_071d(); break; } // end switch } // end func void func_03bb() { say( "Call me that again, and thy tongue shall wag without thy head around it!" ); func_00d1(); } // end func void func_03c8() { int locals[23]; say( "That is quite enough. Hast thou some reason for coming here?" ); locals[2] = 13; // "I would see thy hoard." locals[3] = 14; // "I am in search of adventure." locals[4] = 15; // "I bring thee this gift." locals[5] = 0; // "" locals[23] = babl_menu( 0, &locals[2] ); switch ( locals[23] ) { case 1: func_06d5(); break; case 2: func_0779(); break; case 3: func_062c(); break; } // end switch } // end func void func_0424() { int locals[22]; say( "Thou shalt see it for thyself! Take thee to the end of the hall from which thou didst enter and say the words "Deco Morono" to the guard at the door." ); locals[1] = 17; // "I thank thee." locals[2] = 18; // "Thou art truly a noble dwarf." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_00e0(); break; case 2: func_03bb(); break; } // end switch } // end func void func_046c() { int locals[22]; say( "Well! Thou art aware that it is customary to offer a gift when granted an audience?" ); locals[1] = 20; // "No, I was not, my lord. I have nothing worthy here." locals[2] = 21; // "Indeed. Here is thy gift." locals[3] = 22; // "Ah, but I am giving thee the blessing of my company!" locals[4] = 23; // "My apologies. We have different customs where I come from." locals[5] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_04dc(); break; case 2: func_054c(); break; case 3: func_07f6(); break; case 4: func_00c2(); break; } // end switch } // end func void func_04dc() { int locals[22]; say( "That's quite all right. Nothing fancy is needed, just a token. A little . . . GOLD will do." ); locals[1] = 25; // "Here is thy gift." locals[2] = 26; // "Nay, I spoke truly. I have nothing to give." locals[3] = 27; // "No, I cannot help thee with that." locals[4] = 28; // "Is there some other way I can help thee?" locals[5] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_054c(); break; case 2: func_00e0(); break; case 3: func_00c2(); break; case 4: func_0779(); break; } // end switch } // end func void func_054c() { int locals[39]; locals[14] = 0; label_0556:; locals[11] = show_inv( 2, &locals[6], &locals[1] ); if ( locals[11] > 0 ) { locals[13] = 1; locals[12] = 0; while ( locals[13] <= locals[11] ) { locals[12] = locals[12] + identify_inv( 4, &locals[17], &locals[15], &locals[16], &locals[5] ); locals[16] = 0; locals[17] = 0; locals[13] = locals[13] + 1; } // while give_to_npc( 2, &locals[6], &locals[11] ); if ( locals[12] > 5 ) { func_062c(); } else { func_068d(); } // end if } else { if ( locals[14] > 2 ) { say( "Thou canst not toy with me!" ); func_00d1(); } else { say( "But thou art empty handed! Dost thou really wish to give me a gift?" ); locals[18] = 31; // "Yes, I'm sorry, here it is..." locals[19] = 32; // "No, I have no gift worthy of thee." locals[20] = 0; // "" locals[39] = babl_menu( 0, &locals[18] ); switch ( locals[39] ) { case 1: locals[14] = locals[14] + 1; goto label_0556; break; case 2: func_04dc(); } // end if } // end if break; } // end switch return; } // end func void func_062c() { int locals[22]; private[2] = 0; say( "This is indeed a goodly gift, and I thank thee for it most kindly. Wouldst care to see the treasure chamber to which it will be added?" ); locals[1] = 34; // "Oh, yes, very much!" locals[2] = 35; // "No, but I thank thee." locals[3] = 36; // "Only if your lordship insists." locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_06d5(); break; case 2: func_00e0(); break; case 3: func_0424(); break; } // end switch } // end func void func_068d() { int locals[22]; say( "It will do, I suppose. Thou mayst go now." ); locals[1] = 38; // "Ungrateful wretch! A pox on thee and thy greed!" locals[2] = 39; // "Thy graciousness is overwhelming. Good-day." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_00d1(); break; case 2: func_00e0(); break; } // end switch } // end func void func_06d5() { int locals[22]; say( "Indeed, I suppose thou wouldst. Many should like to see my treasure . . . touch it, stroke it, perhaps STEAL it! That is what thou wouldst like, isn't it? To rob me blind after I was foolist enough to invite thee here!\n" " GUARDS! GUARDS! ARREST THIS THIEF!" ); locals[1] = 41; // "'Twas not my intent to upset thee. Call off thy guards. I will leave." locals[2] = 42; // "You'll never take @GS8 alive!" locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_00d1(); break; case 2: func_008b(); break; } // end switch } // end func void func_071d() { int locals[22]; say( "Well then. What is the reason for thy visit?" ); locals[1] = 44; // "I bring thee this gift." locals[2] = 45; // "I am seeking adventure." locals[3] = 46; // "Merely to meet thee." locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_054c(); break; case 2: func_0779(); break; case 3: func_046c(); break; } // end switch } // end func void func_0779() { int locals[43]; private[4] = 1; say( "Perhaps we can help each other . . . I have need of such an adventurer as thyself. Our mines have been invaded by a terrible monster!" ); locals[22] = 1; locals[1] = 48; // "Indeed? Perhaps I can help!" locals[23] = 1; locals[2] = 49; // "That is too bad. Good day to thee." locals[24] = private[6]; locals[3] = 50; // "I believe that I have slain the beast already." locals[4] = 0; // "" locals[43] = babl_fmenu( 0, &locals[1], &locals[22] ); switch ( locals[43] ) { case 48: func_0873(); break; case 49: func_00c2(); break; case 50: func_08bb(); break; } // end switch } // end func void func_07f6() { int locals[43]; private[4] = 1; say( "That is well. I have need of a paragon, just now. Art thou aware that my people's mine has been invaded by a monster?" ); locals[22] = 1; locals[1] = 52; // "Indeed? Perhaps I can help!" locals[23] = 1; locals[2] = 53; // "That is too bad. A good day to thee." locals[24] = private[6]; locals[3] = 54; // "I believe that I have slain the beast already." locals[4] = 0; // "" locals[43] = babl_fmenu( 0, &locals[1], &locals[22] ); switch ( locals[43] ) { case 52: func_0873(); break; case 53: func_00c2(); break; case 54: func_08bb(); break; } // end switch } // end func void func_0873() { int locals[22]; say( "Excellent! A hero at last. My people, at least those not too valuable to lose, are all too afraid of the beast to dare face it! It is a fearsome beast, covered with tentacles and with many eyes. If thou art brave enough, and you slay the creature, I shall reward thee handsomely!" ); locals[1] = 56; // "It shall be done!" locals[2] = 57; // "We shall see." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_00e0(); break; case 2: func_00c2(); break; } // end switch } // end func void func_08bb() { int locals[22]; private[5] = 1; say( "I knew thou wert a hero! Was it difficult?" ); locals[1] = 59; // "Extraordinarily so. None but I could have succeeded." locals[2] = 60; // "Yes. I was fortunate to have slain it." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0908(); break; case 2: func_0964(); break; } // end switch } // end func void func_0908() { int locals[43]; say( "We are then fortunate that thou wert the one to undertake the task. Thou hast our thanks. Was there anything else?" ); locals[22] = private[2]; locals[1] = 62; // "I pray thee, accept this humble gift." locals[23] = 1; locals[2] = 63; // "Thou art most welcome. Farewell." locals[3] = 0; // "" locals[43] = babl_fmenu( 0, &locals[1], &locals[22] ); switch ( locals[43] ) { case 62: func_054c(); break; case 63: func_00e0(); break; } // end switch } // end func void func_0964() { say( "And modest as well! Truly, thou art worthy of this great reward! Here!" ); func_0971(); } // end func void func_0971() { int locals[45]; private[3] = 1; locals[1] = 65; // "A small, stooped member of the race of Mountain-folk scuttles forward, presenting to you a small amulet cast in the shape of a stone-cutter's chisel.\m" print( 1, &locals[1] ); say( "This was the favored tool of Great Coulnes, the best gemcutter ever to grace our tribe. It is traditionally presented to heroes and those who excel in their craft. Thou art the first not of our folk to bear it. May it bring thee fortune. Again, our thanks." ); locals[2] = 275; if ( take_from_npc( 1, &locals[2] ) == 2 ) { say( "\mI will leave it here for ye." ); } // end if locals[24] = private[2]; locals[3] = 68; // "Thou art welcome. Accept this gift in return." locals[25] = 1; locals[4] = 69; // "I thank thee. Farewell." locals[5] = 0; // "" locals[45] = babl_fmenu( 0, &locals[3], &locals[24] ); switch ( locals[45] ) { case 68: func_054c(); break; case 69: func_00e0(); break; } // end switch } // end func void func_09f7() { if ( private[5] ) { func_0a8b(); } else { if ( private[4] ) { func_0a13(); } else { func_0b77(); } // end if } // end if } // end func void func_0a13() { int locals[43]; say( "Greetings, bold @GS8. Hast thou managed to kill the vicious monster infesting our mines?" ); locals[22] = private[6]; locals[1] = 71; // "Yes, the deed has been done." locals[23] = 1; locals[2] = 72; // "No, it has still eluded me." locals[24] = 1; locals[3] = 73; // "I have been busy with other quests." locals[4] = 0; // "" locals[43] = babl_fmenu( 0, &locals[1], &locals[22] ); switch ( locals[43] ) { case 71: func_08bb(); break; case 72: func_0b1d(); break; case 73: func_0b1d(); break; } // end switch } // end func void func_0a8b() { int locals[23]; say( "Ah, @GS8! It is a pleasure to see thee again. Thy name shall go down in the history of our clan!" ); locals[2] = 75; // "And rightfully so." locals[3] = 76; // "I do not deserve such praise." locals[4] = 77; // "I thank thee. Here is a gift for you." locals[5] = 0; // "" locals[23] = babl_menu( 0, &locals[2] ); switch ( locals[23] ) { case 1: func_0af0(); break; case 2: func_0b06(); break; case 3: if ( locals[1] ) { func_0c20(); } else { func_054c(); } // end if break; } // end switch } // end func void func_0af0() { int locals[1]; say( "Well, we are glad that thou hast visited us. Do say hello again when thou art in the vicinity. Thy company is always welcome." ); locals[1] = 3; func_00b1( &locals[1] ); } // end func void func_0b06() { if ( private[3] ) { say( "Oh, pish. Thou bearest the amulet of Coulnes, a testament to thy heroics. As long as this clan lives, we shall remember thee." ); } else { say( "Thou art humble as well as brave! Surely thou deservest a reward." ); func_0971(); } // end if } // end func void func_0b1d() { int locals[24]; say( "Hm. Perhaps thou art not so great a warrior as I first suspected." ); locals[1] = 82; // "Thou may be right." locals[2] = 83; // "I will do my best to vanquish the beast." 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: locals[24] = 2; func_00b1( &locals[24] ); break; } // end switch } // end func void func_0b77() { int locals[45]; locals[2] = !private[2]; if ( npc_attitude < 2 ) { say( "Oh, 'tis thee again. Is there a reason for thy visit?" ); } else { say( "Greetings, bold @GS8. What brings thee back to our hall?" ); } // end if locals[24] = private[2]; locals[3] = 86; // "I have a gift for your Lordship. I trust it pleases thee." locals[25] = locals[2]; locals[4] = 87; // "I have another gift for your Lordship." locals[26] = 1; locals[5] = 88; // "I am in search of adventure." locals[27] = 1; locals[6] = 89; // "I merely wished to pay my respects, your Lordship. I must be going." locals[7] = 0; // "" locals[45] = babl_fmenu( 0, &locals[3], &locals[24] ); switch ( locals[45] ) { case 86: func_054c(); break; case 87: func_0c20(); break; case 88: func_0779(); break; case 89: func_00e0(); break; } // end switch } // end func void func_0c20() { int locals[42]; locals[14] = 0; label_0c2a:; locals[11] = show_inv( 2, &locals[6], &locals[1] ); if ( locals[11] > 0 ) { locals[13] = 1; locals[12] = 0; while ( locals[13] <= locals[11] ) { if ( locals[0] == 175 ) { locals[16] = locals[5]; locals[18] = 1; give_to_npc( 2, &locals[16], &locals[18] ); func_0d84(); } // end if locals[12] = locals[12] + identify_inv( 4, &locals[20], &locals[15], &locals[19], &locals[5] ); locals[19] = 0; locals[20] = 0; locals[13] = locals[13] + 1; } // while give_to_npc( 2, &locals[6], &locals[11] ); if ( locals[12] > 5 ) { func_0d2a(); } else { func_068d(); } // end if } else { if ( locals[14] > 2 ) { say( "Thou canst not toy with me!" ); func_00d1(); } else { say( "But thou art empty handed! Dost thou really wish to give me a gift?" ); locals[21] = 92; // "Yes, I'm sorry, here it is..." locals[22] = 93; // "No, I have no gift worthy of thee." locals[23] = 0; // "" locals[42] = babl_menu( 0, &locals[21] ); switch ( locals[42] ) { case 1: locals[14] = locals[14] + 1; goto label_0c2a; break; case 2: func_04dc(); } // end if } // end if break; } // end switch } // end func void func_0d2a() { int locals[24]; say( "'Tis a fine gift. I thank thee kindly." ); locals[1] = 95; // "Thou art welcome. Farewell." locals[2] = 96; // "I am glad thou dost enjoy it." 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_0d84() { int locals[2]; say( "Zounds! A larger lump of gold I have never seen! Surely thou art deserving of this axe, an honored weapon that has been passed down from the time of my ancestors. Use it well, for there are few weapons better." ); locals[1] = 11; take_from_npc( 1, &locals[1] ); locals[2] = 3; func_00b1( &locals[2] ); } // end func