fight.c

demise/src/fight.c · 397.4 KB

From the archive dodbackup-final.tar.gz

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 improvements copyright (C) 1994, 1995, 1996 by Richard    *
 *  Woolcock.  This mud is NOT to be copied in whole or in part, or to be  *
 *  run without the permission of Richard Woolcock.  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"

/*
 * 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, bool shadow, int dam, int dt));
void death_cry args ((CHAR_DATA * ch));
int xp_compute args ((CHAR_DATA * gch, CHAR_DATA * victim));
int zenni_compute args ((CHAR_DATA * gch, CHAR_DATA * victim));
bool can_counter args ((CHAR_DATA * ch));
bool can_bypass args ((CHAR_DATA * ch, CHAR_DATA * victim));
int get_speed args ((CHAR_DATA * ch));
void update_damcap args ((CHAR_DATA * ch, CHAR_DATA * victim));
void check_arena args ((CHAR_DATA * ch, CHAR_DATA * victim));
int countforms args ((CHAR_DATA * ch));
void dropvoid args ((CHAR_DATA * ch));

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

  for (ch = first_fight; ch != NULL; ch = ch_next)
    {
      ch_next = ch->next_fight;

      /*
       * Hunting mobs.
       */
      if (IS_NPC (ch)
	  && ch->fighting == NULL && IS_AWAKE (ch) && ch->hunting != NULL)
	{
	  hunt_victim (ch);
	  continue;
	}

      if ((victim = ch->fighting) == NULL || ch->in_room == NULL)
	{
	  stop_fighting (ch, FALSE);
	  continue;
	}

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

      if ((victim = ch->fighting) == NULL)
	{
	  stop_fighting (ch, FALSE);
	  continue;
	}

      /*
       * Fun for the whole family!
       */
      for (rch = ch->in_room->people; rch != NULL; rch = rch_next)
	{
	  rch_next = rch->next_in_room;

	  if (IS_AWAKE (rch) && rch->fighting == NULL)
	    {
	      /*
	       * Mount's auto-assist their riders and vice versa.
	       */
	      if ((mount = rch->mount) != NULL)
		{
		  if (mount == ch)
		    multi_hit (rch, victim, TYPE_UNDEFINED);
		  continue;
		}
	      /*
	       * PC's auto-assist others in their group.
	       */
	      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;
		}

	      /*
	       * NPC's assist NPC's of same type or 12.5% chance regardless.
	       */
	      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, i;
  int level;
  int unarmed;
  int wieldorig = 0;
  int wieldtype = 0;
  int chance;
  int maxcount;
  int countup;

  if (ch->position < POS_SLEEPING)
    return;

  if (dt == gsn_headbutt)
    {
      one_hit (ch, victim, dt, 1, DAM_NORMAL, FALSE);
      return;
    }

  if (dt == gsn_tail)
    {
      one_hit (ch, victim, dt, 1, DAM_NORMAL, FALSE);
      return;
    }
  wield1 = get_eq_char (ch, WEAR_WIELD);
  wield2 = get_eq_char (ch, WEAR_HOLD);
  wield3 = get_eq_char (ch, WEAR_THIRD_HAND);
  wield4 = get_eq_char (ch, WEAR_FOURTH_HAND);
  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;

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

  if (wieldtype == 4)
    wield = wield4;
  else if (wieldtype == 3)
    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)
	{
	  if (IS_NPC (victim) && victim->pIndexData->vnum == 3011)
	    return;
	  if (!IS_NPC (victim) && get_tribe (victim, TRIBE_WENDIGOS) > 4)
	    return;
	  special_move (ch, victim);
	  return;
	}
    }
  if (IS_MONK (ch))
    {
      if (!IS_NPC (ch))
	{
	  if (!IS_NPC (victim)
	      || (IS_NPC (victim) && victim->pIndexData->vnum != 3011))
	    {
	      unarmed = number_range (1, 8);
	      unarmed = unarmed - 1;
	      if (!IS_NPC (ch) && ch->cmbt[unarmed] != 0)
		{
		  fightaction (ch, victim, ch->cmbt[unarmed], dt, wieldtype);
		  if (victim->position == POS_STUNNED)
		    {
		      return;
		    }
		}
	    }
	}
    }

  unarmed = 0;
  one_hit (ch, victim, dt, wieldtype, DAM_NORMAL, FALSE);

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

  if (dt == TYPE_UNDEFINED)
    {
      dt = TYPE_HIT;
      if (wield != NULL && wield->item_type == ITEM_WEAPON)
	{
	  dt += wield->value[3];
	  if (wield->value[0] >= 1)
	    {
	      /* Look, just don't ask...   KaVir */
	      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)
    return;

  if (!IS_NPC (victim) && !IS_SET (victim->act, PLR_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_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_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, "left");
	}

//OLD FIGHTCODE

      if (wpntype > 0)
	one_hit (victim, ch, TYPE_UNDEFINED, 1, DAM_NORMAL, FALSE);
      if (victim == NULL || victim->position != POS_FIGHTING)
	return;
      if (wpntype2 > 0)
	one_hit (victim, ch, TYPE_UNDEFINED, 2, DAM_NORMAL, FALSE);
      if (victim == NULL || victim->position != POS_FIGHTING)
	return;
    }
  maxcount = 1;

  if (IS_MONK (ch) || IS_KAHN (ch))
    {
      if (is_unarmed (ch))
	{
	  maxcount++;
	  if (IS_MOD (ch, MOD_THIRD_ARM))
	    maxcount++;
	  if (IS_MOD (ch, MOD_FOURTH_ARM))
	    maxcount++;
	}
    }

  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 (wieldorig == 15)
    maxcount += 3;
  if (wieldorig == 14)
    maxcount += 2;
  if (wieldorig == 13)
    maxcount += 2;
  if (wieldorig == 12)
    maxcount += 1;
  if (wieldorig == 11)
    maxcount += 2;
  if (wieldorig == 10)
    maxcount += 1;
  if (wieldorig == 9)
    maxcount += 1;
  if (wieldorig == 7)
    maxcount += 2;
  if (wieldorig == 6)
    maxcount += 1;
  if (wieldorig == 5)
    maxcount += 1;
  if (wieldorig == 3)
    maxcount += 1;

  maxcount += number_attacks (ch, victim);

  if (!IS_NPC (ch))
    maxcount -= 2;

  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, DAM_NORMAL, FALSE);
      if (victim == NULL || victim->position != POS_FIGHTING)
	return;
      if (ch->fighting != victim)
	return;
    }

  wieldtype = wieldorig;

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


  one_hit (ch, victim, -1, wieldtype, DAM_NORMAL, FALSE);
  if (victim == NULL || victim->position != POS_FIGHTING)
    return;
  if (ch->fighting != victim)
    return;
  if (!IS_NPC (ch) && IS_XX (ch, XX_FSTAND))
    more_hit (ch, victim, gsn_blur, 0, number_range (3, 5), TRUE);

  if (IS_NPC (ch) && ch->pIndexData->vnum == 3011 && number_range (1, 3) == 3)
    {
      more_hit (ch, victim, gsn_headbutt, 0, number_range (3, 5), TRUE);
    }
  if (IS_NPC (ch) && ch->pIndexData->vnum == 3011 && number_range (1, 3) == 2)
    {
      more_hit (ch, victim, gsn_kick, 0, number_range (3, 5), TRUE);
    }
  if (IS_NPC (ch) && ch->pIndexData->vnum == 3011 && number_range (1, 3) == 1)
    {
      more_hit (ch, victim, gsn_claws, 0, number_range (3, 5), TRUE);
    }
  if (IS_NPC (ch)
      && (ch->pIndexData->vnum == 45792 || ch->pIndexData->vnum == 138)
      && number_range (1, 3) == 3)
    {
      more_hit (ch, victim, gsn_headbutt, 0, number_range (3, 5), TRUE);
    }
  if (IS_NPC (ch)
      && (ch->pIndexData->vnum == 45792 || ch->pIndexData->vnum == 138)
      && number_range (1, 3) == 2)
    {
      more_hit (ch, victim, gsn_kick, 0, number_range (3, 5), TRUE);
    }
  if (IS_NPC (ch)
      && (ch->pIndexData->vnum == 45792 || ch->pIndexData->vnum == 138)
      && number_range (1, 3) == 1)
    {
      more_hit (ch, victim, gsn_claws, 0, number_range (3, 5), TRUE);
    }

  if (!IS_NPC (victim) && IS_NPC (ch) && ch->pIndexData->vnum == 3011
      && victim->hit < (victim->max_hit / 4) && !IS_IMMORTAL (victim)
      && !IS_CREATOR (victim))
    {
      char buf[MIL];

      do_say (ch,
	      "With the power granted me by the #0Darkness#R, I claim your soul");
      sprintf (buf, "#RWith one mighty blow %s #Rcleaves you in half.#n\n\r",
	       ch->short_descr);
      stc (buf, victim);
      sprintf (buf,
	       "%s shouts '#0With the power granted me by the Darkness, I claim your soul %s#n.",
	       ch->short_descr, victim->name);
      do_mecho (victim, buf);
      stc ("#RYou have been executed for your sins#n.\n\r", victim);
      killperson (ch, victim);
    }
  if (!IS_NPC (victim) && IS_RNPC (ch)
      && (ch->pIndexData->vnum == 45792 || ch->pIndexData->vnum == 138)
      && victim->hit < 0 && !IS_IMMORTAL (victim) && !IS_CREATOR (victim))
    {
      char buf[MIL];

      do_shout (ch, "Wheeeeeee, You got owned!");
      sprintf (buf,
	       "#R%s #Rengulfs you burning you to #0ash#R and enslaves your #ys#oou#yl#n.#n\n\r",
	       ch->short_descr);
      stc (buf, victim);
      if (victim->race >= 1)
	victim->race--;
      ch->race++;
      killperson (ch, victim);
    }

  if (ch->fighting == victim && IS_MONK (ch) && !IS_NPC (ch)
      && ch->monkab[BODY] > 3 && ch->chi[CURRENT] > 0
      && number_range (1, 6) == 2)
    {
      int wdam = number_range (2, 4);
      char buf[MSL];

      if (ch->in_room != victim->in_room)
	return;

      wdam =
	wdam * number_range ((ch->chi[CURRENT] * 60),
			     (ch->chi[CURRENT] * 100));
      act ("$n's hands glow with a #Cheavenly aura#n.", ch, NULL, victim,
	   TO_VICT);
      sprintf (buf, "$n's #Caura#n sears your flesh! #R[#7%d#R]#n", wdam);
      act (buf, ch, NULL, victim, TO_VICT);
      sprintf (buf, "Your #Cheavenly aura#n sears $N's flesh.#R[#7%d#R]#n",
	       wdam);
      act (buf, ch, NULL, victim, TO_CHAR);
      act ("$n's hands' #Cheavenly aura#n sears $N's flesh.", ch, NULL,
	   victim, TO_NOTVICT);
      if (number_range (1, 3) == 2)
	{
	  level = ch->spl[RED_MAGIC] * number_range (8, 12);

	  if ((sn = skill_lookup ("curse")) > 0)
	    (*skill_table[sn].spell_fun) (sn, level, ch, victim);
	}
      hurt_person (ch, victim, wdam, 0);
      if (victim != NULL && victim->hit < 1)
	update_pos (victim);
    }
  if (!IS_NPC (ch) && IS_DRACONIAN (ch) && IS_DRACWEAP (ch, DRAC_JAW))
    {
      bool bite = FALSE;

      if (ch->pcdata->cpowers[DRAC_OFFENSIVE] > 6)
	{
	  if (number_range (1, 6) == 6)
	    {
	      bite = TRUE;
	    }
	}
      else
	{
	  if (number_range (1, 9) == 6)
	    {
	      bite = TRUE;
	    }
	}

      if (bite)
	{
	  if (!IS_NPC (victim))
	    dracbite (ch, victim);
	  else
	    one_hit (ch, victim, gsn_fangs, 0, 0, FALSE);
	}
    }
  if (IS_ANGELW (ch) && IS_POLYAFF (ch, POLY_ANGELFORM)
      && number_range (1, 6) == 1)
    one_hit (ch, victim, gsn_awings, 0, 0, FALSE);
  if (IS_DEMON (ch) && IS_DEMAFF (ch, DEM_UNFOLDED)
      && number_range (1, 6) == 1)
    one_hit (ch, victim, gsn_dwings, 0, 0, FALSE);
  if (IS_DRACONIAN (ch) && IS_DRACWEAP (ch, DRAC_WINGS)
      && IS_DRACWEAP (ch, DRAC_UNFOLDED) && number_range (1, 6) == 2)
    one_hit (ch, victim, gsn_buffet, 0, 0, FALSE);
  if (IS_DRACONIAN (ch) && IS_DRACWEAP (ch, DRAC_HORNS)
      && number_range (1, 6) == 1)
    one_hit (ch, victim, gsn_headbutt, 0, 0, FALSE);
  if (IS_DRACONIAN (ch) && IS_DRACWEAP (ch, DRAC_DHAMMER)
      && number_range (1, 5) == 2)
    {
      int fmin = 0, fmax = 0;

      level = ch->spl[BLUE_MAGIC];

      fmin = level * number_range (8, 12);

      fmax = level * number_range (12, 16);

      act_brief
	("#cD#0ra#cy#0go#cn#n'#0s#y H#0amme#yr#n swings at $N, spewing a shower of #rS#Rp#ya#Rr#rks#n on impact.",
	 ch, NULL, victim, TO_CHAR, PLR_BRIEF3);
      act_brief
	("#cD#0ra#cy#0go#cn#n'#0s#y H#0amme#yr#n swings at $N, spewing a shower of #rS#Rp#ya#Rr#rks#n on impact.",
	 ch, NULL, victim, TO_NOTVICT, PLR_BRIEF4);
      if (!IS_NPC (victim))
	{
	  act_brief
	    ("#cD#0ra#cy#0go#cn#n'#0s#y H#0amme#yr#n swings at you, spewing a shower of #rS#Rp#ya#Rr#rks#n on impact.",
	     ch, NULL, victim, TO_VICT, PLR_BRIEF3);
	}
      one_hit (ch, victim, gsn_hammer, 0, DAM_LIGHT, TRUE);
      if (number_range (1, 3) == 2)
	{
	  level = ch->spl[RED_MAGIC] * number_range (8, 12);

	  if ((sn = skill_lookup ("curse")) > 0)
	    (*skill_table[sn].spell_fun) (sn, level, ch, victim);
	}
      several_hit (ch, victim, fmin, fmax, gsn_holyspark, DAM_FIRE,
		   number_range (1, 3), FALSE, TRUE, TRUE);
    }
  if (IS_DRACONIAN (ch) && IS_DRACWEAP (ch, DRAC_SPIKES)
      && number_range (1, 6) == 4)
    one_hit (ch, victim, gsn_spinespikes, 0, 0, FALSE);
  if (IS_DRACONIAN (ch) && IS_DRACWEAP (ch, DRAC_CLAWS)
      && number_range (1, 6) == 5)
    one_hit (ch, victim, gsn_razorclaws, 0, 0, FALSE);
  if (IS_DRACONIAN (ch) && IS_DRACWEAP (ch, DRAC_TAIL)
      && number_range (1, 6) == 3)
    {
      if (ch->pcdata->cpowers[DRAC_OFFENSIVE] > 8)
	more_hit (ch, victim, gsn_wyverntail, 0, number_range (1, 2), FALSE);
      else
	one_hit (ch, victim, gsn_tailslap, 0, 0, FALSE);
    }
  if (IS_POLYAFF (ch, POLY_BSDFORM) && number_range (1, 6) == 1)
    one_hit (ch, victim, gsn_bonespike, 0, 0, FALSE);
  if (!IS_NPC (ch) && IS_NINJA (ch) && ch->pcdata->npowers[NPATH_DARK] > 9
      && number_range (1, 6) == 1)
    {
      more_hit (ch, victim, gsn_scythes, 0, number_range (1, 2), FALSE);
    }
  if (!IS_NPC (ch) && IS_VAMPIRE (ch) && IS_NYM (ch, NYM_BLOODSPIRIT)
      && number_range (1, 6) == 1)
    {
      spirittheft (ch, "");
    }
  if (IS_NYM (ch, NYM_SKINDANCER) && number_range (1, 6) == 2)
    {
      int c, xx;
      xx = number_range (1, 3);

      for (c = 0; c < xx; c++)
	{
	  one_hit (ch, victim, gsn_mystical, 0, 0, FALSE);
	}
    }
  if (IS_DEMON (ch) && IS_SET (ch->pcdata->disc[O_POWERS], DEM_HELLFIRE)
      && number_range (1, 4) == 1)
    {
      hellfire (ch, TRUE, HFIRE_DEF);
    }
  if (IS_ANGELW (ch) && IS_SET (ch->apowers, APOWER_PURE1) && number_range (1, 4) == 1)
    {
      wrath (ch, TRUE, HFIRE_DEF);
    }

  if (IS_SAINT (ch) && IS_COR (ch, COR_RIBBONS))
    {
      if (ch->chi[CURRENT] > 0)
	{
	  if (number_range (1, 6) == 1)
	    {
	      one_hit (ch, victim, gsn_chi_ribbon, 0, DAM_LIGHT, FALSE);
	    }
	}
    }
  if (IS_ELF (ch) && number_range (1, 50) <= 5
      && ch->pcdata->wisdoms[ELF_ARCHERY] >= 3)
    {
      multi_hit (ch, victim, gsn_elvenarrow);
    }
  if (IS_ELF (ch) && number_range (1, 50) <= 5
      && ch->pcdata->wisdoms[ELF_WATER] >= 1)
    {
      multi_hit (ch, victim, gsn_elvenaura);
    }

  if (IS_XX (ch, XX_ELFEARTH) && number_range (1, 50) <= 5)
    {
      if (ch != NULL)
	{
	  act_brief
	    ("#CThe earth around your arms solidify, and you punch $N's with all the power earth, sending $M sprawling on the ground.#n",
	     ch, NULL, victim, TO_CHAR, PLR_BRIEF3);
	}
      if (!IS_NPC (victim) && ch != NULL && victim != NULL)
	{
	  act
	    ("The earth around $n's arms solidifys, and $e punches you with all the power of earth, sending you sprawling to the floor.",
	     ch, NULL, victim, TO_VICT);
	}
      act_brief
	("the earth around $n's arms solidifys, and $e punches $N with all the power of earth, sending $M sprawling on the ground.#n",
	 ch, NULL, victim, TO_NOTVICT, PLR_BRIEF4);
      stop_fighting (victim, TRUE);
      victim->position = POS_STUNNED;
      update_pos (victim);
      multi_hit (ch, victim, gsn_earthpunch);
      SET_BIT (victim->loc_hp[1], BROKEN_RIBS_4);
    }

  if (IS_EM (ch, EM_WEBSPINNER))
    {
      if (number_range (1, 4) == 2)
	{
	  int spelltype;

	  if ((sn = skill_lookup ("uberweb")) < 0)
	    {
	      stc ("Bug tell Corim, no Web.\n\r", ch);
	      return;
	    }

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

	  spelltype = skill_table[sn].target;

	  level = ch->spl[spelltype];

	  (*skill_table[sn].spell_fun) (sn, level, ch, victim);

	}
    }
  if (!IS_NPC (ch) && IS_DRACONIAN (ch)
      && ch->pcdata->cpowers[DRAC_COMBAT] > 4 && number_range (1, 5) == 5)
    {
      if (ch != NULL)
	{
	  act_brief
	    ("#CYou BASH through #n$N's#C defences sending $M sprawling on the ground.#n",
	     ch, NULL, victim, TO_CHAR, PLR_BRIEF3);
	  act_brief
	    ("#CYou stomp on #n$N's#C chest while $E is defenceless, cracking some of $S ribs.#n",
	     ch, NULL, victim, TO_CHAR, PLR_BRIEF3);
	}
      if (!IS_NPC (victim) && ch != NULL && victim != NULL)
	{
	  act
	    ("$n#C BASHES through your defences sending you sprawling on the ground.#n",
	     ch, NULL, victim, TO_VICT);
	  act_brief
	    ("$n#C stomps on your chest while your defenceless, cracking some of your ribs.#n",
	     ch, NULL, victim, TO_CHAR, PLR_BRIEF3);
	}
      act_brief
	("$n BASHES through #n$N's#C defences sending $M sprawling on the ground.#n",
	 ch, NULL, victim, TO_NOTVICT, PLR_BRIEF4);
      act_brief
	("$n stomps on #n$N's#C chest while $E is defenceless, cracking ribs loudly.#n",
	 ch, NULL, victim, TO_NOTVICT, PLR_BRIEF4);
      stop_fighting (victim, TRUE);
      victim->position = POS_STUNNED;
      update_pos (victim);
      multi_hit (ch, victim, gsn_stomp);
      SET_BIT (victim->loc_hp[1], BROKEN_RIBS_4);
    }

  if (IS_DRAGON (ch) && IS_POLYAFF (ch, POLY_DRAGONFORM)
      && ch->pcdata->cpowers[DRAC_OFFENSIVE] > 7
      && !IS_SET (ch->pcdata->dpowers[BREATH], BNONE))

    {
      if (number_range (1, 3) == 1)
	{
	  if (IS_SET (ch->pcdata->dpowers[BREATH], BGAS))
	    do_gbreath (ch, "");
	  if (IS_SET (ch->pcdata->dpowers[BREATH], BFIRE))
	    do_fbreath (ch, "");
	  if (IS_SET (ch->pcdata->dpowers[BREATH], BLIGHT))
	    do_lbreath (ch, "");
	  if (IS_SET (ch->pcdata->dpowers[BREATH], BCOLD))
	    do_cbreath (ch, "");
	  if (IS_SET (ch->pcdata->dpowers[BREATH], BACID))
	    do_abreath (ch, "");
	  if (IS_SET (ch->pcdata->dpowers[BREATH], BSHADOW))
	    do_sbreath (ch, "");
	  if (IS_SET (ch->pcdata->dpowers[BREATH], BSONIC))
	    do_vbreath (ch, "");
	}
    }

