fight.c

low4/src/fight.c · 189.5 KB

From the archive low4_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 originally written by KaVir aka Richard Woolcock.         *
 *  Changes done to the code done by Sage aka Walter Howard, this mud is   *
 *  for the public, however if you run this code it means you agree        *
 *  to the license.low, license.gw, and license.merc have fun. :)          *
***************************************************************************/
#if defined(macintosh)
#include <types.h>
#else
#include <sys/types.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "merc.h"

#define MONK_AUTODROP ch->pcdata->autostance

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



/*
 * Control the fights going on.
 * Called periodically by update_handler.
 *
*/
void violence_update( void )
{
    CHAR_DATA *ch;
    CHAR_DATA *ch_next;
    CHAR_DATA *victim;
    CHAR_DATA *rch;
    CHAR_DATA *rch_next;
    CHAR_DATA *mount;
    char buf[MAX_STRING_LENGTH];
        int chance;


      chance = number_percent();

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

  victim = ch->blinkykill;

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

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

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

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


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



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



	if (ch->silence_timer > 0)
		{
		    ch->silence_timer--;
		    if (ch->silence_timer < 1)
		    {
			if (IS_SET(ch->newbits, NEW_SILENCE))
			{
			    act("The room is no longer silent.",ch,NULL,NULL,TO_CHAR);
			    act("The room is no longer silent.",ch,NULL,NULL,TO_ROOM);
			    REMOVE_BIT(ch->in_room->added_flags,ROOM2_SILENCE); 
			    REMOVE_BIT(ch->newbits, NEW_SILENCE);
			    ch->silence_timer = 60;
			}
			else send_to_char("Your ability to call the Silence of Death has returned.\n\r",ch);
		    }
		}
	if (ch->obeah_timer > 0 && !IS_SET(ch->newbits, NEW_NEUTRAL))
		{
		    ch->obeah_timer--;
		    if (ch->obeah_timer < 1)
		    {
			if (IS_WEREWOLF(ch))
			    send_to_char("Your healing powers have returned.\n\r",ch);
			else
			{
			    send_to_char("Your third eye stops glowing.\n\r",ch);
			    act("The eye in $n's forehead stops glowing.",ch,NULL,NULL,TO_ROOM);
			}
		    }
		}
		
		if (ch->reina_timer > 0)
		{
		    ch->reina_timer--;
		    if (ch->reina_timer < 1)
		    {
			if (IS_SET(ch->newbits, NEW_REINA))
			{
			    send_to_char("The peaceful harmony in the air gradually fades away to nothing.\n\r",ch);
			    act("The peaceful harmony in the air gradually fades away to nothing.",ch,NULL,NULL,TO_ROOM);
			    REMOVE_BIT(ch->in_room->room_flags, ROOM_SAFE); 
			    REMOVE_BIT(ch->newbits, NEW_REINA);
			    ch->reina_timer = 60;
			}
	else if (IS_WEREWOLF(ch))
{
	stc("You may once again use madness.\n\r", ch);
REMOVE_BIT(ch->affected_by, AFF_STEELSHIELD);
}
			else send_to_char("You have recovered your voice.\n\r",ch);
		REMOVE_BIT(ch->affected_by, AFF_STEELSHIELD);		   
 }
		}
if (ch->cobra_timer > 0) {
	ch->cobra_timer--;
                        if (ch->cobra_timer < 1) {
if (IS_WEREWOLF(ch))
        {       
 stc("You may once again use eyes of the cobra\n\r",ch);
}
else
stc("EMPTY PLACE FOR A NEW MESSAGE..:)\n\r",ch);
} 
}
    if (ch->majesty_timer > 0) {
			ch->majesty_timer--;
			if (ch->majesty_timer < 1) {
	if (IS_WEREWOLF(ch))
	{
	stc("You may now use your icy chill of despair\n\r",ch);
}
else			
				send_to_char("Your may once again use majesty.\n\r",ch);
			}
		}
 if (ch->darkness_timer > 0)
                ch->darkness_timer--;
 if (ch->arena_timer > 0)
                ch->arena_timer--;
 if (ch->arena_timer < 1)
                    {
 if ( IS_SET(ch->flag2, AFF2_INARENA) || IS_SET(ch->flag2,
AFF2_CHALLENGED) || IS_SET(ch->flag2, AFF2_CHALLENGER))
{
	 REMOVE_BIT(ch->flag2, AFF2_CHALLENGED);
  REMOVE_BIT(ch->flag2, AFF2_CHALLENGER);
  REMOVE_BIT(ch->flag2, AFF2_INARENA   );
  undo_arena(ch); 
 arena = FIGHT_CLEAR;
	sprintf(buf,"The arena is no longer busy!");
	do_info(ch,buf);
	stc("You waited to long, arena status cleared!\n\r", ch);
}
}

if (ch->wyld_timer > 0)
                ch->wyld_timer--;

	if (ch->fight_timer > 0)
		ch->fight_timer--;
if (ch->hit < 1)
update_pos( ch );

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

        if ( IS_SET(ch->monkstuff, MONK_HEAL) )
        {
	  if ( ch->hit < (ch->max_hit /2 ) )
	  {
	    if ( ch->hit < ch->max_hit )
	      ch->hit +=  number_range( 200,400 );
	    if ( ch->move < ch->max_move )
	      ch->move += number_range( 175,400 );
	      stc("Your body emits glowing sparks.\n\r",ch);
	      act("$n's body emits glowing sparks and fizzes.",ch,NULL,NULL,TO_ROOM);
	  }               
	  else
	  {
	      if ( number_range( 1,2 ) == 1 )
	      {
	         stc("The sparks fizzle and die.\n\r",ch);
	         act("The sparks around $n's body fizzle and die.",ch,NULL,NULL,TO_ROOM);
		 REMOVE_BIT(ch->monkstuff, MONK_HEAL);
              }
	      else
	      {
	       if ( ch->hit < ch->max_hit )
		 ch->hit +=  number_range( 200,400 );
               if ( ch->move < ch->max_move )
                 ch->move += number_range( 175,400 );
                 stc("Your body emits glowing sparks.\n\r",ch);
                 act("$n's body emits glowing sparks and fizzes.",ch,NULL,NULL,TO_ROOM);
	      }
	   }
	}


	if (IS_CLASS(ch, CLASS_MONK)
	  && ch->level < 7 && IS_SET(ch->act, PLR_WIZINVIS) )
	REMOVE_BIT(ch->act, PLR_WIZINVIS);

	if ( IS_SET(ch->newbits, NEW_POWER) )
 	{
	   if ( ch->move < 75 )
	     do_spiritpower(ch,"");
	   else
	     ch->move -= 15;
        }


      if ( ch->chi[CURRENT] > 0 )
      {
        if ( IS_CLASS(ch, CLASS_MONK) && ch->move > ( 500 - ch->chi[CURRENT] * 20 ))
            ch->move -= ch->chi[CURRENT] * 20;
        else
	{
	  if ( ch->chi[CURRENT] > 0 )
          {
	    stc("You feel exhausted, and lose control of your ch'i.\n\r",ch);
	    ch->chi[CURRENT] -= 1;
	  }
	}
      }

	if ( ( victim = ch->fighting ) == NULL || ch->in_room == NULL )
	    continue;
	        if (!IS_NPC(ch) && !IS_NPC(victim) && !is_safe(ch, victim)
		  && !is_safe(victim,ch))
                ch->fight_timer = 10;

	if ( IS_AWAKE(ch) && IS_AWAKE(victim) && 
		ch->in_room == victim->in_room )
{
	    multi_hit( ch, victim, TYPE_UNDEFINED );
}
	/*
	if (IS_CLASS(ch, CLASS_DROW) && POLY_SPIDERFORM
	&& IS_SET(ch->pcdata->powers[1], DPOWER_ARMS))
	    multi_hit(ch, victim, gsn_spiderform);
	} 
*/
	else
	    stop_fighting( ch, FALSE );

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

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

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

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

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

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

    return;
}

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

    if ( ch->position < POS_SLEEPING ) return;


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

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

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

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

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

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

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

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

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

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

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

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

    if (!IS_NPC(victim) && IS_AFFECTED(victim, AFF_STEELSHIELD) )
    {
	send_to_char( "They are protected by a powerful being.\n\r", ch );
	return;
    }

    wield1 = get_eq_char( ch, WEAR_WIELD );
    wield2 = get_eq_char( ch, WEAR_HOLD );
    if ( wield1 != NULL && wield1->item_type == ITEM_WEAPON ) wieldorig  = 1;
    if ( wield2 != NULL && wield2->item_type == ITEM_WEAPON ) wieldorig += 2;
    wieldtype = wieldorig;

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

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

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

    if (!IS_NPC(ch) && ch->stance[0] > 0 && number_percent() == 1)
    {
	int stance = ch->stance[0];
	if (ch->stance[stance] >= 200)
	{
	    special_move(ch,victim);
	    return;
	}
    }

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

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

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


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

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

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

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

	if ((obj = get_eq_char(victim,WEAR_SCABBARD_R)) != NULL)
	{
	    wpntype = obj->value[3];
	    if (wpntype < 0 || wpntype > 12) wpntype = 0;
	    if ((obj = get_eq_char(victim,WEAR_WIELD)) != NULL)
	    {
		obj_from_char(obj);
		obj_to_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");
	}
	if (wpntype  > 0) one_hit( victim, ch, TYPE_UNDEFINED, 1 );
	if ( victim == NULL || victim->position != POS_FIGHTING ) return;
	if (wpntype2 > 0) one_hit( victim, ch, TYPE_UNDEFINED, 2 );
	if ( victim == NULL || victim->position != POS_FIGHTING ) return;
    }

    maxcount = number_attacks(ch,victim);
    if (!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 == 3) maxcount += 1;
    for (countup = 0; countup <= maxcount; countup++)
    {
	wieldtype = wieldorig;
	if ( wieldorig == 3 )
	{
	    if (number_range(1,2) == 2) wieldtype = 2;
	    else wieldtype = 1;
	}
	one_hit( ch, victim, -1, wieldtype );
	if ( victim == NULL || victim->position != POS_FIGHTING ) return;
	if ( ch->fighting != victim ) return;
    }

    if (!IS_NPC(ch) && IS_VAMPAFF(ch,VAM_FANGS))
	one_hit( ch, victim, ( TYPE_HIT + 10 + TYPE_ADD_AGG), 0 );
    if ( victim == NULL || victim->position != POS_FIGHTING ) return;
    if (!IS_NPC(ch))
    {

if ( IS_CLASS(ch, CLASS_WEREWOLF) && IS_GAR1(ch, WOLF_VISCERAL ) ) 
{
if ( !IS_SET(victim->newbits, NEW_VISCERAL) )
    {
SET_BIT(victim->newbits, NEW_VISCERAL);
  act("The venom on your claws mingles with $N's blood",ch, NULL, victim, TO_CHAR);
  act("Something black on $n's claws mingles with your blood.",ch,NULL,victim,TO_VICT);
  act("Something black on $n's mingles with $N's blood.",ch,NULL,victim,TO_NOTVICT);
}

}
if ((IS_CLASS(ch, CLASS_WEREWOLF) && ch->gifts[BLACKFURIES] > 2)
 && number_range(1,3) == 1)
        one_hit( ch, victim, gsn_waspt, 0);
if ( IS_CLASS(ch, CLASS_DEMON) && IS_SET(ch->warp, WARP_SPIKETAIL)
        && number_range(1,3) == 1)
        one_hit( ch, victim, gsn_spiket, 0);
  if ( IS_CLASS(ch, CLASS_DEMON) && IS_SET(ch->warp, WARP_SHARDS)
        && number_range(1,3) == 1)
        one_hit( ch, victim, gsn_shards, 0);
  if ( IS_CLASS(ch, CLASS_DEMON) && IS_SET(ch->warp, WARP_MAGMA)
        && number_range(1,3) == 1)
        one_hit( ch, victim, gsn_magma, 0);
  if ( IS_CLASS(ch, CLASS_DEMON) && IS_SET(ch->warp, WARP_VENOMTONG)
	&& number_range(1,3) == 1)
	one_hit( ch, victim, gsn_venomt, 0);
	if (IS_CLASS(ch, CLASS_DEMON)  && IS_DEMAFF(ch,DEM_HORNS) 
		&& number_range(1,3) == 1)
	   {one_hit( ch, victim, gsn_headbutt, 0 );dt += TYPE_ADD_AGG;}

if (IS_CLASS(ch, CLASS_NINJA) && ch->pcdata->powers[NPOWER_NINGENNO] > 0
&& number_range(1,2 ) == 1) one_hit(ch, victim, gsn_claws, 0);
	if ( IS_CLASS(ch, CLASS_NINJA) && ch->pcdata->powers[NPOWER_NINGENNO] > 3
        && number_range(1,3) == 1) one_hit( ch, victim, gsn_shiroken +TYPE_ADD_AGG,0 );
	if (IS_CLASS(ch, CLASS_DEMON)  && IS_DEMAFF(ch,DEM_TAIL)
                && number_range(1,3) == 1)   one_hit( ch, victim, gsn_tail , 0);
	if (IS_SET(ch->newbits, NEW_QUILLS) )
	  one_hit( ch, victim, gsn_quills, 0 );

 if ( IS_DROW(ch) && IS_SET(ch->pcdata->powers[1], DPOWER_ARMS) )
  {
     int ii;
     if( IS_POLYAFF(ch, POLY_SPIDERFORM) )
     {
     for( ii = 0; ii < 8; ii++ )
     {
          if( number_range(1,4) == 1 )
        {
           if( number_range(1,3) == 1 )
            one_hit( ch, victim, gsn_spiderform + TYPE_ADD_AGG, 0 );
        else one_hit(ch, victim, gsn_spiderform, 0);

        }
         }
     }
     else
     {
     for( ii = 0; ii < 4; ii++ )
 {
        if( number_range(1,3) == 1 )
        {
           if( number_range(1,2) == 1 )
            one_hit( ch, victim, gsn_spiderform + TYPE_ADD_AGG, 0 );
           else
            one_hit( ch, victim, gsn_spiderform, 0 );
        }
     }
}
}
  if ( IS_CLASS(ch, CLASS_DEMON) && IS_SET(ch->warp, WARP_WINGS)
	 && number_range(1,3) == 1)      one_hit( ch, victim, gsn_buffet, 0 );  
        if (IS_CLASS(ch, CLASS_VAMPIRE) && IS_VAMPAFF(ch, VAM_WINGS)
	&& number_range(1,3) == 1)	one_hit( ch, victim, gsn_buffet, 0 );
	if (IS_CLASS(ch, CLASS_VAMPIRE) && IS_VAMPAFF(ch, VAM_HORNS)
	&& number_range(1,3) == 1)	one_hit( ch, victim, gsn_headbutt, 0 );
	if (IS_CLASS(ch, CLASS_VAMPIRE)  && IS_VAMPAFF(ch, VAM_TAIL)
                && number_range(1,3) == 1)   one_hit( ch, victim, gsn_tail, 0 );
    }
    if ( victim == NULL || victim->position != POS_FIGHTING ) return;

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

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

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

