fight.c

legend/src/fight.c · 320.8 KB

From the archive LoCRelease.tgz

Download the archive   « Back to the archive contents

/**************************************************************************
 *  Original Diku Mud copyright (C) 1990, 1991 by Sebastian Hammer,        *
 *  Michael Seifert, Hans Henrik St{rfeldt, Tom Madsen, and Katja Nyboe.   *
 *                                                                         *
 *  Merc Diku Mud improvments copyright (C) 1992, 1993 by Michael          *
 *  Chastain, Michael Quan, and Mitchell Tse.                              *
 *                                                                         *
 *  In order to use any part of this Merc Diku Mud, you must comply with   *
 *  both the original Diku license in 'license.doc' as well the Merc       *
 *  license in 'license.txt'.  In particular, you may not remove either of *
 *  these copyright notices.                                               *
 *                                                                         *
 *  Much time and thought has gone into this software and you are          *
 *  benefitting.  We hope that you share your changes too.  What goes      *
 *  around, comes around.                                                  *
 ***************************************************************************/
/***************************************************************************
 *  God Wars Mud copyright (C) 1994, 1995, 1996 by Richard Woolcock        *
 *  									   *
 *  Legend of Chrystancia copyright (C) 1999, 2000, 2001 by Matthew Little *
 *  This mud is NOT to be copied in whole or in part, or to be run without *
 *  the permission of Matthew Little. Nobody else has permission to        *
 *  authorise the use of this code.                                        *
 ***************************************************************************/
#if defined(macintosh)
#include <types.h>
#else
#include <sys/types.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "merc.h"

#define MONK_AUTODROP 11
extern bool nosafe;
NCLANS_DATA *nclans_table;

/*
 * Local functions.
 */
void autodrop args ((CHAR_DATA * ch));
bool check_dodge args ((CHAR_DATA * ch, CHAR_DATA * victim, int dt));
void check_killer args ((CHAR_DATA * ch, CHAR_DATA * victim));
bool check_parry args ((CHAR_DATA * ch, CHAR_DATA * victim, int dt));
void dam_message args ((CHAR_DATA * ch, CHAR_DATA * victim, int dam, int dt));
void death_cry args ((CHAR_DATA * ch));
void group_gain args ((CHAR_DATA * ch, CHAR_DATA * victim));
int xp_compute args ((CHAR_DATA * gch, CHAR_DATA * victim));
void set_fighting args ((CHAR_DATA * ch, CHAR_DATA * victim));
bool can_counter args ((CHAR_DATA * ch));
bool can_bypass args ((CHAR_DATA * ch, CHAR_DATA * victim));
int number_attacks args ((CHAR_DATA * ch, CHAR_DATA * victim));
int dambonus args ((CHAR_DATA * ch, CHAR_DATA * victim, int dam, int stance));
int oupdate_damcap args ((CHAR_DATA * ch, CHAR_DATA * victim));
void update_damcap args ((CHAR_DATA * ch, CHAR_DATA * victim));
int add_bonuses args ((CHAR_DATA * ch, CHAR_DATA * victim, int dam, int dt));
void rparasite args((void));

extern CHAR_DATA *quest_target;
extern CHAR_DATA *quest_mob;


/*
 * Control the fights going on.
 * Called periodically by update_handler.
 *
*/
void violence_update (void)
{
   CHAR_DATA *ch;
   CHAR_DATA *ch_next;
   CHAR_DATA *victim;
   CHAR_DATA *rch;
   CHAR_DATA *rch_next;
   CHAR_DATA *mount;
   int chance;
   int sn;
   int level;

   chance = number_percent ();

   for (ch = char_list; ch != NULL; ch = ch->next)
   {
/* testing something lets see
     if ( ch->combined_exp > 0 )
	show_combined_exp( ch );
*/

      if (chance > 60 && ch->position == POS_FIGHTING
	  && IS_CLASS (ch, CLASS_DEMON) && IS_SET (ch->warp, WARP_SCARED))
      {
	 do_flee (ch, "");
	 stc ("You are so scared you flee from combat, COWARD!\n\r", ch);
	 return;
      }

      victim = ch->blinkykill;

      if (ch->blinkykill == NULL)
	 continue;

      if (IS_SET (ch->flag2, AFF2_BLINK_1ST_RD))
      {
	 REMOVE_BIT (ch->flag2, AFF2_BLINK_1ST_RD);
	 SET_BIT (ch->flag2, AFF2_BLINK_2ND_RD);
      }
      else if (IS_SET (ch->flag2, AFF2_BLINK_2ND_RD))
      {

	 REMOVE_BIT (ch->flag2, AFF2_BLINK_2ND_RD);
	 REMOVE_BIT (ch->flag2, AFF2_BLINK_1ST_RD);

	 if (ch->blinkykill->in_room != ch->in_room)
	 {
	    ch->blinkykill = NULL;
	    act ("$n pops back into existence.", ch, NULL, NULL, TO_ROOM);
	    stc ("You pop back into existence.\n\r", ch);
	    stc ("Your victim is no longer in the room.\n\r", ch);
	    break;
	 }

	 act ("$n pops back into existence next to $N.", ch, NULL,
	      ch->blinkykill, TO_NOTVICT);
	 act ("You pop back into existence next to $N.", ch, NULL,
	      ch->blinkykill, TO_CHAR);
	 act ("$n pops back into existence next to you.", ch, NULL,
	      ch->blinkykill, TO_VICT);
	 set_fighting (ch, ch->blinkykill);
	 if (!is_safe (ch, victim))
	 {
	    if (ch->hit > 0)
	    {
	       do_say (ch, "Muhahahahahaha");
	       ch->blinkykill = NULL;
	       multi_hit (ch, victim, gsn_blinky);
	       multi_hit (ch, victim, gsn_blinky);
	       update_pos (victim);
	    }
	 }
      }
   }

   for (ch = char_list; ch != NULL; ch = ch->next)
   {
      ch_next = ch->next;

      if (ch->fight_timer > 0 && ch->fighting == NULL && (IS_NPC(ch) || ch->pcdata->login_timer < 1))
      {
	 ch->fight_timer--;
	 if (ch->fight_timer < 1)
	 {
	    send_to_char ("Your fight timer is now clear.\n\r", ch);
	    ch->fight_timer = 0;
	 }

      }

      if (IS_SET (ch->flag2, AFF2_FROZEN))
      {
	 int break_fail = 60;

	 break_fail -= ch->spl[RED_MAGIC] / 5;

         if (IS_NPC(ch))
            break_fail -= ch->level / 5;
         if (IS_CLASS (ch, CLASS_DROW))
	    break_fail -= ch->spl[RED_MAGIC] / 10;
	 if (IS_CLASS (ch, CLASS_MAGE))
	    break_fail -= ch->spl[RED_MAGIC] / 5;
	 if (IS_CLASS (ch, CLASS_HIGHLANDER))
	    break_fail -= ch->wpn[1] / 20;

	 if (break_fail < 0)
	    break_fail = 0;
	 else
	 {
	    if ((ch->fighting))
	       break_fail /= 3;
	 }

	 if (number_range (1, 100) > break_fail)
	 {
	    send_to_char
	       ("The ice around you is so thin you flex your muscles and shatter it.\n\r",
		ch);
	    act ("The ice around $n shatters revealing one pissed off $n.",
		 ch, NULL, NULL, TO_ROOM);
	    REMOVE_BIT (ch->flag2, AFF2_FROZEN);
	    stop_fighting (ch, FALSE);
	    update_pos (ch);
	    continue;
	 }
	 else
	 {
	    send_to_char ("The ice around you melts a little bit.\n\r", ch);
	    act ("The ice around $n melts a little.", ch, NULL, NULL,
		 TO_ROOM);
	    stop_fighting (ch, FALSE);
	    update_pos (ch);
	    continue;
	 }
      }

      if (IS_SET (ch->monkstuff, MONK_DEATH))
      {
	 if (ch->hit > (ch->max_hit / 2))
	 {
	    ch->hit -= number_range (500, 1000);
	    stc ("Your writhe in agony as magical energies tear you asunder.\n\r", ch);
	    act ("$n's writhes in agony as magical forces tear apart $s body.", ch, NULL, NULL, TO_ROOM);
	 }
	 else
	 {
	    if (number_range (1, 2) == 1)
	    {
	       stc ("You feel the magical forces leave your body.\n\r", ch);
	       act ("The magical forces leave $n's body.", ch, NULL, NULL,
		    TO_ROOM);
	       REMOVE_BIT (ch->monkstuff, MONK_DEATH);
	    }
	    else
	    {
	       ch->hit -= number_range (500, 2000);
	       stc ("Your writhe in agony as magical energies tear you asunder.\n\r", ch);
	       act ("$n's writhes in agony as magical forces tear apart $s body.", ch, NULL, NULL, TO_ROOM);
	    }
	 }
      }

      if (IS_SET (ch->newbits, NEW_POWER))
      {
	 if (ch->move < 75)
	    do_spiritpower (ch, "");
	 else
	    ch->move -= 25;
      }
/*
      if (ch->chi[CURRENT] > 0)
      {
	 if (IS_CLASS (ch, CLASS_MONK)
	     && ch->move > (500 - ch->chi[CURRENT] * 40))
	    ch->move -= ch->chi[CURRENT] * 40;
	 else
	 {
	    if (ch->chi[CURRENT] > 0)
	    {
	       stc ("You feel exhausted, and lose control of your ch'i.\n\r",
		    ch);
	       ch->chi[CURRENT] -= 1;
	    }
	 }
      }
*/
      if ((victim = ch->fighting) == NULL || ch->in_room == NULL)
	 continue;


/*
      if ( ( ch->pcdata->obj_vnum != 0 ) || ( victim->pcdata->obj_vnum != 0 ) )
      {
      	stop_fighting( ch, FALSE );
		continue;
	  }
*/
      if (!IS_NPC (ch) && !IS_NPC (victim) && !is_safe (ch, victim)
	  && !is_safe (victim, ch))
      {
	 ch->fight_timer = 30;
	 victim->fight_timer = 30;
      }
      if (IS_SET (victim->flag2, AFF2_FROZEN))
      {
	 stc ("You chip away at the ice but can do little damage.\n\r", ch);
	 return;
      }

      if (IS_AWAKE (ch) && IS_AWAKE (victim)
	  && ch->in_room == victim->in_room)
      {
	 multi_hit (ch, victim, TYPE_UNDEFINED);
      }
      else
	 stop_fighting (ch, FALSE);

/*
*/

      if ((victim = ch->fighting) == NULL)
	 continue;

      if (IS_NPC (ch) || ch->spl[1] < 4)
         level = ch->level;
      else
         level = (ch->spl[1] * 0.25);

      for (rch = ch->in_room->people; rch != NULL; rch = rch_next)
      {
	 rch_next = rch->next_in_room;

         if (IS_ITEMAFF (ch, ITEMA_SOLARSHIELD) &&
             rch->position == POS_FIGHTING &&
             rch->fighting == ch)
            if ((sn = skill_lookup ("solar flare")) > 0)
               (*skill_table[sn].spell_fun) (sn, level, ch, rch);

         if (IS_AWAKE (rch) && rch->fighting == NULL)
	 {
	    if ((mount = rch->mount) != NULL)
	    {
	       if (mount == ch)
		  multi_hit (rch, victim, TYPE_UNDEFINED);
	       continue;
	    }
	    if (!IS_NPC (ch) || IS_AFFECTED (ch, AFF_CHARM))
	    {
	       if ((!IS_NPC (rch) || IS_AFFECTED (rch, AFF_CHARM))
		   && is_same_group (ch, rch))
		  multi_hit (rch, victim, TYPE_UNDEFINED);
	       continue;
	    }

	    if (IS_NPC (rch) && !IS_AFFECTED (rch, AFF_CHARM))
	    {
	       if (rch->pIndexData == ch->pIndexData || number_bits (3) == 0)
	       {
		  CHAR_DATA *vch;
		  CHAR_DATA *target;
		  int number;

		  target = NULL;
		  number = 0;
		  for (vch = ch->in_room->people; vch; vch = vch->next)
		  {
		     if (can_see (rch, vch) && is_same_group (vch, victim)
			 && number_range (0, number) == 0)
		     {
			target = vch;
			number++;
		     }
		  }

		  if (target != NULL)
		     multi_hit (rch, target, TYPE_UNDEFINED);
	       }
	    }
	 }
      }

   }

   return;
}

/*
 * Do one group of attacks.
 */
