Ultima Underworld/technical/conversations/211

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 #211 // string block 0x0ed3 (3795), name Dantes // // 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[22]; if ( private[0] == 1 ) { func_0420(); } else { private[2] = 1; private[3] = 1; say( "Greetings, friend. I am Dantes." ); locals[1] = 2; // "Well met, Dantes. How can I help thee?" locals[2] = 3; // "Greetings, Dantes. How wert thou captured?" locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_050d(); break; case 2: func_037c(); } // end if break; } // end switch } // end func void func_02fb() { int locals[22]; say( "I thank thee. Perhaps I can help thee. Thou doth seem to be in good health. Thou shouldst be able to make it over the lava." ); locals[1] = 5; // "What lava?" locals[2] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); if ( locals[22] == 1 ) { func_032f(); } // end if } // end func void func_032f() { int locals[22]; private[3] = 0; say( "I dug myself an escape route from my cell, using only my belt-buckle. Unfortunately, the cell looks out on a lava-filled cavern, and I cannot make the leap. I have a gamy leg, as thou can see." ); locals[1] = 7; // "Why didst thou come down here to begin with?" locals[2] = 8; // "Perhaps I can carry thee." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_037c(); break; case 2: func_06d2(); break; } // end switch } // end func void func_037c() { int locals[43]; say( "I was a fool! Rumor had it there were mysterious tombs down here, filled with fabulous treasures. I was searching for these when Tyball's lackeys got me..." ); locals[22] = private[2]; locals[1] = 10; // "Who is Tyball?" locals[23] = 1; locals[2] = 11; // "Where are these tombs?" locals[3] = 0; // "" locals[43] = babl_fmenu( 0, &locals[1], &locals[22] ); switch ( locals[43] ) { case 10: func_060d(); break; case 11: func_03d8(); break; } // end switch } // end func void func_03d8() { int locals[22]; say( "I know naught but rumors. Some say those who find the tombs become permanent guests. It seems true in my case, at least. But the treasure, the treasure is worth the risk..." ); locals[1] = 13; // "That much treasure?" locals[2] = 14; // "I thank thee. Farewell." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_04b1(); break; case 2: func_00e0(); break; } // end switch } // end func void func_0420() { int locals[25]; if ( private[2] ) { say( "Ah! Tyball has not slain thee yet! Thou art lucky!" ); locals[2] = 16; // "What canst thou tell me of this Tyball?" locals[3] = 17; // "Yes, I am. Farewell, now." locals[4] = 0; // "" locals[23] = babl_menu( 0, &locals[2] ); switch ( locals[23] ) { case 1: func_060d(); break; case 2: func_00e0(); } // end if } else { break; } // end switch locals[1] = random( 1, &locals[24] ); locals[24] = 3; locals[25] = locals[1]; if ( 1 == locals[25] ) { say( "I'm done for! Thou... go on without me... I'll be all right. Go on, get!" ); } else { if ( 2 == locals[25] ) { say( "I'll never make it! Use the exit, and go!" ); } else { if ( 3 == locals[25] ) { say( "Farewell, friend! I'm a goner. Get out while thou canst!" ); } // end if } // end if } // end if func_00e0(); } // end func void func_04b1() { int locals[43]; say( "Oh, that much and more! Why, I've heard tell of a knight who returned with a magical golden suit of armor. But alas, his mind was not the same, and one day he dove head-first into a pool of lava...\n" " In any event, thou must take care if thou doth enter the tombs. First, though, use my escape route, and take care to jump over the rivers of lava." ); locals[22] = private[3]; locals[1] = 22; // "What escape route?" locals[23] = 1; locals[2] = 23; // "Indeed. My thanks for thy advice. Farewell." locals[3] = 0; // "" locals[43] = babl_fmenu( 0, &locals[1], &locals[22] ); switch ( locals[43] ) { case 22: func_032f(); break; case 23: func_00e0(); break; } // end switch } // end func void func_050d() { int locals[22]; say( "Well, I wouldn't say no to something to eat." ); locals[1] = 25; // "Certainly. Have some of my food." locals[2] = 26; // "I'm sorry, I haven't anything to eat. How about some water?" locals[3] = 27; // "I'm sorry to say I haven't any food or water." locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_071a(); break; case 2: func_0569(); break; case 3: func_05b1(); break; } // end switch } // end func void func_0569() { int locals[22]; say( "That's plenty good for me! I'm not long for this place, anyway." ); locals[1] = 29; // "Here thou art." locals[2] = 30; // "I'm sorry to say I haven't any food or water." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_07f3(); break; case 2: func_05b1(); break; } // end switch } // end func void func_05b1() { int locals[43]; say( "That is indeed a pity. Thou wilt die soon without provisions." ); locals[22] = private[3]; locals[1] = 32; // "Indeed. Surely someone of thy wisdom can help me?" locals[23] = 1; locals[2] = 33; // "An unpleasant observation, from one who is himself trapped." locals[3] = 0; // "" locals[43] = babl_fmenu( 0, &locals[1], &locals[22] ); switch ( locals[43] ) { case 32: func_032f(); break; case 33: func_037c(); break; } // end switch } // end func void func_060d() { int locals[22]; private[2] = 0; say( "I cannot believe thou hast not heard of him! He is the most dangerous man in these parts, a sorcerer with powers that dwarf those of ordinary magicians the way the sun dwarfs a candle." ); locals[1] = 35; // "He is probably the one I'm after, then." locals[2] = 36; // "Oh, that Tyball. Do not worry about him." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_065a(); break; case 2: func_065a(); break; } // end switch } // end func void func_065a() { int locals[43]; say( "Thou must be crazy! This Tyball is dangerous, I tell thee. Who dost thou think captured all these poor souls?" ); locals[22] = 1; locals[1] = 38; // "Enough of that! He is my quarry. What else canst thou tell me?" locals[23] = private[3]; locals[2] = 39; // "As thou sayst. In any event, I must be going. How can I leave?" locals[24] = 1; locals[3] = 40; // "I am confident I can defeat him. Now I must be off." locals[4] = 0; // "" locals[43] = babl_fmenu( 0, &locals[1], &locals[22] ); switch ( locals[43] ) { case 38: func_03d8(); break; case 39: func_032f(); break; case 40: func_00e0(); break; } // end switch } // end func void func_06d2() { int locals[22]; say( "Nay, it is impossible! I am done for in any event. Get out there and save thyself!" ); locals[1] = 42; // "Very well. I shall return for thee if I can." locals[2] = 43; // "As thou wish. Good luck." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_00c2(); break; case 2: func_00e0(); break; } // end switch } // end func void func_071a() { int locals[40]; locals[16] = show_inv( 2, &locals[6], &locals[1] ); locals[18] = 0; while ( locals[16] != 0 ) { locals[17] = locals[0]; if ( ((((((locals[17] == 176 || locals[17] == 177) || locals[17] == 178) || locals[17] == 179) || locals[17] == 180) || locals[17] == 181) || locals[17] == 182) ) { locals[18] = locals[18] + 1; locals[10] = locals[5]; } // end if locals[16] = locals[16] - 1; } // while if ( locals[18] > 0 ) { give_to_npc( 2, &locals[11], &locals[18] ); func_02fb(); } else { say( "Where is the food thou didst promise?" ); locals[19] = 45; // "I'm sorry, here it is." locals[20] = 46; // "I haven't any food." locals[21] = 0; // "" locals[40] = babl_menu( 0, &locals[19] ); switch ( locals[40] ) { case 1: func_071a(); break; case 2: func_05b1(); } // end if break; } // end switch } // end func void func_07f3() { int locals[40]; locals[16] = show_inv( 2, &locals[6], &locals[1] ); locals[18] = 0; while ( locals[16] != 0 ) { locals[17] = locals[0]; if ( locals[17] == 189 ) { locals[18] = locals[18] + 1; locals[10] = locals[5]; } // end if locals[16] = locals[16] - 1; } // while if ( locals[18] > 1 ) { give_to_npc( 2, &locals[11], &locals[18] ); func_02fb(); } else { say( "Where is the water thou didst promise?" ); locals[19] = 48; // "I'm sorry, here it is." locals[20] = 49; // "I haven't any water." locals[21] = 0; // "" locals[40] = babl_menu( 0, &locals[19] ); switch ( locals[40] ) { case 1: func_07f3(); break; case 2: func_05b1(); } // end if break; } // end switch } // end func void func_08a2() { int locals[44]; setup_to_barter( 0 ); while ( !private[1] ) { locals[1] = 50; // "I make thee this offer." locals[2] = 51; // "I demand thou givest me these items." locals[3] = 52; // "Excuse me, I must think about this deal." locals[4] = 53; // "I do not wish to barter any further." locals[5] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0953(); break; case 2: func_09ad(); break; case 3: do_judgement( 0 ); break; case 4: do_decline( 0 ); private[1] = 1; break; } // end switch } // while locals[23] = 54; // "Farewell." locals[24] = 0; // "" locals[44] = babl_menu( 0, &locals[23] ); if ( locals[44] == 1 ) { private[1] = 1; } // end if } // end func void func_0953() { int locals[15]; locals[0] = -1; locals[6] = -1; locals[11] = 55; // "I accept thy offer." locals[12] = 56; // "No, I do not like this deal." locals[13] = 57; // "Dost thou take me for a fool?" locals[14] = 58; // "I am weary of this haggling." locals[15] = 59; // "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_09ad() { int locals[24]; say( "Dost thou intend to rob me?" ); locals[1] = 61; // "Yes, I must." locals[2] = 62; // "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] = 63; // "If thou dost insist, thou canst have them." locals[24] = 64; // "No! Thou shalt not take them!" if ( do_demand( 2, &locals[24], &locals[23] ) ) { private[1] = 1; } else { func_008b(); } // end if } // end func