//OLD FIGHT CODE
  if (!IS_NPC (ch) && IS_NYM (ch, NYM_NEPHFURY) && number_range (1, 6) == 2)
    {
      one_hit (ch, victim, gsn_shadeflame, 0, DAM_SHADOW, FALSE);
      if (number_percent () > 60 && !IS_MORE (victim, MORE_FLAMES))
	{
	  send_to_char ("You are engulfed in infernal flames!\n\r", victim);
	  act ("$n is engulfed in infernal flames!", victim, NULL, NULL,
	       TO_ROOM);
	  SET_BIT (victim->affected_by, AFF_FLAMING);
	  SET_BIT (victim->more, MORE_FLAMES);
	}
    }
  if (!IS_NPC (ch) && IS_POLYAFF (ch, POLY_DEMONFORM)
      && IS_DEMPOWER (ch, DEM_TENTACLE) && number_range (1, 5) == 1)
    {
      more_hit (ch, victim, gsn_tentacle, 0, number_range (1, 2), FALSE);
    }
  if (!IS_NPC (ch) && IS_POLYAFF (ch, POLY_ANGELFORM)
      && IS_SET (ch->apowers, APOWER_PURE2) && victim->alignment < 1 && number_range (1, 5) == 1)
    {
      more_hit (ch, victim, gsn_feather, 0, number_range (1, 3), FALSE);
    }
  if (!IS_NPC (ch) && IS_XXX (ch, XXX_TIMESHIELD) && number_range (1, 5) >= 4)
    more_hit (ch, victim, gsn_timeshield, 0, number_range (3, 5), FALSE);
  if (!IS_NPC (ch) && ch->pcdata->powers[KAHN_RANKS] >= 8
      && number_range (1, 5) >= 4)
    more_hit (ch, victim, gsn_shaclaw, 0, number_range (5, 7), FALSE);
  if (!IS_NPC (ch) && IS_XXX (ch, XXX_DEATHSHIELD)
      && number_range (1, 5) == 4)
    more_hit (ch, victim, gsn_deathshield, 0, number_range (2, 7), TRUE);

  if (!IS_NPC (ch) && IS_NEWWW (ch)
      && number_range (1, 15) < get_tribe (ch, QUAL_CELERITY)
      && get_tribe (ch, TRIBE_CELERITY) >= 1)
    {
      more_hit (ch, victim, gsn_lfattack, 0, number_range (1, 2), FALSE);
    }

  if (!IS_NPC (ch) && IS_POLYAFF (ch, POLY_WRAITHFORM)
      && number_range (1, 6) == 2)
    {
      more_hit (ch, victim, gsn_tentacle, 0, number_range (1, 2), FALSE);
    }
  if (!IS_NPC (ch) && IS_POLYAFF (ch, POLY_WRAITHFORM)
      && number_range (1, 6) == 1)
    {
      more_hit (ch, victim, gsn_spectralchill, 0, number_range (1, 2), FALSE);
    }
  if (!IS_NPC (ch) && IS_POLYAFF (ch, POLY_WRAITHFORM)
      && number_range (1, 6) == 3)
    {
      more_hit (ch, victim, gsn_enslavedsouls, 0, number_range (1, 2), FALSE);
    }
  if (!IS_NPC (ch) && IS_POLYAFF (ch, POLY_WRAITHFORM)
      && number_range (1, 6) == 4)
    {
      more_hit (ch, victim, gsn_unearthlyshriek, 0, number_range (1, 2),
		FALSE);
    }

  if (!IS_NPC (ch) && IS_VAMPAFF (ch, VAM_FANGS) && number_range (1, 6) == 1)
    one_hit (ch, victim, gsn_fangs, 0, 0, FALSE);
  if (!IS_NPC (ch) && IS_MOD (ch, MOD_TUSKS) && number_range (1, 6) == 1)
    one_hit (ch, victim, (TYPE_HIT + 10), 0, 0, FALSE);
  if (!IS_NPC (ch) && IS_MOD (ch, MOD_HORNS) && number_range (1, 6) == 1)
    one_hit (ch, victim, gsn_headbutt, 0, 0, FALSE);
  if (!IS_NPC (ch) && IS_XBITS (ch, X_YING_AURA) && victim->alignment < 1
      && number_range (1, 7) == 7 && ch->fighting == victim)
    {
      char buf[MSL];
      int dam = number_range (600, 1600);

      if (ch->in_room != victim->in_room)
	return;

      if (IS_NPC (victim))
	{
	  sprintf (buf, "Your #Caura#n singes %s's flesh #r[#7%d#r]#n.\n\r",
		   victim->short_descr, dam);
	}
      if (!IS_NPC (victim))
	{
	  sprintf (buf, "Your #Caura#n singes %s's flesh #r[#7%d#r]#n.\n\r",
		   victim->name, dam);
	}
      stc (buf, ch);
      sprintf (buf, "%s's #Caura#n singes your flesh #r[#7%d#r]#n.\n\r",
	       ch->name, dam);
      stc (buf, victim);
      act ("$n's #Caura#n singes $N's flesh.", ch, NULL, victim, TO_NOTVICT);
      hurt_person (ch, victim, dam, 0);
    }
  if (!IS_NPC (ch) && IS_XBITS (ch, X_YANG_AURA) && victim->alignment > -1
      && number_range (1, 7) == 7 && ch->fighting != NULL)
    {
      char buf[MSL];
      int dam = number_range (600, 1600);

      if (ch->in_room != victim->in_room)
	return;

      if (IS_NPC (victim))
	{
	  sprintf (buf, "Your #caura#n singes %s's flesh #r[#7%d#r]#n.\n\r",
		   victim->short_descr, dam);
	}
      if (!IS_NPC (victim))
	{
	  sprintf (buf, "Your #caura#n singes %s's flesh #r[#7%d#r]#n.\n\r",
		   victim->name, dam);
	}
      stc (buf, ch);
      sprintf (buf, "%s's #caura#n singes your flesh #r[#7%d#r]#n.\n\r",
	       ch->name, dam);
      stc (buf, victim);
      act ("$n's #caura#n singes $N's flesh.", ch, NULL, victim, TO_NOTVICT);
      hurt_person (ch, victim, dam, 0);
    }
  if (!IS_NPC (ch) && IS_KAHN (ch) && IS_VAMPAFF (ch, VAM_CLAWS)
      && number_range (1, 6) <= 3)
    {
      if (!IS_SET (ch->more, MORE_HAND_FLAME))
	{
	  one_hit (ch, victim, gsn_claws, 0, 0, FALSE);
	}
      if (IS_SET (ch->more, MORE_HAND_FLAME))
	{
	  one_hit (ch, victim, gsn_flamingclaws, 0, DAM_FIRE, TRUE);
	}
    }
  if (IS_HL (ch) && IS_SET (ch->quickening, QUICKENING_FIREAURA))
    {
      if (!IS_AFFECTED (victim, AFF_FLAMING) && !IS_EFRETI (victim))
	{
	  send_to_char ("You are engulfed in flames!\n\r", victim);
	  act ("$n is engulfed in flames!", victim, NULL, NULL, TO_ROOM);
	  SET_BIT (victim->affected_by, AFF_FLAMING);
	}
    }
  if (!IS_NPC (ch) && IS_DRAGON (ch) && IS_VAMPAFF (ch, VAM_CLAWS)
      && number_range (1, 6) == 1)
    one_hit (ch, victim, gsn_claws, 0, 0, FALSE);
  if (IS_WEREWOLF (ch) && get_tribe (ch, TRIBE_BONE_GNAWERS) > 2
      && number_range (1, 6) == 1)
    one_hit (ch, victim, gsn_fangs, 0, 0, FALSE);
  if (IS_WEREWOLF (ch) && get_tribe (ch, TRIBE_STARGAZERS) > 2
      && IS_VAMPAFF (ch, VAM_CLAWS) && number_range (1, 6) == 2)
    {
      int tal = DAM_NORMAL;
      int flame = 0;
      char wtalon[MIL];

      if (get_auspice (ch, AUSPICE_AHROUN) > 2)
	tal = DAM_SILVER;

      if (IS_MORE (ch, MORE_HAND_FLAME))
	{
	  tal = DAM_FIRE;
	  flame = 1;
	}

      sprintf (wtalon,
	       "You point your claws at $N and fire several %swasp talons at $M",
	       flame == 1 ? "#rf#Rla#ym#Rin#rg#n " : "");
      act_brief (wtalon, ch, NULL, victim, TO_CHAR, PLR_BRIEF3);
      if (!IS_NPC (victim))
	{
	  sprintf (wtalon,
		   "$n points $s claws at $N and fires several %swasp talons at you",
		   flame == 1 ? "#rf#Rla#ym#Rin#rg#n " : "");
	  act_brief (wtalon, ch, NULL, victim, TO_VICT, PLR_BRIEF3);
	}
      sprintf (wtalon,
	       "$n points $s claws at $N and fires several %swasp talons at $M",
	       flame == 1 ? "#rf#Rla#ym#Rin#rg#n " : "");
      act_brief (wtalon, ch, NULL, victim, TO_NOTVICT, PLR_BRIEF4);
      if (flame == 0)
	more_hit (ch, victim, gsn_wasptalons, tal, number_range (1, 3), TRUE);
      if (flame == 1)
	more_hit (ch, victim, gsn_firetalons, tal, number_range (1, 3), TRUE);
    }
  if (IS_DJINN (ch) && IS_VAMPAFF (ch, VAM_CLAWS) && number_range (1, 6) == 1)
    one_hit (ch, victim, gsn_claws, 0, 0, FALSE);
  if (IS_DJINN (ch) && IS_POLYAFF (ch, POLY_DJINNFORM)
      && number_range (1, 6) == 1)
    one_hit (ch, victim, gsn_windgust, 0, DAM_WIND, FALSE);
  if (IS_NINJA (ch) && ch->pcdata->npowers[NPOWER_NINGENNO] > 0
      && number_range (1, 6) == 1)
    {
      if (IS_XBITS (ch, X_YING_SPEED))
	{
	  one_hit (ch, victim, gsn_swift_strike, 0, 0, FALSE);
	}
      one_hit (ch, victim, gsn_claws, 0, 0, FALSE);
    }
  if (IS_NINJA (ch) && ch->pcdata->npowers[NPOWER_NINGENNO] > 3
      && number_range (1, 6) == 1)
    {
      if (IS_XBITS (ch, X_YING_SPEED))
	{
	  one_hit (ch, victim, gsn_swift_strike, 0, 0, FALSE);
	}
      one_hit (ch, victim, gsn_shiroken, 0, 0, FALSE);
    }
  if (IS_NINJA (ch) && ch->pcdata->npowers[NPOWER_NINBUKI] > 1
      && number_range (1, 6) == 1)
    {
      if (IS_XBITS (ch, X_YING_SPEED))
	{
	  one_hit (ch, victim, gsn_swift_strike, 0, 0, FALSE);
	}
      one_hit (ch, victim, gsn_marukugi, 0, 0, FALSE);
    }
  if (IS_NINJA (ch) && ch->pcdata->npowers[NPOWER_NINBUKI] > 3
      && number_range (1, 6) == 1)
    {
      if (IS_XBITS (ch, X_YING_SPEED))
	{
	  one_hit (ch, victim, gsn_swift_strike, 0, 0, FALSE);
	}
      more_hit (ch, victim, gsn_dokuhari, DAM_ACID, number_range (1, 3),
		TRUE);
    }
  if (IS_NINJA (ch) && ch->pcdata->npowers[NPOWER_BUSHIDO] > 3
      && number_range (1, 6) == 1)
    {
      if (IS_XBITS (ch, X_YING_SPEED))
	{
	  one_hit (ch, victim, gsn_swift_strike, 0, 0, FALSE);
	}
      one_hit (ch, victim, gsn_ittaken, DAM_NORMAL, 0, FALSE);
    }
  if (IS_DJINN (ch)
      && IS_SET (ch->pcdata->powers[DJINNPOWERS], DJINN_DREAMSTAIN)
      && number_range (1, 6) == 2)
    one_hit (ch, victim, gsn_dreamstain, 0, DAM_MAGIC, FALSE);

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

  if (!IS_NPC (ch) && IS_WEREWOLF (ch) && wieldorig == 0
      && get_tribe (ch, TRIBE_BLACK_FURIES) > 1 && number_range (1, 3) == 1)
    spell_poison (gsn_poison, 25, ch, victim);
  if (!IS_NPC (ch) && IS_WEREWOLF (ch) && wieldorig == 0
      && get_tribe (ch, TRIBE_BLACK_FURIES) > 2 && number_range (1, 3) == 3)
    {
      level = ch->spl[RED_MAGIC] * number_range (8, 12);

      if ((sn = skill_lookup ("curse")) > 0)
	(*skill_table[sn].spell_fun) (sn, level, ch, victim);
    }
  if (!IS_NPC (ch) && IS_WEREWOLF (ch) && wieldorig == 0
      && get_auspice (ch, AUSPICE_RAGABASH) > 5 && number_range (1, 3) == 3)
    {
      level = ch->spl[RED_MAGIC] * number_range (8, 12);

      if ((sn = skill_lookup ("pestilence")) > 0)
	(*skill_table[sn].spell_fun) (sn, level, ch, victim);
    }
  if (!IS_NPC (victim) && !IS_NPC (ch) && IS_KAHN (ch) && wieldorig == 0
      && ch->pcdata->powers[KAHN_COMBAT] > 5 && number_range (1, 3) == 2)
    {
      level = ch->spl[RED_MAGIC] * number_range (8, 12);

      if ((sn = skill_lookup ("tracer")) > 0)
	(*skill_table[sn].spell_fun) (sn, level, ch, victim);
    }
  if (!IS_NPC (ch) && IS_NINJA (ch)
      && ch->pcdata->npowers[NPOWER_NINGENNO] > 4 && dt == gsn_shiroken
      && number_range (1, 3) == 1)
    spell_poison (gsn_poison, (ch->level * number_range (5, 10)), ch, victim);
  if (!IS_NPC (ch) && IS_NINJA (ch)
      && ch->pcdata->npowers[NPOWER_NINGENNO] > 4 && dt == gsn_marukugi
      && number_range (1, 3) == 1)
    spell_poison (gsn_poison, (ch->level * number_range (5, 10)), ch, victim);
  if (!IS_NPC (ch) && IS_DRAGON (ch)
      && dt == gsn_wyverntail && number_range (1, 3) == 1)
    spell_poison (gsn_poison, (ch->level * number_range (5, 10)), ch, victim);
  if (!IS_NPC (ch) && IS_DJINN (ch) && IS_VAMPAFF (ch, VAM_CLAWS)
      && number_range (1, 3) == 1)
    spell_poison (gsn_poison, (ch->level * number_range (5, 10)), ch, victim);
  if (!IS_NPC (ch) && IS_DRACONIAN (ch) && IS_DRACWEAP (ch, DRAC_POISON)
      && number_range (1, 3) == 1)
    spell_poison (gsn_poison, (ch->level * number_range (5, 10)), ch, victim);

  if (victim == NULL || victim->position == POS_DEAD)
    return;
  if (IS_XBITS (victim, X_DEATH_SHIELD) && ch->position == POS_FIGHTING
      && number_range (1, 3) == 1)
    {
      if (!IS_XBITS (ch, X_DEATH_SHIELD))
	{
	  level = victim->spl[YELLOW_MAGIC] * number_range (8, 12);
	  if (victim->pcdata->npowers[NPATH_DARK] > 8)
	    level *= 1.5;

	  if ((sn = skill_lookup ("spirit drain")) > 0)
	    (*skill_table[sn].spell_fun) (sn, level, victim, ch);
	}
    }