/*
 * TIJMOD: 29/12/99
 * Legend status now gives extra attacks per level 
 */

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

    if ( IS_NPC(ch) )
    {
	if (ch->level >= 50)  count++;
	if (ch->level >= 100) count += ( ch->level / 50 );
	return count;
    }

    if ( IS_STANCE(ch, STANCE_VIPER) && number_percent() > 
	ch->stance[STANCE_VIPER] * 0.5) count += 1;
    else if ( IS_STANCE(ch, STANCE_MANTIS) && number_percent() > 
	ch->stance[STANCE_MANTIS] * 0.5) count += 1;
	else if ( IS_STANCE(ch, STANCE_RABBIT) && number_percent() > 
	ch->stance[STANCE_RABBIT] * 0.5) count += 2;
    else if ( IS_STANCE(ch, STANCE_TIGER) && number_percent() > 
	ch->stance[STANCE_TIGER] * 0.5) count += 2;
	  else if ( IS_STANCE(ch, STANCE_BEAR) && number_percent() > 
	ch->stance[STANCE_BEAR] * 0.7) count += 3;

    if (!IS_NPC(ch))
    {
    	if ( IS_CLASS(ch, CLASS_VAMPIRE) && IS_VAMPAFF(ch, VAM_CELERITY) )
		count += 1;
	else if ( IS_CLASS(ch, CLASS_MONK) && ch->monkab[COMBAT] > 0 )
		count += ch->monkab[COMBAT];
   	else if ( !IS_NPC(ch) && IS_CLASS(ch, CLASS_DEMON) && IS_DEMPOWER(ch, DEM_SPEED) )
		count += 1;
else if ( IS_CLASS(ch, CLASS_DEMON) && !IS_SET(ch->warp, WARP_QUICKNESS) ) 
	count += 1;
	else if (IS_CLASS(ch, CLASS_DROW) && (IS_SET(ch->special, SPC_DROW_WAR)
	         || ch->pcdata->stats[UNI_GEN] < 3))
		count += 3;
	else if (IS_CLASS(ch, CLASS_DROW) && !IS_SET(ch->special, SPC_DROW_WAR) )
     		count += 2;
	else if (is_garou(ch) && ch->gifts[SILENTSTRIDERS] > 0 )
        {
          count++;
	  if ( ch->gifts[SILENTSTRIDERS] > 1 )
	  count++;
	  if ( ch->gifts[SILENTSTRIDERS] > 1 )
	  count++;
	}
    }
	if (!IS_NPC(ch) && IS_CLASS(ch, CLASS_DROW) && 
	IS_SET(ch->pcdata->powers[1],DPOWER_SPEED))
	count += 1;


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


    if ( !IS_NPC(ch) && !IS_NPC(victim) && ch->lstatus > victim->lstatus )
      count += ( ch->lstatus - victim->lstatus );
	if(IS_CLASS(ch,CLASS_DROW))count /= 4;
    return count;
}


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

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

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

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

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


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

    /*
     * Figure out the type of damage message.
     */
    if (handtype == 2)
    {
    	wield = get_eq_char( ch, WEAR_HOLD );
	right_hand = FALSE;
    }
    else if (handtype == 4 )
    {
        wield = get_eq_char( ch, WEAR_THIRD );
	right_hand = FALSE;
    }
    else if ( handtype == 8 )
    {
        wield = get_eq_char( ch, WEAR_FOURTH );
        right_hand = FALSE;
    }
    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 (IS_CLASS(victim, CLASS_WEREWOLF))
            {
                if ((right_hand && IS_ITEMAFF(ch, ITEMA_RIGHT_SILVER)) ||   
                    (!right_hand && IS_ITEMAFF(ch, ITEMA_LEFT_SILVER)) )
                    dt += TYPE_ADD_AGG;
            }
    }

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

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

    /*
     * 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 );
	tail_chain( );
	if (!is_safe(ch,victim))
	{
	    improve_wpn(ch,dt,right_hand);
    	    improve_stance(ch);
	}
	return;
    }

    /*
     * Hit.
     * Calc damage.
     */

    if ( IS_NPC(ch) )
    {
	dam = number_range( ch->level, ch->level * 3 / 2 );
	if ( wield != NULL )
	    dam += dam * 0.5;
    }
    else
    {
	if ( IS_VAMPAFF(ch,VAM_CLAWS) && wield == NULL)
	    {dam = number_range( 10, 20 );dt += TYPE_ADD_AGG;}

        else if ( IS_SET(ch->newbits, NEW_MONKADAM))
           {dam = dice( 10, 25 );dt += TYPE_ADD_AGG;}
	else if ( wield != NULL && wield->item_type == ITEM_WEAPON )
	    dam = number_range( wield->value[1], wield->value[2] );
	else
	    dam = number_range( 1, 4 );
    }

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

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

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

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

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


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

        if(dt == gsn_spiderform)dam /= 2.25;
        if(dt == gsn_blinky)dam /= 2.25;
    damage( ch, victim, dam, dt );
    tail_chain( );
    if (!is_safe(ch,victim))
    {
	improve_wpn(ch,dt,right_hand);
	improve_stance(ch);
    }
    return;
}

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

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

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

        if ( IS_CLASS(ch, CLASS_VAMPIRE) )
	{
	    if ( ch->pcdata->powers[VAM_POTE] > 0 )
                mult += ( ch->pcdata->powers[VAM_POTE] / 3 );

	    /* Vampire Day\Night Bonus Shit */
	    if ( weather_info.sunlight == SUN_LIGHT && dam > 1 )
                mult -= .5;
            else
	        mult += .5;
        }
 	if ( IS_CLASS(ch, CLASS_WEREWOLF) )
	{
	    if ( ch->gifts[PHILODOX] >= 4 )
              mult += .7;
            if ( ch->gifts[SHADOWLORDS] >= 1 )
 	      mult += .9;
	    if ( ch->gifts[GETOFFENRIS] >= 3 )
	      mult += 3;
	    if ( ch->gifts[STARGAZERS] >= 1 )
              mult += .4;
            if ( ch->gifts[AHROUN] >= 1 )
	      mult += .5;
	    if ( ch->gifts[AHROUN] >= 2 )
	      mult += .3;
	    if ( ch->gifts[BLACKFURIES] >= 3 )
	      mult += .3;
	}
	if ( IS_CLASS(ch, CLASS_MAGE) )
	{
	    if ( IS_SET(ch->mflags, MAGE_TELEKINETICS) )
	      mult += .4;
	    if ( IS_SET(ch->mflags, MFLAGS_DIMMAK) )
	      mult += .3;
	    if ( ch->spheres[MENT] >= 1 )
	      mult += ( ch->spheres[MENT] *.2 );
	}
	if ( IS_CLASS(ch, CLASS_MONK) )
	{
	    if ( ch->chi[CURRENT] > 0 )
	      mult += ( ch->chi[CURRENT] / 2 );
	}
	if ( IS_CLASS(ch, CLASS_DROW) )
        {
	    mult += .7;
	}


    if ( !IS_NPC(ch) && IS_CLASS(ch, CLASS_VAMPIRE))
{ 
      mult  += (ch->pcdata->powers[VAM_POTE] / 5);  
}
	if ( IS_CLASS(ch, CLASS_DEMON) )
	{
	    if ( IS_DEMPOWER(ch, DEM_MIGHT) )
	        mult += 1.9;
        }
if ( IS_CLASS(ch, CLASS_MONK))
{
mult += .1;
}
if (IS_CLASS(ch, CLASS_WEREWOLF) &&  IS_GAR1(ch, WOLF_RAZORCLAWS ) )
{
mult += 1; 
}
       if (IS_CLASS(ch, CLASS_WEREWOLF))
	{
	if (ch->gifts[FIANNA] > 2)
	mult += 2;
}
      
        if ( IS_CLASS(ch, CLASS_DEMON) &&  IS_SET(ch->warp, WARP_WEAK))
        {
          mult   -= .5;
        }

if ( IS_CLASS(ch, CLASS_DEMON) &&  IS_SET(ch->warp, WARP_GBODY))
        {
          mult   -= .5;
        }

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

   if ( !IS_NPC( victim ) )
    {
	if ( IS_ITEMAFF(victim, ITEMA_RESISTANCE) )
	    reduct += 1;

	if ( IS_CLASS(victim, CLASS_HIGHLANDER) )
	{
	    reduct += 2;
	}
if (IS_CLASS(victim, CLASS_MONK))
{
reduct += .2;
}

if (IS_CLASS(victim, CLASS_MAGE))
{
reduct += 2;
}
	if ( IS_CLASS(victim, CLASS_VAMPIRE) )
	{
	    if ( victim->pcdata->powers[VAM_FORT] > 0 )
	        reduct += ( victim->pcdata->powers[VAM_FORT] - 1.5 );
	}
	if ( IS_CLASS(victim, CLASS_WEREWOLF) )
	{
	    if ( IS_GAR1(victim, WOLF_COCOON) )
	      reduct += .5;
	    if ( victim->gifts[PHILODOX] >= 1 )
	      reduct += .2;
	    if ( victim->gifts[PHILODOX] >= 3 )
	      reduct += .3;
	    if ( victim->gifts[SHADOWLORDS] >= 2 )
	      reduct += .3;
	    if ( victim->gifts[SHADOWLORDS] >= 4 )
	      reduct += .4;
	}
	if ( IS_CLASS(victim, CLASS_MAGE) )
	{
	    if ( victim->spheres[MENT] >= 1 )
	      reduct += 1.5;
        }
	if ( IS_CLASS(victim, CLASS_DEMON) )
	{
	    if ( IS_DEMPOWER(victim, DEM_TOUGH) )
	      reduct += 1.4;
	}

if ( IS_CLASS(ch, CLASS_DEMON) &&  IS_SET(ch->warp, WARP_STAMINA))
{
        reduct +=  1;
        }

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

      if ( IS_CLASS(victim, CLASS_DEMON) && IS_SET(victim->warp, WARP_SBODY))
{
        reduct +=  1;
        }

       if ( IS_CLASS(victim, CLASS_DEMON) && IS_SET(victim->warp, WARP_CBODY))  
{
	reduct +=  1.5;
	}

        if ( IS_CLASS(victim, CLASS_MONK) )
        {
	   if ( victim->chi[CURRENT] > 0 )
	       reduct += victim->chi[CURRENT];
	   if ( victim->monkab[BODY] >= 2 )
	       reduct += .5;
        }
	if ( IS_CLASS(victim, CLASS_DROW) )
	{
	    reduct += 1.3;
	}
	if ( IS_CLASS(victim, CLASS_NINJA) )
	{
	    reduct += 1.4;
	}
    }

    if ( !IS_NPC(ch) && dt >= TYPE_HIT )
    {
        wpn = ( dt - 1000 );
        dam = dam + ( dam * ((ch->wpn[wpn]+1) / 100 ) );
    }

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


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


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

    dam *= mult;
    dam /= reduct;
    
    return dam;
}    


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

