Ultima Underworld/technical/conversations/9

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 #9 // string block 0x0e09 (3593), name Vernix // // 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[22]; if ( npc_talkedto == 1 ) { func_04fd(); } else { say( "Yes?" ); locals[1] = 2; // "Greetings, Goblin-Lord." locals[2] = 3; // "All Hail the Most Mighty and Puissant Ruler of the Great and Noble Race of the Green Goblins." locals[3] = 4; // "Good day, your highness." locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0305(); break; case 2: func_034d(); break; case 3: func_0305(); } // end if break; } // end switch } // end func void func_0305() { int locals[22]; say( "Clearly, thou art a boor, unfit for the gentle company present here. Away with thee until thou hast learned to ape the manners of thy betters." ); locals[1] = 6; // "Thou shalt wait some time for my return! Goodbye!" locals[2] = 7; // "I beg thy pardon, your Majesty, I had not expected to meet such nobility here." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_00d1(); break; case 2: func_0405(); break; } // end switch } // end func void func_034d() { int locals[22]; say( "Fair greetings to thee. For what reason hast thou intruded on our court?" ); locals[1] = 9; // "I come seeking information." locals[2] = 10; // "I have quested long to drink from the fountain of thy wisdom, O pearl among kings." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_04b6(); break; case 2: func_0395(); break; } // end switch } // end func void func_0395() { int locals[22]; say( "True! I AM rather wise, come to think of it. What dost thou wish to know?" ); locals[1] = 12; // "Who was Sir Cabirus?" locals[2] = 13; // "What are these Talismans of which I hear?" locals[3] = 14; // "Tell me of the races of the Abyss." locals[4] = 15; // "How came you by that gorgeous cloak?" locals[5] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_04b6(); break; case 2: func_04b6(); break; case 3: func_04b6(); break; case 4: func_0507(); break; } // end switch } // end func void func_0405() { int locals[22]; say( "Well... Perhaps thou canst be forgiven. This place IS full of the most frightfully rude people. Thou mayst remain. What is thy need?" ); locals[1] = 17; // "Merely to partake in some small manner of thy vast knowledge." locals[2] = 18; // "Nothing. I'm leaving." locals[3] = 19; // "I require some information." locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0395(); break; case 2: func_00c2(); break; case 3: func_04b6(); break; } // end switch } // end func void func_0461() { int locals[3]; locals[1] = random( 1, &locals[2] ); locals[2] = 4; locals[3] = locals[1]; if ( 1 == locals[3] ) { say( "I've changed my mind about thee! Thou art indeed a ruffian! Get thee hence!" ); } else { if ( 2 == locals[3] ) { say( "Thou hast the manners of an acid slug! Get out of here!" ); } else { if ( 3 == locals[3] ) { say( "Thou art entirely too generous with thy time!" ); } else { if ( 4 == locals[3] ) { say( "Perhaps thou couldst stand a little further downwind?" ); } // end if } // end if } // end if } // end if } // end func void func_04b6() { int locals[22]; func_0461(); locals[1] = 24; // "I do most humbly crave thy pardon." locals[2] = 25; // "Thou art a dandified fool!" locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0405(); break; case 2: func_06c9(); break; } // end switch } // end func void func_04fd() { func_034d(); } // end func void func_0507() { int locals[22]; say( "It does suit me, doesn't it? I had it made especially for me. One simply doesn't find work like this underground.\n" " Well, perhaps the Mountain-folk do make a few nice things, but they tend toward metals rather than clothes.\n" " And of course the Seers -- the Ancient Illuminated Seers of the Moonstone, they call themselves -- they do nice work, too. But they generally tend more toward the literary than the sartorial arts." ); locals[1] = 27; // "Who was Sir Cabirus?" locals[2] = 28; // "What are these Talismans of which I hear?" locals[3] = 29; // "What are the power groups within the Abyss?" locals[4] = 30; // "And this hall? It is most beautiful." locals[5] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_04b6(); break; case 2: func_04b6(); break; case 3: func_04b6(); break; case 4: func_0577(); break; } // end switch } // end func void func_0577() { int locals[22]; say( "Well, one does what one can. Of course those awful Gray Goblins took all the really nice things with them when they stole away in the night -- this was just after Sir Cabirus died, you know, when things were falling apart -- and we've had to make do since then.\n" " One of these days I'm going to get some poison into Ketchaval or his ugly wife (which amounts to the same thing -- he's terribly henpecked, you know), and then we'll see what's what. King of the Gray Goblins, indeed.\m" ); say( "Why he's an upstart! His father was a horse-thief! But enough of this ... You wanted to know something? How can I help you?" ); locals[1] = 33; // "What are these Talismans of which I hear?" locals[2] = 34; // "I would like to know about Sir Cabirus." locals[3] = 35; // "Canst tell me more of the groups in the Abyss?" locals[4] = 36; // "'Tis very kind of thee to take time to help me, your majesty." locals[5] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_04b6(); break; case 2: func_04b6(); break; case 3: func_04b6(); break; case 4: func_05ea(); break; } // end switch } // end func void func_05ea() { int locals[22]; say( "Oh, mention it not! It is so seldom that I get a chance to speak to a really intelligent person!\n" " I mean, our allies the Lizardmen are nice enough, but the poor fellows can't speak a word of the common tongue. They understand it well enough, but the poor things don't have the mouth to speak it. And their language is so difficult! I know "Sseth" and "'click" mean "yes" and "no," but I don't know which is which!\m" ); say( "Then there are the Knights of the Crux Ansata -- they can talk well enough, but all they ever say is how many Trolls they've killed. Frightful bore, even if it does help keep the pest population down -- both kinds of pests, Knights AND Trolls, you know." ); locals[1] = 39; // "It must be a trial, even for one as noble as yourself." locals[2] = 40; // "What of these Talismans?" locals[3] = 41; // "I would like to know about Sir Cabirus." locals[4] = 42; // "Are there other groups here in the Abyss?" locals[5] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_065d(); break; case 2: func_04b6(); break; case 3: func_04b6(); break; case 4: func_04b6(); break; } // end switch } // end func void func_065d() { int locals[22]; say( "Oh, indeed it is! Sometimes I wonder how I even manage. It wasn't always like this, you know.\n" " When Sir Cabirus was alive, things were ever so much better. He had all of us working together so well. A born leader was that man.\n" " When he founded this colony you could have made a wager anywhere in Britannia that it wouldn't work, but he made it so.\n" " I still think one of those bastard Grays must have done him in. There were certain items, too...\m" ); say( "Well, I suppose it will do no harm to tell thee. Sir Cabirus collected eight great Talismans, each embodying a certain Virtue -- he was a great one for Virtue, was our Cabirus -- and it was well known that he intended them to come to the leaders of the various groups here in the Abyss. Well, WE never saw them. If they still exist, they must be lost.\n" " But I must be boring thee." ); locals[1] = 45; // "Well, actually, yes." locals[2] = 46; // "No, not at all." locals[3] = 47; // "I could listen forever, your Majesty, but I've taken enough of thy time." locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_06c9(); break; case 2: func_0711(); break; case 3: func_06bc(); break; } // end switch } // end func void func_06bc() { say( "Well, bless you, you're such a charming conversationalist. Please do visit again." ); func_00e0(); } // end func void func_06c9() { int locals[22]; say( "Well! I never!" ); locals[1] = 50; // "Well thou hast now!" locals[2] = 51; // "I beg thy pardon, but I must go now." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_00d1(); break; case 2: func_00c2(); break; } // end switch } // end func void func_0711() { int locals[22]; say( "Oh, thou'rt just saying that. I'm sure there's much more for thee to do than listen me me natter on.\n" " And if you should happen to meet "King" Ketchaval or "Queen" Retichall of the Gray Goblins, be a dear and stick a knife in them, would you?" ); locals[1] = 53; // "Farewell, your Majesty." locals[2] = 54; // "Goodbye, milord." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_00e0(); break; case 2: func_00e0(); break; } // end switch } // end func