/*    if (IS_XBITS(ch, X_DEATH_SHIELD) && victim->position == POS_FIGHTING && number_range(1,3) == 1)
    {
     	if (!IS_XBITS(victim, X_DEATH_SHIELD))
     	{
     	 level = ch->spl[YELLOW_MAGIC] * number_range(8,12);
	 if (ch->pcdata->npowers[NPATH_DARK] > 8) level *= 2;

		if ( (sn = skill_lookup( "spirit drain" ) ) > 0)
		    (*skill_table[sn].spell_fun) (sn,level,ch,victim);
     	}
    }
*/
  level = victim->spl[1] << 1;

  if (victim == NULL || victim->position == POS_DEAD)
    return;
  if (IS_ITEMAFF (victim, ITEMA_SHOCKSHIELD) && ch->position == POS_FIGHTING
      && number_range (1, 3) == 1)
    {
      if (!IS_ITEMAFF (ch, ITEMA_SHOCKSHIELD))
	{
	  if ((sn = skill_lookup ("lightning bolt shield")) > 0)
	    (*skill_table[sn].spell_fun) (sn, level, victim, ch);
	}
    }
  if (victim == NULL || victim->position == POS_DEAD)
    return;
  if (IS_ITEMAFF (victim, ITEMA_FIRESHIELD) && ch->position == POS_FIGHTING
      && number_range (1, 3) == 1)
    {
      if (!IS_ITEMAFF (ch, ITEMA_FIRESHIELD))
	{
	  if ((sn = skill_lookup ("fireball shield")) > 0)
	    (*skill_table[sn].spell_fun) (sn, level, victim, ch);
	}
    }
  if (victim == NULL || victim->position == POS_DEAD)
    return;
  if (IS_ITEMAFF (victim, ITEMA_ICESHIELD) && ch->position == POS_FIGHTING
      && number_range (1, 3) == 1)
    {
      if (!IS_ITEMAFF (ch, ITEMA_ICESHIELD))
	{
	  if ((sn = skill_lookup ("chill touch shield")) > 0)
	    (*skill_table[sn].spell_fun) (sn, level, victim, ch);
	}
    }
  if (victim == NULL || victim->position == POS_DEAD)
    return;
  if (IS_ITEMAFF (victim, ITEMA_ACIDSHIELD) && ch->position == POS_FIGHTING
      && number_range (1, 3) == 1)
    {
      if (!IS_ITEMAFF (ch, ITEMA_ACIDSHIELD))
	{
	  if ((sn = skill_lookup ("acid blast shield")) > 0)
	    (*skill_table[sn].spell_fun) (sn, level, victim, ch);
	}
    }
  if (IS_ITEMAFF (victim, ITEMA_BLADESHIELD) && ch->position == POS_FIGHTING
      && number_range (1, 3) == 1)
    {
      if (!IS_ITEMAFF (ch, ITEMA_BLADESHIELD))
	{
	  if ((sn = skill_lookup ("blade shield")) > 0)
	    (*skill_table[sn].spell_fun) (sn, level, victim, ch);
	}
    }
  if (victim == NULL || victim->position == POS_DEAD)
    return;
  if (IS_ITEMAFF (victim, ITEMA_CHAOSSHIELD) && ch->position == POS_FIGHTING
      && number_range (1, 3) == 1)
    {
      if (!IS_ITEMAFF (ch, ITEMA_CHAOSSHIELD))
	{
	  if ((sn = skill_lookup ("chaos blast shield")) > 0)
	    (*skill_table[sn].spell_fun) (sn, level, victim, ch);
	}
    }



  level = ch->spl[1] >> 1;

  if (!IS_NPC (ch) && IS_XBITS (ch, X_RIGHT_POISON)
      && number_range (1, 3) == 1)
    {
      spell_poison (gsn_poison, level, ch, victim);
    }
  if (!IS_NPC (ch) && IS_XBITS (ch, X_LEFT_POISON)
      && number_range (1, 3) == 1)
    {
      spell_poison (gsn_poison, level, ch, victim);
    }
  if (!IS_NPC (ch) && IS_XBITS (ch, X_RIGHT_HOLY) && number_range (1, 3) == 1)
    {
      if ((sn = skill_lookup ("holybolt")) > 0)
	(*skill_table[sn].spell_fun) (sn, level, ch, victim);
    }
  if (!IS_NPC (ch) && IS_XBITS (ch, X_LEFT_HOLY) && number_range (1, 3) == 3)
    {
      if ((sn = skill_lookup ("holybolt")) > 0)
	(*skill_table[sn].spell_fun) (sn, level, ch, victim);
    }
  if (!IS_NPC (ch) && IS_XBITS (ch, X_RIGHT_SHOCK)
      && number_range (1, 3) == 2)
    {
      if (!IS_ITEMAFF (victim, ITEMA_SHOCKSHIELD))
	{
	  if ((sn = skill_lookup ("shocking grasp weapon")) > 0)
	    (*skill_table[sn].spell_fun) (sn, level, ch, victim);
	}
    }
  if (!IS_NPC (ch) && IS_XBITS (ch, X_LEFT_SHOCK) && number_range (1, 3) == 1)
    {
      if (!IS_ITEMAFF (victim, ITEMA_SHOCKSHIELD))
	{
	  if ((sn = skill_lookup ("shocking grasp weapon")) > 0)
	    (*skill_table[sn].spell_fun) (sn, level, ch, victim);
	}
    }
  if (!IS_NPC (ch) && IS_XBITS (ch, X_RIGHT_FROST)
      && number_range (1, 3) == 1)
    {
      if (!IS_ITEMAFF (victim, ITEMA_ICESHIELD))
	{
	  if ((sn = skill_lookup ("ice blast weapon")) > 0)
	    (*skill_table[sn].spell_fun) (sn, level, ch, victim);
	}
    }
  if (!IS_NPC (ch) && IS_XBITS (ch, X_LEFT_FROST) && number_range (1, 3) == 1)
    {
      if (!IS_ITEMAFF (victim, ITEMA_ICESHIELD))
	{
	  if ((sn = skill_lookup ("ice blast weapon")) > 0)
	    (*skill_table[sn].spell_fun) (sn, level, ch, victim);
	}
    }
  if (!IS_NPC (ch) && IS_XBITS (ch, X_LEFT_FLAMING)
      && number_range (1, 3) == 1)
    {
      if (!IS_ITEMAFF (victim, ITEMA_FIRESHIELD))
	{
	  if ((sn = skill_lookup ("burning hands weapon")) > 0)
	    (*skill_table[sn].spell_fun) (sn, level, ch, victim);
	}
    }
  if (!IS_NPC (ch) && IS_XBITS (ch, X_RIGHT_FLAMING)
      && number_range (1, 3) == 1)
    {
      if (!IS_ITEMAFF (victim, ITEMA_FIRESHIELD))
	{
	  if ((sn = skill_lookup ("burning hands weapon")) > 0)
	    (*skill_table[sn].spell_fun) (sn, level, ch, victim);
	}
    }
  if (!IS_NPC (ch) && IS_XBITS (ch, X_RIGHT_ACID) && number_range (1, 3) == 1)
    {
      if (!IS_ITEMAFF (victim, ITEMA_ACIDSHIELD))
	{
	  if ((sn = skill_lookup ("acid arrow weapon")) > 0)
	    (*skill_table[sn].spell_fun) (sn, level, ch, victim);
	}
    }
  if (!IS_NPC (ch) && IS_XBITS (ch, X_LEFT_ACID) && number_range (1, 3) == 1)
    {
      if (!IS_ITEMAFF (victim, ITEMA_ACIDSHIELD))
	{
	  if ((sn = skill_lookup ("acid arrow weapon")) > 0)
	    (*skill_table[sn].spell_fun) (sn, level, ch, victim);
	}
    }


  return;
}

void
do_combat (CHAR_DATA * ch, char *argument)
{
  char buf[MSL];
  int speed = get_speed (ch);
  int hitroll = char_hitroll (ch);
  int damroll = char_damroll (ch);
  int damcap = ch->damcap[0];
  int numatk = 0;
  CHAR_DATA *victim;
  OBJ_DATA *wield1;
  OBJ_DATA *wield2;
  OBJ_DATA *wield3;
  OBJ_DATA *wield4;

  if (IS_NPC (ch))
    return;

  if (!IS_NPC (ch)
      && (IS_EXTRA (ch, EXTRA_OSWITCH) || IS_HEAD (ch, LOST_HEAD)))
    return;

  if (ch->fighting != NULL)
    {
      victim = ch->fighting;
    }
  else
    {
      victim = ch;
    }

  if (!IS_NPC (victim) && victim != ch)
    {
      victim = ch;
    }

  numatk = number_attacks (ch, victim);
  wield1 = get_eq_char (ch, WEAR_WIELD);
  wield2 = get_eq_char (ch, WEAR_HOLD);
  wield3 = get_eq_char (ch, WEAR_THIRD_HAND);
  wield4 = get_eq_char (ch, WEAR_FOURTH_HAND);
  numatk++;
  if ((IS_MONK (ch) || IS_KAHN (ch)) && is_unarmed (ch))
    {
      numatk++;
      if (IS_MOD (ch, MOD_THIRD_ARM))
	numatk++;
      if (IS_MOD (ch, MOD_FOURTH_ARM))
	numatk++;
    }
  if (wield1 != NULL && wield1->item_type == ITEM_WEAPON && wield2 != NULL
      && wield2->item_type == ITEM_WEAPON)
    numatk++;
  if (wield3 != NULL && wield3->item_type == ITEM_WEAPON)
    numatk++;
  if (wield4 != NULL && wield4->item_type == ITEM_WEAPON)
    numatk++;

  stc ("\n\r#g====================#y Combat#g ====================#n\n\r\n\r",
       ch);
  sprintf (buf, "   #cHitroll:#C %6d#c.          Damroll:#C %6d#c.#n\n\r\n\r",
	   hitroll, damroll);
  stc (buf, ch);
  sprintf (buf, "               #cCombat Speed:#C %2d#c.#n\n\r\n\r", speed);
  stc (buf, ch);
  sprintf (buf,
	   "#c      Attacks each round against Mobs:#C %2d#c.#n\n\r\n\r",
	   numatk);
  stc (buf, ch);
  sprintf (buf, "               #cDamcap:#C %6d#c.#n\n\r", damcap);
  stc (buf, ch);
  stc ("\n\r#g================================================#n\n\r", ch);

  return;

}

