/*

filename    skills
password    release
changedby   Darg
EmailAdd    Mark Pringle darg@valhalla.com
request     compile
version     8
END HEADER*/

     #include

%zone skills
reset RESET_NOT
weather 1040
creators {"whistler"}

notes
"This is the skills zone. Dont let any rooms point to this zone, or use any
objects from this zone without special permission. Do not slime objects from
this zone."

%dil

dilbegin integer skillresist(aa : integer, ad : integer,
       sa : integer, sd : integer);
code
{
  return (openroll(100, 5) + aa + sa - ad - sd - 50);
}
dilend


dilbegin string sizestring(cm : integer);
var
  ftn : integer;
  fts : string;
  inn : integer;
  ins : string;
code
{
  /* One inch equals 2,54 cm. There are 12 inches (30.48 cm) to a foot */
  ftn := cm / 30;
  inn := (10*(cm % 30))/25;
  if (ftn == 1)
    fts := "one foot";
  else if (ftn > 1)
    fts := itoa(ftn)+" feet";
  else
    fts := "";

  if (inn == 1)
    ins := "one inch";
  else if (inn > 1)
    ins := itoa(inn)+" inches";
  else
    ins := "";

  if (fts != "")
  {
     if (ins != "")
       fts := fts + " and ";
  }
  else
  {
     if (inn < 1)
ins := "less than an inch";
  }

  return (fts + ins);
}
dilend
dilbegin string weightstring(p : integer);
var
  s : string;
code
{
  if (p == 1)
    s := "one pound";
  else if (p > 1)
    s := itoa(p)+" pounds";
  else
    s := "less than a pound";

  return (s);
}
dilend


dilbegin provoked_attack(victim : unitptr, ch : unitptr);
code
{
  if (not (victim.type & (UNIT_ST_NPC|UNIT_ST_PC)))
    return; /* FALSE */

  if (not (ch.type & (UNIT_ST_PC|UNIT_ST_NPC)))
    return; /* FALSE */

  if (victim.level >= 200)
    return; /* FALSE */

  if (ch.level >= 200)
    return; /* FALSE */

  if (not isset(ch.charflags, CHAR_SELF_DEFENCE))
  {
     if ((ch.fighting == null) and
  (not isset(victim.charflags, CHAR_LEGAL_TARGET)))
       set(victim.charflags, CHAR_SELF_DEFENCE);
  }

  /* Test for LEGAL_TARGET bit */
  if (isset(victim.charflags, CHAR_PROTECTED))
  {
      if ((not isset(victim.charflags, CHAR_LEGAL_TARGET)) and
          (not isset(ch.charflags, CHAR_SELF_DEFENCE)))
        set(ch.charflags, CHAR_LEGAL_TARGET);
  }

  if (victim.position <= POSITION_SLEEPING)
    return; /* FALSE */

  if (isset(victim.charflags, CHAR_PEACEFUL))
    return; /* FALSE */

  if (opponent(victim, ch))
    return; /* TRUE */

  set_fighting(victim, ch);

  return; /* TRUE */
}
dilend
dilbegin integer skill_duration(hm : integer);
code
{
  if (hm < 20)
    return (2);
  else if (hm > 150)
    return (15);
  else
    return (hm / 10);
}
dilend


dilbegin ski_bash(arg : string);
external
  integer skillresist (aa : integer, ad : integer,
                            sa : integer, sd : integer);
  provoked_attack (victim : unitptr, ch : unitptr);

var
skia : integer;
skib : integer;
hm   : integer;
tgt  : unitptr;
shield : unitptr;
code
{

if((self.type == UNIT_ST_PC) and
   (self.skills[SKI_BASH] <= 0))
{
 act("You must practice first.",
  A_ALWAYS, self, null, null, TO_CHAR);
 quit;
}

if(equipment(self,WEAR_SHIELD) == null)
{
 act("You must be wearing a shield to bash someone!",
  A_ALWAYS, self, null, null, TO_CHAR);
 quit;
}
else shield := equipment(self,WEAR_SHIELD);
 
if(arg == "")
{
 if(self.fighting)
 {
  tgt := self.fighting;
  goto bash;
 }
 else
 {
  act("Bash who?",
   A_ALWAYS, self, null, null, TO_CHAR);
  quit;
 }
}

tgt := findunit(self,arg,FIND_UNIT_SURRO,null);

if((tgt == null) or (not visible(self,tgt)))
{
 act("Bash who?",
  A_ALWAYS, self, null, null, TO_CHAR);
 quit;
}

if(tgt == self)
{
 act("You bash yourself in the head!",
  A_ALWAYS, self, null, null, TO_CHAR);
 act("$1n bashes $1mself in the head!",
  A_SOMEONE, self, null, null, TO_REST);
 quit;
}

if ((tgt.type==UNIT_ST_PC) and
    (self.type==UNIT_ST_PC))
{
 if (not(isset (self.pcflags, PC_PK_RELAXED)))
 {
   act ("You are not allowed to do this unless you sign the book of blood.",
  A_ALWAYS,self,null,null,TO_CHAR);
  quit;
  }

 if (not(isset (tgt.pcflags, PC_PK_RELAXED)))
 {
  act ("You are not allowed to do this unless $2e signs the book of blood.",
 A_SOMEONE,self,tgt,null,TO_CHAR);
  quit;
    }
 }

 if(((tgt.weight - self.weight) > 350))
 {
  act("$3n is too large to be bashed!",
   A_SOMEONE, self, null, tgt, TO_CHAR);
  quit;
 }
 
 if(tgt.position < POSITION_FIGHTING)
 {
  act("$3n isn't even standing!",
   A_SOMEONE, self, null, tgt, TO_CHAR);
  quit;
 }
 
 :bash:
 
 if(dilfind("bashed@skills",tgt))
 {
 
 act("$3n skillfully dodges your bash.",
  A_SOMEONE, self, null, tgt, TO_CHAR);
 act("$3n skillfully dodges $1n's bash.",
  A_SOMEONE, self, null, tgt, TO_NOTVICT);
 act("$1n attempts to bash you, but you skillfully avoid it.",
  A_SOMEONE, self, null, tgt, TO_VICT);
 quit;
 }
 
 if(self.endurance < 10)
 {
  act("You are too tired to try that!",
   A_ALWAYS, self, null, null, TO_CHAR);
  quit;
 }
 else self.endurance := self.endurance - 10;

 if(self.type == UNIT_ST_PC)
  skia := self.skills[SKI_BASH];
 else
  skia := self.abilities[ABIL_DEX];
 
 if(tgt.type == UNIT_ST_PC)
  skia := tgt.skills[SKI_BASH];
 else
  skia := tgt.abilities[ABIL_DEX];
 
 hm := skillresist(self.abilities[ABIL_DEX],
       tgt.abilities[ABIL_DEX],
       skia,
       skib);
 
 if(hm < -25)
 {
  change_speed(self,PULSE_VIOLENCE);
 
  act("&[hit_opponent]You attempt to bash $3n but your $2t slips "+
      "from your hands!&[default]",
   A_SOMEONE, self, shield.name, tgt, TO_CHAR);
  act("&[hit_other]$1n attempts to bash $3n but $1s $2t slips from "+
      "$1s hands!&[default]",
       A_SOMEONE, self, shield.name, tgt, TO_NOTVICT);
  act("&[hit_me]$1n attempts to bash you, but $1s $2t slips from "+
      "$1s hands!&[default]",
       A_SOMEONE, self, shield.name, tgt, TO_VICT);
  provoked_attack(tgt,self);
  unequip(shield);
  quit;
 }
 
 if(hm < 0)
 {
  change_speed(self,PULSE_VIOLENCE / 2);
 
  act("&[hit_opponent]You bash the passing wind.&[default]",
   A_ALWAYS, self, null, null, TO_CHAR);
  act("&[hit_other]$1n bashes the passing wind.&[default]",
   A_SOMEONE, self, null, tgt, TO_NOTVICT);
  act("&[hit_me]$1n bashes the passing wind.&[default]",
   A_SOMEONE, self, null, tgt, TO_VICT);
  provoked_attack(tgt,self);
  quit;
 }
 
 dilcopy("bashed@skills",tgt);
 
 change_speed(tgt,PULSE_VIOLENCE);
 
 act("&[hit_opponent]You slam your $2t into $3n.&[default]",
  A_SOMEONE, self, shield.name, tgt, TO_CHAR);
 act("&[hit_other]$1n slams $1s $2t into $3n.&[default]",
  A_SOMEONE, self, shield.name, tgt, TO_NOTVICT);
 act("&[hit_me]&1n slams $1s $2t into you!&[default]",
  A_SOMEONE, self, shield.name, tgt, TO_VICT);
 provoked_attack(tgt,self);
 send_done("bash",self,shield,tgt,hm,arg,null);
 
 quit;
}
dilend

dilbegin bashed();
code
{
heartbeat := PULSE_VIOLENCE * 3;

wait(SFB_TICK, TRUE);
quit;
}
dilend

dilbegin disarm(arg : string);
/* by Drevar */
external
  integer skillresist (aa : integer, ad : integer,
                            sa : integer, sd : integer);
  provoked_attack (victim : unitptr, ch : unitptr);

var
  tweapon  : unitptr;
  mweapon  : unitptr;
  skilla : integer;
  skilld : integer;
  hm     : integer;
  targ   : unitptr;

code
{

 if ((self.type == UNIT_ST_PC) and (self.skills[SKI_DISARM] <= 0))
 {
    act("You must practice first.", A_ALWAYS, self, null, null, TO_CHAR);
    quit;
 }

  if (arg == "")
  {
    if (self.fighting)
    {
      targ := self.fighting;
      goto disarm;
    }
    else
    {
      act("Who do you wish to disarm?", A_SOMEONE, self, null, null,
          TO_CHAR);
      quit;
    }
  }
  targ := findunit(self, arg, FIND_UNIT_SURRO, null);

  if ((targ == null) or not visible(self, targ))
    {
      act("They are not here!", A_SOMEONE, self, null, targ, TO_CHAR);
      quit;
    }

if (targ==self)
 {
     act("Why not use the remove command.", A_SOMEONE, self,
         null, null, TO_CHAR);
     quit;
   }


 if ( (targ.type != UNIT_ST_PC) and (targ.type != UNIT_ST_NPC) )
   {
     act("No need to disarm that, it can't attack you.", A_SOMEONE, self,
         null, null, TO_CHAR);
     quit;
   }

  if (targ.position <= POSITION_INCAP)
    {
      act("Why bother?  $3e can't hurt you now!", A_SOMEONE, self, null,
          targ, TO_CHAR);
      quit;
    }

  if ((targ.type==UNIT_ST_PC) and
  (self.type==UNIT_ST_PC))
 {
if (not(isset (self.pcflags, PC_PK_RELAXED)))
 {
 act ("You are not allowed to do this unless you sign the book of blood.",
 A_ALWAYS,self,null,null,TO_CHAR);
 quit;
 }

if (not(isset (targ.pcflags, PC_PK_RELAXED)))
 {
 act ("You are not allowed to do this unless $2e signs the book of blood.",
 A_ALWAYS,self,targ,null,TO_CHAR);
 quit;
 }
 }

  :disarm:
  mweapon := self.inside;
  while (mweapon)
    {
      if ( (mweapon.objecttype == ITEM_WEAPON) and
           (mweapon.equip == WEAR_WIELD) )
        {
          break;
        }
      mweapon := mweapon.next;
    }

  if (mweapon == null)
    {
      act("Better get yourself a weapon first!", A_SOMEONE, self, null, null,
          TO_CHAR);
      quit;
    }

  tweapon := targ.inside;
  while (tweapon)
    {
      if ( (tweapon.objecttype == ITEM_WEAPON) and
           (tweapon.equip == WEAR_WIELD) )
        {
          break;
        }
      tweapon := tweapon.next;
    }

  if (tweapon == null)
    {
      act("$3n has no weapon!", A_SOMEONE, self, null, targ, TO_CHAR);
      quit;
    }

  provoked_attack (targ, self);

  if (self.type == UNIT_ST_PC)
    skilla := self.skills[SKI_DISARM];
  else
    skilla := (self.abilities[ABIL_DEX] / 2) + (self.abilities[ABIL_STR] /2);

  if (targ.type == UNIT_ST_PC)
    skilld := targ.skills[SKI_DISARM];
  else
    skilld := (targ.abilities[ABIL_DEX] / 2) + (targ.abilities[ABIL_STR] /2);

  if (self.fighting)
    hm := skillresist (
             (self.abilities[ABIL_DEX] / 4) + (self.abilities[ABIL_STR] /4),
             (targ.abilities[ABIL_DEX] / 2) + (targ.abilities[ABIL_STR] /2),
             (skilla / 2), skilld);
  else
    hm := skillresist (
             (self.abilities[ABIL_DEX] / 2) + (self.abilities[ABIL_STR] /2),
             (targ.abilities[ABIL_DEX] / 2) + (targ.abilities[ABIL_STR] /2),
              skilla, skilld);


  if (self.endurance < 3)
    {
     act("You are too exhausted to attempt that.", A_ALWAYS, self, null,
        null, TO_CHAR);
      quit;
     }
  else self.endurance := self.endurance - 3;


  if (hm <= -25)
    {
       act("As you attempt to disarm $3n, your $2N slips through your " +
           "hands!", A_SOMEONE, self, mweapon, targ, TO_CHAR);
       act("$1n tries a fancy move, but you counter and cause $1m to drop
"  +
           "$1s $2N!.", A_SOMEONE, self, mweapon, targ, TO_VICT);
       act("$3n counters $1n's disarm attempt, $1n lost $1s own weapon " +
           "instead!",A_SOMEONE, self, mweapon, targ, TO_NOTVICT);
       link(mweapon, self.outside);
       if (self.type == UNIT_ST_NPC)
         dilcopy("rearm@skills("+mweapon.name+")", self);
       quit;
    }
  if (hm <= 0)
    {
      act("You attempt to disarm $3n, but fail.", A_SOMEONE, self, null,
targ,
          TO_CHAR);
      act("$1n makes a feeble attempt to relieve you of your $2N.",
          A_SOMEONE, self, tweapon, targ, TO_VICT);
      act("$1n fails $1s attempt at disarming $3n.", A_SOMEONE, self, null,
          targ, TO_NOTVICT);
      quit;
    }
  act("Your quick move pulls $3n's $2N from $3s hands!", A_SOMEONE, self,
      tweapon, targ, TO_CHAR);
  act("$1n strips your $2N from you hands!", A_SOMEONE, self, tweapon,
      targ, TO_VICT);
  act("$1n deftly strips $3n's $2N from $3s hands!", A_SOMEONE, self,
      tweapon, targ, TO_NOTVICT);
  link(tweapon, targ.outside);
  if (targ.type == UNIT_ST_NPC)
   dilcopy("rearm@skills("+tweapon.name+")", targ);
  quit;

}
dilend

