Ultima Underworld/technical/conversations/184

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 #184 // string block 0x0eb8 (3768), name Delanrey // // 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[45]; locals[1] = get_quest( 1, &locals[2] ); locals[2] = 10; if ( private[0] ) { func_03d4(); } else { private[2] = 0; say( "Ho, adventurer! I have been looking for one like thee. Hast thou made the acquaintance of an adventurer known as Zak?" ); locals[24] = 1; locals[3] = 2; // "I have not met such a man." locals[25] = locals[1]; locals[4] = 3; // "Indeed I have. He lives above with the lizardmen." locals[26] = 1; locals[5] = 4; // "Zak?" locals[6] = 0; // "" locals[45] = babl_fmenu( 0, &locals[3], &locals[24] ); switch ( locals[45] ) { case 2: func_0335(); break; case 3: func_034b(); break; case 4: func_0366(); } // end if break; } // end switch } // end func void func_0335() { int locals[1]; say( "I am sorry to hear it. I have not been able to find another candelabra like the one he stole from me." ); locals[1] = 2; func_00b1( &locals[1] ); } // end func void func_034b() { int locals[1]; private[2] = 1; say( "I am glad to hear that! Perhaps I will be able to retrieve my candelabra from him now." ); locals[1] = 2; func_00b1( &locals[1] ); } // end func void func_0366() { int locals[45]; locals[1] = get_quest( 1, &locals[2] ); locals[2] = 10; say( "I don't know his real name, but he has come to be known simply as Zak. He was a Knight, I understand, before finding something in his adventures that caused him to lose his sanity. Recently he wandered by and made off with my candelabra. I don't expect ever to see it again. I hear that he also stole from the Knights some candle that they value highly." ); locals[24] = 1; locals[3] = 8; // "I've never met him." locals[25] = locals[1]; locals[4] = 9; // "Indeed I have met him! He resides above us, on the level of the lizardmen." locals[5] = 0; // "" locals[45] = babl_fmenu( 0, &locals[3], &locals[24] ); switch ( locals[45] ) { case 8: func_0335(); break; case 9: func_034b(); break; } // end switch } // end func void func_03d4() { int locals[46]; locals[1] = get_quest( 1, &locals[2] ); locals[2] = 10; if ( private[2] ) { say( "Hello, @GS8! I thank thee again for telling me of the whereabouts of Zak." ); locals[3] = 2; func_00b1( &locals[3] ); } else { say( "Oh, hello again. Hast thou perhaps found Zak?" ); locals[25] = 1; locals[4] = 12; // "No, I still have not seen him." locals[26] = locals[1]; locals[5] = 13; // "Yes, in fact, I have seen him. He lives above with the lizardmen." locals[27] = 1; locals[6] = 14; // "I'm sorry - who is Zak again?" locals[7] = 0; // "" locals[46] = babl_fmenu( 0, &locals[4], &locals[25] ); switch ( locals[46] ) { case 12: func_0335(); break; case 13: func_034b(); break; case 14: func_0366(); } // end if break; } // end switch } // end func void func_0473() { int locals[44]; setup_to_barter( 0 ); while ( !private[1] ) { locals[1] = 15; // "I make thee this offer." locals[2] = 16; // "I demand thou givest me these items." locals[3] = 17; // "Excuse me, I must think about this deal." locals[4] = 18; // "I do not wish to barter any further." locals[5] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0524(); break; case 2: func_057e(); break; case 3: do_judgement( 0 ); break; case 4: do_decline( 0 ); private[1] = 1; break; } // end switch } // while locals[23] = 19; // "Farewell." locals[24] = 0; // "" locals[44] = babl_menu( 0, &locals[23] ); if ( locals[44] == 1 ) { private[1] = 1; } // end if } // end func void func_0524() { int locals[15]; locals[0] = -1; locals[6] = -1; locals[11] = 20; // "I accept thy offer." locals[12] = 21; // "No, I do not like this deal." locals[13] = 22; // "Dost thou take me for a fool?" locals[14] = 23; // "I am weary of this haggling." locals[15] = 24; // "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_057e() { int locals[24]; say( "Dost thou intend to rob me?" ); locals[1] = 26; // "Yes, I must." locals[2] = 27; // "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] = 28; // "If thou dost insist, thou canst have them." locals[24] = 29; // "No! Thou shalt not take them!" if ( do_demand( 2, &locals[24], &locals[23] ) ) { private[1] = 1; } else { func_008b(); } // end if } // end func