void multi_hit (CHAR_DATA * ch, CHAR_DATA * victim, int dt)
{
   OBJ_DATA *wield;
   OBJ_DATA *wield1;
   OBJ_DATA *wield2;
   OBJ_DATA *wield3;
   OBJ_DATA *wield4;
   int sn;
   int level;
   int chance;
   int unarmed;
   int wieldorig = 0;
   int wieldtype = 0;
   int maxcount;
   int countup;
   int wieldie;
   int breathindex = 0;		/*for random dragon breath attacks */

   if (ch->position < POS_SLEEPING)
      return;

   if (number_attacks (ch, victim) == 0)	// no, if you don't get to attacks you don't get to fight.
      return;

   if (dt == gsn_spiket)
   {
      one_hit (ch, victim, dt, 1);
      return;
   }

   if (dt == gsn_magma)
   {
      one_hit (ch, victim, dt, 1);
      return;
   }

   if (dt == gsn_shards)
   {
      one_hit (ch, victim, dt, 1);
      return;
   }

   if (dt == gsn_venomt)
   {
      one_hit (ch, victim, dt, 1);
      return;
   }
   if (dt == gsn_darktendrils && IS_CLASS (ch, CLASS_DROW))
   {
      one_hit (ch, victim, dt, 1);
      return;
   }
   if (dt == gsn_bodyspikes)
   {
      one_hit (ch, victim, dt, 1);
      return;
   }
   if (dt == gsn_headbutt)
   {
      one_hit (ch, victim, dt, 1);
      return;
   }

   if (dt == gsn_quills)
   {
      one_hit (ch, victim, dt, 1);
      return;
   }

   if (dt == gsn_spiderform)
   {
      one_hit (ch, victim, dt, 2);
      one_hit (ch, victim, dt, 2);
      one_hit (ch, victim, dt, 4);
      one_hit (ch, victim, dt, 4);
      one_hit (ch, victim, dt, 6);
      one_hit (ch, victim, dt, 6);
      one_hit (ch, victim, dt, 8);
      one_hit (ch, victim, dt, 8);
      return;
   }

   if (dt == gsn_tail)
   {
      one_hit (ch, victim, dt, 1);
      return;
   }

   if (!IS_NPC (ch) && IS_ITEMAFF (ch, ITEMA_PEACE))
   {
      send_to_char ("You are unable to attack them.\n\r", ch);
      return;
   }

   if (!IS_NPC (victim) && IS_ITEMAFF (victim, ITEMA_PEACE))
   {
      send_to_char ("You can't seem to attack them.\n\r", ch);
      return;
   }

   if (!IS_NPC (ch) && IS_AFFECTED (ch, AFF_SAFE))
   {
      send_to_char ("You cannot attack people under Gaia's protection.\n\r",
		    ch);
      return;
   }

   if (!IS_NPC (victim) && IS_AFFECTED (victim, AFF_SAFE))
   {
      send_to_char ("You cannot attack people under Gaia's protection.\n\r",
		    ch);
      return;
   }

   if (!IS_NPC (ch) && IS_AFFECTED (ch, AFF_STEELSHIELD))
   {
      send_to_char ("You cannot attack while in majesty.\n\r", ch);
      return;
   }

   if (!IS_NPC (victim) && IS_AFFECTED (victim, AFF_STEELSHIELD))
   {
      send_to_char ("They are protected by a powerful being.\n\r", ch);
      return;
   }
/*
	wield1 = get_eq_char(ch, WEAR_WIELD);
	wield2 = get_eq_char(ch, WEAR_HOLD);
	if (wield1 != NULL && wield1->item_type == ITEM_WEAPON)
		wieldorig = 1;
	if (wield2 != NULL && wield2->item_type == ITEM_WEAPON)
		wieldorig += 2;
	wieldtype = wieldorig;
*/

   wield1 = get_eq_char (ch, WEAR_WIELD);
   wield2 = get_eq_char (ch, WEAR_HOLD);
   if (wield1 == NULL && wield2 == NULL)
	wield1 = get_eq_char( ch, WEAR_DUAL);

   wield3 = get_eq_char (ch, WEAR_THIRD);
   wield4 = get_eq_char (ch, WEAR_FOURTH);
   if (wield1 != NULL && wield1->item_type == ITEM_WEAPON)
      wieldorig = 1;
   if (wield2 != NULL && wield2->item_type == ITEM_WEAPON)
      wieldorig += 2;
   if (wield3 != NULL && wield3->item_type == ITEM_WEAPON)
      wieldorig += 4;
   if (wield4 != NULL && wield4->item_type == ITEM_WEAPON)
      wieldorig += 8;
   wieldtype = wieldorig;
   wieldie = number_range (1, 4);

   if (wieldorig == 15)
   {
      if (wieldie == 2)
	 wieldtype = 8;
      else
	 wieldtype = 4;
   }
   if (wieldorig == 14)
   {
      if (wieldie == 2)
	 wieldtype = 8;
      else if (wieldie == 1)
	 wieldtype = 4;
      else if (wieldie == 3)
	 wieldtype = 2;
      else
	 wieldtype = 1;
   }
   if (wieldorig == 13)
   {
      if (wieldie == 1)
	 wieldtype = 8;
      else if (wieldie == 2)
	 wieldtype = 4;
      else
	 wieldtype = 1;
   }
   if (wieldorig == 12)
   {
      if (wieldie == 1)
	 wieldtype = 8;
      else
	 wieldtype = 4;
   }
   if (wieldorig == 11)
   {
      if (wieldie == 1)
	 wieldtype = 8;
      if (wieldie == 2)
	 wieldtype = 2;
      else
	 wieldtype = 1;
   }
   if (wieldorig == 10)
   {
      if (wieldie == 1)
	 wieldtype = 8;
      else
	 wieldtype = 2;
   }
   if (wieldorig == 9)
   {
      if (wieldie == 1)
	 wieldtype = 8;
      else
	 wieldtype = 1;
   }
   if (wieldorig == 8)
      wieldtype = 8;
   if (wieldorig == 7)
   {
      if (wieldie == 1)
	 wieldtype = 4;
      else if (wieldie == 2)
	 wieldtype = 2;
      else
	 wieldtype = 1;
   }
   if (wieldorig == 6)
   {
      if (wieldie == 1 || wieldie == 2)
	 wieldtype = 2;
      else
	 wieldtype = 4;
   }
   if (wieldorig == 5)
   {
      if (wieldie == 1)
	 wieldtype = 4;
      else
	 wieldtype = 1;
   }
   if (wieldorig == 4)
      wieldtype = 4;
   if (wieldorig == 3)
   {
      if (wieldie == 2 || wieldie == 4)
	 wieldtype = 2;
      else
	 wieldtype = 1;
   }
   if (wieldorig == 2)
      wieldtype = 2;
   if (wieldorig == 1)
      wieldtype = 1;

   if (wieldtype == 8)
      wield = wield4;
   else if (wieldtype == 4)
      wield = wield3;
   else if (wieldtype == 2)
      wield = wield2;
   else
      wield = wield1;

   if (ch->stance[0] > 0 && number_percent () == 1)
   {
      int stance = ch->stance[0];

      if (ch->stance[stance] >= 200)
      {
	 special_move (ch, victim);
	 return;
      }
   }

   if (IS_CREATOR (ch) || IS_CLASS (ch, CLASS_MONK))
   {
      if (!IS_NPC (ch))
      {
	 unarmed = number_range (1, 7);
	 if (!IS_NPC (ch) && ch->cmbt[unarmed] != 0)
	 {
	    fightaction (ch, victim, ch->cmbt[unarmed], dt, wieldtype);
	 }
      }
   }

   unarmed = 0;
   one_hit (ch, victim, dt, wieldtype);
   if (victim == NULL || victim->position != POS_FIGHTING)
      return;

   // Check for Highlander empowerment - Krynn
   if (IS_CLASS (ch, CLASS_HIGHLANDER) && (ch->hempower > 0))
   {
      int mult = 1;
      int x;

      if ((ch->quickening[1] >= 25) && (number_range (1, 100) > 10))
	 mult++;
      if ((ch->quickening[1] >= 50) && (number_range (1, 100) > 30))
	 mult++;
      if ((ch->quickening[1] >= 75) && (number_range (1, 100) > 60))
	 mult++;
      if ((ch->quickening[1] >= 100) && (number_range (1, 100) > 90))
	 mult++;

      if (IS_DEMPOWER (ch, HPOWER_USE_BYPASS) && (mult > 1))
         mult += 1;
      if (IS_DEMPOWER (ch, HPOWER_USE_SHIELDLESS) && (mult > 1))
         mult += 1;

      for (x = 0; x == mult; x++)
	 one_hit (ch, victim, dt, wieldtype);
   }

   if (dt == TYPE_UNDEFINED)
   {
      dt = TYPE_HIT;
      if (wield != NULL && wield->item_type == ITEM_WEAPON)
      {
	 dt += wield->value[3];
	 if (wield->value[0] >= 1)
	 {
	    if (wield->value[0] >= 1000)
	       sn = wield->value[0] - ((wield->value[0] / 1000) * 1000);
	    else
	       sn = wield->value[0];
	    if (sn != 0 && victim->position == POS_FIGHTING)
	       (*skill_table[sn].spell_fun) (sn, wield->level, ch, victim);
	 }
      }
   }

   if (victim == NULL || victim->position != POS_FIGHTING)
      return;

   if (ch->fighting != victim || dt == gsn_backstab || dt == gsn_headbutt
       || dt == gsn_bodyspikes)
      return;

   if (!IS_NPC (victim) && !IS_SET (victim->special, SPC_WOLFMAN)
       && number_percent () <= victim->pcdata->learned[gsn_fastdraw])
   {
      OBJ_DATA *obj;
      int wpntype = 0;
      int wpntype2 = 0;

      if ((obj = get_eq_char (victim, WEAR_SCABBARD_R)) != NULL)
      {
	 wpntype = obj->value[3];
	 if (wpntype < 0 || wpntype > 12)
	    wpntype = 0;
	 if ((obj = get_eq_char (victim, WEAR_WIELD)) != NULL)
	 {
	    obj_from_char (obj);
	    obj_to_char (obj, victim);
//	    obj_to_room (obj, victim->in_room);
	    act ("You hurl $p aside.", victim, obj, NULL, TO_CHAR);
	    act ("$n hurls $p aside.", victim, obj, NULL, TO_ROOM);
	 }
	 do_draw (victim, "right");
      }
      if ((obj = get_eq_char (victim, WEAR_SCABBARD_L)) != NULL)
      {
	 wpntype2 = obj->value[3];
	 if (wpntype2 < 0 || wpntype2 > 12)
	    wpntype2 = 0;
	 if ((obj = get_eq_char (victim, WEAR_HOLD)) != NULL)
	 {
	    obj_from_char (obj);
	    obj_to_char (obj, victim);
	    act ("You hurl $p aside.", victim, obj, NULL, TO_CHAR);
	    act ("$n hurls $p aside.", victim, obj, NULL, TO_ROOM);
	 }
	 do_draw (victim, "left");
      }
      if (wpntype > 0)
	 one_hit (victim, ch, TYPE_UNDEFINED, 1);
      if (victim == NULL || victim->position != POS_FIGHTING)
	 return;
      if (wpntype2 > 0)
	 one_hit (victim, ch, TYPE_UNDEFINED, 2);
      if (victim == NULL || victim->position != POS_FIGHTING)
	 return;
   }

   maxcount = number_attacks (ch, victim);
   if (maxcount == 0)
      return;

   if (!IS_NPC (ch))
   {
      chance = 0;
      if (wield != NULL && wield->item_type == ITEM_WEAPON)
      {
	 int tempnum = wield->value[3];

	 chance = (ch->wpn[tempnum]) * 0.5;
      }
      else
	 chance = (ch->wpn[0]) * 0.5;
      if (number_percent () <= chance)
	 maxcount += 1;
   }
   if (IS_CLASS (ch, CLASS_FAE) && IS_EXTRA2 (ch, EXTRA2_FAESPEED))
      maxcount += 3;
   if (wieldorig == 3)
      maxcount += 1;
   for (countup = 0; countup <= maxcount; countup++)
   {
      wieldtype = wieldorig;
      if (wieldorig == 3)
      {
	 if (number_range (1, 2) == 2)
	    wieldtype = 2;
	 else
	    wieldtype = 1;
      }
      one_hit (ch, victim, -1, wieldtype);
      if (victim == NULL || victim->position != POS_FIGHTING)
	 return;
      if (ch->fighting != victim)
	 return;
   }

   if (!IS_NPC (ch) && IS_CLASS (ch, CLASS_VAMPIRE)
       && IS_VAMPAFF (ch, VAM_FANGS) && number_range (1, 2) == 1)
      vam_bite (ch, victim, (TYPE_HIT + 10), 0);
   if (!IS_NPC (ch) && !IS_CLASS (ch, CLASS_VAMPIRE)
       && IS_VAMPAFF (ch, VAM_FANGS))
      one_hit (ch, victim, (TYPE_HIT + 10), 0);

   if (victim == NULL || victim->position != POS_FIGHTING)
      return;
   if (!IS_NPC (ch))
   {
      if (IS_CLASS (ch, CLASS_DROW) && IS_POLYAFF (ch, POLY_ZULO))
      {
	 act ("You spit webbing at $N.", ch, NULL, victim, TO_CHAR);
	 act ("$n spits webbing at $N.", ch, NULL, victim, TO_NOTVICT);
	 act ("$n spits webbing at you.", ch, NULL, victim, TO_VICT);
	 if (number_range (1, 10) == 10
	     && !IS_SET (victim->affected_by, AFF_WEBBED))
	 {
	    act ("$N is coated in a sticky webbing.", ch, NULL, victim,
		 TO_CHAR);
	    act ("$N is coated in a sticky webbing.", ch, NULL, victim,
		 TO_NOTVICT);
	    act ("You are coated in a sticky webbing.", ch, NULL, victim,
		 TO_VICT);
	    SET_BIT (victim->affected_by, AFF_WEBBED);
	 }
      }
      if ( IS_CLASS( ch, CLASS_DROW ) && ( IS_SET( ch->extra2, DROW_DARKTENDRILS ) ) )
	{
	 multi_hit (ch, victim, gsn_darktendrils);
	}
      if (IS_CLASS (ch, CLASS_DROW)
	  && IS_SET (ch->pcdata->powers[1], DPOWER_ARMS))
      {
	 int ii;
	 if (IS_POLYAFF (ch, POLY_SPIDERFORM))
	 {
	    for (ii = 0; ii < 8; ii++)
	    {
	       if (number_range (1, 4) == 1)
	       {
		  one_hit (ch, victim, gsn_spiderform, 0);

	       }
	    }
	 }
	 else
	 {
	    for (ii = 0; ii < 4; ii++)
	    {
	       if (number_range (1, 3) == 1)
	       {
		  one_hit (ch, victim, gsn_spiderform, 0);
	       }
	    }
	 }
      }
  if ( IS_CLASS(ch, CLASS_WRAITH) && ( ch->arcanoi[WPAND] == 5 ) &&
         number_range(1,2) == 1 )       one_hit( ch, victim, gsn_phenom, 0 );
  if ( IS_CLASS(ch, CLASS_WRAITH) && ( ch->arcanoi[WMATE] >= 3 ) &&
         number_range(1,2) == 1 )       one_hit(ch, victim, gsn_buffet, 0);
      if ((IS_CLASS (ch, CLASS_WEREWOLF) && ch->gifts[BLACKFURIES] > 2)
	  && number_range (1, 3) == 1)
	 one_hit (ch, victim, gsn_waspt, 0);
      if (IS_CLASS (ch, CLASS_DEMON) && IS_SET (ch->warp, WARP_SPIKETAIL)
	  && number_range (1, 3) == 1)
	 one_hit (ch, victim, gsn_spiket, 0);
      if (IS_CLASS (ch, CLASS_DEMON) && IS_SET (ch->warp, WARP_SHARDS)
	  && number_range (1, 3) == 1)
	 one_hit (ch, victim, gsn_shards, 0);
      if (IS_CLASS (ch, CLASS_DEMON) && IS_SET (ch->warp, WARP_MAGMA)
	  && number_range (1, 3) == 1)
	 one_hit (ch, victim, gsn_magma, 0);
      if (IS_CLASS (ch, CLASS_DEMON) && IS_SET (ch->warp, WARP_VENOMTONG)
	  && number_range (1, 3) == 1)
	 one_hit (ch, victim, gsn_venomt, 0);
      if (IS_DEMAFF (ch, DEM_HORNS)
	  && number_range (1, 3) == 1)
	 one_hit (ch, victim, gsn_headbutt, 0);
      if (IS_VAMPAFF (ch, VAM_HORNS)
	  && number_range (1, 3) == 1)
	 one_hit (ch, victim, gsn_headbutt, 0);
      if (IS_CLASS (ch, CLASS_DEMON) && IS_DEMAFF (ch, DEM_BODYSPIKES)
	  && number_range (1, 3) == 1)
	 one_hit (ch, victim, gsn_bodyspikes, 0);
      if (IS_CLASS (ch, CLASS_NINJA)
	  && ch->pcdata->powers[NPOWER_NINGENNO] > 3
	  && number_range (1, 3) == 1)
	 one_hit (ch, victim, gsn_shiroken, 0);
      if (IS_CLASS (ch, CLASS_NINJA) && ch->pcdata->powers[NPOWER_TENGU] > 1
	  && number_range (1, 2) == 1)
	 one_hit (ch, victim, gsn_dart_shiroken, 0);

      else if (IS_CLASS (ch, CLASS_NINJA)
	       && ch->pcdata->powers[NPOWER_TENGU] > 2
	       && number_range (1, 2) == 1)
      {
	 one_hit (ch, victim, gsn_dart_shiroken, 0);
	 one_hit (ch, victim, gsn_dart_shiroken, 0);
      }
      if (IS_CLASS (ch, CLASS_DEMON) && IS_DEMAFF (ch, DEM_TAIL)
	  && number_range (1, 3) == 1)
	 one_hit (ch, victim, gsn_tail, 0);
      if (IS_SET (ch->newbits, NEW_QUILLS))
	 one_hit (ch, victim, gsn_quills, 0);

      if (IS_CLASS (ch, CLASS_DEMON) && IS_SET (ch->warp, WARP_WINGS)
	  && number_range (1, 3) == 1)
	 one_hit (ch, victim, gsn_buffet, 0);
      if (IS_CLASS (ch, CLASS_VAMPIRE) && IS_VAMPAFF (ch, VAM_WINGS)
	  && number_range (1, 3) == 1)
	 one_hit (ch, victim, gsn_buffet, 0);
      if (IS_CLASS (ch, CLASS_VAMPIRE) && IS_VAMPAFF (ch, VAM_TAIL)
	  && number_range (1, 3) == 1)
	 one_hit (ch, victim, gsn_tail, 0);
      if (IS_CLASS (ch, CLASS_DRAGON)
	  && IS_SET (ch->pcdata->dragonaff, DRA_TAIL))
	 one_hit (ch, victim, gsn_sweep, 0);
      if (IS_CLASS (ch, CLASS_DRAGON)
	  && IS_SET (ch->pcdata->dragonaff, DRA_WINGS))
	 one_hit (ch, victim, gsn_buffet, 0);
      if (IS_CLASS (ch, CLASS_DRAGON)
	  && IS_SET (ch->pcdata->dragonaff, DRA_FANGS)
	  && (number_range (1, 3) == 1
	      || IS_SET (ch->pcdata->dragonaff, DRA_LUCK)))
	 one_hit (ch, victim, gsn_fangs, 0);

   }
   if (victim == NULL || victim->position != POS_FIGHTING)
      return;
/*
    if (!IS_NPC(ch))
    {   
        int x;
        int acid = 0;
                         
        for( x = 0; x < 5 && ch->pcdata->breath[x] != NULL ; x++)
        {
        if (IS_CLASS(ch, CLASS_DRAGON) && !str_cmp(ch->pcdata->breath[x], "frost")
         && ( (number_range(1,3) == 1) || IS_SET(ch->pcdata->dragonaff, DRA_LUCK))) 
                spell_frost_breath(skill_lookup( "frost breath" ),GET_AGE(ch) * 10, ch, victim); 
        if (IS_CLASS(ch, CLASS_DRAGON) && !str_cmp(ch->pcdata->breath[x], "fire")
         && ( (number_range(1,3) == 1) || IS_SET(ch->pcdata->dragonaff, DRA_LUCK))) 
                spell_fire_breath(skill_lookup( "fire breath" ),GET_AGE(ch) * 10, ch, victim);    
        if (IS_CLASS(ch, CLASS_DRAGON) && !str_cmp(ch->pcdata->breath[x], "lightning")
         && ( (number_range(1,3) == 1) || IS_SET(ch->pcdata->dragonaff, DRA_LUCK))) 
              spell_lightning_breath(skill_lookup( "lightning breath" ),GET_AGE(ch) * 10, ch, victim );
        if (IS_CLASS(ch, CLASS_DRAGON) && !str_cmp(ch->pcdata->breath[x], "acid") && acid < 3
         && ( (number_range(1,3) == 1) || IS_SET(ch->pcdata->dragonaff, DRA_LUCK))) {
               spell_acid_breath(skill_lookup( "acid breath" ),GET_AGE(ch) * 10, ch, victim );
                acid += 1; }       
        if (IS_CLASS(ch, CLASS_DRAGON) && !str_cmp(ch->pcdata->breath[x], "gas")
         && ( (number_range(1,3) == 1) || IS_SET(ch->pcdata->dragonaff, DRA_LUCK))) 
              spell_gas_breath(skill_lookup( "gas breath" ),GET_AGE(ch) * 10, ch, victim );
        }

    }
*/
   if (IS_CLASS (ch, CLASS_DRAGON) && !IS_NPC (ch))
   {
      if (ch->in_room == NULL)
	 return;
      if (victim->in_room == NULL)
	 return;

      /*Breath 1 */

      if (ch->pcdata->breath[0] == NULL)
	 return;

      breathindex = (number_range (1, 50));

      if (IS_SET (ch->pcdata->dragonaff, DRA_LUCK))
	 breathindex += 10;

      if (!str_cmp (ch->pcdata->breath[0], "frost") && (breathindex >= 40))
	 spell_frost_breath (skill_lookup ("frost breath"),
                             GET_AGE(ch) * 5, ch, victim);

      if (!str_cmp (ch->pcdata->breath[0], "fire") && (breathindex >= 40))
	 spell_fire_breath (skill_lookup ("fire breath"),
                            GET_AGE(ch) * 5, ch, victim);

      if (!str_cmp (ch->pcdata->breath[0], "lightning")
	  && (breathindex >= 40))
	 spell_lightning_breath (skill_lookup ("lightning breath"),
                                 GET_AGE(ch) * 5, ch, victim);

      if (!str_cmp (ch->pcdata->breath[0], "acid") && (breathindex >= 45))
	 spell_acid_breath (skill_lookup ("acid breath"),
                            GET_AGE(ch) * 5, ch, victim);

      if (!str_cmp (ch->pcdata->breath[0], "gas") && (breathindex >= 35))
	 spell_gas_breath (skill_lookup ("gas breath"),
                           GET_AGE(ch) * 5, ch, victim);

/*Breath 2*/

      if (ch->pcdata->breath[1] == NULL)
	 return;

      breathindex = (number_range (1, 50));

      if (IS_SET (ch->pcdata->dragonaff, DRA_LUCK))
	 breathindex += 10;

      if (!str_cmp (ch->pcdata->breath[1], "frost") && (breathindex >= 40))
	 spell_frost_breath (skill_lookup ("frost breath"),
                             GET_AGE(ch) * 5, ch, victim);

      if (!str_cmp (ch->pcdata->breath[1], "fire") && (breathindex >= 40))
	 spell_fire_breath (skill_lookup ("fire breath"),
                            GET_AGE(ch) * 5, ch, victim);

      if (!str_cmp (ch->pcdata->breath[1], "lightning")
	  && (breathindex >= 40))
	 spell_lightning_breath (skill_lookup ("lightning breath"),
                                 GET_AGE(ch) * 5, ch, victim);

      if (!str_cmp (ch->pcdata->breath[1], "acid") && (breathindex >= 45))
	 spell_acid_breath (skill_lookup ("acid breath"),
                            GET_AGE(ch) * 5, ch, victim);

      if (!str_cmp (ch->pcdata->breath[1], "gas") && (breathindex >= 35))
	 spell_gas_breath (skill_lookup ("gas breath"),
                           GET_AGE(ch) * 5, ch, victim);

      /*Breath 3 */

      if (ch->pcdata->breath[2] == NULL)
	 return;

      breathindex = (number_range (1, 50));

      if (IS_SET (ch->pcdata->dragonaff, DRA_LUCK))
	 breathindex += 10;

      if (!str_cmp (ch->pcdata->breath[2], "frost") && (breathindex >= 40))
	 spell_frost_breath (skill_lookup ("frost breath"),
                             GET_AGE(ch) * 5, ch, victim);

      if (!str_cmp (ch->pcdata->breath[2], "fire") && (breathindex >= 40))
	 spell_fire_breath (skill_lookup ("fire breath"),
                            GET_AGE(ch) * 5, ch, victim);

      if (!str_cmp (ch->pcdata->breath[2], "lightning")
	  && (breathindex >= 40))
	 spell_lightning_breath (skill_lookup ("lightning breath"),
                                 GET_AGE(ch) * 5, ch, victim);

      if (!str_cmp (ch->pcdata->breath[2], "acid") && (breathindex >= 45))
	 spell_acid_breath (skill_lookup ("acid breath"),
                            GET_AGE(ch) * 5, ch, victim);

      if (!str_cmp (ch->pcdata->breath[2], "gas") && (breathindex >= 35))
	 spell_gas_breath (skill_lookup ("gas breath"),
                           GET_AGE(ch) * 5, ch, victim);

/* Breath 4*/

      if (ch->pcdata->breath[3] == NULL)
	 return;

      breathindex = (number_range (1, 50));

      if (IS_SET (ch->pcdata->dragonaff, DRA_LUCK))
	 breathindex += 10;

      if (!str_cmp (ch->pcdata->breath[3], "frost") && (breathindex >= 40))
	 spell_frost_breath (skill_lookup ("frost breath"),
                             GET_AGE(ch) * 5, ch, victim);

      if (!str_cmp (ch->pcdata->breath[3], "fire") && (breathindex >= 40))
	 spell_fire_breath (skill_lookup ("fire breath"),
                            GET_AGE(ch) * 5, ch, victim);

      if (!str_cmp (ch->pcdata->breath[3], "lightning")
	  && (breathindex >= 40))
	 spell_lightning_breath (skill_lookup ("lightning breath"),
                                 GET_AGE(ch) * 5, ch, victim);

      if (!str_cmp (ch->pcdata->breath[3], "acid") && (breathindex >= 45))
	 spell_acid_breath (skill_lookup ("acid breath"),
                            GET_AGE(ch) * 5, ch, victim);

      if (!str_cmp (ch->pcdata->breath[3], "gas") && (breathindex >= 35))
	 spell_gas_breath (skill_lookup ("gas breath"),
                           GET_AGE(ch) * 5, ch, victim);

      /*Breath 5 */

      if (ch->pcdata->breath[4] == NULL)
	 return;

      breathindex = (number_range (1, 50));

      if (IS_SET (ch->pcdata->dragonaff, DRA_LUCK))
	 breathindex += 10;

      if (!str_cmp (ch->pcdata->breath[4], "frost") && (breathindex >= 40))
	 spell_frost_breath (skill_lookup ("frost breath"),
                             GET_AGE(ch) * 5, ch, victim);

      if (!str_cmp (ch->pcdata->breath[4], "fire") && (breathindex >= 40))
	 spell_fire_breath (skill_lookup ("fire breath"),
                            GET_AGE(ch) * 5, ch, victim);

      if (!str_cmp (ch->pcdata->breath[4], "lightning")
	  && (breathindex >= 40))
	 spell_lightning_breath (skill_lookup ("lightning breath"),
                                 GET_AGE(ch) * 5, ch, victim);

      if (!str_cmp (ch->pcdata->breath[4], "acid") && (breathindex >= 45))
	 spell_acid_breath (skill_lookup ("acid breath"),
                            GET_AGE(ch) * 5, ch, victim);

      if (!str_cmp (ch->pcdata->breath[4], "gas") && (breathindex >= 35))
	 spell_gas_breath (skill_lookup ("gas breath"),
                           GET_AGE(ch) * 5, ch, victim);

   }

   if (victim == NULL || victim->position != POS_FIGHTING)
      return;

   if (!IS_NPC (ch) && IS_CLASS (ch, CLASS_VAMPIRE)
       && IS_VAMPAFF (ch, VAM_SERPENTIS))
      spell_poison (gsn_poison, (ch->level * number_range (5, 10)), ch,
		    victim);
   else if (!IS_NPC (ch) && IS_CLASS (ch, CLASS_WEREWOLF)
	    && ch->pcdata->powers[WPOWER_SPIDER] > 0)
      spell_poison (gsn_poison, (ch->level * number_range (5, 10)), ch,
		    victim);
   else if (!IS_NPC (ch) && IS_CLASS (ch, CLASS_NINJA)
	    && ch->pcdata->powers[NPOWER_NINGENNO] > 4)
      spell_poison (gsn_poison, (ch->level * number_range (5, 10)), ch,
		    victim);

   if (victim->itemaffect < 1)
      return;
   if (IS_NPC (victim) || victim->spl[1] < 4)
      level = victim->level;
   else
      level = (victim->spl[1] * 0.25);
   if (IS_SET (victim->newbits, NEW_MONKFLAME)
       && !IS_AFFECTED (ch, AFF_FLAMING)
       && !WORN_ARTIFACT (ch, ARTI_DEMONS_HEART))
   {
      if (number_percent () > 65)
      {
	 SET_BIT (ch->affected_by, AFF_FLAMING);
         if (!IS_NPC(victim) && !IS_VAMPAFF (victim, VAM_CLAWS))
	 {
	    act ("Your flaming hands catch $n on fire!", ch, NULL, victim,
		 TO_VICT);
	    act ("$N's flaming hands catch $n on fire!", ch, NULL, victim,
		 TO_NOTVICT);
	    act ("$N's flaming hands catch you on fire!.", ch, NULL, victim,
		 TO_CHAR);
	 }
	 else
	 {
	    act ("Your flaming claws catch $n on fire!", ch, NULL, victim,
		 TO_VICT);
	    act ("$N's flaming claws catch $n on fire!", ch, NULL, victim,
		 TO_NOTVICT);
	    act ("$N's flaming claws catch you on fire!.", ch, NULL, victim,
		 TO_CHAR);
	 }
      }
      else
      {
	 return;
      }
   }
   if (IS_ITEMAFF (victim, ITEMA_SHOCKSHIELD) && ch->position == POS_FIGHTING)
      if ((sn = skill_lookup ("lightning bolt")) > 0)
	 (*skill_table[sn].spell_fun) (sn, level, victim, ch);
   if (IS_ITEMAFF (victim, ITEMA_FIRESHIELD) && ch->position == POS_FIGHTING)
      if ((sn = skill_lookup ("fireball")) > 0)
	 (*skill_table[sn].spell_fun) (sn, level, victim, ch);
   if (IS_ITEMAFF (victim, ITEMA_ICESHIELD) && ch->position == POS_FIGHTING)
      if ((sn = skill_lookup ("chill touch")) > 0)
	 (*skill_table[sn].spell_fun) (sn, level, victim, ch);
   if (IS_ITEMAFF (victim, ITEMA_ACIDSHIELD) && ch->position == POS_FIGHTING)
      if ((sn = skill_lookup ("acid blast")) > 0)
	 (*skill_table[sn].spell_fun) (sn, level, victim, ch);
   if (IS_ITEMAFF (victim, ITEMA_CHAOSSHIELD) && ch->position == POS_FIGHTING)
      if ((sn = skill_lookup ("chaos blast")) > 0)
	 (*skill_table[sn].spell_fun) (sn, level, victim, ch);

   return;
}