dilbegin rearm(t : string);
var
i : integer;
tweap : unitptr;
code
{
 interrupt(SFB_DEAD, activator == self, stop);
 heartbeat := PULSE_VIOLENCE;

 :retry:

 wait(SFB_COM, self.position == POSITION_FIGHTING);

 heartbeat := PULSE_VIOLENCE;
 i := rnd(1, 100);
 if (i >= 40)
 {
   change_speed(self, PULSE_VIOLENCE);
   act("$1n ducks quickly and tries to recover $1s weapon.", A_SOMEONE,
       self, null, null, TO_ROOM);
   i := rnd(1, 200);
   if (i <= self.abilities[ABIL_DEX])
   {
     tweap := findunit(self, t, FIND_UNIT_SURRO, null);
         if ( (tweap!=null) and
         (tweap.type == UNIT_ST_OBJ) and
              (tweap.objecttype == ITEM_WEAPON) and
              (not isset(tweap.flags, UNIT_FL_BURIED)) )
     {
       link(tweap, self);
       act("$1n manages to retrieve $1s "+tweap.name+"", A_SOMEONE, self,
           null, null, TO_ROOM);
       exec("wield "+tweap.name+"", self);
       goto stop;
     }
     else
     {
       tweap := self.outside.inside;
       while (tweap)
       {
         if ( (tweap.type == UNIT_ST_OBJ) and
              (tweap.objecttype == ITEM_WEAPON) and
              (not isset(tweap.flags, UNIT_FL_BURIED)) )
         {
           link(tweap, self);
           act("$1n manages to retrieve a "+tweap.name+"", A_SOMEONE, self,
               null, null, TO_ROOM);
           exec("wield "+tweap.name+"", self);
           act("$1n scowls at $1s "+tweap.name+"", A_SOMEONE, self, null,
               null, TO_ROOM);
           i := 1;
           break;
         }
         else
         {
           tweap := tweap.next;
           i := 0;
         }
       }
     if (i == 0)
       act("$1n resigns to using $1s natural weapons.", A_SOMEONE, self,
           null, null, TO_ROOM);

     goto stop;
     }
   }
   else
   {
     act("$1n fumbles and fails to retrieve $1s weapon.", A_SOMEONE, self,
         null, null, TO_ROOM);
     goto retry;
   }
 }
 else
   goto retry;

 :stop:
 quit;
}
dilend



dilbegin pickpocket(arg : string);
/* by Drevar */
external
  integer skillresist (aa : integer, ad : integer,
                            sa : integer, sd : integer);
  provoked_attack (victim : unitptr, ch : unitptr);
var
skilla   :  integer;
skilld   :  integer;
hm       :  integer;
vict     :  unitptr;
object   :  unitptr;
willtake :  integer;
plat     :  integer;
gold     :  integer;
silv     :  integer;
copp     :  integer;
iron     :  integer;

code
{
 if ((self.type == UNIT_ST_PC) and (self.skills[SKI_PICK_POCKETS] <= 0))
 {
    act("You must practice first.", A_ALWAYS, self, null, null, TO_CHAR);
    quit;
 }

 object := self.inside;
 hm := 0;
 while ((object) and (hm != 2))
   {
     if ( (object.equip == WEAR_WIELD) and
          (isset(object.objectflags, OBJ_TWO_HANDS)) )
       {
         hm := 2;
         continue;
       }

     if ( (object.equip == WEAR_HOLD) or (object.equip == WEAR_WIELD) or
        (object.equip == WEAR_SHIELD) )
       {
         hm := hm + 1;
       }

     object := object.next;
   }

 if (hm == 2)
   {
      act("You must have at least one hand free to attempt that!", A_SOMEONE,
          self, null, null, TO_CHAR);
      quit;
   }


 vict := findunit(self, arg, FIND_UNIT_SURRO, null);

 if ((vict == null) or not visible(self, vict))
   {
     act("No such person to pickpocket.",  A_SOMEONE, self, null, null,
         TO_CHAR);
     quit;
   }

  if ((vict.type==UNIT_ST_PC) and
  (self.type==UNIT_ST_PC))
 {
if (not(isset (self.pcflags, PC_PK_RELAXED)))
 {
 act ("You are not allowed to do this unless you sign the book of blood.",
 A_ALWAYS,self,null,null,TO_CHAR);
 quit;
 }

if (not(isset (vict.pcflags, PC_PK_RELAXED)))
 {
 act ("You are not allowed to do this unless $2e signs the book of blood.",
 A_ALWAYS,self,vict,null,TO_CHAR);
 quit;
 }
 }


  if (self.type == UNIT_ST_PC)
    skilla := self.skills[SKI_PICK_POCKETS];
  else
    skilla := self.abilities[ABIL_DEX];

  if (vict.type == UNIT_ST_PC)
    skilld := vict.skills[SKI_PICK_POCKETS];
  else
    skilld := vict.abilities[ABIL_DEX];

  hm := skillresist (self.abilities[ABIL_DEX],
                    vict.abilities[ABIL_DEX],
      skilla, skilld);

 if (hm <= -5)
   {
     act("You are caught!", A_SOMEONE, self, null, vict, TO_CHAR);

     if (isaff(self, ID_INVISIBILITY))
       subaff(self, ID_INVISIBILITY);

     act("You catch $1n with $1s hand in your purse!", A_SOMEONE, self, null,
         vict, TO_VICT);
     act("You see $1n trying to pilfer money from $3n...$3e doesn't " +
         "seem amused!", A_SOMEONE, self, null, vict, TO_NOTVICT);
     provoked_attack (vict, self);
     logcrime(self, vict, CRIME_STEALING);
     quit;
   }


 if (hm <= 0)
   {
     act("You fail to get any money from $3n, but at least no one was
watching!",
       A_SOMEONE, self, null, vict, TO_CHAR);
     quit;
   }

 if (hm <= 5)
   {
     act("You pilfer a handful of coins just as $3e turns toward you..." +
         "You have been caught!", A_SOMEONE, self, null, vict, TO_CHAR);
     if (isaff(self, ID_INVISIBILITY))
       subaff(self, ID_INVISIBILITY);

     act("Arrgh!  $1n just stole some of your hard earned money!",
          A_SOMEONE, self, null, vict, TO_VICT);
     act("You see $1n swipe a handful of coins from $3n...$3e doesn't " +
         "seem amused!", A_SOMEONE, self, null, vict, TO_NOTVICT);
     willtake := (self.skills[SKI_PICK_POCKETS] / 2);
     willtake := (rnd((willtake / 4), willtake));
     plat := (((purse(vict, PLATINUM_PIECE)*willtake) / 100) * 40960);
     gold := (((purse(vict, GOLD_PIECE)*willtake) / 100) * 5120);
     silv := (((purse(vict, SILVER_PIECE)*willtake) / 100) * 640);
     copp := (((purse(vict, COPPER_PIECE)*willtake) / 100) * 80);
     iron := (((purse(vict, IRON_PIECE)*willtake) / 100) * 10);

     if (iron)
       iron := (transfermoney(vict, self, iron));
     if (copp)
       copp := (transfermoney(vict, self, copp));
     if (silv)
       silv := (transfermoney(vict, self, silv));
     if (gold)
       gold := (transfermoney(vict, self, gold));
     if (plat)
       plat := (transfermoney(vict, self, plat));

     provoked_attack (vict, self);
     logcrime(self, vict, CRIME_STEALING);
     send_done("pickpocket",self,null,vict,hm,arg,null);
     quit;
   }

 willtake := (self.skills[SKI_PICK_POCKETS] / 2);
 willtake := (rnd((willtake / 4), willtake));

 plat := (((purse(vict, PLATINUM_PIECE)*willtake) / 100) * 40960);
 gold := (((purse(vict, GOLD_PIECE)*willtake) / 100) * 5120);
 silv := (((purse(vict, SILVER_PIECE)*willtake) / 100) * 640);
 copp := (((purse(vict, COPPER_PIECE)*willtake) / 100) * 80);
 iron := (((purse(vict, IRON_PIECE)*willtake) / 100) * 10);

 if (iron)
   iron := (transfermoney(vict, self, iron));
 if (copp)
   copp := (transfermoney(vict, self, copp));
 if (silv)
   silv := (transfermoney(vict, self, silv));
 if (gold)
   gold := (transfermoney(vict, self, gold));
 if (plat)
   plat := (transfermoney(vict, self, plat));


 act("You stealthily pilfer a handful of coins from $3n's purse and " +
     "quickly deposit them in your own.",A_SOMEONE, self, null, vict,
     TO_CHAR);
 send_done("pickpocket",self,null,vict,hm,arg,null);
 quit;

}
dilend

dilbegin peek(arg : string);

external
  integer skillresist (aa : integer, ad : integer,
                            sa : integer, sd : integer);

var
  skilla : integer;
  skilld : integer;
  hm     : integer;
  targ   : unitptr;
  object  : unitptr;
code
{
 if ((self.type == UNIT_ST_PC) and (self.skills[SKI_PEEK] <= 0))
 {
   act("You must practice first.", A_ALWAYS, self, null, null, TO_CHAR);
   quit;
 }

 if (arg == "")
 {
   act("Who's inventory do you wish to peek at?", A_SOMEONE, self, null,
        null, TO_CHAR);
   quit;
 }

 targ := findunit(self, arg, FIND_UNIT_SURRO, null);

 if ((targ == null) or not visible(self, targ))
 {
   act("That person is not here!", A_SOMEONE, self, null, null, TO_CHAR);
   quit;
 }

 if (targ.type &(UNIT_ST_ROOM | UNIT_ST_OBJ))
 {
   act("You don't have to peek, just look in it!", A_SOMEONE, self, null,
   null, TO_CHAR);
   quit;
 }

 if (targ == self)
 {
   act("Why don't you just use the inventory command?", A_SOMEONE, self,
        null, null, TO_CHAR);
   quit;
 }

 if (targ.position <=  POSITION_SLEEPING)
 {
   act("They won't mind if you take a little peek at the moment.",
       A_SOMEONE, self, null, null, TO_CHAR);
   goto success;
 }

 if (self.type == UNIT_ST_PC)
   skilla := self.skills[SKI_PEEK];
 else
   skilla := self.abilities[ABIL_BRA];

 if (targ.type == UNIT_ST_PC)
   skilld := targ.skills[SKI_PEEK];
 else
   skilld := targ.abilities[ABIL_BRA];

 hm := skillresist (self.abilities[ABIL_BRA],
                    targ.abilities[ABIL_BRA],
      skilla, skilld);

 if (hm < -25)
 {
   act("You clumsily attempt to see what goodies $3n has, $3e " +
        "doesn't seem to be amused.", A_SOMEONE, self, null, targ, TO_CHAR);
     if (isaff(self, ID_INVISIBILITY))
       {
         subaff(self, ID_INVISIBILITY);
       }
   act("You catch $1n blatently peeking at your possessions!",
        A_SOMEONE, self, null, targ, TO_VICT);
   quit;
 }

 if (hm <= 0)
 {
   act("You can't quite make out what $3e has, but at least you were " +
   "discrete.", A_SOMEONE, self, null, targ, TO_CHAR);
   quit;
 }

 act("You manage to peek at $3s belongings.", A_SOMEONE, self, null, targ,
     TO_CHAR);

 :success:
 act("You see $3e has: ", A_SOMEONE, self, null, targ, TO_CHAR);

 hm := FALSE;

 object := targ.inside;

 while (object)
 {
    if (visible(self, object))
    {
       if (object.equip == 0)
       {
          /* Perhaps do check for each item */
          act(object.title, A_SOMEONE, self, null, targ, TO_CHAR);
          hm := TRUE;
       }
    }
    object := object.next;
 }

 if (hm == FALSE)
   act("Absolutely nothing!", A_SOMEONE, self, null, targ, TO_CHAR);

 quit;
}
dilend

