!
! Default trainer script..
!
! (c) DC Software, 1992
!

!------------------------------------------------------------------------!
:@TALK ! Talk to the character !
!------------------------------------------------------------------------!

  if player.hp = 0 then
    writeln( player.name, " is dead!" );
    STOP;
  endif;

  if npc.picture >= 0 then
    viewpcx(npc);
  endif;

! First, say hello.. !
  if NPC.V0 > 0 then
    writeln( "Hello ", player.name, ". What brings you back?" );
  else
    writeln( "Welcome to ", npc.name, ". How may I help you?" );
  endif;

! Now, set some variables..
  NPC.V0 = 1; ! From know on, remember we've been here
  L1   = 0; ! No business transactions have taken place
  L15  = 0; ! Has not asked for credit.. 

  L4 = npc.value * (random(3)+1); ! Cost of STRENGTH training !
  L5 = npc.value * (random(3)+1); ! Cost of DEXERITY training !
  L6 = npc.value * (random(3)+1); ! Cost of AIM      training !
  L7 = npc.value * (random(3)+1); ! Cost of Speed    training !
  L8 = npc.value * (random(3)+1); ! Cost of IQ       training !

:LOOP

  L9 = random(5) + 2; ! Points given when training.. !

  L3 = select$( "Strength",     L4,
                "Dexterity",    L5,
                "Aim",          L6,
                "Speed",        L7,
                "Intelligence", L8,
                "Talk", -1 );

  IF L3 >= 0 AND L3 < 5 GOTO TRAIN;
  IF L3 = 5             GOTO CHAT;

:CSTOP
  if L1 = 0 then
    writeln( "Next time buy something!" );
  else
    writeln( "It's been a pleasure doing business with you!" );
  endif;
  goto XSTOP;

!
! Want's to train..  Now find out WHO!
!
:TRAIN

  writeln( "Who want's to train?" );
  L10 = select( group );
  IF L10 < 0 GOTO LOOP;
  group.current = L10;

  ON L3 GOTO XSTR, XDEX, XAIM, XSPD, XIQ;

!
! Increase your strength..
!
:XSTR

  if L4 > group.gold goto BROKE;

  dec( group.gold, L4 );
  inc( player.mstr, L9 );
  inc( player.str,  L9 );
  writeln( player.name, " undergoes extensive physical training.." );
  writeln( "Your strength has increased by ", L9, " units." );
  inc( L1 );
  GOTO LOOP;

!
! Increase your dexterity..
!
:XDEX

  if L5 > group.gold goto BROKE;

  dec( group.gold, L5 );
  inc( player.mdex, L9 );
  inc( player.dex,  L9 );
  writeln( "Your dexterity has increased by ", L9, " units." );
  inc( L1 );
  GOTO LOOP;

!
! Increase your aim..
!
:XAIM

  if L6 > group.gold goto BROKE;

  dec( group.gold, L6 );
  inc( player.maim, L9 );
  inc( player.aim,  L9 );
  writeln( "You practice with all kinds of missle weapons, including" );
  writeln( "stationary and moving targets." );
  writeln( "Your aim has increased by ", L9, " units." );
  inc( L1 );
  GOTO LOOP;

!
! Increase your speed
!
:XSPD

  if L7 > group.gold goto BROKE;

  dec( group.gold, L7 );
  inc( player.miq, L9 );
  inc( player.iq,  L9 );
  writeln( "You learn that every move you make is followed by another" );
  writeln( "and practice teaches your body to anticipate that move and" );
  writeln( "flow into it.  You never thought of yourself as 'gracefull'." );
  writeln( "Your iq has increased by ", L9, " units." );
  inc( L1 );
  GOTO LOOP;

!
! Increase your iq..
!
:XIQ

  if L8 > group.gold goto BROKE;

  dec( group.gold, L8 );
  inc( player.miq, L9 );
  inc( player.iq,  L9 );
  writeln( "You learn some new concentration techniques and fine tune" );
  writeln( "your deductive reasoning methods.." );
  writeln( "Your iq has increased by ", L9, " units." );
  inc( L1 );
  GOTO LOOP;

:BROKE
  writeln( "You don't have enough money!");
  voice( "Broke" );
  goto LOOP;

!
! Handle conversation..
!
:CHAT
  writeln( "What would you like to talk about?" );

:CHAT1
  L3 = getstr("Name","Strength","Dexerity","Aim","I.Q.","Train","Credit","Job","Bye");
  if L3 = -1 then 
    writeln( "Ok." );
    goto LOOP; ! Pressed ESCape !
  endif;

! First, see if the keyword typed is in the character's text block !
  if dotext( S0 ) then
    if L3 = 3 goto XSTOP;
    goto CHAT1;
  endif;

! It didn't, so try the predefined ones..
  on L3 goto CNAME, CSTR, CDEX, CAIM, CIQ, CTRAIN, CCREDIT, CJOB, CSTOP;

! Nope, try a 'DEFAULT' line
  if not dotext( "DEFAULT" ) then
    writeln( "I don't know anything about that!" );
  endif;
  goto CHAT1;

:CNAME 
  writeln( "My name is ", NPC.name, "."                    );
  goto CHAT1;

:CSTR
  writeln( "Strength let's you carry heavier weights" );
  writeln( "It also increases the damage you do with contact weapons" );
  goto CHAT1;

:CDEX
  writeln( "Dexterity allows you to a void hits when being attacked" );
  writeln( "It also helps avoid traps!" );
  goto CHAT1;

:CAIM
  writeln( "Good aim is needed when using missle weapons." );
  writeln( "During a fight, the targets move a lot and aim is essential" );
  goto CHAT1;

:CSPD
  writeln( "With practice, your body can react a lot faster than you can" );
  writeln( "think.  Speed gives you an edga allowing an extra hit during" );
  writeln( "a battle." );
  goto CHAT1;

:CIQ
  writeln( "A magician must learn to concentrate and focus their mental" );
  writeln( "powers.  I teach techniques that increase your ability to tap" );
  writeln( "your inner strength." );
  goto CHAT1;

:CCREDIT
  L3 = select( "MasterCard", 
               "Visa",
               "Am. Express",
               "Diner's Club",
               "Discover",
               "Sears" );
  if L3 >= 0 then
    if L15 > 0 then
      writeln( "I don't take that one either.." );
      if L15 = 2 then
        writeln( "(you start to see a pattern here..)" );
      endif;
    else
      writeln( "Sorry, I don't take that one.." );
    endif;
  endif;
  inc( L15 );
  goto CHAT1;

:CTRAIN
  writeln( "What do you want to train in?" );
  goto LOOP;

:CJOB
  writeln( "I teach people to use what nature has already given them!" );
  goto CHAT1;

! Feel free to expand on this list.. !

!-----------------------------------------------------------------!
! All STOPs now lead here so the screen can be restored if needed !
!-----------------------------------------------------------------!
:XSTOP
  if npc.picture >= 0 then
    paint(window); ! Assumes the picture fits in the window !
  endif;
  STOP;