bool can_bypass( CHAR_DATA *ch, CHAR_DATA *victim )
{
    if (IS_NPC(ch) || IS_NPC(victim)) return FALSE;
    else if (IS_STANCE(ch, STANCE_VIPER)) return TRUE;
    else if (IS_STANCE(ch, STANCE_MANTIS)) return TRUE;
     else if (IS_STANCE(ch, STANCE_RABBIT)) return TRUE;
    else if (IS_STANCE(ch, STANCE_TIGER)) return TRUE;
    else if (IS_STANCE(ch, STANCE_BEAR)) return TRUE;
    else if (IS_STANCE(ch, STANCE_COBRA)) return TRUE;
    return FALSE;
}

void update_damcap( CHAR_DATA *ch, CHAR_DATA *victim )
{
    int max_dam = 1000;
    
    if ( !IS_NPC(ch) )
    {
        if ( IS_CLASS(ch, CLASS_DROW) )
	{
	    max_dam += 1000;
	    if ( weather_info.sunlight == SUN_DARK )
	        max_dam += 500;
	    if ( IS_SET(ch->newbits, NEW_DROWHATE) )
	        max_dam += 750;
	}
if ( IS_SET(victim->garou1, GAROU_PAWS) )
{
max_dam =- 500;
}

	if ( IS_CLASS(ch, CLASS_DEMON) )
	{
	    if ( ch->in_room != NULL )
	        if ( ch->in_room->vnum == 30000 ) max_dam = 10000;
	    max_dam += ( ch->pcdata->stats[DEMON_POWER] * 20 );
	    max_dam += 1000;
	}
	if (IS_SET(ch->warp, WARP_DAMCAP))
	max_dam += 800;
	if ( IS_CLASS(ch, CLASS_VAMPIRE) )
	{
	         if ( ch->pcdata->stats[UNI_GEN] < 2 ) max_dam = 1500;
	    else if ( ch->pcdata->stats[UNI_GEN] < 3 ) max_dam = 1400;	    
	    else if ( ch->pcdata->stats[UNI_GEN] < 4 ) max_dam = 1300;
	    else if ( ch->pcdata->stats[UNI_GEN] < 5 ) max_dam = 1200;
	    else				       max_dam = 1100;
	    max_dam += ( ch->pcdata->stats[UNI_RAGE] );
	    if ( ch->pcdata->powers[VAM_POTE] > 0 )
	      max_dam += ( 100 * ch->pcdata->powers[VAM_POTE] );
	    if ( ch->pcdata->rank == AGE_METHUSELAH ) max_dam += 300;
	    else if ( ch->pcdata->rank == AGE_ELDER ) max_dam += 200;
	    else if ( ch->pcdata->rank == AGE_ANCILLA ) max_dam += 100;
	}
	if ( IS_CLASS(ch, CLASS_MONK) )
	{
	    max_dam += 300;
	    if ( ch->monkab[COMBAT] > 0 )
	      max_dam += ( ch->monkab[COMBAT] * 100 );
	    if ( ch->chi[CURRENT] > 0 )
	      max_dam += ( ch->chi[CURRENT] * 200 );
	}
	if ( IS_CLASS(ch, CLASS_NINJA) )
	{
	         if ( ch->pcdata->stats[UNI_GEN] < 3 ) max_dam = 1500;
	    else if ( ch->pcdata->stats[UNI_GEN] < 4 ) max_dam = 1400;
	    else if ( ch->pcdata->stats[UNI_GEN] < 5 ) max_dam = 1300;
	    else				       max_dam = 1200;
	    max_dam += (ch->pcdata->stats[UNI_RAGE] * 5);
	    if ( ch->pcdata->powers[NPOWER_CHIKYU] >= 6 && ch->pcdata->powers[HARA_KIRI] > 0 )
	        max_dam += 600;
	    if ( ch->pcdata->powers[NPOWER_CHIKYU] >= 2 )
	        max_dam += 500;
	}
	if ( IS_CLASS(ch, CLASS_MAGE) )
	{
	    max_dam = 1500;
	    if ( ch->spheres[MENT] > 0 )
	      max_dam += ( 200 * ch->spheres[MENT] );
	}
	if ( IS_CLASS(ch, CLASS_WEREWOLF) )
	{
	         if ( ch->pcdata->stats[UNI_GEN] < 2 ) max_dam = 2000;
	    else if ( ch->pcdata->stats[UNI_GEN] < 3 ) max_dam = 1900;
	    else if ( ch->pcdata->stats[UNI_GEN] < 4 ) max_dam = 1800;
	    else				       max_dam = 1700;
	    if ( IS_SET(ch->special, SPC_WOLFMAN) )
		max_dam += ( ch->pcdata->stats[UNI_RAGE] );
	    if ( ch->gifts[PHILODOX] >= 3 )
	        max_dam += 200;
	    if ( ch->gifts[SILVERFANGS] > 0 )
	        max_dam += 150;
	    if ( ch->gifts[GETOFFENRIS] >= 3 )
	        max_dam += 300;
if (IS_ITEMAFF(ch, ITEMA_SUNSHIELD)) max_dam += 500;
	}
	if ( IS_CLASS(ch, CLASS_HIGHLANDER) )
        {
	    if ( get_eq_char(ch, WEAR_WIELD) != NULL )
	    {
	        max_dam += (ch->wpn[1] / 2);
	        max_dam += (ch->race * 10);
	    }
	}
	if ( IS_ITEMAFF(ch, ITEMA_ARTIFACT)) max_dam += 500;
	if ( IS_ITEMAFF(victim, ITEMA_ARTIFACT)) max_dam -= 500;
    }
    else max_dam += ( ch->level * 100 );  // for NPCs


/* Legend Status Bonuses
 * BUGFIX: 29/12/99
 * Damcap fixed by Tijer original code wasnt giving dmcap bonusses
 * At all for legend
 */
      if (!IS_NPC(ch))
      {
         if ( ch->lstatus == 1 )
       max_dam += 50;
         if ( ch->lstatus == 2 )
       max_dam += 100;
         if ( ch->lstatus == 3 )
       max_dam += 200;
         if ( ch->lstatus == 4 )
       max_dam += 300;
         if ( ch->lstatus == 5 )
       max_dam += 400;
         if ( ch->lstatus == 6 )
       max_dam += 500;
         if ( ch->lstatus == 7)
       max_dam += 1000;
         if ( ch->lstatus == 8)
       max_dam += 1500;
         if ( ch->lstatus == 9) 
       max_dam += 2000;
       }

    if ( max_dam < 1000 ) max_dam = 1000;
    if ( max_dam > 6000 ) max_dam = 6000;
    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->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;

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

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

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

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

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

	/*
	 * Damage modifiers.
	 */
	// First Round Check
	if(IS_SET(ch->extra,FROUND))
	{if(IS_CLASS(ch,CLASS_WEREWOLF) && ch->gifts[BLACKFURIES] >= 1)
	 {stc("You devise the best place to strike your opponent.\n\r",ch);
	  dam *= 2;}
         
	REMOVE_BIT(ch->extra,FROUND);
	}
	if ( IS_AFFECTED(ch, AFF_HIDE) )
	{
	    if (!can_see(victim,ch)) {dam *= 1.5;
		send_to_char("You use your concealment to get a surprise attack!\n\r",ch);}
	    REMOVE_BIT( ch->affected_by, AFF_HIDE );
	    act( "$n leaps from $s concealment.", ch, NULL, NULL, TO_ROOM );
	}

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

	if ( IS_AFFECTED(victim, AFF_SANCTUARY) && dam > 1  )
	    dam *= 0.5;

	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( ) < ch->level * 0.5 )
		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_NPC(victim) && 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_NPC(victim) && 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_RABBIT) && 
		victim->stance[STANCE_RABBIT] > 100 && !can_counter(ch)
		&& !can_bypass(ch,victim) && check_parry( ch, victim, dt ))
		return;
	    if ( check_dodge( ch, victim, dt ) )
		return;
	    if ( !IS_NPC(victim) && 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_NPC(victim) && 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_EAGLE) && 
		victim->stance[STANCE_EAGLE] > 100 && !can_counter(ch)
		&& !can_bypass(ch,victim) && check_dodge( ch, victim, dt ))
		return;
	}

	if(dt == 10 && ch->gifts[GETOFFENRIS] >= 5)
	  dam *= 1.25;
	dam_message( ch, victim, dam, dt );
    }
    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 > 1500 ) dam = 1500;

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

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

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

	if ( IS_AFFECTED(victim, AFF_PROTECT) && IS_EVIL(ch) && dam > 1  )
	    dam -= dam / 4;
	if (!IS_NPC(victim) && !IS_NPC(ch)) dam = dam *2/3;

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

void hurt_person( CHAR_DATA *ch, CHAR_DATA *victim, int dam, bool agg_dam )
{
    
    int vnum;

    /*
     * Hurt the victim.
     * Inform the victim of his new state.
     */
    victim->hit -= dam;

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


if (agg_dam && victim->agg < 100) victim->agg++;

    if (agg_dam)
    {
	if (victim->position == POS_MORTAL) victim->agg = 100;
	if (victim->agg < 100) victim->agg++;
	if (!IS_NPC(victim)) SET_BIT(victim->act, PLR_LAST_AGG);
    }

    else if (!IS_NPC(victim)) REMOVE_BIT(victim->act, PLR_LAST_AGG);

//MAYBE NOT LINE BELOW??
// victim->hit -= dam;

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


    switch( victim->position )
    {
    case POS_MORTAL:
	act( "$n is mortally wounded, and spraying blood everywhere.\n\r",victim, NULL, NULL, TO_ROOM );
	send_to_char( 
	    "You are mortally wounded, and spraying blood everywhere.\n\r",victim );
	if ( IS_CLASS(victim, CLASS_DROW) && IS_SET(victim->in_room->room_flags, ROOM_TOTAL_DARKNESS) )
	REMOVE_BIT(victim->in_room->room_flags, ROOM_TOTAL_DARKNESS);

	break;

    case POS_INCAP:
	act( "$n is incapacitated, and bleeding badly.", victim, NULL, NULL, TO_ROOM );
	send_to_char(
	    "You are incapacitated, and bleeding badly.\n\r", victim );
	break;

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

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

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

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

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

	if ( !IS_NPC(victim) )
	{
	    sprintf( log_buf, "%s killed by %s at %d",
		victim->name,
		(IS_NPC(ch) ? ch->short_descr : ch->name),
		victim->in_room->vnum );
	    log_string( log_buf );

	    /*
	     * Dying penalty:
	     * 1/2 your current exp.
	     */
	    if ( victim->exp > 0 )
		victim->exp = victim->exp / 2;
	}

    	if (IS_NPC(victim) && !IS_NPC(ch))
	{
	    ch->mkill += 1;
	if ( ch->level >= 3 )
	{
	if (IS_CLASS(ch, CLASS_DROW) && IS_NPC(victim) && !IS_SET(victim->act, ACT_NOEXP ))
		ch->pcdata->stats[DROW_POWER] += victim->level*4/3;

	    if (IS_CLASS(ch, CLASS_DEMON) || IS_SET(ch->special, SPC_CHAMPION))
	    {
		if ((vnum = victim->pIndexData->vnum) > 29000)
		{
		    switch (vnum)
		    {
		    default:
			ch->pcdata->stats[DEMON_CURRENT] += victim->level/2;
			ch->pcdata->stats[DEMON_TOTAL]   += victim->level/2;
			break;
		    case 29600:
		    case 30001:
		    case 30006:
		    case 30007:
		    case 30008:
		    case 30009:
                    case 30000:
			break;
		    }
		}
		else if (IS_NPC(victim) && !IS_SET(victim->act, ACT_NOEXP))
		{
		    ch->pcdata->stats[DEMON_CURRENT] += victim->level*2;
		    ch->pcdata->stats[DEMON_TOTAL] += victim->level*2;
		}
	    }
	    }
	    if (ch->level == 1 && ch->mkill > 4)
	    {
		ch->level = 2;
		do_save(ch,"");
	    }
	}
    	if (!IS_NPC(victim) && IS_NPC(ch)) 
        {
           victim->mdeath = victim->mdeath + 1;
        }
	raw_kill( victim, ch );


	if ( IS_SET(ch->act, PLR_AUTOLOOT) )
	    do_get( ch, "all corpse" );
	else
	    do_look( ch, "in corpse" );

	if ( !IS_NPC(ch) )
	{
	    if ( IS_SET(ch->act, PLR_AUTOSAC) )
		do_sacrifice( ch, "corpse" );
	}

	return;
    }

    if ( victim == ch )
	return;

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

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

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

    tail_chain( );
    return;
}