int
number_attacks (CHAR_DATA * ch, CHAR_DATA * victim)
{
  int count = 0;

  if (ch->in_room == NULL
      || IS_SET (ch->in_room->added_flags, ROOM2_TIMESLOW))
    return count;



  if (IS_NPC (ch))
    {
      if (ch->level >= 10)
	count++;
      if (ch->level >= 30)
	count++;
      if (ch->level >= 60)
	count++;
      if (ch->level >= 100)
	count++;
      if (ch->level >= 200)
	count++;
      if (ch->level >= 300)
	count++;
      if (ch->level >= 400)
	count++;
      if (ch->level >= 500)
	count++;
      if (ch->level >= 600)
	count++;
      if (ch->level >= 800)
	count++;
      if (ch->level >= 6000)
	count++;
      if (ch->level >= 7000)
	count += 2;
      if (ch->level >= 8000)
	count += 2;
      return count;
    }

  if (IS_STANCE (ch, STANCE_VIPER) && number_percent () >
      ch->stance[STANCE_VIPER] * 0.5)
    count++;
  else if (IS_STANCE (ch, STANCE_MANTIS) && number_percent () >
	   ch->stance[STANCE_MANTIS] * 0.5)
    count++;
  else if (IS_STANCE (ch, STANCE_TIGER) && number_percent () >
	   ch->stance[STANCE_TIGER] * 0.5)
    count++;

  if (!IS_NYM (ch, NYM_DEAD))
    {
      if (!IS_NPC (ch) && get_celerity (ch) > 0)
	count += get_celerity (ch);

      if (!IS_NPC (ch) && IS_WEREWOLF (ch)
	  && get_tribe (ch, TRIBE_SILENT_STRIDERS) > 0)
	{
	  if (get_tribe (ch, TRIBE_SILENT_STRIDERS) > 2)
	    count += 4;
	  if (get_tribe (ch, TRIBE_STARGAZERS) > 1)
	    count += 2;
	}


      if (IS_NEWBIE (ch))
	count += 5;

      if (IS_VAMPIRE (ch))
	count += 8 - ch->vampgen;

      if (IS_VAMPIRE (ch) && (ch->pcdata->vamprage > 0))
	count += 3;

      if (IS_KAHN (ch))
	{
	  if (ch->pcdata->powers[KAHN_TIGER] > 0)
	    count += ch->pcdata->powers[KAHN_TIGER];
	}
      if (IS_MONK (ch) && ch->monkab[COMBAT] > 0)
	{
	  count += ch->monkab[COMBAT] / 2;
	}
      if (IS_MONK (ch) && ch->chi[CURRENT] > 2)
	{
	  count += ch->chi[CURRENT] / 3;
	}
      if (IS_DJINN (ch))
	{
	  if (IS_SET (ch->pcdata->powers[DJINNPOWERS], DJINN_SPEED))
	    count += 3;
	  if (IS_POLYAFF (ch, POLY_DJINNFORM))
	    count += 4;
	}

      if (!IS_NPC (ch))
	{
	  if (ch->pcdata->wisdoms[ELF_HASTE] > 0)
	    count += ch->pcdata->wisdoms[ELF_FIRE];
	}

      if (IS_ANGELW (ch))
	{
	  if (IS_SET (ch->corbits, COR_PRAYER))
	    count += 3;
	  if (IS_POLYAFF (ch, POLY_ANGELFORM))
	    count += ch->arank / 2;
	}

      if (IS_NINJA (ch))
	{
	  count += ch->pcdata->npowers[NPOWER_NINGENNO];
	}
      if (IS_DRAGON (ch))
	{
	  if (ch->pcdata->dpowers[DRAGON_AGE] > 2)
	    count += 1;
	  if (ch->pcdata->dpowers[DRAGON_AGE] > 5)
	    count += 1;
	  if (ch->pcdata->dpowers[DRAGON_AGE] > 8)
	    count += 2;
	  if (ch->pcdata->dpowers[DRAGON_AGE] >= 12)
	    count += 2;
	}
      if (IS_DRACONIAN (ch))
	{
	  int percent = 0;
	  int percent2 = 0;

	  if (IS_DRAGON (ch))
	    {
	      if (ch->pcdata->cpowers[DRAC_SPEED] < 6)
		{
		  percent = ch->pcdata->cpowers[DRAC_SPEED];
		}
	      else
		{
		  percent = 5;
		  percent2 = ch->pcdata->cpowers[DRAC_SPEED];
		  percent2 /= 3;
		  percent += percent2;
		}
	    }
	  else
	    {
	      percent = ch->pcdata->cpowers[DRAC_SPEED];
	    }
	  count += percent;
	}

      if (IS_HIGHLANDER (ch))
	{
	  count++;
	  if (IS_QUICK (ch, QUICKENING_SPEED))
	    count += 2;
	  if (IS_ITEMAFF (ch, ITEMA_HIGHLANDER))
	    count++;
	}
      if (!IS_NPC (ch) && IS_DEMON (ch)
	  && IS_SET (ch->pcdata->disc[C_POWERS], DEM_SPEED))
	count += 2;

      if (IS_DEMON (ch))
	count++;
      if (IS_ELF (ch))
	count++;
      if (ch->pcdata->wisdoms[ELF_HASTE] > 0)
	count += 2;
    }
  if (!IS_NPC (ch))
    count += (ch->max_move / 10000);

  if (ch->lstatus >= 2)
    count++;

  if (IS_ITEMAFF (ch, ITEMA_SPEED))
    count++;

  if (count > 10)
    count = 10;

  if (!IS_NPC (victim) && victim != ch)
    count = 0;

  if (IS_ITEMAFF (ch, ITEMA_SUPERSPEED))
    count += 2;

  if (!IS_NPC (victim))
    {
      if (ch->lstatus > victim->lstatus)
	count += ch->lstatus;
      if (ch->lstatus < victim->lstatus)
	count -= victim->lstatus;
    }
  return count;
}

int
get_speed (CHAR_DATA * ch)
{
  int count = 13;

  if (IS_STANCE (ch, STANCE_VIPER) && number_percent () >
      ch->stance[STANCE_VIPER] * 0.5)
    count--;
  else if (IS_STANCE (ch, STANCE_MANTIS) && number_percent () >
	   ch->stance[STANCE_MANTIS] * 0.5)
    count--;
  else if (IS_STANCE (ch, STANCE_TIGER) && number_percent () >
	   ch->stance[STANCE_TIGER] * 0.5)
    count--;
  else if (!IS_NPC (ch) && IS_STANCE (ch, STANCE_SUPER1))
    {
      if (ch->stance[STANCE_SUPER1] > 100 &&
	  IS_SET (ch->pcdata->qstats[0], QS_SUPER_SPEED))
	count--;
    }
  else if (!IS_NPC (ch) && IS_STANCE (ch, STANCE_SUPER2))
    {
      if (ch->stance[STANCE_SUPER2] > 100 &&
	  IS_SET (ch->pcdata->qstats[1], QS_SUPER_SPEED))
	count--;
    }
  else if (!IS_NPC (ch) && IS_STANCE (ch, STANCE_SUPER3))
    {
      if (ch->stance[STANCE_SUPER3] > 100 &&
	  IS_SET (ch->pcdata->qstats[2], QS_SUPER_SPEED))
	count--;
    }
  else if (!IS_NPC (ch) && IS_STANCE (ch, STANCE_SUPER4))
    {
      if (ch->stance[STANCE_SUPER4] > 100 &&
	  IS_SET (ch->pcdata->qstats[3], QS_SUPER_SPEED))
	count--;
    }
  else if (!IS_NPC (ch) && IS_STANCE (ch, STANCE_SUPER5))
    {
      if (ch->stance[STANCE_SUPER5] > 100 &&
	  IS_SET (ch->pcdata->qstats[4], QS_SUPER_SPEED))
	count--;
    }

  if (!IS_NYM (ch, NYM_DEAD))
    {
      if (!IS_NPC (ch) && IS_ANGELW (ch))
	{
	  if (IS_SET (ch->apowers, APOWER_GODLYSPEED))
	    count -= 2;
	  else
	    count -= 1;
	}
      if (!IS_NPC (ch) && get_celerity (ch) > 0)
	count -= (get_celerity (ch));

      if (!IS_NPC (ch) && IS_NINJA (ch))
	{
	  if (ch->pcdata->npowers[NPOWER_NINGENNO] > 2)
	    count -= 2;

	  if (IS_XBITS (ch, X_YING_SPEED))
	    count -= 1;
	}
      if (!IS_NPC (ch) && IS_WEREWOLF (ch)
	  && get_tribe (ch, TRIBE_SILENT_STRIDERS) > 0)
	{
	  if (get_tribe (ch, TRIBE_SILENT_STRIDERS) > 2)
	    count -= 4;
	  else
	    count -= 3;
	}

      if (IS_DRACONIAN (ch))
	{
	  int percent = 0;
	  int percent2 = 0;

	  if (IS_DRAGON (ch))
	    {
	      if (ch->pcdata->cpowers[DRAC_SPEED] < 6)
		{
		  percent = ch->pcdata->cpowers[DRAC_SPEED];
		}
	      else
		{
		  percent = 5;
		  percent2 = ch->pcdata->cpowers[DRAC_SPEED];
		  percent2 /= 3;
		  percent += percent2;
		}
	    }
	  else
	    {
	      percent = ch->pcdata->cpowers[DRAC_SPEED];
	    }
	  percent /= 2;
	  count -= percent;
	}

      if (IS_HIGHLANDER (ch))
	{
	  if (IS_QUICK (ch, QUICKENING_SPEED))
	    count -= 2;
	  if (IS_ITEMAFF (ch, ITEMA_HIGHLANDER))
	    count--;
	}

      if (!IS_NPC (ch))
	{
	  if (ch->pcdata->wisdoms[ELF_HASTE] > 1)
	    count -= ch->pcdata->wisdoms[ELF_FIRE] / 2;
	}

      if (!IS_NPC (ch) && IS_DEMON (ch)
	  && IS_SET (ch->pcdata->disc[C_POWERS], DEM_SPEED))
	count -= 1;

      if (IS_MONK (ch) && ch->monkab[COMBAT] > 0)
	count -= ch->monkab[COMBAT];

      if (IS_DRAGON (ch))
	count -= ch->pcdata->dpowers[DRAGON_AGE] / 6;

      if (IS_DJINN (ch))
	{
	  if (IS_SET (ch->pcdata->powers[DJINNPOWERS], DJINN_SPEED))
	    count -= 2;
	}
    }
  if (IS_ITEMAFF (ch, ITEMA_SPEED))
    count--;

  if (IS_NPC (ch))
    {
      if (ch->level >= 10)
	count--;
      if (ch->level >= 30)
	count--;
      if (ch->level >= 75)
	count--;
      if (ch->level >= 150)
	count--;
      if (ch->level >= 300)
	count--;
      if (ch->level >= 500)
	count--;
      if (ch->level >= 800)
	count--;
      if (ch->level >= 1000)
	count--;
      if (ch->level >= 5000)
	count--;
    }

  if (!IS_NPC (ch))
    count -= ch->move / 10000;

  if (!IS_NPC (ch) && ch->lstatus > 0)
    {
      if (ch->lstatus >= 4)
	count--;
      if (ch->lstatus >= 6)
	count--;
      if (ch->lstatus >= 8)
	count--;
      if (ch->lstatus >= 9)
	count--;
    }

  if (count < 3)
    {
      count = 3;
    }

  if (IS_ITEMAFF (ch, ITEMA_SUPERSPEED))
    count--;

  return count;
}


/*
 * Hit one guy once.
 */
void
one_hit (CHAR_DATA * ch, CHAR_DATA * victim, int dt, int handtype,
	 int damkind, bool agg_dam)
{
  OBJ_DATA *wield;
  OBJ_DATA *gloves;
  int victim_ac;
  int thac0;
  int thac0_00;
  int thac0_32;
  int dam;
  int diceroll;
  int level;
  int mult;
  int stance;
  bool right_hand;
  bool silver = FALSE;

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

  /*
   * Figure out the type of damage message.
   */
  if (handtype == 2)
    {
      wield = get_eq_char (ch, WEAR_HOLD);
      right_hand = FALSE;
      if (dt == TYPE_UNDEFINED)
	{
	  dt = TYPE_HIT;
	  if (wield != NULL && wield->item_type == ITEM_WEAPON)
	    {
	      dt += wield->value[3];
	      if (!right_hand && IS_ITEMAFF (ch, ITEMA_LEFT_AGG))
		agg_dam = TRUE;
	      if (!right_hand && IS_ITEMAFF (ch, ITEMA_LEFT_SILVER))
		silver = TRUE;
	    }
	}
    }
  else
    {
      wield = get_eq_char (ch, WEAR_WIELD);
      right_hand = TRUE;
      if (dt == TYPE_UNDEFINED)
	{
	  dt = TYPE_HIT;
	  if (wield != NULL && wield->item_type == ITEM_WEAPON)
	    {
	      dt += wield->value[3];
	      if (right_hand && IS_ITEMAFF (ch, ITEMA_RIGHT_AGG))
		agg_dam = TRUE;
	      if (right_hand && IS_ITEMAFF (ch, ITEMA_RIGHT_SILVER))
		silver = TRUE;
	    }
	}
    }
  if (!IS_NPC (victim))
    {
      if (wield != NULL && IS_SET (wield->spectype, SITEM_SILVER))
	{
	  silver = TRUE;
	}
      else if ((gloves = get_eq_char (ch, WEAR_HANDS)) != NULL
	       && IS_SET (gloves->spectype, SITEM_SILVER))
	{
	  silver = TRUE;
	}
      else if ((IS_WEREWOLF (ch) && get_auspice (ch, AUSPICE_AHROUN) > 2) || IS_NEWWW (ch))
	{
	  silver = TRUE;
	}
    }
  if (ch->wpn[dt - 1000] > 5)
    level = (ch->wpn[dt - 1000] / 5);
  else
    level = 1;
/*
    if (level > 40) level = 40;
    else level = 1;
    if (level > 60) level = 60;
    if (IS_NPC(ch)) {
    if (ch->level>20) level=level +5;
    if (ch->level>40) level=level +10;
    if (ch->level>75) level=level +10;
    if (ch->level>150) level=level +10;
    if (ch->level>200) level=level +10;
    if (ch->level>400) level=level +10;
    if (ch->level>650) level=level +10;
    if (ch->level>900) level=level +10;
    if (ch->level>1000) level=level +20;

 if (char_hitroll(ch)>char_hitroll(victim)) level=level +5;
    }
*/ if (char_hitroll (ch) > char_hitroll (victim))
    level = level + 10;
  else
    level = level - 10;

  if (level > 90)
    level = 90;

  /*
   * 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 = interpolate (level, thac0_00, thac0_32) - char_hitroll (ch);
  victim_ac = UMAX (-100, char_ac (victim) / 10);
  if (!can_see (ch, victim))
//      victim_ac -= 4;
    victim_ac -= 50;
  if ((IS_NPC (ch) && ch->level > 30 && victim->level > 2)
      || IS_HIGHLANDER (ch))
    thac0 += 3;
  /*
   * The moment of excitement!
   */
  while ((diceroll = number_bits (5)) >= 20)
    ;

  if (diceroll == 0 || (diceroll != 19 && diceroll < thac0 - victim_ac))
    {
      /* Miss. */
      damage (ch, victim, 0, dt, DAM_NORMAL, FALSE, TRUE, TRUE);
      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);
      if (wield != NULL)
	dam += dam * 0.5;
      dam += ch->level;
    }
  else
    {
      if (IS_POLYAFF (ch, POLY_SERPENT))
	dam = number_range (25, 50);

/*	else if (!IS_NPC(ch) && IS_WEREWOLF(ch) && IS_VAMPAFF(ch,VAM_FANGS) && 
	    get_breed(ch, BREED_LUPUS) > 4 && dt == (TYPE_HIT + 10))
	    {dam = number_range( 50, 100 );}

	else if ( IS_MORE(ch,MORE_HAND_FLAME) && wield == NULL &&
	    IS_VAMPAFF(ch, VAM_CLAWS))
	    {dam = number_range( 25, 50 );}
*/
/* kavirp
	else if ( !IS_NPC(ch) && IS_VAMPAFF(ch,VAM_CLAWS) && wield == NULL && 
	    get_auspice(ch, AUSPICE_AHROUN) > 0)
	    {dam = number_range( 25, 50 );dt += TYPE_ADD_AGG;}
*/
      else if (IS_MONK (ch) && IS_VAMPAFF (ch, VAM_CLAWS) && wield == NULL)
	{
	  dam = number_range (200, 400);
	  agg_dam = TRUE;
	}
      else if (IS_VAMPAFF (ch, VAM_CLAWS) && wield == NULL && IS_NEWWW (ch))
        {
          dam = number_range (600, 1000);
          agg_dam = TRUE;
        }
      else if (IS_KAHN (ch) && IS_VAMPAFF (ch, VAM_CLAWS)
	       && IS_MORE (ch, MORE_HAND_FLAME) && wield == NULL)
	{
	  dam = number_range (400, 600);
	  agg_dam = TRUE;
	}
      else if (IS_MORE (ch, MORE_HAND_FLAME) && wield == NULL)
	{
	  dam = number_range (250, 350);
	  agg_dam = TRUE;
	}
      else if (IS_VAMPAFF (ch, VAM_CLAWS) && wield == NULL)
	{
	  dam = number_range (150, 250);
	  agg_dam = TRUE;
	}
      else if (wield != NULL && wield->item_type == ITEM_WEAPON)
	dam = number_range (wield->value[1], wield->value[2]);
      else
	dam = number_range (1, 4);
    }



  /*
   * Bonuses.
   */
  dam += char_damroll (ch);
  if (dt >= TYPE_HIT)
    dam += (dam * ((ch->wpn[dt - 1000] + 1) * 0.01));


  if (!IS_NPC (ch))
    {
      stance = ch->stance[0];
      if (IS_STANCE (ch, STANCE_NORMAL))
	dam *= 1.25;
      else
	dam += dambonus (ch, victim, dam, stance);
    }

  if (dam <= 0)
    {
      dam = 1;
    }
  if (IS_LICH (ch))
    {
      agg_dam = TRUE;
    }

  if (dt == gsn_backstab)
    {
      dam *= number_range (2, 3);
    }
  if (!IS_NPC (ch) && IS_WRAITH (ch) && IS_NYM (ch, NYM_DEATHPLANE))
    dam *= number_range (2, 5);
  if (IS_HIGHLANDER (ch))
    agg_dam = TRUE;

  if (IS_HIGHLANDER (ch) && wield != NULL)
    {
      int damtype = dt;
      int numpcent, wpdam;
      numpcent = (number_percent () * 10);
      wpdam = ch->wpn[wield->value[3]];
      if (numpcent > wpdam)
	{
	  improve_wpn (ch, damtype, 1);
	}
    }
  if (damkind == DAM_SILVER || damkind == DAM_NORMAL)
    {
      if (silver && agg_dam)
	{
	  damage (ch, victim, dam, dt, DAM_SILVER, TRUE, TRUE, TRUE);
	}
      else if (silver)
	{
	  if (IS_WEREWOLF (victim))
	    {
	      damage (ch, victim, dam, dt, DAM_SILVER, TRUE, TRUE, TRUE);
	    }
	  else
	    {
	      damage (ch, victim, dam, dt, DAM_SILVER, FALSE, TRUE, TRUE);
	    }
	}
      else if (agg_dam)
	{
	  damage (ch, victim, dam, dt, DAM_NORMAL, TRUE, TRUE, TRUE);
	}
      else
	{
	  damage (ch, victim, dam, dt, DAM_NORMAL, FALSE, TRUE, TRUE);
	}
    }
  else
    {
      damage (ch, victim, dam, dt, damkind, agg_dam, TRUE, TRUE);
    }
  tail_chain ();
  if (!is_safe (ch, victim))
    {
      improve_wpn (ch, dt, right_hand);
      improve_stance (ch);
      if (IS_KENSAI (victim) && !IS_COR (victim, COR_TOUGHNESS))
	{
	  improve_tough (victim);
	}
      if (IS_KENSAI (ch) && !IS_COR (ch, COR_DISCIPLINE)
	  && IS_COR (ch, COR_TOUGHNESS))
	{
	  improve_discipline (ch);
	}
    }
  return;
}

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

