Ultima Underworld/technical/conversations/188
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 #188 // string block 0x0ebc (3772), name Gralwart // // 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] ) { func_03d1(); } else { private[2] = 0; private[3] = 0; say( "A new adventurer in our midst, eh? Perhaps thou wouldst like to increase thy magical powers?" ); locals[1] = 2; // "I surely would." locals[2] = 3; // "No, thank thee." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_034e(); break; case 2: func_02f8(); } // end if break; } // end switch } // end func void func_02f8() { int locals[23]; say( "Yes, I now see that thou art not as powerful as I first thought. I'm sure thou hast not the power to use a Vas runestone anyways." ); locals[1] = 5; // "Thou art right. Farewell." locals[2] = 6; // "I certainly could use a Vas runestone!" locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: locals[23] = 2; func_00b1( &locals[23] ); break; case 2: say( "Well then, here's how to obtain one." ); func_035d(); func_036d(); break; } // end switch } // end func void func_034e() { say( "Well, listen carefully, for I shall tell thee how to obtain a Vas runestone, the most powerful runestone there is." ); func_035d(); func_036d(); } // end func void func_035d() { private[2] = 1; say( "Go to the meeting hall to the east and shoot right between the eyes. Then put an emerald on each of the four platforms in the corners, walk back to the middle of the room, and press the gray button." ); } // end func void func_036d() { int locals[23]; locals[1] = 10; // "Thank thee, I shall follow thy instructions carefully." locals[2] = 11; // "Thy instructions are most confusing." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: locals[23] = 3; func_00b1( &locals[23] ); break; case 2: func_03bb(); break; } // end switch } // end func void func_03bb() { int locals[1]; say( "'Tis true - they are. 'Tis also true that if thou canst not follow them, thou art perhaps not worthy to reap the reward gained by doing so. Good luck." ); locals[1] = 2; func_00b1( &locals[1] ); } // end func void func_03d1() { if ( private[2] ) { if ( private[3] ) { func_03ed(); } else { func_0457(); } // end if } else { func_0403(); } // end if } // end func void func_03ed() { int locals[1]; say( "Thou hast gained the runestone already. Thou hast no further need of me. Use thy new powers as thou wilt!" ); locals[1] = 3; func_00b1( &locals[1] ); } // end func void func_0403() { int locals[23]; say( "Hello again, adventurer! Hast thou decided to seek greater magical power after all?" ); locals[1] = 15; // "Yes, I have need of it." locals[2] = 16; // "No, I still desire no greater power." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_034e(); break; case 2: say( "Very well, then." ); locals[23] = 2; func_00b1( &locals[23] ); break; } // end switch } // end func void func_0457() { int locals[23]; say( "Hello again! Wert thou successful in finding what thou sought?" ); locals[1] = 19; // "Indeed I was. Thank thee for the directions." locals[2] = 20; // "No, thy instructions were too confusing." locals[3] = 21; // "No, but I will continue to search." locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_04bf(); break; case 2: func_04da(); break; case 3: say( "Good luck!" ); locals[23] = 3; func_00b1( &locals[23] ); break; } // end switch } // end func void func_04bf() { int locals[1]; private[3] = 1; say( "Well done. I wish thee luck with thy new power." ); locals[1] = 3; func_00b1( &locals[1] ); } // end func void func_04da() { int locals[23]; say( "Very well, I shall repeat them." ); func_035d(); locals[1] = 25; // "Thank thee. Perhaps I will have better luck this time." locals[2] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); if ( locals[22] == 1 ) { locals[23] = 3; func_00b1( &locals[23] ); } // end if } // end func void func_0519() { int locals[44]; setup_to_barter( 0 ); while ( !private[1] ) { locals[1] = 26; // "I make thee this offer." locals[2] = 27; // "I demand thou givest me these items." locals[3] = 28; // "Excuse me, I must think about this deal." locals[4] = 29; // "I do not wish to barter any further." locals[5] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_05ca(); break; case 2: func_0624(); break; case 3: do_judgement( 0 ); break; case 4: do_decline( 0 ); private[1] = 1; break; } // end switch } // while locals[23] = 30; // "Farewell." locals[24] = 0; // "" locals[44] = babl_menu( 0, &locals[23] ); if ( locals[44] == 1 ) { private[1] = 1; } // end if } // end func void func_05ca() { int locals[15]; locals[0] = -1; locals[6] = -1; locals[11] = 31; // "I accept thy offer." locals[12] = 32; // "No, I do not like this deal." locals[13] = 33; // "Dost thou take me for a fool?" locals[14] = 34; // "I am weary of this haggling." locals[15] = 35; // "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_0624() { int locals[24]; say( "Dost thou intend to rob me?" ); locals[1] = 37; // "Yes, I must." locals[2] = 38; // "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] = 39; // "If thou dost insist, thou canst have them." locals[24] = 40; // "No! Thou shalt not take them!" if ( do_demand( 2, &locals[24], &locals[23] ) ) { private[1] = 1; } else { func_008b(); } // end if } // end func