bool is_safe( CHAR_DATA *ch, CHAR_DATA *victim )
{

    if ( !IS_NPC(ch) && ch->level < 3 && !IS_NPC(victim) )
    {
        stc("You must be an avatar to fight other avatars!\n\r",ch);
        return TRUE;
    }

    if ( !IS_NPC(victim) && !IS_NPC(ch) && victim->level < 3 )
    {
        stc("They must be an avatar!\n\r",ch);
        return TRUE;
    }

 if ( !IS_NPC(victim) )
    {
	if (victim->pcdata->in_progress /* &&
	    (!victim->pcdata->in_progress->text) */ )
        {
            send_to_char ("Not while they are writting a note!\n\r", ch );
	    return TRUE;
	}                                                    
    }


    if ( victim->fight_timer > 0 )
      return FALSE;

    /* Ethereal people can only attack other ethereal people */
    if ( IS_AFFECTED(ch, AFF_ETHEREAL) && !IS_AFFECTED(victim, AFF_ETHEREAL) )
    {
	send_to_char( "You cannot while ethereal.\n\r", ch );
	return TRUE;
    }
    if ( !IS_AFFECTED(ch, AFF_ETHEREAL) && IS_AFFECTED(victim, AFF_ETHEREAL) )
    {
	send_to_char( "You cannot fight an ethereal person.\n\r", ch );
	return TRUE;
    }

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

    if ( IS_SET(ch->in_room->room_flags,ROOM_SAFE) )
    {
	send_to_char( "You cannot fight in a safe room.\n\r", ch );
	return TRUE;
    }

    if ( IS_HEAD(ch,LOST_HEAD) || IS_EXTRA(ch,EXTRA_OSWITCH) )
    {
	send_to_char( "Objects cannot fight!\n\r", ch );
	return TRUE;
    }
    else if ( IS_HEAD(victim,LOST_HEAD) || IS_EXTRA(victim,EXTRA_OSWITCH))
    {
	send_to_char( "You cannot attack an object.\n\r", ch );
	return TRUE;
    }

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

    /* Thx Josh! */
    if ( victim->fighting == ch )
	return FALSE;

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

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

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


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

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

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

   else if (strlen(ch->pcdata->love) > 1 && 
	    !str_cmp(ch->pcdata->love, victim->name))
	{
	    send_to_char( "How could you attack someone you love?!\n\r",ch );
	    return TRUE;
	}
    
    if ( !CAN_PK(ch) || !CAN_PK(victim) )
    {
	send_to_char( "Both players must be avatars to fight.\n\r", ch );
	return TRUE;
    }

  return FALSE;
}	

bool no_attack( CHAR_DATA *ch, CHAR_DATA *victim )
{


    if ( !IS_NPC(ch) && ch->level < 3 && !IS_NPC(victim) )
    {
        stc("You must be an avatar to fight other avatars!\n\r",ch);
        return TRUE;
    }

    if ( !IS_NPC(victim) && !IS_NPC(ch) && victim->level < 3 )
    {
        stc("They must be an avatar!\n\r",ch);
        return TRUE;
    }

    if ( victim->fight_timer > 0 )
      return FALSE;

    /* Ethereal people can only attack other ethereal people */
    if ( IS_AFFECTED(ch, AFF_ETHEREAL) && !IS_AFFECTED(victim, AFF_ETHEREAL) )
    {
	send_to_char( "You cannot while ethereal.\n\r", ch );
	return TRUE;
    }
    if ( !IS_AFFECTED(ch, AFF_ETHEREAL) && IS_AFFECTED(victim, AFF_ETHEREAL) )
    {
	send_to_char( "You cannot fight an ethereal person.\n\r", ch );
	return TRUE;
    }

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

    if ( IS_SET(ch->in_room->room_flags,ROOM_SAFE) )
    {
	send_to_char( "You cannot fight in a safe room.\n\r", ch );
	return TRUE;
    }

    if ( IS_HEAD(ch,LOST_HEAD) || IS_EXTRA(ch,EXTRA_OSWITCH) )
    {
	send_to_char( "Objects cannot fight!\n\r", ch );
	return TRUE;
    }
    else if ( IS_HEAD(victim,LOST_HEAD) || IS_EXTRA(victim,EXTRA_OSWITCH) )
    {
	send_to_char( "You cannot attack objects.\n\r", ch );
	return TRUE;
    }

    return FALSE;
}



/*
 * See if an attack justifies a KILLER flag.
 */
void check_killer( CHAR_DATA *ch, CHAR_DATA *victim )
{
    /*
     * Follow charm thread to responsible character.
     * Attacking someone's charmed char is hostile!
     */
    while ( IS_AFFECTED(victim, AFF_CHARM) && victim->master != NULL )
	victim = victim->master;

    /*
     * NPC's are fair game.
     * So are killers and thieves.
     */
    if ( IS_NPC(victim) )
	return;

    /*
     * Charm-o-rama.
     */
    if ( IS_SET(ch->affected_by, AFF_CHARM) )
    {
	if ( ch->master == NULL )
	{
	    affect_strip( ch, gsn_charm_person );
	    REMOVE_BIT( ch->affected_by, AFF_CHARM );
	    return;
	}
	stop_follower( ch );
	return;
    }
    return;
}



/*
 * Check for parry.
 */
bool check_parry( CHAR_DATA *ch, CHAR_DATA *victim, int dt )
{
    OBJ_DATA *obj = NULL;
    int chance = 0;
    int thingy;
    bool claws = FALSE;
    bool hands = FALSE;

    if ( !IS_AWAKE(victim) )
	return FALSE;

    else if ( IS_CLASS(victim, CLASS_WEREWOLF)	&& 
	victim->gifts[AHROUN] >= 2		&& 
	IS_VAMPAFF(victim, VAM_CLAWS)		&&
	get_eq_char(victim, WEAR_WIELD) == NULL	&&
	get_eq_char(victim, WEAR_HOLD) == NULL)
    {
	obj = NULL;
	claws = TRUE;
    }
    else if ( IS_CLASS(victim, CLASS_MONK) &&
              IS_SET(victim->newbits, NEW_MONKADAM) &&
              get_eq_char(victim, WEAR_WIELD) == NULL &&
              get_eq_char(victim, WEAR_HOLD) == NULL)
    {
        obj = NULL;
        claws = TRUE;
    }
    else
    {
	if ( ( obj = get_eq_char( victim, WEAR_WIELD ) ) == NULL 
		|| obj->item_type != ITEM_WEAPON )
	{
	    if ( ( obj = get_eq_char( victim, WEAR_HOLD ) ) == NULL 
		|| obj->item_type != ITEM_WEAPON ) return FALSE;
	}
    }

    if (dt < 1000 || dt > 1012) return FALSE;
    if (!IS_NPC(ch))     chance -= (ch->wpn[dt-1000] * 0.1);
	else             chance -= (ch->level * 0.2);
    if (!IS_NPC(victim)) chance += (victim->wpn[dt-1000] * 0.5);
	else             chance += victim->level;
    if (!IS_NPC(victim) && IS_STANCE(victim, STANCE_CRANE) &&
	victim->stance[STANCE_CRANE] > 0 && !can_counter(ch) &&
	!can_bypass(ch,victim))
	chance += (victim->stance[STANCE_CRANE] * 0.25);
    else if (!IS_NPC(victim) && IS_STANCE(victim, STANCE_MANTIS) &&
	victim->stance[STANCE_MANTIS] > 0 && !can_counter(ch) &&
	!can_bypass(ch,victim))
	chance += (victim->stance[STANCE_MANTIS] * 0.25);
//    chance -= (char_hitroll(ch) * 0.1);
     else if (!IS_NPC(victim) && IS_STANCE(victim, STANCE_RABBIT) &&
	victim->stance[STANCE_RABBIT] > 0 && !can_counter(ch) &&
	!can_bypass(ch,victim))
	chance += (victim->stance[STANCE_RABBIT] * 0.30);
    chance -= (char_hitroll(ch) * 0.3);

    if (claws) 
    {
        chance += (char_hitroll(victim) * 0.075);
    }
    else chance += (char_hitroll(victim) * 0.1);

    if (hands) 
    {
	    chance += (char_hitroll(victim) * 0.075);
    }
    else chance += (char_hitroll(victim) * 0.1);

    if (!IS_NPC(ch))
    {
        if ( IS_CLASS(ch, CLASS_VAMPIRE) )
	{
	    if ( ch->pcdata->powers[VAM_CELE] > 0 )
	        chance -= ( 4 * ch->pcdata->powers[VAM_CELE] );
	}
	if ( IS_CLASS(ch, CLASS_NINJA) )
	{
	    if ( ch->pcdata->powers[NPOWER_CHIKYU] >= 6 && ch->pcdata->powers[HARA_KIRI] > 0 )
	        chance -= 25;
	    if ( ch->pcdata->powers[NPOWER_CHIKYU] > 2 )
	        chance -= 20;
	    if ( ch->pcdata->powers[NINJAKI] > 4 )
	        chance -= ( ch->pcdata->powers[NINJAKI] / 4 );
	} 
	if ( IS_CLASS(ch, CLASS_DEMON) )
	{
	    if ( IS_DEMPOWER(ch, DEM_SPEED) )
	        chance -= 15;
	}
    if ( IS_CLASS(ch, CLASS_DEMON) && !IS_SET(ch->warp, WARP_QUICKNESS) )
        chance -= 10;
	if ( IS_CLASS(ch, CLASS_MAGE) )
	{
	    if ( IS_SET(ch->mflags, MAGE_POLYAPPEAR) )
	        chance -= 10;
	    if ( ch->spheres[MTIM] > 0 )
	        chance -= ( ch->spheres[MTIM] * 3 );
	}
	if ( IS_CLASS(ch, CLASS_DROW) )
	{
	    if ( IS_SET(ch->pcdata->powers[1], DPOWER_ARMS) )
	        chance -= 20;
	    chance -= 40;
	}
	if ( IS_CLASS(ch, CLASS_WEREWOLF) )
	{
	    if ( IS_SET(ch->special, SPC_WOLFMAN) )
	        chance -= 5;
	    if ( ch->gifts[SILENTSTRIDERS] > 0 )
	        chance -= 5;
	    if ( ch->gifts[SILENTSTRIDERS] > 1 )
	        chance -= 10;
	    if ( ch->gifts[SILENTSTRIDERS] > 2 )
	        chance -= 10;
            if ( ch->gifts[STARGAZERS] >= 3 )
	        chance -= 5;
	}
	if ( IS_CLASS(ch, CLASS_MONK) )
	{
	    if ( ch->chi[CURRENT] > 0 )
	        chance -= ( ch->chi[CURRENT] * 7 );
	}
	if ( IS_CLASS(ch, CLASS_HIGHLANDER) )
	{
	    if ( get_eq_char(ch, WEAR_WIELD) != NULL )
	      chance -= ch->race*2/3;
	}
    }

  /* Some shit for Earth Embrace )Mage Power(, works on NPC's.. */
    if ( IS_SET(victim->mflags, MAGE_EMBRACED2) )
      chance += 10;
    if ( IS_SET(victim->mflags, MAGE_EMBRACED1) )
      chance += 5;
    if ( IS_SET(ch->mflags, MAGE_EMBRACED2) )
      chance -= 10;
    if ( IS_SET(ch->mflags, MAGE_EMBRACED1) )
      chance -= 5;

    if(IS_CLASS(ch,CLASS_DROW)) chance *= 2;
    if(IS_CLASS(ch,CLASS_DROW)) chance /= 3;
    if (!IS_NPC(victim))
    {
        if ( IS_CLASS(victim, CLASS_VAMPIRE) )
	{
	    if ( victim->pcdata->powers[VAM_CELE] > 0 )
	        chance += ( 3 * victim->pcdata->powers[VAM_CELE] );
	}
	if ( IS_CLASS(victim, CLASS_NINJA) )
	{
	    if ( victim->pcdata->powers[NPOWER_CHIKYU] >= 6 && victim->pcdata->powers[HARA_KIRI] > 0 )
	        chance += 25;
	    if ( victim->pcdata->powers[NPOWER_CHIKYU] > 2 )
	        chance += 20;
	    if ( victim->pcdata->powers[NINJAKI] > 4 )
	        chance += ( victim->pcdata->powers[NINJAKI] / 4 );
	}
	if ( IS_CLASS(victim, CLASS_DEMON) )
	{
	    if ( IS_DEMPOWER(victim, DEM_SPEED) )
	        chance += 15;
	}
if ( IS_CLASS(ch, CLASS_DEMON) && !IS_SET(ch->warp, WARP_QUICKNESS) )
        chance -= 10;
	if ( IS_CLASS(victim, CLASS_DROW) )
	{
	    if ( IS_SET(victim->pcdata->powers[1], DPOWER_ARMS) )
	        chance += 20;
		chance += 40;
	}
	if ( IS_CLASS(victim, CLASS_MAGE) )
	{
	    if ( IS_SET(victim->mflags, MAGE_POLYAPPEAR) )
	        chance += 10;
	    if ( victim->spheres[MTIM] > 0 )
	        chance += ( victim->spheres[MTIM] * 2 );
	}
	if ( IS_CLASS(victim, CLASS_MONK) )
	{
	    if ( victim->chi[CURRENT] > 0 )
	        chance += ( victim->chi[CURRENT] * 7 );
	}
	if ( IS_CLASS(victim, CLASS_WEREWOLF) )
	{
	    if ( IS_SET(victim->special, SPC_WOLFMAN) )
	        chance += 5;
	    if ( victim->gifts[SILENTSTRIDERS] > 0 )
	        chance += 5;
	    if ( victim->gifts[SILENTSTRIDERS] > 1 )
	        chance += 10;
	    if ( victim->gifts[SILENTSTRIDERS] > 2 )
	        chance += 10;
            if ( victim->gifts[STARGAZERS] >= 3 )
	        chance += 5;
	}
	if ( IS_CLASS(victim, CLASS_HIGHLANDER) )
	{
	    if ( get_eq_char(victim, WEAR_WIELD) != NULL )
	      chance += ch->race*2/3;
	}

    }

    if      (chance > 75) chance = 75;
    else if (chance < 25) chance = 25;

    if (!IS_NPC(ch) && ch->pcdata->powers[VAM_CELE] > 0 && 
	IS_CLASS(ch, CLASS_VAMPIRE))
    {
	if (ch->pcdata->rank == AGE_METHUSELAH) chance -= 10;
	else if (ch->pcdata->rank == AGE_ELDER) chance -= 7;
	else if (ch->pcdata->rank == AGE_ANCILLA) chance -= 5;
    }
    if (!IS_NPC(victim) && victim->pcdata->powers[VAM_CELE] > 0 && 
	IS_CLASS(victim, CLASS_VAMPIRE))
    {
	if (victim->pcdata->rank == AGE_METHUSELAH) chance += 10;
	else if (victim->pcdata->rank == AGE_ELDER) chance += 7;
	else if (victim->pcdata->rank == AGE_ANCILLA) chance += 5;
    }
   if ( !IS_NPC(victim) && IS_CLASS(victim, CLASS_MONK) )
    {
     if ( victim->monkblock / 4 > 0 )
        chance += victim->monkblock / 4;
    }
           
    if ( IS_NPC(victim) )
    {
      if ( victim->level < 100 )
        chance = 15;
      if ( victim->level >= 100 )
        chance = ( victim->level * .01 );
      if ( victim->level >= 500 )
        chance = 50;
      chance += config_info->bonus;
    }
	if(IS_CLASS(victim,CLASS_DROW))
	chance /= 1.35;
    thingy = number_range(1,100);
    if ( thingy >= chance )
	return FALSE;

    if (claws)
    {
	if (IS_NPC(victim) || !IS_SET(victim->act, PLR_BRIEF))
	    act( "You parry $n's blow with your claws.",  ch, NULL, victim, TO_VICT );
	if (IS_NPC(ch) || !IS_SET(ch->act, PLR_BRIEF))
	    act( "$N parries your blow with $S claws.", ch, NULL, victim, TO_CHAR );
	return TRUE;
    }
	if (hands)
    {
	if (IS_NPC(victim) || !IS_SET(victim->act, PLR_BRIEF))
	    act( "You parry $n's blow with your adamantium hands.",  ch, NULL, victim, TO_VICT);
	if (IS_NPC(ch) || !IS_SET(ch->act, PLR_BRIEF))
	    act( "$N parries your blow with $S adamantium hands.", ch, NULL, victim, TO_CHAR);
	return TRUE;
    }
          if (!IS_NPC(victim) && IS_CLASS(victim, CLASS_MONK)
                 && victim->monkblock < 150 )
              victim->monkblock++;

    if (!IS_NPC(victim) && obj != NULL && obj->item_type == ITEM_WEAPON &&
	obj->value[3] >= 0 && obj->value[3] <= 12)
    {
	if (IS_NPC(victim) || !IS_SET(victim->act, PLR_BRIEF))
	    act( "You parry $n's blow with $p.",  ch, obj, victim, TO_VICT );
	if (IS_NPC(ch) || !IS_SET(ch->act, PLR_BRIEF))
	    act( "$N parries your blow with $p.", ch, obj, victim, TO_CHAR );
	return TRUE;
    }
    if (IS_NPC(victim) || !IS_SET(victim->act, PLR_BRIEF))
	act( "You parry $n's attack.",  ch, NULL, victim, TO_VICT    );
    if (IS_NPC(ch) || !IS_SET(ch->act, PLR_BRIEF))
	act( "$N parries your attack.", ch, NULL, victim, TO_CHAR    );
    return TRUE;
}