int number_attacks( CHAR_DATA *ch, CHAR_DATA *victim )
{
  int percentage = 100;

  if ( IS_NPC( ch ) )
  {
    if ( ch->level >=   50 ) percentage += 100;
    if ( ch->level >=  100 ) percentage += 100;
    if ( ch->level >=  500 ) percentage += 100;
    if ( ch->level >= 1000 ) percentage += 100;
    if ( ch->level >= 1500 ) percentage += 100;
    if ( ch->level >= 2000 ) percentage += 200;

    if ( IS_NPC( victim ) )  percentage += 200;

#ifdef FUCK_PLAYERS
    percentage += 5000;
#endif

    return percentage / 100;
  }

  percentage += 250;
  if ( !IS_NPC( victim ) )
  {
    percentage += ( ch->lstatus * 75 );
    percentage -= ( victim->lstatus * 35 );

    if ( ch->lstatus > victim->lstatus )
      percentage += 75;
    else if ( ch->lstatus < victim->lstatus )
      percentage -= 75;
  }
  else
    percentage += ( ch->lstatus * 125 );

  if ( ch->move > 50000 )
    percentage += ( ch->move - 50000 ) / 100;

  if ( !IS_STANCE( ch, STANCE_MONKEY ) )
  {
    if ( IS_STANCE( ch, STANCE_VIPER ) )
      percentage += 100;
    else if ( IS_STANCE( ch, STANCE_MANTIS ) )
      percentage += 200;
    else if ( IS_STANCE( ch, STANCE_TIGER ) )
      percentage += 300;
  }

  if ( IS_ITEMAFF( ch, ITEMA_SPEED ) )
  {
    if ( ( ( ch->move / ch->max_move ) * 100 ) > 50 )
      percentage += 150;
    else
      percentage +=  75;
  }

  if ( IS_SUPER_NPC( ch ) )
  {
    percentage += 100;
    if ( number_range( 0, 4 ) == 0 ) percentage += 200;
  }

  if ( IS_CLASS( ch, CLASS_HIGHLANDER ) )
  {
    if ( IS_DEMPOWER( ch, HPOWER_SPEED ) )
      percentage += 125;

    if ( IS_ITEMAFF( ch, ITEMA_SPEED ) )
      percentage += number_range( 25, 75 );

    percentage = ( percentage * 3 ) / 5;
  }
  else if ( IS_CLASS( ch, CLASS_DROW ) )
  {
    if ( IS_SET( ch->special, SPC_DROW_WAR ) )
      percentage += 100;
    else if ( IS_SET( ch->special, SPC_DROW_ASN) )
      percentage += 25;
    else
      percentage -= 25;

    if ( ch->pcdata->stats[UNI_GEN] < 3 )
      percentage += 40;

    if ( IS_SET( ch->pcdata->powers[1], DPOWER_SPEED ) )
      percentage += 85;
  }
  else if ( IS_CLASS( ch, CLASS_FAE ) )
  {
    if ( IS_SET( ch->extra2, EXTRA2_FAESPEED ) )
      percentage += 125;

    percentage *= 1.1;
  }
  else if ( IS_CLASS( ch, CLASS_DRAGON ) )
  {
    percentage += 15 + ( 10 * GET_AGE( ch ) );
  }
  else if ( IS_CLASS( ch, CLASS_WRAITH ) )
  {
    percentage += 150 + ( percentage / 100 );    
  }
  else if ( IS_CLASS( ch, CLASS_MAGE ) )
  {
    percentage += ( ch->max_mana / 175 );
    
    percentage *= 1.15;
  }
  else if ( IS_CLASS( ch, CLASS_NINJA ) )
  {
    if ( ch->pcdata->powers[NPOWER_CHIKYU] >= 3 )
      percentage += 250;
  }
  else if ( IS_CLASS( ch, CLASS_VAMPIRE ) )
  {
    percentage += 100 * ( get_disc( ch, VAM_CELE ) / 2 );
  }
  else if ( IS_CLASS( ch, CLASS_WEREWOLF ) )
  {
    percentage += 40 * ch->gifts[SILENTSTRIDERS];
  }
  else if ( IS_CLASS( ch, CLASS_DEMON ) )
  {
    if ( IS_DEMPOWER( ch, DEM_SPEED ) )
       percentage += 100;

    if ( IS_SET( ch->warp, WARP_QUICKNESS ) )
       percentage += 100;
  }
  else if ( IS_CLASS( ch, CLASS_MONK ) )
  {
    percentage += 35 * ( ch->monkab[COMBAT] + 1 );
  }
  else
    percentage += 100;

  if ( !IS_CLASS( ch, CLASS_HIGHLANDER ) )
  {
    percentage = ( percentage / 3 ) * 2.2;

    if ( IS_CLASS( ch, CLASS_WEREWOLF ) )
      percentage *= 0.85;
  }

  if ( IS_CLASS( ch, CLASS_MAGE ) )
    percentage *= 0.87;

  return percentage / 100;
}

/*
 * Hit one guy once.
 */
