Ultima Underworld/technical/conversations/19
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 #19 // string block 0x0e13 (3603), name Hagbard // // 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[27]; if ( npc_talkedto == 1 ) { func_057c(); } else { global[0] = 0; locals[1] = sex( 2, &locals[3], &locals[2] ); locals[2] = 1; locals[3] = 2; locals[4] = 1; locals[5] = 1; set_quest( 2, &locals[5], &locals[4] ); say( "Hah! Another fish enters the barrel! What be THY crime, @SS1 of misfortune?" ); locals[6] = 4; // "I am innocent! I was falsely accused!" locals[7] = 5; // "It is said I kidnapped a girl." locals[8] = 6; // "I am guilty of naught but misfortune." locals[9] = 7; // "What dost thou mean?" locals[10] = 0; // "" locals[27] = babl_menu( 0, &locals[6] ); switch ( locals[27] ) { case 1: func_0350(); break; case 2: func_03eb(); break; case 3: func_0350(); break; case 4: func_0648(); } // end if break; } // end switch } // end func void func_0350() { int locals[44]; locals[1] = !global[0]; say( "Innocent, eh? Why, so are we all, falsely accused every one of us!" ); locals[23] = locals[1]; locals[2] = 9; // "It grieves me to hear it. Can nothing be done?" locals[24] = 1; locals[3] = 10; // "Well, I must take my leave. Farewell." locals[25] = 1; locals[4] = 11; // "Speaking of innocence, hast seen a maiden in distress?" locals[26] = 1; locals[5] = 12; // "Begone, liar! Thou art a charlatan and worse!" locals[6] = 0; // "" locals[44] = babl_fmenu( 0, &locals[2], &locals[23] ); switch ( locals[44] ) { case 9: func_0648(); break; case 10: func_00e0(); break; case 11: func_03eb(); break; case 12: func_00c2(); break; } // end switch } // end func void func_03eb() { int locals[22]; say( "A young girl was this? Beauteous, but innocent?" ); locals[1] = 14; // "Aye, that was she." locals[2] = 15; // "I never saw her. I am innocent of the charge." locals[3] = 16; // "I would assume so." locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0447(); break; case 2: func_0447(); break; case 3: func_0447(); break; } // end switch } // end func void func_0447() { int locals[22]; if ( game_days == 0 ) { say( "We did see her but hours agone, carried by a troll and pursued by a pack of fools! They fell afoul of the Gobs, to be sure." ); } else { say( "Ah, she is long gone by now. A troll carried her below. Almric's men were in pursuit, but they proved no match for the Gobs." ); } // end if locals[1] = 19; // "The "Gobs?"" locals[2] = 20; // "I thank thee. I must seek them to prove my innocence!" locals[3] = 21; // "Where be she now?" locals[4] = 22; // "Still, I must recover her to clear my name. Goodbye." locals[5] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_04c4(); break; case 2: func_00c2(); break; case 3: func_06a9(); break; case 4: func_00c2(); break; } // end switch } // end func void func_04c4() { int locals[22]; say( "Aye, the Goblins. There be the Greens and the Grays, and they are deadly foes. They make our lives more difficult still with their vendettas." ); locals[1] = 24; // "What is the nature of their feud?" locals[2] = 25; // "Which cause is just?" locals[3] = 26; // "And are they the only inhabitants aside from thee?" locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0520(); break; case 2: func_0520(); break; case 3: func_06a9(); break; } // end switch } // end func void func_0520() { int locals[22]; say( "None can say. Their conflict seems to have begun at the time of the Great Collapse, when the civilization of the under-earth fell. We know only that their leaders have sworn never to agree on anything." ); locals[1] = 28; // "Is there nothing else thou canst tell me?" locals[2] = 29; // "I thank thee. Thou hast helped me greatly." locals[3] = 30; // "And is there aught beyond the domain of these Goblins?" locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_070e(); break; case 2: func_00e0(); break; case 3: func_06a9(); break; } // end switch } // end func void func_057c() { int locals[44]; if ( npc_attitude < 2 ) { say( "Thou again? Haven't had enough of thy betters, then?" ); locals[1] = 32; // "If my presence offends thee, I shall go." locals[2] = 33; // "Indeed I have, thou fool!" locals[3] = 34; // "Excuse me. I thought thou wert someone else." locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_062e(); break; case 2: func_008b(); break; case 3: func_00c2(); } // end if } else { break; } // end switch say( "Good day to thee again, if day it is outside!" ); if ( global[0] == 1 ) { locals[23] = 36; // "Hast thou news of the girl I seek?" locals[24] = 37; // "And a good day to thee. I must journey onward in my search." locals[25] = 0; // "" locals[44] = babl_menu( 0, &locals[23] ); switch ( locals[44] ) { case 1: func_063b(); break; case 2: func_00e0(); } // end if } else { break; } // end switch func_0648(); } // end func void func_062e() { say( "Since thou art so kind, I shall take thee up on thy generous offer of absence. Goodbye!" ); func_00c2(); } // end func void func_063b() { say( "No, she's long gone. Thou shouldst hurry if thou dost wish to catch her." ); func_00e0(); } // end func void func_0648() { int locals[22]; global[0] = 1; say( "Surely thou art one among us who was condemned by that pious oaf Baron Almric. We of the Outcasts are the survivors of his intemperate justice, fugitives from the predations of the Gobs." ); locals[1] = 41; // "Ah, perhaps then thou canst tell me of his daughter." locals[2] = 42; // "What are these Gobs of whom thou doth speak?" locals[3] = 43; // "I shall be on my way." locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_03eb(); break; case 2: func_04c4(); break; case 3: func_00e0(); break; } // end switch } // end func void func_06a9() { int locals[23]; say( "Ah... None who have ventured past the realm of the Gobs have returned. But rumor hath it there are worse perils below." ); locals[1] = 45; // "Well, I thank thee anyway. Farewell." locals[2] = 46; // "Perhaps I can solve the mystery for thee." locals[3] = 47; // "You cowards! Have none of you the courage to venture down yourselves?" locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_00e0(); break; case 2: func_00e0(); break; case 3: locals[23] = 1; func_00b1( &locals[23] ); break; } // end switch } // end func void func_070e() { int locals[22]; say( "Some goblins no longer abide the commands of their leaders, but wander the corridors in search of prey. They take from our supplies of food and are a danger as well. Would that we were rid of them." ); locals[1] = 49; // "I shall be on the lookout for them. Farewell." locals[2] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); if ( locals[22] == 1 ) { func_00e0(); } // end if } // end func void func_0742() { int locals[44]; setup_to_barter( 0 ); while ( !private[1] ) { locals[1] = 50; // "I make thee this offer." locals[2] = 51; // "I demand thou givest me these items." locals[3] = 52; // "Excuse me, I must think about this deal." locals[4] = 53; // "I do not wish to barter any further." locals[5] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_07f3(); break; case 2: func_084d(); break; case 3: do_judgement( 0 ); break; case 4: do_decline( 0 ); private[1] = 1; break; } // end switch } // while locals[23] = 54; // "Farewell." locals[24] = 0; // "" locals[44] = babl_menu( 0, &locals[23] ); if ( locals[44] == 1 ) { private[1] = 1; } // end if } // end func void func_07f3() { int locals[15]; locals[0] = -1; locals[6] = -1; locals[11] = 55; // "I accept thy offer." locals[12] = 56; // "No, I do not like this deal." locals[13] = 57; // "Dost thou take me for a fool?" locals[14] = 58; // "I am weary of this haggling." locals[15] = 59; // "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_084d() { int locals[24]; say( "Dost thou intend to rob me?" ); locals[1] = 61; // "Yes, I must." locals[2] = 62; // "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] = 63; // "If thou dost insist, thou canst have them." locals[24] = 64; // "No! Thou shalt not take them!" if ( do_demand( 2, &locals[24], &locals[23] ) ) { private[1] = 1; } else { func_008b(); } // end if } // end func