Ultima Underworld/technical/conversations/212

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 #212 // string block 0x0ed4 (3796), name Kallistan // // 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() { if ( private[0] == 1 ) { func_0506(); } else { func_02b3(); } // end if } // end func void func_02b3() { int locals[22]; say( "Who be ye?" ); locals[1] = 2; // "I am @GS12. Who art thou?" locals[2] = 3; // "None of thy business!" locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_02fb(); break; case 2: func_05be(); break; } // end switch } // end func void func_02fb() { int locals[22]; say( "I be Kallistan. What do ye here, @GS12?" ); global[2] = 1; locals[1] = 5; // "I am seeking a way out of these infernal prisons." locals[2] = 6; // "I am a friend of Tyball's." locals[3] = 7; // "I seek to rid this area of a certain evil wizard." locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_035c(); break; case 2: func_03a4(); break; case 3: func_03ec(); break; } // end switch } // end func void func_035c() { int locals[22]; say( "Go back the way ye came, then, ye craven!" ); locals[1] = 9; // "I am no coward. I seek to defeat Tyball." locals[2] = 10; // "Very well. Good riddance!" locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_03ec(); break; case 2: func_00c2(); break; } // end switch } // end func void func_03a4() { int locals[22]; say( "Any friend o' that whoreson be no friend o' mine!" ); locals[1] = 12; // "Quite right. I was only testing thee." locals[2] = 13; // "Then I suppose I must be going." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_03ec(); break; case 2: func_05be(); break; } // end switch } // end func void func_03ec() { int locals[22]; say( "An' what proof have ye that ye're nae from the very wizard himself?" ); locals[1] = 15; // "I am a confidant of Goldthirst's!" locals[2] = 16; // "Thou shalt just have to trust me." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0434(); break; case 2: func_0606(); break; } // end switch } // end func void func_0434() { int locals[24]; say( "Well, ye'll be knowin' the password t' his hoard, then, won't ye?" ); locals[2] = 18; // "Indeed I do know it! 'Tis ..." locals[3] = 20; // "Nay, I'm afraid not. Thou shalt have to trust me." locals[4] = 0; // "" locals[23] = babl_menu( 0, &locals[2] ); switch ( locals[23] ) { case 1: locals[1] = babl_ask( 0 ); locals[24] = 19; if ( contains( 2, &locals[1], &locals[24] ) ) { func_0576(); } else { func_05be(); } // end if break; case 2: func_0606(); break; } // end switch } // end func void func_049d() { int locals[22]; if ( global[2] == 1 ) { say( "What ye want now, @GS12?" ); } else { say( "What ye want now?" ); } // end if locals[1] = 23; // "I am seeking a way out of these infernal prisons." locals[2] = 24; // "I am a friend of Tyball's." locals[3] = 25; // "I seek to rid this area of a certain evil wizard." locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_035c(); break; case 2: func_03a4(); break; case 3: func_03ec(); break; } // end switch } // end func void func_0506() { int locals[23]; if ( global[0] == 0 ) { func_049d(); } else { if ( global[1] == 1 ) { say( "I've nothing more to say to ye, ungrateful lout. Begone!" ); func_00d1(); } else { if ( global[2] == 1 ) { say( "What can I do for thee now, @GS12?" ); } else { say( "And what want ye now?" ); } // end if locals[2] = 29; // "Nothing. I will be on my way." locals[3] = 30; // "Tell me again of the tombs." locals[4] = 0; // "" locals[23] = babl_menu( 0, &locals[2] ); switch ( locals[23] ) { case 1: func_00e0(); break; case 2: func_0815(); } // end if } // end if break; } // end switch } // end func void func_0576() { int locals[22]; say( "Well, then, ye be a hero to th' Clan, an' most welcome here! What can I do for ye?" ); locals[1] = 32; // "I need thy help to find and defeat Tyball." locals[2] = 33; // "Nothing, thanks." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_06f2(); break; case 2: func_00e0(); break; } // end switch } // end func void func_05be() { int locals[22]; say( "Get ye gone from here, ye mangy dog!" ); locals[1] = 35; // "Very well. Excuse me." locals[2] = 36; // "Good riddance!" locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_00c2(); break; case 2: func_00c2(); break; } // end switch } // end func void func_0606() { int locals[22]; say( "Trust ye? Well, If I must, I must. But first, ye shall swear to me an oath, that ye mean no weal t' Tyball an' his lackeys." ); locals[1] = 38; // "Very well." locals[2] = 39; // "I shall do no such thing." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_064e(); break; case 2: func_05be(); break; } // end switch } // end func void func_064e() { int locals[22]; say( "Swear, then!" ); locals[1] = 41; // "I swear by my body and by my blood that I am no friend of Tyball's." locals[2] = 42; // "I swear by my sword that I mean Tyball no good!" locals[3] = 43; // "I swear by all the virtues that Tyball and I are foes!" locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_06aa(); break; case 2: func_06aa(); break; case 3: func_06aa(); break; } // end switch } // end func void func_06aa() { int locals[22]; say( "Very well. Know then, that if ye be forsworn, all that ye hast sworn upon will turn against ye!" ); locals[1] = 45; // "I have no fear. I stand by my oath." locals[2] = 46; // "I hereby recant and void my oath." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_06f2(); break; case 2: func_05be(); break; } // end switch } // end func void func_06f2() { int locals[23]; say( "Here. Take ye this splinter of crystal." ); locals[1] = 273; if ( take_from_npc( 1, &locals[1] ) == 2 ) { say( "Ye seem heavily laden, so I'll leave it here for ye." ); } // end if locals[2] = 49; // "What is it?" locals[3] = 0; // "" locals[23] = babl_menu( 0, &locals[2] ); if ( locals[23] == 1 ) { func_073d(); } // end if } // end func void func_073d() { int locals[22]; say( "I found it three days ago while at my labors in the mines. At night it makes a faint, eerie keening. I've heard rumors of others who've found its like, and before long they're off searching for the tombs from which it came." ); locals[1] = 51; // "Why give it to me?" locals[2] = 52; // "I don't want it." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_07cd(); break; case 2: func_0785(); break; } // end switch } // end func void func_0785() { int locals[22]; say( "It will do thee no harm, and may even help thee. I believe it may give thee access to the tombs." ); locals[1] = 54; // "I told thee I don't want it." locals[2] = 55; // "Why should I enter the tombs?" locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0815(); break; case 2: func_0815(); break; } // end switch } // end func void func_07cd() { int locals[22]; say( "I believe the tombs to be of my ancient ancestors, built here long before the colony of the Abyss was formed. I've dreamt of them since finding the crystal." ); locals[1] = 57; // "Again, why give this crystal to me?" locals[2] = 58; // "And what lies in the tombs?" locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0815(); break; case 2: func_0815(); break; } // end switch } // end func void func_0815() { int locals[22]; say( "The way I figure it, the tombs have been defiled by an evil presence. This entity places the crystal where it'll be found, in order to draw unwary souls to its lair. I ask ye - find these tombs and cleanse them of this evil, so that others do not fall into this trap." ); locals[1] = 60; // "And why should I do this?" locals[2] = 61; // "I will do what I can." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_085d(); break; case 2: func_085d(); break; } // end switch } // end func void func_085d() { int locals[22]; say( "If ye can do this, I'm sure the beast responsible will have collected a sizable hoard from his victims. Ye may find the items useful in your quest against Tyball. But beware - disturb not the tombs themselves. Search for the entrance to the south of these prisons, where the pit trap spiders prowl. Carry the crystal with ye in your search - it may prove to be helpful." ); global[0] = 1; locals[1] = 63; // "Thank thee, I will see if thy suppositions prove to be true." locals[2] = 64; // "I think imprisonment has addled thy brain. However, I will take the crystal just in case..." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_00e0(); break; case 2: global[1] = 1; func_00d1(); break; } // end switch } // end func void func_08af() { int locals[44]; setup_to_barter( 0 ); while ( !private[1] ) { locals[1] = 65; // "I make thee this offer." locals[2] = 66; // "I demand thou givest me these items." locals[3] = 67; // "Excuse me, I must think about this deal." locals[4] = 68; // "I do not wish to barter any further." locals[5] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0960(); break; case 2: func_09ba(); break; case 3: do_judgement( 0 ); break; case 4: do_decline( 0 ); private[1] = 1; break; } // end switch } // while locals[23] = 69; // "Farewell." locals[24] = 0; // "" locals[44] = babl_menu( 0, &locals[23] ); if ( locals[44] == 1 ) { private[1] = 1; } // end if } // end func void func_0960() { int locals[15]; locals[0] = -1; locals[6] = -1; locals[11] = 70; // "I accept thy offer." locals[12] = 71; // "No, I do not like this deal." locals[13] = 72; // "Dost thou take me for a fool?" locals[14] = 73; // "I am weary of this haggling." locals[15] = 74; // "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_09ba() { int locals[24]; say( "Dost thou intend to rob me?" ); locals[1] = 76; // "Yes, I must." locals[2] = 77; // "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] = 78; // "If thou dost insist, thou canst have them." locals[24] = 79; // "No! Thou shalt not take them!" if ( do_demand( 2, &locals[24], &locals[23] ) ) { private[1] = 1; } else { func_008b(); } // end if } // end func