home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1993 #2 / Image.iso / games1 / dcg303xa.zip / MERCHANT.SCR < prev    next >
Text File  |  1993-06-27  |  12KB  |  394 lines

  1. !
  2. ! Default merchant script..
  3. !
  4. ! (c) DC Software, 1993
  5. !
  6. ! Pending Enhancements
  7. !
  8. ! - I need to create a voice file (.VFL) with voices for this script.
  9. !   Look at the 'voice()' entries to see what voices it would play if
  10. !   they were available.  These voices could even be placed in the
  11. !   system's voice file (DCSOUNDS.VFL) in which case the voice command
  12. !   should read 'voice( xxxx, 1000 )'.
  13. !
  14.  
  15. !------------------------------------------------------------------------!
  16. :@TALK ! Talk to the character !
  17. !------------------------------------------------------------------------!
  18.  
  19.   if player.hp = 0 then
  20.     writeln( player.name, " is dead!" );
  21.     STOP;
  22.   endif;
  23.  
  24.   if npc.picture >= 0 then
  25.     viewpcx(npc);
  26.   endif;
  27.  
  28. ! First, say hello.. !
  29.   if NPC.V0 > 0 then
  30.     writeln( "Hello ", player.name, ". What brings you back?" );
  31.   else
  32.     writeln( "Welcome to ", npc.name, ". How may I help you?" );
  33.   endif;
  34.  
  35. ! Now, set some variables..
  36.   NPC.V0 = 1; ! From know on, remember we've been here
  37.   L1 = 0;     ! No items have been SOLD to the player
  38.   L2 = 0;     ! No items have been BOUGHT from the player
  39.  
  40. ! Then start a loop and show a menu..
  41. :LOOP
  42.   L3 = select( "Buy", "Sell", "Identify", "Talk", "Bye" );
  43.   on L3 goto BUY, SELL, GETINFO, CHAT;
  44.  
  45. ! ESCape and BYE get's us out of here..
  46. :CSTOP
  47.   if L1 = 0 and L2 = 0 then
  48.     writeln( "Next time buy something!" );
  49.   else
  50.     writeln( "It's been a pleasure doing business with you!" );
  51.   endif;
  52.   goto XSTOP;
  53.  
  54. !-------------------------------------------------!
  55. ! Player want's to buy something from us..        !
  56. !-------------------------------------------------!
  57. :BUY
  58.   L3 = select$( NPC );
  59.   if L3 < 0 goto LOOP;
  60.  
  61.   if NPC.BP.VALUE >= GROUP.GOLD then 
  62.     writeln( "You don't have enough money!");
  63.     voice( "Broke" );
  64.   else
  65.     if npc.bp.type = FOOD and npc.bp.class = NONE then
  66.       L10 = 255 - group.food; ! Max food we can carry !
  67.       if L10 < npc.bp.count then
  68.         L11 = npc.bp.count - L10;
  69.         writeln( "{You have to carry ", L11, " in your backpack}" );
  70.         inc( group.food, L10 );
  71.         copy( npc.bp, player, L11 ); ! Put L11 foods in the backpack !
  72.         if failure then
  73.           L12 = failure - 1;
  74.           writeln( "{The excess merchandize is placed on the floor!}" );
  75.           drop( npc.bp, -L12 ); ! Negative count means "drop a copy" !
  76.         endif;
  77.       else
  78.         inc( group.food, npc.bp.count );
  79.       endif;
  80.     else
  81.       L12 = npc.bp.count;
  82.       copy( NPC.BP, PLAYER );
  83.       if failure then
  84.         ! Value of failure is # that DID NOT get moved (+1) !
  85.         L11 = failure - 1;
  86.         if L12 > 1 then
  87.           if L11 < L12 then
  88.             writeln( "You can only carry {", L11, "} of them!" );
  89.           else
  90.             writeln( "You can't carry them!" );
  91.           endif;
  92.         else
  93.           writeln( "You can't carry it!" );
  94.         endif;
  95.         writeln( "The ", npc.bp.name, " is ON THE FLOOR!" );
  96.         if npc.x = player.x then
  97.           L13 = npc.x;
  98.           L14 = player.y + sgn(npc.y - player.y);
  99.         else
  100.           L13 = player.x + sgn(npc.x - player.x);
  101.           L14 = npc.y;
  102.         endif;
  103.         drop( npc.bp, -L11, L13, L14 ); ! Leave a copy (-) under the PLAYER !
  104.       endif;
  105.     endif;
  106.     dec ( GROUP.GOLD, NPC.BP.VALUE );
  107.     inc ( L1 );                     ! Sold 1 item to the PLAYER !
  108.     writeln( "SOLD: ", NPC.BP.COUNT, " ", NPC.BP.NAME, " for ", $NPC.BP.VALUE );
  109.     voice( "Sold" );
  110.   endif;
  111.   goto BUY;
  112.  
  113. !
  114. ! Player want's to sell something to us..
  115. !
  116. :SELL
  117.   L3 = select$2( PLAYER, matching ); ! Shows only thing's that I might want to buy  !
  118.   if L3 < 0 then
  119.     if L3 = -2 then   ! No items in the player's backpack !
  120.       if L2 > 0 then
  121.         writeln( "You have no more items to sell." );
  122.         voice( "NonLeft" );
  123.       else
  124.         writeln( "You have no items to sell." );
  125.         voice( "NoItems" );
  126.       endif;
  127.     endif;
  128.     if L3 = -3 then   ! No items of the type(s) I sell in the backpack !
  129.       if L2 > 0 then
  130.         writeln( "You have no more items that I would like to buy." );
  131.         voice( "NonLeft" );
  132.       else
  133.         writeln( "You have no items that I would like to buy." );
  134.         voice( "NoItems" );
  135.       endif;
  136.     endif;
  137.     goto LOOP;
  138.   endif;
  139.  
  140. ! Buy an item at half price (it's used) !
  141.   if player.bp.count > 1 then
  142.     L10 = getnum( "Sell how many?", 0, player.bp.count );
  143.   else
  144.     L10 = 1;
  145.   endif;
  146.   if L10 > 0 then
  147.     if player.bp.type = FOOD and player.bp.class = POISON then
  148.       writeln( "Sorry. This food is poisoned.  Anything else?" );
  149.       goto SELL;
  150.     endif;
  151.     L4 = (PLAYER.BP.VALUE+1) / 2;   ! Price paid for the item.
  152.     if L10 > 1 then
  153.       writeln( "Here is ", $L4, " for each of your ", L10, " ", PLAYER.BP.NAME, "s" );
  154.     else
  155.       writeln( "Here is ", $L4, " for your ", PLAYER.BP.NAME );
  156.     endif;
  157.     voice( "Bought" );
  158.     inc( group.gold, L4*L10 );     ! Pay the player for the items
  159.     inc( L2 );                     ! Bought 1 item from the player !
  160.  
  161.     ! Now, see if we have an exact or approximate match
  162.     for L11 = 0 to 15 do
  163.       setbp( npc, L11 );
  164.       if npc.bp.count > 0               and
  165.          npc.bp.name  = player.bp.name  and
  166.          npc.bp.type  = player.bp.type  and
  167.          npc.bp.class = player.bp.class and
  168.          npc.bp.value = player.bp.value goto REMOVEIT;
  169.     endfor;
  170.     ! Merchant does not have an identical item, so we will copy 1 (one)
  171.     ! item into the backpack for later resale
  172.     !
  173.     ! Note: The assumption is that the 'value' field contains the
  174.     ! UNIT value.  If the player had 20 items, we paid 20 x value, so
  175.     ! we keep 1 copy and sell each for 'value' amount.
  176.     copy( player.bp, npc, 1 );
  177.  
  178.     :REMOVEIT
  179.     if L10 < player.bp.count then
  180.       dec( player.bp.count, L10 ); ! Remove the items we sold
  181.     else
  182.       player.bp.count = 0;         ! Zap the items
  183.     endif;
  184.   else
  185.     writeln( "Maybe another item? <ESC> for go back" );
  186.   endif;
  187.  
  188.   goto SELL;
  189.  
  190. !
  191. ! Player want's to know about some of the items he has..
  192. !
  193. :GETINFO
  194.   writeln( "Let me see.. What do you wish to identify?" );
  195.   L3 = select$2( PLAYER, matching ); ! Item's I know about !
  196.   if L3 < 0 then
  197.     if L3 = -2 then   ! No items in the player's backpack !
  198.       if L2 > 0 then
  199.         writeln( "You have no more items!" );
  200.         voice( "NonLeft" );
  201.       else
  202.         writeln( "Your backpack is empty!" );
  203.         voice( "NoItems" );
  204.       endif;
  205.     endif;
  206.     if L3 = -3 then   ! No items of the type(s) I sell in the backpack !
  207.       if L2 > 0 then
  208.         writeln( "There are no other items I can identify!" );
  209.         voice( "NonLeft" );
  210.       else
  211.         writeln( "There are no items that I can identify!" );
  212.         voice( "NoItems" );
  213.       endif;
  214.     endif;
  215.     goto LOOP;
  216.   endif;
  217.  
  218. ! Identify the selected item
  219.   L4 = (player.bp.value+7) / 8;
  220.   writeln( "The fee is ", $L4, ". Do you pay it?" );
  221.   L11 = select( "Yes", "No" );
  222.   if L11 = 0 then ! Yes !
  223.     if group.gold < L4 then
  224.       writeln( "You don't have enough money!" );
  225.       voice( "Broke" );
  226.       goto LOOP;
  227.     endif;
  228.     gosub DESCRIBE;
  229.     writeln( "What name do you want to give it? <ESC>=none" );
  230.     L3 = getstr();
  231.     if L3 = -2 then ! -1 = <ESC>, -2 = Any string not in the list (No List) !
  232.       player.bp.name = S0;
  233.     else
  234.       writeln( "ok" );
  235.     endif;
  236.     dec( group.gold, L4 );
  237.   else
  238.     writeln( "Maybe another item? <ESC> to go back" );
  239.   endif;
  240.  
  241.   goto GETINFO;
  242.  
  243. !-------------------------------------------------------------------!
  244. ! Describe an item (player's BP)                                    !
  245. !-------------------------------------------------------------------!
  246. :DESCRIBE
  247.  
  248.   if player.bp.count < 0 then
  249.     writeln( "I don't know what you're talking about" );
  250.     return;
  251.   endif;
  252.  
  253.   write( "Name: ", player.bp.name, ", Type: ", player.bp.type );
  254.  
  255.   if player.bp.type = FOOD or player.bp.type = POTION  then
  256.     if player.bp.class then
  257.       write( ", Class: ", player.bp.class );
  258.       if player.bp.class <> CURE then
  259.         write( ", Units: ", player.bp.units );
  260.       endif;
  261.     else
  262.       write( ", it has no special properties" );
  263.     endif;
  264.   elsif player.bp.type = WEAPON then
  265.     write( ", Class: ", player.bp.class, 
  266.            ", Hands: ", player.bp.hands, 
  267.            ", Range: ", player.bp.range, 
  268.            ", Damage: ", player.bp.damage );
  269.     if player.bp.ammoneeded then
  270.       write( ", Needs ammo type: ", player.bp.ammo_type );
  271.     endif;
  272.   elsif player.bp.type = AMMO then
  273.     write( ", Ammo Type: ", player.bp.ammotype );
  274.     if player.bp.traptype then
  275.       write( ", Poisoned" );
  276.     endif;
  277.     if player.bp.damage then
  278.       write( ", Extra Damage: ", player.bp.damage );
  279.     endif;
  280.   elsif player.bp.type = ARMOR or player.bp.type = SHIELD then
  281.     write( ", Armor Class: ", player.bp.ac );
  282.     if player.bp.cursed then
  283.       write( " Cursed!" );
  284.     endif;
  285.   elsif player.bp.type = AMULET or player.bp.type = RING or player.bp.type = GEMS then
  286.     if player.bp.class then
  287.       write( ", Class: ", player.bp.class );
  288.       write( ", Charges: ", player.bp.charges );
  289.       if player.bp.class <> CURE then
  290.         write( ", Units: ", player.bp.units );
  291.         if player.bp.permanent then
  292.           write( ", Permanent!" );
  293.         else
  294.           write( ", Temporary" );
  295.         endif;
  296.       endif;
  297.       if player.bp.cursed then
  298.         write( ", Cursed!" );
  299.       endif;
  300.     endif;
  301.   elsif player.bp.type = SCROLL then
  302.     write( ", Class: ", player.bp.class );
  303.   elsif player.bp.type = STAFF then
  304.     write( ", Class: ", player.bp.class, ", Charges: ", player.bp.charges );
  305.   elsif player.bp.type = CHEST then
  306.     if player.bp.locktype then
  307.       write( ", Locked!" );
  308.       if player.bp.traptype = 0 then
  309.         write( ", no traps" );
  310.       elsif player.bp.traptype = 1 then
  311.         write( ", poison trap" );
  312.       else
  313.         write( ", bomb damage: ", player.bp.traptype );
  314.       endif;
  315.     endif;
  316. ! elsif player.bp.type = KEYS     then
  317. !   nothing special about it
  318. ! elsif player.bp.type = BOOK     then
  319. !   nothing special about it
  320. ! elsif player.bp.type = GOLDSACK then
  321. !   nothing special about it
  322. ! elsif player.bp.type = TORCH    then
  323. !   nothing special about it
  324. ! elsif player.bp.type = LANTERN  then
  325. !   nothing special about it
  326. ! elsif player.bp.type = ROPE     then
  327. !   nothing special about it
  328. ! elsif player.bp.type = HOOKS    then
  329. !   nothing special about it
  330. ! elsif player.bp.type = MIRROR   then
  331. !   nothing special about it
  332. ! elsif player.bp.type = SIGN     then
  333. !   nothing special about it
  334.   elsif player.bp.type = VEHICLE then
  335.     write( ", Class: ", player.bp.class );
  336. ! else
  337. !   user defined type?
  338.   endif;
  339.   if player.bp.weight > 1 and player.bp.weight < 256 then
  340.     write( ", Weight: ", player.bp.weight );
  341.   endif;
  342.   writeln( "." );
  343.   return;
  344.  
  345.  
  346.  
  347.  
  348.  
  349.  
  350.  
  351. !
  352. ! Handle conversation..
  353. !
  354. :CHAT
  355.   writeln( "What would you like to talk about?" );
  356.  
  357. :CHAT1
  358.   L3 = getstr("Name","Buy","Sell","Credit","Job","Bye");
  359.   if L3 = -1 then 
  360.     writeln( "Ok." );
  361.     goto LOOP; ! Pressed ESCape !
  362.   endif;
  363.  
  364. ! First, see if the keyword typed is in the character's text block !
  365.   if dotext( S0 ) then
  366.     if L3 = 5 goto XSTOP;
  367.     goto CHAT1;
  368.   endif;
  369.  
  370. ! It didn't, so try the predefined ones..
  371.   on L3 goto CNAME, BUY, SELL, CCREDIT, CJOB, CSTOP;
  372.  
  373. ! Nope, try a 'DEFAULT' line
  374.   if not dotext( "DEFAULT" ) then
  375.     writeln( "I don't know anything about that!" );
  376.   endif;
  377.   goto CHAT1;
  378.  
  379. :CNAME   writeln( "My name is ", NPC.name, "." ); GOTO CHAT1;
  380. :CCREDIT writeln( "No credit sales, sorry!"    ); GOTO CHAT1;
  381. :CJOB    writeln( "I {buy} and {sell} things!" ); GOTO CHAT1;
  382.  
  383. ! Feel free to expand on this list.. !
  384.  
  385. !-----------------------------------------------------------------!
  386. ! All STOPs now lead here so the screen can be restored if needed !
  387. !-----------------------------------------------------------------!
  388. :XSTOP
  389.   if npc.picture >= 0 then
  390.     paint(window); ! Assumes the picture fits in the window !
  391.   endif;
  392.   STOP;
  393.  
  394.