Ultima Underworld/technical/conversations/189
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 #189 // string block 0x0ebd (3773), name Shenilor // // 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] ) { func_0528(); } else { say( "Hail, stranger! Hast thou come to enroll in the Academy?" ); locals[1] = 2; // "Yes, I have." locals[2] = 3; // "No, I have had enough schooling." locals[3] = 4; // "The Academy? I was not aware of such an institution." locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0302(); break; case 2: func_030f(); break; case 3: func_031c(); } // end if break; } // end switch } // end func void func_0302() { say( "That is too bad, for it has been closed for years now." ); func_0329(); } // end func void func_030f() { say( "'Twould not matter in any case, for the Academy has been closed for many a year." ); func_0329(); } // end func void func_031c() { say( "I am not surprised, for the Academy is now closed, and few remember its days of glory." ); func_0329(); } // end func void func_0329() { int locals[22]; say( "'Tis a pity that thou wert not here when Sir Cabirus was still alive. The Abyss was a thriving settlement, and our Academy was the center of it. Nobody seems to be interested in the higher arts any longer, though." ); locals[1] = 9; // "Indeed, simply to survive here is quite a feat." locals[2] = 10; // "But I am! Canst thou assist me in my search for knowledge?" locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0371(); break; case 2: func_049a(); break; } // end switch } // end func void func_0371() { int locals[22]; say( "This is so. Since the Academy was closed, most of us have been content merely to eke out a meager existence in some small corner of the Abyss." ); locals[1] = 12; // "And the Academy? Is there aught left of it now?" locals[2] = 13; // "I do not blame thee. The Abyss is truly a dangerous place." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_03b9(); break; case 2: func_0401(); break; } // end switch } // end func void func_03b9() { int locals[22]; say( "I am afraid our once proud Academy has been infested by creatures who have no interest in the knowledge and wisdom contained there. To them, its halls offer notihg more than convenient shelter. It pains my heart to think of the Academy's decline from the days of old." ); locals[1] = 15; // "What knowledge may one find in the Academy?" locals[2] = 16; // "I sympathize with thee. Surely 'twas once a wondrous place." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_049a(); break; case 2: func_0401(); break; } // end switch } // end func void func_0401() { int locals[22]; say( "Perhaps one day the Abyss will return to its former glory, but I begin to doubt it more and more. Ah, what I would not give to see the Academy restored!" ); locals[1] = 18; // "I doubt it will happen in our lifetime." locals[2] = 19; // "I would not give up hope." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0449(); break; case 2: func_0449(); break; } // end switch } // end func void func_0449() { int locals[23]; say( "It may be that thou art right. All I can do is hope." ); locals[1] = 21; // "I wish thee luck. Farewell!" locals[2] = 22; // "Does anything remain of the Academy's former days?" locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: locals[23] = 2; func_00b1( &locals[23] ); break; case 2: func_049a(); break; } // end switch } // end func void func_049a() { int locals[23]; say( "It is possible that in the old library of the Academy thou mayst be able to find some useful information. But be careful - many monsters inhabit the Academy these days." ); locals[1] = 24; // "Where is this library?" locals[2] = 25; // "Thank thee for thy help." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_04eb(); break; case 2: locals[23] = 2; func_00b1( &locals[23] ); break; } // end switch } // end func void func_04eb() { int locals[23]; say( "Enter the great hall of the Academy and head west. The library will be on thy left. Perhaps some of its books, and the knowledge contained therein, are still intact." ); locals[1] = 27; // "Thank thee." locals[2] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); if ( locals[22] == 1 ) { locals[23] = 2; func_00b1( &locals[23] ); } // end if } // end func void func_0528() { int locals[22]; say( "Greetings again! Hast thou discovered aught in the area of the Academy?" ); locals[1] = 29; // "No, nothing of any import." locals[2] = 30; // "Nothing remains of its former glory." locals[3] = 31; // "It is somewhat dilapidated, but perhaps it can yet be renovated." locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0584(); break; case 2: func_0584(); break; case 3: func_059a(); break; } // end switch } // end func void func_0584() { int locals[1]; say( "I am sorry to hear that. I fear that the best days of the Academy are past." ); locals[1] = 2; func_00b1( &locals[1] ); } // end func void func_059a() { int locals[1]; say( "Perhaps there is hope yet. When thy quest is done, perhaps thou canst return to see us restore the Academy to its former state of glory." ); locals[1] = 2; func_00b1( &locals[1] ); } // end func void func_05b0() { int locals[44]; setup_to_barter( 0 ); while ( !private[1] ) { locals[1] = 34; // "I make thee this offer." locals[2] = 35; // "I demand thou givest me these items." locals[3] = 36; // "Excuse me, I must think about this deal." locals[4] = 37; // "I do not wish to barter any further." locals[5] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0661(); break; case 2: func_06bb(); break; case 3: do_judgement( 0 ); break; case 4: do_decline( 0 ); private[1] = 1; break; } // end switch } // while locals[23] = 38; // "Farewell." locals[24] = 0; // "" locals[44] = babl_menu( 0, &locals[23] ); if ( locals[44] == 1 ) { private[1] = 1; } // end if } // end func void func_0661() { int locals[15]; locals[0] = -1; locals[6] = -1; locals[11] = 39; // "I accept thy offer." locals[12] = 40; // "No, I do not like this deal." locals[13] = 41; // "Dost thou take me for a fool?" locals[14] = 42; // "I am weary of this haggling." locals[15] = 43; // "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_06bb() { int locals[24]; say( "Dost thou intend to rob me?" ); locals[1] = 45; // "Yes, I must." locals[2] = 46; // "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] = 47; // "If thou dost insist, thou canst have them." locals[24] = 48; // "No! Thou shalt not take them!" if ( do_demand( 2, &locals[24], &locals[23] ) ) { private[1] = 1; } else { func_008b(); } // end if } // end func