void one_hit (CHAR_DATA * ch, CHAR_DATA * victim, int dt, int handtype)
{
   OBJ_DATA *wield;
   OBJ_DATA *gloves;
   int victim_ac;
   int thac0;
   int thac0_00;
   int thac0_32;
   int dam;
   int diceroll;
   int wdam;
   int level;
   int bufz;
    bool        dual_wield      = FALSE;
   bool right_hand;
   char buf[MSL];

   /*
    * Can't beat a dead char!
    * Guard against weird room-leavings.
    */
   if (victim->position == POS_DEAD || ch->in_room != victim->in_room)
      return;

   if (!IS_NPC (ch) && IS_ITEMAFF (ch, ITEMA_PEACE))
   {
      send_to_char ("You are unable to attack them.\n\r", ch);
      return;
   }

   if (!IS_NPC (victim) && IS_ITEMAFF (victim, ITEMA_PEACE))
   {
      send_to_char ("You can't seem to attack them.\n\r", ch);
      return;
   }

   if (!IS_NPC (ch) && IS_AFFECTED (ch, AFF_SAFE))
   {
      send_to_char ("You cannot attack people under Gaia's protection.\n\r",
		    ch);
      return;
   }

   if (!IS_NPC (victim) && IS_AFFECTED (victim, AFF_SAFE))
   {
      send_to_char ("You cannot attack people under Gaia's protection.\n\r",
		    ch);
      return;
   }

   if (!IS_NPC (ch) && IS_AFFECTED (ch, AFF_STEELSHIELD))
   {
      send_to_char ("You cannot attack while in Majesty.\n\r", ch);
      return;
   }

   if (!IS_NPC (victim) && IS_AFFECTED (victim, AFF_STEELSHIELD))
   {
      send_to_char ("There are far to imposing.\n\r", ch);
      return;
   }

   /*
    * Figure out the type of damage message.
    */
/*
   if (handtype == 8)
   {
      wield = get_eq_char (ch, WEAR_FOURTH);
      right_hand = FALSE;
   }
   else if (handtype == 4)
   {
      wield = get_eq_char (ch, WEAR_THIRD);
      right_hand = FALSE;
   }
   else if (handtype == 2)
   {
      wield = get_eq_char (ch, WEAR_HOLD);
      right_hand = FALSE;
   }
   else
   {
      if (!IS_NPC (ch) && (wield = get_eq_char (ch, WEAR_DUAL)) != NULL);
      else if (!IS_NPC (ch) && IS_SET (ch->extra2, PLR_RIGHTHAND))
	 wield = get_eq_char (ch, WEAR_WIELD);
      else if (!IS_NPC (ch) && IS_SET (ch->act, PLR_LEFTHAND))
	 wield = get_eq_char (ch, WEAR_HOLD);
      else
      {
	 if (number_range (1, 10) > 4 && !IS_NPC (ch))
	    wield = get_eq_char (ch, WEAR_HOLD);
	 else
	    wield = get_eq_char (ch, WEAR_WIELD);
      }
      right_hand = 1;		// improve the right hand anyway...
   }
*/
    /*
     * Figure out the type of damage message.
     */
    if (handtype == 2)
    {
        wield = get_eq_char( ch, WEAR_HOLD );
        right_hand = FALSE;
    }
    else
    {
        wield = get_eq_char( ch, WEAR_WIELD );
        right_hand = TRUE;
    }

    if (wield == NULL)
    {
        wield = get_eq_char( ch, WEAR_DUAL);
        right_hand = TRUE;
        if ((wield != NULL) && (wield->item_type == ITEM_WEAPON))
                dual_wield = TRUE;
    }

   if (dt == TYPE_UNDEFINED)
   {
      dt = TYPE_HIT;
      if (wield != NULL && wield->item_type == ITEM_WEAPON)
	 dt += wield->value[3];
   }

   if (ch->wpn[dt - 1000] > 5)
      level = (ch->wpn[dt - 1000] / 5);
   else
      level = 1;
   if (level > 40)
      level = 40;

   /*
    * Calculate to-hit-armor-class-0 versus armor.
    */
   if (IS_NPC (ch))
   {
      thac0_00 = 20;
      thac0_32 = 0;
   }
   else
   {
      thac0_00 = SKILL_THAC0_00;
      thac0_32 = SKILL_THAC0_32;
   }
   thac0 = 0 - interpolate (level, thac0_00, thac0_32) - (char_hitroll (ch) / 10);
   victim_ac = UMIN (10, char_ac (victim) / 50);
   if (!can_see (ch, victim))
      victim_ac -= 100;

   if (IS_CLASS (ch, CLASS_DRAGON) && IS_SET (ch->pcdata->dragonaff, DRA_TERROR) && IS_NPC (victim))	/*dragons */
   {				/*dragons */
      victim_ac += 200;		/*dragons */
   }				/*dragons */
   /*
    * The moment of excitement!
    */
   while ((diceroll = number_bits (5)) >= 20)
      ;


#ifdef FUCK_PLAYERS
   while (diceroll == 0 || (diceroll != 19 && diceroll < thac0 - victim_ac))
   {
      while ((diceroll = number_bits (5)) >= 20);
   }
#endif
   if (diceroll == 0 || (diceroll != 19 && diceroll < thac0 - victim_ac))
   {
      /* Miss. */
      damage (ch, victim, 0, dt);
      tail_chain ();
      if (!is_safe (ch, victim))
      {
	 improve_wpn (ch, dt, right_hand);
	 improve_stance (ch);
      }
      return;
   }

   /*
    * Hit.
    * Calc damage.
    */

   if (IS_NPC (ch))
   {
      dam = number_range (ch->level, ch->level * 3 / 2);
      if (wield != NULL)
	 dam += dam * 0.5;

#ifdef FUCK_PLAYERS
      dam = dice (1, 30) * 1000;
#endif
   }

   else
   {

      if (IS_SET(ch->more, MORE_LIONSMANE))
         dam = number_range (500, 750);
      else if (IS_CLASS (ch, CLASS_DRAGON) && (wield == NULL || wield->item_type != ITEM_WEAPON))
         dam = number_range (500, 750);
      else if (IS_CLASS (ch, CLASS_WEREWOLF) && (wield == NULL || wield->item_type != ITEM_WEAPON))
         dam = number_range (400, 650);
      else if (IS_SET (ch->newbits, NEW_MONKADAM) && (wield == NULL || wield->item_type != ITEM_WEAPON))
         dam = dice (434, 666);
      else if (IS_VAMPAFF (ch, VAM_CLAWS) && (wield == NULL || wield->item_type != ITEM_WEAPON))
         dam = number_range (200, 400);
      else if (wield != NULL && wield->item_type == ITEM_WEAPON)
	 dam = number_range (wield->value[1], wield->value[2]);
      else
	 dam = number_range (1, 4);
   }

   if (number_range (1, 5) == 2)
   {
      if (ch->fighting == victim && IS_CLASS (ch, CLASS_MONK) && !IS_NPC (ch)
	  && ch->monkab[BODY] > 3)
      {
	 wdam =
	    number_range ((ch->chi[CURRENT] * 6), (ch->chi[CURRENT] * 10));
	 if (victim->alignment < 0)
	    wdam *= 1.5;
	 act ("$n's hands glow with a heavenly aura.", ch, NULL, victim,
	      TO_VICT);
	 act ("$n's aura sears your flesh!", ch, NULL, victim, TO_VICT);
	 act ("Your heavenly aura sears $N's flesh.", ch, NULL, victim,
	      TO_CHAR);
	 act ("$n's hands' heavenly aura sears $N's flesh.", ch, NULL, victim,
	      TO_ROOM);
	 victim->hit -= wdam;
	 update_pos (victim);
      }
   }

   /* Fun with weapons */
   if (!IS_NPC (ch) && wield != NULL)
   {
      if (number_range (1, 5) == 2)
      {
	 if (ch->fighting == victim)
	 {
            if (IS_WEAP (wield, WEAPON_FLAMING) && !WORN_ARTIFACT (victim, ARTI_DEMONS_HEART))
	    {
	       wdam = number_range (1, wield->level / 4 + 1);
	       if (!IS_SET (ch->more, MORE_SHIELDS))
	       {
		  act ("$n is burned by $p.", victim, wield, NULL, TO_ROOM);
		  act ("$p sears your flesh.", victim, wield, NULL, TO_CHAR);
	       }
               hurt_person (ch, victim, wdam);
	       update_pos (victim);
	    }

	    if (IS_WEAP (wield, WEAPON_FROST))
	    {
	       wdam = number_range (1, wield->level / 6 + 2);
	       if (!IS_SET (ch->more, MORE_SHIELDS))
	       {
		  act ("$p freezes $n.", victim, wield, NULL, TO_ROOM);
		  act ("The cold touch of $p surrounds you with ice.", victim,
		       wield, NULL, TO_CHAR);
	       }
               hurt_person (ch, victim, wdam);
	       update_pos (victim);
	    }

	    if (IS_WEAP (wield, WEAPON_POISON))
	    {
	       wdam = number_range (1, wield->level / 6 + 2);
	       if (!IS_SET (ch->more, MORE_SHIELDS))
	       {
		  act ("$n turns green as $p poisons $m.", victim, wield,
		       NULL, TO_ROOM);
		  act ("You feel sick as $p's poisoned edge pierces you.",
		       victim, wield, NULL, TO_CHAR);
	       }
               hurt_person (ch, victim, wdam);

	       update_pos (victim);
	    }
	 }
      }
   }

   dam += char_damroll (ch);
   dam = add_bonuses (ch, victim, dam, dt);

   /* Werewolf Silver Stuff.. */
   if (!IS_NPC (victim) && IS_CLASS (victim, CLASS_WEREWOLF))
   {
      if (number_percent () > victim->pcdata->powers[WPOWER_SILVER])
      {
	 if (is_garou (ch))
	 {
	    if (IS_GAR1 (ch, GAROU_AVENGER))
	       dam *= 3;
	    else if (ch->gifts[AHROUN] >= 4 || ch->gifts[SILVERFANGS] >= 2)
	       dam *= 2.2;
	    else if (wield != NULL && IS_SET (wield->spectype, SITEM_SILVER))
	       dam *= 2;
	    else if ((gloves = get_eq_char (ch, WEAR_HANDS)) != NULL
		     && IS_SET (gloves->spectype, SITEM_SILVER))
	       dam *= 2;
	 }
	 else if (!is_garou (ch))
	 {
	    if (wield != NULL && IS_SET (wield->spectype, SITEM_SILVER))
	       dam *= 2;
	    else if ((gloves = get_eq_char (ch, WEAR_HANDS)) != NULL
		     && IS_SET (gloves->spectype, SITEM_SILVER))
	       dam *= 2;
	 }
      }
   }

   if (dt == gsn_backstab)
   {
      if (IS_CLASS (ch, CLASS_DROW))
	 dam *= number_range (4, 5);
      else
	 dam *= number_range (2, 3);

      if (IS_CLASS (ch, CLASS_NINJA) && !IS_NPC (ch)
	  && ch->pcdata->powers[NPOWER_NINGENNO] >= 2)
	 dam *= number_range (4, 8);
      else
	 dam *= number_range (2, 4);
   }
   if (dt == gsn_garotte)
      dam *= (number_range (3, 5));


   if (dt == gsn_circle)
      dam *= number_range (5, 6);

   if (!IS_NPC (victim) && IS_CLASS (victim, CLASS_HIGHLANDER)
       && IS_DEMPOWER (victim, HPOWER_TOUGHNESS))
   {
      char buf[MAX_STRING_LENGTH];
      int skin;
      int rebound;

      skin = number_range (1, 100);
      rebound = number_range (1, 100);
      if (skin == 20 || skin == 40 || skin == 60 || skin == 80 || skin == 100)
      {
	 stc ("#3You bounce their pathetic blow off your skin#n.\n\r",
	      victim);
	 stc ("#3Your opponent bounces your attack off their skin#n.\n\r",
	      ch);
	 if (rebound == 10 || rebound == 50 || rebound == 100)
	 {
	    sprintf (buf,
		     "#3The bounced blow slams into them#n. [#1%d#n]\n\r",
		     dam / 2);
	    stc (buf, victim);
	    sprintf (buf,
		     "#3Your attack bounces and slams into you#n. [#1%d#n]\n\r",
		     dam / 2);
	    stc (buf, ch);
	    dam /= 2;
            damage (victim, ch, dam, dt);
	 }
	 dam = 0;
      }
   }
   if (!IS_NPC (victim) && IS_CLASS (victim, CLASS_DROW)
       && IS_SET (victim->extra2, DROW_DARKTENDRILS))
   {
      int ddodge = number_range (1, 50);

      if (ddodge == 10 || ddodge == 20 || ddodge == 30 || ddodge == 40
	  || ddodge == 50)
      {
         bufz = number_range(1,20);
	 sprintf (buf,"#0You dark aura absorbs the damage and channels some of it into you. #r[#G+#C%d#r]#n.\n\r", bufz);
         stc(buf,victim);
	 stc ("#0Your opponent's dark aura absorbs your damage#n.\n\r", ch);
         victim->hit += bufz;
	 dam = 0;
      }
   }
   damage (ch, victim, dam, dt);

// special arti's -- Serenity
   if ((victim != NULL) && (ch->fighting == victim) && (dam > 0)
       && (wield != NULL) && ((dt - TYPE_HIT >= 0) && (dt - TYPE_HIT <= 12)))
   {
      bool arti = FALSE;
      char movie_buf1[10000];
      char movie_buf2[10000];
      char movie_buf3[10000];
      int activate = 0;
      OBJ_DATA *the_arti;

      if (dam > ch->damcap[DAM_CAP])
	 dam = ch->damcap[DAM_CAP];

      if ((wield != NULL) && OBJ_ARTIFACT (wield))
	 arti = TRUE;
      if ((!arti) && (WORN_ARTIFACT (ch, ARTI_PLATE_IRON_GAUNTLET)))
	 arti = TRUE;
      if ((!arti) && (WORN_ARTIFACT (ch, ARTI_CROWN_OF_CHRYSTANCIA)))
	 arti = TRUE;

      if ((arti) && (IS_ARTIFACT (wield, ARTI_SHATTERED_BLADE)))
      {
	 if ((the_arti = get_artifact (ch, ARTI_SHATTERED_BLADE)) == NULL)
	 {
	    bug ("Supposedly had Shattered Blade, but couldn't find it.", 0);
	    tail_chain ();
	    if (!is_safe (ch, victim))
	    {
	       improve_wpn (ch, dt, right_hand);
	       improve_stance (ch);
	    }
	    return;
	 }
	 activate = the_arti->points;

	 if (activate > 0)
	 {
	    sprintf (movie_buf1,
		     "Slivers of $p tear off and dig into $N's wound causing more damage. #w[ #r%d #w]#n",
		     (dam / 4));
	    sprintf (movie_buf2,
		     "Slivers from $n's $p tear off and dig into your wound causing more damage. #w[ #r%d #w]#n",
		     (dam / 4));
	    sprintf (movie_buf3,
		     "$n's motion causes slivers of $p to tear off and dig into the wound causing more damage to $N.");

	    act (movie_buf1, ch, wield, victim, TO_CHAR);
	    act (movie_buf2, ch, wield, victim, TO_VICT);
	    act (movie_buf3, ch, wield, victim, TO_NOTVICT);
	    hurt_person (ch, victim, (dam / 4));
	    the_arti->points = 0;
	 }
	 else
	    the_arti->points++;
      }

      if ((arti) && (IS_ARTIFACT (wield, ARTI_METEORIC_AXE)))
      {
	 if ((the_arti = get_artifact (ch, ARTI_METEORIC_AXE)) == NULL)
	 {
	    bug ("Supposedly had Axe of Meteoric Steel, but couldn't find it.", 0);
	    tail_chain ();
	    if (!is_safe (ch, victim))
	    {
	       improve_wpn (ch, dt, right_hand);
	       improve_stance (ch);
	    }
	    return;
	 }
	 activate = the_arti->points;
	 if (activate > 1)
	 {
	    sprintf (movie_buf1,
		     "Small meteors fly forth from $p striking $N. #w[ #r%d #w]#n",
		     (dam / 10));
	    sprintf (movie_buf2,
		     "Small meteors fly forth from $n's $p striking you. #w[ #r%d #w]#n",
		     (dam / 10));
	    sprintf (movie_buf3,
		     "Small meteors fly forth from $n's $p striking $N.");

	    act (movie_buf1, ch, wield, victim, TO_CHAR);
	    act (movie_buf2, ch, wield, victim, TO_VICT);
	    act (movie_buf3, ch, wield, victim, TO_NOTVICT);
	    hurt_person (ch, victim, (dam / 10));
	    the_arti->points = 0;
	 }
	 else
	    the_arti->points++;
      }

      if ((arti) && (WORN_ARTIFACT (ch, ARTI_PLATE_IRON_GAUNTLET)))
      {
	 OBJ_DATA *wield_obj;

	 if ((the_arti = get_artifact (ch, ARTI_PLATE_IRON_GAUNTLET)) == NULL)
	 {
	    bug ("Supposedly had Plate Iron Gauntlet, but couldn't find it.",
		 0);
	    tail_chain ();
	    if (!is_safe (ch, victim))
	    {
	       improve_wpn (ch, dt, right_hand);
	       improve_stance (ch);
	    }
	    return;
	 }
	 activate = the_arti->points;

	 if (activate > 1)
	 {
	    wield_obj =
	       create_object (get_obj_index (ARTI_PLATE_IRON_GAUNTLET), 0);
	    sprintf (movie_buf1,
		     "You strike $N hard with your Gauntlets. #w[ #r%d #w]#n",
		     (dam / 10));
	    sprintf (movie_buf2,
		     "$n strikes you hard with $s Gauntlets. #w[ #r%d #w]#n",
		     (dam / 10));
	    sprintf (movie_buf3, "$n strikes $N hard with $s Gauntlets.");

	    act (movie_buf1, ch, NULL, victim, TO_CHAR);
	    act (movie_buf2, ch, NULL, victim, TO_VICT);
	    act (movie_buf3, ch, NULL, victim, TO_NOTVICT);
	    hurt_person (ch, victim, (dam / 10));
	    extract_obj (wield_obj);
	    the_arti->points = 0;
	 }
	 else
	    the_arti->points++;
      }

      if ((arti) && (WORN_ARTIFACT (ch, ARTI_CROWN_OF_CHRYSTANCIA)))
      {
	 OBJ_DATA *wield_obj;

	 if ((the_arti =
	      get_artifact (ch, ARTI_CROWN_OF_CHRYSTANCIA)) == NULL)
	 {
	    bug ("Supposedly had Crown of Chrystancia, but couldn't find it.",
		 0);
	    tail_chain ();
	    if (!is_safe (ch, victim))
	    {
	       improve_wpn (ch, dt, right_hand);
	       improve_stance (ch);
	    }
	    return;
	 }
	 activate = the_arti->points;

	 if (activate > 1)
	 {
	    wield_obj =
	       create_object (get_obj_index (ARTI_CROWN_OF_CHRYSTANCIA), 0);
	    sprintf (movie_buf1,
		     "The Crown of Chrystancia on your head blasts $N with a coruscating wave of energy. #w[ #r%d #w]#n",
		     (dam / 10));
	    sprintf (movie_buf2,
		     "The Crown of Chrystancia on $n's head blasts you with a coruscating wave of energy. #w[ #r%d #w]#n",
		     (dam / 10));
	    sprintf (movie_buf3,
		     "The Crown of Chrystancia on $n's head blasts $N with a coruscating wave of energy.");

	    act (movie_buf1, ch, NULL, victim, TO_CHAR);
	    act (movie_buf2, ch, NULL, victim, TO_VICT);
	    act (movie_buf3, ch, NULL, victim, TO_NOTVICT);
	    hurt_person (ch, victim, (dam / 10));
	    extract_obj (wield_obj);
	    the_arti->points = 0;
	 }
	 else
	    the_arti->points++;
      }

      if ((arti) && (IS_ARTIFACT (wield, ARTI_ICE_SHARD)))
      {
	 if ((the_arti = get_artifact (ch, ARTI_ICE_SHARD)) == NULL)
	 {
	    bug ("Supposedly had Ice Shard, but couldn't find it.", 0);
	    tail_chain ();
	    if (!is_safe (ch, victim))
	    {
	       improve_wpn (ch, dt, right_hand);
	       improve_stance (ch);
	    }
	    return;
	 }
	 activate = the_arti->points;

	 if (activate > 1)
	 {
	    non_katana_ice_sword (ch, wield);
	    the_arti->points = 0;
	 }
	 else
	    the_arti->points++;
      }
   }

   tail_chain ();
   if (!is_safe (ch, victim))
   {
      improve_wpn (ch, dt, right_hand);
      improve_stance (ch);
   }
   return;
}

