Ultima Underworld/technical/conversations/215
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 #215 // string block 0x0ed7 (3799), name Smonden // // 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() { int locals[22]; if ( private[0] == 1 ) { func_03fa(); } else { global[0] = 0; say( "I shall tell thee nothing, thou minion of Tyball!" ); locals[1] = 2; // "Thou dost misjudge me. I am Tyball's foe." locals[2] = 3; // "This is Tyball's blood upon my weapon, fool!" locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_04dc(); break; case 2: func_04dc(); } // end if break; } // end switch } // end func void func_02f6() { int locals[22]; say( "I was captured while on a quest for the Key of Courage." ); locals[1] = 5; // "I also seek the Key." locals[2] = 6; // "That is too bad. Didst thou achieve any success?" locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_033e(); break; case 2: func_044c(); break; } // end switch } // end func void func_033e() { int locals[22]; say( "Indeed? Then know this: I believe the entrance lies directly north of this very spot." ); locals[1] = 8; // "What else knowest thou of this entrance?" locals[2] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); if ( locals[22] == 1 ) { func_0372(); } // end if } // end func void func_0372() { int locals[22]; say( "A locked door blocks the way. But I still have the key hidden here in my cell. The key to the Key, as it were." ); locals[1] = 10; // "May I have this key?" locals[2] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); if ( locals[22] == 1 ) { func_03a6(); } // end if } // end func void func_03a6() { int locals[1]; say( "Yes, for I have been imprisoned too long and have neither heart nor strength left for this quest." ); locals[1] = 1016; take_from_npc( 1, &locals[1] ); say( "It is thine." ); global[0] = 1; func_03c9(); } // end func void func_03c9() { int locals[22]; locals[1] = 13; // "I thank thee." locals[2] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); if ( locals[22] == 1 ) { func_00e0(); } // end if } // end func void func_03fa() { int locals[3]; if ( !global[0] ) { func_056c(); } else { locals[1] = random( 1, &locals[2] ); locals[2] = 3; locals[3] = locals[1]; if ( 1 == locals[3] ) { say( "I am too weary to talk." ); } else { if ( 2 == locals[3] ) { say( "Go on, do what thou must." ); } else { if ( 3 == locals[3] ) { say( "Farewell, friend! I shall leave here as soon as I rest a bit." ); } // end if } // end if } // end if } // end if } // end func void func_044c() { int locals[22]; say( "Nay, for even as I discovered the location of my objective, I was captured by Tyball. He seemed to think I had been speaking with his deceased brother, ridiculous as that sounds. He would not release me. A pity, since I believed that the recovery of the three keys would help right the wrongs of this place." ); locals[1] = 18; // "If thou wilt entrust me with thy knowledge, I shall take up thy quest." locals[2] = 19; // "I shall set thee free and thou canst continue thy quest." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_033e(); break; case 2: func_0494(); break; } // end switch } // end func void func_0494() { int locals[22]; say( "No, I cannot! I am too weak now. Would that thou could continue my quest for me!" ); locals[1] = 21; // "I would be glad to." locals[2] = 22; // "Perhaps." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_033e(); break; case 2: func_033e(); break; } // end switch } // end func void func_04dc() { int locals[22]; say( "Of course! I have not seen thee in the ranks of his lackeys. How may I help thee?" ); locals[1] = 24; // "Well, tell me what it is that hast brought thee here." locals[2] = 25; // "How may I help thee?" locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_02f6(); break; case 2: func_0524(); break; } // end switch } // end func void func_0524() { int locals[22]; say( "Nay, thou canst not help me! My freedom is not restored by unlocking these bars, for I am in ill health and can no longer follow my quest: to find the Key of Courage." ); locals[1] = 27; // "Truly, then, I shall undertake to complete thy quest for thee." locals[2] = 28; // "Oh, well, never mind, then." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_033e(); break; case 2: func_00c2(); break; } // end switch } // end func void func_056c() { int locals[22]; say( "Please, thou must undertake to complete my quest. Seek thou the Key of Courage." ); locals[1] = 30; // "Very well. Where is it?" locals[2] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); if ( locals[22] == 1 ) { func_033e(); } // end if } // end func void func_05a0() { int locals[44]; setup_to_barter( 0 ); while ( !private[1] ) { locals[1] = 31; // "I make thee this offer." locals[2] = 32; // "I demand thou givest me these items." locals[3] = 33; // "Excuse me, I must think about this deal." locals[4] = 34; // "I do not wish to barter any further." locals[5] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0651(); break; case 2: func_06ab(); break; case 3: do_judgement( 0 ); break; case 4: do_decline( 0 ); private[1] = 1; break; } // end switch } // while locals[23] = 35; // "Farewell." locals[24] = 0; // "" locals[44] = babl_menu( 0, &locals[23] ); if ( locals[44] == 1 ) { private[1] = 1; } // end if } // end func void func_0651() { int locals[15]; locals[0] = -1; locals[6] = -1; locals[11] = 36; // "I accept thy offer." locals[12] = 37; // "No, I do not like this deal." locals[13] = 38; // "Dost thou take me for a fool?" locals[14] = 39; // "I am weary of this haggling." locals[15] = 40; // "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_06ab() { int locals[24]; say( "Dost thou intend to rob me?" ); locals[1] = 42; // "Yes, I must." locals[2] = 43; // "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] = 44; // "If thou dost insist, thou canst have them." locals[24] = 45; // "No! Thou shalt not take them!" if ( do_demand( 2, &locals[24], &locals[23] ) ) { private[1] = 1; } else { func_008b(); } // end if } // end func