dilbegin steal(arg : string);

external
 integer skillresist (aa : integer, ad : integer,
                           sa : integer, sd : integer);
 provoked_attack (victim : unitptr, ch : unitptr);
var
skilla  :  integer;
skilld  :  integer;
hm      :  integer;
vict    :  unitptr;
object  :  unitptr;
targ    :  unitptr;
hands   :  integer;
t       :  string;
temp    : string;
ti:integer;
code
{
 if ((self.type == UNIT_ST_PC) and (self.skills[SKI_STEAL] <= 0))
 {
    act("You must practice first.", A_ALWAYS, self, null, null, TO_CHAR);
    quit;
 }

 object := self.inside;
 while ((object) and (hands != 2))
   {
     if ( ((object.equip == WEAR_WIELD) or (object.equip == WEAR_HOLD))
and
          (isset(object.objectflags, OBJ_TWO_HANDS)) )
       {
         hands := 2;
         continue;
       }

     if ( (object.equip == WEAR_HOLD) or (object.equip == WEAR_WIELD) or
        (object.equip == WEAR_SHIELD) )
       {
         hands := hands + 1;
       }
     object := object.next;
   }

 if (hands == 2)
   {
      act("You must have at least one hand free to attempt that!",
A_SOMEONE,
          self, null, null, TO_CHAR);
      quit;
   }

 if (not (" from " in arg))
   {
     act("Steal what from who?", A_SOMEONE, self, null, null,  TO_CHAR);
     quit;
   }

 /* needed for multi word names */
 t := getword(arg);
 temp := getword(arg);
 while (temp != "from")
 {
   t := (t + " " + temp);
   temp := getword(arg);
 }

 vict := findunit(self, arg, FIND_UNIT_SURRO, null);
 if ((vict == null) or not visible(self, vict))
   {
     act("No such person to steal from.",  A_SOMEONE, self, null,  null,
         TO_CHAR);
     quit;
   }


 if ( (vict.type != UNIT_ST_PC) and (vict.type != UNIT_ST_NPC) )
   {
     act("Why bother? Just get the darn thing!", A_SOMEONE, self, null,
null,
         TO_CHAR);
     quit;
   }

  if ((vict.type==UNIT_ST_PC) and
  (self.type==UNIT_ST_PC))
 {
if (not(isset (self.pcflags, PC_PK_RELAXED)))
 {
 act ("You are not allowed to do this unless you sign the book of blood.",
 A_ALWAYS,self,null,null,TO_CHAR);
 quit;
 }

if (not(isset (vict.pcflags, PC_PK_RELAXED)))
 {
 act ("You are not allowed to do this unless $2e signs the book of
blood.",
 A_ALWAYS,self,vict,null,TO_CHAR);
 quit;
 }
 }



 targ := findunit(vict, t, FIND_UNIT_IN_ME, null);

 if ((targ == null) or not visible(self,targ))
   {
     act("You can't find that on $3n.", A_SOMEONE, self, targ, vict,
TO_CHAR);
     quit;
   }

 if (targ.objecttype == ITEM_MONEY)
   {
     act("That would take a different type of finesse, try pilfering " +
         "instead.", A_SOMEONE, self, null, vict, TO_CHAR);
     quit;
   }

 if ( (targ.equip != 0) )  /* 0 = not equipped, value not in values.h */
   {
     act("You can only steal non-equiped items!", A_SOMEONE, self, null,
          vict, TO_CHAR);
     quit;
   }

  if (targ.zoneidx == "treasure")
  {
    act("A chill runs down your spine...someone or something is watching.",
        A_ALWAYS, self, null, null, TO_CHAR);
    act("You change your mind about stealing that.", A_ALWAYS, self,
        null, null, TO_CHAR);
    quit;
  }

ti:=can_carry (self,targ,1);
if (ti==1)
{
act ("You can't carry another thing.",
 A_ALWAYS,self,null,null,TO_CHAR);
 quit;
 }
  if (self.type == UNIT_ST_PC)
    skilla := self.skills[SKI_STEAL];
  else
    skilla := self.abilities[ABIL_DEX];

  if (targ.type == UNIT_ST_PC)
    skilld := vict.skills[SKI_STEAL];
  else
    skilld := vict.abilities[ABIL_DEX];

  hm := skillresist (self.abilities[ABIL_DEX],
                    vict.abilities[ABIL_DEX],
      skilla, skilld);



  if (hm <= -5)
   {
     act("You are caught!", A_SOMEONE, self, targ, vict, TO_CHAR);
     if (isaff(self, ID_INVISIBILITY))
       {
         subaff(self, ID_INVISIBILITY);
       }
     act("You catch $1n trying to steal your $2n!", A_SOMEONE, self, targ,
         vict, TO_VICT);
     act("You see $1n trying to steal something from $3n...$3e doesn't " +
         "seem amused!", A_SOMEONE, self, targ, vict, TO_NOTVICT);

     provoked_attack (vict, self);
     logcrime(self, vict, CRIME_STEALING);
     quit;
   }

 if (hm <= 0)
   {
     act("You fail to steal $3n's $2n, but at least no one was watching!",
       A_SOMEONE, self, targ, vict, TO_CHAR);
     quit;
   }
 if (hm < 5)
   {
     act("You steal $2n from $3n just as $3e turns toward you..You have "
+
         "been caught!", A_SOMEONE, self, targ, vict, TO_CHAR);
     if (isaff(self, ID_INVISIBILITY))
       {
         subaff(self, ID_INVISIBILITY);
       }
     act("Arrgh!  $1n just stole your $2n!", A_SOMEONE, self, targ, vict,
         TO_VICT);
     act("You see $1n steal something from $3n...$3e doesn't seem
amused!",
         A_SOMEONE, self, targ, vict, TO_NOTVICT);
     link(targ, self);
     provoked_attack (vict, self);
     logcrime(self, vict, CRIME_STEALING);
     send_done("steal",self,targ,vict,hm,arg,null);
     quit;
   }

 act("You stealthily steal $3n's $2n and quickly tuck it out of " +
     "sight!", A_SOMEONE, self, targ, vict, TO_CHAR);
 link(targ, self);
 send_done("steal",self,targ,vict,hm,arg,null);
 quit;


}
dilend

dilbegin filch(arg : string);

external
  integer skillresist (aa : integer, ad : integer,
                            sa : integer, sd : integer);
  provoked_attack (victim : unitptr, ch : unitptr);

var
  skilla  : integer;
  skilld  : integer;
  hm      : integer;
  targ    : unitptr;
  vict    : unitptr;
  from    : string;
  object  : unitptr;
  hands   : integer;
  t       : string;
  temp    : string;
 ti:integer;
code
{
 if ((self.type == UNIT_ST_PC) and (self.skills[SKI_FILCH] <= 0))
 {
    act("You must practice first.", A_ALWAYS, self, null, null, TO_CHAR);
    quit;
 }

 hands := (0);
 object := self.inside;
 while ((object) and (hands != 2))
   {
     if ( ((object.equip == WEAR_WIELD) or (object.equip == WEAR_HOLD))
and
          (isset(object.objectflags, OBJ_TWO_HANDS)) )
       {
         hands := 2;
         continue;
       }

     if ( (object.equip == WEAR_HOLD) or (object.equip == WEAR_WIELD) or
          (object.equip == WEAR_SHIELD) )
       {
         hands := hands + 1;
       }
     object := object.next;
   }

 if (hands == 2)
   {
      act("You must have at least one hand free to attempt that!",
A_SOMEONE,
          self, null, null, TO_CHAR);
      quit;
   }

 if (not (" from " in arg))
   {
     act("Filch what from who?", A_SOMEONE, self, null, null,  TO_CHAR);
     quit;
   }

 /* needed for multi word names */
 t := getword(arg);
 temp := getword(arg);
 while (temp != "from")
 {
   t := (t + " " + temp);
   temp := getword(arg);
 }

 vict := findunit(self, arg, FIND_UNIT_SURRO, null);
 if ((vict == null) or not visible(self, vict))
   {
     act("No such person to filch from.",  A_SOMEONE, self, null,  null,
         TO_CHAR);
     quit;
   }
 if ( (not(vict.type & (UNIT_ST_PC | UNIT_ST_NPC)) ))
   {
     act("Why bother? Just get the darn thing!", A_SOMEONE, self, null,
null,
         TO_CHAR);
     quit;
   }


  if ((vict.type==UNIT_ST_PC) and
  (self.type==UNIT_ST_PC))
 {
if (not(isset (self.pcflags, PC_PK_RELAXED)))
 {
 act ("You are not allowed to do this unless you sign the book of blood.",
 A_ALWAYS,self,null,null,TO_CHAR);
 quit;
 }

if (not(isset (vict.pcflags, PC_PK_RELAXED)))
 {
 act ("You are not allowed to do this unless $2e signs the book of
blood.",
 A_ALWAYS,self,vict,null,TO_CHAR);
 quit;
 }
 }


 targ := findunit(vict, t, FIND_UNIT_EQUIP, null);
 if ((targ == null) or not visible(self, targ))
   {
     act("You can't find that on $3n.", A_SOMEONE, self, targ, vict,
TO_CHAR);
     quit;
   }

 if ( (targ.equip != WEAR_FINGER_R) and (targ.equip != WEAR_FINGER_L) and
      (targ.equip != WEAR_NECK_1) and (targ.equip != WEAR_NECK_2) and
      (targ.equip != WEAR_WAIST) and (targ.equip != WEAR_WRIST_R) and
      (targ.equip != WEAR_BACK) and (targ.equip != WEAR_EAR_L) and
      (targ.equip != WEAR_EAR_R) and (targ.equip != WEAR_ANKLE_L) and
      (targ.equip != WEAR_ANKLE_R) and (targ.equip != WEAR_WRIST_L) )
   {
     act("That would be much to difficult to filch away from $3n!",
         A_SOMEONE, self, null, vict, TO_CHAR);
     quit;
   }

  if (targ.zoneidx == "treasure")
  {
    act("A chill runs down your spine...someone or something is watching.",
        A_ALWAYS, self, null, null, TO_CHAR);
    act("You change your mind about filching that.", A_ALWAYS, self,
        null, null, TO_CHAR);
    quit;
  }
ti:=can_carry (self,targ,1);
if (ti==1)
{
act ("You can't carry another thing.",
 A_ALWAYS,self,null,null,TO_CHAR);
 quit;
 }

  if (self.type == UNIT_ST_PC)
    skilla := self.skills[SKI_FILCH];
  else
    skilla := self.abilities[ABIL_DEX];

  if (vict.type == UNIT_ST_PC)
    skilld := vict.skills[SKI_FILCH];
  else
    skilld := vict.abilities[ABIL_DEX];

  hm := skillresist (self.abilities[ABIL_DEX],
                    vict.abilities[ABIL_DEX],
      skilla, skilld);




 if (hm <= -5)
   {
     act("You are caught!", A_SOMEONE, self, targ, vict, TO_CHAR);
     if (isaff(self, ID_INVISIBILITY))
       {
         subaff(self, ID_INVISIBILITY);
       }
     act("You catch $1n trying to filch your $2n!", A_SOMEONE, self, targ,
         vict, TO_VICT);
     act("You see $1n trying to filch something from $3n...$3e doesn't " +
         "seem amused!", A_SOMEONE, self, targ, vict, TO_NOTVICT);
     provoked_attack (vict, self);
     logcrime(self, vict, CRIME_STEALING);
     quit;
   }


 if (hm <= 0)
   {
     act("You fail to filch $3n's $2n, but at least no one was watching!",
       A_SOMEONE, self, targ, vict, TO_CHAR);
     quit;
   }

 if (hm <= 5)
   {
     act("You filch $2n from $3n just as $3e turns toward you..You have "
+
         "been caught!", A_SOMEONE, self, targ, vict, TO_CHAR);
     if (isaff(self, ID_INVISIBILITY))
       {
         subaff(self, ID_INVISIBILITY);
       }
     act("Arrgh!  $1n just stole your $2n!", A_SOMEONE, self, targ, vict,
         TO_VICT);
     act("You see $1n filch something from $3n...$3e doesn't seem
amused!",
         A_SOMEONE, self, targ, vict, TO_NOTVICT);
     link(targ, self);
     provoked_attack (vict, self);
     logcrime(self, vict, CRIME_STEALING);
     send_done("filch",self,targ,vict,hm,arg,null);
     quit;
   }

 act("You stealthily filch $3n's $2n and quickly tuck it out of " +
     "sight!", A_SOMEONE, self, targ, vict, TO_CHAR);
 link(targ, self);
 send_done("filch",self,targ,vict,hm,arg,null);
 quit;


}
dilend

dilbegin diagnose(arg : string);
external
  string sizestring (cm : integer);
  string weightstring (cm : integer);
  integer skillresist (aa : integer, ad : integer,
       sa : integer, sd : integer);

var
  percent : integer;
  hm      : integer;
  s1      : string;
  s2      : string;
  vict    : unitptr;
  skilla  : integer;
