Ultima Underworld/technical/conversations/21

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 #21 // string block 0x0e15 (3605), name Steeltoe // // 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]; say( "Halt! Who goes there?" ); locals[1] = 2; // "I am @GS8." locals[2] = 3; // "Who wants to know?" locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_02e5(); break; case 2: func_0379(); break; } // end switch } // end func void func_02e5() { int locals[24]; say( "What is thy business here?" ); locals[2] = 5; // "Other..." locals[3] = 8; // "I might ask thee the same." locals[4] = 9; // "I come on Goldthirst's business." locals[5] = 10; // "I am merely exploring." locals[6] = 0; // "" locals[23] = babl_menu( 0, &locals[2] ); switch ( locals[23] ) { case 1: locals[1] = babl_ask( 0 ); locals[24] = 6; if ( contains( 2, &locals[1], &locals[24] ) ) { func_041c(); } else { say( "What is that? Speak up!" ); func_02e5(); } // end if break; case 2: func_0379(); break; case 3: func_0386(); break; case 4: func_040f(); break; } // end switch } // end func void func_0379() { say( "I ask the questions here!" ); func_02e5(); } // end func void func_0386() { int locals[25]; say( "I doubt your purpose here is legitimate, if ye know not the password!" ); locals[2] = 13; // "Thou art right. I'll just be going." locals[3] = 14; // "What?" locals[4] = 15; // "Other..." locals[5] = 0; // "" locals[23] = babl_menu( 0, &locals[2] ); switch ( locals[23] ) { case 1: func_00e0(); break; case 2: func_0379(); break; case 3: locals[1] = babl_ask( 0 ); locals[24] = 16; if ( contains( 2, &locals[1], &locals[24] ) ) { func_041c(); } else { say( "That's not it! Begone!" ); locals[25] = 1; func_00b1( &locals[25] ); } // end if break; } // end switch } // end func void func_040f() { say( "We'll have no exploring here! Now, off with ye!" ); func_00c2(); } // end func void func_041c() { int locals[7]; locals[1] = sex( 2, &locals[3], &locals[2] ); locals[2] = 19; locals[3] = 20; locals[4] = 11; locals[5] = 13; locals[6] = 0; gronk_door( 3, &locals[6], &locals[5], &locals[4] ); say( "Greetings, noble @SS1! Enter with honor and look upon the magnificent treasure chamber of Lord Goldthirst. Dare ye not to do any further." ); locals[7] = 3; func_00b1( &locals[7] ); } // end func