Ultima Underworld/technical/conversations/22

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 #22 // string block 0x0e16 (3606), name golem // // 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]global[0]; 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] && global[0] ) { say( "Thou hast bested me and earned the Shield of Valor; thou hast nothing more to prove here." ); func_0535(); } else { if ( npc_hp < 10 ) { func_040b(); } else { if ( private[0] && play_hp < 20 ) { func_03c3(); } else { if ( private[0] ) { func_04ed(); } else { global[0] = 0; say( "Hold, puny mortal! I am thy doom!" ); locals[1] = 3; // "So sayest THOU!" locals[2] = 4; // "Perhaps." locals[3] = 5; // "I was just leaving." locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0333(); break; case 2: func_0333(); break; case 3: func_0535(); } // end if } // end if } // end if } // end if break; } // end switch } // end func void func_0333() { int locals[22]; say( "I am what I was made to be - the greatest warrior in Britannia. If thou be not of mighty valor, turn back now and no shame will come of it. Else, prepare to meet thy doom." ); locals[1] = 7; // "And what be my reward if I succeed?" locals[2] = 8; // "I thank thee, but I must be going." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_037b(); break; case 2: func_0535(); break; } // end switch } // end func void func_037b() { int locals[22]; say( "Thou wagerest thy life against a mighty talisman - the Shield of Valor. Defeat me and it shall be thine. Fail and thou shalt surely die." ); locals[1] = 10; // "Have at thee, then, for I fear nothing!" locals[2] = 11; // "I have pressing business elsewhere." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_008b(); break; case 2: func_0535(); break; } // end switch } // end func void func_03c3() { int locals[22]; say( "Hold! Thou hast fought well, mortal. Better than any in many a year. I would give thee a chance to live, that valor such as yours should not die. Flee now and I grant thee thy life. " ); locals[1] = 13; // "I thank thee. Perhaps we shall meet again." locals[2] = 14; // "Thou art bluffing. Die, monster!" locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0535(); break; case 2: func_008b(); break; } // end switch } // end func void func_040b() { int locals[34]; say( "Hold, mortal! Thou hast bested me! Never have any shown such Valor! Surely thou shouldst be the master of the Shield!" ); locals[1] = find_inv( 2, &locals[3], &locals[2] ); locals[2] = 55; locals[3] = 0; if ( locals[1] > 0 ) { locals[4] = 1; locals[5] = 7; locals[6] = -1; locals[7] = -1; locals[8] = -1; locals[9] = -1; locals[10] = -1; locals[11] = -1; x_obj_stuff( 9, &locals[11], &locals[10], &locals[9], &locals[8], &locals[7], &locals[6], &locals[5], &locals[4], &locals[1] ); } // end if locals[12] = 55; if ( take_from_npc( 1, &locals[12] ) == 2 ) { say( "I will leave it here for thee. Use it well!" ); } // end if global[0] = 1; npc_hp = 125; locals[13] = 17; // "Thou art a noble opponent. I give thee thy life. Farewell." locals[14] = 18; // "I thank thee for the Shield, but thou art too dangerous to live: Die, fiend!" locals[15] = 0; // "" locals[34] = babl_menu( 0, &locals[13] ); switch ( locals[34] ) { case 1: func_0535(); break; case 2: func_008b(); break; } // end switch } // end func void func_04ed() { int locals[22]; say( "Why dost thou continue to talk to me? Art thou not eager to continue our battle?" ); locals[1] = 20; // "Yes, and now I shall prevail!" locals[2] = 21; // "Perhaps another time." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_008b(); break; case 2: func_0535(); break; } // end switch } // end func void func_0535() { int locals[1]; npc_goal = 8; locals[1] = 2; func_00b1( &locals[1] ); } // end func