Ultima Underworld/technical/conversations/89

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 #89 // string block 0x0e59 (3673), name Hewstone // // 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[134]; if ( private[0] ) { if ( private[5] ) { } else { say( "Ach, @GS8, the aspiring miner! What can I do for ye?" ); } else { private[2] = 1; private[3] = 1; private[4] = 1; say( "Ach, ye don't look like a miner to me. Who be ye?" ); locals[2] = 3; // "I am @GS8, an adventurer." locals[3] = 4; // "That is my business, not thine." locals[4] = 0; // "" locals[23] = babl_menu( 0, &locals[2] ); switch ( locals[23] ) { case 1: break; case 2: say( "Well then, off with thee!" ); private[5] = 1; locals[24] = 1; func_00b1( &locals[24] ); break; } // end switch say( "Well met, @GS8. I be Hewstone. What are ye doing in these parts?" ); label_0316:; locals[25] = 7; // "I wish to learn the ways of a miner." locals[26] = 8; // "I am looking for treasure." locals[27] = 9; // "I am searching for a monster to destroy." locals[28] = 0; // "" locals[46] = babl_menu( 0, &locals[25] ); switch ( locals[46] ) { case 1: goto label_0367; break; case 2: goto label_03b0; break; case 3: goto label_03ba; break; } // end switch label_0367:; label_0367:; private[2] = 0; say( "Aye, ye would be a miner, eh? It's a tough job, ye should know that. Don't take it up if ye have not the strength. Hard it work it is, picking up a rock hammer and smashing boulders to pieces, scraping the rock over and over again, one inch of wall at a time." ); locals[47] = 11; // "It sounds awful." locals[48] = 12; // "There must be some good points to being a miner." locals[49] = 0; // "" locals[68] = babl_menu( 0, &locals[47] ); switch ( locals[68] ) { case 1: break; case 2: break; } // end switch say( "Well, it is backbreaking work but the rewards are great. Gold there is for the hard worker, and I know of no substance better. Ah, the thrill of feeling one's hammer thud solid rock and suddenly discovering a new vein!\n" " Go ye to the northern part of these mines and see for yourself the beauty of a gold mine. But watch yourself - a fearsome monster has been seen in that area, and perhaps even an adventurer such as ye could not handle it.\m" ); say( "Is there anything else I can help ye with?" ); goto label_03c4; label_03b0:; label_03b0:; private[3] = 0; say( "Ach, ye've come to the right place. There is no treasure better than gold, and gold there is in abundance in these mines. In the north parts of these mines especially, ye shall find a beautiful sight. Be careful of the monster that's been seen around those parts, though.\n" " Now, what else might ye want to know?" ); goto label_03c4; label_03ba:; label_03ba:; private[4] = 0; say( "The monster of the mines? A great boon it would be if ye did defeat it, but I don't know that it can be done. A fearsome thing it is. Caught it once out of the corner of me eye, and I don't care to see it again. It lurks in the north part of these mines. Ye be careful, if ye truly mean to destroy it.\n" " We caused a cave-in to block its area from ours, so ye'll have to break your way through it. Is there anything I can help ye with before ye go off after it?" ); } // end if label_03c4:; label_03c4:; locals[1] = ((!private[2] || !private[3]) || !private[4]); locals[90] = private[2]; locals[69] = 17; // "What is it like to a be miner?" locals[91] = private[3]; locals[70] = 18; // "Is there great treasure in these mines?" locals[92] = private[4]; locals[71] = 19; // "What of the monster that resides here?" locals[93] = locals[1]; locals[72] = 20; // "I would like to trade with thee." locals[94] = 1; locals[73] = 21; // "Thank thee, I shall be on my way." locals[74] = 0; // "" locals[111] = babl_fmenu( 0, &locals[69], &locals[90] ); switch ( locals[111] ) { case 17: goto label_0367; break; case 18: goto label_03b0; break; case 19: goto label_03ba; break; case 20: goto label_04d1; break; case 21: func_00e0(); } // end if break; } // end switch say( "Decided to be a bit more friendly, eh?" ); locals[112] = 23; // "Yes. My name is @GS8." locals[113] = 24; // "What gave thee that impression? Goodbye." locals[114] = 0; // "" locals[133] = babl_menu( 0, &locals[112] ); switch ( locals[133] ) { case 1: break; case 2: say( "Good riddance!" ); locals[134] = 1; func_00b1( &locals[134] ); break; } // end switch private[5] = 0; say( "That's a bit better. I be Hewstone. What are ye doing in these parts?" ); goto label_0316; label_04d1:; say( "'Twould be a pleasure." ); func_04de(); say( "Farewell." ); func_00e0(); } // end func void func_04de() { int locals[44]; setup_to_barter( 0 ); while ( !private[1] ) { locals[1] = 29; // "I make thee this offer." locals[2] = 30; // "I demand thou givest me these items." locals[3] = 31; // "Excuse me, I must think about this deal." locals[4] = 32; // "I do not wish to barter any further." locals[5] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_058f(); break; case 2: func_05e9(); break; case 3: do_judgement( 0 ); break; case 4: do_decline( 0 ); private[1] = 1; break; } // end switch } // while locals[23] = 33; // "Farewell." locals[24] = 0; // "" locals[44] = babl_menu( 0, &locals[23] ); if ( locals[44] == 1 ) { private[1] = 1; } // end if } // end func void func_058f() { int locals[15]; locals[0] = -1; locals[6] = -1; locals[11] = 34; // "I accept thy offer." locals[12] = 35; // "No, I do not like this deal." locals[13] = 36; // "Dost thou take me for a fool?" locals[14] = 37; // "I am weary of this haggling." locals[15] = 38; // "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_05e9() { int locals[24]; say( "Dost thou intend to rob me?" ); locals[1] = 40; // "Yes, I must." locals[2] = 41; // "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] = 42; // "If thou dost insist, thou canst have them." locals[24] = 43; // "No! Thou shalt not take them!" if ( do_demand( 2, &locals[24], &locals[23] ) ) { private[1] = 1; } else { func_008b(); } // end if } // end func