Ultima Underworld/technical/conversations/216
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 #216 // string block 0x0ed8 (3800), name guard // // 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[5]; private[5] = x_traps( 2, &locals[2], &locals[1] ); locals[1] = 50; locals[2] = 10001; private[7] = x_traps( 2, &locals[4], &locals[3] ); locals[3] = 51; locals[4] = 10001; if ( private[0] == 0 ) { private[2] = 0; private[3] = 0; private[4] = 0; private[6] = 0; } // end if if ( private[7] ) { func_0684(); } // end if if ( private[0] && private[6] ) { func_056f(); } else { if ( private[5] ) { if ( private[8] ) { locals[5] = 1; func_0328( &locals[5] ); } else { func_0384(); } // end if } else { func_066e(); } // end if } // end if } // end func void func_0328() { int locals[23]; private[6] = 1; if ( param1[0]play_hunger ) { say( "Ho ho, just like big rat in trap. What you want?" ); } // end if locals[1] = 2; // "Open this portcullis immediately!" locals[2] = 3; // "I need no help from you!" locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_03ff(); break; case 2: locals[23] = 1; func_00b1( &locals[23] ); break; } // end switch } // end func void func_0384() { int locals[24]; private[6] = 1; private[8] = 1; say( "Ho ho, you just like big dumb rat in trap now. Ho Ho." ); locals[1] = 5; // "Open this portcullis immediately!" locals[2] = 6; // "Leave me be, everything is under control." locals[3] = 7; // "What have you done?" locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_03ff(); break; case 2: locals[23] = 1; func_00b1( &locals[23] ); break; case 3: say( "Ho ho, I lock you in jail, silly human. Now what you want." ); locals[24] = 0; func_0328( &locals[24] ); break; } // end switch } // end func void func_03ff() { int locals[22]; private[4] = 1; say( "Yeah? Why I do that? What in it for me?" ); locals[1] = 10; // "What do you want?" locals[2] = 11; // "Here, take this." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_044c(); break; case 2: func_044c(); break; } // end switch } // end func void func_044c() { int locals[61]; locals[14] = 0; locals[12] = 0; label_045b:; label_045b:; locals[11] = show_inv( 2, &locals[6], &locals[1] ); if ( locals[11] > 0 ) { locals[13] = 1; while ( locals[13] <= locals[11] ) { locals[12] = locals[12] + identify_inv( 4, &locals[17], &locals[15], &locals[16], &locals[5] ); locals[16] = 0; locals[17] = 0; locals[13] = locals[13] + 1; } // while give_to_npc( 2, &locals[6], &locals[11] ); if ( locals[12] > 20 ) { func_063c(); } else { say( "Not enough... More!" ); private[2] = 1; locals[18] = 13; // "How about this, then?" locals[19] = 14; // "That's all I have." locals[20] = 0; // "" locals[39] = babl_menu( 0, &locals[18] ); switch ( locals[39] ) { case 1: goto label_045b; break; case 2: func_062f(); } // end if } else { } // end if break; } // end switch if ( locals[14] > 5 ) { say( "Play games, huh? You rot then." ); func_00d1(); } else { say( "What you got, eh? Show me, go on." ); locals[40] = 17; // "Ok, how about this?" locals[41] = 18; // "No, you'll get nothing from me." locals[42] = 0; // "" locals[61] = babl_menu( 0, &locals[40] ); switch ( locals[61] ) { case 1: locals[14] = locals[14] + 1; goto label_045b; break; case 2: func_062f(); } // end if break; } // end switch return; } // end func void func_056f() { int locals[45]; if ( private[3] == 1 ) { say( "What you want now? I open gate... Inner gate, ho ho." ); func_00d1(); } else { if ( private[4] ) { private[2] = 1; say( "So, you give more stuff, or what?" ); locals[1] = 21; // "Yes." locals[2] = 22; // "No." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_044c(); break; case 2: func_062f(); } // end if } else { break; } // end switch say( "Ho ho, you want open door now?" ); locals[23] = 24; // "Yes, open it immediately!" locals[24] = 25; // "Yes, please do." locals[25] = 26; // "I will deal with it myself." locals[26] = 0; // "" locals[44] = babl_menu( 0, &locals[23] ); switch ( locals[44] ) { case 1: func_03ff(); break; case 2: func_03ff(); break; case 3: locals[45] = 1; func_00b1( &locals[45] ); } // end if break; } // end switch } // end func void func_062f() { say( "Hmmph... You stay then." ); func_00e0(); } // end func void func_063c() { int locals[3]; say( "Ho ho... I open gate, okay." ); locals[1] = 21; locals[2] = 56; locals[3] = 0; gronk_door( 3, &locals[3], &locals[2], &locals[1] ); private[3] = 1; func_00d1(); } // end func void func_066e() { int locals[1]; say( "I no want talk to you now, human. You talk to goblins, maybe they have better reason." ); locals[1] = 1; func_00b1( &locals[1] ); } // end func void func_0684() { say( "You! You escape from prison! Bad human, bad human!" ); func_008b(); } // end func void func_0691() { int locals[44]; setup_to_barter( 0 ); while ( !private[1] ) { locals[1] = 31; // "I make thee this offer." locals[2] = 32; // "I demand thou givest me these items." locals[3] = 33; // "Excuse me, I must think about this deal." locals[4] = 34; // "I do not wish to barter any further." locals[5] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0742(); break; case 2: func_079c(); break; case 3: do_judgement( 0 ); break; case 4: do_decline( 0 ); private[1] = 1; break; } // end switch } // while locals[23] = 35; // "Farewell." locals[24] = 0; // "" locals[44] = babl_menu( 0, &locals[23] ); if ( locals[44] == 1 ) { private[1] = 1; } // end if } // end func void func_0742() { int locals[15]; locals[0] = -1; locals[6] = -1; locals[11] = 36; // "I accept thy offer." locals[12] = 37; // "No, I do not like this deal." locals[13] = 38; // "Dost thou take me for a fool?" locals[14] = 39; // "I am weary of this haggling." locals[15] = 40; // "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_079c() { int locals[24]; say( "Dost thou intend to rob me?" ); locals[1] = 42; // "Yes, I must." locals[2] = 43; // "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] = 44; // "If thou dost insist, thou canst have them." locals[24] = 45; // "No! Thou shalt not take them!" if ( do_demand( 2, &locals[24], &locals[23] ) ) { private[1] = 1; } else { func_008b(); } // end if } // end func