Ultima Underworld/technical/conversations/7

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 #7 // string block 0x0e07 (3591), name Ketchaval // // 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[2] = get_quest( 1, &locals[1] ); locals[1] = 3; if ( private[2] == 0 ) { func_085b(); } // end if if ( private[6] == 1 ) { func_07ae(); } else { private[6] = 1; private[3] = 1; private[4] = 1; private[5] = 1; say( "Who be ye and what business have ye here?" ); locals[2] = 2; // "I am @GS8. I wish to speak to thee." locals[3] = 3; // "I am on a quest." locals[4] = 0; // "" locals[23] = babl_menu( 0, &locals[2] ); switch ( locals[23] ) { case 1: func_0369(); break; case 2: func_0321(); } // end if break; } // end switch } // end func void func_0321() { int locals[22]; say( "And who be ye?" ); locals[1] = 5; // "I am @GS8. Perhaps thou hast heard of me?" locals[2] = 6; // "@GS8 is my name. Canst help me?" locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0369(); break; case 2: func_0369(); break; } // end switch } // end func void func_0369() { int locals[22]; say( "I have never heard of ye. Be ye friend to Vernix?" ); locals[1] = 8; // "Vernix who?" locals[2] = 9; // "Yes, I am." locals[3] = 10; // "No, I am not." locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_03c5(); break; case 2: func_040d(); break; case 3: func_0441(); break; } // end switch } // end func void func_03c5() { int locals[22]; say( "Vernix, the so-called King of the so-called Green Goblins!" ); locals[1] = 12; // "Nay, I am no friend of his." locals[2] = 13; // "Aye, I call him friend." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0441(); break; case 2: func_040d(); break; } // end switch } // end func void func_040d() { int locals[22]; say( "Then ye, like him, are my sworn foe! Get away from me, else I shall call my guards!" ); locals[1] = 15; // "As thou dost wish. Good riddance!" locals[2] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); if ( locals[22] == 1 ) { func_00d1(); } // end if } // end func void func_0441() { int locals[22]; say( "Hmmm. Very well. Did ye speak wi' him?" ); locals[1] = 17; // "Yes, I did." locals[2] = 18; // "No. Should I?" locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0489(); break; case 2: func_04d1(); break; } // end switch } // end func void func_0489() { int locals[22]; say( "Poofy, ain't he? Not a proper Goblin at all!" ); locals[1] = 20; // "I agree, certainly. Yet what of thee?" locals[2] = 21; // "I wouldn't know. Canst help me now?" locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_05e7(); break; case 2: func_066f(); break; } // end switch } // end func void func_04d1() { int locals[22]; say( "Don't bother! He's a complete waste of time. Ye're fortunate ye came to me first." ); locals[1] = 23; // "Indeed I am. Canst thou tell me of this Abyss?" locals[2] = 24; // "How lucky I am. Dost know of a girl kidnapped by a Troll?" locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_06e8(); break; case 2: func_0519(); break; } // end switch } // end func void func_0519() { int locals[43]; say( "I know nothing of no girl! I've got problems of me own." ); private[3] = 0; locals[22] = private[5]; locals[1] = 26; // "Such as?" locals[23] = 1; locals[2] = 27; // "I am sure thou hast. I shall be going." locals[24] = private[4]; locals[3] = 28; // "Well, canst thou tell me aught of the Abyss?" locals[4] = 0; // "" locals[43] = babl_fmenu( 0, &locals[1], &locals[22] ); switch ( locals[43] ) { case 26: func_0597(); break; case 27: func_00c2(); break; case 28: func_06e8(); break; } // end switch } // end func void func_0597() { int locals[22]; private[5] = 0; say( "My enemies are legion. Even the vermin here are troublesome. A great she-spider, known as Navrey Night-eyes, threatens my folk. Nor is she my only problem, though she is enough. Her web, ye know, be strong as iron, and does not burn. A Goblin caught in it will stay 'till he rots!" ); locals[1] = 30; // "Terrible!" locals[2] = 31; // "Perhaps I can help." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0735(); break; case 2: say( "Do not be a fool! None can slay the dread Navrey! Now, ye came here for something." ); func_066f(); break; } // end switch } // end func void func_05e7() { int locals[43]; say( "I be Ketchaval, the mighty leader of the last holding of the noble Goblins, the Gray tribe.\n" " Years ago, when we were lured here by that sweet-talking fool, Cabirus, we noble Grays brought with us our servants, the lowly and ignorant Green Goblins, to care for us in our new homes.\m" ); say( "We later granted them their freedom, and equal citizenship, though all knew we did them more honor than they were worth. And see how they rewarded us! They split off when Cabirus' "civilization" fell, and have opposed us ever since.\n" " Only my leadership has kept us together in the face of such opposition." ); locals[22] = private[5]; locals[1] = 35; // "Such a job must have many cares." locals[23] = 1; locals[2] = 36; // "Have the Greens no redeeming value?" locals[24] = 1; locals[3] = 37; // "I am glad for thee. Farewell." locals[4] = 0; // "" locals[43] = babl_fmenu( 0, &locals[1], &locals[22] ); switch ( locals[43] ) { case 35: func_0597(); break; case 36: func_0662(); break; case 37: func_00e0(); break; } // end switch } // end func void func_0662() { say( "None whatever! They are distrusting, vindictive, and calculating. But enough of them!" ); func_066f(); } // end func void func_066f() { int locals[43]; say( "What d'ye want?" ); locals[22] = private[3]; locals[1] = 40; // "I need to find a girl." locals[23] = private[4]; locals[2] = 41; // "I seek knowledge of Cabirus." locals[24] = 1; locals[3] = 42; // "Thou hast helped me already. I thank thee. I must be going." locals[4] = 0; // "" locals[43] = babl_fmenu( 0, &locals[1], &locals[22] ); switch ( locals[43] ) { case 40: func_0519(); break; case 41: func_06e8(); break; case 42: func_00c2(); break; } // end switch } // end func void func_06e8() { int locals[22]; say( "A human fool named Cabirus convinced many of our people to come here and colonize this accursed place. When his dreams were shown to be mere folly, he killed himself -- by taking poison -- and left us to our fates." ); private[4] = 0; locals[1] = 44; // "Tragic!" locals[2] = 45; // "Ah, well, I must be going now. Goodbye!" locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0735(); break; case 2: func_00c2(); break; } // end switch } // end func void func_0735() { int locals[43]; say( "Indeed, 'tis not fair! Still, we must persevere. Was there anything else?" ); locals[22] = 1; locals[1] = 47; // "No. I thank thee. Farewell." locals[23] = private[3]; locals[2] = 48; // "I need to find a girl." locals[24] = private[4]; locals[3] = 49; // "I seek knowledge of Cabirus." locals[4] = 0; // "" locals[43] = babl_fmenu( 0, &locals[1], &locals[22] ); switch ( locals[43] ) { case 47: func_00e0(); break; case 48: func_0519(); break; case 49: func_06e8(); break; } // end switch } // end func void func_07ae() { int locals[24]; if ( !private[3] && !private[4] ) { say( "Only so much of my time canst thou waste! Hast thou no one else to bother?" ); func_00e0(); } // end if locals[1] = npc_attitude + 1; if ( locals[1] > 3 ) { locals[1] = 3; } // end if locals[2] = locals[1]; if ( 1 == locals[2] ) { say( "Ye again! Begone before I call my guards!" ); } else { if ( 2 == locals[2] ) { say( "Again ye bother me? What be it THIS time?" ); } else { if ( 3 == locals[2] ) { say( ""Tis @GS8! What may I do for ye, my friend?" ); } // end if } // end if } // end if locals[3] = 54; // "Pardon, I must be going." locals[4] = 55; // "I need to ask thee a question." locals[5] = 56; // "I need thy help." locals[6] = 0; // "" locals[24] = babl_menu( 0, &locals[3] ); switch ( locals[24] ) { case 1: func_00e0(); break; case 2: func_066f(); break; case 3: func_066f(); break; } // end switch } // end func void func_085b() { int locals[22]; say( "Loutish oaf! What brings thee here without the consent of my bride?" ); locals[1] = 58; // "I knew not that I needed thy wife's permission." locals[2] = 60; // "I see that one of us needs thy wife's leave to talk. Farewell." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: say( "Well, ye know now! Good-bye!" ); func_00c2(); break; case 2: func_00c2(); break; } // end switch } // end func