Ultima Underworld/technical/conversations/288
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 #288 // string block 0x0f20 (3872), critter #32, troll // // 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] ) { say( "You come back? Why?" ); } else { say( "What you doing here?" ); } // end if locals[1] = 3; // "Canst thou tell me any news?" locals[2] = 4; // "I am searching for trolls to kill." locals[3] = 5; // "I am merely exploring." locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0359(); break; case 2: func_0436(); break; case 3: func_0303(); break; } // end switch } // end func void func_0303() { int locals[23]; if ( func_0020() ) { say( "We trade?" ); locals[1] = 7; // "Yes." locals[2] = 8; // "No." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_04d5(); break; case 2: locals[23] = 2; func_00b1( &locals[23] ); } // end if break; } // end switch } // end func void func_0359() { int locals[10]; locals[8] = 1; locals[9] = 1; while ( locals[8] <= 6 ) { if ( private[2][0] == 0 ) { locals[0] = locals[8]; locals[9] = locals[9] + 1; } // end if locals[8] = locals[8] + 1; } // while if ( locals[9] == 0 ) { say( "I have no new news for you." ); locals[8] = 1; } // end if if ( locals[8] <= 6 ) { private[2][0] = 0; } else { } // end if locals[8] = random( 1, &locals[9] ); locals[9] = locals[0]; private[2][0] = 1; locals[10] = locals[9]; if ( 1 == locals[10] ) { say( "Me hear one Troll got caught by Wizard, made slave." ); } else { if ( 2 == locals[10] ) { say( "Me hear somebody killing Trolls! Me catch, me eat!" ); } else { if ( 3 == locals[10] ) { say( "Sethar and his friend live near the big pit." ); } else { if ( 4 == locals[10] ) { say( "Sneak snuck on Sethar, but he tossed him in pit." ); } else { if ( 5 == locals[10] ) { say( "One Knight real mean, he live up north." ); } else { if ( 6 == locals[10] ) { say( "Ghouls live below us. They disgusting." ); } // end if } // end if } // end if } // end if } // end if } // end if } // end func void func_0436() { int locals[23]; say( "You food, puny human?" ); locals[1] = 17; // "Yes, come and get it..." locals[2] = 18; // "No, let's not fight." locals[3] = 19; // "Ha! Try it!" locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_008b(); break; case 2: break; case 3: func_049e(); break; } // end switch say( "You confuse me, first want fight and then not want fight." ); locals[23] = 1; func_00b1( &locals[23] ); } // end func void func_049e() { int locals[1]; if ( play_level + play_drawn > npc_level + 5 ) { func_0063(); } // end if if ( play_level + play_drawn < npc_level - 1 ) { func_008b(); } // end if locals[1] = 1; func_00b1( &locals[1] ); } // end func void func_04d5() { int locals[44]; setup_to_barter( 0 ); while ( !private[1] ) { locals[1] = 21; // "I make thee this offer." locals[2] = 22; // "I demand thou givest me these items." locals[3] = 23; // "Excuse me, I must think about this deal." locals[4] = 24; // "I do not wish to barter any further." locals[5] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0586(); break; case 2: func_05e0(); break; case 3: do_judgement( 0 ); break; case 4: do_decline( 0 ); private[1] = 1; break; } // end switch } // while locals[23] = 25; // "Farewell." locals[24] = 0; // "" locals[44] = babl_menu( 0, &locals[23] ); if ( locals[44] == 1 ) { private[1] = 1; } // end if } // end func void func_0586() { int locals[15]; locals[0] = -1; locals[6] = -1; locals[11] = 26; // "I accept thy offer." locals[12] = 27; // "No, I do not like this deal." locals[13] = 28; // "Dost thou take me for a fool?" locals[14] = 29; // "I am weary of this haggling." locals[15] = 30; // "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_05e0() { int locals[24]; say( "Dost thou intend to rob me?" ); locals[1] = 32; // "Yes, I must." locals[2] = 33; // "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] = 34; // "If thou dost insist, thou canst have them." locals[24] = 35; // "No! Thou shalt not take them!" if ( do_demand( 2, &locals[24], &locals[23] ) ) { private[1] = 1; } else { func_008b(); } // end if } // end func