bool
can_bypass (CHAR_DATA * ch, CHAR_DATA * victim)
{
  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;
  else if (IS_POLYAFF (ch, POLY_SERPENT))
    return TRUE;
  else if (IS_POLYAFF (ch, POLY_WOLF))
    return TRUE;
  else if (!IS_NPC (ch) && IS_STANCE (ch, STANCE_SUPER1))
    {
      if (IS_SET (ch->pcdata->qstats[0], QS_SUPER_BYPASS))
	return TRUE;
    }
  else if (!IS_NPC (ch) && IS_STANCE (ch, STANCE_SUPER2))
    {
      if (IS_SET (ch->pcdata->qstats[1], QS_SUPER_BYPASS))
	return TRUE;
    }
  else if (!IS_NPC (ch) && IS_STANCE (ch, STANCE_SUPER3))
    {
      if (IS_SET (ch->pcdata->qstats[2], QS_SUPER_BYPASS))
	return TRUE;
    }
  else if (!IS_NPC (ch) && IS_STANCE (ch, STANCE_SUPER4))
    {
      if (IS_SET (ch->pcdata->qstats[3], QS_SUPER_BYPASS))
	return TRUE;
    }
  else if (!IS_NPC (ch) && IS_STANCE (ch, STANCE_SUPER5))
    {
      if (IS_SET (ch->pcdata->qstats[4], QS_SUPER_BYPASS))
	return TRUE;
    }
  return FALSE;
}