/*
 * Check for dodge.
 */
bool check_dodge( CHAR_DATA *ch, CHAR_DATA *victim, int dt )
{
    int chance = 0;
    int thingy;

    if ( !IS_AWAKE(victim) )
	return FALSE;

    if (!IS_NPC(ch))     chance -= (ch->wpn[dt-1000] * 0.1);
	else             chance -= (ch->level * 0.2);
    if (!IS_NPC(victim)) chance += (victim->wpn[0] * 0.5);
	else             chance += victim->level;

    if (!IS_NPC(victim) && IS_STANCE(victim, STANCE_MONGOOSE) &&
	victim->stance[STANCE_MONGOOSE] > 0 && !can_counter(ch) &&
	!can_bypass(ch,victim))
	(chance += victim->stance[STANCE_MONGOOSE] * 0.25);
    if (!IS_NPC(victim) && IS_STANCE(victim, STANCE_SWALLOW) &&
	victim->stance[STANCE_SWALLOW] > 0 && !can_counter(ch) &&
	!can_bypass(ch,victim))
	(chance += victim->stance[STANCE_SWALLOW] * 0.25);
 if (!IS_NPC(victim) && IS_STANCE(victim, STANCE_EAGLE) &&
	victim->stance[STANCE_EAGLE] > 0 && !can_counter(ch) &&
	!can_bypass(ch,victim))
	(chance += victim->stance[STANCE_EAGLE] * 0.30);
    if (!IS_NPC(ch))
    {
        if ( IS_CLASS(ch, CLASS_VAMPIRE) )
	{
	    if ( ch->pcdata->powers[VAM_CELE] > 0 )
	        chance -= ( 4 * ch->pcdata->powers[VAM_CELE] );
	}
	if ( IS_CLASS(ch, CLASS_NINJA) )
	{
	    if ( ch->pcdata->powers[NPOWER_CHIKYU] >= 6 && ch->pcdata->powers[HARA_KIRI] > 0 )
	        chance -= 25;
	    if ( ch->pcdata->powers[NPOWER_CHIKYU] > 2 )
	        chance -= 20;
	    if ( ch->pcdata->powers[NINJAKI] > 4 )
	        chance -= ( ch->pcdata->powers[NINJAKI] / 4 );
	}
	if ( IS_CLASS(ch, CLASS_DEMON) )
	{
	    if ( IS_DEMPOWER(ch, DEM_SPEED) )
	        chance -= 15;
	}
if ( IS_CLASS(ch, CLASS_DEMON) && !IS_SET(ch->warp, WARP_QUICKNESS) )
        chance -= 10;
	if ( IS_CLASS(ch, CLASS_MAGE) )
	{
	    if ( IS_SET(ch->mflags, MAGE_POLYAPPEAR) )
	        chance -= 10;
	    if ( ch->spheres[MTIM] > 0 )
	        chance -= ( ch->spheres[MTIM] * 2 );
	}
	if ( IS_CLASS(ch, CLASS_DROW) )
	{
	    if ( IS_SET(ch->pcdata->powers[1], DPOWER_ARMS) )
	        chance -= 20;
	    chance -= 40;
	}
	if ( IS_CLASS(ch, CLASS_WEREWOLF) )
	{
	    if ( IS_SET(ch->special, SPC_WOLFMAN) )
	        chance -= 5;
	    if ( ch->gifts[SILENTSTRIDERS] > 0 )
	        chance -= 5;
	    if ( ch->gifts[SILENTSTRIDERS] > 1 )
	        chance -= 10;
	    if ( ch->gifts[SILENTSTRIDERS] > 2 )
	        chance -= 10;
            if ( ch->gifts[STARGAZERS] >= 3 )
	        chance -= 5;
	}
	if ( IS_CLASS(ch, CLASS_MONK) )
	{
	    if ( ch->chi[CURRENT] > 0 )
	        chance -= ( ch->chi[CURRENT] * 7 );
	}
	if ( IS_CLASS(ch, CLASS_HIGHLANDER) )
	{
	    if ( get_eq_char(ch, WEAR_WIELD) != NULL )
	      chance -= ch->race*2/3;
	}
    }


  /* Some shit for Earth Embrace )Mage Power(, works on NPC's.. */
    if ( IS_SET(victim->mflags, MAGE_EMBRACED2) )
      chance += 10;
    if ( IS_SET(victim->mflags, MAGE_EMBRACED1) )
      chance += 5;
    if ( IS_SET(ch->mflags, MAGE_EMBRACED2) )
      chance -= 10;
    if ( IS_SET(ch->mflags, MAGE_EMBRACED1) )
      chance -= 5;

    if (!IS_NPC(victim))
    {
        if ( IS_CLASS(victim, CLASS_VAMPIRE) )
	{
	    if ( victim->pcdata->powers[VAM_CELE] > 0 )
	        chance += ( 3 * victim->pcdata->powers[VAM_CELE] );
	}
	if ( IS_CLASS(victim, CLASS_NINJA) )
	{
	    if ( victim->pcdata->powers[NPOWER_CHIKYU] >= 6 && victim->pcdata->powers[HARA_KIRI] > 0 )
	        chance += 25;
	    if ( victim->pcdata->powers[NPOWER_CHIKYU] > 2 )
	        chance += 20;
	    if ( victim->pcdata->powers[NINJAKI] > 4 )
	        chance += ( victim->pcdata->powers[NINJAKI] / 4 );
	}
	if ( IS_CLASS(victim, CLASS_DEMON) )
	{
	    if ( IS_DEMPOWER(victim, DEM_SPEED) )
	        chance += 15;
	}
if ( IS_CLASS(ch, CLASS_DEMON) && !IS_SET(ch->warp, WARP_QUICKNESS) )
        chance -= 10;
	if ( IS_CLASS(victim, CLASS_DROW) )
	{
	    if ( IS_SET(victim->pcdata->powers[1], DPOWER_ARMS) )
	        chance += 20;
		chance += 40;
	}
	if ( IS_CLASS(victim, CLASS_MAGE) )
	{
	    if ( IS_SET(victim->mflags, MAGE_POLYAPPEAR) )
	        chance += 10;
	    if ( victim->spheres[MTIM] > 0 )
	        chance += ( victim->spheres[MTIM] * 2 );
	}
	if ( IS_CLASS(victim, CLASS_MONK) )
	{
	    if ( victim->chi[CURRENT] > 0 )
	        chance += ( victim->chi[CURRENT] * 7 );
	}
	if ( IS_CLASS(victim, CLASS_WEREWOLF) )
	{
	    if ( IS_SET(victim->special, SPC_WOLFMAN) )
	        chance += 5;
	    if ( victim->gifts[SILENTSTRIDERS] > 0 )
	        chance += 5;
	    if ( victim->gifts[SILENTSTRIDERS] > 1 )
	        chance += 10;
	    if ( victim->gifts[SILENTSTRIDERS] > 2 )
	        chance += 10;
            if ( victim->gifts[STARGAZERS] >= 3 )
	        chance += 5;
	}
	if ( IS_CLASS(victim, CLASS_HIGHLANDER) )
	{
	    if ( get_eq_char(victim, WEAR_WIELD) != NULL )
	      chance += ch->race*2/3;
	}

    }

    if      (chance > 75) chance = 75;
    else if (chance < 25) chance = 25;

    if (!IS_NPC(ch) && IS_VAMPAFF(ch, VAM_CELERITY) && 
	IS_CLASS(ch, CLASS_VAMPIRE))
    {
	if (ch->pcdata->rank == AGE_METHUSELAH) chance -= 10;
	else if (ch->pcdata->rank == AGE_ELDER) chance -= 7;
	else if (ch->pcdata->rank == AGE_ANCILLA) chance -= 5;
    }
    if (!IS_NPC(victim) && IS_VAMPAFF(victim, VAM_CELERITY) && 
	IS_CLASS(victim, CLASS_VAMPIRE))
    {
	if (victim->pcdata->rank == AGE_METHUSELAH) chance += 10;
	else if (victim->pcdata->rank == AGE_ELDER) chance += 7;
	else if (victim->pcdata->rank == AGE_ANCILLA) chance += 5;
    }

   if ( !IS_NPC(victim) && IS_CLASS(victim, CLASS_MONK) )
    {
     if ( victim->monkblock / 4 > 0 )
        chance += victim->monkblock / 4;
    }

    if ( IS_NPC(victim) )
    {
      if ( victim->level < 100 )
        chance = 15;
      if ( victim->level >= 100 )
        chance = ( victim->level * .01 );
      if ( victim->level >= 500 )
        chance = 50;
      chance += config_info->bonus;
    }
	if(IS_CLASS(victim,CLASS_DROW))chance /= 1.25;
    thingy = number_range(1,100);
    if ( thingy >= chance )
	return FALSE;

    if (IS_NPC(victim) || !IS_SET(victim->act, PLR_BRIEF))
	act( "You dodge $n's attack.", ch, NULL, victim, TO_VICT );
    if (IS_NPC(ch) || !IS_SET(ch->act, PLR_BRIEF))
	act( "$N dodges your attack.", ch, NULL, victim, TO_CHAR );
    return TRUE;
}



