Ultima Underworld/technical/conversations/26

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 #26 // string block 0x0e1a (3610), name Celaven // // 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_0293(); 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_goal = 6; func_0012(); } // end func void func_0072() { npc_goal = 1; func_0012(); } // end func void func_0081() { npc_gtarg = 1; npc_goal = 5; npc_attitude = 1; func_0012(); } // end func void func_009a() { npc_attitude = 6; } // end func void func_00a7() { npc_attitude = param1[0]play_hunger; func_0012(); } // end func void func_00b8() { npc_attitude = 2; func_0012(); } // end func void func_00c7() { npc_attitude = 1; func_0012(); } // end func void func_00d6() { func_0012(); } // end func void func_00e0() { param1[1] = game_days; param1[2] = game_mins; } // end func void func_00fc() { 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_0185() { 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_0239() { 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_0293() { int locals[25]; if ( private[0] == 1 ) { func_04cf(); } else { locals[1] = sex( 2, &locals[3], &locals[2] ); locals[2] = 1; locals[3] = 2; say( "Good day to thee, my young @SS1. I am Celaven, and I seek a certain wand. Hast thou seen it?" ); private[2] = 0; private[3] = 0; locals[4] = 4; // "What sort of wand was this?" locals[5] = 5; // "Yes, I believe I have it here." locals[6] = 6; // "I have seen no wands." locals[7] = 0; // "" locals[25] = babl_menu( 0, &locals[4] ); switch ( locals[25] ) { case 1: func_032c(); break; case 2: func_042b(); break; case 3: if ( private[2] == 1 ) { func_0380(); } else { func_03c8(); } // end if } // end if break; } // end switch } // end func void func_032c() { int locals[22]; say( "It had the property of casting fireballs. One of my better works, actually. I particularly like the way the fireballs look. Not enough mages take pride in the little details like that. Then I loaned it to a friend of\n" " mine, and I think she must have blown herself up with it. A pity, thou knowst, but there thou art. Perhaps I should have made sure she knew which end to hold. At any rate, it has been missing since. Hast thou seen it?" ); locals[1] = 8; // "Yes, I believe this is it." locals[2] = 9; // "I have seen no such wand." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_042b(); break; case 2: if ( private[2] == 1 ) { func_0380(); } else { func_03c8(); } // end if break; } // end switch } // end func void func_0380() { int locals[22]; say( "A pity. I felt sure an explorer such as thyself might have run across it. It could be dangerous in the wrong hands, thou knowest. Art certain thou hast seen it not?" ); locals[1] = 11; // "Well, come to think of it, I do have a wand here. Could this be thine?" locals[2] = 12; // "Absolutely. I would remember such an item." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_042b(); break; case 2: func_00d6(); break; } // end switch } // end func void func_03c8() { int locals[25]; locals[1] = sex( 2, &locals[3], &locals[2] ); locals[2] = 13; locals[3] = 14; say( "Good day to thee then, my young @SS1. If thou shouldst encounter my wand, I'll gladly reward thee for its return." ); locals[4] = 16; // "Of course." locals[5] = 17; // "We shall see." locals[6] = 0; // "" locals[25] = babl_menu( 0, &locals[4] ); switch ( locals[25] ) { case 1: func_00d6(); break; case 2: func_00b8(); break; } // end switch } // end func void func_042b() { int locals[22]; say( "Ah, at last! May I examine it please?" ); locals[1] = 19; // "Certainly, here you are." locals[2] = 20; // "Is it yours, or isn't it?" locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0473(); break; case 2: func_053c(); break; } // end switch } // end func void func_0473() { int locals[22]; say( "Ah. Now this IS nice. Very nice indeed. 'Tis not my mine, though. Unless I'm mistaken, this is the work of Corey Confundo, a most excellent mage indeed. Thou shouldst consider thyself lucky to have such a tool. May it serve thee well." ); locals[1] = 22; // "Will thou not accept it in place of the one thou lost?" locals[2] = 23; // "Thank thee kindly. I hope thou findest thy wand." locals[3] = 24; // "Goodbye." locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0584(); break; case 2: func_00d6(); break; case 3: func_00b8(); break; } // end switch } // end func void func_04cf() { int locals[22]; say( "Ah, we meet again. Hast news of my wand?" ); private[2] = 0; locals[1] = 26; // "What sort of wand was this again?" locals[2] = 27; // "Is this it?" locals[3] = 28; // "I have seen it not." locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_032c(); break; case 2: func_042b(); break; case 3: if ( private[2] == 1 ) { func_0380(); } else { func_03c8(); } // end if break; } // end switch } // end func void func_053c() { int locals[22]; say( "Well, thou need not be so snappy! Just hold it up there, that's it. No, I'm afraid mine is much nicer than that. Should expect that one might blow off thine hand. Well, if thou wilt excuse me, I must be going." ); locals[1] = 30; // "Fare thee well. I hope thou findest thy wand." locals[2] = 31; // "Goodbye." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_00d6(); break; case 2: func_00b8(); break; } // end switch } // end func void func_0584() { int locals[22]; say( "Nay, thou art too generous. My interest is not in any wand, but the one I myself created. Still, such generosity must be rewarded. Thou might not know it, but the wand thou hast posseses another setting. . . There. I think thou shalt find it all the better now. Good day to thee." ); locals[1] = 33; // "Thank thee kindly. I hope thou findest thy wand." locals[2] = 34; // "Goodbye." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_00d6(); break; case 2: func_00b8(); break; } // end switch } // end func void func_05cc() { int locals[44]; setup_to_barter( 0 ); while ( !private[1] ) { locals[1] = 35; // "I make thee this offer." locals[2] = 36; // "I demand thou givest me these items." locals[3] = 37; // "Excuse me, I must think about this deal." locals[4] = 38; // "I do not wish to barter any further." locals[5] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_067d(); break; case 2: func_06ce(); break; case 3: do_judgement( 0 ); break; case 4: do_decline( 0 ); private[1] = 1; break; } // end switch } // while locals[23] = 39; // "Farewell." locals[24] = 0; // "" locals[44] = babl_menu( 0, &locals[23] ); if ( locals[44] == 1 ) { private[1] = 1; } // end if } // end func void func_067d() { int locals[14]; locals[0] = -1; locals[6] = -1; locals[11] = 40; // "I accept thy offer." locals[12] = 41; // "No, I do not like this deal." locals[13] = 42; // "Dost thou take me for a fool?" locals[14] = 43; // "I am weary of this haggling." if ( do_offer( 6, &locals[14], &locals[13], &locals[12], &locals[11], &locals[6], &locals[1] ) ) { private[1] = 1; } // end if } // end func void func_06ce() { int locals[24]; say( "Dost thou intend to rob me?" ); locals[1] = 45; // "Yes, I must." locals[2] = 46; // "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] = 47; // "If thou dost insist, thou canst have them." locals[24] = 48; // "No! Thou shalt not take them!" if ( do_demand( 2, &locals[24], &locals[23] ) ) { private[1] = 1; } else { func_0081(); } // end if } // end func