int add_bonuses (CHAR_DATA * ch, CHAR_DATA * victim, int dam, int dt)
{
   float mult = 1;
   float reduct = 1;
   int stance;
   int wpn;

   if (!IS_AWAKE (victim))
      dam *= 2;

   ch->mult = 0;
   victim->reduct = 0;

   if (!IS_NPC (ch))
   {
      /* Stance Bonuses.. */
      stance = ch->stance[0];
      if (IS_STANCE (ch, STANCE_NORMAL))
	 mult += .25;
      else
	 dam = dambonus (ch, victim, dam, stance);
      /* ----------------- */

      if (IS_CLASS (ch, CLASS_VAMPIRE))
      {
         if (get_disc(ch, VAM_POTE) > 0)
            mult += (get_disc(ch, VAM_POTE) / 2);

	 /* Vampire Day\Night Bonus Shit */
         if (weather_info.sunlight == SUN_LIGHT && dam > 1 && !IS_IMMUNE (ch,IMM_SUNLIGHT))
	    mult -= .5;
	 else
	    mult += .5;
      }
      if (IS_CLASS (ch, CLASS_WEREWOLF))
      {
	 if (ch->pcdata->stats[UNI_RAGE] > 150)
	    mult += .10;
	 if (ch->gifts[PHILODOX] >= 4)
	    mult += .6;
	 if (ch->gifts[SHADOWLORDS] >= 1)
	    mult += .7;
	 if (ch->gifts[GETOFFENRIS] >= 3)
	    mult += 1;
	 if (ch->gifts[STARGAZERS] >= 1)
	    mult += .3;
	 if (ch->gifts[AHROUN] >= 1)
	    mult += .3;
	 if (ch->gifts[AHROUN] >= 2)
	    mult += .3;
	 if (ch->gifts[BLACKFURIES] >= 3)
	    mult += .3;
      }

      if (IS_CLASS (ch, CLASS_MAGE))
      {
	 if (IS_SET (ch->mflags, MAGE_TELEKINETICS))
	    mult += .5;
	 if (IS_SET (ch->mflags, MFLAGS_DIMMAK))
	    mult += .4;
	 if (ch->spheres[MENT] >= 1)
	    mult += (ch->spheres[MENT] * .3);
      }
      if (IS_CLASS (ch, CLASS_MONK))
      {
	 if (ch->chi[CURRENT] > 0)
	    mult += (ch->chi[CURRENT] / 2);
      }
      if (IS_CLASS (ch, CLASS_FAE))
      {
         mult += 1;
         if (IS_EXTRA2 (ch, EXTRA2_WYRM))
            mult += 1.5;
         if (IS_EXTRA2 (ch, EXTRA2_FAEMIGHT))
            mult += 3.5;
      }
      if (IS_CLASS (ch, CLASS_DROW))
      {
	 if IS_SET
            (ch->pcdata->powers[1], DPOWER_TOUGHSKIN) mult += 2.5;
      }
      if (IS_CLASS (ch, CLASS_DEMON))
      {
	 if (IS_DEMPOWER (ch, DEM_MIGHT))
	    mult += 1.7;
         if (IS_SET (ch->warp, WARP_WEAK))
            mult -= .5;
         if (IS_SET (ch->warp, WARP_GBODY))
            mult -= .5;
         if (IS_SET (ch->warp, WARP_STRONGARMS))
            mult += 1;
      }

      if (IS_CLASS (ch, CLASS_DRAGON) && IS_SET (ch->pcdata->dragonaff, DRA_TERROR))
      {
         mult += (GET_AGE(ch) / 4);
      }

      if (IS_CLASS (ch, CLASS_HIGHLANDER))
      {
	 if (IS_DEMPOWER (ch, HPOWER_MIGHT))
	    mult += 1.7;
      }

      if (IS_CLASS (ch, CLASS_NINJA))
      {
	 if (ch->pcdata->powers[NPOWER_CHIKYU] > 1)
	    mult += 3;
      }

      if (ch->move >= 50000)
      {
          mult += ch->move / 50000;
      }
   }

   if (!IS_NPC (victim))
   {
      if (IS_ITEMAFF (victim, ITEMA_RESISTANCE))
	 reduct += 5;
      if (IS_CLASS (victim, CLASS_HIGHLANDER))
      {
	 reduct += 2;
      }
      if (IS_CLASS (victim, CLASS_HIGHLANDER))
      {
	 if (IS_DEMPOWER (victim, HPOWER_TOUGHNESS))
	    reduct += 1.7;
      }
      if (IS_CLASS (victim, CLASS_DRAGON)
          && IS_SET (victim->pcdata->dragonaff, DRA_TERROR))
      {
         reduct += (GET_AGE(victim) / 4);
      }
      if (!IS_NPC (ch) && IS_CLASS (victim, CLASS_DRAGON)
	  && IS_SET (victim->pcdata->dragonaff, DRA_TOUGHNESS))
      {
         reduct += (GET_AGE(victim) / 4);
      }
      if (IS_CLASS (victim, CLASS_VAMPIRE))
      {
         if (get_disc(victim, VAM_FORT) > 0)
            reduct += (get_disc(victim, VAM_FORT) * .6);
      }
      if (IS_CLASS (victim, CLASS_WEREWOLF))
      {
	 if (victim->pcdata->stats[UNI_RAGE] > 150)
	    reduct += .5;

	 if (victim->gifts[PHILODOX] >= 1)
	    reduct += .1;
	 if (victim->gifts[PHILODOX] >= 3)
	    reduct += .2;
	 if (victim->gifts[SHADOWLORDS] >= 2)
	    reduct += .2;
	 if (victim->gifts[SHADOWLORDS] >= 4)
	    reduct += .3;
         if (IS_GAR1 (victim, WOLF_COCOON))
            reduct += 1.25;
      }

      if (IS_CLASS (victim, CLASS_MAGE))
      {
	 if (IS_SET (victim->mflags, MAGE_BETTERBODY))
            reduct += .75;
	 if (IS_SET (victim->mflags, MAGE_POLYAPPEAR))
	    reduct += number_range (0, 4) * 0.3;
	 if (victim->spheres[MENT] >= 0)
	    reduct += victim->spheres[MENT] * 0.3;
      }
      if (IS_CLASS (victim, CLASS_FAE))
      {
         reduct += 0.75;
	 if (IS_SET (victim->extra2, EXTRA2_FAETOUGH))
	    reduct += 1.4;
         if (IS_EXTRA2 (victim, EXTRA2_WYRM))
            reduct += 1.5;
         if (IS_GAR1 (victim, WW_GRANITE))
            reduct += 3;
      }
      if (IS_CLASS (victim, CLASS_DEMON))
      {
	 if (IS_DEMPOWER (victim, DEM_TOUGH))
	    reduct += 1.4;
         if (IS_SET (victim->warp, WARP_SBODY))
            reduct += 1.5;
         if (IS_SET (victim->warp, WARP_CBODY))
            reduct += 1.5;
         if (IS_SET (victim->warp, WARP_STAMINA))
            reduct += 2;
      }

      if (IS_CLASS (ch, CLASS_DEMON) && IS_SET (ch->warp, WARP_WEAK))
	 reduct += .5;


      if (IS_CLASS (victim, CLASS_MONK))
      {
	 if (victim->chi[CURRENT] > 0)
            reduct += victim->chi[CURRENT] / 2;
	 if (victim->monkab[BODY] >= 2)
	    reduct += .5;
      }
      if (IS_CLASS (victim, CLASS_DROW))
      {
         reduct += 1;
	 if IS_SET
            (victim->pcdata->powers[1], DPOWER_TOUGHSKIN) reduct += 2.5;
      }
      if (IS_CLASS (victim, CLASS_NINJA))
      {
	 reduct += 1.4;
         if (victim->pcdata->powers[NPOWER_CHIKYU] > 6)
            reduct += 2.25;
      }
   }

 if (IS_CLASS(ch, CLASS_WRAITH))
        mult += 4;
        if (IS_CLASS(victim, CLASS_WRAITH))
        reduct += 2;
   if (!IS_NPC (ch) && dt >= TYPE_HIT)
   {
      wpn = (dt - 1000);
      dam = dam + (dam * ((ch->wpn[wpn] + 1) / 100));
   }

   if (!IS_NPC (victim))
   {
      if (dt >= TYPE_HIT)
      {
	 wpn = (dt - 1000);
	 if ((wpn == 1 || wpn == 3) && IS_IMMUNE (victim, IMM_SLASH))
	    dam /= (number_range (1, 4));
	 if ((wpn == 2 || wpn == 11) && IS_IMMUNE (victim, IMM_STAB))
	    dam /= (number_range (1, 4));
	 if ((wpn == 6 || wpn == 7 || wpn == 8)
	     && IS_IMMUNE (victim, IMM_SMASH))
	    dam /= (number_range (1, 4));
         if ((wpn == 0 || wpn == 5 || wpn == 10) && IS_IMMUNE (victim, IMM_ANIMAL))
	    dam /= (number_range (1, 4));
	 if ((wpn == 4 || wpn == 9 || wpn == 12)
	     && IS_IMMUNE (victim, IMM_MISC))
	    dam /= (number_range (1, 4));
      }
   }

   if (IS_NPC (ch) && ch->level > 200)
   {
      mult += (ch->level / 200);
   }

   if (IS_NPC (victim))
   {
      reduct += (victim->level / 200);
      reduct += 1;
   }

   ch->mult = mult;
   victim->reduct = reduct;

   dam *= mult;
   dam /= reduct;

   return dam;
}

bool can_counter (CHAR_DATA * ch)
{
   if (IS_STANCE (ch, STANCE_MONKEY))
      return TRUE;
   return FALSE;
}

bool can_bypass (CHAR_DATA * ch, CHAR_DATA * victim)
{
/*
   if (IS_NPC (ch))		//  || IS_NPC (victim))  -- BS... You can bypass mob parry/dodge.
      return FALSE;
*/
   //else 
   if (IS_STANCE (ch, STANCE_VIPER))
      return TRUE;
   else if (IS_STANCE (ch, STANCE_MANTIS))
      return TRUE;
   else if (IS_STANCE (ch, STANCE_TIGER))
      return TRUE;
   return FALSE;
}