/*
 * Set position of a victim.
 */
void update_pos( CHAR_DATA *victim )
{
    CHAR_DATA *mount;

    if ( victim->hit > 0 )
    {
    	if ( victim->position <= POS_STUNNED )
	{
	    bool gm_stance = FALSE;
	    victim->position = POS_STANDING;
	    if (!IS_NPC(victim) && victim->stance[0] > 0)
	    {
		int stance = victim->stance[0];
		if (victim->stance[stance] >= 200) gm_stance = TRUE;
	    }
	    if (IS_NPC(victim) || victim->max_hit * 0.25 > victim->hit || 
		!gm_stance)
	    {
		act( "$n clambers back to $s feet.", victim, NULL, NULL, TO_ROOM);
		act( "You clamber back to your feet.", victim, NULL, NULL, TO_CHAR);
	    }
	    else
	    {
		act( "$n flips back up to $s feet.", victim, NULL, NULL, TO_ROOM);
		act( "You flip back up to your feet.", victim, NULL, NULL, TO_CHAR);
	    }
	}
	return;
    }
    else if ( (mount = victim->mount) != NULL)
    {
	if (victim->mounted == IS_MOUNT)
	{
	    act("$n rolls off $N.",mount,NULL,victim,TO_ROOM);
	    act("You roll off $N.",mount,NULL,victim,TO_CHAR);
	}
	else if (victim->mounted == IS_RIDING)
	{
	    act("$n falls off $N.",victim,NULL,mount,TO_ROOM);
	    act("You fall off $N.",victim,NULL,mount,TO_CHAR);
	}
	mount->mount    = NULL;
	victim->mount   = NULL;
	mount->mounted  = IS_ON_FOOT;
	victim->mounted = IS_ON_FOOT;
    }

    if (!IS_NPC(victim) && victim->hit <=-11 && IS_HERO(victim))
    {
        victim->hit = -10;
        if (victim->position == POS_FIGHTING) 
           stop_fighting(victim,TRUE);
        return;
    }

    if ( IS_NPC(victim) || victim->hit <= -11 )
    {
	victim->position = POS_DEAD;
	return;
    }

         if ( victim->hit <= -6 ) victim->position = POS_MORTAL;
    else if ( victim->hit <= -3 ) victim->position = POS_INCAP;
    else                          victim->position = POS_STUNNED;

    return;
}



/*
 * Start fights.
 */
void set_fighting( CHAR_DATA *ch, CHAR_DATA *victim )
{
    if ( ch->fighting != NULL )
    {
	bug( "Set_fighting: already fighting", 0 );
	return;
    }


     if ( !IS_NPC( ch ) && !IS_NPC( victim) )
        ch->fight_timer = 10;

    if ( !IS_NPC( victim ) && !IS_NPC( ch ) )
        victim->fight_timer = 10;

    if ( IS_AFFECTED(ch, AFF_SLEEP) )
	affect_strip( ch, gsn_sleep );

    ch->fighting = victim;
    ch->position = POS_FIGHTING;
    ch->damcap[DAM_CHANGE] = 1;

	autodrop(ch);
	autodrop(victim);

  if (IS_AFFECTED(ch, AFF_STEELSHIELD))
    {
        REMOVE_BIT(ch->affected_by, AFF_STEELSHIELD);
}

    return;
}

void stop_embrace( CHAR_DATA *ch, CHAR_DATA *victim )
{
if (victim==NULL)
{ch->embracing=NULL;return;}
victim->embraced=NULL;
ch->embracing=NULL;
stc("You release your hold on your victim!\n\r", ch );
//act("$N releases his hold on $N.",ch,NULL,victim,TO_CHAR);
return;

}


/*
 * Stop fights.
 */
void stop_fighting( CHAR_DATA *ch, bool fBoth )
{
    CHAR_DATA *fch;
    


    for ( fch = char_list; fch != NULL; fch = fch->next )
    {
	if ( fch == ch || ( fBoth && fch->fighting == ch ) )
	{
	    fch->fighting	= NULL;
	    fch->position	= POS_STANDING;
	     update_pos( fch );
	}
    }

    return;
}



/*
 * Make a corpse out of a character.
 */
/*void make_corpse( CHAR_DATA *ch )
{
    char buf[MAX_STRING_LENGTH];
    OBJ_DATA *corpse;
    OBJ_DATA *obj;
    OBJ_DATA *obj_next;
    char *name;

    if ( IS_NPC(ch) )
    {
	name		= ch->short_descr;
	corpse		= create_object(get_obj_index(OBJ_VNUM_CORPSE_NPC), 0);
	corpse->timer	= number_range( 20, 35 );
	corpse->value[2]= ch->pIndexData->vnum;
	if ( ch->gold > 0 )
	{
	    obj_to_obj( create_money( ch->gold ), corpse );
	    ch->gold = 0;
	}
    }
    else
    {
	name		= ch->name;
	corpse		= create_object(get_obj_index(OBJ_VNUM_CORPSE_PC), 0);
	corpse->timer	= number_range( 100, 150 );
	if ( ch->gold > 0 )
	{
	    obj = create_money( ch->gold );
	    if (IS_AFFECTED(ch,AFF_SHADOWPLANE) &&
	        (!IS_SET(obj->extra_flags, ITEM_SHADOWPLANE) ) )
	        SET_BIT(obj->extra_flags, ITEM_SHADOWPLANE);
	    obj_to_obj( obj, corpse );
	    ch->gold = 0;
	}
    }

    sprintf( buf, corpse->short_descr, name );
    free_string( corpse->short_descr );
    corpse->short_descr = str_dup( buf );

    sprintf( buf, corpse->description, name );
    free_string( corpse->description );
    corpse->description = str_dup( buf );

    for ( obj = ch->carrying; obj != NULL; obj = obj_next )
    {
	obj_next = obj->next_content;

	obj_from_char( obj );
	if ( IS_SET( obj->extra_flags, ITEM_VANISH ) )
	    extract_obj( obj );
	else
	{
	    if (IS_AFFECTED(ch,AFF_SHADOWPLANE) &&
	        (!IS_SET(obj->extra_flags, ITEM_SHADOWPLANE) ) )
	        SET_BIT(obj->extra_flags, ITEM_SHADOWPLANE);
	    obj_to_obj( obj, corpse );
	}
    }

    if (IS_AFFECTED(ch, AFF_SHADOWPLANE))
	SET_BIT(corpse->extra_flags, ITEM_SHADOWPLANE);

    obj_to_room( corpse, ch->in_room );
    return;
}*/



void death_cry( CHAR_DATA *ch )
{
    ROOM_INDEX_DATA *was_in_room;
    char *msg;
    int door;

    if ( IS_NPC(ch) )
	msg = "You hear something's death cry.";
    else
	msg = "You hear someone's death cry.";

    was_in_room = ch->in_room;
    for ( door = 0; door <= 5; door++ )
    {
	EXIT_DATA *pexit;

	if ( ( pexit = was_in_room->exit[door] ) != NULL
	&&   pexit->to_room != NULL
	&&   pexit->to_room != was_in_room )
	{
	    ch->in_room = pexit->to_room;
	    act( msg, ch, NULL, NULL, TO_ROOM );
	}
    }
    ch->in_room = was_in_room;
    return;
}

void make_part( CHAR_DATA *ch, char *argument )
{
    char  arg [MAX_INPUT_LENGTH];
    int vnum;

    argument = one_argument(argument,arg);
    vnum = 0;

    if (arg[0] == '\0') return;
    if (!str_cmp(arg,"head")) vnum = OBJ_VNUM_SEVERED_HEAD;
    else if (!str_cmp(arg,"arm")) vnum = OBJ_VNUM_SLICED_ARM;
    else if (!str_cmp(arg,"leg")) vnum = OBJ_VNUM_SLICED_LEG;
    else if (!str_cmp(arg,"heart")) vnum = OBJ_VNUM_TORN_HEART;
    else if (!str_cmp(arg,"turd")) vnum = OBJ_VNUM_TORN_HEART;
    else if (!str_cmp(arg,"entrails")) vnum = OBJ_VNUM_SPILLED_ENTRAILS;
    else if (!str_cmp(arg,"brain")) vnum = OBJ_VNUM_QUIVERING_BRAIN;
    else if (!str_cmp(arg,"eyeball")) vnum = OBJ_VNUM_SQUIDGY_EYEBALL;
    else if (!str_cmp(arg,"blood")) vnum = OBJ_VNUM_SPILT_BLOOD;
    else if (!str_cmp(arg,"face")) vnum = OBJ_VNUM_RIPPED_FACE;
    else if (!str_cmp(arg,"windpipe")) vnum = OBJ_VNUM_TORN_WINDPIPE;
    else if (!str_cmp(arg,"cracked_head")) vnum = OBJ_VNUM_CRACKED_HEAD;
    else if (!str_cmp(arg,"ear")) vnum = OBJ_VNUM_SLICED_EAR;
    else if (!str_cmp(arg,"nose")) vnum = OBJ_VNUM_SLICED_NOSE;
    else if (!str_cmp(arg,"tooth")) vnum = OBJ_VNUM_KNOCKED_TOOTH;
    else if (!str_cmp(arg,"tongue")) vnum = OBJ_VNUM_TORN_TONGUE;
    else if (!str_cmp(arg,"hand")) vnum = OBJ_VNUM_SEVERED_HAND;
    else if (!str_cmp(arg,"foot")) vnum = OBJ_VNUM_SEVERED_FOOT;
    else if (!str_cmp(arg,"thumb")) vnum = OBJ_VNUM_SEVERED_THUMB;
    else if (!str_cmp(arg,"index")) vnum = OBJ_VNUM_SEVERED_INDEX;
    else if (!str_cmp(arg,"middle")) vnum = OBJ_VNUM_SEVERED_MIDDLE;
    else if (!str_cmp(arg,"ring")) vnum = OBJ_VNUM_SEVERED_RING;
    else if (!str_cmp(arg,"little")) vnum = OBJ_VNUM_SEVERED_LITTLE;
    else if (!str_cmp(arg,"toe")) vnum = OBJ_VNUM_SEVERED_TOE;

    if ( vnum != 0 )
    {
	char buf[MAX_STRING_LENGTH];
	OBJ_DATA *obj;
	char *name;

	name		= IS_NPC(ch) ? ch->short_descr : ch->name;
	obj		= create_object( get_obj_index( vnum ), 0 );
	if (IS_NPC(ch))   obj->timer = number_range(2,15);
	else              obj->timer = -1;
	if (!str_cmp(arg,"head") && IS_NPC(ch))
	    obj->value[1] = ch->pIndexData->vnum;
	else if (!str_cmp(arg,"head") && !IS_NPC(ch))
	    {ch->pcdata->chobj = obj; obj->chobj = ch;obj->timer = 
	number_range(8,14);}
	else if (!str_cmp(arg,"arm"))
	  SET_BIT(obj->extra_flags, ITEM_ARM);
	else if (!str_cmp(arg,"brain") && !IS_NPC(ch) && 
	IS_AFFECTED(ch,AFF_POLYMORPH) && IS_HEAD(ch, LOST_HEAD))
	{
	    if (ch->pcdata->chobj != NULL) ch->pcdata->chobj->chobj = NULL;
	    ch->pcdata->chobj = obj;
	    obj->chobj = ch;
	    obj->timer = number_range(2,3);
	}

	/* For blood :) KaVir */
	if (vnum == OBJ_VNUM_SPILT_BLOOD) obj->timer = 2;

	/* For voodoo dolls - KaVir */
	if (!IS_NPC(ch))
	{
	    sprintf( buf, obj->name, name );
	    free_string( obj->name );
	    obj->name = str_dup( buf );
	}
	else
	{
	    sprintf( buf, obj->name, "mob" );
	    free_string( obj->name );
	    obj->name = str_dup( buf );
	}

	sprintf( buf, obj->short_descr, name );
	free_string( obj->short_descr );
	obj->short_descr = str_dup( buf );

	sprintf( buf, obj->description, name );
	free_string( obj->description );
	obj->description = str_dup( buf );

    	if (IS_AFFECTED(ch, AFF_SHADOWPLANE))
	    SET_BIT(obj->extra_flags, ITEM_SHADOWPLANE);

	obj_to_room( obj, ch->in_room );
    }
    return;
}



