Ultima Underworld/technical/conversations/138

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 #138 // string block 0x0e8a (3722), name Derek // // 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[23]; private[2] = get_quest( 1, &locals[1] ); locals[1] = 32; if ( private[0] ) { if ( private[3] ) { func_05ad(); } else { func_0565(); } // end if } // end if say( "I am Derek, a knight and a worker. Who art thou?" ); locals[2] = 2; // "My name is @GS8. I am on a quest." locals[3] = 3; // "@GS8, an aspiring knight." locals[4] = 0; // "" locals[23] = babl_menu( 0, &locals[2] ); switch ( locals[23] ) { case 1: func_0307(); break; case 2: func_0307(); break; } // end switch } // end func void func_0307() { int locals[22]; say( "Ah, the adventurous life is not for me. I am content to remain here and work at my craft." ); locals[1] = 5; // "Perhaps thou art simply a coward." locals[2] = 6; // "What is thy craft?" locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_034f(); break; case 2: func_03b4(); break; } // end switch } // end func void func_034f() { int locals[23]; say( "Despite thy words, many feel that it is more important to contribute to society by one's work than by one's sword." ); locals[1] = 8; // "How dost thou contribute to society, then?" locals[2] = 9; // "Perhaps thou art correct. What is thy work?" locals[3] = 10; // "I have no time for those who are not as valorous as I." locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_03b4(); break; case 2: func_03b4(); break; case 3: locals[23] = 1; func_00b1( &locals[23] ); break; } // end switch } // end func void func_03b4() { int locals[22]; say( "I carve gems and work metals. It is hard and tedious work, especially with poor tools, but I am content with it nonetheless." ); locals[1] = 12; // "I wish I could help thee with thy work." locals[2] = 13; // "Would this item help thee?" locals[3] = 14; // "Not all avocations are equally exciting." locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0410(); break; case 2: func_045e(); break; case 3: func_0410(); break; } // end switch } // end func void func_0410() { int locals[22]; say( "Well, if thou hast anything that would help me in my work, I would appreciate it. Perhaps thou hast collected such an item in thy travels." ); while ( 1 ) { locals[1] = 16; // "Will this help?" locals[2] = 17; // "If I do find such an item, I shall let thee know." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_045e(); break; case 2: func_05f5(); break; } // end switch } // while } // end func void func_045e() { int locals[60]; locals[15] = 0; locals[13] = show_inv( 2, &locals[6], &locals[1] ); while ( locals[13] > 0 ) { locals[14] = 1; if ( locals[14] <= locals[13] ) { if ( locals[0] == 275 ) { locals[15] = locals[14]; locals[11] = locals[5]; } // end if locals[14] = locals[14] + 1; } // while } // end if if ( locals[15] > 0 ) { say( "Ah, that's no ordinary tool, but a true work of art befitting an Avatar! I can't take it from thee." ); locals[16] = 19; // "No, I insist - take it." locals[17] = 20; // "Very well." locals[18] = 0; // "" locals[37] = babl_menu( 0, &locals[16] ); switch ( locals[37] ) { case 1: break; case 2: func_05f5(); break; } // end switch locals[38] = 1; give_to_npc( 2, &locals[11], &locals[38] ); private[3] = 1; npc_attitude = 3; say( "That is too kind of thee. I cannot tell thee how much it will help me in my work. Thou hast demonstrated much humility by giving away this artifact - it is only right that I tell thee of the Ring of Humility.\m" ); say( "There is a room in the northwest portion of the level below us. There you will find four switches. Flip them in this order: northwest, southeast, northeast, and southwest. Be careful to stay out of the middle of the room." ); func_05f5(); } else { say( "Ah, I'm afraid that is of no use to me." ); locals[39] = 24; // "I will let thee know if I find something more useful." locals[40] = 25; // "Perhaps this would help thee more." locals[41] = 0; // "" locals[60] = babl_menu( 0, &locals[39] ); switch ( locals[60] ) { case 1: func_05f5(); break; case 2: func_045e(); } // end if break; } // end switch } // end func void func_0565() { int locals[22]; say( "Greetings, @GS8. How goes it?" ); locals[1] = 27; // "I believe I have found an item that may help thee." locals[2] = 28; // "Satisfactorily. Now I must continue on my quest." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_045e(); break; case 2: func_05f5(); break; } // end switch } // end func void func_05ad() { int locals[22]; say( "Greetings, @GS8. I am forever indebted to thee for the gem cutter thou hast given me. It has increased my productivity tenfold." ); locals[1] = 30; // "Don't mention it." locals[2] = 31; // "I am glad it was of use." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_05f5(); break; case 2: func_05f5(); break; } // end switch } // end func void func_05f5() { int locals[22]; say( "Farewell then." ); locals[1] = 33; // "Farewell." locals[2] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); if ( locals[22] == 1 ) { func_00e0(); } // end if } // end func