Ultima Underworld/technical/conversations/112
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 #112 // string block 0x0e70 (3696), name bandit // // 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[44]; if ( npc_attitude >= 2 ) { func_0484(); } // end if say( "HALT! Who approaches?" ); locals[1] = 2; // "It is merely I, @GS8." locals[2] = 3; // "Why dost thou want to know?" locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0330(); break; case 2: break; } // end switch say( "I will do the questioning here. Answer this time, knave, or I will run thee through!" ); locals[23] = 5; // "My name is @GS8." locals[24] = 6; // "I do not wish to continue with this. Goodbye." locals[25] = 0; // "" locals[44] = babl_menu( 0, &locals[23] ); switch ( locals[44] ) { case 1: func_0330(); break; case 2: break; } // end switch say( "Thou wilt learn to answer thy betters!" ); func_008b(); } // end func void func_0330() { int locals[45]; say( "What dost thou seek, @GS8?" ); locals[1] = 9; // "I seek gold and wealth." locals[2] = 11; // "I seek the Baron's daughter." locals[3] = 13; // "I seek information and trade." locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: say( "As I seek thine!" ); func_008b(); break; case 2: say( "Of this I know nothing. " ); break; case 3: say( "I have neither. " ); break; } // end switch say( "Begone with thee!" ); locals[23] = 16; // "Fare thee well, kind sir." locals[24] = 17; // "Wouldst thou wish to exchange items?" locals[25] = 18; // "Thou shouldst have better manners!" locals[26] = 0; // "" locals[44] = babl_menu( 0, &locals[23] ); switch ( locals[44] ) { case 1: locals[45] = npc_attitude + 1; func_00b1( &locals[45] ); break; case 2: break; case 3: say( "I will teach thee better manners!" ); func_008b(); break; } // end switch if ( npc_attitude < 3 ) { say( "I do not. Now leave before I run thee through!" ); func_040c(); } else { say( "Perhaps I have something here for thee." ); func_059a(); func_00b1( 21 ); } // end if } // end func void func_040c() { int locals[26]; locals[1] = 22; // "Sorry to have irked thee so. I shall take my leave now." locals[2] = 23; // "I shall not be talked to that way - prepare for battle!" locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: break; case 2: func_008b(); break; } // end switch if ( npc_attitude == 1 ) { locals[23] = 2; func_00b1( &locals[23] ); } // end if locals[24] = 113; locals[25] = 3; set_attitude( 2, &locals[25], &locals[24] ); locals[26] = 3; func_00b1( &locals[26] ); } // end func void func_0484() { int locals[50]; say( "@GS8, what dost wish now?" ); locals[1] = 25; // "Merely to exchange items and information." locals[2] = 26; // "Excuse me, I must leave now." locals[3] = 27; // "Why must thou be so hostile?" locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: break; case 2: locals[23] = npc_attitude - 1; func_00b1( &locals[23] ); break; case 3: say( "I'll teach thee about hostility!" ); func_008b(); break; } // end switch if ( npc_attitude < 3 ) { say( "I have nothing for thee now. Leave!" ); locals[24] = 30; // "Don't be so hostile. I'm leaving." locals[25] = 31; // "Goodbye." locals[26] = 32; // "Sorry to have bothered thee. Farewell." locals[27] = 33; // "Thy attitude is tiresome. I'll teach thee some manners." locals[28] = 0; // "" locals[45] = babl_menu( 0, &locals[24] ); switch ( locals[45] ) { case 1: locals[46] = 1; func_00b1( &locals[46] ); break; case 2: locals[47] = 2; func_00b1( &locals[47] ); break; case 3: locals[48] = 113; locals[49] = 3; set_attitude( 2, &locals[49], &locals[48] ); locals[50] = 3; func_00b1( &locals[50] ); break; case 4: func_008b(); } // end if break; } // end switch say( "Perhaps I have something thou wilt be interested in." ); func_059a(); func_00b1( 21 ); } // end func void func_059a() { 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_064b(); break; case 2: func_06a5(); 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_064b() { int locals[15]; 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." locals[15] = 44; // "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_06a5() { int locals[24]; say( "Dost thou intend to rob me?" ); locals[1] = 46; // "Yes, I must." locals[2] = 47; // "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] = 48; // "If thou dost insist, thou canst have them." locals[24] = 49; // "No! Thou shalt not take them!" if ( do_demand( 2, &locals[24], &locals[23] ) ) { private[1] = 1; } else { func_008b(); } // end if } // end func