Ultima Underworld/technical/conversations/17

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 #17 // string block 0x0e11 (3601), name Sethar Strongarm // // 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] ) { if ( global[0] ) { func_04ed(); } else { if ( global[1] ) { func_0484(); } else { func_0348(); } // end if } // end if } else { say( "A human! When I was younger, I beat up many humans like you. A fine troll I was!" ); locals[1] = 2; // "I'm sure thou wert." locals[2] = 3; // "Thou still dost seem very powerful to me." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0300(); break; case 2: func_0300(); } // end if break; } // end switch } // end func void func_0300() { int locals[22]; say( "Thank you, you nice human. Ah, those were days. Lots of glory, nice treasure. Now I happy with simpler things." ); locals[1] = 5; // "Like what?" locals[2] = 6; // "Dost thou still have some of this treasure?" locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0390(); break; case 2: func_0439(); break; } // end switch } // end func void func_0348() { int locals[22]; say( "You here again? You go lots of places. I like that once, go fight things, do things, take things. Now I stay here." ); locals[1] = 8; // "Wouldst thou like anything?" locals[2] = 9; // "What kind of things didst thou collect?" locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0390(); break; case 2: func_0439(); break; } // end switch } // end func void func_0390() { int locals[22]; global[1] = 1; say( "Oh, I would love wormy stew. My mother she made it when I just a little troll. You have any?" ); locals[1] = 11; // "Yes, here is some." locals[2] = 12; // "No, but I will look for some." locals[3] = 13; // "No. How is it made?" locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0503(); break; case 2: func_00e0(); break; case 3: func_03f1(); break; } // end switch } // end func void func_03f1() { int locals[22]; say( "Hmm... I no remember. I know you use dead rotworm. My mother knew, but she dead. Maybe someone else. Oh, that stew delicious!" ); locals[1] = 15; // "I will try to make some." locals[2] = 16; // "I will seek out someone who knows the recipe." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_00e0(); break; case 2: func_00e0(); break; } // end switch } // end func void func_0439() { int locals[22]; say( "Hmm, let me see... Aha! I still have dragon scales. I kill nasty dragon when I was a young troll. Big and breathed fire. It could sit on lava forever without burning up. I kill it and save its scales. Never use them though. Now I old troll, I like simple pleasures, I no need them. Maybe if you give me something, I trade for scales." ); locals[1] = 18; // "What wouldst thou like?" locals[2] = 19; // "Maybe I can trade thee some gold." locals[3] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0390(); break; case 2: say( "No, I no need treasure any more. Just simple nice things like wormy stew." ); func_0390(); break; } // end switch } // end func void func_0484() { int locals[22]; say( "Hello, you again! You bring wormy stew for me?" ); locals[1] = 22; // "Yes, here it is." locals[2] = 23; // "I still have not made it." locals[3] = 24; // "It is still cooking." locals[4] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); switch ( locals[22] ) { case 1: func_0503(); break; case 2: func_04e0(); break; case 3: func_04e0(); break; } // end switch } // end func void func_04e0() { say( "Oh, please bring it when you done!" ); func_00e0(); } // end func void func_04ed() { int locals[1]; say( "It human again! Good luck with what you do. That stew delicious!" ); locals[1] = 3; func_00b1( &locals[1] ); } // end func void func_0503() { int locals[24]; if ( func_057b() ) { func_05b1(); } else { locals[1] = 1; say( "You give me stew?" ); while ( locals[1] ) { locals[2] = 28; // "Here it is." locals[3] = 30; // "I'm sorry, I don't have it." locals[4] = 0; // "" locals[23] = babl_menu( 0, &locals[2] ); switch ( locals[23] ) { case 1: if ( func_057b() ) { func_05b1(); } else { say( "I no see stew." ); } // end if break; case 2: locals[1] = 0; break; } // end switch } // while say( "You make me sad, pretend to have stew and then not." ); locals[24] = 1; func_00b1( &locals[24] ); } // end if } // end func void func_057b() { int locals[3]; locals[1] = find_barter( 1, &locals[2] ); locals[2] = 283; if ( locals[1] == 0 ) { } else { locals[3] = -1; give_ptr_npc( 2, &locals[3], &locals[1] ); } // end if } // end func void func_05b1() { int locals[2]; say( "Oh, wormy stew, just what I love. Here, take dragon scales. Maybe they help you not get hurt when you go hot places, just like dragon." ); locals[1] = take_from_npc( 1, &locals[2] ); locals[2] = 285; if ( (locals[1] == 1 || locals[1] == 2) ) { if ( locals[1] == 2 ) { say( "Your arms full, I leave on floor." ); } // end if global[0] = 1; } else { say( "Huh, where they go? I no find." ); } // end if func_05f4(); } // end func void func_05f4() { int locals[22]; locals[1] = 35; // "Farewell." locals[2] = 0; // "" locals[22] = babl_menu( 0, &locals[1] ); if ( locals[22] == 1 ) { func_00e0(); } // end if } // end func