Ultima Underworld/technical/conversations/161

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 #161 // string block 0x0ea1 (3745), name Anjor // // 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[597]; if ( private[0] ) { } else { goto label_02ad; label_02ad:; say( "Greetings, traveler. What brings thee to an area of the Abyss as perilous as this? Art thou upon a quest, as I myself am?" ); locals[9] = 2; // "What is thy quest?" locals[10] = 3; // "No, I am not on a quest." locals[11] = 0; // "" locals[30] = babl_menu( 0, &locals[9] ); switch ( locals[30] ) { case 1: goto label_02ed; break; case 2: goto label_06ae; break; } // end switch label_02ed:; label_02ed:; label_02ed:; say( "Many years ago, I began research into methods for turning lower metals into gold. During the course of my research, I discovered a new and better method that depends on a particular, very rare substance. I quest to find more of this substance." ); locals[31] = 5; // "Why is this method so much better?" locals[32] = 6; // "Tell me of this substance." locals[33] = 0; // "" locals[52] = babl_menu( 0, &locals[31] ); switch ( locals[52] ) { case 1: goto label_032d; break; case 2: goto label_03d9; break; } // end switch label_032d:; label_032d:; private[4] = 1; if ( private[5] ) { locals[1] = 7; } else { locals[1] = 8; } // end if say( "When I started, existing methods required a great many reagents to operate, and could produce only a fraction of an ounce of gold for each pound of lower metal.\n" " The new method requires a much smaller quantity of reagents and produces much more gold. However, @SS1 is rare, and I have been able to locate only trace amounts of it." ); locals[5] = !private[5]; locals[74] = locals[5]; locals[53] = 10; // "Tell me of this substance." locals[75] = private[5]; locals[54] = 11; // "How is the mineral collected?" locals[76] = private[5]; locals[55] = 12; // "Tell me of the mining area." locals[77] = locals[5]; locals[56] = 13; // "Where hast thou located the reagent?" locals[57] = 0; // "" locals[95] = babl_fmenu( 0, &locals[53], &locals[74] ); switch ( locals[95] ) { case 10: goto label_03d9; break; case 11: goto label_0455; break; case 12: goto label_04d2; break; case 13: goto label_03d9; break; } // end switch label_03d9:; label_03d9:; label_03d9:; private[5] = 1; say( "It is a blue rock-like mineral called zanium. The only samples I have found have been on this floor of the Abyss in tunnels with rough-hewn walls. I believe there is a mining area in the southwest where there may be larger deposits, but I cannot gain access to it." ); locals[5] = !private[4]; locals[117] = locals[5]; locals[96] = 15; // "How is the new method better?" locals[118] = 1; locals[97] = 16; // "How is this mineral collected?" locals[119] = 1; locals[98] = 17; // "Tell me of the mining area." locals[99] = 0; // "" locals[138] = babl_fmenu( 0, &locals[96], &locals[117] ); switch ( locals[138] ) { case 15: goto label_032d; break; case 16: goto label_0455; break; case 17: goto label_04d2; break; } // end switch label_0455:; label_0455:; label_0455:; private[6] = 1; say( "Zanium has the property of being self-attractive. Deposits near the surface can be collected merely by walking over them while carrying a sample. In an underground environment such as this, if there is zanium present, there is likely to be some near the the surface. Thus, in a sense, it is collected automatically." ); locals[5] = !private[7]; locals[160] = locals[5]; locals[139] = 19; // "Tell me of this mining area." locals[161] = private[7]; locals[140] = 20; // "Who might know more about the mine?" locals[162] = 1; locals[141] = 21; // "Then perhaps I can help thee." locals[142] = 0; // "" locals[181] = babl_fmenu( 0, &locals[139], &locals[160] ); switch ( locals[181] ) { case 19: goto label_04d2; break; case 20: goto label_0532; break; case 21: goto label_0572; break; } // end switch label_04d2:; label_04d2:; label_04d2:; private[7] = 1; say( "I do not know much. There is a small room in the southwestern region that is labelled "mine dispatch chamber." There appear to be some controls, but I know not how to operate them." ); locals[5] = !private[6]; locals[203] = 1; locals[182] = 23; // "Is there anyone who would know about the controls?" locals[204] = locals[5]; locals[183] = 24; // "How is this mineral collected?" locals[184] = 0; // "" locals[224] = babl_fmenu( 0, &locals[182], &locals[203] ); switch ( locals[224] ) { case 23: goto label_0532; break; case 24: goto label_0455; break; } // end switch label_0532:; label_0532:; say( "Now that thou dost mention it, yes, there is one who may know something. One of those frightful ghouls in the catacombs used to be foreman in the mining sector. No ghoul has spoken to me since I killed one of them in self-defense. Perhaps thou couldst assist me?" ); locals[225] = 26; // "What assistance dost thou need?" locals[226] = 27; // "I am sorry, but I am unable to help thee." locals[227] = 0; // "" locals[246] = babl_menu( 0, &locals[225] ); switch ( locals[246] ) { case 1: goto label_0572; break; case 2: goto label_05b7; break; } // end switch label_0572:; label_0572:; label_0572:; label_0572:; private[12] = 0; say( "If thou couldst talk to the miner ghoul and discover how to operate the dispatch chamber I would be most grateful. In addition, if thou wouldst enter the mining area, brave its dangers and collect at least eighty samples of zanium, I would reward thee with a large gold nugget created from lead." ); locals[247] = 29; // "I shall get thee information about the controls." locals[248] = 30; // "I will bring thee the zanium." locals[249] = 0; // "" locals[268] = babl_menu( 0, &locals[247] ); switch ( locals[268] ) { case 1: goto label_065b; break; case 2: goto label_0605; break; } // end switch label_05b7:; label_05b7:; private[12] = 1; say( "Well, if thou dost change thy mind, speak with me again. Farewell." ); locals[269] = 32; // "Wait! I will help thee." locals[270] = 33; // "Farewell." locals[271] = 0; // "" locals[290] = babl_menu( 0, &locals[269] ); switch ( locals[290] ) { case 1: goto label_0572; break; case 2: locals[291] = 2; func_00b1( &locals[291] ); break; } // end switch label_0605:; label_0605:; label_0605:; label_0605:; label_0605:; label_0605:; private[2] = 0; private[3] = 1; say( "Wouldst thou? Thou art indeed a kind soul! Take this small sample. Carry it through the mine, and it shall attract more of its kind." ); locals[292] = 297; if ( take_from_npc( 1, &locals[292] ) == 2 ) { say( "I will leave it on the floor here for thee." ); } // end if locals[293] = 36; // "Farewell." locals[294] = 0; // "" locals[314] = babl_menu( 0, &locals[293] ); if ( locals[314] == 1 ) { locals[315] = 3; func_00b1( &locals[315] ); } // end if label_065b:; private[2] = 1; private[3] = 0; say( "I thank thee kindly. Speak to me after thou hast obtained the pertinent information. Farewell." ); locals[316] = 38; // "Wait, I shall get the zanium." locals[317] = 39; // "Farewell." locals[318] = 0; // "" locals[337] = babl_menu( 0, &locals[316] ); switch ( locals[337] ) { case 1: goto label_0605; break; case 2: locals[338] = 2; func_00b1( &locals[338] ); break; } // end switch label_06ae:; say( "I see. Then thou art an intrepid explorer indeed, to brave such depths as this." ); locals[339] = 41; // "Though I have no quest, do tell me of thine." locals[340] = 42; // "Indeed. And I must continue. Farewell." locals[341] = 0; // "" locals[360] = babl_menu( 0, &locals[339] ); switch ( locals[360] ) { case 1: goto label_02ed; break; case 2: say( "Farewell." ); locals[361] = 2; func_00b1( &locals[361] ); } // end if break; } // end switch if ( private[10] ) { } else { if ( private[9] ) { } else { if ( private[3] ) { } else { if ( private[11] ) { } else { if ( private[8] ) { } else { if ( private[3] ) { } else { if ( private[12] ) { } else { if ( private[2] ) { } else { } // end if say( "Hast thou obtained the information I require?" ); locals[362] = 45; // "Yes, I have." locals[363] = 46; // "No, I have not." locals[364] = 47; // "I have decided to get the zanium." locals[365] = 0; // "" locals[383] = babl_menu( 0, &locals[362] ); switch ( locals[383] ) { case 1: goto label_0798; break; case 2: goto label_07d8; break; case 3: goto label_0605; break; } // end switch label_0798:; label_0798:; say( "Excellent! What are the settings for the controls?" ); locals[384] = 49; // "The settings are..." locals[385] = 50; // "Oh, sorry. I do not have the settings." locals[386] = 0; // "" locals[405] = babl_menu( 0, &locals[384] ); switch ( locals[405] ) { case 1: goto label_07e6; break; case 2: goto label_07d8; break; } // end switch label_07d8:; label_07d8:; say( "'Tis a shame. Return when thou hast it." ); locals[406] = 2; func_00b1( &locals[406] ); label_07e6:; private[8] = 1; locals[4] = babl_ask( 0 ); locals[407] = 52; if ( contains( 2, &locals[4], &locals[407] ) ) { private[20] = 1; } else { private[20] = 0; } // end if say( "I thank thee very much. I shall attempt to enter the mine." ); locals[408] = 2; func_00b1( &locals[408] ); } // end if if ( private[20] ) { say( "I thank thee for the information. It was indeed correct, but I was unable to retrieve the zanium because of numerous apparitions in the mine area. Wouldst thou retrieve it?" ); locals[409] = 55; // "Yes." locals[410] = 56; // "No, I cannot." locals[411] = 0; // "" locals[430] = babl_menu( 0, &locals[409] ); switch ( locals[430] ) { case 1: goto label_0605; break; case 2: private[11] = 1; say( "Well, if thou dost reconsider, let me know." ); locals[431] = 2; func_00b1( &locals[431] ); } // end if } else { break; } // end switch say( "The information thou didst give me was incorrect. Dost thou wish to correct it?" ); locals[432] = 59; // "Yes, I do." locals[433] = 60; // "No, I do not. Farewell." locals[434] = 61; // "I shall get the zanium." locals[435] = 0; // "" locals[453] = babl_menu( 0, &locals[432] ); switch ( locals[453] ) { case 1: goto label_0798; break; case 2: locals[454] = 2; func_00b1( &locals[454] ); break; case 3: goto label_0605; } // end if } // end if break; } // end switch say( "Hast thou found eighty samples of zanium?" ); locals[455] = 63; // "Yes, I have." locals[456] = 64; // "No, I have not." locals[457] = 0; // "" locals[476] = babl_menu( 0, &locals[455] ); switch ( locals[476] ) { case 1: goto label_0917; break; case 2: goto label_0957; break; } // end switch label_0917:; say( "Excellent! May I have them please?" ); locals[477] = 66; // "Here they are." locals[478] = 67; // "Oh, sorry. I don't have them." locals[479] = 0; // "" locals[498] = babl_menu( 0, &locals[477] ); switch ( locals[498] ) { case 1: goto label_0965; break; case 2: goto label_0957; break; } // end switch label_0957:; label_0957:; say( "Very well. Return when thou hast found it." ); locals[499] = 3; func_00b1( &locals[499] ); label_0965:; label_0965:; locals[500] = 297; find_barter_total( 4, 53, 54, 52, &locals[500] ); if ( private[22] == 0 ) { say( "I see none there!" ); } else { if ( private[22] < 80 ) { if ( private[22] == 1 ) { locals[2] = 70; } else { locals[2] = 71; } // end if say( "I see only @GI53 @SS2 there!" ); } else { give_to_npc( 2, 54, 52 ); private[9] = 1; say( "I thank thee kindly. Return in an hour and I shall give thee a gold nugget the size of which thou canst but imagine." ); func_00ea( 45 ); private[17][1] = 0; private[17][2] = 60; locals[501] = 3; func_00b1( &locals[501] ); } // end if if ( !func_0106( 48, 45 ) ) { func_018f( &locals[6], 48, 45 ); if ( locals[7] == 1 ) { locals[3] = 74; } else { locals[3] = 75; } // end if say( "I said it would be an hour. Come back in @SI6C2 @SS3." ); locals[502] = 3; func_00b1( &locals[502] ); } // end if say( "Here is thy reward. I thank thee again." ); private[10] = 1; locals[503] = 175; do_inv_create( 1, &locals[503] ); locals[504] = 175; take_from_npc( 1, &locals[504] ); locals[505] = 3; func_00b1( &locals[505] ); say( "Hello again, traveler. How may I help thee?" ); locals[506] = 79; // "Please tell me of thy quest." locals[507] = 80; // "I was just leaving" locals[508] = 0; // "" locals[527] = babl_menu( 0, &locals[506] ); switch ( locals[527] ) { case 1: goto label_02ed; break; case 2: locals[528] = 2; func_00b1( &locals[528] ); } // end if break; } // end switch say( "Hast thou reconsidered? Wilt thou help me after all?" ); locals[529] = 82; // "Yes. What dost thou need?" locals[530] = 83; // "No. I cannot help thee." locals[531] = 0; // "" locals[550] = babl_menu( 0, &locals[529] ); switch ( locals[550] ) { case 1: goto label_0572; break; case 2: goto label_05b7; } // end if break; } // end switch say( "Hast thou reconsidered? Wilt thou get the zanium?" ); locals[551] = 85; // "Yes, I shall." locals[552] = 86; // "No. Farewell." locals[553] = 0; // "" locals[572] = babl_menu( 0, &locals[551] ); switch ( locals[572] ) { case 1: goto label_0605; break; case 2: locals[573] = 2; func_00b1( &locals[573] ); } // end if break; } // end switch say( "I must thank thee again for retrieving the zanium. I am sorry, but I must excuse myself, as I am still busy with experiments." ); locals[574] = 3; func_00b1( &locals[574] ); } // end if } // end if locals[575] = 88; // "I am sorry. Here are thy eighty samples of zanium." locals[576] = 89; // "I will go then and retrieve more zanium." locals[577] = 0; // "" locals[596] = babl_menu( 0, &locals[575] ); switch ( locals[596] ) { case 1: goto label_0965; break; case 2: say( "Please do." ); locals[597] = 2; func_00b1( &locals[597] ); break; } // end switch } // end func