int oupdate_damcap (CHAR_DATA * ch, CHAR_DATA * victim)
{
 int vic_ac;
 int dam=0;
  if (is_safe(ch, victim)) return 0;

  vic_ac = char_ac(victim) * 0.01; 
  dam -= vic_ac;
  if (dam <= 0) dam = 1;
  if (dam > 1000000) dam = 1000000;
  if (IS_AFFECTED(victim, AFF_PROTECT) && IS_EVIL(ch))
    dam -= dam * 0.25;

  if ( (IS_AFFECTED (victim, AFF_SANCTUARY) && dam > 1 ) || ( WORN_ARTIFACT( victim, ARTI_CLOAK_OF_THE_ARCHMAGI ) && dam > 1 ) )
    dam *= 0.5;
/*  if ( IS_AFFECTED(victim, AFF_HOLYAURA))
    dam *= 0.5;*/
  if (IS_ITEMAFF(victim, ITEMA_RESISTANCE))
    dam -= dam * 0.25;
  return dam;
}
void update_damcap (CHAR_DATA * ch, CHAR_DATA * victim)
{
   OBJ_DATA *obj1;
   OBJ_DATA *obj2;
   OBJ_DATA *obj3;
   OBJ_DATA *obj4;
   int max_dam = 1000;

   if (IS_NPC (ch))
   {
      max_dam += (ch->level * 100);	// for NPCs
#ifdef FUCK_PLAYERS
      max_dam = 30000;
#endif
   }
   else
   {

      if (IS_CLASS (ch, CLASS_FAE))
      {
	 max_dam += 2700;
	 if (IS_EXTRA2 (ch, EXTRA2_FAEMIGHT))
	    max_dam += 1050;
      }				// 4750

      if (IS_CLASS (ch, CLASS_DROW))
      {
	 if (ch->pcdata->stats[UNI_GEN] < 3)
	    max_dam += 3000;
	 else if (ch->pcdata->stats[UNI_GEN] < 4)
	    max_dam += 2800;
	 else if (ch->pcdata->stats[UNI_GEN] < 5)
	    max_dam += 2700;
	 else if (ch->pcdata->stats[UNI_GEN] < 6)
	    max_dam += 2600;
	 else
	    max_dam += 2500;

	 if (weather_info.sunlight == SUN_DARK)
	    max_dam += 1050;
	 if (IS_SET (ch->newbits, NEW_DROWHATE))
	    max_dam += 1050;
	 if (IS_SET (ch->special, SPC_DROW_WAR))
	    max_dam += 250;
         if (IS_SET (ch->special, SPC_DROW_ASN))
            max_dam += 250;
	 else if (IS_SET (ch->special, SPC_DROW_MAG))
	    max_dam += 200;
	 else if (IS_SET (ch->special, SPC_DROW_CLE))
	    max_dam += 150;

      }

        if (IS_CLASS(ch,CLASS_WRAITH))
        {
         if (ch->arcanoi[WRAGE] == 0)
            max_dam += 2500;
         if (ch->arcanoi[WRAGE] == 1)
            max_dam += 3000;
         if (ch->arcanoi[WRAGE] == 2)
            max_dam += 3250;
         if (ch->arcanoi[WRAGE] == 3)
            max_dam += 3750;
         if (ch->arcanoi[WRAGE] == 4)
            max_dam += 4000;
         if (ch->arcanoi[WRAGE] >= 5)
            max_dam += 4500;
         }
      if (IS_CLASS (ch, CLASS_DEMON))
      {
	 if (ch->pcdata->stats[UNI_GEN] < 3)
	    max_dam += 1500;
	 else if (ch->pcdata->stats[UNI_GEN] < 4)
	    max_dam += 1400;
	 else if (ch->pcdata->stats[UNI_GEN] < 5)
	    max_dam += 1300;
	 else if (ch->pcdata->stats[UNI_GEN] < 6)
	    max_dam += 1200;
	 else
	    max_dam += 1100;
	 if (IS_SET (ch->special, SPC_DEMON_LORD))
	    max_dam += 500;
	 else if (IS_SET (ch->special, SPC_PRINCE))
	    max_dam += 400;
	 else if (IS_SET (ch->special, SPC_SIRE))
	    max_dam += 300;
	 else
	    max_dam += 100;

	 if (ch->in_room != NULL && ch->in_room->vnum == 30000)
	    max_dam += 20000;

	 max_dam += (ch->pcdata->stats[DEMON_POWER] * 20);
	 max_dam += 1000;

      }
      if (!IS_NPC (ch) && IS_SET (ch->warp, WARP_DAMCAP))
	 max_dam += 800;
      if (!IS_NPC (ch) && IS_CLASS (ch, CLASS_DEMON)
	  && IS_DEMPOWER (ch, DEM_MIGHT))
	 max_dam += 200;

      if (IS_CLASS (ch, CLASS_DRAGON))
      {
         max_dam += GET_AGE(ch) * 100;
	 if (ch->pcdata->stats[UNI_GEN] < 3)
	    max_dam += 2500;
	 else if (ch->pcdata->stats[UNI_GEN] < 4)
	    max_dam += 2400;
	 else if (ch->pcdata->stats[UNI_GEN] < 5)
	    max_dam += 2300;
	 else if (ch->pcdata->stats[UNI_GEN] < 6)
	    max_dam += 2200;
	 else
	    max_dam += 2100;
      }
      if (IS_CLASS (ch, CLASS_VAMPIRE))
      {
	 if (ch->pcdata->stats[UNI_GEN] < 3)
	    max_dam += 2500;
	 else if (ch->pcdata->stats[UNI_GEN] < 4)
	    max_dam += 2400;
	 else if (ch->pcdata->stats[UNI_GEN] < 5)
	    max_dam += 2300;
	 else if (ch->pcdata->stats[UNI_GEN] < 6)
	    max_dam += 2200;
	 else
	    max_dam += 2100;
	 max_dam += (ch->pcdata->stats[UNI_RAGE]);
	 if (ch->pcdata->rank == AGE_METHUSELAH)
	    max_dam += 750;
	 else if (ch->pcdata->rank == AGE_ELDER)
	    max_dam += 300;
	 else if (ch->pcdata->rank == AGE_ANCILLA)
	    max_dam += 150;
         if (get_disc(ch, VAM_POTE) > 0)
            max_dam += (200 * get_disc(ch, VAM_POTE));
	 if IS_SET
	    (ch->newbits, NEW_TIDE) max_dam += 500;

      }
      if (IS_CLASS (ch, CLASS_MONK))
      {
	 max_dam += 300;
	 if (ch->pcdata->stats[UNI_GEN] < 3)
	    max_dam += 1700;
	 else if (ch->pcdata->stats[UNI_GEN] < 4)
	    max_dam += 1600;
	 else if (ch->pcdata->stats[UNI_GEN] < 5)
	    max_dam += 1500;
	 else
	    max_dam += 1400;
	 if (ch->monkab[COMBAT] > 0)
	    max_dam += (ch->monkab[COMBAT] * 100);
	 if (ch->chi[CURRENT] > 0)
	    max_dam += (ch->chi[CURRENT] * 200);
      }
      if (IS_CLASS (ch, CLASS_NINJA))
      {
	 if (ch->pcdata->stats[UNI_GEN] < 3)
	    max_dam += 1700;
	 else if (ch->pcdata->stats[UNI_GEN] < 4)
	    max_dam += 1600;
	 else if (ch->pcdata->stats[UNI_GEN] < 5)
	    max_dam += 1500;
	 else
	    max_dam += 1400;

	 max_dam += (ch->pcdata->stats[UNI_RAGE] * 5);
	 if (ch->pcdata->powers[NPOWER_CHIKYU] >= 6
	     && ch->pcdata->powers[HARA_KIRI] > 0)
	    max_dam += 800;
	 if (ch->pcdata->powers[NPOWER_CHIKYU] >= 2)
	    max_dam += 550;
      }
      if (IS_CLASS (ch, CLASS_MAGE))
      {
	 max_dam += 1500;
	 if (ch->pcdata->stats[UNI_GEN] < 3)
	    max_dam += 2500;
	 else if (ch->pcdata->stats[UNI_GEN] < 4)
	    max_dam += 2400;
	 else if (ch->pcdata->stats[UNI_GEN] < 5)
	    max_dam += 2300;
	 else if (ch->pcdata->stats[UNI_GEN] < 6)
	    max_dam += 2200;
	 else
	    max_dam += 2100;

	 if (ch->spheres[MENT] > 0)
	    max_dam += (200 * ch->spheres[MENT]);
      }
      if (IS_CLASS (ch, CLASS_WEREWOLF))
      {
	 if (ch->pcdata->stats[UNI_GEN] < 3)
	    max_dam += 2700;
	 else if (ch->pcdata->stats[UNI_GEN] < 4)
	    max_dam += 2600;
	 else if (ch->pcdata->stats[UNI_GEN] < 5)
	    max_dam += 2500;
	 else
	    max_dam += 2300;
	 if (weather_info.moonphase == MOON_HALF
	     && weather_info.time_of_day == NIGHT)
	    max_dam += 500;
	 if (weather_info.moonphase == MOON_FULL
	     && weather_info.time_of_day == NIGHT)
	    max_dam += 1000;
	 if (IS_SET (ch->special, SPC_WOLFMAN))
	    max_dam += (ch->pcdata->stats[UNI_RAGE]);
	 if (ch->gifts[PHILODOX] >= 3)
	    max_dam += 400;
	 if (ch->gifts[SILVERFANGS] > 0)
	    max_dam += 300;
	 if (ch->gifts[GETOFFENRIS] >= 3)
	    max_dam += 400;
	 if (IS_ITEMAFF (ch, ITEMA_SUNSHIELD))
	    max_dam += 500;
      }
      if (IS_CLASS (ch, CLASS_HIGHLANDER))
      {
	 if (get_eq_char (ch, WEAR_DUAL) != NULL)
	 {
	    max_dam += (ch->wpn[1] * 3.3);
	    //      max_dam += (ch->race * 10);
	 }
	 else
	 {
	    max_dam += (ch->wpn[0] * 3.0);
	    //      max_dam += (ch->race * 10);
	 }
      }

   }
/* Crab Monkey and Swallow take damcap? */

   if (victim->stance[0] != STANCE_MONKEY)
   {
      int stance = ch->stance[0];

      if (ch->stance[0] == STANCE_BULL)
	 max_dam += ch->stance[stance];
      else if (ch->stance[0] == STANCE_DRAGON)
	 max_dam += ch->stance[stance];
      else if (ch->stance[0] == STANCE_TIGER)
	 max_dam += ch->stance[stance];
   }
   if (ch->stance[0] != STANCE_MONKEY)
   {
      int stance = victim->stance[0];

      if (victim->stance[0] == STANCE_CRAB)
	 max_dam -= victim->stance[stance];
      else if (victim->stance[0] == STANCE_DRAGON)
	 max_dam -= victim->stance[stance];
      else if (victim->stance[0] == STANCE_SWALLOW)
	 max_dam -= victim->stance[stance];
   }

/* Legend Status Bonuses */
   if (!IS_NPC (ch))
   {
      if (ch->lstatus == 1)
	 max_dam += 50;
      if (ch->lstatus == 2)
	 max_dam += 100;
      if (ch->lstatus == 3)
	 max_dam += 200;
      if (ch->lstatus == 4)
	 max_dam += 300;
      if (ch->lstatus == 5)
	 max_dam += 400;
      if (ch->lstatus == 6)
	 max_dam += 500;
      if (ch->lstatus == 7)
	 max_dam += 1000;
      if (ch->lstatus == 8)
	 max_dam += 1500;
      if (ch->lstatus == 9)
	 max_dam += 2000;
      if (ch->lstatus == 10)
	 max_dam += 2500;
      if (ch->lstatus == 11)
	 max_dam += 3500;
   }

   /* Status Damcap 50/status */
   if (!IS_NPC (ch))
      max_dam += (ch->race * 100);

/*   if (IS_ITEMAFF (ch, ITEMA_ARTIFACT))
      max_dam += 500;
   if (IS_ITEMAFF (victim, ITEMA_ARTIFACT))
      max_dam -= 500;*/
   if (IS_SUPER_NPC (ch))
      max_dam += ch->level * 2;
   if (IS_SUPER_NPC (victim))
      max_dam -= victim->level / 2;	// Updated by Serenity to be victim not CH

   if (max_dam < 1000)
      max_dam = 1000;
   if (max_dam > 20000)
      max_dam = 20000;
   if (ch->level >= LEVEL_BUILDER)
      max_dam = 30000;
   if (IS_EXTRA2 (ch, EXTRA2_INFECTED) && IS_PARA (3))
      max_dam *= 1.25;		// moved this AHEAD of the setting of damcap otherwise it's worthless -- Serenity

   // wielded/held Arti stuff
   obj1 = get_eq_char (ch, WEAR_HOLD);
   obj2 = get_eq_char (ch, WEAR_WIELD);
   obj3 = get_eq_char (ch, WEAR_THIRD);
   obj4 = get_eq_char (ch, WEAR_FOURTH);
   if (obj4 == NULL) obj4 = get_eq_char (ch, WEAR_DUAL);

   if (WORN_ARTIFACT (ch, ARTI_MAIDENS_BREATH))
      max_dam += 500;
   else if (WORN_ARTIFACT (ch, ARTI_RING_AURELIUS))
      max_dam += 500;
   else if (WORN_ARTIFACT (ch, ARTI_DEMONS_HEART))
      max_dam += 500;
   else if (WORN_ARTIFACT (ch, ARTI_HEART_OF_DARKNESS))
      max_dam += 250;
   else if (WORN_ARTIFACT (ch, ARTI_PLATE_IRON_GAUNTLET))
      max_dam += 1000;
   else if (WORN_ARTIFACT (ch, ARTI_LIONS_MANE))
      max_dam += 750;
   else if (WORN_ARTIFACT (ch, ARTI_CROWN_OF_CHRYSTANCIA))
      max_dam += 500;
   else if (ANY_ARTIFACT (obj1, obj2, obj3, obj4, ARTI_METEORIC_AXE))
      max_dam += 500;
   else if (ANY_ARTIFACT (obj1, obj2, obj3, obj4, ARTI_ICE_SHARD))
      max_dam += 250;
   else if (ANY_ARTIFACT (obj1, obj2, obj3, obj4, ARTI_KATANA_MURAMASE))
      max_dam += 750;
   else if (ANY_ARTIFACT (obj1, obj2, obj3, obj4, ARTI_EMPERORS_BLADE))
      max_dam += 250;
   else
   {
      int x;
      for (x = ARTI_GREEN_PLANAR_RING; x <= ARTI_WYRM_BLADE; x++)
         if (WORN_ARTIFACT (ch, x))
            max_dam += 500;
   }

   ch->damcap[DAM_CAP] = max_dam;
   ch->damcap[DAM_CHANGE] = 0;

   return;
}

/*
 * Inflict damage from a hit.
 */
void damage (CHAR_DATA * ch, CHAR_DATA * victim, int dam, int dt)
{
   bool BYPASSING = FALSE;
   CHAR_DATA *emb;

   int max_dam = ch->damcap[DAM_CAP];

/* Embrace Fix!*/  
   if (!IS_NPC(ch) && ch->embracing != NULL )
   {
      if ( ( emb = ch->embracing ) != NULL )
         stop_embrace(ch,emb);
      else
         stop_embrace(ch,NULL);       
   }
   if (IS_CREATOR (ch))
      max_dam = 10000000;

   if (get_hours (ch) < 6 && !IS_NPC (ch) && !IS_SET (ch->extra2, PKREADY))
      dam *= 3;
   if (get_hours (victim) < 6 && !IS_NPC (victim)
       && !IS_SET (victim->extra2, PKREADY))
      dam /= 2;

   if (victim == NULL || victim->position == POS_DEAD)
      return;

   /*
    * Stop up any residual loopholes.
    */

   if (!IS_NPC (ch) && IS_ITEMAFF (ch, ITEMA_PEACE))
   {
      send_to_char ("You are unable to attack them.\n\r", ch);
      return;
   }

   if (!IS_NPC (victim) && IS_ITEMAFF (victim, ITEMA_PEACE))
   {
      send_to_char ("You can't seem to attack them.\n\r", ch);
      return;
   }

   if (ch->damcap[DAM_CHANGE] == 1)
   {
      update_damcap (ch, victim);
      max_dam = ch->damcap[DAM_CAP];	// after we update the damcap, let's assign it eh? -- serenity
   }


  if (dam > max_dam)
      dam = max_dam;


   if (victim != ch)
   {
      /*
       * Certain attacks are forbidden.
       * Most other attacks are returned.
       */
      if (is_safe (ch, victim))
	 return;
      check_killer (ch, victim);

      if (victim->position > POS_STUNNED)
      {
	 if (victim->fighting == NULL)
	    set_fighting (victim, ch);
	 victim->position = POS_FIGHTING;
      }

      if (victim->position > POS_STUNNED)
      {
	 if (ch->fighting == NULL)
	    set_fighting (ch, victim);

	 /*
	  * If victim is charmed, ch might attack victim's master.
	  */
	 if (IS_NPC (ch) && IS_NPC (victim) && IS_AFFECTED (victim, AFF_CHARM)
	     && victim->master != NULL
	     && victim->master->in_room == ch->in_room
	     && number_bits (3) == 0)
	 {
	    stop_fighting (ch, FALSE);
	    multi_hit (ch, victim->master, TYPE_UNDEFINED);
	    return;
	 }
      }

      /*
       * More charm stuff.
       */
      if (victim->master == ch)
	 stop_follower (victim);

      /*
       * Damage modifiers.
       */
      if ((IS_CLASS (ch, CLASS_HIGHLANDER))
	  && (IS_DEMPOWER (ch, HPOWER_HEAL)))
      {
	 if (IS_AFFECTED (ch, AFF_HIDE))
	 {
	    dam *= 1.65;
	    stc ("You use your healing knowledge to place a grievous wound in your foe.\n\r", ch);
	    //if ( number_range( 1, 100 ) < 95 )
	    REMOVE_BIT (ch->affected_by, AFF_HIDE);
	    act ("$n places a cruel blow deep into your vitals.", ch, NULL,
		 NULL, TO_ROOM);
	 }
      }
      else if (IS_AFFECTED (ch, AFF_HIDE))
      {
	 if (!can_see (victim, ch))
	 {
	    dam *= 1.5;
	    send_to_char
	       ("You use your concealment to get a surprise attack!\n\r", ch);
	 }
	 REMOVE_BIT (ch->affected_by, AFF_HIDE);
	 act ("$n leaps from $s concealment.", ch, NULL, NULL, TO_ROOM);
      }

      if (IS_CLASS (ch, CLASS_NINJA) && IS_SET (ch->act, PLR_WIZINVIS))
      {
	 if (!can_see (victim, ch))
	 {
	    dam *= 3;
	    send_to_char ("You leap from the shadows.\n\r", ch);
	 }
	 REMOVE_BIT (ch->act, PLR_WIZINVIS);
	 act ("$n leaps from the shadows.", ch, NULL, NULL, TO_ROOM);
	 BYPASSING = TRUE;
      }
      else if (IS_CLASS (ch, CLASS_MONK) && IS_SET (ch->act, PLR_WIZINVIS))
      {
	 if (!can_see (victim, ch))
	 {
	    dam *= 1.2;
            send_to_char ("You burst from a flash of light.\n\r", ch);
	 }
	 REMOVE_BIT (ch->act, PLR_WIZINVIS);
	 act ("$n bursts from a flash of light.", ch, NULL, NULL, TO_ROOM);
      }

	 if ( (IS_AFFECTED (victim, AFF_SANCTUARY) && dam > 1 ) || ( WORN_ARTIFACT( victim, ARTI_CLOAK_OF_THE_ARCHMAGI ) && dam > 1 ) )
         {/*
           if ( IS_CLASS( ch, CLASS_HIGHLANDER ) && IS_DEMPOWER( ch, HPOWER_USE_SHIELDLESS ) )
           {
	     if ( ch->quickening[0] >= 3 && number_percent() < 80 )
	     {
	       dam = dam;
	       ch->quickening[0] -= number_range( 0, 3 );
	     }
  	     else
	       dam *= 0.5;
           }
  	   else*/
 	     dam *= 0.5;
   	 }
	 if (IS_AFFECTED (victim, AFF_PROTECT) && IS_EVIL (ch) && dam > 1)
	    dam -= (dam * 0.25);

      if (dam < 0)
	 dam = 0;

      /*
       * Check for disarm, trip, parry, and dodge.
       */
      if (dt >= TYPE_HIT)
      {

	 if (IS_NPC (ch) && number_percent () < ch->level * 0.5)
	    disarm (ch, victim);
	 /*
	    if ( IS_NPC(ch) && number_percent( ) < ch->level * 0.5 )
	    trip( ch, victim );
	  */

	 if ((IS_CLASS (ch, CLASS_HIGHLANDER))
	     && (IS_DEMPOWER (ch, HPOWER_USE_BYPASS)) && (!BYPASSING))
	 {
	    if ((ch->quickening[0] >= 1) && (dam > 0))
	    {
	       ch->quickening[0] -= 1;	// Auto-Bypass...If they spend 1 quickening.
	       if (number_range (1, 100) < 70)
	       {
		  stc ("#c^#n", ch);
		  BYPASSING = TRUE;
	       }
	       else
	       {
		  BYPASSING = FALSE;
	       }
	    }
	 }


	 if (!BYPASSING)
	 {
            if (check_parry (ch, victim, dt))
	       return;
            if (IS_STANCE (victim, STANCE_CRANE)
		&& victim->stance[STANCE_CRANE] > 100 && !can_counter (ch)
		&& !can_bypass (ch, victim) && check_parry (ch, victim, dt))
	       return;
	    else if (IS_STANCE (victim, STANCE_MANTIS)
		     && victim->stance[STANCE_MANTIS] > 100
		     && !can_counter (ch) && !can_bypass (ch, victim)
		     && check_parry (ch, victim, dt))
	       return;
            if (check_dodge (ch, victim, dt))
	       return;
            if (IS_STANCE (victim, STANCE_MONGOOSE)
		&& victim->stance[STANCE_MONGOOSE] > 100 && !can_counter (ch)
		&& !can_bypass (ch, victim) && check_dodge (ch, victim, dt))
	       return;
	    else if (IS_STANCE (victim, STANCE_SWALLOW)
		     && victim->stance[STANCE_SWALLOW] > 100
		     && !can_counter (ch) && !can_bypass (ch, victim)
		     && check_dodge (ch, victim, dt))
	       return;
	 }
      }

      dam_message (ch, victim, dam, dt);
      if (!IS_NPC (ch) && IS_SET (ch->more, SHORT_COMBAT))
      {
	 ch->amount_damage_dealt += dam;
	 ch->amount_attacks_dealt++;
      }
      if (!IS_NPC (victim) && IS_SET (victim->more, SHORT_COMBAT))
      {
         victim->amount_damage_received += dam;
         victim->amount_attacks_received++;
      }


   }
   hurt_person (ch, victim, dam);
   return;
}