void raw_kill( CHAR_DATA *victim, CHAR_DATA *ch )
{
    CHAR_DATA *mount;
  if (!IS_NPC(victim) && victim->fatal > 0) death_message(ch,victim); 
    stop_fighting( victim, TRUE );
    victim->agg = 0;
    death_cry( victim );
    make_corpse( victim );

    if ( (mount = victim->mount) != NULL)
    {
	if (victim->mounted == IS_MOUNT)
	{
	    act("$n rolls off the corpse of $N.",mount,NULL,victim,TO_ROOM);
	    act("You roll off the corpse of $N.",mount,NULL,victim,TO_CHAR);
	}
	else if (victim->mounted == IS_RIDING)
	{
	    act("$n falls off $N.",victim,NULL,mount,TO_ROOM);
	    act("You fall off $N.",victim,NULL,mount,TO_CHAR);
	}
	mount->mount    = NULL;
	victim->mount   = NULL;
	mount->mounted  = IS_ON_FOOT;
	victim->mounted = IS_ON_FOOT;
    }

    if ( IS_NPC(victim) )
    {
	victim->pIndexData->killed++;
	kill_table[URANGE(0, victim->level, MAX_LEVEL-1)].killed++;
	extract_char( victim, TRUE, FALSE );
	return;
    }

    extract_char( victim, FALSE, FALSE );
    while ( victim->affected )
	affect_remove( victim, victim->affected );
    if (IS_AFFECTED(victim,AFF_POLYMORPH) && IS_AFFECTED(victim,AFF_ETHEREAL))
    {
    	victim->affected_by	= AFF_POLYMORPH + AFF_ETHEREAL;
    }
    else if (IS_AFFECTED(victim,AFF_POLYMORPH))
    	victim->affected_by	= AFF_POLYMORPH;
    else if (IS_AFFECTED(victim,AFF_ETHEREAL))
    	victim->affected_by	= AFF_ETHEREAL;
    else
    	victim->affected_by	= 0;

    REMOVE_BIT(victim->immune, IMM_STAKE);
    REMOVE_BIT(victim->extra, TIED_UP);
    REMOVE_BIT(victim->extra, GAGGED);
    REMOVE_BIT(victim->extra, BLINDFOLDED);
    REMOVE_BIT(victim->extra, EXTRA_PREGNANT);
    REMOVE_BIT(victim->extra, EXTRA_LABOUR);
    victim->pcdata->stats[DEMON_POWER] = 0;

    victim->itemaffect	 = 0;
    victim->loc_hp[0]    = 0;
    victim->loc_hp[1]    = 0;
    victim->loc_hp[2]    = 0;
    victim->loc_hp[3]    = 0;
    victim->loc_hp[4]    = 0;
    victim->loc_hp[5]    = 0;
    victim->loc_hp[6]    = 0;
    victim->armor	 = 100;
    victim->position	 = POS_RESTING;
    victim->hit		 = UMAX( 1, victim->hit  );
    victim->mana	 = UMAX( 1, victim->mana );
    victim->move	 = UMAX( 1, victim->move );
    victim->hitroll	 = 0;
    victim->damroll	 = 0;
    victim->saving_throw = 0;
    victim->carry_weight = 0;
    victim->carry_number = 0;
    do_call(victim,"all");
    save_char_obj( victim );
    return;
}


void behead( CHAR_DATA *victim )
{
    char buf [MAX_STRING_LENGTH];
    ROOM_INDEX_DATA *location;

    if (IS_NPC(victim)) return;

    location = victim->in_room;

    stop_fighting( victim, TRUE );

    make_corpse( victim );

    extract_char( victim, FALSE, FALSE );

    char_from_room(victim);
    char_to_room(victim,location);

    if (victim == NULL)
    {bug( "Behead: Victim no longer exists.", 0 );return;}

    make_part( victim, "head" );

    while ( victim->affected )
	affect_remove( victim, victim->affected );
    if (IS_AFFECTED(victim,AFF_POLYMORPH) && IS_AFFECTED(victim,AFF_ETHEREAL))
    {
    	victim->affected_by	= AFF_POLYMORPH + AFF_ETHEREAL;
    }
    else if (IS_AFFECTED(victim,AFF_POLYMORPH))
    	victim->affected_by	= AFF_POLYMORPH;
    else if (IS_AFFECTED(victim,AFF_ETHEREAL))
    	victim->affected_by	= AFF_ETHEREAL;
    else
    	victim->affected_by	= 0;

    REMOVE_BIT(victim->immune, IMM_STAKE);
    REMOVE_BIT(victim->extra, TIED_UP);
    REMOVE_BIT(victim->extra, GAGGED);
    REMOVE_BIT(victim->extra, BLINDFOLDED);
    REMOVE_BIT(victim->extra, EXTRA_PREGNANT);
    REMOVE_BIT(victim->extra, EXTRA_LABOUR);
    victim->pcdata->stats[DEMON_POWER] = 0;

    victim->itemaffect	 = 0;
    victim->loc_hp[0]    = 0;
    victim->loc_hp[1]    = 0;
    victim->loc_hp[2]    = 0;
    victim->loc_hp[3]    = 0;
    victim->loc_hp[4]    = 0;
    victim->loc_hp[5]    = 0;
    victim->loc_hp[6]    = 0;
    victim->affected_by	 = 0;
    victim->armor	 = 100;
    victim->position	 = POS_STANDING;
    victim->hit		 = 1;
    victim->mana	 = UMAX( 1, victim->mana );
    victim->move	 = UMAX( 1, victim->move );
    victim->hitroll	 = 0;
    victim->damroll	 = 0;
    victim->saving_throw = 0;
    victim->carry_weight = 0;
    victim->carry_number = 0;

    SET_BIT(victim->loc_hp[0],LOST_HEAD);
    SET_BIT(victim->affected_by,AFF_POLYMORPH);
    sprintf(buf,"the severed head of %s",victim->name);
    free_string(victim->morph);
    victim->morph = str_dup(buf);
    do_call(victim,"all");
    save_char_obj( victim );
    return;
}



void group_gain( CHAR_DATA *ch, CHAR_DATA *victim )
{
    char buf[MAX_STRING_LENGTH];
    CHAR_DATA *gch;
    CHAR_DATA *lch;
    CHAR_DATA *mount;
    int xp;
    int members;

    /*
     * Monsters don't get kill xp's or alignment changes.
     * P-killing doesn't help either.
     * Dying of mortal wounds or poison doesn't give xp to anyone!
     */
    if ( (IS_NPC(ch) && (mount = ch->mount) == NULL) || victim == ch )
	return;
    
    members = 0;
    for ( gch = ch->in_room->people; gch != NULL; gch = gch->next_in_room )
    {
	if ( is_same_group( gch, ch ) )
	    members++;
    }

    if ( members == 0 )
    {
	bug( "Group_gain: members.", members );
	members = 1;
    }

    lch = (ch->leader != NULL) ? ch->leader : ch;

    for ( gch = ch->in_room->people; gch != NULL; gch = gch->next_in_room )
    {
	OBJ_DATA *obj;
	OBJ_DATA *obj_next;

	if ( !is_same_group( gch, ch ) )
	    continue;

	xp = xp_compute( gch, victim ) / members;
	sprintf( buf, "You receive %d experience points.\n\r", xp );
	send_to_char( buf, gch );
	if ((mount = gch->mount) != NULL) send_to_char( buf, mount );
	gain_exp( gch, xp );

	for ( obj = ch->carrying; obj != NULL; obj = obj_next )
	{
	    obj_next = obj->next_content;
	    if ( obj->wear_loc == WEAR_NONE )
		continue;

	    if ( ( IS_OBJ_STAT(obj, ITEM_ANTI_EVIL)    && IS_EVIL(ch)    )
	    ||   ( IS_OBJ_STAT(obj, ITEM_ANTI_GOOD)    && IS_GOOD(ch)    )
	    ||   ( IS_OBJ_STAT(obj, ITEM_ANTI_NEUTRAL) && IS_NEUTRAL(ch) ) )
	    {
		act( "You are zapped by $p.", ch, obj, NULL, TO_CHAR );
		act( "$n is zapped by $p.",   ch, obj, NULL, TO_ROOM );
		obj_from_char( obj );
		obj_to_room( obj, ch->in_room );
	    }
	}
    }

    return;
}



/*
 * Compute xp for a kill.
 * Also adjust alignment of killer.
 * Edit this function to change xp computations.
 */
int xp_compute( CHAR_DATA *gch, CHAR_DATA *victim )
{
    int align;
    int xp;
    int extra;
    int level;
    int number;
    int vnum;
    int victim_level; /* put to stop mass exp give outs Rotain */

    xp    = 300 - URANGE( -3, 3 - (victim->level*5/3), 6 ) * 50;
    align = gch->alignment - victim->alignment;

    if (victim->level > 1000 )
	victim_level = 1000;
    else
	victim_level = victim->level;

    if (IS_HERO(gch))
    {
	/* Avatars shouldn't be able to change their alignment */
	gch->alignment  = gch->alignment;
    }
    else if ( align >  500 )
    {
	gch->alignment  = UMIN( gch->alignment + (align-500)/4,  1000 );
	xp = 5 * xp / 4;
    }
    else if ( align < -500 )
    {
	gch->alignment  = UMAX( gch->alignment + (align+500)/4, -1000 );
    }
    else
    {
	gch->alignment -= gch->alignment / 4;
	xp = 3 * xp / 4;
    }

     /* 
      * Put in mob vnum that you don't want players to gain exp for
      * Rotain
      */
    if (IS_NPC(victim) && (vnum = victim->pIndexData->vnum) > 29000)
    {
	switch (vnum)
	{
	default:
	    break;
	case 29600:
	case 30001:
	case 30006:
	case 30007:
	case 30008:
	case 30009:
        case 30000:
	    return 0;
	}
    }

    if (IS_NPC(victim) && (IS_SET(victim->act, ACT_NOEXP) || IS_IMMORTAL(gch))) 
	return .40;

    /*
     * Adjust for popularity of target:
     *   -1/8 for each target over  'par' (down to -100%)
     *   +1/8 for each target under 'par' (  up to + 25%)
     */
    level  = URANGE( 0, victim_level, MAX_LEVEL - 1 );
    number = UMAX( 1, kill_table[level].number );
    extra  = victim->pIndexData->killed - kill_table[level].killed / number;
/*  xp    -= xp * URANGE( -2, extra, 8 ) / 8;
    xp    -= xp * URANGE( -2, extra, 6 ) / 8; */

    xp    -= xp * number_range( -2, 2 ) / 8;

    xp     = number_range( xp * 3 / 4, xp * 5 / 4 );
    xp     = UMAX( 0, xp );
    xp     = (xp * (victim_level+1) * 0.50);
    xp     = xp / 2; /* Put in cause players compaling to much exp :P */

/* Newbie Exp - Shows to player on exp payout and saves to pfile

    if ( (( get_age(gch) - 17) * 2 ) < 5 ) xp = xp * 3;
 
 * Uncomment if you want it in */
    if (!IS_NPC(gch))
    {
	gch->pcdata->score[SCORE_TOTAL_LEVEL] += victim->level;
	if (victim->level > gch->pcdata->score[SCORE_HIGH_LEVEL])
	    gch->pcdata->score[SCORE_HIGH_LEVEL] += victim->level;
	if (victim->level > 950) return 0;
	gch->pcdata->score[SCORE_TOTAL_XP] += xp;
	if (xp > gch->pcdata->score[SCORE_HIGH_XP])
	    gch->pcdata->score[SCORE_HIGH_XP] += xp;
    }
//	xp = xp *4/3;
    return xp;
}



