Ultima Underworld/technical/conversations/218
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 #218 // string block 0x0eda (3802), name Griffle // // 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 ( private[0] == 1 ) { func_0681(); } else { say( "Who art thou? Art thou here to take me back to the mines? But no, thou art not one of them... Art thou here to rescue us, then?" ); locals[1] = 2; // "No, I am trapped here myself, for the time being." locals[2] = 3; // "Of course. But it may take a little while." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_02f1(); break; case 2: func_02f1(); } // end if break; } // end switch } // end func void func_02f1() { int locals[22]; say( "Ah, then, a prisoner like the rest of us..." ); locals[1] = 5; // "Why art thou being held prisoner?" locals[2] = 6; // "Only for the nonce." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0339(); break; case 2: func_0459(); break; } // end switch } // end func void func_0339() { int locals[22]; say( "Tyball keeps us here. To work the mines 'til we die... if we're lucky that is. Less fortunate ones he takes away to work his evil magicks on." ); locals[1] = 8; // "What dost thou mean by "evil magicks"?" locals[2] = 9; // "I shall have to attend to this Tyball." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0381(); break; case 2: func_0459(); break; } // end switch } // end func void func_0381() { int locals[22]; say( "There are caverns to the east, filled with the dead. Victims of his dark arts, gone awry. 'Tis said not even he dares venture there now. But the dead things wait, taking their vengeance on any living thing that enters." ); locals[1] = 11; // "Hmmm. Thou didst mention being forced to work the mines. Why?" locals[2] = 12; // "Dost thou know what he attempts with his arts?" locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_03c9(); break; case 2: func_0639(); break; } // end switch } // end func void func_03c9() { int locals[22]; say( "Who knows what we dig for? Mayhap materials he needs for his magic. But it's been days now since I've worked the mines, after what we found on the lower level... And so few of us remain, left to rot in our cells." ); locals[1] = 14; // "The mines are below this level?" locals[2] = 15; // "What heppened there?" locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0411(); break; case 2: func_0411(); break; } // end switch } // end func void func_0411() { int locals[22]; say( "We dug through to the level below this and hit a natural cavern. The walls were veined with gold, but that's not what we were digging for, I'm sure. It was here the fell beasts attacked us and killed most of us prisoners.\n" " The remaining few of us have been left here for days, with no food or water. If thou couldst spare a morsel..." ); locals[1] = 17; // "Certainly. Eat thy fill." locals[2] = 18; // "Thank thee for thy help." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_051d(); break; case 2: func_04a1(); break; } // end switch } // end func void func_0459() { int locals[22]; say( "Oh, a hero, eh? Ruddy great! Won't Tyball have a time with thee!" ); locals[1] = 20; // "What has this Tyball been doing?" locals[2] = 21; // "Why, what dost thou mean?" locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0381(); break; case 2: func_04d5(); break; } // end switch } // end func void func_04a1() { int locals[22]; say( "Farewell, then, and good luck!" ); locals[1] = 23; // "Farewell." locals[2] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); if ( locals[22] == 1 ) { func_00e0(); } // end if } // end func void func_04d5() { int locals[22]; say( "What I mean is that Tyball eats heroes the way a sailor eats limes!" ); locals[1] = 25; // "Well, I trust he'll find me a sour morsel." locals[2] = 26; // "And what exactly has he been doing?" locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_04a1(); break; case 2: func_0639(); break; } // end switch } // end func void func_051d() { int locals[63]; locals[16] = show_inv( 2, &locals[6], &locals[1] ); locals[18] = 0; locals[19] = 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] + count_inv( 1, &locals[5] ); locals[19] = locals[19] + 1; locals[10] = locals[5]; } // end if locals[16] = locals[16] - 1; } // while if ( locals[18] > 0 ) { give_to_npc( 2, &locals[11], &locals[19] ); say( "Many thanks! Thou art a hero as far as I am concerned, just for sharing thy food!" ); locals[20] = 28; // "Thou art most welcome. Excuse me now, I must be going." locals[21] = 0; // "" locals[41] = babl_menu( 0, &locals[20] ); if ( locals[41] == 1 ) { func_04a1(); } // end if } else { } // end if say( "Hast thou no food for me?" ); locals[42] = 30; // "Here is some." locals[43] = 31; // "I'm afraid not." locals[44] = 0; // "" locals[63] = babl_menu( 0, &locals[42] ); switch ( locals[63] ) { case 1: func_051d(); break; case 2: func_04a1(); break; } // end switch } // end func void func_0639() { int locals[22]; say( "I am no sorcerer. Whatever he attempts, though, it can mean no good!" ); locals[1] = 33; // "Agreed. Excuse me, I must go do what I can to thwart his plan." locals[2] = 34; // "I will be on my toes." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_04a1(); break; case 2: func_04a1(); break; } // end switch } // end func void func_0681() { int locals[3]; locals[1] = random( 1, &locals[2] ); locals[2] = 3; locals[3] = locals[1]; if ( 1 == locals[3] ) { say( "I'm too weak to talk." ); } else { if ( 2 == locals[3] ) { say( "Get away, before the guards come back!" ); } else { if ( 3 == locals[3] ) { say( "Farewell, friend! I'm too weak to talk!" ); } // end if } // end if } // end if } // end func void func_06c9() { int locals[44]; setup_to_barter( 0 ); while ( !private[1] ) { locals[1] = 38; // "I make thee this offer." locals[2] = 39; // "I demand thou givest me these items." locals[3] = 40; // "Excuse me, I must think about this deal." locals[4] = 41; // "I do not wish to barter any further." locals[5] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_077a(); break; case 2: func_07d4(); break; case 3: do_judgement( 0 ); break; case 4: do_decline( 0 ); private[1] = 1; break; } // end switch } // while locals[23] = 42; // "Farewell." locals[24] = 0; // "" locals[44] = babl_menu( 0, &locals[23] ); if ( locals[44] == 1 ) { private[1] = 1; } // end if } // end func void func_077a() { int locals[15]; locals[0] = -1; locals[6] = -1; locals[11] = 43; // "I accept thy offer." locals[12] = 44; // "No, I do not like this deal." locals[13] = 45; // "Dost thou take me for a fool?" locals[14] = 46; // "I am weary of this haggling." locals[15] = 47; // "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_07d4() { int locals[24]; say( "Dost thou intend to rob me?" ); locals[1] = 49; // "Yes, I must." locals[2] = 50; // "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] = 51; // "If thou dost insist, thou canst have them." locals[24] = 52; // "No! Thou shalt not take them!" if ( do_demand( 2, &locals[24], &locals[23] ) ) { private[1] = 1; } else { func_008b(); } // end if } // end func