code
{
  if ((self.type == UNIT_ST_PC) and
      (self.skills[SKI_DIAGNOSTICS] == 0))
  {
     act("You must practice first.",
  A_ALWAYS, self, null, null, TO_CHAR);
     quit;
  }

  if (arg == "")
  {
     vict := self.fighting;
     if (vict == null)
     {
 act("Diagnose who?",
            A_ALWAYS, self, null, null, TO_CHAR);
 quit;
     }
  }
  else
  {
     vict := findunit(self, arg, FIND_UNIT_SURRO, null);
     if ((vict == null) or not visible(self, vict))
     {
 act("Nobody here by that name.",
     A_ALWAYS, self, null, vict, TO_CHAR);
 quit;
     }
  }

  if (not (vict.type & (UNIT_ST_PC | UNIT_ST_NPC)))
  {
     act("It seems to be dead?",
  A_ALWAYS, self, null, null, TO_CHAR);
     return;
  }

  if (vict.max_hp > 0)
    percent := (100 * vict.hp) / vict.max_hp;
  else
    percent := -1; /* How could MAX_HIT be < 1?? */

  if (self.type == UNIT_ST_PC)
    skilla := self.skills[SKI_DIAGNOSTICS];
  else
    skilla := self.abilities[ABIL_BRA];

  hm := skillresist (self.abilities[ABIL_BRA], 20,
   skilla, 50);

  if (hm > 0)
    hm := 0;

  percent := percent + ((percent * (-hm))/100);

  if (percent >= 100)
    act("$3n is in an excellent condition.",
 A_ALWAYS, self, null, vict, TO_CHAR);
  else if (percent >= 90)
    act("$3n has a few scratches.",
 A_ALWAYS, self, null, vict, TO_CHAR);
  else if (percent >= 75)
    act("$3n has some small wounds and bruises.",
        A_ALWAYS, self, null, vict, TO_CHAR);
  else if (percent >= 50)
    act("$3n has quite a few wounds.",
        A_ALWAYS, self, null, vict, TO_CHAR);
  else if (percent >= 30)
    act("$3n has some big nasty wounds and scratches.",
        A_ALWAYS, self, null, vict, TO_CHAR);
  else if (percent >= 15)
    act("$3n looks pretty hurt.",
        A_ALWAYS, self, null, vict, TO_CHAR);
  else if (percent >= 0)
    act("$3n is in an awful condition.",
 A_ALWAYS, self, null, vict, TO_CHAR);
  else
    act("$3n is bleeding awfully from big wounds.",
 A_ALWAYS, self, null, vict, TO_CHAR);

  if (self.fighting == null)
  {
     s1 := weightstring (vict.baseweight);
     s2 := sizestring (vict.height);
     act("$3e weighs "+s1+" and is "+s2+" tall.",
  A_SOMEONE, self, null, vict, TO_CHAR);
  }

  quit;
}
dilend

dilbegin resize(arg:string);
external
  res_clothes@skills (tgt:unitptr,tgt_pc:unitptr);
  res_lth@skills (tgt:unitptr,tgt_pc:unitptr);
  res_metal@skills (tgt:unitptr,tgt_pc:unitptr);
var
  item : unitptr;
  tgt_pc : unitptr;