void dam_message( CHAR_DATA *ch, CHAR_DATA *victim, int dam, int dt )
{
    static char * const attack_table[] =
    {
	"hit",
	"slice",  "stab",  "slash", "whip", "claw",
	"blast",  "pound", "crush", "grep", "bite",
	"pierce", "suck"
    };
    static char * const attack_table2[] =
    {
	"hits",
	"slices",  "stabs",  "slashes", "whips", "claws",
	"blasts",  "pounds", "crushes", "greps", "bites",
	"pierces", "sucks"
    };

    char buf1[512], buf2[512], buf3[512];
    const char *vs;
    const char *vp;
    const char *attack;
    const char *attack2;
    int damp;
    int bodyloc;
    bool critical = FALSE;
    char punct;

  if ( dt >= TYPE_ADD_AGG ) 
    {
	dt -= TYPE_ADD_AGG;
	while ( dt >= TYPE_ADD_AGG ) dt -= TYPE_ADD_AGG;
    }


         if ( dam ==   0 ) { vs = " miss";	vp = " misses";		}
    else if ( dam <=  50 ) { vs = " lightly";	vp = " lightly";	}
    else if ( dam <= 100 ) { vs = "";		vp = "";		}
    else if ( dam <= 250 ) { vs = " hard";	vp = " hard";		}
    else if ( dam <= 500 ) { vs = " very hard";	vp = " very hard";	}
    else if ( dam <= 750 ) { vs = " extremely hard";vp = " extremely hard";}
    else                   { vs = " incredibly hard";vp = " incredibly hard";}
    /* If victim's hp are less/equal to 'damp', attacker gets a death blow */
    if (IS_NPC(victim)) damp = 0;
    else                damp = -10;
    if ( (victim->hit - dam > damp ) || (dt >= 0 && dt < MAX_SKILL) ||
	(IS_NPC(victim) && IS_SET(victim->act, ACT_NOPARTS)) )
    {
    	punct   = (dam <= 250) ? '.' : '!';

    	if ( dt == TYPE_HIT && !IS_NPC(ch) && !IS_VAMPAFF(ch,VAM_CLAWS) )
    	{
	    if (dam == 0)
	    {
	    	sprintf( buf1, "$n%s $N%c",  vp, punct );
	    	sprintf( buf2, "You%s $N%c", vs, punct );
	    	sprintf( buf3, "$n%s you%c", vp, punct );
	    }
	    else
	    {
	    	sprintf( buf1, "$n hits $N%s%c",  vp, punct );
	    	sprintf( buf2, "You hit $N%s%c[%d]", vs, punct, dam );
	    	sprintf( buf3, "$n hits you%s%c[%d]", vp, punct, dam );
		critical = TRUE;
	    }
    	}
    	else
    	{
	    if ( dt == TYPE_HIT && !IS_NPC(ch) && IS_VAMPAFF(ch,VAM_CLAWS))
	    {
	    	attack  = attack_table[dt - TYPE_HIT + 5];
	    	attack2 = attack_table2[dt - TYPE_HIT + 5];
	    }
	    else if ( dt >= 0 && dt < MAX_SKILL )
	    {
	    	attack = skill_table[dt].noun_damage;
	    	attack2 = skill_table[dt].noun_damage;
	    }
	    else if ( dt >= TYPE_HIT
	    && dt < TYPE_HIT + sizeof(attack_table)/sizeof(attack_table[0]) )
	    {
	    	attack  = attack_table[dt - TYPE_HIT];
	    	attack2 = attack_table2[dt - TYPE_HIT];
	    }
	    else
	    {/*
	        bug( "Dam_mes\sage: bad dt %d.", dt );
	       */ dt  = TYPE_HIT;
	        attack  = attack_table[0];
	        attack2 = attack_table2[0];
	    }

	    if (dam == 0)
	    {
	    	sprintf( buf1, "$n's %s%s $N%c",  attack, vp, punct );
	    	sprintf( buf2, "Your %s%s $N%c",  attack, vp, punct );
	    	sprintf( buf3, "$n's %s%s you%c", attack, vp, punct );
	    }
		 else if (IS_SET(ch->newbits, NEW_MONKFLAME) && (dam == 0))
	    {
	    	sprintf( buf1, "$n's flaming %s%s $N%c[%d]", attack2, vp, punct, dam );
	    	sprintf( buf2, "Your flaming %s%s $N%c[%d]",  attack, vp, punct, dam );
	    	sprintf( buf3, "$n's flaming %s%s you%c[%d]", attack2, vp, punct, dam );
	    }
       


	    else
	    {
		if ( dt >= 0 && dt < MAX_SKILL )
		{
	    	    sprintf( buf1, "$n's %s strikes $N%s%c", attack2, vp, punct );
	    	    sprintf( buf2, "Your %s strikes $N%s%c[%d]",  attack, vp, punct, dam );
	    	    sprintf( buf3, "$n's %s strikes you%s%c[%d]", attack2, vp, punct, dam );
		}
	else if (IS_SET(ch->newbits, NEW_MONKFLAME))
            {
                sprintf( buf1, "$n's flaming %s hits $N%s%c[%d]", attack2, vp, punct, dam);
                sprintf( buf2, "Your flaming %s hits $N%s%c[%d]", attack, vp, punct, dam);
                sprintf( buf3, "$n's flaming %s hits you%s%c[%d]", attack2, vp, punct, dam);
            }


		else
		{
	    	    sprintf( buf1, "$n %s $N%s%c",  attack2, vp, punct );
	    	    sprintf( buf2, "You %s $N%s%c[%d]",  attack, vp, punct, dam );
	    	    sprintf( buf3, "$n %s you%s%c[%d]", attack2, vp, punct, dam );
		    critical = TRUE;
		}
	    }
        }
        act( buf1, ch, NULL, victim, TO_NOTVICT );
        act( buf2, ch, NULL, victim, TO_CHAR );
        act( buf3, ch, NULL, victim, TO_VICT );
	if (critical) critical_hit(ch,victim,dt,dam);
	return;
    }

    if ( dt == TYPE_HIT && !IS_NPC( ch ) && !IS_VAMPAFF(ch,VAM_CLAWS) 
	&&!IS_VAMPAFF(ch,VAM_FANGS))
    {
	damp=number_range(1,5);
	if ( damp == 1 )
	{
	    act("You ram your fingers into $N's eye sockets and rip $S face off.", ch, NULL, victim, TO_CHAR);
	    act("$n rams $s fingers into $N's eye sockets and rips $S face off.", ch, NULL, victim, TO_NOTVICT);
	    act("$n rams $s fingers into your eye sockets and rips your face off.", ch, NULL, victim, TO_VICT);
	    victim->fatal = 21;
	    make_part(victim,"face");
	}
	else if ( damp == 2 )
	{
	    act("You grab $N by the throat and tear $S windpipe out.", ch, NULL, victim, TO_CHAR);
	    act("$n grabs $N by the throat and tears $S windpipe out.", ch, NULL, victim, TO_NOTVICT);
	    act("$n grabs you by the throat and tears your windpipe out.", ch, NULL, victim, TO_VICT);
	    victim->fatal = 22;
            make_part(victim,"windpipe");
	}
	else if ( damp == 3 )
	{
	    act("You punch your fist through $N's stomach and rip out $S entrails.", ch, NULL, victim, TO_CHAR);
	    act("$n punches $s fist through $N's stomach and rips out $S entrails.", ch, NULL, victim, TO_NOTVICT);
	    act("$n punches $s fist through your stomach and rips out your entrails.", ch, NULL, victim, TO_VICT);
	    victim->fatal = 23;
             make_part(victim,"entrails");
	}
	else if ( damp == 4 )
	{
	    if (!IS_BODY(victim,BROKEN_SPINE))
		SET_BIT(victim->loc_hp[1],BROKEN_SPINE);
	    act("You hoist $N above your head and slam $M down upon your knee.\n\rThere is a loud cracking sound as $N's spine snaps.", ch, NULL, victim, TO_CHAR);
	    act("$n hoists $N above $s head and slams $M down upon $s knee.\n\rThere is a loud cracking sound as $N's spine snaps.", ch, NULL, victim, TO_NOTVICT);
	    act("$n hoists you above $s head and slams you down upon $s knee.\n\rThere is a loud cracking sound as your spine snaps.", ch, NULL, victim, TO_VICT);
            victim->fatal = 24;
	}
	else if ( damp == 5 )
	{
	    act("You lock your arm around $N's head, and give it a vicious twist.", ch, NULL, victim, TO_CHAR);
	    act("$n locks $s arm around $N's head, and gives it a vicious twist.", ch, NULL, victim, TO_NOTVICT);
	    act("$n locks $s arm around your head, and gives it a vicious twist.", ch, NULL, victim, TO_VICT);
	    if (!IS_BODY(victim,BROKEN_NECK))
	    {
		act("There is a loud snapping noise as your neck breaks.", victim, NULL, NULL, TO_CHAR);
		act("There is a loud snapping noise as $n's neck breaks.", victim, NULL, NULL, TO_ROOM);
		SET_BIT(victim->loc_hp[1],BROKEN_NECK);
	    }
            victim->fatal = 25;
	}
	return;
    }
    if ( dt >= 0 && dt < MAX_SKILL )
	attack = skill_table[dt].noun_damage;
    else if ( dt >= TYPE_HIT
    && dt < TYPE_HIT + sizeof(attack_table)/sizeof(attack_table[0]) )
	attack = attack_table[dt - TYPE_HIT];
    else
    {
	dt  = TYPE_HIT;
	attack  = attack_table[0];
    }

    if ( attack == "slash" || attack == "slice" )
    {
	damp=number_range(1,8);
	if ( damp == 1 )
	{
	    act("You swing your blade in a low arc, rupturing $N's abdominal cavity.\n\r$S entrails spray out over a wide area.", ch, NULL, victim, TO_CHAR);
	    act("$n swings $s blade in a low arc, rupturing $N's abdominal cavity.\n\r$S entrails spray out over a wide area.", ch, NULL, victim, TO_NOTVICT);
	    act("$n swings $s blade in a low arc, rupturing your abdominal cavity.\n\rYour entrails spray out over a wide area.", ch, NULL, victim, TO_VICT);
            victim->fatal = 26;
	    make_part(victim,"entrails");
	}
	else if ( damp == 2 )
	{
	    act("You thrust your blade into $N's mouth and twist it viciously.\n\rThe end of your blade bursts through the back of $S head.", ch, NULL, victim, TO_CHAR);
	    act("$n thrusts $s blade into $N's mouth and twists it viciously.\n\rThe end of the blade bursts through the back of $N's head.", ch, NULL, victim, TO_NOTVICT);
	    act("$n thrusts $s blade into your mouth and twists it viciously.\n\rYou feel the end of the blade burst through the back of your head.", ch, NULL, victim, TO_VICT);
            victim->fatal = 27;
	}
	else if ( damp == 3 )
	{
	    if (!IS_BODY(victim,CUT_THROAT))
		SET_BIT(victim->loc_hp[1],CUT_THROAT);
	    if (!IS_BLEEDING(victim,BLEEDING_THROAT))
	    	SET_BIT(victim->loc_hp[6],BLEEDING_THROAT);
	    act("Your blow slices open $N's carotid artery, spraying blood everywhere.", ch, NULL, victim, TO_CHAR);
	    act("$n's blow slices open $N's carotid artery, spraying blood everywhere.", ch, N

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

Site Stats

Snippets: 1791
Codebases: 571