void
update_damcap (CHAR_DATA * ch, CHAR_DATA * victim)
{
  bool doubledam = FALSE;
  bool halfdam = FALSE;
  bool hellstorm = FALSE;
  int max_dam = 1000;


  if (IS_SET (mudconfig->world_affects, WORLD_DOUBLEDAMCAP))
    doubledam = TRUE;

  if (IS_SET (mudconfig->world_affects, WORLD_HALFDAMCAP))
    halfdam = TRUE;

  if (IS_SET (mudconfig->world_affects, WORLD_HELLSTORM))
    hellstorm = TRUE;
  if (!IS_NPC (ch) && ch->pcdata->empireeq[3] > 0)
    {
      max_dam += ch->pcdata->empireeq[3] * 50;
    }
  if (IS_NPC (ch))
    {
      max_dam += (ch->level << 2);

      if (max_dam >= 8000)
	max_dam = 8000;

      max_dam += ch->damcapbonus;
    }
  else
    {
      switch (ch->class)
	{
	default:
	  break;
	case CLASS_ABOMINATION:
	  if (get_disc (ch, DISC_POTENCE) > 0)
	    max_dam += (get_disc (ch, DISC_POTENCE) * 150);
	  if (get_tribe (ch, TRIBE_SHADOW_LORDS) > 0)
	    max_dam += 250;
	  if (get_tribe (ch, TRIBE_GET_OF_FENRIS) > 1)
	    max_dam += 250;
	  if (get_tribe (ch, TRIBE_BONE_GNAWERS) > 1)
	    max_dam += 250;
	  if (get_breed (ch, BREED_METIS) > 2)
	    max_dam += 250;
	  if (IS_POLYAFF (ch, POLY_WWZULO))
	    max_dam += 500;
	  if (IS_SET (ch->act, PLR_WOLFMAN))
	    max_dam += ch->pcdata->wolf * 2;
	  if (ch->pcdata->vamprage > 0)
	    max_dam += ch->pcdata->vamprage;
	  break;

	case CLASS_ABERRATION:
	  max_dam += 1000;
	  if (IS_SET (ch->pcdata->powers[DJINNPOWERS], DJINN_MIGHT))
	    max_dam += 800;
	  if (IS_POLYAFF (ch, POLY_DJINNFORM))
	    max_dam += 1200;
	  if (get_disc (ch, DISC_POTENCE) > 0)
	    max_dam += (get_disc (ch, DISC_POTENCE) * 50);
	  if (IS_SET (ch->polyaff, POLY_KAHNFORM))
	    max_dam += 1250;
	  max_dam += (ch->pcdata->powers[KAHN_COMBAT] * 250);
	  break;

	case CLASS_DJINN:
	  if (get_disc (ch, DISC_POTENCE) > 0)
	    max_dam += (get_disc (ch, DISC_POTENCE) * 50);
	  max_dam += 1000;
	  if (IS_SET (ch->pcdata->powers[DJINNPOWERS], DJINN_MIGHT))
	    max_dam += 800;
	  if (IS_POLYAFF (ch, POLY_DJINNFORM))
	    max_dam += 1200;
	  break;

	case CLASS_BLACK_SPIRAL_DANCER:
	  if (get_tribe (ch, TRIBE_SHADOW_LORDS) > 0)
	    max_dam += 250;
	  if (get_tribe (ch, TRIBE_GET_OF_FENRIS) > 1)
	    max_dam += 250;
	  if (get_breed (ch, BREED_METIS) > 2)
	    max_dam += 250;
	  if (get_tribe (ch, TRIBE_BONE_GNAWERS) > 1)
	    max_dam += 250;
	  if (IS_SET (ch->act, PLR_WOLFMAN))
	    max_dam += ch->pcdata->wolf * 2;
	  if (IS_POLYAFF (ch, POLY_WWZULO))
	    max_dam += 500;
	  if (get_disc (ch, DISC_POTENCE) > 0)
	    max_dam += (get_disc (ch, DISC_POTENCE) * 50);

	  if (!IS_NPC (ch) && IS_SET (ch->pcdata->disc[C_POWERS], DEM_MIGHT))
	    max_dam += 600;

	  if (ch->in_room != NULL && ch->in_room->area->plane == PLANE_HELL)
	    max_dam += 2500;
	  max_dam += (ch->pcdata->demonic * 10);
	  break;

	case CLASS_VAMPIRE:
	  if (ch->pcdata->vamprage > 0)
	    max_dam += ch->pcdata->vamprage;
	  if (get_disc (ch, DISC_POTENCE) > 0)
	    max_dam += (get_disc (ch, DISC_POTENCE) * 150);
	  break;

	case CLASS_CEVOYIA:
	  if (ch->pcdata->vamprage > 0)
	    max_dam += ch->pcdata->vamprage;
	  if (get_disc (ch, DISC_POTENCE) > 0)
	    max_dam += (get_disc (ch, DISC_POTENCE) * 150);
	  max_dam += 300;
	  if (ch->monkab[COMBAT] > 0)
	    max_dam += (ch->monkab[COMBAT] * 100);
	  if (ch->chi[CURRENT] > 0)
	    max_dam += (ch->chi[CURRENT] * 450);
	  break;

	case CLASS_IKIRYU:
	  if (ch->pcdata->vamprage > 0)
	    max_dam += ch->pcdata->vamprage;
	  if (get_disc (ch, DISC_POTENCE) > 0)
	    max_dam += (get_disc (ch, DISC_POTENCE) * 150);
	  max_dam += (ch->pcdata->npowers[NPOWER_NINGENNO] * 150);
	  if (ch->pcdata->npowers[NPOWER_CHIKYU] > 2)
	    max_dam += 500;
	  if (ch->pcdata->npowers[NPOWER_NINGENNO] == 7)
	    max_dam += 500;
	  if (IS_XBITS (ch, X_YANG_MIGHT))
	    max_dam += 600;
	  if (ch->pcdata->npowers[NINJA_RAGE] > 0)
	    max_dam += ch->pcdata->npowers[NINJA_RAGE] * 2;
	  break;

	case CLASS_LICH:
	  max_dam += 500;
	  if (ch->spheres[MENT] > 0)
	    max_dam += (300 * ch->spheres[MENT]);
	  max_dam += ch->pcdata->vamprage;
	  if (IS_SET (ch->in_room->added_flags, ROOM2_LICHCIRCLE))
	    max_dam += 2500;
	  if (IS_SET (ch->in_room->added_flags, ROOM2_LICHCIRCLE2))
	    max_dam += 2500;
	  if (IS_SET (ch->in_room->added_flags, ROOM2_LICHCIRCLE3))
	    max_dam += 2500;

	  if (get_disc (ch, DISC_POTENCE) > 0)
	    max_dam += (get_disc (ch, DISC_POTENCE) * 150);
	  break;

	case CLASS_SAINT:
	  max_dam += 300;
	  if (get_disc (ch, DISC_POTENCE) > 0)
	    max_dam += (get_disc (ch, DISC_POTENCE) * 50);

	  max_dam += ch->arank * 100;

	  if (IS_COR (ch, COR_PRAYER))
	    max_dam += 500;

	  if (ch->saintly > 0)
	    max_dam += 2000;

	  if (IS_POLYAFF (ch, POLY_SAINTFORM))
	    max_dam += (75 * ch->monkab[HOLY]);

	  if (ch->in_room != NULL && ch->in_room->area->plane == PLANE_HEAVEN)
	    max_dam += 2500;
	  if (ch->monkab[COMBAT] > 0)
	    max_dam += (ch->monkab[COMBAT] * 100);
	  if (ch->chi[CURRENT] > 0)
	    max_dam += (ch->chi[CURRENT] * 450);
	  break;

	case CLASS_MONK:
	  if (get_disc (ch, DISC_POTENCE) > 0)
	    max_dam += (get_disc (ch, DISC_POTENCE) * 50);
	  max_dam += 300;
	  if (ch->monkab[COMBAT] > 0)
	    max_dam += (ch->monkab[COMBAT] * 100);
	  if (ch->chi[CURRENT] > 0)
	    max_dam += (ch->chi[CURRENT] * 450);
	  break;

	case CLASS_TAKARRA:
	  max_dam += 300;
	  max_dam += 1000;
	  if (get_disc (ch, DISC_POTENCE) > 0)
	    max_dam += (get_disc (ch, DISC_POTENCE) * 50);
	  if (IS_SET (ch->pcdata->powers[DJINNPOWERS], DJINN_MIGHT))
	    max_dam += 800;
	  if (IS_POLYAFF (ch, POLY_DJINNFORM))
	    max_dam += 1200;
	  if (ch->monkab[COMBAT] > 0)
	    max_dam += (ch->monkab[COMBAT] * 100);
	  if (ch->chi[CURRENT] > 0)
	    max_dam += (ch->chi[CURRENT] * 450);
	  break;

	case CLASS_KAHN:
	  if (get_disc (ch, DISC_POTENCE) > 0)
	    max_dam += (get_disc (ch, DISC_POTENCE) * 50);
	  if (IS_SET (ch->polyaff, POLY_KAHNFORM))
	    max_dam += 1250;
	  max_dam += (ch->pcdata->powers[KAHN_COMBAT] * 250);
	  break;

	case CLASS_DEFYLER:
	  if (get_disc (ch, DISC_POTENCE) > 0)
	    max_dam += (get_disc (ch, DISC_POTENCE) * 50);
	  if (get_tribe (ch, TRIBE_SHADOW_LORDS) > 0)
	    max_dam += 250;
	  if (get_tribe (ch, TRIBE_GET_OF_FENRIS) > 1)
	    max_dam += 250;
	  if (get_breed (ch, BREED_METIS) > 2)
	    max_dam += 250;
	  if (get_tribe (ch, TRIBE_BONE_GNAWERS) > 1)
	    max_dam += 250;
	  if (IS_SET (ch->act, PLR_WOLFMAN))
	    max_dam += ch->pcdata->wolf * 2;
	  max_dam += 1000;
	  if (IS_POLYAFF (ch, POLY_WWZULO))
	    max_dam += 500;
	  if (IS_SET (ch->pcdata->powers[DJINNPOWERS], DJINN_MIGHT))
	    max_dam += 800;
	  if (IS_POLYAFF (ch, POLY_DJINNFORM))
	    max_dam += 1200;
	  break;

	case CLASS_SHAAHOUL:
	  if (get_disc (ch, DISC_POTENCE) > 0)
	    max_dam += (get_disc (ch, DISC_POTENCE) * 50);
	  if (IS_SET (ch->polyaff, POLY_KAHNFORM))
	    max_dam += 1250;
	  max_dam += (ch->pcdata->powers[KAHN_COMBAT] * 250);
	  max_dam *= (ch->pcdata->powers[KAHN_RANKS] / 2);
	  max_dam += 300;
	  if (ch->monkab[COMBAT] > 0)
	    max_dam += (ch->monkab[COMBAT] * 100);
	  if (ch->chi[CURRENT] > 0)
	    max_dam += (ch->chi[CURRENT] * 450);
	  break;

	case CLASS_TIGRASHA:
	  if (get_disc (ch, DISC_POTENCE) > 0)
	    max_dam += (get_disc (ch, DISC_POTENCE) * 50);
	  if (IS_SET (ch->polyaff, POLY_TIGERFORM))
	    max_dam += (85 * ch->pcdata->powers[KAHN_TIGER]);
	  if (IS_SET (ch->polyaff, POLY_KAHNFORM))
	    max_dam += 1250;
	  max_dam += (ch->pcdata->powers[KAHN_COMBAT] * 250);
	  max_dam += ch->arank * 100;

	  if (IS_COR (ch, COR_PRAYER))
	    max_dam += 500;

	  if (ch->in_room != NULL && ch->in_room->area->plane == PLANE_HEAVEN)
	    max_dam += 5000;
	  break;

	case CLASS_GAIAINQ:
	  if (get_disc (ch, DISC_POTENCE) > 0)
	    max_dam += (get_disc (ch, DISC_POTENCE) * 50);
	  if (get_tribe (ch, TRIBE_SHADOW_LORDS) > 0)
	    max_dam += 250;
	  if (get_tribe (ch, TRIBE_GET_OF_FENRIS) > 1)
	    max_dam += 250;
	  if (get_breed (ch, BREED_METIS) > 2)
	    max_dam += 250;
	  if (get_tribe (ch, TRIBE_BONE_GNAWERS) > 1)
	    max_dam += 250;
	  if (IS_SET (ch->act, PLR_WOLFMAN))
	    max_dam += ch->pcdata->wolf * 2;
	  if (IS_POLYAFF (ch, POLY_WWZULO))
	    max_dam += 500;

	  max_dam += ch->arank * 100;

	  if (IS_COR (ch, COR_PRAYER))
	    max_dam += 500;

	  if (ch->in_room != NULL && ch->in_room->area->plane == PLANE_HEAVEN)
	    max_dam += 2500;
	  break;

	case CLASS_ANGELW:

	  if (get_disc (ch, DISC_POTENCE) > 0)
	    max_dam += (get_disc (ch, DISC_POTENCE) * 50);
	  max_dam += ch->arank * 100;

	  if (IS_COR (ch, COR_PRAYER))
	    max_dam += 500;

	  if (ch->in_room != NULL && ch->in_room->area->plane == PLANE_HEAVEN)
	    max_dam += 5000;
	  break;

	case CLASS_BETRAYER:

	  if (get_disc (ch, DISC_POTENCE) > 0)
	    max_dam += (get_disc (ch, DISC_POTENCE) * 50);
	  max_dam += ch->arank * 100;

	  if (get_disc (ch, DISC_POTENCE) > 0)
	    max_dam += (get_disc (ch, DISC_POTENCE) * 50);

	  if (!IS_NPC (ch) && IS_SET (ch->pcdata->disc[C_POWERS], DEM_MIGHT))
	    max_dam += 600;

	  if (ch->in_room != NULL && ch->in_room->area->plane == PLANE_LIMBO)
	    max_dam += 2500;

	  if (IS_COR (ch, COR_PRAYER))
	    max_dam += 500;
	  max_dam += (ch->pcdata->demonic * 10);
	  break;

	case CLASS_NINJA:
	  if (get_disc (ch, DISC_POTENCE) > 0)
	    max_dam += (get_disc (ch, DISC_POTENCE) * 50);
	  max_dam += (ch->pcdata->npowers[NPOWER_NINGENNO] * 150);
	  if (ch->pcdata->npowers[NPOWER_CHIKYU] > 2)
	    max_dam += 500;
	  if (ch->pcdata->npowers[NPOWER_NINGENNO] == 7)
	    max_dam += 500;
	  if (IS_XBITS (ch, X_YANG_MIGHT))
	    max_dam += 600;
	  if (ch->pcdata->npowers[NINJA_RAGE] > 0)
	    max_dam += ch->pcdata->npowers[NINJA_RAGE] * 2;
	  break;

	case CLASS_GYPSY:
	  if (get_disc (ch, DISC_POTENCE) > 0)
	    max_dam += (get_disc (ch, DISC_POTENCE) * 50);
	  max_dam += (ch->pcdata->npowers[NPOWER_NINGENNO] * 150);
	  if (ch->pcdata->npowers[NPOWER_CHIKYU] > 2)
	    max_dam += 500;
	  if (ch->pcdata->npowers[NPOWER_NINGENNO] == 7)
	    max_dam += 500;
	  if (IS_XBITS (ch, X_YANG_MIGHT))
	    max_dam += 600;
	  if (ch->pcdata->npowers[NINJA_RAGE] > 0)
	    max_dam += ch->pcdata->npowers[NINJA_RAGE] * 2;
	  max_dam += 500;
	  if (ch->spheres[MENT] > 0)
	    max_dam += (300 * ch->spheres[MENT]);
	  break;

	case CLASS_SHINOBI:
	  max_dam += 300;
	  if (get_disc (ch, DISC_POTENCE) > 0)
	    max_dam += (get_disc (ch, DISC_POTENCE) * 50);
	  if (ch->monkab[COMBAT] > 0)
	    max_dam += (ch->monkab[COMBAT] * 100);
	  if (ch->chi[CURRENT] > 0)
	    max_dam += (ch->chi[CURRENT] * 450);
	  max_dam += (ch->pcdata->npowers[NPOWER_NINGENNO] * 150);
	  if (ch->pcdata->npowers[NPOWER_CHIKYU] > 2)
	    max_dam += 500;
	  if (ch->pcdata->npowers[NPOWER_NINGENNO] == 7)
	    max_dam += 500;
	  if (ch->pcdata->npowers[NINJA_RAGE] > 0)
	    max_dam += ch->pcdata->npowers[NINJA_RAGE] * 2;
	  break;

	case CLASS_PLANARSOHEI:
	  if (get_disc (ch, DISC_POTENCE) > 0)
	    max_dam += (get_disc (ch, DISC_POTENCE) * 50);

	  max_dam += ch->arank * 100;

	  if (IS_SET (ch->polyaff, POLY_ANGELFORM))
	    max_dam += 1000;

	  if (IS_COR (ch, COR_PRAYER))
	    max_dam += 500;

	  if (ch->in_room != NULL && ch->in_room->area->plane == PLANE_HEAVEN)
	    max_dam += 2500;

	  max_dam += (ch->pcdata->npowers[NPOWER_NINGENNO] * 150);
	  if (ch->pcdata->npowers[NPOWER_CHIKYU] > 2)
	    max_dam += 500;
	  if (ch->pcdata->npowers[NINJA_RAGE] > 0)
	    max_dam += ch->pcdata->npowers[NINJA_RAGE] * 2;
	  break;

	case CLASS_SHIDOSHI:

	  if (get_disc (ch, DISC_POTENCE) > 0)
	    max_dam += (get_disc (ch, DISC_POTENCE) * 50);
	  max_dam += (ch->pcdata->npowers[NPOWER_NINGENNO] * 150);
	  if (ch->pcdata->npowers[NPOWER_CHIKYU] > 2)
	    max_dam += 500;
	  if (ch->pcdata->npowers[NPOWER_NINGENNO] == 7)
	    max_dam += 500;
	  if (IS_XBITS (ch, X_YANG_MIGHT))
	    max_dam += 600;
	  if (ch->pcdata->npowers[NINJA_RAGE] > 0)
	    max_dam += ch->pcdata->npowers[NINJA_RAGE] * 2;

	  if (!IS_NPC (ch) && IS_SET (ch->pcdata->disc[C_POWERS], DEM_MIGHT))
	    max_dam += 600;

	  if (ch->in_room != NULL && ch->in_room->area->plane == PLANE_HELL)
	    max_dam += 2500;

	  max_dam += (ch->pcdata->demonic * 10);
	  break;

	case CLASS_DEMON:

	  if (get_disc (ch, DISC_POTENCE) > 0)
	    max_dam += (get_disc (ch, DISC_POTENCE) * 50);

	  if (!IS_NPC (ch) && IS_SET (ch->pcdata->disc[C_POWERS], DEM_MIGHT))
	    max_dam += 600;

	  if (ch->in_room != NULL && ch->in_room->area->plane == PLANE_HELL)
	    max_dam += 5000;

	  max_dam += (ch->pcdata->demonic * 20);
	  break;

	case CLASS_NEPHANDI:

	  if (get_disc (ch, DISC_POTENCE) > 0)
	    max_dam += (get_disc (ch, DISC_POTENCE) * 50);
	  max_dam += 500;
	  if (ch->spheres[MENT] > 0)
	    max_dam += (300 * ch->spheres[MENT]);

	  if (!IS_NPC (ch) && IS_SET (ch->pcdata->disc[C_POWERS], DEM_MIGHT))
	    max_dam += 600;

	  if (ch->in_room != NULL && ch->in_room->area->plane == PLANE_HELL)
	    max_dam += 2500;

	  max_dam += (ch->pcdata->demonic * 10);
	  break;

	case CLASS_RAKSHASA:
	  max_dam += 100;
	  if (get_disc (ch, DISC_POTENCE) > 0)
	    max_dam += (get_disc (ch, DISC_POTENCE) * 50);

	  if (IS_SET (ch->polyaff, POLY_KAHNFORM))
	    max_dam += 1250;
	  if (IS_SET (ch->polyaff, POLY_RAKSHASA))
	    max_dam += 100 * ch->pcdata->powers[KAHN_FORMS];
	  max_dam += (ch->pcdata->powers[KAHN_COMBAT] * 250);

	  if (!IS_NPC (ch) && IS_SET (ch->pcdata->disc[C_POWERS], DEM_MIGHT))
	    max_dam += 600;


	  if (ch->in_room != NULL && ch->in_room->area->plane == PLANE_HELL)
	    max_dam += 2500;


	  max_dam += (ch->pcdata->demonic * 10);
	  break;

	case CLASS_EFRETI:
	  max_dam += 1000;
	  if (IS_SET (ch->pcdata->powers[DJINNPOWERS], DJINN_MIGHT))
	    max_dam += 800;
	  if (IS_POLYAFF (ch, POLY_DJINNFORM))
	    max_dam += 1200;
	  if (get_disc (ch, DISC_POTENCE) > 0)
	    max_dam += (get_disc (ch, DISC_POTENCE) * 50);

	  if (!IS_NPC (ch) && IS_SET (ch->pcdata->disc[C_POWERS], DEM_MIGHT))
	    max_dam += 600;

	  if (ch->in_room != NULL && ch->in_room->area->plane == PLANE_HELL)
	    max_dam += 2500;

	  max_dam += (ch->pcdata->demonic * 10);
	  break;

	case CLASS_WEREWOLF:
	  if (get_tribe (ch, TRIBE_SHADOW_LORDS) > 0)
	    max_dam += 250;
	  if (get_tribe (ch, TRIBE_GET_OF_FENRIS) > 1)
	    max_dam += 250;
	  if (get_breed (ch, BREED_METIS) > 2)
	    max_dam += 250;
	  if (get_tribe (ch, TRIBE_BONE_GNAWERS) > 1)
	    max_dam += 250;
	  if (IS_SET (ch->act, PLR_WOLFMAN))
	    max_dam += ch->pcdata->wolf * 2;
	  if (IS_POLYAFF (ch, POLY_WWZULO))
	    max_dam += 500;
	  if (get_disc (ch, DISC_POTENCE) > 0)
	    max_dam += (get_disc (ch, DISC_POTENCE) * 50);
	  break;
	case CLASS_NEWWW:
	  if (IS_WOLFBIT (ch, WW_BEASTED))
	    max_dam += 500;
	  if (get_tribe (ch, QUAL_POWER) >= 3)
	    max_dam += get_tribe (ch, QUAL_POWER) * 250;
	  if (get_disc (ch, DISC_POTENCE) > 0)
	    max_dam += (get_disc (ch, DISC_POTENCE) * 50);
	  max_dam = calc_newwwdam (ch, max_dam);
	  break;
	case CLASS_SKINDANCER:
	  if (get_tribe (ch, TRIBE_SHADOW_LORDS) > 0)
	    max_dam += 250;
	  if (get_tribe (ch, TRIBE_GET_OF_FENRIS) > 1)
	    max_dam += 250;
	  if (get_breed (ch, BREED_METIS) > 2)
	    max_dam += 250;
	  if (get_tribe (ch, TRIBE_BONE_GNAWERS) > 1)
	    max_dam += 250;
	  if (IS_POLYAFF (ch, POLY_WWZULO))
	    max_dam += 500;
	  if (IS_SET (ch->act, PLR_WOLFMAN))
	    max_dam += ch->pcdata->wolf * 2;
	  if (IS_POLYAFF (ch, POLY_WWZULO))
	    max_dam += 500;
	  if (get_disc (ch, DISC_POTENCE) > 0)
	    max_dam += (get_disc (ch, DISC_POTENCE) * 50);
	  max_dam += 500;
	  if (ch->spheres[MENT] > 0)
	    max_dam += (300 * ch->spheres[MENT]);
	  break;

	case CLASS_HIGHLANDER:
	case CLASS_WEAPONMASTER:
	  if (get_disc (ch, DISC_POTENCE) > 0)
	    max_dam += (get_disc (ch, DISC_POTENCE) * 50);
	  max_dam += (ch->wpn[1] * 2.5);
	  if (IS_QUICK (ch, QUICKENING_STRENGTH))
	    max_dam += 400;
	  if (ch->battlefury > 0)
	    max_dam += (ch->battlefury * 2);
	  if (IS_POLYAFF (ch, POLY_MASTERFORM))
	    max_dam += 1000;
	  break;

	case CLASS_WISHENCHANT:
	  if (get_disc (ch, DISC_POTENCE) > 0)
	    max_dam += (get_disc (ch, DISC_POTENCE) * 50);
	  max_dam += 1500;
	  if (ch->spheres[MENT] > 0)
	    max_dam += (300 * ch->spheres[MENT]);
	  if (IS_SET (ch->pcdata->powers[DJINNPOWERS], DJINN_MIGHT))
	    max_dam += 800;
	  if (IS_POLYAFF (ch, POLY_DJINNFORM))
	    max_dam += 1200;
	  break;
	case CLASS_PARAGON:
	case CLASS_GRIMALKIN:
	case CLASS_REVENANT:
	case CLASS_BALEHOUND:
	  if (get_tribe (ch, TRIBE_SHADOW_LORDS) > 0)
	    max_dam += 250;
	  if (get_tribe (ch, TRIBE_GET_OF_FENRIS) > 1)
	    max_dam += 250;
	  if (get_breed (ch, BREED_METIS) > 2)
	    max_dam += 250;
	  if (get_tribe (ch, TRIBE_BONE_GNAWERS) > 1)
	    max_dam += 250;
	  if (IS_SET (ch->act, PLR_WOLFMAN))
	    max_dam += ch->pcdata->wolf * 2;
	  if (IS_POLYAFF (ch, POLY_WWZULO))
	    max_dam += 500;
	  if (get_disc (ch, DISC_POTENCE) > 0)
	    max_dam += (get_disc (ch, DISC_POTENCE) * 50);
	case CLASS_NECROMANCER:
	case CLASS_WRAITH:
	  if (ch->spheres[MENT] > 0)
	    max_dam += (300 * ch->spheres[MENT]);
	  if (ch->spheres[MENT] >= 7)
	    max_dam += 500;
	  if (get_disc (ch, DISC_POTENCE) > 0)
	    max_dam += (get_disc (ch, DISC_POTENCE) * 50);
	  if (IS_POLYAFF (ch, POLY_WRAITHFORM))
	    max_dam += 1200;
	  if (ch->pcdata->powers[WRA_OUTR] > 0)
	    max_dam += 50 * ch->pcdata->powers[WRA_OUTR];
	  if (!IS_NYM (ch, NYM_DEATHPLANE))
	    {
	      if (ch->pcdata->powers[WRA_EMBO] > 0)
		max_dam += 50 * ch->pcdata->powers[WRA_EMBO];
	    }
	  if (IS_NYM (ch, NYM_DEATHPLANE))
	    {
	      if (ch->pcdata->powers[WRA_PAND] > 0)
		max_dam += 1000 * ch->pcdata->powers[WRA_PAND];
	    }

	  break;

	case CLASS_ELF:
	  if (get_disc (ch, DISC_POTENCE) > 0)
	    max_dam += (get_disc (ch, DISC_POTENCE) * 50);
	  if (ch->pcdata->wisdoms[ELF_MIGHT] > 0)
	    max_dam += 500 * ch->pcdata->wisdoms[ELF_EARTH];
	  if (IS_POLYAFF (ch, POLY_ELFFORM))
	    max_dam += 800;
	  break;

	case CLASS_MAGE:
	  if (get_disc (ch, DISC_POTENCE) > 0)
	    max_dam += (get_disc (ch, DISC_POTENCE) * 50);
	  max_dam += 500;
	  if (ch->spheres[MENT] > 0)
	    max_dam += (300 * ch->spheres[MENT]);
	  break;

	case CLASS_DRAGON:
	  if (get_disc (ch, DISC_POTENCE) > 0)
	    max_dam += (get_disc (ch, DISC_POTENCE) * 50);
	  if (ch->pcdata->cpowers[DRAC_MIGHT] > 0)
	    max_dam += ch->pcdata->cpowers[DRAC_MIGHT] * 400;
	  if (ch->pcdata->cpowers[DRAC_COMBAT] > 0)
	    max_dam += ch->pcdata->cpowers[DRAC_COMBAT] * 200;
	  if (ch->pcdata->cpowers[DRAC_AVATAR] > 0)
	    max_dam += 500;
	  if (IS_DRAGON (ch))
	    max_dam += ch->pcdata->dpowers[DRAGON_AGE] * 150;
	  break;

	case CLASS_DRACONIAN:
	  if (get_disc (ch, DISC_POTENCE) > 0)
	    max_dam += (get_disc (ch, DISC_POTENCE) * 50);
	  if (ch->pcdata->cpowers[DRAC_MIGHT] > 0)
	    max_dam += ch->pcdata->cpowers[DRAC_MIGHT] * 400;
	  if (ch->pcdata->cpowers[DRAC_COMBAT] > 0)
	    max_dam += ch->pcdata->cpowers[DRAC_COMBAT] * 200;
	  if (ch->pcdata->cpowers[DRAC_AVATAR] > 0)
	    max_dam += 500;
	  break;

	}



    }
  if (!IS_NPC (victim) && victim != ch)
    {
      if (get_disc (victim, DISC_FORTITUDE) > 0)
	max_dam -= (get_disc (victim, DISC_FORTITUDE) * 50);

      switch (victim->class)
	{
	default:
	  break;
	case CLASS_ABOMINATION:
	  if (IS_ITEMAFF (ch, ITEMA_SUNSHIELD))
	    max_dam += 800;
	  if (IS_WEREWOLF (ch) && get_auspice (ch, AUSPICE_AHROUN) > 3
	      && IS_VAMPAFF (ch, VAM_CLAWS))
	    max_dam += 200;
	  else
	    {
	      if (IS_ITEMAFF (ch, ITEMA_RIGHT_SILVER))
		max_dam += 100;
	      if (IS_ITEMAFF (ch, ITEMA_LEFT_SILVER))
		max_dam += 100;
	    }
	  if (get_tribe (victim, TRIBE_BONE_GNAWERS) > 4)
	    max_dam -= 250;
	  if (get_auspice (victim, AUSPICE_PHILODOX) > 4)
	    max_dam -= 1000;
	  if (get_auspice (victim, AUSPICE_GALLIARD) > 3)
	    max_dam -= 500;
	  break;
	case CLASS_VAMPIRE:
	case CLASS_LICH:
	case CLASS_KRENSHAR:
	case CLASS_CEVOYIA:
	case CLASS_NECRONOM:
	  if (IS_ITEMAFF (ch, ITEMA_SUNSHIELD))
	    max_dam += 800;
	  break;
	case CLASS_DEMON:
	case CLASS_NEPHANDI:
	case CLASS_EFRETI:
	case CLASS_RAKSHASA:
	case CLASS_SHIDOSHI:
	  if (victim->in_room != NULL
	      && victim->in_room->area->plane == PLANE_HELL)
	    max_dam *= 0.2;
	  break;
	case CLASS_BETRAYER:
	  if (victim->in_room != NULL
	      && victim->in_room->area->plane == PLANE_LIMBO)
	    max_dam *= 0.2;
	  break;
	case CLASS_GAIAINQ:
	  if (victim->in_room != NULL
	      && victim->in_room->area->plane == PLANE_HEAVEN)
	    max_dam *= 0.2;
	  if (IS_WEREWOLF (ch) && get_auspice (ch, AUSPICE_AHROUN) > 3
	      && IS_VAMPAFF (ch, VAM_CLAWS))
	    max_dam += 200;
	  else
	    {
	      if (IS_ITEMAFF (ch, ITEMA_RIGHT_SILVER)
		  && get_auspice (victim, AUSPICE_RAGABASH) < 5)
		max_dam += 250;
	      if (IS_ITEMAFF (ch, ITEMA_LEFT_SILVER)
		  && get_auspice (victim, AUSPICE_RAGABASH) < 5)
		max_dam += 250;
	    }
	  if (get_auspice (victim, AUSPICE_PHILODOX) > 4)
	    max_dam -= 1000;
	  if (get_tribe (victim, TRIBE_BONE_GNAWERS) > 4)
	    max_dam -= 250;
	  if (get_auspice (victim, AUSPICE_GALLIARD) > 3)
	    max_dam -= 500;
	  break;
	case CLASS_BLACK_SPIRAL_DANCER:
	  if (victim->in_room != NULL
	      && victim->in_room->area->plane != PLANE_HELL)
	    max_dam *= 0.2;
	  if (IS_WEREWOLF (ch) && get_auspice (ch, AUSPICE_AHROUN) > 3
	      && IS_VAMPAFF (ch, VAM_CLAWS))
	    max_dam += 200;
	  else
	    {
	      if (IS_ITEMAFF (ch, ITEMA_RIGHT_SILVER)
		  && get_auspice (victim, AUSPICE_RAGABASH) < 5)
		max_dam += 250;
	      if (IS_ITEMAFF (ch, ITEMA_LEFT_SILVER)
		  && get_auspice (victim, AUSPICE_RAGABASH) < 5)
		max_dam += 250;
	    }
	  if (get_auspice (victim, AUSPICE_PHILODOX) > 4)
	    max_dam -= 1000;
	  if (get_tribe (victim, TRIBE_BONE_GNAWERS) > 4)
	    max_dam -= 250;
	  if (get_auspice (victim, AUSPICE_GALLIARD) > 3)
	    max_dam -= 500;
	  break;
	case CLASS_DRAGON:
	  {
	    if (IS_NPC (ch) && IS_SET (victim->dpwrs, DRA_TERROR))
	      max_dam -= 1000;
	  }
	  break;
	case CLASS_ANGELW:
	case CLASS_SAINT:
	case CLASS_PLANARSOHEI:
	  if (victim->in_room != NULL
	      && victim->in_room->area->plane == PLANE_HEAVEN)
	    max_dam *= 0.2;
	  break;
	case CLASS_PARAGON:
	case CLASS_GRIMALKIN:
	case CLASS_REVENANT:
	case CLASS_BALEHOUND:
	case CLASS_NECROMANCER:
	case CLASS_WRAITH:
	  if (!IS_NPC (ch) && !IS_NPC (victim) && IS_WRAITH (victim)
	      && victim->pcdata->powers[WRA_EMBO] >= 4)
	    max_dam -= 500;
	  if (!IS_NPC (ch) && !IS_NPC (victim) && IS_WRAITH (victim)
	      && victim->pcdata->powers[WRA_EMBO] >= 5)
	    max_dam -= 500;
	  break;
	case CLASS_NEWWW:
	  if (IS_NEWWW (ch) && IS_VAMPAFF (ch, VAM_CLAWS))
	    max_dam += 200;
	  if (IS_NEWWW (victim) && get_tribe (ch, QUAL_CELERITY))
	    max_dam -= get_tribe (ch, QUAL_CELERITY) * 250;
	  break;
	case CLASS_WEREWOLF:
	case CLASS_SKINDANCER:
	case CLASS_DEFYLER:
	  if (IS_WEREWOLF (ch) && get_auspice (ch, AUSPICE_AHROUN) > 3
	      && IS_VAMPAFF (ch, VAM_CLAWS))
	    max_dam += 200;
	  else
	    {
	      if (IS_ITEMAFF (ch, ITEMA_RIGHT_SILVER)
		  && get_auspice (victim, AUSPICE_RAGABASH) < 5)
		max_dam += 250;
	      if (IS_ITEMAFF (ch, ITEMA_LEFT_SILVER)
		  && get_auspice (victim, AUSPICE_RAGABASH) < 5)
		max_dam += 250;
	    }
	  if (get_auspice (victim, AUSPICE_PHILODOX) > 4)
	    max_dam -= 1000;
	  if (get_auspice (victim, AUSPICE_GALLIARD) > 3)
	    max_dam -= 500;
	  if (get_tribe (victim, TRIBE_BONE_GNAWERS) > 4)
	    max_dam -= 250;
	  break;
	}
    }
  if (!IS_NPC (ch) && IS_SET (ch->evenmore, EM_MASTERY))
    max_dam += 1000;
  if (victim->stance[0] != STANCE_MONKEY && victim != ch)
    {
      if (ch->stance[0] == STANCE_BULL)
	max_dam += ch->stance[STANCE_BULL];
      else if (ch->stance[0] == STANCE_DRAGON)
	max_dam += ch->stance[STANCE_DRAGON];
      else if (ch->stance[0] == STANCE_TIGER)
	max_dam += ch->stance[STANCE_TIGER];
      else if (!IS_NPC (ch) && IS_STANCE (ch, STANCE_SUPER1))
	{
	  int stance = STANCE_SUPER1;

	  if (IS_SET (ch->pcdata->qstats[0], QS_POW_LESSER))
	    max_dam += ch->stance[stance] * 2;
	  else if (IS_SET (ch->pcdata->qstats[0], QS_POW_GREATER))
	    max_dam += (ch->stance[stance] * 3);
	  else if (IS_SET (ch->pcdata->qstats[0], QS_POW_SUPREME))
	    max_dam += (ch->stance[stance] * 5);
	}
      else if (!IS_NPC (ch) && IS_STANCE (ch, STANCE_SUPER2))
	{
	  int stance = STANCE_SUPER2;

	  if (IS_SET (ch->pcdata->qstats[1], QS_POW_LESSER))
	    max_dam += ch->stance[stance] * 2;
	  else if (IS_SET (ch->pcdata->qstats[1], QS_POW_GREATER))
	    max_dam += (ch->stance[stance] * 3);
	  else if (IS_SET (ch->pcdata->qstats[1], QS_POW_SUPREME))
	    max_dam += (ch->stance[stance] * 5);
	}
      else if (!IS_NPC (ch) && IS_STANCE (ch, STANCE_SUPER3))
	{
	  int stance = STANCE_SUPER3;

	  if (IS_SET (ch->pcdata->qstats[2], QS_POW_LESSER))
	    max_dam += ch->stance[stance] * 2;
	  else if (IS_SET (ch->pcdata->qstats[2], QS_POW_GREATER))
	    max_dam += (ch->stance[stance] * 3);
	  else if (IS_SET (ch->pcdata->qstats[2], QS_POW_SUPREME))
	    max_dam += (ch->stance[stance] * 5);
	}
      else if (!IS_NPC (ch) && IS_STANCE (ch, STANCE_SUPER4))
	{
	  int stance = STANCE_SUPER4;

	  if (IS_SET (ch->pcdata->qstats[3], QS_POW_LESSER))
	    max_dam += ch->stance[stance] * 2;
	  else if (IS_SET (ch->pcdata->qstats[3], QS_POW_GREATER))
	    max_dam += (ch->stance[stance] * 3);
	  else if (IS_SET (ch->pcdata->qstats[3], QS_POW_SUPREME))
	    max_dam += (ch->stance[stance] * 5);
	}
      else if (!IS_NPC (ch) && IS_STANCE (ch, STANCE_SUPER5))
	{
	  int stance = STANCE_SUPER5;

	  if (IS_SET (ch->pcdata->qstats[4], QS_POW_LESSER))
	    max_dam += ch->stance[stance] * 2;
	  else if (IS_SET (ch->pcdata->qstats[4], QS_POW_GREATER))
	    max_dam += (ch->stance[stance] * 3);
	  else if (IS_SET (ch->pcdata->qstats[4], QS_POW_SUPREME))
	    max_dam += (ch->stance[stance] * 5);
	}

    }
  if (ch->stance[0] != STANCE_MONKEY && victim != ch)
    {
      if (victim->stance[0] == STANCE_CRAB)
	max_dam -= victim->stance[STANCE_CRAB];
      else if (victim->stance[0] == STANCE_DRAGON)
	max_dam -= victim->stance[STANCE_DRAGON];
      else if (victim->stance[0] == STANCE_SWALLOW)
	max_dam -= victim->stance[STANCE_SWALLOW];
      else if (!IS_NPC (victim) && IS_STANCE (victim, STANCE_SUPER1))
	{
	  int stance = STANCE_SUPER1;

	  if (IS_SET (victim->pcdata->qstats[0], QS_RES_LESSER))
	    max_dam -= victim->stance[stance];
	  else if (IS_SET (victim->pcdata->qstats[0], QS_RES_GREATER))
	    max_dam -= (victim->stance[stance] * 2);
	  else if (IS_SET (victim->pcdata->qstats[0], QS_RES_SUPREME))
	    max_dam -= (victim->stance[stance] * 3);
	}
      else if (!IS_NPC (victim) && IS_STANCE (victim, STANCE_SUPER2))
	{
	  int stance = STANCE_SUPER2;

	  if (IS_SET (victim->pcdata->qstats[1], QS_RES_LESSER))
	    max_dam -= victim->stance[stance];
	  else if (IS_SET (victim->pcdata->qstats[1], QS_RES_GREATER))
	    max_dam -= (victim->stance[stance] * 2);
	  else if (IS_SET (victim->pcdata->qstats[1], QS_RES_SUPREME))
	    max_dam -= (victim->stance[stance] * 3);
	}
      else if (!IS_NPC (victim) && IS_STANCE (victim, STANCE_SUPER3))
	{
	  int stance = STANCE_SUPER3;

	  if (IS_SET (victim->pcdata->qstats[2], QS_RES_LESSER))
	    max_dam -= victim->stance[stance];
	  else if (IS_SET (victim->pcdata->qstats[2], QS_RES_GREATER))
	    max_dam -= (victim->stance[stance] * 2);
	  else if (IS_SET (victim->pcdata->qstats[2], QS_RES_SUPREME))
	    max_dam -= (victim->stance[stance] * 3);
	}
      else if (!IS_NPC (victim) && IS_STANCE (victim, STANCE_SUPER4))
	{
	  int stance = STANCE_SUPER4;

	  if (IS_SET (victim->pcdata->qstats[3], QS_RES_LESSER))
	    max_dam -= victim->stance[stance];
	  else if (IS_SET (victim->pcdata->qstats[3], QS_RES_GREATER))
	    max_dam -= (victim->stance[stance] * 2);
	  else if (IS_SET (victim->pcdata->qstats[3], QS_RES_SUPREME))
	    max_dam -= (victim->stance[stance] * 3);
	}
      else if (!IS_NPC (victim) && IS_STANCE (victim, STANCE_SUPER5))
	{
	  int stance = STANCE_SUPER5;

	  if (IS_SET (victim->pcdata->qstats[4], QS_RES_LESSER))
	    max_dam -= victim->stance[stance];
	  else if (IS_SET (victim->pcdata->qstats[4], QS_RES_GREATER))
	    max_dam -= (victim->stance[stance] * 2);
	  else if (IS_SET (victim->pcdata->qstats[4], QS_RES_SUPREME))
	    max_dam -= (victim->stance[stance] * 3);
	}
    }

  if (IS_ITEMAFF (ch, ITEMA_ARTIFACT))
    max_dam += 500;
  if (IS_ITEMAFF (victim, ITEMA_ARTIFACT) && victim != ch)
    max_dam -= 500;

  if (!IS_NPC (ch) && IS_COR (ch, COR_HYBRID))
    max_dam += 1000;

  if (!IS_NPC (ch))
    {
      max_dam += (ch->pcdata->rank * 100);
      max_dam += (ch->max_move * 0.01);
      max_dam += (ch->max_mana * 0.01);
      max_dam += (ch->max_hit * 0.01);
    }
  if (!IS_NPC (ch))
    {
      if (ch->lstatus == 1)
	max_dam += 50;
      if (ch->lstatus == 2)
	max_dam += 100;
      if (ch->lstatus == 3)
	max_dam += 150;
      if (ch->lstatus == 4)
	max_dam += 200;
      if (ch->lstatus == 5)
	max_dam += 250;
      if (ch->lstatus == 6)
	max_dam += 300;
      if (ch->lstatus == 7)
	max_dam += 350;
      if (ch->lstatus == 8)
	max_dam += 400;
      if (ch->lstatus == 9)
	max_dam += 500;
    }
  if (!IS_NPC (ch))
    {
      if (IS_EMPEROR (ch))
	max_dam += 800;
      else if (IS_HEIR (ch))
	max_dam += 600;
      else if (IS_DUKE (ch))
	max_dam += 400;
      else if (IS_KNIGHT (ch))
	max_dam += 200;
    }

  if (ch->in_room != NULL && ch->in_room->area->plane != PLANE_HEAVEN
      && ch->in_room->area->plane != PLANE_HELL)
    {
      if (IS_DEMON (ch))
	{
	  if (hellstorm)
	    {
	      max_dam += 1500;
	    }
	}
    }

  max_dam += 100 * (11 - ch->vampgen);
  max_dam += ch->damcapbonus;

  if (!IS_NPC (ch) && !IS_NPC (victim) && victim != ch)
    max_dam = max_dam / 2;

  if (!IS_NPC (ch) && IS_NPC (victim))
    {
      if (doubledam)
	max_dam = max_dam * 2;
      if (halfdam)
	max_dam = max_dam / 2;
    }

  if (max_dam < 1000)
    max_dam = 1000;
  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 )
{
    int max_dam = ch->damcap[DAM_CAP];
    bool agg_dam = FALSE;

    if ( victim == NULL || victim->position == POS_DEAD )
	return;
  
*//*
   * Stop up any residual loopholes.
   */
  /*  if (ch->damcap[DAM_CHANGE] == 1) update_damcap(ch,victim);


     if ( dam > max_dam ) dam = max_dam;// -(number_range(0,499));  testing

     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 );
	}
  
*//*
   * More charm stuff.
   */
/*	if ( victim->master == ch )
	    stop_follower( victim );
*/
	/*
	 * Damage modifiers.
	 */
/*	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_XBITS(ch, X_NINJA_HIDE))
	{
	    if (!can_see(victim,ch)) {dam *= 4;
		send_to_char("You use your concealment to get a surprise attack!\n\r",ch);}
	    REMOVE_BIT( ch->xbits, X_NINJA_HIDE );
	    act( "$n leaps from $s concealment.", ch, NULL, NULL, TO_ROOM );
	}

	if (!IS_NPC(ch) && (IS_DRACWEAP(ch,DRAC_INVIS)))
	{
	    if (!can_see(victim,ch)) {dam *= 4;
		send_to_char("You use your concealment to get a surprise attack!\n\r",ch);}
	    REMOVE_BIT( ch->pcdata->cpowers[DRAC_WEAPONRY], DRAC_INVIS );
	    act( "$n leaps from $s concealment.", ch, NULL, NULL, TO_ROOM );
	}
	if (!IS_IMMORTAL(ch) && !IS_NPC(ch) && IS_VAMPAFF(ch, VAM_OBFUSCATE))
	{
	    send_to_char("You drop out of Obfuscate!\n\r",ch);
	    if (!can_see(victim,ch)) dam *= 1.5;
	    REMOVE_BIT( ch->vampaff, VAM_OBFUSCATE );
	    act( "$n fades into existance.", ch, NULL, NULL, TO_ROOM );
	}

        if ( !IS_NPC(victim) && IS_SET(victim->act, PLR_WOLFMAN))
		dam /= 1.8;

        if (get_tribe(victim, TRIBE_BONE_GNAWERS) > 4) dam /= 1.7;

        if (get_tribe(victim, TRIBE_SILENT_STRIDERS) > 1 ) dam /= 1.7;

	if ( (IS_KAHN(victim) || IS_RAKSHASA (victim)) && IS_POLYAFF(victim, POLY_KAHNFORM) && dam > 1 )
		dam /= 2;

        if (IS_NPC(victim) && victim->pIndexData->vnum == 3011 && dam > 1)
		dam /= 2;
        if (IS_NPC(victim) && (victim->pIndexData->vnum == 45792 || victim->pIndexData->vnum = 138)&& dam > 1)
              { 
            if (ch->max_life > 150000)
                dam /= 2;
           else if (!IS_NPC (ch) && IS_XX (ch, XX_BLOODHUNT))
                dam = 0;
           else if (ch->max_life > 250000)
                dam /= 2.5;
           else
                dam /= 1.2;
              }
	if ( IS_HL(victim) && IS_QUICK(victim, QUICKENING_BODY) && dam > 1 )
		dam /= 1.5;

	if (IS_MONK(victim))
	{
	  float reduct = 1;

           if ( victim->chi[CURRENT] > 0 )
               reduct += victim->chi[CURRENT] / 3;
           if ( victim->monkab[BODY] >= 2 )
               reduct += .5;

	       reduct += .2;

	   dam = dam / reduct;
        }
    	if ( !IS_NPC(ch) && IS_DJINN(victim) && dam > 1 )
    	{
    	   if (IS_SET(victim->pcdata->powers[DJINNPOWERS], DJINN_TOUGHNESS))
 		dam /= 1.8;
    	} 

        if ( !IS_NPC(victim) && get_disc(victim,DISC_FORTITUDE) > 0 && dam > 1)
	    {
		switch(get_disc(victim,DISC_FORTITUDE) )
		{
		    default: dam /= 1;                      	break;
		    case 1:  dam /= 1.35;			break;
		    case 2:  dam /= 1.45;  			break;
		    case 3:  dam /= 1.55;  			break;
		    case 4:  dam /= 1.65;		  	break;
		    case 5:  dam /= 1.75; 			break;
		}

	    }

	if (!IS_NPC(victim) && IS_POLYAFF(victim, POLY_ZULO))
		dam /= 1.7;

   	if (IS_ITEMAFF(victim, ITEMA_RESISTANCE) && dam > 1) 
		dam /= 1.7;

 	if ( !IS_NPC(victim) && IS_DEMON(victim) && dam > 0 && IS_SET(victim->pcdata->disc[C_POWERS], DEM_TOUGH)) 
		dam /= 1.6;
 
	if ( !IS_NPC(victim) && IS_ANGELW(victim) && dam > 0 && IS_POLYAFF(victim, POLY_ANGELFORM))
		dam /= 1.6;

	if ( IS_VAMPIRE(victim) && victim->beast < 1 && dam > 1 )
		dam /= 1.75;

	if ( IS_MAGE(victim) && dam > 1  )
		dam /= 1.7;

        if (IS_POLYAFF(ch, POLY_WWZULO) && dam > 1)
	{
		dam *= 1.2;
		if (dam > ch->damcap[DAM_CAP])
			dam = ch->damcap[DAM_CAP]; 
	}

	if (IS_DEMON(victim) && ch->in_room != NULL && ch->in_room->area->plane == PLANE_HELL)
		dam /= 4;

	if (IS_ANGELW(victim) && ch->in_room != NULL && ch->in_room->area->plane == PLANE_HEAVEN)
		dam /= 4;

	if ( IS_AFFECTED(victim, AFF_SANCTUARY) && dam > 1  )
	    dam /= 2;

	if ( IS_AFFECTED(victim, AFF_PROTECT) && IS_EVIL(ch) && dam > 1  )
	    dam -= dam * 0.25;

	if ( dam < 0 )
	    dam = 0;
  
*//*
   * Check if damage is aggravated.
   */
/*	if ( dt >= TYPE_ADD_AGG )
	{
	    agg_dam = TRUE;
	    dt -= TYPE_ADD_AGG;
	    while ( dt >= TYPE_ADD_AGG ) dt -= TYPE_ADD_AGG;
	}
  
*//*
   * Check for disarm, trip, parry, and dodge.
   */
/*	if ( dt >= TYPE_HIT )
	{

	    if ( IS_NPC(ch) && number_percent( ) < 2 )
  		disarm( ch, victim );
*//*
     if ( IS_NPC(ch) && number_percent( ) < ch->level * 0.5 )
     trip( ch, victim );
    *//*
      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;
      else if ( !IS_NPC(victim) && IS_STANCE(victim, STANCE_SUPER1) )
      {
      int stance = STANCE_SUPER1;

      if (IS_SET(victim->pcdata->qstats[0], QS_SUPER_PARRY))
      {
      if (victim->stance[stance] > 100 && !can_counter(ch)
      && !can_bypass(ch,victim) && check_parry( ch, victim, dt ))
      return;
      }
      }
      else if ( !IS_NPC(victim) && IS_STANCE(victim, STANCE_SUPER2) )
      {
      int stance = STANCE_SUPER2;

      if (IS_SET(victim->pcdata->qstats[1], QS_SUPER_PARRY))
      {
      if (victim->stance[stance] > 100 && !can_counter(ch)
      && !can_bypass(ch,victim) && check_parry( ch, victim, dt ))
      return;
      }
      }
      else if ( !IS_NPC(victim) && IS_STANCE(victim, STANCE_SUPER3) )
      {
      int stance = STANCE_SUPER3;

      if (IS_SET(victim->pcdata->qstats[2], QS_SUPER_PARRY))
      {
      if (victim->stance[stance] > 100 && !can_counter(ch)
      && !can_bypass(ch,victim) && check_parry( ch, victim, dt ))
      return;
      }
      }
      else if ( !IS_NPC(victim) && IS_STANCE(victim, STANCE_SUPER4) )
      {
      int stance = STANCE_SUPER4;

      if (IS_SET(victim->pcdata->qstats[3], QS_SUPER_PARRY))
      {
      if (victim->stance[stance] > 100 && !can_counter(ch)
      && !can_bypass(ch,victim) && check_parry( ch, victim, dt ))
      return;
      }
      }
      else if ( !IS_NPC(victim) && IS_STANCE(victim, STANCE_SUPER5) )
      {
      int stance = STANCE_SUPER5;

      if (IS_SET(victim->pcdata->qstats[4], QS_SUPER_PARRY))
      {
      if (victim->stance[stance] > 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;
      else if ( !IS_NPC(victim) && IS_STANCE(victim, STANCE_SUPER1) )
      {
      int stance = STANCE_SUPER1;

      if (IS_SET(victim->pcdata->qstats[0], QS_SUPER_DODGE))
      {
      if (victim->stance[stance] > 100 && !can_counter(ch)
      && !can_bypass(ch,victim) && check_dodge( ch, victim, dt ))
      return;
      }
      }
      else if ( !IS_NPC(victim) && IS_STANCE(victim, STANCE_SUPER2) )
      {
      int stance = STANCE_SUPER2;

      if (IS_SET(victim->pcdata->qstats[1], QS_SUPER_DODGE))
      {
      if (victim->stance[stance] > 100 && !can_counter(ch)
      && !can_bypass(ch,victim) && check_dodge( ch, victim, dt ))
      return;
      }
      }
      else if ( !IS_NPC(victim) && IS_STANCE(victim, STANCE_SUPER3) )
      {
      int stance = STANCE_SUPER3;

      if (IS_SET(victim->pcdata->qstats[2], QS_SUPER_DODGE))
      {
      if (victim->stance[stance] > 100 && !can_counter(ch)
      && !can_bypass(ch,victim) && check_dodge( ch, victim, dt ))
      return;
      }
      }
      else if ( !IS_NPC(victim) && IS_STANCE(victim, STANCE_SUPER4) )
      {
      int stance = STANCE_SUPER4;

      if (IS_SET(victim->pcdata->qstats[3], QS_SUPER_DODGE))
      {
      if (victim->stance[stance] > 100 && !can_counter(ch)
      && !can_bypass(ch,victim) && check_dodge( ch, victim, dt ))
      return;
      }
      }
      else if ( !IS_NPC(victim) && IS_STANCE(victim, STANCE_SUPER5) )
      {
      int stance = STANCE_SUPER5;

      if (IS_SET(victim->pcdata->qstats[4], QS_SUPER_DODGE))
      {
      if (victim->stance[stance] > 100 && !can_counter(ch)
      && !can_bypass(ch,victim) && check_dodge( ch, victim, dt ))
      return;
      }
      }
      }

      if (IS_POLYAFF(ch, POLY_BAT)) {dt = TYPE_HIT + 10; agg_dam = TRUE;}
      else if (IS_POLYAFF(ch, POLY_SERPENT)) {dt = gsn_tongue; agg_dam = TRUE;}

      dam_message( ch, victim, dam, dt );

      if (victim == NULL || victim->position == POS_DEAD) return;
      }
      hurt_person(ch,victim,dam,agg_dam);
      return;
      }
    */

void
adv_damage (CHAR_DATA * ch, CHAR_DATA * victim, int dam)
{
  if (victim->position == POS_DEAD)
    return;

  if (dam > 1000)
    dam = 1000;

  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);
	  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;
	    }
	}

      if (IS_AFFECTED (victim, AFF_SANCTUARY) && dam > 1
	  && !IS_XXX (ch, XXX_LORDLY))
	dam /= 2;

      if (!IS_NPC (victim) && IS_MAGE (victim) && dam > 1)
	dam /= 1.5;

      if (!IS_NPC (victim) && IS_KAHN (victim)
	  && IS_POLYAFF (victim, POLY_KAHNFORM) && dam > 1)
	dam /= 1.9;

      if (!IS_NPC (victim) && IS_HL (victim)
	  && IS_QUICK (victim, QUICKENING_BODY) && dam > 1)
	dam /= 1.3;

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


      if (IS_AFFECTED (victim, AFF_PROTECT) && IS_EVIL (ch) && dam > 1)
	dam -= (dam * 0.25);

      if (dam < 0)
	dam = 0;
    }
  return;
}