void adv_damage (CHAR_DATA * ch, CHAR_DATA * victim, int dam)
{

	int max_dam = 0;
	max_dam = ch->damcap[DAM_CAP];            // after we update the damcap, let's assign it eh? -- serenity

   if (victim == NULL)
      return;

   if (victim->position == POS_DEAD)
      return;

   if (ch->damcap[DAM_CHANGE] == 1)
   {
      update_damcap (ch, victim);
          max_dam = ch->damcap[DAM_CAP];            // after we update the damcap, let's assign it eh? -- serenity
   }


	if (dam > max_dam)
		dam = max_dam;


   if (victim != ch)
   {
      if (is_safe (ch, victim))
	 return;
      check_killer (ch, victim);

      if (victim->position > POS_STUNNED)
      {
	 if (victim->fighting == NULL)
	    set_fighting (victim, ch);
      }

      if (victim->position > POS_STUNNED)
      {
	 if (ch->fighting == NULL)
	    set_fighting (ch, victim);

	 /*
	  * If victim is charmed, ch might attack victim's master.
	  */
	 if (IS_NPC (ch) && IS_NPC (victim) && IS_AFFECTED (victim, AFF_CHARM)
	     && victim->master != NULL
	     && victim->master->in_room == ch->in_room
	     && number_bits (3) == 0)
	 {
	    stop_fighting (ch, FALSE);
	    multi_hit (ch, victim->master, TYPE_UNDEFINED);
	    return;
	 }
      }

      if (victim->master == ch)
	 stop_follower (victim);


	 if ( (IS_AFFECTED (victim, AFF_SANCTUARY) && dam > 1 ) || ( WORN_ARTIFACT( victim, ARTI_CLOAK_OF_THE_ARCHMAGI ) && dam > 1 ) )
			dam *= 0.5;
		if (IS_AFFECTED (victim, AFF_PROTECT) && IS_EVIL (ch) && dam > 1)
			dam -= (dam * 0.25);
	
		if (dam < 0)
			dam = 0;
   }
   return;
}

void hurt_person (CHAR_DATA * ch, CHAR_DATA * victim, int dam)
{
   bool is_npc = FALSE;
   bool same_room = FALSE;
   bool remote_room = FALSE;
   int old_hp = 0;
   int tierxp = 0;

//    int vnum;
   char buf[MSL];

#ifdef FUCK_PLAYERS
   if (IS_NPC (victim) && !IS_NPC (ch))
      dam /= 1000;
   if (!IS_NPC (ch) && !IS_NPC (victim))
      dam /= 1000;
#endif

   /*
    * Hurt the victim.
    * Inform the victim of his new state.
    */

   if (WORN_ARTIFACT (ch, ARTI_SHATTERED_BLADE))
      dam *= 1.25;
   if (WORN_ARTIFACT (ch, ARTI_DEMONS_HEART))
      dam *= 1.25;
   if (WORN_ARTIFACT (ch, ARTI_LIONS_MANE) && IS_SET(ch->more, MORE_LIONSMANE))
      dam *= 1.25;
   if (WORN_ARTIFACT (ch, ARTI_PLATE_IRON_GAUNTLET))
      dam *= 1.1;
   if (WORN_ARTIFACT (ch, ARTI_METEORIC_AXE))
      dam *= 1.1;
   if (WORN_ARTIFACT (ch, ARTI_CROWN_OF_CHRYSTANCIA))
      dam *= 1.1;

   if (WORN_ARTIFACT (victim, ARTI_GREENLEAF_CLOAK) && !IS_SET (victim->flag2, AFF2_INARENA) &&
      victim->in_room != NULL && victim->in_room->sector_type != SECT_INSIDE &&
      victim->in_room->sector_type != SECT_CITY)
      dam *= 0.75;

   if (WORN_ARTIFACT (victim, ARTI_ARCHANGELS_WING) && number_percent() > 50)
   {
      char buf [MAX_STRING_LENGTH];
      dam = (dam * number_range(1,99)) / 100;
      sprintf (buf, "The Archangel's Wing protects %s and reduces their damage to %d.\n\r", victim->name, dam);
      if (!IS_SET (ch->more, SHORT_COMBAT))
         send_to_char (buf, ch);
      if (!IS_SET (victim->more, SHORT_COMBAT))
         sprintf (buf, "The Archangel's Wing protects you and reduces the damage to %d.\n\r", dam);
      send_to_char (buf, victim);
   }

   if (WORN_ARTIFACT (victim, ARTI_CRYSTAL_SHIELD))
   {
      if (number_range(0,99) < number_range(5,10))
      {
         char buf [MAX_STRING_LENGTH];
         sprintf (buf, "%s uses the Crystal Shield to deflect your hit.\n\r", victim->name);
         if (!IS_SET (ch->more, SHORT_COMBAT))
            send_to_char (buf, ch);
         if (!IS_SET (victim->more, SHORT_COMBAT))
            stc ("You deflect their hit with the Crystal Shield.\n\r", victim);
         dam = 0;
      }
   }

   old_hp = victim->hit;
   victim->hit -= dam;

   if (IS_SET (victim->flag2, AFF2_INARENA) && victim->hit < 0)
      clean_arena (victim, ch);

   if (!IS_NPC (victim) && victim->level >= LEVEL_IMMORTAL && victim->hit < 1)
      victim->hit = 1;
   update_pos (victim);

   switch (victim->position)
   {
   case POS_MORTAL:
      act ("$n is mortally wounded, and spraying blood everywhere.", victim,
	   NULL, NULL, TO_ROOM);
      send_to_char
	 ("You are mortally wounded, and spraying blood everywhere.\n\r",
	  victim);
//MORTAL MESS
      if (!IS_NPC (victim) && !IS_NPC (ch) && ch->mort_count == 0
	  && ch != victim)
      {

	 if (!IS_SET (victim->war, WARRING) && !IS_SET (ch->war, WARRING))
	 {
	    sprintf (buf, "#r%s #whas been mortally wounded by #r%s at #y%s",
		     victim->name, ch->name,
		     (get_room_index (victim->in_room->vnum))->name);
	    if (old_hp > -5)
	       do_fatality (ch, buf);
//                                      ltf(buf, "mortalwound", FALSE);
	    ch->mort_count = 1;
	 }
      }
      if (WORN_ARTIFACT (victim, ARTI_HEART_OF_DARKNESS) && IS_SET (victim->in_room->room_flags, ROOM_TOTAL_DARKNESS) )
                REMOVE_BIT(victim->in_room->room_flags, ROOM_TOTAL_DARKNESS);
      if (IS_CLASS (victim, CLASS_DROW)
	  && IS_SET (victim->in_room->room_flags, ROOM_TOTAL_DARKNESS))
	 REMOVE_BIT (victim->in_room->room_flags, ROOM_TOTAL_DARKNESS);
      if (IS_CLASS(victim, CLASS_FAE) && IS_KITH (victim, KITH_SLUAGH) && IS_SET(victim->in_room->room_flags, ROOM_TOTAL_DARKNESS))
         REMOVE_BIT (victim->in_room->room_flags, ROOM_TOTAL_DARKNESS);
      if (IS_CLASS (victim, CLASS_MONK)
	  && IS_SET (victim->monkstuff, MONK_HEAL))
	 REMOVE_BIT (victim->monkstuff, MONK_HEAL);

      break;

   case POS_INCAP:
      act ("$n is incapacitated, and bleeding badly.", victim, NULL, NULL,
	   TO_ROOM);
      send_to_char ("You are incapacitated, and bleeding badly.\n\r", victim);
      //victim->last_mort = 300;

      break;

   case POS_STUNNED:
      act ("$n is stunned, but will soon recover.", victim, NULL, NULL,
	   TO_ROOM);
      send_to_char ("You are stunned, but will soon recover.\n\r", victim);
      //victim->last_mort = 300;
      break;

   case POS_DEAD:
      act ("$n is DEAD!!", victim, 0, 0, TO_ROOM);
      send_to_char ("You have been KILLED!!\n\r\n\r", victim);
      break;

   default:
      if (dam > victim->max_hit / 4)
	 send_to_char ("That really did #rHURT!\n\r", victim);
      if (victim->hit < victim->max_hit / 4 && dam > 0)
      {
	 if (!IS_NPC (victim) && IS_CLASS (victim, CLASS_VAMPIRE)
	     && number_percent () < victim->beast)
	    vamp_rage (victim);
      }
      break;
   }

   /*
    * Sleep spells and extremely wounded folks.
    */
   if (!IS_AWAKE (victim))
      stop_fighting (victim, FALSE);

   /*
    * Payoff for killing things.
    */
   if (victim->position == POS_DEAD)
   {
      
      group_gain (ch, victim);

      if (!IS_NPC (victim))
      {
	 sprintf (log_buf, "%s killed by %s at %d", victim->name,
		  (IS_NPC (ch) ? ch->short_descr : ch->name),
		  victim->in_room->vnum);
	 log_string (log_buf, ch);
	 wiznet (ch, WIZ_DEATHS, 7, log_buf);
// wiznet
	 /*
	  * Dying penalty:
	  * 1/2 your current exp.
	  */
	 if (victim->exp > 0)
	    victim->exp = victim->exp / 2;
      }
      demon_gain (ch, victim);

      if (IS_NPC (victim) && !IS_NPC (ch))
      {

//	 ch->mkill += 1;
      if ((IS_CLASS(ch, CLASS_DROW) && IS_SET (ch->special, SPC_DROW_CLE)))
      {
        if (ch->cleregen >= 100000) { stc("You have the maximum amount of points stored.\n\r",ch); }
        else { sprintf(buf,"#cYou store#e %d #cpoints from that kill.#n\n\r",victim->level / 2);
        stc(buf,ch);
        ch->cleregen += victim->level / 2; }
      }
  	 if (ch->level == 1 && ch->mkill > 4)
	 {
	    ch->level = 2;
	    do_save (ch, "");
	 }
      }
      if (!IS_NPC (ch) && ch->tier < 250 && IS_NPC(victim) && !IS_SET(victim->act, ACT_NOEXP))
      {
	 tierxp = number_range ((victim->level / 4), victim->level);
	 if ((WizConfig->xpbonus > 1) && (get_hours (ch) >= 6))
	    tierxp = tierxp * WizConfig->xpbonus;
	 ch->tierxp += tierxp;

	 if (ch->tierxp > (ch->tier * 100000))
	 {
	    ch->tierxp = 0;
	    ch->tier++;
	    stc ("#r->^1#wYou gain a Tier!#n#r<-#n\n\r", ch);
	    gainstats (ch);
	 }
      }

      if (IS_NPC (victim))
	 is_npc = TRUE;
      if (victim->in_room == ch->in_room)
	 same_room = TRUE;

      if (IS_CLASS (ch, CLASS_MAGE) && (!same_room) && (is_npc))
      {
	 raw_kill(victim, ch);
	 remote_room = TRUE;
      }
      else
	 raw_kill (victim, ch);
//ok raw kill is here.
      if (same_room)
      {
         OBJ_DATA *payday = NULL;
         bool winner = FALSE;
         if (ch != NULL && ch->in_room != NULL && ch->in_room->contents != NULL)
         for ( payday = ch->in_room->contents; payday != NULL; payday = payday->next_content )
         {
            if (!payday) break;
            if (payday->item_type != 23 && payday->item_type != 24) continue;
            if (payday->contains == NULL) break;
            winner = TRUE;
            break;
         }
         if (winner && IS_SET (ch->act, PLR_AUTOLOOT))
            do_get (ch, "all corpse");
         if (winner && IS_SET (ch->more, PLR_AUTOGOLD))
            do_get (ch, "all.priceless corpse auto");
      }

      if (IS_SET (ch->flag2, LOOKINCORPSE) && same_room)
	 do_look (ch, "in corpse");

      if (!IS_NPC (ch))
      {
	 if (IS_SET (ch->act, PLR_AUTOSAC) && same_room)
         {
            if (!IS_NPC (ch) && IS_CLASS (ch, CLASS_DRAGON))
               do_consume (ch, "corpse");
            else
               do_sacrifice (ch, "corpse");
         }
/*
         else if (IS_SET (ch->act, PLR_AUTOSAC) && remote_room)
	 {
	    do_get (ch, "all.priceless corpse auto");
	    do_silent_sacrifice (ch, "corpse");
	 }
*/
      }

/*      if (!IS_NPC (ch) && IS_CLASS (ch, CLASS_DRAGON))
      {
	 if (IS_SET (ch->extra2, AUTOCONSUME) && same_room)
	    do_consume (ch, "corpse");
      }*/
      return;
   }

   if (victim == ch)
      return;

   /*
    * Take care of link dead people.
    */
   if (!IS_NPC (victim) && victim->desc == NULL)
   {
      if (number_range (0, victim->wait) == 0)
      {
	 do_flee (victim, " ");
	 return;
      }
   }

   /*
    * Wimp out?
    */
   if (IS_NPC (victim) && dam > 0)
   {
      if ((IS_SET (victim->act, ACT_WIMPY) && number_bits (1) == 0
	   && victim->hit < victim->max_hit / 2)
	  || (IS_AFFECTED (victim, AFF_CHARM) && victim->master != NULL
	      && victim->master->in_room != victim->in_room))
	 do_flee (victim, "");
   }

   if (!IS_NPC (victim) && victim->hit > 0 && victim->hit <= victim->wimpy
       && number_range (0, victim->wait) == 0)
      do_flee (victim, "");

   tail_chain ();
   return;
}

