Ultima Underworld/technical/conversations/16

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 #16 // string block 0x0e10 (3600), name Ishtass // // 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[23]; if ( !private[0] ) { global[0] = 0; global[1] = 0; global[2] = 0; } // end if if ( private[0] == 1 ) { func_066d(); } // end if say( "A greeting to you I give. Ishtass I am known as. What thing you are wanting?" ); locals[1] = 2; // "Amazing. You speak my language!" locals[2] = 3; // "Nothing, but I thank thee. Excuse me." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_030d(); break; case 2: locals[23] = 3; func_00b1( &locals[23] ); break; } // end switch } // end func void func_030d() { int locals[22]; say( "Though by other Thepa the Quiet Ones my people are called, this an irony is. We alone of the Thepa your language can speak." ); locals[1] = 5; // "And very well, too." locals[2] = 6; // "Who are the Thepa?" locals[3] = 7; // "Please, I must go now." locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_036c(); break; case 2: func_03de(); break; case 3: func_00b1( 24 ); break; } // end switch } // end func void func_036c() { int locals[22]; npc_attitude = npc_attitude + 1; if ( npc_attitude > 3 ) { npc_attitude = 3; } // end if say( "Not easy it is, but we try. Now, you in some need are?" ); locals[1] = 9; // "Who are the Thepa?" locals[2] = 10; // "Wouldst have any tales for me?" locals[3] = 11; // "No, thank you. I must be going." locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_03de(); break; case 2: func_048e(); break; case 3: func_00c2(); break; } // end switch } // end func void func_03de() { int locals[22]; say( "The Thepa my folk are. By you Lizardmen they are called." ); locals[1] = 13; // "Ah. Can you perhaps translate their speech for me?" locals[2] = 14; // "Interesting. Canst tell me any history?" locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0426(); break; case 2: func_048e(); break; } // end switch } // end func void func_0426() { int locals[23]; say( "Nay, against our oaths it goes. We a humble order are, sworn secrets to keep. Perhaps one among your people the True Speech knows." ); locals[1] = 16; // "Perhaps. Thanks anyway." locals[2] = 17; // "Thanks for nothing!" locals[3] = 18; // "Canst talk with me?" locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_00b1( 24 ); break; case 2: locals[23] = 2; func_00b1( &locals[23] ); break; case 3: func_048e(); break; } // end switch } // end func void func_048e() { int locals[46]; if ( npc_attitude < 2 ) { say( "Nay. A stranger thou art. We cannot thee help." ); locals[1] = 20; // "Thanks anyway." locals[2] = 21; // "Very well. I shall respect thy oaths." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: locals[23] = 1; func_00b1( &locals[23] ); break; case 2: locals[24] = 2; func_00b1( &locals[24] ); } // end if break; } // end switch if ( global[0] == 0 ) { say( "Wouldst mad wizard know of?" ); } else { say( "Wouldst mad wizard story again hear?" ); } // end if locals[25] = 24; // "Please, tell me more." locals[26] = 25; // "I tire of this talk. Goodbye." locals[27] = 0; // "" locals[46] = babl_menu( 0, &locals[25] ); switch ( locals[46] ) { case 1: func_0540(); break; case 2: func_00b1( 24 ); break; } // end switch } // end func void func_0540() { int locals[91]; global[0] = 1; say( "After Sir Cabirus death, mumbling wizard began upriver working. He talked with me after, as your strange tongue we know. Spoke he, who nameless remains, of a Great Sword, apart he broke." ); locals[1] = 27; // "Tell me more!" locals[2] = 28; // "Please talk no more. I must go." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: break; case 2: func_00b1( 24 ); break; } // end switch say( "I cannot more much say. For favor I will more information get." ); locals[23] = 30; // "Please tell me what favor thou dost want." locals[24] = 31; // "I do not have time for such bother. Bye." locals[25] = 32; // "Thank you for your story. Good bye, kind sir." locals[26] = 0; // "" locals[44] = babl_menu( 0, &locals[23] ); switch ( locals[44] ) { case 1: break; case 2: locals[45] = 1; func_00b1( &locals[45] ); break; case 3: locals[46] = 3; func_00b1( &locals[46] ); break; } // end switch say( "Ossikka, leader of ours, upstream travelled, a great many-armed water beast known to Thepa as kri'kla to kill. He returned never. Would you him find?" ); locals[47] = 34; // "I cannot at this time. Perhaps later." locals[48] = 35; // "I will search for your leader!" locals[49] = 0; // "" locals[68] = babl_menu( 0, &locals[47] ); switch ( locals[68] ) { case 1: func_00b1( 24 ); break; case 2: break; } // end switch say( "Upstream Ossikka travelled, returning never. Book of mad wizard had he, perhaps telling more. Return with news and the Quiet One will reward handsomely you." ); global[1] = 1; locals[69] = 37; // "I shall search for Ossikka." locals[70] = 0; // "" locals[90] = babl_menu( 0, &locals[69] ); if ( locals[90] == 1 ) { locals[91] = 3; func_00b1( &locals[91] ); } // end if } // end func void func_066d() { int locals[69]; if ( npc_attitude >= 2 && global[1] == 0 ) { locals[1] = 1; } else { if ( npc_attitude == 1 ) { locals[3] = 1; } else { locals[3] = 0; } // end if locals[1] = 0; } // end if if ( global[1] == 1 && global[2] == 0 ) { locals[2] = 1; } else { locals[2] = 0; } // end if locals[4] = npc_attitude; if ( 1 == locals[4] ) { say( "Not welcome here thou art!" ); } else { if ( 2 == locals[4] ) { say( "What you here brings?" ); } else { if ( 3 == locals[4] ) { say( "Again, a greeting to you I give." ); } // end if } // end if } // end if locals[26] = 1; locals[5] = 41; // "Your pardon, I must be going." locals[27] = locals[3]; locals[6] = 42; // "Wait! Please help me!" locals[28] = locals[2]; locals[7] = 43; // "I have news of Ossikka!" locals[29] = locals[1]; locals[8] = 44; // "Dost have any news of the world?" locals[30] = global[2]; locals[9] = 45; // "I have more questions about the sword." locals[10] = 0; // "" locals[47] = babl_fmenu( 0, &locals[5], &locals[26] ); switch ( locals[47] ) { case 41: func_00b1( 24 ); break; case 42: break; case 43: func_07e1(); break; case 44: func_048e(); break; case 45: func_09ba(); break; } // end switch say( "Of you I worry. Perhaps I should not help." ); locals[48] = 47; // "Fine. I bid thee goodbye." locals[49] = 48; // "Oh, please, kind Ishtass. Can you not help me?" locals[50] = 0; // "" locals[69] = babl_menu( 0, &locals[48] ); switch ( locals[69] ) { case 1: func_00b1( 24 ); break; case 2: break; } // end switch npc_attitude = 2; say( "Is good thing Ishtass nice. Many civilized groups are still found in the Abyss and must be treated with much kindness. Important it is to know this." ); func_048e(); } // end func void func_07e1() { int locals[111]; say( "Please, adventurer, what Ossikka news have you?" ); locals[14] = 51; // "I have found this." locals[15] = 52; // "No news yet. Sorry." locals[16] = 0; // "" locals[35] = babl_menu( 0, &locals[14] ); switch ( locals[35] ) { case 1: break; case 2: func_00b1( 24 ); break; } // end switch label_0827:; locals[12] = 0; locals[11] = show_inv( 2, &locals[6], &locals[1] ); while ( locals[11] != 0 ) { locals[36] = 0; locals[37] = -1; locals[38] = -1; locals[39] = -1; locals[40] = -1; locals[41] = -1; locals[42] = -1; x_obj_stuff( 9, &locals[42], &locals[41], &locals[40], &locals[12], &locals[39], &locals[38], &locals[37], &locals[36], &locals[5] ); if ( locals[12] == 67 ) { locals[43] = -1; give_ptr_npc( 2, &locals[43], &locals[5] ); locals[11] = 0; } else { locals[11] = locals[11] - 1; } // end if } // while if ( locals[12] != 67 ) { say( "This nothing me tells. Please something of Ossikka find?" ); locals[44] = 54; // "I will continue my search." locals[45] = 55; // "Oh. How about this?" locals[46] = 0; // "" locals[65] = babl_menu( 0, &locals[44] ); switch ( locals[65] ) { case 1: func_00b1( 24 ); break; case 2: goto label_0827; } // end if } else { break; } // end switch say( "Why yes, of this Ossikka did have. Oh, what means this?" ); locals[66] = 57; // "I found his bones in a room upstream." locals[67] = 0; // "" locals[87] = babl_menu( 0, &locals[66] ); if ( locals[87] == 1 ) { } // end if say( "Sorry day, indeed. Still, thank you. Here, a gift for you is." ); locals[13] = take_from_npc_inv( 1, &locals[88] ); locals[88] = 1; if ( locals[13] > 0 ) { if ( take_id_from_npc( 1, &locals[13] ) == 2 ) { say( "On floor, I leave it for you." ); } // end if } // end if global[2] = 1; locals[89] = 60; // "Thank you very much." locals[90] = 61; // "Canst thou now tell me of the sword?" locals[91] = 0; // "" locals[110] = babl_menu( 0, &locals[89] ); switch ( locals[110] ) { case 1: locals[111] = 3; func_00b1( &locals[111] ); break; case 2: func_09ba(); break; } // end switch } // end func void func_09ba() { int locals[45]; say( "What you to know want?" ); locals[2] = 63; // "You have told me enough. Thank you." locals[3] = 64; // "Where can I find the Sword?" locals[4] = 0; // "" locals[23] = babl_menu( 0, &locals[2] ); switch ( locals[23] ) { case 1: func_00b1( 24 ); break; case 2: break; } // end switch say( "Sword in two pieces broken is. Wizard took haft below. Ossikka clue to blade found, he said. Blade somewhere in our domain is, I think. More than that I do not know." ); locals[24] = 66; // "Thank you for your help." locals[25] = 67; // "I will continue my search." locals[26] = 0; // "" locals[45] = babl_menu( 0, &locals[24] ); switch ( locals[45] ) { case 1: func_00e0(); break; case 2: func_00e0(); break; } // end switch } // end func