void
npc_retal (CHAR_DATA *ch)
{
  CHAR_DATA *vch;
  CHAR_DATA *vch_next;
  int count = 0;

  if (IS_NPC (ch) || IS_RNPC (ch))
    return;
  if (ch->position == POS_FIGHTING)
    return;
  for (vch = char_list; vch != NULL; vch = vch_next)
    {
      vch_next = vch->next;
      if (vch->in_room == NULL)
        continue;
      if (vch->in_room != ch->in_room)
        continue;
      if (!IS_NPC (vch))
        continue;
      if (count > 2)
	return;      
      if (ch->position == POS_FIGHTING)
        return;

      if (vch->position == POS_FIGHTING && vch->fighting == ch)
        {
	  stop_fighting (vch, TRUE);
	  set_fighting (ch, vch);
	  count++;
        }
    }
  return;
}

void
hurt_person (CHAR_DATA * ch, CHAR_DATA * victim, int dam, bool agg_dam)
{
  bool is_npc = FALSE;
  bool saved = FALSE;
  CHAR_DATA *demon;
  OBJ_DATA *obj;
  /*
   * Hurt the victim.
   * Inform the victim of his new state.
   */


  if (agg_dam && !IS_NPC (victim) && IS_WEREWOLF (victim)
      && get_tribe (victim, TRIBE_SILVER_FANGS) > 4
      && weather_info.sunlight == SUN_DARK)
    agg_dam = FALSE;

  if (IS_NPC (victim) && vic

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

Site Stats

Snippets: 1791
Codebases: 571