bool newis_safe (CHAR_DATA * ch, CHAR_DATA * victim)
{
   OBJ_DATA *obj;
   OBJ_DATA *obj_next;

   if (ch->trust > LEVEL_BUILDER && ch != victim)
   {
      send_to_char ("You cannot fight if you have implementor powers!\n\r",
		    ch);
      return TRUE;
   }

   if (victim->trust > LEVEL_BUILDER && ch != victim)
   {
      send_to_char ("You cannot fight someone with implementor powers!\n\r",
		    ch);
      return TRUE;
   }
   if (IS_SET (ch->tag_flags, TAG_PLAYING)
       || IS_SET (victim->tag_flags, TAG_PLAYING))
   {
      stc ("Not during a game of Freeze Tag!\n\r", ch);
      return TRUE;
   }

   if (ch->in_room->vnum == ROOM_VNUM_ALOSER
       || ch->in_room->vnum == ROOM_VNUM_AWINNER)
   {
      stc ("Not in the Arena Winner/Loser rooms.\n\r", ch);
      return TRUE;
   }

   if (WORN_ARTIFACT (ch, ARTI_HEART_OF_DARKNESS) && IS_SET (ch->in_room->room_flags, ROOM_TOTAL_DARKNESS) )
      REMOVE_BIT(ch->in_room->room_flags, ROOM_TOTAL_DARKNESS);
   else if (WORN_ARTIFACT (victim, ARTI_HEART_OF_DARKNESS) && IS_SET (victim->in_room->room_flags, ROOM_TOTAL_DARKNESS) )
      REMOVE_BIT(victim->in_room->room_flags, ROOM_TOTAL_DARKNESS);
   else if (IS_CLASS (ch, CLASS_DROW)
       && IS_SET (ch->in_room->room_flags, ROOM_TOTAL_DARKNESS))
      REMOVE_BIT (ch->in_room->room_flags, ROOM_TOTAL_DARKNESS);
   else if (IS_CLASS (victim, CLASS_DROW)
       && IS_SET (victim->in_room->room_flags, ROOM_TOTAL_DARKNESS))
      REMOVE_BIT (victim->in_room->room_flags, ROOM_TOTAL_DARKNESS);
   else if (IS_CLASS(ch, CLASS_FAE) && IS_KITH (ch, KITH_SLUAGH) && IS_SET(ch->in_room->room_flags, ROOM_TOTAL_DARKNESS))
         REMOVE_BIT (ch->in_room->room_flags, ROOM_TOTAL_DARKNESS);
   else if (IS_CLASS(victim, CLASS_FAE) && IS_KITH (victim, KITH_SLUAGH) && IS_SET(victim->in_room->room_flags, ROOM_TOTAL_DARKNESS))
         REMOVE_BIT (victim->in_room->room_flags, ROOM_TOTAL_DARKNESS);

   if (!IS_NPC(ch) && !IS_NPC(victim) && IS_SET (ch->flag2, AFF2_INARENA) && IS_SET(victim->flag2, AFF2_INARENA))
      return FALSE;
   else if (!IS_NPC(ch) && !IS_NPC(victim) && IS_SET (ch->war, WARRING) && IS_SET (victim->war, WARRING))
      return FALSE;
   else if (!IS_NPC(ch) && !IS_NPC(victim) && IS_SET (ch->war, JOINING))
   {
      stc ("You are unable to start hostilities just before your war!\n\r", ch);
      return TRUE;
   }
   else if (!IS_NPC(ch) && !IS_NPC(victim) && IS_SET (victim->war, JOINING))
   {
      stc ("You are unable to start hostilities just before their war!\n\r", ch);
      return TRUE;
   }

   /* Make it so newbies cant be killed by players. */
   if (!IS_NPC (victim) && (get_hours (ch) < 10) && !IS_NPC (ch)
       && (ch != victim) && !IS_SET (ch->extra2, PKREADY))
   {
      stc ("You are unable to attack players untill you reach 10 hours!.\n\r",
	   ch);
      return TRUE;
   }

   if (!IS_NPC (ch) && (get_hours (victim) < 10) && !IS_NPC (victim)
       && (ch != victim) && !IS_SET (victim->extra2, PKREADY))
   {
      stc ("You are unable to attack newbies of under 10 hours!\n\r", ch);
      return TRUE;
   }
   if (!IS_NPC (victim) && nosafe)
   {
      return FALSE;
   }

   if (!IS_NPC (victim) && IS_SET (victim->newbits, NEW_NOTEWRITE))
   {
      stc ("They are posting a note!\n\r", ch);
      return TRUE;
   }
/*
   if ((IS_SET(ch->flag2, AFF2_INARENA) && !IS_SET(victim->flag2,AFF2_INARENA))
         || (IS_SET(victim->flag2, AFF2_INARENA) && !IS_SET(ch->flag2,AFF2_INARENA)))
    {   
        send_to_char( "You cannot interfere with arena battles\n\r", ch );
        return TRUE;
    }      
       
       
*/
   // People with artifacts aren't safe. - Krynn
   for (obj = victim->carrying; obj != NULL; obj = obj_next)
   {
      obj_next = obj->next_content;
      if (IS_SET (obj->quest, QUEST_ARTIFACT))
	 return FALSE;
   }

   /* Ethereal people can only attack other ethereal people */
   if (!IS_NPC (ch) && get_trust (ch) == LEVEL_BUILDER)
   {
      send_to_char ("Don't fight, build.\n\r", ch);
      return TRUE;
   }

   if (!IS_NPC (victim) && get_trust (victim) == LEVEL_BUILDER)
   {
      send_to_char ("They build, not fight.\n\r", ch);
      return TRUE;
   }

   if (IS_AFFECTED (ch, AFF_ETHEREAL) && !IS_AFFECTED (victim, AFF_ETHEREAL))
   {
      send_to_char ("You cannot while ethereal.\n\r", ch);
      return TRUE;
   }
   if (!IS_AFFECTED (ch, AFF_ETHEREAL) && IS_AFFECTED (victim, AFF_ETHEREAL))
   {
      send_to_char ("You cannot fight an ethereal person.\n\r", ch);
      return TRUE;
   }
   /* You cannot attack across planes */
   if (IS_AFFECTED (ch, AFF_SHADOWPLANE)
       && !IS_AFFECTED (victim, AFF_SHADOWPLANE))
   {
      act ("You are too insubstantial!", ch, NULL, victim, TO_CHAR);
      return TRUE;
   }
   if (!IS_AFFECTED (ch, AFF_SHADOWPLANE)
       && IS_AFFECTED (victim, AFF_SHADOWPLANE))
   {
      act ("$E is too insubstantial!", ch, NULL, victim, TO_CHAR);
      return TRUE;
   }
   if (IS_HEAD (ch, LOST_HEAD) || IS_EXTRA (ch, EXTRA_OSWITCH))
   {
      send_to_char ("Objects cannot fight!\n\r", ch);
      return TRUE;
   }
   else if (IS_HEAD (victim, LOST_HEAD) || IS_EXTRA (victim, EXTRA_OSWITCH))
   {
      send_to_char ("You cannot attack an object.\n\r", ch);
      return TRUE;
   }
//EARTHMELD CHECK
   if (!IS_NPC (ch) && IS_EXTRA (ch, EXTRA_EARTHMELD))
      return TRUE;

   if (!IS_NPC (victim) && IS_EXTRA (victim, EXTRA_EARTHMELD))
      return TRUE;

   if (!IS_NPC (ch) && IS_AFFECTED (ch, AFF_SAFE))
   {
      send_to_char ("You cannot attack people under Gaia's protection.\n\r",
		    ch);
      return TRUE;
   }

   if (!IS_NPC (victim) && IS_AFFECTED (victim, AFF_SAFE))
   {
      send_to_char ("You cannot attack people under Gaia's protection.\n\r",
		    ch);
      return TRUE;
   }

   if (!IS_NPC (ch) && IS_AFFECTED (ch, AFF_STEELSHIELD))
   {
      send_to_char ("You cannot attack while in Majesty.\n\r", ch);
      return TRUE;
   }

   if (!IS_NPC (victim) && IS_AFFECTED (victim, AFF_STEELSHIELD))
   {
      send_to_char ("They are far to imposing.\n\r", ch);
      return TRUE;
   }
   /* Thx Josh! */
   if (victim->fighting == ch)
      return FALSE;

   /* You might be attacking them while they attack someone else */
   if (ch->fighting == victim)
      return FALSE;

   // People with artifacts aren't safe. - Krynn
   for (obj = victim->carrying; obj != NULL; obj = obj_next)
   {
      obj_next = obj->next_content;
      if (IS_SET (obj->quest, QUEST_ARTIFACT))
	 return FALSE;
   }
   /* Deal with safe rooms (either you or they are in one) */
   if (ch->in_room == NULL || victim->in_room == NULL
       || IS_SET (ch->in_room->room_flags, ROOM_SAFE)
       || IS_SET (victim->in_room->room_flags, ROOM_SAFE))
   {
      /* REASONING:
       * If you're in a safe room, you cannot attack someone if:
       * 1) They have no fight timer, AND:
       * 2) They do not have an artifact.
       * If either (or both) of the above statements are not true (ie
       * they DO have a fight timer, and/or they have an artifact) then
       * the safe room does not make them safe.
       *
       * The reverse logic is necessary because you cannot simply
       * return at this point - artifacts and fight timers ONLY
       * affect combat within safe rooms.  If you returned FALSE for
       * people with fight timers and artifacts, that would allow 
       * newbies to attack people with artifacts as long as they
       * were in safe rooms at the time!
       *
       * Note another interesting side affect is that the banner of
       * peace will now make you safe anywhere OTHER than safe rooms.
       */
      if (victim->fight_timer <= 0 && !IS_ITEMAFF (victim, ITEMA_ARTIFACT))
      {
	 send_to_char
	    ("Something in the air prevents you from attacking.\n\r", ch);
	 return TRUE;
      }
   }

   if (IS_ITEMAFF (ch, ITEMA_PEACE))
   {
      send_to_char ("You are unable to attack them.\n\r", ch);
      return TRUE;
   }

// Majesty CHECK
   if (!IS_NPC (victim))
   {
      CHAR_DATA *rch;

      for (rch = ch->in_room->people; rch; rch = rch->next_in_room)
      {
	 if (IS_CLASS (rch, CLASS_FAE) && !IS_NPC (rch)
	     && IS_SET (rch->extra2, EXTRA2_NEUTRAL) && rch->fight_timer <= 0)
	 {
	    send_to_char
	       ("Something in the air prevents your from attackin.\n\r", ch);
	    return TRUE;
	 }
      }
   }

   if (IS_NPC (ch) || IS_NPC (victim))
      return FALSE;


   if ((!CAN_PK (ch) || !CAN_PK (victim)) && ch != victim)
   {
      send_to_char ("Mortals are not permitted to fight other players.\n\r",
		    ch);
      return TRUE;
   }

   if (ch != victim && (IS_CLASS (ch, CLASS_VAMPIRE) || IS_VAMPAFF(ch, VAM_MORTAL))
       && IS_SET (ch->special, SPC_INCONNU)
       && (IS_CLASS (victim, CLASS_VAMPIRE)
	   || IS_VAMPAFF (victim, VAM_MORTAL)))
   {
      send_to_char ("You cannot attack another vampire.\n\r", ch);
      return TRUE;
   }
   else if (ch != victim && (IS_CLASS (victim, CLASS_VAMPIRE) || IS_VAMPAFF(victim, VAM_MORTAL))
       && IS_SET (victim->special, SPC_INCONNU)
       && (IS_CLASS (ch, CLASS_VAMPIRE) || IS_VAMPAFF (ch, VAM_MORTAL)))
   {
      send_to_char ("You cannot attack a member of the Inconnu.\n\r", ch);
      return TRUE;
   }

   return FALSE;
}

bool is_safe (CHAR_DATA * ch, CHAR_DATA * victim)
{
   OBJ_DATA *obj;
   OBJ_DATA *obj_next;
/*
if (victim->fighting == ch) return FALSE;
if (ch->fighting == victim) return FALSE;
*/
   if (ch->trust > LEVEL_BUILDER && !IS_NPC(victim) && ch != victim)
   {
      send_to_char ("You cannot fight if you have implementor powers!\n\r",
		    ch);
      return TRUE;
   }

   if (victim->trust > LEVEL_BUILDER && !IS_NPC(ch) && ch != victim)
   {
      send_to_char ("You cannot fight someone with implementor powers!\n\r",
		    ch);
      return TRUE;
   }
   /* Ethereal people can only attack other ethereal people */

   if (IS_AFFECTED (ch, AFF_ETHEREAL) && !IS_AFFECTED (victim, AFF_ETHEREAL))
   {
      send_to_char ("You cannot while ethereal.\n\r", ch);
      return TRUE;
   }
   if (!IS_AFFECTED (ch, AFF_ETHEREAL) && IS_AFFECTED (victim, AFF_ETHEREAL))
   {
      send_to_char ("You cannot fight an ethereal person.\n\r", ch);
      return TRUE;
   }

   /* You cannot attack across planes */
   if (IS_AFFECTED (ch, AFF_SHADOWPLANE)
       && !IS_AFFECTED (victim, AFF_SHADOWPLANE))
   {
      act ("You are too insubstantial!", ch, NULL, victim, TO_CHAR);
      return TRUE;
   }
   if (!IS_AFFECTED (ch, AFF_SHADOWPLANE)
       && IS_AFFECTED (victim, AFF_SHADOWPLANE))
   {
      act ("$E is too insubstantial!", ch, NULL, victim, TO_CHAR);
      return TRUE;
   }
   if (IS_AFFECTED (ch, AFF_SHADOWPLANE)
       && !IS_AFFECTED (victim, AFF_SHADOWPLANE))
   {
      act ("You are too insubstantial!", ch, NULL, victim, TO_CHAR);
      return TRUE;
   }
   if (!IS_AFFECTED (ch, AFF_SHADOWPLANE)
       && IS_AFFECTED (victim, AFF_SHADOWPLANE))
   {
      act ("$E is too insubstantial!", ch, NULL, victim, TO_CHAR);
      return TRUE;
   }

   if (IS_NPC (victim) && IS_SET (victim->act, ACT_NO_KILL))
   {
      stc ("You are unable to attack them!\n\r", ch);
      return TRUE;
   }
   if (IS_NPC (victim) && (victim->pIndexData->vnum == 3145))
   {
      stc ("You are unable to attack them!\n\r", ch);
      return TRUE;
   }
   if (IS_SET (victim->more, MORE_JAIL))
   {
      stc ("They are in Jail\n\r", ch);
      return TRUE;
   }

   if (IS_SET (ch->tag_flags, TAG_PLAYING)
       || IS_SET (victim->tag_flags, TAG_PLAYING))
   {
      stc ("Not during a game of Freeze Tag!\n\r", ch);
      return TRUE;
   }
   if (IS_SET (victim->war, WARRING) && !IS_SET (ch->war, WARRING))
   {
      stc ("You cannot interfere with wars!\n\r", ch);
      return TRUE;
   }
   if ((IS_SET (ch->flag2, AFF2_INARENA)
	&& !IS_SET (victim->flag2, AFF2_INARENA))
       || (IS_SET (victim->flag2, AFF2_INARENA)
	   && !IS_SET (ch->flag2, AFF2_INARENA)))
   {
      send_to_char ("You cannot interfere with arena battles\n\r", ch);
      return TRUE;
   }

   if (WORN_ARTIFACT (ch, ARTI_HEART_OF_DARKNESS) && IS_SET (ch->in_room->room_flags, ROOM_TOTAL_DARKNESS) )
      REMOVE_BIT(ch->in_room->room_flags, ROOM_TOTAL_DARKNESS);
   else if (WORN_ARTIFACT (victim, ARTI_HEART_OF_DARKNESS) && IS_SET (victim->in_room->room_flags, ROOM_TOTAL_DARKNESS) )
      REMOVE_BIT(victim->in_room->room_flags, ROOM_TOTAL_DARKNESS);
   else if (IS_CLASS (ch, CLASS_DROW)
       && IS_SET (ch->in_room->room_flags, ROOM_TOTAL_DARKNESS))
      REMOVE_BIT (ch->in_room->room_flags, ROOM_TOTAL_DARKNESS);
   else if (IS_CLASS (victim, CLASS_DROW)
       && IS_SET (victim->in_room->room_flags, ROOM_TOTAL_DARKNESS))
      REMOVE_BIT (victim->in_room->room_flags, ROOM_TOTAL_DARKNESS);
   else if (IS_CLASS(ch, CLASS_FAE) && IS_KITH (ch, KITH_SLUAGH) && IS_SET(ch->in_room->room_flags, ROOM_TOTAL_DARKNESS))
         REMOVE_BIT (ch->in_room->room_flags, ROOM_TOTAL_DARKNESS);
   else if (IS_CLASS(victim, CLASS_FAE) && IS_KITH (victim, KITH_SLUAGH) && IS_SET(victim->in_room->room_flags, ROOM_TOTAL_DARKNESS))
         REMOVE_BIT (victim->in_room->room_flags, ROOM_TOTAL_DARKNESS);

   if (!IS_NPC(ch) && !IS_NPC(victim) && IS_SET (ch->flag2, AFF2_INARENA) && IS_SET(victim->flag2, AFF2_INARENA))
      return FALSE;
   else if (!IS_NPC(ch) && !IS_NPC(victim) && IS_SET (ch->war, WARRING) && IS_SET (victim->war, WARRING))
      return FALSE;
   else if (!IS_NPC(ch) && !IS_NPC(victim) && IS_SET (ch->war, JOINING))
   {
      stc ("You are unable to start hostilities just before your war!\n\r", ch);
      return TRUE;
   }
   else if (!IS_NPC(ch) && !IS_NPC(victim) && IS_SET (victim->war, JOINING))
   {
      stc ("You are unable to start hostilities just before their war!\n\r", ch);
      return TRUE;
   }

   if (!IS_NPC(victim) && !victim->desc && victim->pcdata->login_timer > 0 && victim->fight_timer < 1 && ( victim != ch ) && !IS_NPC(ch) )
   {
	stc("Not with a login timer!\n\r", ch);
	return TRUE;
   }
/*
   if (!IS_NPC(victim) && (victim->pcdata->login_timer > 0) && ( victim != ch ) && !IS_NPC(ch) )
   {
	stc("Not with a login timer!\n\r", ch);
	return TRUE;
   }
   if (!IS_NPC(ch) && (ch->pcdata->login_timer > 0) && ( victim != ch )&& !IS_NPC(victim) )
   {
	stc("Not with a login timer!\n\r", ch);
	return TRUE;
   

Showing the first 100 KB of 320.8 KB. Download the archive for the full file.

Site Stats

Snippets: 1791
Codebases: 571