Ultima Underworld/technical/conversations/24

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 #24 // string block 0x0e18 (3608), name prisoner // // 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[27]; if ( private[0] == 0 ) { private[4] = 0; } // end if locals[1] = 0; if ( get_quest( 1, &locals[1] ) == 1 ) { func_0bcb(); } else { locals[2] = 7; if ( get_quest( 1, &locals[2] ) == 1 ) { locals[3] = 15; locals[4] = 0; set_attitude( 2, &locals[4], &locals[3] ); func_0bcb(); } else { if ( private[4] == 1 ) { func_0646(); } else { locals[5] = 1; // "He points to his mouth and shakes his head." print( 1, &locals[5] ); locals[6] = 2; // "Art thou hungry?" locals[7] = 3; // "Art thou mute?" locals[8] = 0; // "" locals[27] = babl_menu( 0, &locals[6] ); switch ( locals[27] ) { case 1: func_0350(); break; case 2: func_03a3(); } // end if } // end if } // end if break; } // end switch } // end func void func_0350() { int locals[23]; locals[1] = 4; // "He nods, but looks agitated. He makes a talking motion with his hand next to his mouth, then shakes his head no." print( 1, &locals[1] ); locals[2] = 5; // "Oh. Thou'rt mute AND hungry!" locals[3] = 6; // "I imagine I can guess thy name." locals[4] = 0; // "" locals[23] = babl_menu( 0, &locals[2] ); switch ( locals[23] ) { case 1: func_03a3(); break; case 2: func_03f6(); break; } // end switch } // end func void func_03a3() { int locals[23]; locals[1] = 7; // "He nods his head unhappily." print( 1, &locals[1] ); locals[2] = 8; // "Canst thou tell me thy name?" locals[3] = 9; // "Here's something to eat." locals[4] = 0; // "" locals[23] = babl_menu( 0, &locals[2] ); switch ( locals[23] ) { case 1: func_03f6(); break; case 2: func_04a5(); break; } // end switch } // end func void func_03f6() { int locals[23]; locals[1] = 10; // "His eyes light up, and with great effort he grunts out something that sounds like "Uurghoo."" print( 1, &locals[1] ); locals[2] = 11; // "I have it. Thy name is ... " locals[3] = 12; // "I'm sorry, I cannot understand thee." locals[4] = 0; // "" locals[23] = babl_menu( 0, &locals[2] ); switch ( locals[23] ) { case 1: private[3] = babl_ask( 0 ); func_05d2(); break; case 2: func_0452(); break; } // end switch } // end func void func_0452() { int locals[23]; locals[1] = 13; // "His face takes on an expression of almost comical sadness. Then he shrugs elaborately." print( 1, &locals[1] ); locals[2] = 14; // "Canst thou not leave? Art a prisoner?" locals[3] = 15; // "Here is some food." locals[4] = 0; // "" locals[23] = babl_menu( 0, &locals[2] ); switch ( locals[23] ) { case 1: func_0769(); break; case 2: func_04a5(); break; } // end switch } // end func void func_04a5() { int locals[64]; locals[16] = show_inv( 2, &locals[6], &locals[1] ); locals[18] = 0; while ( locals[16] != 0 ) { locals[17] = locals[0]; if ( ((((((locals[17] == 176 || locals[17] == 177) || locals[17] == 178) || locals[17] == 179) || locals[17] == 180) || locals[17] == 181) || locals[17] == 182) ) { locals[18] = locals[18] + 1; locals[10] = locals[5]; } // end if locals[16] = locals[16] - 1; } // while if ( locals[18] > 0 ) { give_to_npc( 2, &locals[11], &locals[18] ); locals[19] = 16; // "He gobbles it down as though he hasn't eaten in weeks." print( 1, &locals[19] ); locals[20] = 17; // "Art thou a prisoner here?" locals[21] = 18; // "What is thy name?" locals[22] = 0; // "" locals[41] = babl_menu( 0, &locals[20] ); switch ( locals[41] ) { case 1: func_0769(); break; case 2: func_03f6(); } // end if } else { break; } // end switch locals[42] = 19; // "He looks at you disappointedly." print( 1, &locals[42] ); locals[43] = 20; // "Oh, here is thy food." locals[44] = 21; // "I'm sorry, I have no food. Art thou a prisoner here?" locals[45] = 0; // "" locals[64] = babl_menu( 0, &locals[43] ); switch ( locals[64] ) { case 1: func_04a5(); break; case 2: func_0769(); break; } // end switch } // end func void func_05d2() { int locals[25]; locals[1] = 22; if ( compare( 2, &locals[1], 34 ) ) { func_065e(); } else { locals[2] = 23; // "He shakes his head sadly, and seems to give up on name-guessing. He mimes being in a cage." print( 1, &locals[2] ); locals[3] = 24; // "Art thou a prisoner here?" locals[4] = 25; // "I cannot understand thee!" locals[5] = 0; // "" locals[24] = babl_menu( 0, &locals[3] ); switch ( locals[24] ) { case 1: func_0769(); break; case 2: locals[25] = 3; func_00b1( &locals[25] ); } // end if break; } // end switch } // end func void func_0646() { int locals[1]; locals[1] = 26; // "He seems delighted to see you again, capering happily. Then he waits expectantly." print( 1, &locals[1] ); func_080f(); } // end func void func_065e() { int locals[48]; locals[2] = 27; // "He nods his head excitedly, a smile creasing his ugly face." print( 1, &locals[2] ); locals[1] = get_quest( 1, &locals[3] ); locals[3] = 2; if ( locals[1] ) { locals[4] = 28; // "He performs a flawless imitation of Dr. Owl that you're sure the bitter old man would not appreciate, then looks at you expectantly." print( 1, &locals[4] ); } else { locals[5] = 29; // "He does an imitation which looks to be of a mad old wizard." print( 1, &locals[5] ); } // end if locals[27] = locals[1]; locals[6] = 30; // "Yes, I've spoken to Dr. Owl. He is in search of thee." locals[28] = 1; locals[7] = 31; // "What can I do for thee?" locals[29] = 1; locals[8] = 32; // "I'm sorry, I have no time for games." locals[9] = 0; // "" locals[48] = babl_fmenu( 0, &locals[6], &locals[27] ); switch ( locals[48] ) { case 30: func_0716(); break; case 31: func_0716(); break; case 32: func_00c2(); break; } // end switch } // end func void func_0716() { int locals[23]; locals[1] = 33; // "He looks crestfallen, then mimes being a prisoner." print( 1, &locals[1] ); locals[2] = 34; // "Thou art a prisoner of the Lizardmen? Why?" locals[3] = 35; // "It serves thee right!" locals[4] = 0; // "" locals[23] = babl_menu( 0, &locals[2] ); switch ( locals[23] ) { case 1: func_0769(); break; case 2: func_00c2(); break; } // end switch } // end func void func_0769() { int locals[23]; locals[1] = 36; // "He nods sadly, then performs a complicated series of charades that seem to indicate that he is innocent.\n He mimes vicious Lizardmen grabbing a wide-eyed victim and laughing heartily as they fling him in this cell.\n He implores you, by gestures, to speak to the Lizardmen and get him released." print( 1, &locals[1] ); locals[2] = 37; // "I'm sorry, but I don't understand their language." locals[3] = 38; // "No, I'd rather not get involved." locals[4] = 0; // "" locals[23] = babl_menu( 0, &locals[2] ); switch ( locals[23] ) { case 1: func_07bc(); break; case 2: func_00c2(); break; } // end switch } // end func void func_07bc() { int locals[23]; locals[1] = 39; // "He gestures at himself indicating that HE understands the tongue of the Lizardmen. Further, he makes signs that seem to say the Lizardmen understand YOUR speech, but cannot pronounce human talk themselves." print( 1, &locals[1] ); locals[2] = 40; // "Very well. If thou wishest to teach me lizard tongue, I will try." locals[3] = 41; // "No, I'm sorry. I can do no such thing." locals[4] = 0; // "" locals[23] = babl_menu( 0, &locals[2] ); switch ( locals[23] ) { case 1: func_080f(); break; case 2: func_00c2(); break; } // end switch } // end func void func_080f() { int locals[25]; private[4] = 1; locals[1] = 42; // "He indicates that you must supply a word, and he will translate it for you." print( 1, &locals[1] ); while ( 1 ) { locals[2] = 43; // "Very well, I'll be back later." locals[3] = 44; // "What does "sseth" mean?" locals[4] = 46; // "How about "'click"?" locals[5] = 48; // "Other..." locals[6] = 0; // "" locals[23] = babl_menu( 0, &locals[2] ); switch ( locals[23] ) { case 1: locals[24] = 3; func_00b1( &locals[24] ); break; case 2: private[2] = 45; func_08bf(); break; case 3: private[2] = 47; func_08bf(); break; case 4: private[2] = babl_ask( 0 ); func_08bf(); break; } // end switch locals[25] = 49; // "He indicates for you to try again." print( 1, &locals[25] ); } // while } // end func void func_08bf() { int locals[43]; locals[1] = 50; if ( compare( 2, &locals[1], 33 ) ) { locals[2] = 51; // "He nods his head yes." print( 1, &locals[2] ); } else { locals[3] = 52; if ( compare( 2, &locals[3], 33 ) ) { locals[4] = 53; // "He shakes his head no." print( 1, &locals[4] ); } else { locals[5] = 54; if ( compare( 2, &locals[5], 33 ) ) { locals[6] = 55; // "He eyes you suspiciously." print( 1, &locals[6] ); } else { locals[7] = 56; if ( compare( 2, &locals[7], 33 ) ) { locals[8] = 57; // "He mimes giving assistance." print( 1, &locals[8] ); } else { locals[9] = 58; if ( compare( 2, &locals[9], 33 ) ) { locals[10] = 59; // "He scowls and acts aggressive toward you." print( 1, &locals[10] ); } else { locals[11] = 60; if ( compare( 2, &locals[11], 33 ) ) { locals[12] = 61; // "He smiles and acts friendly toward you." print( 1, &locals[12] ); } else { locals[13] = 62; if ( compare( 2, &locals[13], 33 ) ) { locals[14] = 63; // "He points to his mouth, chews, and rubs his belly." print( 1, &locals[14] ); } else { locals[15] = 64; if ( compare( 2, &locals[15], 33 ) ) { locals[16] = 65; // "He smiles and acts friendly toward you." print( 1, &locals[16] ); } else { locals[17] = 66; if ( compare( 2, &locals[17], 33 ) ) { locals[18] = 67; // "He puffs up his chest and pretends to be leading a crowd, then mimes removing his hat and shedding a tear." print( 1, &locals[18] ); } else { locals[19] = 68; if ( compare( 2, &locals[19], 33 ) ) { locals[20] = 69; // "He mimes hitting someone." print( 1, &locals[20] ); } else { locals[21] = 70; if ( compare( 2, &locals[21], 33 ) ) { locals[22] = 71; // "He mimes picking your pocket." print( 1, &locals[22] ); } else { locals[23] = 72; if ( compare( 2, &locals[23], 33 ) ) { locals[24] = 73; // "He mimes strangling someone to death." print( 1, &locals[24] ); } else { locals[25] = 74; if ( compare( 2, &locals[25], 33 ) ) { locals[26] = 75; // "He points to himself, then takes your hand and makes you point to yourself." print( 1, &locals[26] ); } else { locals[27] = 76; if ( compare( 2, &locals[27], 33 ) ) { locals[28] = 77; // "He points to you, and takes your hand and makes you point to him." print( 1, &locals[28] ); } else { locals[29] = 78; if ( compare( 2, &locals[29], 33 ) ) { locals[30] = 79; // "He points to himself." print( 1, &locals[30] ); } else { locals[31] = 80; if ( compare( 2, &locals[31], 33 ) ) { locals[32] = 81; // "He imitates a Lizardman." print( 1, &locals[32] ); } else { locals[33] = 82; if ( compare( 2, &locals[33], 33 ) ) { locals[34] = 83; // "He pantomimes a greeting." print( 1, &locals[34] ); } else { locals[35] = 84; if ( compare( 2, &locals[35], 33 ) ) { locals[36] = 85; // "He holds his arms out and looks imploringly at you." print( 1, &locals[36] ); } else { locals[37] = 86; if ( compare( 2, &locals[37], 33 ) ) { locals[38] = 87; // "He acts out someone taking many things from a sack and giving them to another, then shakes his head." print( 1, &locals[38] ); } else { locals[39] = 88; if ( compare( 2, &locals[39], 33 ) ) { locals[40] = 89; // "He mimes going away and then returning." print( 1, &locals[40] ); } else { locals[41] = 90; if ( compare( 2, &locals[41], 33 ) ) { locals[42] = 91; // "He pretends to give you a gift." print( 1, &locals[42] ); } else { locals[43] = 92; // "He shrugs his shoulders, indicating he doesn't recognize the phrase." print( 1, &locals[43] ); } // end if } // end if } // end if } // end if } // end if } // end if } // end if } // end if } // end if } // end if } // end if } // end if } // end if } // end if } // end if } // end if } // end if } // end if } // end if } // end if } // end if } // end func void func_0bcb() { int locals[50]; locals[1] = get_quest( 1, &locals[2] ); locals[2] = 2; locals[3] = 93; // "He looks at you with wild joy in his eyes and launches into a mad, capering dance of joy. Then he turns to you and signs his thanks." print( 1, &locals[3] ); locals[25] = locals[1]; locals[4] = 94; // "Get thee now to Dr. Owl, and steal no more food!" locals[26] = 1; locals[5] = 95; // "Go now and steal no more!" locals[27] = 1; locals[6] = 96; // "Farewell, and enjoy thy freedom!" locals[7] = 0; // "" locals[46] = babl_fmenu( 0, &locals[4], &locals[25] ); switch ( locals[46] ) { case 94: break; case 95: break; case 96: break; } // end switch remove_talker( 0 ); locals[47] = 97; // "You see him scamper off down the hallway, jumping up and down with joy." print( 1, &locals[47] ); locals[48] = 0; locals[49] = 1; set_quest( 2, &locals[49], &locals[48] ); locals[50] = 3; func_00b1( &locals[50] ); } // end func