Ultima Underworld/technical/conversations/140

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 #140 // string block 0x0e8c (3724), name Ree // // 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_02ee(); } else { say( "Lo fair person. Here we are in the ruins of what was once a great civilization, ruined by greed, despair, and pain." ); locals[1] = 2; // "That sounds horrible. What happened?" locals[2] = 3; // "Perhaps the people of the Abyss deserved such a fate." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_034a(); break; case 2: func_05d6(); } // end if break; } // end switch } // end func void func_02ee() { int locals[22]; say( "Thou art back, outsider from above. What dost thou think of our settlement here?" ); locals[1] = 5; // "To be honest, I am not that impressed." locals[2] = 6; // "It is quite nice." locals[3] = 7; // "It must have been quite something in the old days." locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_05d6(); break; case 2: func_034a(); break; case 3: func_034a(); break; } // end switch } // end func void func_034a() { int locals[22]; say( "In better times thou wouldst have seen our true glory. The splendor of our domain and righteousness of our cause were great indeed.\n" " But alas, the environs have changed and the walls have fallen down, the just have been silenced by the desperate, and not even the strongest among us can hope to rebuild what Cabirus wrought." ); locals[1] = 9; // "What was it like before?" locals[2] = 10; // "Perhaps it should never have been built." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0392(); break; case 2: func_05d6(); break; } // end switch } // end func void func_0392() { int locals[22]; say( "It was wonderful. We would visit the ceremonial hall every day. Sometimes we would go below and challenge the Golem to a test of might. There were marvelous banquets. The Mayors of towns throughout Britannia would come to marvel at our achievements. Now none can survive the dangers of this place long enough to reach us." ); locals[1] = 12; // "Well, I was able to reach thee." locals[2] = 13; // "A test of might?" locals[3] = 14; // "What have you done to make it better?" locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_03ee(); break; case 2: func_0436(); break; case 3: func_047f(); break; } // end switch } // end func void func_03ee() { int locals[22]; say( "Well, thou art an exception, the first outsider I've seen in this place in years." ); locals[1] = 16; // "Thou didst speak of a test of might." locals[2] = 17; // "Have you done anything to improve the area?" locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0436(); break; case 2: func_047f(); break; } // end switch } // end func void func_0436() { int locals[22]; say( "A Golem resides on an island surrounded by lava in the land of the Seers.\n" " We would take our swords and shields, leap onto the island, and battle the Golem. It was indestructable, but honorable and valorious. Though it could not be destroyed, it would congratulate thee if thou didst fight well.\n" " If thou wert good enough it would sometimes reward thee." ); locals[1] = 19; // "The Seers live below, correct?" locals[2] = 21; // "Thank thee." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: say( "Yes. If the Golem still exists, he would be there." ); break; case 2: break; } // end switch func_05fe(); } // end func void func_047f() { int locals[22]; say( "We have sent Knights on many quests to make certain things better. All met with grave perils. Some met with success. Some never returned." ); locals[1] = 23; // "I am glad to hear that some of the quests were successful." locals[2] = 24; // "Tell me about those who never returned." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0530(); break; case 2: func_04c7(); break; } // end switch } // end func void func_04c7() { int locals[22]; say( "We heard rumors that a powerful mage on the seventh level of the Abyss was kidnapping and killing people. We sent a party of our most valorous Knights to investigate. They never returned. We hope to mount an expedition to investigate, but our resources are limited." ); locals[1] = 26; // "Perhaps this is the same mage I seek." locals[2] = 27; // "I will investigate this mage myself." locals[3] = 28; // "Thank thee for thy time, and farewell." locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0523(); break; case 2: func_0523(); break; case 3: func_00e0(); break; } // end switch } // end func void func_0523() { say( "Be thou most careful! If our Knights were unable to defeat him, he must be powerful indeed." ); func_05fe(); } // end func void func_0530() { int locals[46]; locals[1] = get_quest( 1, &locals[3] ); locals[3] = 32; if ( locals[1] < 2 ) { locals[2] = 1; } else { locals[2] = 0; } // end if say( "Yes, we made great inroads against the trolls at first. And we nearly succeeded in clearing our own demesne of headlesses and other vermin. Our recent quests have been disasters, though, and our order is in trouble." ); locals[25] = 1; locals[4] = 31; // "What has gone wrong?" locals[26] = locals[2]; locals[5] = 32; // "I would like to join the order if possible." locals[6] = 0; // "" locals[46] = babl_fmenu( 0, &locals[4], &locals[25] ); switch ( locals[46] ) { case 31: func_04c7(); break; case 32: func_05b2(); break; } // end switch } // end func void func_05b2() { int locals[2]; say( "Seek out Dorna Ironfist, our leader, if thou wishest to join." ); locals[1] = 32; locals[2] = 1; set_quest( 2, &locals[2], &locals[1] ); func_05fe(); } // end func void func_05d6() { int locals[3]; locals[1] = sex( 2, &locals[3], &locals[2] ); locals[2] = 34; locals[3] = 35; say( "In the old days, thou wouldst not have said that! No one understands the splendor of Cabirus' achievements...\p Oh, thou wouldst not understand." ); func_05fe(); } // end func void func_05fe() { int locals[22]; locals[1] = 37; // "Farewell." locals[2] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); if ( locals[22] == 1 ) { func_00e0(); } // end if } // end func