Ultima Underworld/technical/conversations/139

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 #139 // string block 0x0e8b (3723), name Trisch // // 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[87]; if ( private[0] == 0 ) { private[2] = 0; say( "I welcome thee to the last bastion of civilization in the Abyss, traveller." ); locals[1] = 2; // "Thou dost relieve my fears, for I thought civilization gone." locals[2] = 3; // "This really isn't much, despite thy claims." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_075f(); break; case 2: func_0711(); } // end if } else { break; } // end switch if ( npc_attitude < 2 ) { say( "I have nothing to say to thee." ); locals[23] = 5; // "If that is what thou wishest." locals[24] = 6; // "Wait! I must speak with thee." locals[25] = 0; // "" locals[44] = babl_menu( 0, &locals[23] ); switch ( locals[44] ) { case 1: func_00d1(); break; case 2: func_06c7(); } // end if } else { break; } // end switch if ( private[3] ) { func_03b7(); } else { say( "Thou hast returned. What dost thou wish to speak of?" ); locals[66] = 1; locals[45] = 8; // "Nothing. Farewell." locals[67] = 1; locals[46] = 9; // "The order of the Crux Ansata." locals[68] = private[2]; locals[47] = 10; // "This taper that was lost." locals[48] = 0; // "" locals[87] = babl_fmenu( 0, &locals[45], &locals[66] ); switch ( locals[87] ) { case 8: func_00e0(); break; case 9: func_03c4(); break; case 10: func_0491(); } // end if break; } // end switch } // end func void func_03b7() { say( "It is good to see thee again. Thou wilt go down in the history of our order as the brave soul who found the Taper of Sacrifice that was so long lost. I thank thee again." ); func_00e0(); } // end func void func_03c4() { int locals[69]; locals[1] = get_quest( 1, &locals[3] ); locals[3] = 32; locals[2] = !private[2]; if ( locals[1] >= 2 ) { say( "Our order has been here since the founding of the Colony of the Abyss, and has had many virtuous members. In the chaos that followed Cabirus' death, we attempted to collect the Talismans of virtue. However, most were already lost, some supposedly destroyed.\n" " We did have the Taper of Sacrifice, briefly, but it was taken by some lunatic. Supposedly the Standard of Honor is somewhere as well, merely awaiting an honorable deed." ); locals[25] = locals[2]; locals[4] = 13; // "Tell me about this taper." locals[26] = 1; locals[5] = 15; // "Thank you for the information." locals[6] = 0; // "" locals[46] = babl_fmenu( 0, &locals[4], &locals[25] ); switch ( locals[46] ) { case 13: say( "We had it, but a while ago a lunatic raided our quarters and stole many things." ); func_07f3(); break; case 15: say( "It is my pleasure to provide information to a member of the order." ); } // end if } else { break; } // end switch say( "The order has been here since the founding of the Colony of the Abyss, and has had many virtuous members. More I cannot say to one who is not a member, but thou mayst return to me once thou art inducted and I can tell thee more." ); locals[47] = 18; // "I shall." locals[48] = 19; // "I doubt I will bother." locals[49] = 0; // "" locals[68] = babl_menu( 0, &locals[47] ); switch ( locals[68] ) { case 1: break; case 2: say( "Well, thy path is thine alone to choose, but I feel it should lie with ours for a while." ); break; } // end switch locals[69] = 2; func_00b1( &locals[69] ); } // end func void func_0491() { int locals[44]; say( "Hast thou heard tell of it, or even seen it, perhaps?" ); locals[1] = 22; // "Yes, I have heard others speak of it." locals[2] = 24; // "Yes. Actually, I have it." locals[3] = 25; // "No. Canst thou tell me more of it?" locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: say( "That is good news. Continue to search, and thou mayst find it." ); break; case 2: func_0518(); break; case 3: say( "The lunatic who took it fled to the levels above, or so it is told. Perhaps others have heard tell of him, or can otherwise help thee." ); break; } // end switch locals[23] = 27; // "Farewell." locals[24] = 0; // "" locals[44] = babl_menu( 0, &locals[23] ); if ( locals[44] == 1 ) { func_00e0(); } // end if } // end func void func_0518() { int locals[62]; say( "It is in thy possession e'en now? Could thou please show it to me?" ); locals[3] = 0; } // end if locals[4] = 29; // "Very well, here it is." locals[5] = 30; // "No. It would not be appropriate." locals[6] = 0; // "" locals[25] = babl_menu( 0, &locals[4] ); switch ( locals[25] ) { case 1: break; case 2: if ( locals[3] < 3 ) { locals[26] = locals[3]; if ( 0 == locals[26] ) { say( "Please, may I see it?" ); } else { if ( 1 == locals[26] ) { say( "Please reconsider." ); } else { if ( 2 == locals[26] ) { } // end if } // end if } // end if say( "I beg of thee, let me but look at it." ); } else { locals[3] = locals[3] + 1; } else { say( "Thou art indeed cruel, to deny me a glance at the Taper of Sacrifice." ); locals[27] = 1; func_00b1( &locals[27] ); break; } // end switch locals[2] = 0; locals[1] = find_barter( 1, &locals[28] ); locals[28] = 147; switch ( locals[1] ) { case 0: locals[2] = 1; locals[1] = find_barter( 1, &locals[29] ); locals[29] = 151; break; case 0: say( "That is not the Taper. Return if thou hast truly found it." ); locals[30] = 1; func_00b1( &locals[30] ); break; } // end switch locals[31] = 1; locals[32] = 7; locals[33] = -1; locals[34] = -1; locals[35] = -1; locals[36] = -1; locals[37] = -1; locals[38] = -1; x_obj_stuff( 9, &locals[38], &locals[37], &locals[36], &locals[35], &locals[34], &locals[33], &locals[32], &locals[31], &locals[1] ); locals[39] = locals[2]; if ( 0 == locals[39] ) { say( "Ah! To see the taper again, this is good indeed." ); } else { if ( 1 == locals[39] ) { say( "Ah! It is good to be bathed in the taper's radiance once more." ); } // end if } // end if private[3] = 1; say( "I thank thee for the chance to see the taper again. Now that thou hast found it, it is right that thou dost keep it. Thou wilt find that the light it produces is quite steady, for it continually sacrifices of itself to produce light for thee.\n" " Cabirus imbued it with virtue, however, and although it consumes itself constantly to provide light, it is continually replenished as well." ); locals[40] = 39; // "I shall keep it then, and keep it safe." locals[41] = 41; // "Thank thee." locals[42] = 0; // "" locals[61] = babl_menu( 0, &locals[40] ); switch ( locals[61] ) { case 1: say( "Good luck to thee." ); break; case 2: say( "And I thank thee for finding it." ); break; } // end switch locals[62] = 3; func_00b1( &locals[62] ); } // end func void func_06c7() { int locals[22]; say( "What dost thou want?" ); locals[1] = 44; // "Nothing. Farewell." locals[2] = 45; // "Canst thou tell me of Sir Cabirus? I thought all had abandoned his dream." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_00e0(); break; case 2: func_07a7(); break; } // end switch func_085b(); } // end func void func_0711() { int locals[22]; say( "Thou hast uttered sacrilege. Recant or face my blade." ); locals[1] = 47; // "I must say what I believe." locals[2] = 49; // "Thou art quite right. This culture is splendid." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: say( "That is as it must be, as is my slaying thee in the name of my order." ); func_008b(); break; case 2: say( "That is more appropriate. I trust thou wilt remember this lesson. Leave now." ); func_00d1(); break; } // end switch } // end func void func_075f() { int locals[22]; say( "It has been thy misfortune to travel through the other levels of this wasteland, and I am not surprised thou dost think that. However, we still abide by the dreams of Cabirus and the eight virtues." ); locals[1] = 52; // "I thought all had abandoned Cabirus' dream." locals[2] = 53; // "They seem to be outdated, and to have failed. Perhaps you should admit defeat and start something new." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_07a7(); break; case 2: func_0711(); break; } // end switch } // end func void func_07a7() { int locals[22]; say( "No! We work still to bring about a return to the days of the Abyss' glory. There is hope yet if the races of the colony will believe again in the virtues and in each other.\n" " Unfortunately, I think there is little hope. Most of the dwellers in this colony have forgotten what little they may once have known about its purpose.\m" ); say( "Even the most stalwart believers now doubt. No one remembers the virtues any more. It is a sad situation.\n" " Why, several months ago, someone came from above and stole one of the greatest treasures remaining from Cabirus' days." ); locals[1] = 56; // "That is tragic." locals[2] = 58; // "What was stolen?" locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: say( "Indeed it was.\n" "" ); break; case 2: break; } // end switch func_07f3(); } // end func void func_07f3() { int locals[22]; say( "We lost many small things, mostly from storage. All of our torches and lanterns were taken. A few items of food, but mostly light sources, actually. Quite odd.\n" " The grave loss was that of the Taper of Sacrifice, though. It was created by Sir Cabirus himself and imbued with virtue. We placed it in our shrine where we kept a vigil over it. There it remained lit for three years.\m" ); say( "But one day a man arrived at one of our guard posts. He ranted and raved, but we let him in, as common courtesy dictates, of course. He started running about and grabbing candles and such. We were all too shocked to respond. Then he grabbed the Taper itself and ran off.\n" " By the time we were in armor and ready to give chase we had lost him. A tragedy it was." ); private[2] = 1; locals[1] = 61; // "Perhaps I shall seek this Taper thou dost speak of." locals[2] = 63; // "I believe that I have found this Taper." locals[3] = 64; // "It must be hard living in a wild place like this." locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: say( "I wish thee good luck. Seek it above, for that is where we believe the lunatic came from." ); break; case 2: func_0518(); break; case 3: say( "It is indeed tiresome. But Knights of the Crux are not defeated, regardless of the difficulty of their task." ); break; } // end switch func_085b(); } // end func void func_085b() { int locals[22]; locals[1] = 66; // "Farewell." locals[2] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); if ( locals[22] == 1 ) { func_00e0(); } // end if } // end func void func_088c() { 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_093d(); break; case 2: func_0997(); 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_093d() { 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_0997() { 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