Ultima Underworld/technical/conversations/136

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 #136 // string block 0x0e88 (3720), name Oradinar // // 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() { if ( private[0] == 0 ) { func_08cb(); private[2] = 0; private[3] = 0; } // end if if ( private[0] ) { func_0801(); } else { func_02c4(); } // end if } // end func void func_02c4() { int locals[22]; say( "Hail Stranger. What unhappy accident brings thee to the Abyss?" ); locals[1] = 2; // "I have been unjustly accused of a kidnapping." locals[2] = 3; // "I am attemping to rescue a girl." locals[3] = 4; // "I'd rather not speak of it." locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0325(); break; case 2: func_0325(); break; case 3: private[2] = 1; func_0920(); break; } // end switch } // end func void func_0325() { say( "Survival alone is an ambitious goal in the Abyss. Thou art a brave soul indeed if thou aspirest to aught beyond that." ); func_0332(); } // end func void func_0332() { int locals[66]; if ( play_hunger == 0 ) { locals[1] = 6; // "In sooth, I grow weak already from hunger." locals[2] = 7; // "My honor demands I pursue my quest against all opposition." locals[3] = 8; // "True, yet perhaps thou might assist me in my task." locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0469(); break; case 2: func_04d9(); break; case 3: func_0521(); } // end if } else { break; } // end switch if ( play_hunger < 64 ) { locals[23] = 9; // "I may succumb to hunger ere long." locals[24] = 10; // "Tell me more of the perils that lie ahead." locals[25] = 11; // "I must prove my innocence at any cost." locals[26] = 12; // "Yet, with thy aid, my chances might improve." locals[27] = 0; // "" locals[44] = babl_menu( 0, &locals[23] ); switch ( locals[44] ) { case 1: func_0569(); break; case 2: func_0611(); break; case 3: func_04d9(); break; case 4: func_0521(); } // end if } else { break; } // end switch locals[45] = 13; // "How dost thou survive amidst such peril?" locals[46] = 14; // "Canst tell me aught of what lies ahead?" locals[47] = 15; // "I will brook no opposition in my quest." locals[48] = 16; // "Canst thou aid in me in my quest?" locals[49] = 0; // "" locals[66] = babl_menu( 0, &locals[45] ); switch ( locals[66] ) { case 1: func_066d(); break; case 2: func_0611(); break; case 3: func_04d9(); break; case 4: func_0521(); break; } // end switch } // end func void func_0469() { int locals[23]; say( "By the bright and glittering stars of heaven, which I have not seen these many years, I wish I had food to give thee. Yet, I do not.\n" " I can, however, tell thee something which, as the ancient proverb states, may feed thee for life. Mind thee, many have been cast into the Abyss with the empty promises of the hypocrite Almric, and met with a far more grisly demise than mere starvation.\m" ); say( "Still, my words are as useless as shouting upwind in a hurricane. More to the point, thou mayest find a pond but a little north of here, where fish will leap from the water and onto thy pole, more numerous than vultures upon a carcass the jackals have forsaken." ); if ( private[3] == 1 ) { say( "If thou dost employ the pole I gave thee, thou shall have all the fish thou may desire." ); func_0920(); } else { say( "I have an extra pole, if thou dost need one." ); locals[1] = 21; // "I thank thee heartily for thy generosity." locals[2] = 22; // "Thou art kind, but I need it not." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: locals[23] = 299; take_from_npc( 1, &locals[23] ); private[3] = 1; func_07cd(); break; case 2: func_0920(); } // end if break; } // end switch } // end func void func_04d9() { int locals[22]; say( "I wish thee well. I once believed in noble causes myself. Now I find that just surviving is a noble enough fight. 'Tis easier to drink water from a sieve than escape from the Abyss alive. If thou dost seek trouble, it shall find thee 'ere long." ); locals[1] = 24; // "Farewell, and fortune favor thee." locals[2] = 25; // "I cannot shun the call of duty." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_00c2(); break; case 2: func_00e0(); break; } // end switch } // end func void func_0521() { int locals[22]; say( "I have little urge to seek trouble. I have outlived many in the Abyss by having the good sense to keep myself out of harm's way. Thou wouldst be wise to do the same." ); locals[1] = 27; // "Canst thou tell me anything that might aid me in my quest?" locals[2] = 28; // "I shall seek advice from one who lives more honorably. Good day." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_06c9(); break; case 2: func_00d1(); break; } // end switch } // end func void func_0569() { int locals[45]; say( "'Tis said that against hunger the gods themselves contend in vain. Still, Britannia was not built in a day. I can tell thee this much, at least: To the north but a short way is a pond, as full of fish as the day is long." ); if ( private[3] == 1 ) { say( "If thou but put the pole I gave thee to its proper use, thou shalt have fish aplenty." ); locals[1] = 31; // "'Sblood, that is sage advice, friend. I will go at once." locals[2] = 32; // "I fear fish do not agree with my stomach. Goodbye." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_00e0(); break; case 2: func_00c2(); } // end if } else { break; } // end switch say( "I have an extra fishing pole. Dost thou want it?" ); locals[23] = 34; // "Thank thee. I gladly accept thy pole." locals[24] = 35; // "'Tis a kind offer, but I have no need of it." locals[25] = 0; // "" locals[44] = babl_menu( 0, &locals[23] ); switch ( locals[44] ) { case 1: locals[45] = 299; take_from_npc( 1, &locals[45] ); private[3] = 1; func_07cd(); break; case 2: func_0920(); break; } // end switch } // end func void func_0611() { int locals[22]; say( "I fear I can tell thee little of what lies ahead. I have found that those seeking trouble in the nether regions of the Abyss find it eager to make their acquaintance." ); locals[1] = 37; // "How dost thou survive here, if thou liv'st in fear of thy own shadow?" locals[2] = 38; // "Surely thou knowest of thy immediate surroundings?" locals[3] = 39; // "Hast thou seen an evil wizard carrying a maiden?" locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_066d(); break; case 2: func_06c9(); break; case 3: func_0771(); break; } // end switch } // end func void func_066d() { int locals[22]; say( "I take care to keep myself far from trouble's path, and fish for my food." ); locals[1] = 41; // "Where dost thou fish in this place?" locals[2] = 42; // "I have more pressing matters to attend to." locals[3] = 43; // "Hast thou seen an evil wizard carrying a maiden?" locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_06c9(); break; case 2: func_00c2(); break; case 3: func_0771(); break; } // end switch } // end func void func_06c9() { int locals[45]; say( "If thou but venture northward, thou shalt soon come across a pond so thick with fish thou couldst walk across without getting thy boots wet." ); if ( private[3] == 1 ) { say( "Use the pole there, and thou shalt soon have food in abundance." ); locals[1] = 46; // "I shall. Thank thee." locals[2] = 47; // "Perhaps I shall later." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_00e0(); break; case 2: func_00c2(); } // end if } else { break; } // end switch say( "I can give thee my spare fishing pole, if thou dost need it." ); locals[23] = 49; // "I do need one. Thank thee kindly." locals[24] = 50; // "Thou art kind, but I need it not." locals[25] = 0; // "" locals[44] = babl_menu( 0, &locals[23] ); switch ( locals[44] ) { case 1: locals[45] = 299; take_from_npc( 1, &locals[45] ); private[3] = 1; func_07cd(); break; case 2: func_0920(); break; } // end switch } // end func void func_0771() { int locals[22]; say( "No I haven't. I think I should go now." ); locals[1] = 52; // "Good bye." locals[2] = 53; // "Thou shouldst learn more of Valor." locals[3] = 54; // "Look, there he is, right behind thee!" locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_00c2(); break; case 2: func_00d1(); break; case 3: func_0063(); break; } // end switch } // end func void func_07cd() { int locals[22]; say( "May thy casts be ever fruitful." ); locals[1] = 56; // "Thank thee, and thine too." locals[2] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); if ( locals[22] == 1 ) { func_00e0(); } // end if } // end func void func_0801() { int locals[44]; if ( private[2] == 1 ) { say( "Art feeling more talkative than when last I saw thee?" ); locals[1] = 58; // "No. I have no time for the likes of thee." locals[2] = 59; // "Aye. Who art thou?" locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_00d1(); break; case 2: private[2] = 0; func_08be(); } // end if } else { break; } // end switch if ( private[3] == 1 ) { say( "Greetings, friend! Hast thou caught any fish?" ); locals[23] = 61; // "Aye, more than the sands of the desert." locals[24] = 63; // "I have not tried." locals[25] = 64; // "Never mind that. Dost thou know aught of an evil wizard nearby?" locals[26] = 0; // "" locals[44] = babl_menu( 0, &locals[23] ); switch ( locals[44] ) { case 1: say( "Excellent!" ); func_0920(); break; case 2: func_0920(); break; case 3: func_0771(); } // end if } else { break; } // end switch say( "Welcome back! In sooth, thou art lucky to have survived so long, friend. The Abyss is a place of fearsome peril." ); func_0332(); } // end func void func_08be() { say( "I am an outcast, trying to survive amidst the fearsome perils of the Abyss. I am surprised thou hast lived so long in spite of thy surly disposition." ); func_0332(); } // end func void func_08cb() { private[4][1] = 1011; private[4][2] = 1002; private[4][3] = 1003; private[4][4] = 1000; private[4][5] = -1; private[25][1] = 161; private[25][2] = 160; private[25][3] = -1; set_likes_dislikes( 2, 56, 35 ); } // end func void func_0920() { int locals[22]; say( "Wouldst thou be interested in a trade?" ); locals[1] = 68; // "Yes." locals[2] = 69; // "No." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_096d(); break; case 2: goto label_0965; break; } // end switch label_0965:; return locals[1]; } // end func void func_096d() { int locals[44]; setup_to_barter( 0 ); while ( !private[1] ) { locals[1] = 70; // "I make thee this offer." locals[2] = 71; // "I demand thou givest me these items." locals[3] = 72; // "I beg thy pardon, I must think about this deal." locals[4] = 73; // "I do not wish to barter any further." locals[5] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0a1e(); break; case 2: func_0a60(); break; case 3: do_judgement( 0 ); break; case 4: do_decline( 0 ); private[1] = 1; break; } // end switch } // while locals[23] = 74; // "Farewell." locals[24] = 0; // "" locals[44] = babl_menu( 0, &locals[23] ); if ( locals[44] == 1 ) { private[1] = 1; } // end if } // end func void func_0a1e() { int locals[5]; locals[1] = 75; // "Thou hast a deal!" locals[2] = 76; // "Thy offer does not interest me" locals[3] = 77; // "What kind of fool dost thou take me for?" locals[4] = 78; // "I grow weary of this petty haggling." locals[5] = 79; // "That is no trade!" if ( do_offer( 5, &locals[5], &locals[4], &locals[3], &locals[2], &locals[1] ) ) { private[1] = 1; } // end if } // end func void func_0a60() { int locals[24]; say( "Art thou attempting to intimidate me into surrendering my possessions?" ); locals[1] = 81; // "Yes, I will deal thee grievous injury if thou dost not comply." locals[2] = 82; // "No, thou mistakest my meaning entirely." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: break; case 2: return; break; } // end switch locals[23] = 83; // "If thou art desperate enough to steal, I will not oppose thee." locals[24] = 84; // "Miscreant! I shall teach thee a lesson!" if ( do_demand( 2, &locals[24], &locals[23] ) ) { private[1] = 1; } else { func_008b(); } // end if } // end func