code
{
  if (arg == "")
  {
     act("What do you wish to resize?", A_SOMEONE, self, null, null,TO_CHAR);
     quit;
  }

  item := findunit(self, arg, FIND_UNIT_INVEN, null);

  if ((item == null) or not visible(self, item))
  {
     act("No such thing by that name!", A_SOMEONE, self, null, null,
TO_CHAR);
     quit;
  }

  tgt_pc := findunit(self,arg,FIND_UNIT_SURRO,null);

  if ((tgt_pc==null) or not visible(self, tgt_pc))
    tgt_pc := self;

  if (not (item.type&UNIT_ST_OBJ))
  {
     act("You can't resize that!", A_SOMEONE, self, null, null,
  TO_CHAR);
     quit;
  }

  if (item.objecttype == ITEM_ARMOR)
  {
     if ((item.value[0]          (item.value[0]>ARM_PLATE))
     {
        act ("The armor seems to be broken.",
      A_ALWAYS,self,null, null,TO_CHAR);
        quit;
     }
     on item.value[0] goto clothes,leather,leather,metal,metal;
  }
  else if (item.objecttype == ITEM_SHIELD)
    goto metal;
  else if (item.objecttype == ITEM_WEAPON)
    goto metal;
  else if (item.objecttype == ITEM_WORN)
    goto clothes;
  else
  {
     if ((item.manipulate & (MANIPULATE_WEAR_FINGER | MANIPULATE_WEAR_NECK  |
       MANIPULATE_WEAR_BODY   | MANIPULATE_WEAR_HEAD  |
       MANIPULATE_WEAR_LEGS   | MANIPULATE_WEAR_FEET  |
       MANIPULATE_WEAR_HANDS  | MANIPULATE_WEAR_ARMS  |
       MANIPULATE_WEAR_SHIELD | MANIPULATE_WEAR_ABOUT |
       MANIPULATE_WEAR_WAIST  | MANIPULATE_WEAR_WRIST |
       MANIPULATE_WIELD       | MANIPULATE_WEAR_EAR   |
       MANIPULATE_WEAR_BACK   | MANIPULATE_WEAR_CHEST |
       MANIPULATE_WEAR_ANKLE)) == 0)
     {
        act ("There is no way the $3N can be resized.",
      A_SOMEONE, self, null, item, TO_CHAR);
        quit;
     }
     goto metal; /* What else can one do? */
  }
  quit;

  :clothes:
  res_clothes(item,tgt_pc);
  quit;
  :leather:
  res_lth (item,tgt_pc);
  quit;
  :metal:
  res_metal(item,tgt_pc);
  quit;
}
dilend


dilbegin res_clothes(tgt:unitptr,tgt_pc:unitptr);
external
  integer skillresist (aa : integer, ad : integer,
       sa : integer, sd : integer);
  unitptr unit_room (u:unitptr);
var
 hm:integer;
 amount:integer;
 size:string;
 diff:integer;
 skilla : integer;
 rm:unitptr;
 skilld : integer;
 hold_eq:unitptr;
 wield_eq:unitptr;

code
{
  if ((self.type == UNIT_ST_PC) and (self.skills[SKI_RESIZE_CLOTHES] <= 0))
  {
     act("You have no knowledge in tailoring, you must practice first.",
  A_ALWAYS, self, null, null, TO_CHAR);
     quit;
  }

/*
  rm := unit_room(self);
  if ("$clothes room" in rm.extra)
    goto workshop;

  hold_eq := equipment (self ,WEAR_HOLD);
  wield_eq := equipment (self,WEAR_WIELD);
  if ((not("$refit clothes" in hold_eq.extra)) and
      (not("$refit clothes" in wield_eq.extra)))
  {
     act ("You need to hold or use a proper tailoring tool to work on $2n.",
   A_ALWAYS,self,tgt,null,TO_CHAR);
     quit;
  }
*/
  :workshop:
  if ("$resized" in tgt.extra)
  {
     act("You see that the $2N has already been resized, you are unable "+
         "to do more yourself.",
   A_ALWAYS,self,tgt,null,TO_CHAR);
     quit;
  }

  if (self.type == UNIT_ST_PC)
    skilla := self.skills[SKI_RESIZE_CLOTHES];
  else
    skilla := self.abilities[ABIL_DEX];

  skilld := 2*tgt.value[1] + 6*tgt.value[2];

  hm := skillresist (self.abilities[ABIL_DEX],
      tgt.spells[SPL_CREATION],
      skilla, skilld);

  if (hm<=-100)
    goto major_fail;
  if (hm<-50)
    goto fail;
  if (hm < 0)
  {
     act("Nothing happens.", A_ALWAYS, self, null, null, TO_CHAR);
     quit;
  }

  amount := (100*tgt_pc.height) / tgt.height;
  if (amount > 100)
    diff := amount - 100;
  else
    diff := 100 - amount;
  if (self.endurance
  if (tgt_pc.height>tgt.height)
   size:="enlarges"
  else
   size:="shrinks";

  tgt.max_hp := tgt.max_hp-diff;
  tgt.hp := tgt.hp-diff;
  tgt.height := tgt_pc.height;

  addextra(tgt.extra, {"$resized"}, "");

  self.endurance := self.endurance - diff;

  if (tgt_pc==self)
  {
     act("You skillfully work on $2n till it $3t enough to fit.",
  A_ALWAYS, self, tgt, size, TO_CHAR);
     act("$1n skillfully works on $2n till it $3t enough to fit $1m",
  A_SOMEONE, self, tgt, size, TO_REST);
  }
  else
  {
     act("You skillfully work on $2n till it $3t enough to fit "+
  tgt_pc.name+".", A_SOMEONE, self, tgt, size, TO_CHAR);
     act("$1n skillfully works on "+tgt.title+
  " till it $3t enough to fit $2n",
  A_SOMEONE, self, tgt_pc, size, TO_REST);
  }
  quit;

  :fail:
  tgt.hp := tgt.hp-diff;
  if (tgt.hp<1) goto major_fail;
  act("You try to $3t $2n but you make a mistake and damage it instead",
      A_ALWAYS, self, tgt, size, TO_CHAR);
  act ("$1n tries to $3t but $1e makes a mistake and damages it instead.",
A_SOMEONE, self, tgt, size, TO_REST);
  quit;

  :major_fail:
  act("You try to $3t $2n but the job is to much for you and you destroy
it.",
      A_ALWAYS, self, tgt, size, TO_CHAR);
  act ("$1n tries to $3t but the job is to much for $1m and he destroys it.",
A_SOMEONE, self, tgt, size, TO_REST);
 addextra (tgt.extra,tgt.names,"Well whatever this was it looks like
someone realy screwed up resizing this.");
 tgt.title:=tgt.title+" (broken)";
  tgt.objecttype := ITEM_TRASH;
tgt.manipulate:=MANIPULATE_TAKE;
tgt.hp := -1;
position_update(tgt);
  quit;

  :fail_endurance:
  act("You begin to work on $2n but relize you are much to tired to finish.",
      A_ALWAYS, self, tgt,null, TO_CHAR);
  act("$1n Begins working on $2n but relizes $1e is to tired and slumps "+
      "back exausted.",
      A_SOMEONE, self, tgt, size, TO_REST);
  quit;
}
dilend

dilbegin res_lth(tgt:unitptr,tgt_pc:unitptr);
external
  integer skillresist (aa : integer, ad : integer,
       sa : integer, sd : integer);
  unitptr unit_room (u:unitptr);
var
 hm:integer;
 amount:integer;
 size:string;
 diff:integer;
 rm:unitptr;
 skilla : integer;
 skilld : integer;
 hold_eq:unitptr;
 wield_eq:unitptr;

code
{
  if ((self.type == UNIT_ST_PC) and (self.skills[SKI_RESIZE_LEATHER] <= 0))
  {
     act("You have no knowledge in leather, you must practice first.",
  A_ALWAYS, self, null, null, TO_CHAR);
     quit;
  }

/*
  rm := unit_room(self);
  if ("$leather room" in rm.extra) goto workshop;

  hold_eq := equipment (self ,WEAR_HOLD);
  wield_eq := equipment (self,WEAR_WIELD);

  if ((not("$refit leather" in hold_eq.extra)) and
      (not("$refit leather" in wield_eq.extra)))
  {
     act ("You need to use a proper leather tool to work on $2n.",
   A_ALWAYS,self,tgt,null,TO_CHAR);
     quit;
  }
*/
  :workshop:
  if ("$resized" in tgt.extra)
  {
     act("You see that the $2N have already been resized, you are unable "+
         "to do more yourself.",
   A_ALWAYS,self,tgt,null,TO_CHAR);
     quit;
  }

  if (self.type == UNIT_ST_PC)
    skilla  :=  self.skills[SKI_RESIZE_LEATHER];
  else
    skilla  :=  self.abilities[ABIL_STR];

  skilld := 2*tgt.value[1] + 6*tgt.value[2];

  hm := skillresist (self.abilities[ABIL_DEX],
      tgt.spells[SPL_CREATION],
      skilla, skilld);

  if (hm<=-100)goto major_fail;

  if (hm<-50) goto fail;

  if (hm < 0)
  {
     act("Nothing happens.", A_ALWAYS, self, null, null, TO_CHAR);
     quit;
  }

  amount := (100*tgt_pc.height) / tgt.height;
  if (amount > 100)
    diff := amount - 100;
  else
    diff := 100 - amount;
  if (self.endurance
  if (tgt_pc.height>tgt.height)
    size := "enlarges"
  else
    size := "shrinks";


  tgt.max_hp := tgt.max_hp-diff;
  tgt.hp := tgt.hp-diff;
  tgt.height := tgt_pc.height;

  addextra(tgt.extra, {"$resized"}, "");

  self.endurance := self.endurance - diff;

  if (tgt_pc==self)
  {
     act("You skillfully work on $2n till it $3t enough to fit.",
  A_ALWAYS, self, tgt, size, TO_CHAR);
     act("$1n skillfully works on $2n till it $3t enough to fit $1m",
  A_SOMEONE, self, tgt, size, TO_REST);
  }
  else
  {
     act("You skillfully work on $2n till it $3t enough to fit
"+tgt_pc.name+".",
  A_SOMEONE, self, tgt, size, TO_CHAR);
     act("$1n skillfully works on "+tgt.title+" till it $3t enough to fit
$2n",
  A_SOMEONE, self, tgt_pc, size, TO_REST);
  }

  quit;
  :fail:
  tgt.hp := tgt.hp-diff;
  if (tgt.hp<1) goto major_fail;
  act("You try to $3t $2n but you make a mistake and damage it instead",
      A_ALWAYS, self, tgt, size, TO_CHAR);
  act ("$1n tries to $3t but $1e makes a mistake and damages it instead.",
A_SOMEONE, self, tgt, size, TO_REST);
  quit;

  :major_fail:

  act("You try to $3t $2n but the job is to much for you and you destroy
it.",
      A_ALWAYS, self, tgt, size, TO_CHAR);
  act ("$1n tries to $3t but the job is to much for $1m and he destroys it.",
A_SOMEONE, self, tgt, size, TO_REST);
 addextra (tgt.extra,tgt.names,"Well whatever this was it looks like
someone realy screwed up resizing this.");
 tgt.title:=tgt.title+" (broken)";
  tgt.objecttype := ITEM_TRASH;
tgt.manipulate:=MANIPULATE_TAKE;

tgt.hp := -1;
position_update(tgt);
  quit;

  :fail_endurance:
  act("You begin to work on $2n but relize you are much to tired to finish.",
      A_ALWAYS, self, tgt,null, TO_CHAR);
  act ("$1n Begins working on $2n but relizes $1e is to tired and slumps
back exausted.",
A_SOMEONE, self, tgt, size, TO_REST);
  quit;

}
dilend

dilbegin res_metal(tgt:unitptr,tgt_pc:unitptr);
external
  integer skillresist (aa : integer, ad : integer,
       sa : integer, sd : integer);
  unitptr unit_room (u:unitptr);

var
 hm:integer;
 amount:integer;
 size:string;
 diff:integer;
 rm:unitptr;
 skilla : integer;
 skilld : integer;
 hold_eq:unitptr;
 wield_eq:unitptr;

code
{
  if ((self.type == UNIT_ST_PC) and (self.skills[SKI_RESIZE_METAL] <= 0))
  {
     act("You have no knowledge in smithing, you must practice first.",
         A_ALWAYS, self, null, null, TO_CHAR);
     quit;
  }

/*
  rm := unit_room(self);
  if ("$metal room" in rm.extra) goto workshop;

  hold_eq := equipment (self ,WEAR_HOLD);
  wield_eq := equipment (self,WEAR_WIELD);

  if ((not("$refit metal" in hold_eq.extra)) and
      (not("$refit metal" in wield_eq.extra)))
  {
     act ("You need to use a proper smithing tool to work on $2n.",
   A_ALWAYS,self,tgt,null,TO_CHAR);
     quit;
  }
*/
  :workshop:
  if ("$resized" in tgt.extra)
  {
     act("You see that the $2N have already been resized, you are unable "+
         "to do more yourself.",
   A_ALWAYS,self,tgt,null,TO_CHAR);
     quit;
  }

  if (self.type == UNIT_ST_PC)
    skilla  :=  self.skills[SKI_RESIZE_METAL];
  else
    skilla := self.abilities[ABIL_STR];

  skilld := 2*tgt.value[1] + 6*tgt.value[2];

  hm := skillresist (self.abilities[ABIL_STR],
      tgt.spells[SPL_CREATION],
      skilla, skilld);

  if (hm<=-100)goto major_fail;
  if (hm<-50) goto fail;
  if (hm < 0)
  {
     act("Nothing happens.", A_ALWAYS, self, null, null, TO_CHAR);
     quit;
  }

  amount := (100*tgt_pc.height) / tgt.height;
  if (amount > 100)
    diff := amount - 100;
  else
    diff := 100 - amount;
  if (self.endurance
  if (tgt_pc.height>tgt.height)
   size:="enlarges"
  else
    size := "shrinks";

  self.endurance := self.endurance - diff;

  tgt.max_hp := tgt.max_hp-diff;
  tgt.hp := tgt.hp-diff;
  tgt.height := tgt_pc.height;

  addextra(tgt.extra, {"$resized"}, "");

  if (tgt_pc==self)
  {
     act("You skillfully work on $2n till it $3t enough to fit.",
  A_ALWAYS, self, tgt, size, TO_CHAR);
     act("$1n skillfully works on $2n till it $3t enough to fit $1m",
  A_SOMEONE, self, tgt, size, TO_REST);
  }
  else
  {
     act("You skillfully work on $2n till it $3t enough to fit "+
  tgt_pc.name+".", A_SOMEONE, self, tgt, size, TO_CHAR);
     act("$1n skillfully works on "+tgt.title+
  " till it $3t enough to fit $2n",
  A_SOMEONE, self, tgt_pc, size, TO_REST);
  }

  quit;
  :fail:
  tgt.hp := tgt.hp-diff;
  if (tgt.hp<1) goto major_fail;
  act("You try to $3t $2n but you make a mistake and damage it instead",
      A_ALWAYS, self, tgt, size, TO_CHAR);
  act ("$1n tries to $3t but $1e makes a mistake and damages it instead.",
A_SOMEONE, self, tgt, size, TO_REST);
  quit;

  :major_fail:

  act("You try to $3t $2n but the job is to much for you and you destroy
it.",
      A_ALWAYS, self, tgt, size, TO_CHAR);
  act ("$1n tries to $3t but the job is to much for $1m and he destroys it.",
A_SOMEONE, self, tgt, size, TO_REST);
 addextra (tgt.extra,tgt.names,"Well whatever this was it looks like
someone realy screwed up resizing this.");
 tgt.title:=tgt.title+" (broken)";
  tgt.objecttype := ITEM_TRASH;
tgt.manipulate:=MANIPULATE_TAKE;

tgt.hp := -1;
position_update(tgt);

  quit;

  :fail_endurance:
  act("You begin to work on $2n but relize you are much to tired to finish.",
      A_ALWAYS, self, tgt,null, TO_CHAR);
  act ("$1n Begins working on $2n but relizes $1e is to tired and slumps
back exausted.",
A_SOMEONE, self, tgt, size, TO_REST);
  quit;

}
dilend

/* The climb skill as a special routine to be connected to ROOMS

 Ticks  : None
 Used on: ROOMS
 Syntax : climb(destination:string, difficulty:integer,
         damage : integer, direction : integer);
 Example: dilcopy climb ("deck@ship", 17, 20, "up");

    This special dil is used for the climb skill and should be set
    on stationary objects (stationary mast, robe, tree, wall, etc).
    The is the skill-amount required to climb. A skill of 100
    would be a 50% chance for the expert thief / climber.
    The is how much damage is given if you fail to climb the
    object. When you fail, you "fall" to the , so you can
    make gravity work correctly.
    The destination can be the same room in which you started.
    The is the direction in which a climb is required
    (most usually it is up, which is macro UP == 5).
*/

dilbegin climb(destination:string, difficulty:integer,
              damage:integer, direction:integer);
external
  integer skillresist (aa : integer, ad : integer,
                            sa : integer, sd : integer);
var
  dest : unitptr;
  skilla : integer;
  hm : integer;
  doorname : string;
code
{
  if (not self.exit_to[direction])
  {
     log("No such exit in climb dil.");
     quit;
  }

  if (not findroom(destination))
  {
     log("No such room in climb dil.");
     quit;
  }

  doorname := self.exit_names[direction].[0];
  /* One could check for an empty name here... */

  :loop:
  wait(SFB_CMD, command("climb") or command(direction));

  if (self.type == UNIT_ST_PC)
  {
     skilla := self.skills[SKI_CLIMB];
     if (skilla < 1)
skilla := -25;
  }
  else
    skilla := self.abilities[ABIL_DEX];

  hm := skillresist (skilla, 0,
      activator.abilities[ABIL_DEX], 0);

  if (hm >= difficulty)
  {
     act("You easily climb the $2t.",
  A_ALWAYS, activator, doorname, null, TO_CHAR);
     act("$1n easily climbs the $2t.",
  A_HIDEINV, activator, doorname, null, TO_ROOM);
     goto loop;
  }

  dest := findroom(destination);

  if (dest != activator.outside)
  {
     act("You fall and hit yourself!",
  A_ALWAYS, activator, doorname, null, TO_CHAR);

     act("$1n failed to climb the $2t and takes a nasty fall...",
  A_SOMEONE, activator, doorname, null, TO_ROOM);

     link(activator, dest);

     act("$1n failed to climb the $2t and lands at your feet...",
  A_SOMEONE, activator, doorname, null, TO_ROOM);
  }
  else
  {
     act("You fail to climb the $2t!",
  A_ALWAYS, activator, doorname, null, TO_CHAR);

     act("$1n failed to climb the $2t!",
  A_SOMEONE, activator, doorname, null, TO_ROOM);
  }

  if (activator.level < IMMORTAL_LEVEL)
  {
     activator.hp := activator.hp - damage;
     position_update(activator);
  }
  block;
  goto loop;
}
dilend



dilbegin do_rescue(arg: string);

external base_rescue(targ: unitptr); /* Needed for SFUN_RESCUE */

var targ: unitptr;

code
{

if (arg == "")
   {
   sendtext("Rescue who?&n", self);
   quit;
   }

targ :=findunit(self, arg, FIND_UNIT_SURRO, null);

if ((not targ) or not(targ.type & UNIT_ST_PC|UNIT_ST_NPC))
   {
   sendtext("Who do you want to rescue?&n", self);
   quit;
   }

base_rescue(targ);

quit;
}

dilend


dilbegin base_rescue(targ: unitptr); /* May be copied on mobs easily */

external integer skillresist (aa : integer, ad : integer,
                             sa : integer, sd : integer);

var tmp: unitptr;
   hm : integer;
   ska: integer;
   skb: integer;

code
{

if (not visible(self, targ))
   {
   sendtext("Who do you want to rescue?&n", self);
   return;
   }

if (targ == self)
   {
   sendtext("What about fleeing instead?&n", self);
   return;
   }

if (targ == self.fighting)
   {
   sendtext("How can you rescue someone you are trying to kill?&n", self);
   return;
   }

foreach (UNIT_ST_PC|UNIT_ST_NPC, tmp)
   {
   if (tmp.fighting == targ)
       break;
   }

if ((tmp == null) or (tmp.fighting != targ))
   {
   act("Nobody is fighting $3m?", A_SOMEONE, self, null, targ, TO_CHAR);
   return;
   }

if ((self.type == UNIT_ST_PC) and (self.skills[SKI_RESCUE] <= 0))
   {
   sendtext("You'd better practice first.&n", self);
   return;
   }

if (self.type == UNIT_ST_PC)
   ska := self.skills[SKI_RESCUE];

else
   ska := (self.abilities[ABIL_DEX] + self.abilities[ABIL_BRA]) / 2;

if (tmp.type == UNIT_ST_PC)
   skb := tmp.skills[SKI_RESCUE];

else
   skb := (tmp.abilities[ABIL_DEX] + tmp.abilities[ABIL_BRA]) / 2;

hm := skillresist(self.abilities[ABIL_DEX], tmp.abilities[ABIL_DEX], ska, skb);

if ((tmp.type == UNIT_ST_PC) and (self.skills[SKI_LEADERSHIP])
  and (targ.master == self))
  hm := hm + self.skills[SKI_LEADERSHIP] / 4;

if (hm < 0)
   {
   sendtext("You bulge in from the left...&n"+
       "...and continue out to the right.&n", self);

   act("$1n bulges in from the left...&n"+
       "...and continues out to the right.",
       A_SOMEONE, self, null, targ, TO_VICT);

   act("$1n makes a feeble attempt to rescue $3n.",
       A_SOMEONE, self, null, targ, TO_NOTVICT);
   return;
   }

sendtext("Banzai! To the rescue...&n", self);

act("You are rescued by $1n, you are confused!",
   A_SOMEONE, self, null, targ, TO_VICT);

act("$1n heroically rescues $3n.", A_SOMEONE, self, null, targ, TO_NOTVICT);

if (targ.fighting == tmp)
   stop_fighting (targ, tmp);

if (self.fighting)
   stop_fighting (self, self.fighting);

if (isset(tmp.charflags, CHAR_SELF_DEFENCE))
   set(self.charflags, CHAR_SELF_DEFENCE);

set_fighting(self, tmp);
set_fighting(tmp, self);

/*
Can I set that?

  if (CHAR_COMBAT(tmp_ch))
    CHAR_COMBAT(tmp_ch)->setMelee(ch);
*/

return;
}

dilend


dilbegin kick(arg : string);

external
  provoked_attack (victim : unitptr, ch : unitptr);

var
  bonus : integer;
  targ  : unitptr;

code
{
  if ((self.type == UNIT_ST_PC) and (self.weapons[WPN_KICK] <= 0))
  {
     act("You must practice first.", A_ALWAYS, self, null, null, TO_CHAR);
     quit;
  }

  if (arg == "")
  {
     if (self.fighting)
     {
 targ := self.fighting;
 goto kick;
     }

     act("Kick who?", A_SOMEONE, self, null, null, TO_CHAR);
     quit;
  }

  targ := findunit(self, arg, FIND_UNIT_SURRO, null);

  if ((targ == null) or not visible(self, targ))
  {
     act("That person is not here!", A_SOMEONE, self, null, null, TO_CHAR);
     quit;
  }

  if (not (targ.type & (UNIT_ST_PC | UNIT_ST_NPC)))
  {
     act("You can't kick that, silly!", A_SOMEONE, self, null, null,
  TO_CHAR);
     quit;
  }

  if (targ == self)
  {
     act("You kick yourself.", A_HIDEINV, self, null, null,
  TO_CHAR);
     act("$1n kicks $1mself.", A_HIDEINV, self, null, null,
  TO_ROOM);
     quit;
  }

  if ((targ.type==UNIT_ST_PC) and
  (self.type==UNIT_ST_PC))
 {
if (not(isset (self.pcflags, PC_PK_RELAXED)))
 {
 act ("You are not allowed to do this unless you sign the book of blood.",
 A_ALWAYS,self,null,null,TO_CHAR);
 quit;
 }

if (not(isset (targ.pcflags, PC_PK_RELAXED)))
 {
 act ("You are not allowed to do this unless $2e signs the book of blood.",
 A_ALWAYS,self,targ,null,TO_CHAR);
 quit;
 }
 }


  :kick:
  if (equipment(self, WEAR_WIELD))
    bonus := 0;
  else
    {
    bonus := rnd(1,(self.weapons[WPN_KICK] - 70));
    if(bonus <= 0) bonus := 1;
    }
  if (self.endurance < 2)
    act("You are too exhausted to attempt that.", A_ALWAYS, self, null,
        null, TO_CHAR);
  else self.endurance := self.endurance - 2;
  provoked_attack (targ, self);
  bonus := meleeattack(self, targ, (bonus+self.level), WPN_KICK);
  quit;
}
dilend



dilbegin tripwt ();
code
{
heartbeat:=PULSE_VIOLENCE*3;
wait (SFB_TICK,TRUE);
quit;
}
dilend

dilbegin trip(arg : string);

external
  integer skillresist (aa : integer, ad : integer,
                            sa : integer, sd : integer);
  provoked_attack (victim : unitptr, ch : unitptr);

var
  skilla : integer;
  skilld : integer;
  hm     : integer;
  targ   : unitptr;

code
{
  if ((self.type == UNIT_ST_PC) and (self.skills[SKI_TRIP] <= 0))
  {
     act("You must practice first.", A_ALWAYS, self, null, null, TO_CHAR);
     quit;
  }

  if (arg == "")
  {
     if (self.fighting)
     {
 targ := self.fighting;
 goto trip;
     }
     else
     {
 act("Who do you wish to trip?", A_SOMEONE, self, null, null,
     TO_CHAR);
 quit;
     }
  }

  targ := findunit(self, arg, FIND_UNIT_SURRO, null);

  if ((targ == null) or not visible(self, targ))
  {
     act("That person is not here!", A_SOMEONE, self, null, null, TO_CHAR);
     quit;
  }

  if (not (targ.type & (UNIT_ST_PC | UNIT_ST_NPC)))
  {
     act("You can't trip that, silly!", A_SOMEONE, self, null, null,
  TO_CHAR);
     quit;
  }

  if (targ == self)
  {
     act("You trip over your own feet.", A_HIDEINV, self, null, null,
  TO_CHAR);
     act("$1n trips over $1s own feet.", A_SOMEONE, self, null, null,
  TO_ROOM);
     quit;
  }


  if ((targ.type==UNIT_ST_PC) and
  (self.type==UNIT_ST_PC))
 {
if (not(isset (self.pcflags, PC_PK_RELAXED)))
 {
 act ("You are not allowed to do this unless you sign the book of blood.",
 A_ALWAYS,self,null,null,TO_CHAR);
 quit;
 }

if (not(isset (targ.pcflags, PC_PK_RELAXED)))
 {
 act ("You are not allowed to do this unless $2e signs the book of blood.",
 A_ALWAYS,self,targ,null,TO_CHAR);
 quit;
 }
 }

  if (not (RACE_IS_MAMMAL(targ.race) or RACE_IS_HUMANOID(targ.race)))
  {
     act("There doesn't seem to be a way to effectively trip $3n.",
         A_SOMEONE, self, null, targ, TO_CHAR);
     quit;
  }

  if ( ((targ.weight - self.weight) > 350) )
  {
     act("You quickly find that $3e is much to heavy to trip...ouch.",
         A_SOMEONE, self, null, targ, TO_CHAR);
     quit;
  }

  if (targ.position <= POSITION_STUNNED)
  {
     act("$3e is already down!", A_SOMEONE, self, null, targ, TO_CHAR);
     quit;
  }

  :trip:
  provoked_attack (targ, self);

if (dilfind ("tripwt@skills",targ))
{
act ("$3n anticipates $1n's trip and leaps harmlessly over.",
 A_ALWAYS, self,null,targ,TO_NOTVICT);
act ("You try to trip again but $3n anticipates your trip and leaps harmlessly over.",
 A_ALWAYS, self,null,targ,TO_CHAR);
 act ("You notice $3n trying to trip you again and you leap harmlessly over $3s leg.",
  A_ALWAYS, targ,null,self,TO_CHAR);
  quit;
  }

  if (self.type == UNIT_ST_PC)
    skilla := self.skills[SKI_TRIP];
  else
    skilla := self.abilities[ABIL_DEX];

  if (targ.type == UNIT_ST_PC)
    skilld := targ.skills[SKI_TRIP];
  else
    skilld := targ.abilities[ABIL_DEX];

  hm := skillresist (self.abilities[ABIL_DEX],
      targ.abilities[ABIL_DEX],
      skilla, skilld);
  if (self.endurance < 10)
    act("You are too exhausted to attempt that.", A_ALWAYS, self, null,
        null, TO_CHAR);
  else self.endurance := self.endurance - 10;
  if (hm < -25)
  {
     change_speed(self, PULSE_VIOLENCE);
     act("You fumble your trip attempt and stumble!.", A_ALWAYS, self,
  null, targ, TO_CHAR);
     act("$1n ducks clumsily and attempts to sweep your feet!.",
  A_ALWAYS, self, null, targ, TO_VICT);
     act("$1n attempts to trip $3n but fails miserably.", A_SOMEONE, self,
  null, targ, TO_NOTVICT);
     quit;
  }

  if (hm < 0)
  {
     change_speed(self, PULSE_VIOLENCE / 2);
     act("You fumble your trip attempt on $3n!.", A_ALWAYS, self, null, targ,
  TO_CHAR);
     act("$1n ducks and attempts to sweeep your feet!.", A_ALWAYS, self,
  null, targ, TO_VICT);
     act("$1n attempts to trip $3n but fails.", A_SOMEONE, self, null, targ,
  TO_NOTVICT);
     quit;
  }

dilcopy ("tripwt@skills",targ);
  change_speed(targ, PULSE_VIOLENCE);
  act("You make a quick move and trip $3n.", A_ALWAYS, self, null, targ,
      TO_CHAR);
  act("$1n ducks quickly and sweeps your feet from under you.",
      A_ALWAYS, self, null, targ, TO_VICT);
  act("$1n makes a quick manuever and trips $3n.", A_SOMEONE, self, null,
      targ, TO_NOTVICT);
  quit;
}
dilend

dilbegin scan (arg : string);

external
  string dirstring@function(dir : integer);
  room_display@skills(the_dir : string, place : unitptr);

var
  room      : unitptr;

  ex_num    : integer;
  recur_num : integer;
  verify    : integer;
  temp_int  : integer;
  the_dir   : integer;

  tstr      : string;
  tstr2     : string;
  atoied    : string;

  cant_see1 : stringlist;
  cant_see2 : stringlist;
  cant_see3 : stringlist;

code
{
  heartbeat := PULSE_SEC;
  if (self.position != POSITION_STANDING)
  {
     act("You need to be standing and have room to look about you.",
         A_ALWAYS, self, null, null, TO_CHAR);
     quit;
  }

  atoied := getword(arg);

  if ((atoied == "north") or (atoied == "n"))
  {
     the_dir := 0;
     goto sing_prep;
  }

  else if ((atoied == "east") or (atoied == "e"))
  {
     the_dir := 1;
     goto sing_prep;
  }
  else if ((atoied == "south") or (atoied == "s"))
  {
     the_dir := 2;
     goto sing_prep;
  }
  else if ((atoied == "west") or (atoied == "w"))
  {
     the_dir := 3;
     goto sing_prep;
  }
  else if ((atoied == "up") or (atoied == "u"))
  {
     the_dir := 4;
     goto sing_prep;
  }
  else if ((atoied == "down") or (atoied == "d"))
  {
     the_dir := 5;
     goto sing_prep;
  }
  else if ((atoied == "northeast") or (atoied == "ne"))
  {
     the_dir := 6;
     goto sing_prep;
  }
  else if ((atoied == "northwest") or (atoied == "nw"))
  {
     the_dir := 7;
     goto sing_prep;
  }
  else if ((atoied == "southeast") or (atoied == "se"))
  {
     the_dir := 8;
     goto sing_prep;
  }
  else if ((atoied == "southwest") or (atoied == "sw"))
  {
     the_dir := 9;
     goto sing_prep;
  }

  goto arg_proc;

:sing_prep:

  if (self.skills[SKI_SCAN] >= 100) recur_num := 3;
  else if (self.skills[SKI_SCAN] >= 40) recur_num := 2;
  else recur_num := 1;

  goto start_single;

:arg_proc:

  if (atoied == "")
     recur_num := 1;
  else if ("0" in atoied)
     recur_num := 1;
  else recur_num := atoi(atoied);

  if (recur_num == 0)
  {
     act("You can't scan that!",
         A_ALWAYS, self, null, null, TO_CHAR);
     quit;
  }

  else if ((recur_num == 2) and (self.skills[SKI_SCAN] < 40))
  {
     act("You must practice further in order to scan that far.",
         A_ALWAYS, self, null, null, TO_CHAR);
     quit;
  }
  else if ((recur_num == 3) and (self.skills[SKI_SCAN] < 100))
  {
     act("You must practice further in order to scan that far.",
         A_ALWAYS, self, null, null, TO_CHAR);
     quit;
  }
  else if (recur_num > 3)
  {
     act("No one can scan through more than three rooms away, no matter " +
         "what their skill!",
         A_ALWAYS, self, null, null, TO_CHAR);
     quit;
  }
  else if ((recur_num < 1) or (recur_num > 3))
  {
     act("I don't think so.",
         A_ALWAYS, self, null, null, TO_CHAR);
     quit;
  }

  if (self.outside.type != UNIT_ST_ROOM)
  {
     act("You cannot scan here.",
         A_ALWAYS, self, null, null, TO_CHAR);
     quit;
  }

  if (arg != "") goto single_dir;

  ex_num := 0;
  verify := 0;

  while (ex_num < 10)
  {
     tstr := dirstring@function(ex_num);
     if (not(self.outside.exit_to[ex_num])) goto cannot_see;
     else if (isset(self.outside.exit_info[ex_num], EX_CLOSED))
        goto cannot_see;
     if (not(verify))
     {
        verify := 1;
        act("&c+wClosest to this place you see:&cw",
            A_ALWAYS, self, null, null, TO_CHAR);
     }

     room := null;
     room := self.outside.exit_to[ex_num];
     if (room == null)
        act("Room is a null.",
            A_ALWAYS, self, null, null, TO_CHAR);
     room_display@skills(tstr, room);
     goto next_exit;

:cannot_see:
  addstring(cant_see1, tstr);

:next_exit:
     ex_num := ex_num + 1;
  }

  if ((cant_see1) and (not(cant_see1.[0] == "")))
  {
     tstr2 := "You cannot see";
     tstr2 := tstr2 + " " + cant_see1.[0];

     temp_int := 1;
     while (temp_int < (length(cant_see1) - 1) )
     {
        tstr2 := tstr2 + ", " + cant_see1.[temp_int];

        temp_int := temp_int + 1;
     }

     if (length(cant_see1) > 1)
        tstr2 := tstr2 + " or " + cant_see1.[length(cant_see1) - 1];
     tstr2 := tstr2 + ".";
     act(tstr2,
         A_ALWAYS, self, null, null, TO_CHAR);
  }

  if ((recur_num < 2) or (verify == 0)) goto end;

  verify := 0;

  ex_num := 0;

  act("&n&c+wAnd casting your gaze further away:&cw",
      A_ALWAYS, self, null, null, TO_CHAR);

  while (ex_num < 10)
  {
     tstr := dirstring@function(ex_num);
     if (not(self.outside.exit_to[ex_num])) goto cannot_see2;
     else if (isset(self.outside.exit_info[ex_num], EX_CLOSED))
        goto cannot_see2;

     if (not(self.outside.exit_to[ex_num].exit_to[ex_num])) goto no_see2;
else if (isset(self.outside.exit_to[ex_num].exit_info[ex_num],
                    EX_CLOSED)) goto no_see2;

     if (not(verify))
     {
        verify := 1;
     }

     room := null;
     room := self.outside.exit_to[ex_num].exit_to[ex_num];
     if (room == null)
        act("Room is a null.",
            A_ALWAYS, self, null, null, TO_CHAR);
     room_display@skills(tstr, room);
     goto next_exit2;

:no_see2:
  addstring(cant_see2, tstr);

:cannot_see2:

:next_exit2:
     ex_num := ex_num + 1;
  }

  if ((cant_see2) and (not(cant_see2.[0] == "")))
  {
     tstr2 := "You cannot see any further";
     tstr2 := tstr2 + " " + cant_see2.[0];

     temp_int := 1;
     while (temp_int < (length(cant_see2) - 1) )
     {
        tstr2 := tstr2 + ", " + cant_see2.[temp_int];

        temp_int := temp_int + 1;
     }

     if (length(cant_see2) > 1)
        tstr2 := tstr2 + " or " + cant_see2.[length(cant_see2) - 1];
     tstr2 := tstr2 + ".";
     act(tstr2,
         A_ALWAYS, self, null, null, TO_CHAR);
  }

  if ((recur_num < 3) or (verify == 0)) goto end;

  verify := 0;

  ex_num := 0;

  act("&n&c+wAnd at the limit of your vision:&cw",
      A_ALWAYS, self, null, null, TO_CHAR);

  while (ex_num < 10)
  {
     tstr := dirstring@function(ex_num);
     if (not(self.outside.exit_to[ex_num])) goto cannot_see3;
     else if (isset(self.outside.exit_info[ex_num], EX_CLOSED))
        goto cannot_see3;

     if (not(self.outside.exit_to[ex_num].exit_to[ex_num])) goto cannot_see3;
else if (isset(self.outside.exit_to[ex_num].exit_info[ex_num],
                    EX_CLOSED)) goto cannot_see3;

     if (not(self.outside.exit_to[ex_num].exit_to[ex_num].exit_to[ex_num]))
        goto no_see3;
else if (isset(self.outside.exit_to[ex_num].exit_to[ex_num].exit_info[ex_num],
              EX_CLOSED)) goto no_see3;

     if (not(verify))
     {
        verify := 1;
     }

     room := null;
     room := self.outside.exit_to[ex_num].exit_to[ex_num].exit_to[ex_num];
     if (room == null)
        act("Room is a null.",
            A_ALWAYS, self, null, null, TO_CHAR);
     room_display@skills(tstr, room);
     goto next_exit3;

:no_see3:
  addstring(cant_see3, tstr);

:cannot_see3:

:next_exit3:
     ex_num := ex_num + 1;
  }

  if ((cant_see3) and (not(cant_see3.[0] == "")))
  {
     tstr2 := "You cannot see any further";
     tstr2 := tstr2 + " " + cant_see3.[0];

     temp_int := 1;
     while (temp_int < (length(cant_see3) - 1) )
     {
        tstr2 := tstr2 + ", " + cant_see3.[temp_int];

        temp_int := temp_int + 1;
     }

     if (length(cant_see3) > 1)
        tstr2 := tstr2 + " or " + cant_see3.[length(cant_see3) - 1];
     tstr2 := tstr2 + ".";
     act(tstr2,
         A_ALWAYS, self, null, null, TO_CHAR);
  }

:end:
  quit;

:single_dir:
  if ((arg == "north") or (arg == "n"))
     the_dir := 0;
  else if ((arg == "east") or (arg == "e"))
     the_dir := 1;
  else if ((arg == "south") or (arg == "s"))
     the_dir := 2;
  else if ((arg == "west") or (arg == "w"))
     the_dir := 3;
  else if ((arg == "up") or (arg == "u"))
     the_dir := 4;
  else if ((arg == "down") or (arg == "d"))
     the_dir := 5;
  else if ((arg == "northeast") or (arg == "ne"))
     the_dir := 6;
  else if ((arg == "northwest") or (arg == "nw"))
     the_dir := 7;
  else if ((arg == "southeast") or (arg == "se"))
     the_dir := 8;
  else if ((arg == "southwest") or (arg == "sw"))
     the_dir := 9;
  else
  {
     act("That is not a valid direction to scan. It must be " +
         "north, east, south, west, up, down, northwest, northeast, " +
         "southwest, or southeast.",
         A_ALWAYS, self, null, null, TO_CHAR);
     quit;
  }

:start_single:

  verify := 0;

  tstr := dirstring@function(the_dir);
  if (not(self.outside.exit_to[the_dir])) goto sing_see1;
  else if (isset(self.outside.exit_info[the_dir], EX_CLOSED))
     goto sing_see1;

  if (not(verify))
  {
     verify := 1;
     act("&c+wClosest to this place you see:&cw",
         A_ALWAYS, self, null, null, TO_CHAR);
  }

  room := null;
  room := self.outside.exit_to[the_dir];
  room_display@skills(tstr, room);
  goto sing_part2;

:sing_see1:
  act("You cannot see " + tstr + ".",
      A_ALWAYS, self, null, null, TO_CHAR);
  goto end;


:sing_part2:

  if (recur_num < 2) goto end;
  if (verify == 0) goto end;

  verify := 0;

  act("&n&c+wAnd casting your gaze further away:&cw",
      A_ALWAYS, self, null, null, TO_CHAR);

  if (not(self.outside.exit_to[the_dir].exit_to[the_dir])) goto sing_see2;
  else if (isset(self.outside.exit_to[the_dir].exit_info[the_dir], EX_CLOSED))
     goto sing_see2;

  if (not(verify))
  {
     verify := 1;
  }

  room := null;
  room := self.outside.exit_to[the_dir].exit_to[the_dir];
  room_display@skills(tstr, room);
  goto sing_part3;

:sing_see2:
  act("You cannot see any further " + tstr + ".",
      A_ALWAYS, self, null, null, TO_CHAR);
  goto end;

:sing_part3:

  if (recur_num < 3) goto end;
  if (verify == 0) goto end;

  verify := 0;

  act("&n&c+wAnd at the limit of your vision:&cw",
      A_ALWAYS, self, null, null, TO_CHAR);

  if (not(self.outside.exit_to[the_dir].exit_to[the_dir].exit_to[the_dir]))
     goto sing_see3;
else if (isset(self.outside.exit_to[the_dir].exit_to[the_dir].exit_info[the_dir], EX_CLOSED))
     goto sing_see3;

  if (not(verify))
  {
     verify := 1;
  }

  room := null;
  room := self.outside.exit_to[the_dir].exit_to[the_dir].exit_to[the_dir];
  room_display@skills(tstr, room);
  goto end;

:sing_see3:
  act("You cannot see any further " + tstr + ".",
      A_ALWAYS, self, null, null, TO_CHAR);
  goto end;
}
dilend

dilbegin room_display(dir_scan : string, place : unitptr);

var
  end_str    : string;
  tmp_str    : string;

  str_list   : stringlist;
  str_list2  : stringlist;

  i          : integer;

  item       : unitptr;
  nxt        : unitptr;

code
{
  heartbeat := PULSE_SEC;
  end_str := "&c+b" + dir_scan + "&cw: " +  place.title;
  end_str := textformat(end_str);
  act(end_str,
      A_ALWAYS, self, null, null, TO_CHAR);

  item := place.inside;
  while( item )
  {
     nxt := item.next;
     if (not(isset (item.flags, UNIT_FL_BURIED)))
     {
        if (item.type == UNIT_ST_PC)
        {
           if ((isset(self.charflags, CHAR_DETECT_LIFE)) and
               ((not(visible(self, item))) or (isset(item.charflags,
                                                     CHAR_HIDE)) ) )
           {
              tmp_str := "&cc" + "You sense a hidden lifeform here.&cw";
              addstring(str_list, tmp_str);
           }
           else if (visible(self, item) and (not(isset(item.charflags,
                                                       CHAR_HIDE))) )
           {
              if (item.position == POSITION_STANDING)
                 tmp_str := "&c+c" + item.name + " " + item.title +
                            " is standing here.&cw";
              else if (item.position == POSITION_MORTALLYW)
                 tmp_str := "&c+c" + item.name + " " + item.title +
                            " is lying here, mortally wounded.&cw";
              else if (item.position == POSITION_INCAP)
                 tmp_str := "&c+c" + item.name + " " + item.title +
                            " is lying here, incapacitated.&cw";
              else if (item.position == POSITION_STUNNED)
                 tmp_str := "&c+c" + item.name + " " + item.title +
                            " is lying here, stunned.&cw";
              else if (item.position == POSITION_SLEEPING)
                 tmp_str := "&c+c" + item.name + " " + item.title +
                            " is sleeping here.&cw";
              else if (item.position == POSITION_SITTING)
                 tmp_str := "&c+c" + item.name + " " + item.title +
                            " is sitting here.&cw";
              else if (item.position == POSITION_RESTING)
                 tmp_str := "&c+c" + item.name + " " + item.title +
                            " is resting here.&cw";
              else if (item.position == POSITION_FIGHTING)
                 tmp_str := "&c+c" + item.name + " " + item.title +
                            " is fighting someone here.&cw";
              else
                 tmp_str := "&c+c" + item.name + " " + item.title +
                            " is here.&cw";

              addstring(str_list, tmp_str);
           }
        }
        if (item.type == UNIT_ST_NPC)
        {
           if ((isset(self.charflags, CHAR_DETECT_LIFE)) and
               ((not(visible(self, item))) or (isset(item.charflags,
                                                     CHAR_HIDE)) ) )
           {
              tmp_str := "&cc" + "You sense a hidden lifeform here.&cw";
              addstring(str_list, tmp_str);
           }
           else if (visible(self, item) and (not(isset(item.charflags,
                                                       CHAR_HIDE))) )
           {
           tmp_str := "&cc" + item.outside_descr + "&cw";
           addstring(str_list, tmp_str);
           }
        }
        if ((item.type == UNIT_ST_OBJ) and visible(self, item))
        {
           tmp_str := "&cw" + item.outside_descr;
           addstring(str_list2, tmp_str);
        }
     }
     item := nxt;
  }
  i := 0;
  while( length(str_list2) > 0 )
  {
     tmp_str := str_list2.[length(str_list2) - 1];
     substring(str_list2, tmp_str);
     i := i + 1;
     while (tmp_str in str_list2)
     {
        i := i + 1;
        substring(str_list2, tmp_str);
     }
     if (i > 1)
     {
        end_str := "[x" + itoa(i) + "] " +
                   tmp_str;
        act(end_str,
            A_ALWAYS, self, null, null, TO_CHAR);
        i := 0;
     }
     else
     {
        end_str := tmp_str;
        act(end_str,
            A_ALWAYS, self, null, null, TO_CHAR);
        i := 0;
     }
  }
  while( length(str_list) > 0 )
  {
     tmp_str := str_list.[length(str_list) - 1];
     substring(str_list, tmp_str);
     i := i + 1;
     while (tmp_str in str_list)
     {
        i := i + 1;
        substring(str_list, tmp_str);
     }
     if (i > 1)
     {
        end_str := "&cc[x" + itoa(i) + "] " +
                   tmp_str;
        act(end_str,
            A_ALWAYS, self, null, null, TO_CHAR);
        i := 0;
     }
     else
     {
        end_str := tmp_str;
        act(end_str,
            A_ALWAYS, self, null, null, TO_CHAR);
        i := 0;
     }
  }

:end:
  return;
}
dilend

/* end of cook skill */

/* End Rangers version 1 */

/* Mesmer- Rewrite of base coded scroll use */
dilbegin ski_scroll_use(arg : string);
external
   integer skillresist@skills(aa : integer,ad : integer,sa : integer,sd : integer);

var
scroll : unitptr;  
i      : integer;
skia   : integer;
skib   : integer;
hm     : integer;
tgt    : unitptr;
sc_st  : string;

code
{

if(arg == "")
{
 act("What do you want to recite?",
      A_ALWAYS, self, null, null, TO_CHAR);
 quit;
}

if(self.skills[SKI_SCROLL_USE] <= 0)
{
 act("You must practice first.",
      A_ALWAYS, self, null, null, TO_CHAR);
 quit;
}

if(isset(self.charflags,CHAR_BLIND))
{
 act("You can't see anything!!! You're blind!",
       A_ALWAYS, self, null, null, TO_CHAR);
 quit;
}


scroll := findunit(self,arg,FIND_UNIT_IN_ME,null);

if(scroll == null)              
{
 act("You do not have such an item.",
    A_ALWAYS, self, null, null, TO_CHAR);
 quit;
}

if(scroll.objecttype != ITEM_SCROLL)
{
 act("Recite is normally used for scroll's.",
    A_ALWAYS, self, null, null, TO_CHAR);
 quit;
}

if(arg == "")
 tgt := self;
  else
   tgt := findunit(self,arg,FIND_UNIT_SURRO,null);

 if(tgt == null)                
  {
   act("No such thing around to recite the scroll on.",
     A_ALWAYS, self, null, null, TO_CHAR);
    quit;
  }

 if(self.type == UNIT_ST_PC)    
    skia := self.skills[SKI_SCROLL_USE];
  else
   skia := self.abilities[ABIL_BRA];

 skib := self.abilities[ABIL_BRA];

hm := skillresist@skills(skia,scroll.value[0],skib,scroll.value[0]);
if(hm < -50)
{
 act("You failed to recite the scroll properly.",
    A_ALWAYS, self, null, null, TO_CHAR);
 act("You fail to recite $2n which then crumbles to dust.",
    A_ALWAYS, self, scroll, null, TO_CHAR);
 destroy(scroll);
 quit;
}

if(hm < 0)
{
  act("You failed to recite the scroll properly.",
      A_ALWAYS, self, null, null, TO_CHAR);
  quit;
}

act("You recite $2n which dissolves.",
   A_ALWAYS, self, scroll, null, TO_CHAR);

scroll.spells[SPL_ALL] := scroll.value[0];
i := 1;

while( i <= 3 )
{

 if(scroll.value[i] != SPL_NONE)
  cast_spell(scroll.value[i],self,scroll,tgt);

 i := i + 1;
}

 send_done("recite",self,scroll,tgt,0,arg,null);


destroy(scroll);
quit;
}
dilend

dilbegin ski_turn(arg : string);
external
   integer skillresist(aa : integer,ad : integer,sa : integer,sd : integer);

var
tgt    : unitptr;
hm     : integer;
skilla : integer;
skillb : integer;
skillc : integer;
skilld : integer;

code
{

if(self.skills[SKI_TURN_UNDEAD] <= 0)
{
 act("You failed.", A_ALWAYS, self, null, null, TO_CHAR);
 quit;
}

tgt := findunit(self,arg,FIND_UNIT_SURRO,null);

if(tgt == null)
{
 act("No such undead here?",
      A_ALWAYS, self, null, null, TO_CHAR);
 quit;
}

if(not(tgt.type & (UNIT_ST_PC | UNIT_ST_NPC)))
{
 act("This one is stone dead for sure!",
     A_ALWAYS, self, null, null, TO_CHAR);
 quit;
}

/* Undead PC ? Thats an idea */

if(self.type == UNIT_ST_PC)
 skilla := self.skills[SKI_TURN_UNDEAD];
  else
   skilla := self.abilities[ABIL_DIV];

if(tgt.type == UNIT_ST_PC)
  skillb := tgt.skills[SKI_TURN_UNDEAD];
   else
    skillb := tgt.abilities[ABIL_DIV];

skillc := self.abilities[ABIL_DIV];
skilld := tgt.abilities[ABIL_DIV];

hm := skillresist(skilla,skillb,skillc,skilld);

if((hm >= 0) and (RACE_IS_UNDEAD(tgt.race)))
{
 act("$3n is terrified!",
     A_SOMEONE, self, null, tgt, TO_CHAR);
 act("$1n turns $3n!",
     A_SOMEONE, self, null, tgt, TO_NOTVICT);
 act("You are turned by $1n!",
     A_SOMEONE, self, null, tgt, TO_VICT);

 send_done("turn",self,null,tgt,0,arg,null);

 exec("flee", tgt);
 }
  else
   {
     act("$3n seems to ignore your attempt.",
         A_SOMEONE, self, null, tgt, TO_CHAR);
     act("$1n attempts to turn $3n.",
         A_SOMEONE, self, null, tgt, TO_NOTVICT);
     act("$1n attempts to turn you.",
         A_SOMEONE, self, null, tgt, TO_VICT);
    }

quit;
}
dilend


dilbegin ski_appraise(arg : string);
external
 integer skillresist(aa : integer,ad : integer,sa : integer,sd : integer);

var
hm   : integer;
skia : integer;
val  : integer;
item : unitptr;
f    : integer;
mstr : string;

code
{

if(arg == "")
{
 act("Appraise what?",
   A_ALWAYS, self, null, null, TO_CHAR);
 quit;
}

if(self.skills[SKI_APPRAISAL] <= 0)
{
 act("You must practice first.",
   A_ALWAYS, self, null, null, TO_CHAR);
 quit;
}

item := findunit(self,arg,FIND_UNIT_HERE,null);

if(item == null)
{
act("No such thing around.",
   A_ALWAYS, self, null, null, TO_CHAR);
quit;
}

if(item.type != UNIT_ST_OBJ)
{
 act("It is not possible to estimate $3s value.",
   A_SOMEONE, self, null, item, TO_CHAR);
 quit;
}

if(self.type == UNIT_ST_PC)
  skia := self.skills[SKI_APPRAISAL];
   else
    skia := self.abilities[ABIL_BRA];

hm := skillresist(self.abilities[ABIL_BRA],50,skia,0);

val := item.cost;

if(hm < 0)
{

  f := -hm / 100;

  val := val * f;
}

if(val < 8)
 val := 8;

mstr := moneystring(val,TRUE);

act("It's probably worth $2t to the right person.",
  A_SOMEONE,self,mstr,null,TO_CHAR);

 send_done("appraise",self,item,null,0,arg,null);


quit;

}
dilend

dilbegin ski_ventril(arg : string);
external
 integer skillresist(aa : integer,ad : integer,sa : integer,sd : integer);

var
hm   : integer;
skia : integer;
skib : integer;
abia : integer;
abib : integer;
vict : unitptr;
str  : string;

code
{

if(arg == "")
{
 act("Who or what should speak?",
    A_ALWAYS, self, null, null, TO_CHAR);
 quit;
}

if(self.skills[SKI_VENTRILOQUATE] <= 0)
{
 act("You must practice first.",
    A_ALWAYS, self, null, null, TO_CHAR);
 quit;
}

vict := findunit(self,arg,FIND_UNIT_SURRO,null);

if(vict == null)
{
 act("No such thing here.",
    A_ALWAYS, self, null, null, TO_CHAR);
 quit;
}

if(arg == "")
{
 sendtext("What should be said?&n", self);
 quit;
}

/* Moan why did papi have to do it this way? */

if(self.type & (UNIT_ST_PC | UNIT_ST_NPC))
  abia := self.abilities[ABIL_BRA] +
          self.abilities[ABIL_CHA];
  else
   abia := 50;

 if(abia > 50) abia := 50;

if(self.type == UNIT_ST_PC)
  skia := self.skills[SKI_VENTRILOQUATE];
   else
    skia := abia;

if(vict.type & (UNIT_ST_PC | UNIT_ST_NPC))
  abib := vict.abilities[ABIL_BRA] +
          vict.abilities[ABIL_CHA];
   else
    abib := 50;

 if(vict.type == UNIT_ST_PC)
   skib := vict.skills[SKI_VENTRILOQUATE];
    else
     skib := abib;

/*
Since I have no skip_spaces funciton I'll do it this way.
Here what I had by just repeating the arg...
Healer Koarn seems to say ' blah'
Stupid spaces.
*/

str := getword(arg);

if(arg != "")
 arg := str+" "+arg;
else
 arg := str;
 
 hm := skillresist(abia,abib,skia,skib);

 if(hm >= 0)
  {
   act("$1n says '$2t'",A_HIDEINV,vict,arg,self,TO_NOTVICT);
   act("Someone says '$2t'",A_HIDEINV,vict,arg,self,TO_CHAR);
   act("$1n seems to say '$2t'",A_SOMEONE, vict, arg, self, TO_VICT);
     
   send_done("ventriloquate",self,null,vict,0,arg,null);

  }
  else
   {
    act("$3n says '$2t'&nin a funny way.",A_HIDEINV, vict, arg, self, TO_NOTVICT);
    act("$3n says '$2t'&nin a funny way.",A_HIDEINV, vict, arg, self, TO_CHAR);
    act("$1n seems to say '$2t'",A_SOMEONE, vict, arg, self, TO_VICT);
    }

quit;
}
dilend

dilbegin ski_weather(arg : string);
external
  integer skillresist(aa : integer,ad : integer,sa : integer,sd : integer);

var
skia : integer;
chng : integer;
list : stringlist;
hm   : integer;
room : unitptr;

code
{

list := {"cloudless",
         "cloudy",
         "rainy",
         "lit by flashes of lightning"};

room := self.outside;

if((room.type != UNIT_ST_ROOM) or
   (room.flags & (UNIT_FL_NO_WEATHER | UNIT_FL_INDOORS)))
{
 act("You can't see the sky from here.",
     A_ALWAYS, self, null, null, TO_CHAR);
 quit;
 }
else
 act("The sky is $3t.",
     A_ALWAYS, self, null, list.[weather], TO_CHAR);

if(self.type == UNIT_ST_PC)
 skia := self.skills[SKI_WEATHER_WATCH];
  else
   skia := self.abilities[ABIL_BRA];

/*
  This is really worthless at the moment without being able to
  really predict weather.
*/

if(skia > 0)
{
 
 if(weather < 3)
  act("The weather will probably become worse.",
    A_ALWAYS, self, null,null, TO_CHAR);
   else
    act("The weather will probably be better.",
      A_ALWAYS, self, null, null, TO_CHAR);

   send_done("weather watching",self,null,null,0,arg,null);
 }


quit;
}
dilend


dilbegin ski_sneak(arg : string);
external
 integer skillresist(aa : integer,ad : integer,sa : integer,sd : integer);

var
hm   : integer;
skia : integer;

code
{

if(self.skills[SKI_SNEAK] <= 0)
{
 act("You must practice first.",
   A_ALWAYS, self, null, null, TO_CHAR);
 quit;
}

if(isaff(self,ID_SNEAK))
{
 subaff(self,ID_SNEAK);
 quit;
}

if(self.type == UNIT_ST_PC)
 skia := self.skills[SKI_SNEAK]
 else
  skia := (self.abilities[ABIL_DEX] +
           self.abilities[ABIL_BRA]) / 2;

hm := skillresist((self.abilities[ABIL_DEX] +
                   self.abilities[ABIL_BRA]) / 2, 60, skia, 50);

if(hm < 0)
{
 act("You make a feeble attempt to move silently.",
      A_ALWAYS, self, null, null, TO_CHAR);
 act("$1n makes a feeble attempt to move silently.",
      A_HIDEINV, self, null, null, TO_REST);
 quit;
}

addaff(self, ID_SNEAK, 6, 4 * (36 * hm) / 6 + 12, CHAR_SNEAK,
       0, 0, TIF_SNEAK_ON, TIF_SNEAK_TICK, TIF_SNEAK_OFF,
       APF_MOD_CHAR_FLAGS);

   send_done("sneak",self,null,null,0,arg,null);


quit;
}
dilend


dilbegin ski_hide(arg : string);
external
 integer skillresist(aa : integer,ad : integer,sa : integer,sd : integer);

var
hm   : integer;
skia : integer;

code
{

if(self.skills[SKI_HIDE] <= 0)
{
 act("You must practice first.",
    A_ALWAYS, self, null, null, TO_CHAR);
 quit;
}

/*
  This changes a bit, instead of actually using the TIF's the C code
  reads the affect data then generates the acts, something not doable
  in dil at this time.
*/

if(isaff(self, ID_HIDE))
{
 subaff(self, ID_HIDE);
 quit;
}

if(self.type == UNIT_ST_PC)
 skia := self.skills[SKI_HIDE]
  else
   skia := (self.abilities[ABIL_DEX] +
            self.abilities[ABIL_BRA]) / 2;

hm := skillresist((self.abilities[ABIL_DEX] +
                   self.abilities[ABIL_BRA]) / 2, 20, skia, 50);

if(hm < 0)
 {
 hm := -hm;
 addaff(self, ID_HIDE, 5, 4 * (24 * hm) / 6 + 12, CHAR_HIDE,
        5, 0, TIF_HIDE_ON, TIF_NOHIDE_TICK, TIF_HIDE_OFF, APF_NONE);
  }
  else
   addaff(self, ID_HIDE, 5, 4 * (24 * hm) / 6 + 12, CHAR_HIDE,
        5, 0, TIF_HIDE_ON, TIF_HIDE_TICK, TIF_HIDE_OFF,
        APF_MOD_CHAR_FLAGS);

   send_done("hide",self,null,null,0,arg,null);

quit;
}
dilend


dilbegin ski_first_aid(arg : string);
external
 integer skillresist(aa : integer,ad : integer,sa : integer,sd : integer);

var
vict : unitptr;
hm   : integer;
skia : integer;

code
{

if(self.skills[SKI_FIRST_AID] <= 0)
{
 act("You must practice first.",
    A_ALWAYS, self, null, null, TO_CHAR);
 quit;
}

if(arg == "")
{
 act("Perform first aid on who?",
    A_ALWAYS, self, null, null, TO_CHAR);
 quit;
}

vict := findunit(self, arg, FIND_UNIT_SURRO, null);

if(vict == null)
{
 act("No such person here.",
    A_ALWAYS, self, null, null, TO_CHAR);
 quit;
}

if(not(vict.type & (UNIT_ST_PC | UNIT_ST_NPC)))
{
 act("Surely you can't perform first aid on that?",
    A_ALWAYS, self, null, null, TO_CHAR);
 quit;
}

if(vict.hp > -1)
{
 act("You can't do much more for $3m.",
   A_ALWAYS, self, null, vict, TO_CHAR);
 quit;
}

if(self.type == UNIT_ST_PC)
 skia := self.skills[SKI_FIRST_AID];
  else
   skia := (self.abilities[ABIL_BRA] +
            self.abilities[ABIL_DIV]) / 2;

hm := skillresist((self.abilities[ABIL_BRA] +
                   self.abilities[ABIL_DIV]) / 2, 10, skia, 40);

if(hm >= 0)
{
 act("You perform first aid on $3n.",
      A_ALWAYS, self, null, vict, TO_CHAR);
 act("Someone performs first aid on you.",
      A_SOMEONE, self, null, vict, TO_VICT);
 vict.hp := vict.hp + 1;
 

}
else if(hm < -50)
 {
  act("You fumble... Real bad..",
      A_ALWAYS, self, null, vict, TO_CHAR);
  act("You feel someone poke in your wounds.",
      A_SOMEONE, self, null, vict, TO_VICT);
  vict.hp := vict.hp - 1;
 }
 else
  {
   act("You fumble...",
       A_ALWAYS, self, null, vict, TO_CHAR);
   act("Someone tries to perform first aid on you.",
       A_SOMEONE, self, null, vict, TO_VICT);
  }

send_done("aid",self,null,vict,hm,arg,null);
position_update(vict);

quit;
}
dilend



%rooms
                                  skill_room
title "The Skill Room"
descr
"Token room."
movement SECT_INSIDE
flags {UNIT_FL_NO_WEATHER}
ALWAYS_LIGHT
end

%end