fight.c

src/fight.c · 208.3 KB

From the archive GWLow2.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.                                                  *
 ***************************************************************************/

#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"
#include "warlock.h"

#define MONK_AUTODROP 11


/*
 * 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 ) );
void    check_arena     args( ( CHAR_DATA *ch, CHAR_DATA *victim ) );


/*
 * Control the fights going on.
 * Called periodically by update_handler.
 */
void violence_update( void )
{
    CHAR_DATA *ch;
    CHAR_DATA *ch_next;
    CHAR_DATA *emb;
    CHAR_DATA *victim;
    CHAR_DATA *rch;
    CHAR_DATA *rch_next;
    CHAR_DATA *mount;
    //OBJ_DATA  *obj;
  
    for ( ch = char_list; ch != NULL; ch = ch->next )
    {
        victim = ch->blinkykill; 
 	if (victim == NULL) continue;

	if (IS_SET(ch->flag3, AFF3_BLINK_1ST_RD))
	{
	    REMOVE_BIT(ch->flag3, AFF3_BLINK_1ST_RD);
	    SET_BIT(ch->flag3, AFF3_BLINK_2ND_RD);
	}
	else if (IS_SET(ch->flag3, AFF3_BLINK_2ND_RD))
	{

	    REMOVE_BIT(ch->flag3, AFF3_BLINK_2ND_RD);
	    REMOVE_BIT(ch->flag3, AFF3_BLINK_1ST_RD);

	    /* Has the victim left? */
	    if (victim->in_room != ch->in_room)
	    {
                SET_BIT(ch->extra,EXTRA_BLINKY);
		victim = 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;
	    }

                SET_BIT(ch->extra,EXTRA_BLINKY);

	    act("$n pops back into existence next to $N.", ch,
NULL,victim, TO_NOTVICT);
	    act("You pop back into existence next to $N.", ch, NULL,
victim, TO_CHAR);
	    act("$n pops back into existence next to you.", ch, NULL,
victim, TO_VICT);
	    set_fighting(ch, victim);
	    do_say(ch, "Muhahahahahaha");
            multi_hit(ch, victim, gsn_blinky);
	    multi_hit(ch, victim, gsn_blinky);
	    if (IS_SET(ch->newbits, THIRD_HAND) && get_eq_char(ch, WEAR_THIRD) != NULL )
	    multi_hit(ch, victim, gsn_blinky);
	    if (IS_SET(ch->newbits, FOURTH_HAND) && get_eq_char(ch, WEAR_FOURTH) != NULL)
	    multi_hit(ch, victim, gsn_blinky);
	    update_pos(victim);
	}
    }


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

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

        if (ch->rage > 0 && IS_CLASS(ch, CLASS_DEMON))
	    ch->rage--;

	if ( ch->embracing != NULL )
	{
	  emb = ch->embracing;
	  if ( emb == NULL ) ch->embracing = NULL;
	  if ( ch->in_room != emb->in_room )
	  {
	    if ( emb->embraced != NULL )
	    {
	      emb->embraced = NULL;
    	      ch->embracing = NULL;
	    }
	    else
	      ch->embracing = NULL;
	  }
	}

	if ( ch->embraced != NULL )
	{
          emb = ch->embraced;
	  if ( emb == NULL ) ch->embraced = NULL;
          if ( ch->in_room != emb->in_room )
          {
            if ( emb->embracing != NULL )
            {
              emb->embracing = NULL;
              ch->embraced   = NULL;
            }
	    else
	      ch->embraced = NULL;
          }
        }  
  
	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 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 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 ( ( 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_CLASS(ch, CLASS_VAMPIRE) || IS_CLASS(ch, CLASS_MONK) )&& ch->level < 7 && IS_SET(ch->act, PLR_WIZINVIS) )
	REMOVE_BIT(ch->act, PLR_WIZINVIS);


/*        if (!IS_CLASS(ch, CLASS_DEMON) && ch->alignment > 0
	 	&& !IS_NPC(ch) && ch->level > 2)
	{
	    OBJ_DATA *obj_next;

	    for ( obj = ch->in_room->contents; obj != NULL; obj = obj_next )
	    {
		obj_next = obj->next_content;
		if (IS_OBJ_STAT2(obj, ITEM_ATTACK_GOOD) && number_range(1, 3) == 1)
		{
                act("$p jumps into the air and slams into $n.", ch, obj, NULL, TO_ROOM);
                act("$p jumps into the air and slams into you.", ch, obj, NULL, TO_CHAR);
		    ch->hit -= number_range( 40, 60 );
                update_pos( ch );
		}
	    }
	}
*/
	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) && ch->cur_form == FRM_DROWSPIDER
	&& 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;

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

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

		/*
		 * NPC's assist NPC's of same type or 12.5% chance regardless.
		 */
		if ( IS_NPC(rch) && !IS_AFFECTED(rch, AFF_CHARM) )
		{
		    if ( rch->pIndexData == ch->pIndexData
		    ||   number_bits( 3 ) == 0 )
		    {
			CHAR_DATA *vch;
			CHAR_DATA *target;
			int number;

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

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

    

    return;
}



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

    if ( ch->position < POS_SLEEPING ) return;

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

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

	if (dt == gsn_shiroken) 
	{one_hit(ch, victim, dt, 1);
	if(ch->pcdata->powers[NPOWER_NINGENNO] >=4 )
	    spell_poison(gsn_poison,(ch->level*number_range(10,20)),ch,victim);
	return;}

    if ( dt == gsn_spiderform ) {
	for (x = 1; x < 9; x++)
	one_hit(ch,victim,dt,0);
    }

    if ( dt == gsn_fangs )
    {
        one_hit( ch, victim, dt, 1 );
        return;
    } 
    if ( dt== gsn_quills)
    {
   	 one_hit(ch,victim,dt,1);
    	 return;
    }
    if ( dt==gsn_venomtong)
    {
  	  one_hit(ch,victim,dt,1);
   	  return;
    }
    if ( dt==gsn_spiketail)
    {
	    one_hit(ch,victim,dt,1);
	    return;
    }  
    if ( dt==gsn_badbreath)
    {
	    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_cheapshot)
    {
	    send_to_char("You stun them with a shoulder charge!\n\r",ch);
	    send_to_char("You are stunned by a shoulder charge!\n\r",victim);
	  /*victim->position=POS_STUNNED;*/
	    one_hit(ch,victim,dt,1);    
	   /* victim->position=POS_STUNNED;
	    one_hit(ch,victim,dt,1);*/
	    one_hit(ch,victim,dt,1);
	    one_hit(ch,victim,dt,1);
	    return;
    } 
    if ( dt == gsn_buffet )
    {
        one_hit( ch, victim, dt, 1 );
        return;
    } 

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

   /* if (!IS_NPC(ch) && IS_AFFECTED(ch, AFF_PEACE))
    {
	send_to_char( "You are unable to attack them.\n\r", ch );
	return;
    }*/
    if( IS_NPC(ch) )
    {
        switch( ch->pIndexData->vnum ){
        case 30003:
        case 20050:
        case 30704:
        case 30703:
        case 10000:
        case 10001:
        case 10002:
        case 10003:
        case 10004:
		break;
        default:
	    {
	        if (!IS_NPC(victim) && IS_AFFECTED(victim, AFF_PEACE))
	        {
		    send_to_char( "You can't seem to attack them.\n\r", ch );
		    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;
		}
	    }
        }
    }


    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() == 5)
    {
	int stance = ch->stance[0];
	if (ch->stance[stance] >= 200)
	{
	    special_move(ch,victim);
	    return;
	}
    }

    unarmed = 0;
/*
    if (!IS_NPC(ch) && wieldorig == 0)
        {
            if      (countup == 0) unarmed = number_range(0,3);
            else if (countup == 1) unarmed = number_range(4,7);
            else                   unarmed = number_range(0,7);
            if ( !IS_NPC(ch) && !IS_AFFECTED(ch, AFF_POLYMORPH) &&
                ch->cmbt[unarmed] != 0 && wieldorig == 0 )
            {
                fightaction(ch,victim,ch->cmbt[unarmed], dt, wieldtype);
            }
        }
    else
*/

    if	( IS_SET(ch->act, AFF_HIDE ) ) REMOVE_BIT(ch->act, AFF_HIDE);
	if ( IS_SET( ch->flag2, VAMP_OBJMASK) )
    {
      act("You return to your normal form.",ch,NULL,NULL,TO_CHAR);
      sprintf(buf,"%s reforms as %s.\n\r",ch->morph, ch->name );
      act(buf,ch,NULL,NULL,TO_ROOM);
      free_string(ch->morph);
      free_string(ch->objdesc);
      ch->long_descr = str_dup("");
      REMOVE_BIT(ch->flag2, VAMP_OBJMASK);
      REMOVE_BIT(ch->affected_by, AFF_POLYMORPH);
    }

	one_hit( ch, victim, dt, wieldtype );

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

    /* Only want one spell per round from spell weapons...otherwise it's 
     * too powerful, and would unbalance player killing (as this is a PK mud).
     */

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

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

    if ( ch->fighting != victim || dt == gsn_backstab || dt == gsn_shiroken 
	|| dt == gsn_garotte || dt == gsn_headbutt || dt == gsn_circle )
	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++)
    {
/*
	if (!IS_NPC(ch) && wieldorig == 0)
	{
	    if      (countup == 0) unarmed = number_range(0,3);
	    else if (countup == 1) unarmed = number_range(4,7);
    	    else                   unarmed = number_range(0,7);
    	    if ( !IS_NPC(ch) && !IS_AFFECTED(ch, AFF_POLYMORPH) &&
		ch->cmbt[unarmed] != 0 && wieldorig == 0 )
	    {
		fightaction(ch,victim,ch->cmbt[unarmed], dt, wieldtype);
		continue;
	    }
	}
*/
	wieldtype = wieldorig;
        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 == 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 == 3 )
    {
        if ( wieldie == 2 || wieldie == 4)
          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 ), 0 );
    if ( victim == NULL || victim->position != POS_FIGHTING ) return;
    if (!IS_NPC(ch))
    {
	if (IS_VAMPAFF(ch,VAM_HORNS) 
		&& number_range(1,3) == 1)
	multi_hit( ch, victim, gsn_headbutt );
	if (IS_CLASS(ch, CLASS_ANGEL) && IS_ANGPOWER(ch, ANG_HALO)
                && number_range(1,3) == 1)      multi_hit( ch, victim, gsn_halo );

    }
	if (IS_CLASS(ch, CLASS_DEMON)  && IS_DEMAFF(ch,DEM_HORNS) 
		&& number_range(1,3) == 1)
	multi_hit( ch, victim, gsn_headbutt );

        if (IS_CLASS(ch, CLASS_DEMON)  && IS_DEMAFF(ch, DEM_TAIL)
		&& number_range(1,2) == 2)
	multi_hit( ch, victim, gsn_sweep );

	if (!IS_NPC(ch))
	if (IS_CLASS(ch, CLASS_NINJA) && ch->pcdata->powers[NPOWER_NINGENNO] >=5 && number_range(1,4) != 1)
	multi_hit(ch, victim, gsn_shiroken);


    if (!IS_NPC(ch))
    {
        if (IS_VAMPAFF(ch,VAM_TAIL)
                && number_range(1,2) == 1)
        multi_hit( ch, victim, gsn_sweep );
	if (IS_CLASS(ch, CLASS_DRAGON)	&& IS_SET(ch->pcdata->dragonaff, DRA_TAIL)) /*dragons*/
		multi_hit( ch, victim, gsn_sweep ); /*dragons*/
	if (IS_CLASS(ch, CLASS_DRAGON) && IS_SET(ch->pcdata->dragonaff, DRA_FROST_BREATH) && ( (number_range(1, 3) == 1) || IS_SET(ch->pcdata->dragonaff, DRA_LUCK))) /*dragons*/
		spell_frost_breath(skill_lookup( "frost breath" ),ch->pcdata->dragonage * 50, ch, victim ); /*dragons*/
	if (IS_CLASS(ch, CLASS_DRAGON) && IS_SET(ch->pcdata->dragonaff, DRA_FIRE_BREATH) && ( (number_range(1, 3) == 1) || IS_SET(ch->pcdata->dragonaff, DRA_LUCK))) /*dragons*/
		spell_fire_breath(skill_lookup( "fire breath" ),ch->pcdata->dragonage * 50, ch, victim ); /*dragons*/
   if (IS_CLASS(ch, CLASS_DRAGON) && IS_SET(ch->pcdata->dragonaff, DRA_LIGHTNING_BREATH) && ( (number_range(1, 3) == 1) || IS_SET(ch->pcdata->dragonaff, DRA_LUCK))) /*dragons*/
		spell_lightning_breath(skill_lookup( "lightning breath" ),ch->pcdata->dragonage * 50, ch, victim ); /*dragons*/
	if (IS_CLASS(ch, CLASS_DRAGON) && IS_SET(ch->pcdata->dragonaff, DRA_ACID_BREATH) && ( (number_range(1, 3) == 1) || IS_SET(ch->pcdata->dragonaff, DRA_LUCK))) /*dragons*/
		spell_acid_breath(skill_lookup( "acid breath" ),ch->pcdata->dragonage * 50, ch, victim ); /*dragons*/
	if (IS_CLASS(ch, CLASS_DRAGON) && IS_SET(ch->pcdata->dragonaff, DRA_GAS_BREATH) && ( (number_range(1, 3) == 1) || IS_SET(ch->pcdata->dragonaff, DRA_LUCK))) /*dragons*/
		spell_gas_breath(skill_lookup( "gas breath" ),ch->pcdata->dragonage * 50, ch, victim ); /*dragons*/
	if( IS_CLASS(ch, CLASS_DRAGON) && IS_SET(ch->pcdata->dragonaff, DRA_FANGS) && (number_range(1,3) == 1 || IS_SET(ch->pcdata->dragonaff, DRA_LUCK))) /*dragons*/
	    one_hit( ch, victim, ( TYPE_HIT + 10 ), 0 );/*dragons*/
    }          

    if (!IS_NPC(ch))
    {
        if (IS_VAMPAFF(ch,VAM_HEAD)
                && number_range(1,2) == 1)
        multi_hit( ch, victim, gsn_fangs );
    }        
   if (!IS_NPC(ch))
  {
   if (IS_SET(ch->newbits,NEW_QUILLS))
       multi_hit(ch,victim,gsn_quills);
    }

   if (!IS_NPC(ch)&& IS_CLASS(ch,CLASS_WEREWOLF))
   {
   if (IS_SET(ch->newbits,NEW_SLAM) && number_range(1,
ch->power[DISC_WERE_BEAR]/3)==1)
   multi_hit(ch,victim,gsn_cheapshot);
  }
    if (!IS_NPC(ch))
    {
        if (IS_VAMPAFF(ch,VAM_WINGS)
                && number_range(1,2) == 1)
        multi_hit( ch, victim, gsn_buffet );
    }        
    if (!IS_NPC(ch) && IS_CLASS(ch,CLASS_WEREWOLF)
                    && ch->power[DISC_WERE_RAPT] > 0)
    {
     multi_hit(ch,victim,gsn_rfangs);
    }
                    
    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->power[DISC_WERE_SPID] > 0)
	spell_poison( gsn_poison, (ch->level*number_range(5,10)),ch,victim );
    else if (!IS_NPC(ch) && IS_CLASS(ch, CLASS_DROW) && IS_SET(ch->pcdata->powers[1], DPOWER_DROWPOISON))
	spell_poison(gsn_poison,(ch->level*number_range(10,20)),ch,victim);
	else if (!IS_NPC(ch) && IS_CLASS(ch, CLASS_NINJA) &&
	ch->pcdata->powers[NPOWER_NINGENNO] >=5)
	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() > 95)
	{
        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;

    if ( IS_NPC(ch) )
    {
	if (ch->level >= 50) count += 1;
	if (ch->level >= 100) count += 1;
	if( ch->pIndexData->hitsizedice > 20) count += ch->pIndexData->hitsizedice;
	else count += ch->pIndexData->hitsizedice;
	return count;
    }

 if (IS_NPC(victim))
 {
    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_TIGER) && number_percent() > 
	ch->stance[STANCE_TIGER] * 0.5) count += 1;
    else if ( IS_STANCE(ch, STANCE_WOLF) && number_percent() >
       ch->stance[STANCE_WOLF] * .5) count += 2;
    else if ( IS_STANCE(ch, STANCE_XKILLA) && number_percent() >
       ch->stance[STANCE_XKILLA] * 1) count += 4;
    if (!IS_NPC(ch))
    {   
        if ( IS_CLASS(ch, CLASS_VAMPIRE) && ch->power[DISC_VAMP_CELE] > 0)
                count += .5;
        else if ( IS_CLASS(ch, CLASS_VAMPIRE) && ch->power[DISC_VAMP_CELE] > 5)
                count += .5;
	else if ( IS_CLASS(ch, CLASS_VAMPIRE) && ch->power[DISC_VAMP_CELE] > 7)
		count += .5;
	else if ( IS_CLASS(ch, CLASS_VAMPIRE) && ch->power[DISC_VAMP_CELE] > 9)
		count += .5;
    	else if (IS_CLASS(ch, CLASS_WEREWOLF) && ch->power[DISC_WERE_LYNX] > 2 )
		count += 2;
	else if ( !IS_NPC(ch) && IS_CLASS(ch, CLASS_DEMON) && IS_DEMPOWER( ch, DEM_SPEED) )
		count += 2;   	
	else if (IS_CLASS(ch, CLASS_DROW) && (IS_SET(ch->special, SPC_DROW_WAR) || ch->generation < 3))
		count += 1;
        else if ( !IS_NPC(ch) && IS_CLASS(ch, CLASS_ANGEL) && IS_ANGPOWER(ch, ANG_SPEED) )
                count += 4;

    }

	if (!IS_NPC(ch) && IS_CLASS(ch, CLASS_DROW) && 
	IS_SET(ch->pcdata->powers[1],DPOWER_SPEED))
	count += 1;

    if ( !IS_NPC(ch) && IS_CLASS(ch,CLASS_WEREWOLF) && ch->power[DISC_WERE_BOAR] > 6)
    {
	if( ch->move /2000 > 10 ) 
	    count += 10;
	else
	    count += ch->move/2000;
    }
	if (!IS_NPC(ch) && IS_CLASS(ch, CLASS_NINJA) && ch->pcdata->powers[NPOWER_CHIKYU] >= 3)
		count += 2;

    if ( IS_ITEMAFF(ch, ITEMA_SPEED) ) count += 2;
  }

  else
  {
    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_TIGER) && number_percent() > 
	ch->stance[STANCE_TIGER] * 0.5) count += 1;
    else if ( IS_STANCE(ch, STANCE_XKILLA) && number_percent() >
        ch->stance[STANCE_XKILLA] * 0.5) count += 1;
    

    if (!IS_NPC(ch))
    {   
           if ( IS_CLASS(ch, CLASS_VAMPIRE) && ch->power[DISC_VAMP_CELE] > 0)
            count += 1;
      else if ( IS_CLASS(ch, CLASS_VAMPIRE) && ch->power[DISC_VAMP_CELE] > 5)
            count += 1;
	else if ( IS_CLASS(ch, CLASS_VAMPIRE) && ch->power[DISC_VAMP_CELE] > 7)
		count += 1;
	else if ( IS_CLASS(ch, CLASS_VAMPIRE) && ch->power[DISC_VAMP_CELE] > 9)
		count += 1;
	else if ( IS_CLASS(ch, CLASS_MONK) && ch->monkab[COMBAT] > 0 )
		count += ch->monkab[COMBAT];
    	else if (IS_CLASS(ch, CLASS_WEREWOLF) && ch->power[DISC_WERE_LYNX] > 2 )
		count += 1;
        else if (ch->power[DISC_DAEM_ATTA] > 0)
		count += ch->power[DISC_DAEM_ATTA] / 2;
	else if (IS_CLASS(ch, CLASS_DROW) && (IS_SET(ch->special, SPC_DROW_WAR) || ch->generation < 3))
		count += 1;

    }

    if ( !IS_NPC(ch) && IS_CLASS(ch,CLASS_WEREWOLF) && ch->power[DISC_WERE_BOAR] > 6)
    {
    count += ch->move/4000;
    }

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

    if (victim->power[DISC_VAMP_CELE] >= 3)
        count -= victim->power[DISC_VAMP_CELE] / 3;
    if (victim->power[DISC_WERE_MANT] >= 3)
	  count -= victim->power[DISC_WERE_MANT] / 3;
    if (victim->power[DISC_DAEM_ATTA] > 0)
	count -= victim->power[DISC_DAEM_ATTA] /2;
    if (number_range(1,4) == 2)
        count -= 1;
 }
    if ( count < 1)
       count = 1;


    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;
    char buf[MAX_STRING_LENGTH];
    int victim_ac;
    int thac0;
    int thac0_00;
    int thac0_32;
    int dam, wdam;
    int diceroll;
    int level;
    int attack_modify;
//  int stance;
    int 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) )
    {
	if (IS_AFFECTED( ch, AFF_PEACE) && ch->fighting != NULL)
	REMOVE_BIT(ch->affected_by, AFF_PEACE);
    }
    
    if ( !IS_NPC(victim) )
    {
	if (IS_AFFECTED(victim, AFF_PEACE) && victim->fighting != NULL)
	REMOVE_BIT(victim->affected_by, AFF_PEACE);
    }

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

    if (!IS_NPC(victim) && IS_AFFECTED(victim, AFF_PEACE))
    {
	send_to_char( "You can't seem to attack them.\n\r", ch );
	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 (ch->power[DISC_DAEM_HELL] > 3 && number_range(1, 50-ch->generation) == 1
	&& ch->fighting != NULL)
    {
        wdam = dice(ch->generation + 5, 20);
	sprintf(buf,"#1%s breathes out a cloud of fire at you#n.[%d]", ch->name, wdam);
	sprintf(buf,"#1%s breathes out a cloud of fire at %s#n.",ch->name,victim->name );
	sprintf(buf,"#1You breathe out a cloud of fire at %s#n.[%d]",victim->name, wdam );
        victim->hit -= wdam;
	update_pos(victim);
    }

    /*
     * Figure out the type of damage message.
     */
    if (handtype == 8)
    {
	wield = get_eq_char( ch, WEAR_FOURTH );
	right_hand = 8;
    }
    else if (handtype == 4)
    {
	wield = get_eq_char( ch, WEAR_THIRD );
	right_hand = 4;
    }
    else if (handtype == 2)
    {
    	wield = get_eq_char( ch, WEAR_HOLD );
	right_hand = 2;
    }
    else if (handtype == 0) 
    {
	wield = NULL;
	right_hand = 0;
    }
    else
    {
    	wield = get_eq_char( ch, WEAR_WIELD );
	right_hand = 1;
    }

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

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

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

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

    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 / 2, ch->level * 3 / 2 );
	if ( wield != NULL )
	    dam += dam * 0.5;
    }
    else
    {
	if( IS_CLASS( ch, CLASS_DRAGON))
		dam = number_range( 100, 500 );/*not sure about range, email me a better if you find*/
	else if ( wield != NULL && wield->item_type == ITEM_WEAPON )
	    dam = dice( wield->value[1], wield->value[2] );
	else if ( IS_VAMPAFF(ch, VAM_CLAWS) && IS_GAR1(ch, WOLF_RAZORCLAWS))
            dam = dice( 25, 35 ); 
	else if ( IS_VAMPAFF(ch,VAM_CLAWS))
	    dam = dice( 10, 20 );
	else if ( IS_SET(ch->newbits, NEW_MONKADAM))
	    dam = dice( 10, 25 );
	else
	    dam = dice( 1, 4 );
    }

    /*
     * Bonuses.
     */
    dam += char_damroll(ch);
    if ( !IS_AWAKE(victim) )
	dam *= 2;

	if ( IS_CLASS(ch, CLASS_MAGE) )
	{
	    if ( IS_SET(ch->mflags, MAGE_TELEKINETICS) )
	      dam *= 1.4;
	    if ( IS_SET(ch->mflags, MFLAGS_DIMMAK) )
	      dam *= 1.3;
	    if ( ch->spheres[MENT] >= 1 )
	      dam *= 1 + ( ch->spheres[MENT] *.2 );
	}

    else if ( !IS_NPC(ch) && IS_CLASS(ch, CLASS_ANGEL))
    {
      if ( IS_ANGPOWER(ch, ANG_STRENGTH) && !IS_ANGPOWER(ch, ANG_HALO) && !IS_EVIL(victim)) dam *= 1.75;
      else if ( IS_ANGPOWER(ch, ANG_STRENGTH) && IS_ANGPOWER(ch, ANG_HALO) && IS_EVIL(victim) ) dam *= 4;
      else if ( IS_ANGPOWER(ch, ANG_HALO) && !IS_ANGPOWER(ch, ANG_STRENGTH) && IS_EVIL(victim) ) dam *= 2.5;
      else dam *= 1.5;
   }


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


    /* Other Resistances */
   
    if (IS_ITEMAFF(victim, ITEMA_RESISTANCE))
	    dam /= 2;
	if ( IS_CLASS(victim, CLASS_MAGE) )
	{
	    if ( victim->spheres[MENT] >= 1 )
	      dam /= 2;
        }
       
    /* damage reduction */
    if ( dam > 1000)
	dam = (dam - 1000)/2 + 312;
    if ( dam > 1500)
	dam = (dam - 1500)/2 + 427;


    if ( dam <= 0 )
	dam = 1;

    if ( !IS_NPC(ch) && IS_CLASS(ch, CLASS_DEMON) && 
		IS_DEMPOWER(ch, DEM_MIGHT) )
	dam *= 1.1;

	if( IS_CLASS(ch, CLASS_DRAGON) && IS_SET(ch->pcdata->dragonaff, DRA_TERROR ))/*dragons*/
	{/*dragons*/
		dam *= 2.5;/*dragons*/
	}/*dragons*/

    if (!IS_NPC(ch) && IS_CLASS(ch, CLASS_WEREWOLF)
	&& ch->power[DISC_WERE_BEAR] > 5)
       dam *= 1.2;
     
    if (!IS_NPC(victim) && IS_CLASS(victim, CLASS_WEREWOLF)
	&& ch->power[DISC_WERE_LUNA] > 9)
       {
	int luna;
	luna = number_range(1,50);
	if (luna == 10 || luna == 20 || luna == 30 || luna == 40 || luna == 50)
        {
	stc("#3You absorb your opponents damage#n.\n\r",victim);
	stc("#3Your opponent absorbs your damage#n.\n\r",ch);
	dam = 0;
        }
       }

 if (!IS_NPC(ch) && wield != NULL)
 {

    if (number_range(1,6) == 2)
    {
    	if (ch->fighting == victim && IS_WEAP(wield,WEAPON_VAMPIRIC))
	{
	    wdam = number_range(1,wield->level / 5 + 1);
	    act("$p draws life from $n.",victim,wield,NULL,TO_ROOM);
	    act("You feel $p drawing your life away.",
		victim,wield,NULL,TO_CHAR);
	    victim->hit -= wdam;
	    update_pos( victim );
	    ch->alignment = UMAX(-1000,ch->alignment - 1);
	    ch->hit += wdam/2;
	}

	if (ch->fighting == victim && (IS_WEAP(wield,WEAPON_FLAMING)
		|| IS_WEAP(wield, WEAPON_ELE_FLAME) )  )
	{
	    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);
	    fire_effect( (void *) victim,wield->level/2,wdam,TARGET_CHAR);
	    victim->hit -= wdam;
	    update_pos( victim );
	}

	if (ch->fighting == victim && (IS_WEAP(wield,WEAPON_FROST)
		|| IS_WEAP(wield, WEAPON_ELE_WATER) ) )
	{
	    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);
	    cold_effect(victim,wield->level/2,wdam,TARGET_CHAR);
	    victim->hit -= wdam;
	    update_pos( victim );
	}

	if (ch->fighting == victim && IS_WEAP(wield, WEAPON_ELE_EARTH) )
	{
	    wdam = number_range(1,wield->level / 5 + 2);
	    act("$p covers $n in acid.",victim,wield,NULL,TO_ROOM);
	    act("The corrosive touch of $p surrounds you with acid.",
		victim,wield,NULL,TO_CHAR);
	    acid_effect(victim,wield->level/2,wdam,TARGET_CHAR);
	    victim->hit -= wdam;
	    update_pos( victim );
	}

	if (ch->fighting == victim && (IS_WEAP(wield,WEAPON_SHOCKING)
		|| IS_WEAP(wield, WEAPON_ELE_AIR) ) )
	{
	    wdam = number_range(1,wield->level/5 + 2);
	    act("$n is struck by lightning from $p.",victim,wield,NULL,TO_ROOM);
	    act("You are shocked by $p.",victim,wield,NULL,TO_CHAR);
	    shock_effect(victim,wield->level/2,wdam,TARGET_CHAR);
	    victim->hit -= wdam;
	    update_pos( victim );
      }

	if (ch->fighting == victim && IS_WEAP(wield, WEAPON_SUNBLADE))
	{
	    wdam = number_range(wield->level/2, wield->level+1);
	    if (victim->alignment > -100)
		wdam = 0;
	    if (victim->alignment > -300)
		wdam = wdam / 2;
	    if (victim->alignment == -1000)
		wdam *= 2;
	    if (victim->class == CLASS_VAMPIRE)
		wdam *= 4;
	    if (wdam > 0)
	    {
	    act("$n's flesh is seared by the radiant aura of $p.",victim,wield,NULL,TO_ROOM);
	    act("Your flesh is seared by the radiant aura of $p.",victim,wield,NULL,TO_CHAR);
	    victim->hit -= wdam;
	    update_pos( victim );
	    ch->alignment = UMAX(-1000,ch->alignment + 1);
	    }
	}

	if (ch->fighting == victim 
		&& IS_WEAP(wield, WEAPON_DRAGONLANCE))
	{
	    wdam = number_range(wield->level/2, wield->level+1)*4;
		wdam = 0;
	    if (wdam > 0)
	    {
	    act("$n's flesh is torn apart by $p.",victim,wield,NULL,TO_ROOM);
	    act("Your flesh is torn apart by $p.",victim,wield,NULL,TO_CHAR);
	    victim->hit -= wdam;
	    update_pos( victim );
	    }
	}

	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_NOTVICT);
	    victim->hit -= wdam;
	    update_pos( victim );
	}
     }
  }

    if ( number_range( 1,5 ) == 3 )
    {
	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_NOTVICT);
            victim->hit -= wdam;
            update_pos( victim );
        }
    }

  if ( !IS_NPC(ch) && IS_CLASS(ch, CLASS_MONK) )
  {
    if (ch->chi[CURRENT] > 0 && ch->chi[CURRENT] < 3 )
	dam *= 1.3;
    if (ch->chi[CURRENT] > 2 && ch->chi[CURRENT] < 7 )
	dam *= ((ch->chi[CURRENT]) / 2);
  }

    if ( dt == gsn_garotte )
	dam *= (number_range(3,5));
   
    if ( dt == gsn_backstab ) 
	if (IS_CLASS(ch, CLASS_NINJA) && !IS_NPC(ch) && ch->pcdata->powers[NPOWER_NINGENNO] >=2)
	dam *= number_range(4,8);
	else if( IS_CLASS(ch, CLASS_DROW)){
	dam += number_range(100,1000);
	dam *= number_range(7,10);
	}
	else
	dam *= number_range(2,4);

	if (dt == gsn_circle)
	dam *= number_range(2,4);

    dam = cap_dam(ch,victim,dam);

    if( IS_NPC(ch) && ch->pIndexData->hitplus > 3) dam *=3;
    else if( IS_NPC(ch) && ch->pIndexData->hitplus > 0 ) dam *= ch->pIndexData->hitplus;

    if( IS_NPC(victim))
    {
	if( victim->pIndexData->hitnodice > 100 ) victim->pIndexData->hitnodice = 0;
	dam = dam * (100 - victim->pIndexData->hitnodice) / 100;
    }

    attack_modify = dice(1, 100);
    randomize_damage(ch,dam,attack_modify);
    damage( ch, victim, dam, dt );

    if (IS_SET(victim->newbits, NEW_LWRATH) && dt != gsn_garotte)
    {
    act("You absorb the damage and $n is struck by Luna's Wrath!", ch, NULL, victim, TO_VICT);
    act("$N absorbs $n's hit and $n is struck by Luna's Wrath!", ch, NULL, victim, TO_NOTVICT);
       if (!IS_NPC(ch))
    act("$n absorbs your damage and you are struck by Luna's Wrath!", ch, NULL, victim, TO_CHAR);
      ch->hit -= 250;
      victim->hit += 500;
     if (victim->hit > victim->max_hit)
      victim->hit = victim->max_hit;
      REMOVE_BIT(victim->newbits, NEW_LWRATH);
    }


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

int randomize_damage( CHAR_DATA *ch, int dam, int am )
{
    dam = dam * (am + 50) / 100;
    return dam;
}

int cap_dam(CHAR_DATA *ch, CHAR_DATA *victim, int dam)
{
    
    if (is_safe(ch, victim))
	return 0;

    if (dam > 80)
	dam = (dam - 80) / 2 + 80;

    if (!IS_NPC(victim) && victim->pcdata->condition[COND_DRUNK] > 10)
	dam /= 2;
	
	if (!IS_NPC(victim) && IS_CLASS(victim, CLASS_DROW)) {
	if (IS_SET(victim->pcdata->powers[1], DPOWER_TOUGHSKIN))
	dam /= 2;
	}

    /* Vampire protean 7 (flesh of lava) reduces damage */
    if (victim->power[DISC_VAMP_PROT] >= 10)
    {
  	dam *= 2;
	dam /= 3;
    }

    /* body of stone */
    if (victim->monkab[BODY] >= 2 )
    {
	dam *= 2;
	dam /= 3;
    }

    /* Monk Chi */
    if (victim->chi[CURRENT] > 0 )
    {
	dam *= (100 - (victim->chi[CURRENT] * 8) );
	dam /= 100;
    }

    if (victim->power[DISC_DAEM_IMMU] > 0)
    {
	dam *= (100 - (victim->power[DISC_DAEM_IMMU] * 3.7));
	dam /= 100;
    }

    if ( !IS_NPC(victim) && IS_CLASS(victim, CLASS_ANGEL)
    && IS_ANGPOWER( victim, ANG_TOUGHNESS)) dam /= 2;


    /* Vampire fortitude reduces damage */
    if (victim->power[DISC_VAMP_FORT] > 0)
    {
        dam *= (100 - (victim->power[DISC_VAMP_FORT] * 8));
        dam /= 100;
    }

	if (!IS_NPC(victim))
	if (victim->pcdata->powers[NPOWER_CHIKYU] >= 1 && IS_CLASS(victim,CLASS_NINJA))
	{
	dam /= 2;
	}

	
        if (!IS_NPC(victim))
        if (victim->pcdata->powers[NPOWER_CHIKYU] >= 1 && IS_CLASS(victim,CLASS_MAGE))
        {
        dam /= 2;
        }	

	else if ( !IS_NPC(victim) && IS_CLASS(victim, CLASS_DEMON) 
		 && IS_DEMPOWER( victim, DEM_TOUGH))
        {
          dam *= 50;
          dam /= 100;
        }

    if (victim->power[DISC_WERE_BOAR] > 2)
    {
	dam *= 50;
        dam /= 100;
    }

    if ( IS_GAR1(victim, WOLF_COCOON) )
        dam /= 1.5;

    /* Vampires should be tougher at night and weaker during the day. */
    if ( !IS_NPC(ch) && IS_CLASS(ch, CLASS_VAMPIRE) )
    {
        if (weather_info.sunlight == SUN_LIGHT && dam > 1)
            dam /= 1.5;
        else if (weather_info.sunlight == SUN_DARK)
            dam *= 1.5;
    }

    if (dam >= 2000)
        dam = dam - (dam / number_range(3,10) + number_range(10,30));

    if (!IS_NPC(victim))
    {
	dam = dam + (dam / number_range(2,5) + number_range(10,50));
	dam *= (number_range(2,4) * number_range(2,3) / number_range(4,6));
    }

    if (dam <= 0)
	dam = 1;
                                                                               
    if (dam > 30000) dam = 30000;                                               

    if ( dam > ch->damcap[DAM_CAP] )
      dam = number_range( (ch->damcap[DAM_CAP] - 200), (ch->damcap[DAM_CAP] + 100) );

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

    return dam;
}

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

bool can_bypass( CHAR_DATA *ch, CHAR_DATA *victim )
{
    if (IS_NPC(ch) || IS_NPC(victim)) return FALSE;
    else if (IS_STANCE(ch, STANCE_VIPER)) return TRUE;
    else if (IS_STANCE(ch, STANCE_MANTIS)) return TRUE;
    else if (IS_STANCE(ch, STANCE_TIGER)) return TRUE;
    else if (IS_STANCE(ch, STANCE_WOLF)) return TRUE;
    else if (IS_STANCE(ch, STANCE_XKILLA)) 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))
	{
		if (weather_info.sunlight == SUN_DARK)
		max_dam += 500;
		
		if (IS_SET(ch->newbits, NEW_DROWHATE))
		max_dam += 750;
	}
else if ((IS_CLASS(ch, CLASS_DEMON) || IS_SET(ch->special,
SPC_CHAMPION)) &&
	    ch->in_room != NULL)
	{
	    if (ch->in_room->vnum == 30000) max_dam = 10000; /* was5000Rotain*/
	    max_dam += (ch->pcdata->stats[DEMON_POWER] * 20);
	}	

	if (IS_CLASS(ch, CLASS_DRAGON))
	{
		max_dam += ch->pcdata->dragonage * 500;
	}

	if (IS_CLASS(ch, CLASS_MONK))
	    max_dam +=  (ch->monkab[COMBAT] * 100);
	if (IS_CLASS(ch, CLASS_MONK) && ch->chi[CURRENT] > 0 )
	    max_dam += ch->chi[CURRENT] * 200;
        if (IS_CLASS(ch, CLASS_ANGEL) && IS_ANGPOWER(ch, ANG_STRENGTH)) max_dam += 3000;

	else if (IS_CLASS(ch, CLASS_VAMPIRE))
	{
	     max_dam = 1500;

	    max_dam += (ch->rage * 10);
            if (ch->power[DISC_VAMP_POTE] > 0) 
	         max_dam += (ch->power[DISC_VAMP_POTE] * 125 * 2);
	    
	    if( ch->pcdata->rank == AGE_TRUEBLOOD)  max_dam += 1000;
	    else if( ch->pcdata->rank == AGE_LA_MAGRA) max_dam += 750;
	    else if (ch->pcdata->rank == AGE_METHUSELAH) max_dam += 400;
	    else if (ch->pcdata->rank == AGE_ELDER) max_dam += 250;
	    else if (ch->pcdata->rank == AGE_ANCILLA) max_dam += 125;
	
	if (ch->generation == 13)
          max_dam += 75;
         else if (ch->generation ==12)
          max_dam += 100;
         else if (ch->generation ==11)          
         max_dam += 150;
          else if (ch->generation == 10)
          max_dam += 200;
          else if (ch->generation == 9)
          max_dam += 250;
  	else if (ch->generation == 8)
          max_dam += 300;
          else if (ch->generation == 7)
          max_dam += 350;
        else if (ch->generation == 6)
          max_dam += 400;
        else if (ch->generation == 5)
          max_dam += 450;
        else if (ch->generation  == 4)
          max_dam += 500;
	else if (ch->generation  == 3)
          max_dam += 550;
	else if (ch->generation  == 2)
          max_dam += 600;


	}
	else if (IS_CLASS(ch, CLASS_NINJA)) 
	{
	max_dam += (ch->rage * 5);
	if(ch->pcdata->powers[NPOWER_CHIKYU] >=6 &&
	ch->pcdata->powers[HARA_KIRI] > 0) 
	max_dam += 500;
	if (ch->pcdata->powers[NPOWER_CHIKYU] >=2)
	max_dam += 500;
	}
	else if (IS_SET(ch->special, SPC_WOLFMAN))
	{
	    if      (ch->generation < 2) max_dam = 2000;
	    else if (ch->generation < 3) max_dam = 1900;
	    else if (ch->generation < 4) max_dam = 1800;
	    else                      max_dam = 1700;

	    max_dam += ch->rage;

          if (ch->power[DISC_WERE_LUNA] > 6
	    && (weather_info.sunlight == SUN_DARK))
            max_dam += 400;
	}
        
	else if (IS_CLASS(ch, CLASS_DEMON)) max_dam += 500;
	else if (IS_SET(ch->special, SPC_CHAMPION)) max_dam += 250;
	
	if (ch->pcdata->souls >= 10)
	max_dam += 500;

	
	if ( ch->generation > 0 && IS_CLASS(ch, CLASS_DEMON))
	{
  	  max_dam += (ch->generation * 20);
        }

	else if (IS_CLASS(ch, CLASS_HIGHLANDER) && (get_eq_char(ch, WEAR_WIELD) != NULL))
        {
            int wpn = ch->wpn[1];
                    max_dam += wpn;
		max_dam += ch->race*40;
        }
   }
        if (IS_ITEMAFF(ch, ITEMA_ARTIFACT)) max_dam += 500;

	if (IS_ITEMAFF(victim, ITEMA_ARTIFACT)) max_dam += 500;

	if (IS_NPC(victim) || victim->stance[0] != STANCE_MONKEY )
	{
	    if      (ch->stance[0] == STANCE_BULL)   max_dam += 250;
	    else if (ch->stance[0] == STANCE_DRAGON) max_dam += 300;
            else if (ch->stance[0] == STANCE_WOLF)   max_dam += 500;
	    else if (ch->stance[0] == STANCE_TIGER)  max_dam += 350;
	    else if (ch->stance[0] == STANCE_XKILLA) max_dam += 750;
	}

    /* Max Dam Reductions */
    /* Werewolves */

    if (!IS_NPC(victim))
    {
	int silver_tol = (victim->siltol * 2.5);
	if (IS_CLASS(victim, CLASS_WEREWOLF) && 
	    IS_ITEMAFF(ch, ITEMA_RIGHT_SILVER))
	    max_dam += (250 - silver_tol);
	if (IS_CLASS(victim, CLASS_WEREWOLF) && 
	    IS_ITEMAFF(ch, ITEMA_LEFT_SILVER))
	    max_dam += (250 - silver_tol);
    	
        /* Vampies */
	if (!IS_NPC(ch) && (IS_CLASS(victim, CLASS_VAMPIRE)))
 	    max_dam -= (victim->power[DISC_VAMP_FORT] * 100); 

	if (IS_NPC(ch) || ch->stance[0] != STANCE_MONKEY)
	{
	    if      (victim->stance[0] == STANCE_CRAB)    max_dam -= 250;
	    else if (victim->stance[0] == STANCE_DRAGON)  max_dam -= 250;
	    else if (victim->stance[0] == STANCE_SWALLOW) max_dam -= 250;
	}

if ((IS_CLASS(victim,CLASS_DEMON) || IS_SET(victim->special,SPC_CHAMPION)) 
	    && victim->in_room != NULL && victim->in_room->vnum == 30000)
	    max_dam *= 0.2;
}

    if (max_dam < 3000) max_dam = 3000;
    if (max_dam > 3500) max_dam = 3500;
    if (ch->level >= LEVEL_BUILDER)
    max_dam = 30000;
    ch->damcap[DAM_CAP] = max_dam;
    ch->damcap[DAM_CHANGE] = 0;
    return;
}

int check_immune(CHAR_DATA *ch, int dam_type)
{
    int immune, def;
    int bit;

    immune = -1;
    def = IS_NORMAL;

    if (dam_type == DAM_NONE)
	return immune;

    /* Firstly, dDo the backbone for each race, and then do the powers,
	which are not at all race specific - so that ie, eladrin can
	learn protean and be immune to fire! */

    /* Eladrin aura deals with itself, as it is switched on and off
	and removes and sets the bits in both */

    if (ch->class == CLASS_VAMPIRE)
    {
	/* They are resistant to cold */
	if (dam_type == DAM_COLD) immune = IS_RESISTANT;
 	/* They are vulnerable to drowning */
	if (dam_type == DAM_DROWNING) immune = IS_VULNERABLE;
	/* They are vulnerable to fire */
	if (dam_type == DAM_FIRE) immune = IS_VULNERABLE;
    }

    /* Firstly, we'll do flesh of lava! */
    if (ch->power[DISC_VAMP_PROT] >= 7
        && dam_type == DAM_FIRE) immune = IS_RESISTANT;

    /* The corruption discipline */
    if (dam_type == DAM_POISON && ch->power[DISC_DAEM_CORR] >= 3)
	immune = IS_DIMMUNE;
    if (dam_type == DAM_POISON && ch->power[DISC_DAEM_CORR] >= 1)
	immune = IS_RESISTANT;

    /* The hellfire discipline */
    if (dam_type == DAM_FIRE && ch->power[DISC_DAEM_HELL] >= 2)
	immune = IS_DIMMUNE;
    if (dam_type == DAM_FIRE && ch->power[DISC_DAEM_HELL] >= 1)
	immune = IS_RESISTANT;

    /* The geluge discipline */
    if (dam_type == DAM_COLD && ch->power[DISC_DAEM_GELU] >= 4)
	immune = IS_DIMMUNE;
    if (dam_type == DAM_COLD && ch->power[DISC_DAEM_GELU] >= 1)
	immune = IS_RESISTANT;

    /* Fortitude level 1 for vampires */
    if (dam_type == DAM_POISON && ch->power[DISC_VAMP_FORT] >= 1)
	immune = IS_RESISTANT;

    /* Returns immune if it has been changed at all ! */
    if (immune != -1) return immune;

    
    /* set bits to check -- VULN etc. must ALL be the same or this will
fail */
    switch (dam_type)
    {
	case(DAM_BASH):         bit = DIMM_BASH;         break;
	case(DAM_PIERCE):       bit = DIMM_PIERCE;       break;
	case(DAM_SLASH):        bit = DIMM_SLASH;        break;
	case(DAM_FIRE):         bit = DIMM_FIRE;         break;
	case(DAM_COLD):         bit = DIMM_COLD;         break;
	case(DAM_LIGHTNING):    bit = DIMM_LIGHTNING;    break;
	case(DAM_ACID):         bit = DIMM_ACID;         break;
	case(DAM_POISON):       bit = DIMM_POISON;       break;
	case(DAM_NEGATIVE):     bit = DIMM_NEGATIVE;     break;
	case(DAM_HOLY):         bit = DIMM_HOLY;         break;
	case(DAM_ENERGY):       bit = DIMM_ENERGY;       break;
	case(DAM_MENTAL):       bit = DIMM_MENTAL;       break;
	case(DAM_DISEASE):      bit = DIMM_DISEASE;      break;
	case(DAM_DROWNING):     bit = DIMM_DROWNING;     break;
	case(DAM_LIGHT):        bit = DIMM_LIGHT;        break;
	case(DAM_CHARM):        bit = DIMM_CHARM;        break;
	case(DAM_SOUND):        bit = DIMM_SOUND;        break;
	default:                return def;
    }


    if (immune == -1)
	return def;
    else
	return immune;
}


/*
 * Inflict damage from a hit.
 */
bool damage_old( CHAR_DATA *ch, CHAR_DATA *victim, int dam, int dt, int dam_type, bool show ) 
{
    OBJ_DATA *corpse;
    bool immune;
    char buf[MAX_STRING_LENGTH];

    if ( victim->position == POS_DEAD )
	return FALSE;
    
    /* damage reduction */
    if ( dam > 35)
	dam = (dam - 35)/2 + 35; 
    if ( dam > 80)
	dam = (dam - 80)/2 + 80; 
   
    if ( victim != ch )
    {
	/*
	 * Certain attacks are forbidden.
	 * Most other attacks are returned.
	 */
	if ( is_safe( ch, victim ) )
	    return FALSE;

	if ( victim->position > POS_STUNNED )
	{
	    /*
	     * 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 );
		
		set_fighting( ch, victim->master);
		return FALSE;
	    }
	}

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

    /*
     * Inviso attacks ... not.
     */
    if ( IS_AFFECTED(ch, AFF_INVISIBLE) )
    {
	affect_strip( ch, gsn_invis );
	affect_strip( ch, gsn_mass_invis );
	REMOVE_BIT( ch->affected_by, AFF_INVISIBLE );
	act( "$n fades into existence.", ch, NULL, NULL, TO_ROOM );
    }

    /*
     * Damage modifiers.
     */

    if ( dam > 1 && !IS_NPC(victim)
    &&   victim->pcdata->condition[COND_DRUNK]  > 10 )
	dam = 9 * dam / 10;
 
    immune = FALSE;


    switch(check_immune(victim,dam_type))
    {
	case(IS_DIMMUNE):
	    immune = TRUE;
	    dam = 0;
	    break;
	case(IS_RESISTANT):     
	    dam -= dam/3;
	    break;
	case(IS_VULNERABLE):
	    dam += dam/2;
	    break;
    }

    if (show)
	dam_message( ch, victim, dam, dt);

    if (dam == 0)
	return FALSE;

    /*
     * Hurt the victim.
     * Inform the victim of his new state.
     */
    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 will die soon, if not aided.",
	    victim, NULL, NULL, TO_ROOM );
	send_to_char( 
	    "You are mortally wounded, and will die soon, if not aided.\n\r",
	    victim );
	break;

    case POS_INCAP:
	act( "$n is incapacitated and will slowly die, if not aided.",
	    victim, NULL, NULL, TO_ROOM );
	send_to_char(
	    "You are incapacitated and will slowly die, if not aided.\n\r",
	    victim );
	break;

    case POS_STUNNED:
	act( "$n is stunned, but will probably recover.",
	    victim, NULL, NULL, TO_ROOM );
	send_to_char("You are stunned, but will probably 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 );
	stop_fighting(ch, TRUE);
	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 )
	    send_to_char( "#1You sure are BLEEDING!\n\r", victim );
	break;
    }

    /*
     * Sleep spells and extremely wounded folks.
     */
    if (victim->position == POS_DEAD && !IS_NPC(victim) && victim->class !=0 )
    {
	stop_fighting(victim, TRUE);
	return TRUE;
    }
    else
    {
	update_pos(victim);
    }

    if ( !IS_AWAKE(victim) )
	stop_fighting( victim, FALSE );

    /*
     * Payoff for killing things.
     */

    if ( victim->position == POS_DEAD && victim->class==0)
    {
	
	group_gain( ch, victim );

	if (IS_NPC(victim) && !IS_NPC(ch) )
	    ch->mkill += 1;	


	if ( !IS_NPC(victim) )
	{    
	    if (IS_NPC(ch))
	        victim->mdeath += 1;
	    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 );
	}
	
	sprintf( log_buf, "%s got crapped upon by %s at %s [room %d]",
	    (IS_NPC(victim) ? victim->short_descr : victim->name),
	    (IS_NPC(ch) ? ch->short_descr : ch->name),
	    ch->in_room->name, ch->in_room->vnum);
		    
	raw_kill(victim);

     	if (!IS_NPC(ch) && !IS_NPC(victim) && victim->pcdata->bounty > 0)
	{
    	sprintf(buf,"You recive a %d QP bounty, for killing %s.\n\r",
    	victim->pcdata->bounty, victim->name);
    	send_to_char(buf, ch);
    	ch->pcdata->quest += victim->pcdata->bounty;
    	victim->pcdata->bounty =0;	
	}

	if ( !IS_NPC(ch) && IS_NPC(victim) )
	{
	    corpse = get_obj_list( ch, "corpse", ch->in_room->contents );
	 
	    if ( IS_SET(ch->act, PLR_AUTOLOOT) &&
		 corpse && corpse->contains) /* exists and not empty */
		do_get( ch, "all corpse" );
      
	      if ( IS_SET(ch->act,PLR_AUTOLOOT) && corpse && corpse->contains)
		return TRUE;  /* leave if corpse has treasure */
	      else
		do_sacrifice( ch, "corpse" );
	}

	return TRUE;
     }

    if ( victim == ch )
	return TRUE;

    /*
     * Wimp out?
     */

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

    tail_chain( );
    return TRUE;
}

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

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

    if ( ch->embracing != NULL )
    {
      if ( ( emb = ch->embracing ) != NULL ) stop_embrace(ch,emb);
    else stop_embrace(ch,NULL);
    }

    /*
     * Stop up any residual loopholes.
     */

    if (ch->damcap[DAM_CHANGE] == 1) update_damcap(ch,victim);


    if (IS_NPC(victim) && dam > 2750)
	  dam = number_range( 2600, 2900 );

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

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

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

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

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

	/*
	 * Damage modifiers.
	 */
	if ( IS_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_AFFECTED(victim, AFF_PROTECT) && IS_EVIL(ch) && dam > 1  )
	    dam -= dam * 0.25;

	if ( dam < 0 )
	    dam = 0;

	/*
	 * Check for disarm, trip, parry, and dodge.
	 */
	if ( dt >= TYPE_HIT )
	{
	    if ( IS_NPC(ch) && number_percent( ) < ch->level * 0.5 )
		disarm( ch, victim );
	    if ( IS_NPC(ch) && number_percent( ) < ch->level * 0.5 )
		trip( ch, victim );
	    if ( 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;
	    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;
	}

	dam_message( ch, victim, dam, dt );
    }
    if ( IS_CLASS( victim, CLASS_MONK ) && victim->monkab[SPIRIT] >= 2 )
    {
	if (IS_SET(victim->newbits, NEW_NATURAL))
        {
	  stc("You absorb the natural imbalances of your opponent.\n\r",victim);
	  act("$n absorbs the natural imbalances of you attack.",victim,NULL,ch,TO_VICT);
	  if ( dam > 2000 ) dam /= 2;
	  victim->hit += dam;
	  REMOVE_BIT(victim->newbits, NEW_NATURAL);
          return;
	}
    }

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

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

    if ( dam > 1000 ) dam = 1000;

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

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

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

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

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

	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 )
{
    char buf[MAX_STRING_LENGTH];
    bool is_npc = FALSE;
    int vnum;

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

    if( IS_NPC(ch) )
    {
        switch( ch->pIndexData->vnum ){
        case 30003:
        case 20050:
        case 30704:
        case 30703:
        case 10000:
        case 10001:
        case 10002:
        case 10003:
        case 10004:
            {
		if( victim->hit <= 0 )
		    victim->hit = victim->max_hit;
	    }  
	}
    }

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

    if ( !IS_NPC(victim)
    &&   IS_SET(victim->newbits, NEW_CLOAK)
    &&   victim->hit < 1 )
      {
	  victim->hit += (victim->max_hit * .25);
	  REMOVE_BIT(victim->newbits, NEW_CLOAK);
      }

    if ( !IS_NPC(victim) && IS_CLASS(ch, CLASS_DROW)
    &&    IS_SET(victim->newbits, NEW_DARKNESS)
    &&    victim->hit < 1 )
    {
        if (IS_SET(victim->in_room->room_flags, ROOM_TOTAL_DARKNESS))
        REMOVE_BIT(victim->in_room->room_flags, ROOM_TOTAL_DARKNESS);
    }

    if (victim->hit < 0 && IS_SET(victim->in_room->room_flags, ROOM_ARENA))
      check_arena(ch, victim);
    update_pos( victim );

    switch( victim->position )
    {
    case POS_MORTAL:
	act( "$n is mortally wounded, and spraying blood everywhere.",
	    victim, NULL, NULL, TO_ROOM );
	send_to_char( 
	    "You are mortally wounded, and spraying blood everywhere.\n\r",
	    victim );
	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 (IS_CLASS(ch, CLASS_DEMON) || IS_SET(ch->special, SPC_CHAMPION)
		|| IS_CLASS(ch, CLASS_DROW) || IS_CLASS(ch, CLASS_ANGEL))
	    {
		if ((vnum = victim->pIndexData->vnum) > 29000)
		{
		    switch (vnum)
		    {
		    default:
			if (IS_CLASS(ch, CLASS_DEMON) || IS_SET(ch->special,SPC_CHAMPION)) {
			ch->pcdata->stats[DEMON_CURRENT] +=victim->level*2;
			ch->pcdata->stats[DEMON_TOTAL] +=victim->level*2;}
			else if (IS_CLASS(ch, CLASS_DROW))
			ch->pcdata->stats[DROW_POWER] += victim->level*2;
			else if (IS_CLASS(ch, CLASS_ANGEL) && IS_NPC(victim) && !IS_SET(victim->act, ACT_NOEXP ))
			{
 		       if (IS_EVIL(victim))
        		{
		         ch->pcdata->stats[ANGEL_CURRENT] += victim->level*5/3;
		         ch->pcdata->stats[ANGEL_TOTAL] += victim->level*5/3;
		         sprintf(buf, "You gained %d angelic power points.\n\r",
         			victim->level*5/3);
  			       send_to_char(buf,ch);
  			      }
       				 else
        			{
  			       ch->pcdata->stats[ANGEL_CURRENT] += victim->level*4/3;
      			   ch->pcdata->stats[ANGEL_TOTAL] += victim->level*4/3;
         		sprintf(buf, "You gained %d angelic power points.\n\r", 
     			    victim->level*4/3);
      			   send_to_char(buf,ch);
      			  }
			}

			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))
		{
		if (IS_CLASS(ch, CLASS_DEMON) || IS_SET(ch->special,SPC_CHAMPION)) {
		    ch->pcdata->stats[DEMON_CURRENT] += victim->level*2;
		    ch->pcdata->stats[DEMON_TOTAL] += victim->level*2;}
		else if (IS_CLASS(ch, CLASS_DROW))
		    ch->pcdata->stats[DROW_POWER] += victim->level*2;
else if (IS_CLASS(ch, CLASS_ANGEL) && IS_NPC(victim) && !IS_SET(victim->act, ACT_NOEXP ))
{
        if (IS_EVIL(victim))
        {
         ch->pcdata->stats[ANGEL_CURRENT] += victim->level*5/3;
         ch->pcdata->stats[ANGEL_TOTAL] += victim->level*5/3;
         sprintf(buf, "You gained %d angelic power points.\n\r",
         victim->level*5/3);
         send_to_char(buf,ch);
        }
        else
        {
         ch->pcdata->stats[ANGEL_CURRENT] += victim->level*4/3;
         ch->pcdata->stats[ANGEL_TOTAL] += victim->level*4/3;
         sprintf(buf, "You gained %d angelic power points.\n\r", 
         victim->level*4/3);
         send_to_char(buf,ch);
        }
}

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

     	if (!IS_NPC(ch) && !IS_NPC(victim) && victim->pcdata->bounty > 0)
	{
    	sprintf(buf,"You recive a %d QP bounty, for killing %s.\n\r",
    	victim->pcdata->bounty, victim->name);
    	send_to_char(buf, ch);
    	ch->pcdata->quest += victim->pcdata->bounty;
    	victim->pcdata->bounty =0;	
	}

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

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

	return;
    }

    if ( victim == ch )
	return;


    if ( !IS_NPC(victim) && victim->desc == NULL )
    {
	if ( number_range( 0, victim->wait ) == 0 )
	{
	    do_recall( victim, "" );
	    return;
	}
    }

/*
    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(victim) && !IS_NPC(ch))
  {
    if ( !CAN_PK(ch) || !CAN_PK(victim) )
    {
        send_to_char( "Both players must be avatars to fight.\n\r", ch );
        return TRUE;
    }  
  }

    if( IS_NPC(ch) )
    {
	switch( ch->pIndexData->vnum ){
	case 30003:
	case 20050:
	case 30704:
	case 30703:
	case 10000:
	case 10001:	
	case 10002:
	case 10003:
	case 10004:
	    return FALSE;
	default: break;
        }
    }

    if( IS_NPC(victim) )
    {
	switch( victim->pIndexData->vnum ){
	case 30003:
	case 20050:
	case 30704:
	case 30703:
	case 10000:
	case 10001:	
	case 10002:
	case 10003:
	case 10004:
	    return FALSE;
	default: break;
	}
    }

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

     if ( !IS_NPC(ch ) )
     {
	if (IS_AFFECTED(ch, AFF_PEACE) && ch->fighting != NULL)
	REMOVE_BIT(ch->affected_by, AFF_PEACE);
     }
     if ( !IS_NPC(victim) )
     {
	if (IS_AFFECTED(victim, AFF_PEACE) && victim->fighting != NULL)
	REMOVE_BIT(victim->affected_by, AFF_PEACE);
     }

    /* 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;
    }

    /* ARENA room checking */
    if (  IS_SET(ch->in_room->room_flags,ROOM_ARENA)
       && IS_SET(victim->in_room->room_flags,ROOM_ARENA) )
        return FALSE;


    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_AFFECTED(ch, AFF_PEACE))
    {
	send_to_char( "You are unable to attack them.\n\r", ch );
        return TRUE;
    }

    if (IS_AFFECTED(victim, AFF_PEACE))
    {
	send_to_char( "You can't seem to attack them.\n\r", ch );
        return TRUE;
    }

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

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

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


  if (!IS_NPC(ch) && !IS_NPC(victim))
  {
    if ( !CAN_PK(ch) || !CAN_PK(victim) )
    {
        send_to_char( "Both players must be avatars to fight.\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;
    bool claws = FALSE;

    if ( !IS_AWAKE(victim) )
	return FALSE;

    if ( IS_NPC(victim) )
	obj = NULL;
    else if ( IS_CLASS(victim, CLASS_WEREWOLF)	&& 
	victim->power[DISC_WERE_BEAR] > 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) && !IS_CLASS(ch, CLASS_MONK) ) return FALSE;

    if (  dt >= 1000 && dt <= 1012 ){
    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;
    }
    else{
    if (!IS_NPC(ch))   chance -= (ch->wpn[0] * 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_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);

    if (claws) 
    {
	    if (victim->power[DISC_WERE_LYNX] > 3)
	       chance += (char_hitroll(victim) * 0.1);
	    else
	       chance += (char_hitroll(victim) * 0.075);
    }


    if (!IS_NPC(ch))
    {
           if (IS_CLASS(ch, CLASS_VAMPIRE))
           {
	         if (ch->power[DISC_VAMP_CELE] > 0)
               chance -= (ch->power[DISC_VAMP_CELE]*4);
           }
	if (IS_CLASS(ch, CLASS_NINJA)  && ch->pcdata->powers[NPOWER_CHIKYU] >= 6
	&& ch->pcdata->powers[HARA_KIRI] > 0) 
	chance -= 25;
	if (ch->pcdata->powers[NPOWER_CHIKYU] >= 5 && IS_CLASS(ch, CLASS_NINJA))
	chance -= 25;
	else if (IS_CLASS(ch, CLASS_DEMON) && IS_DEMPOWER(ch, DEM_SPEED) )
	    chance -= 25;
        if ( IS_CLASS(ch, CLASS_MONK) && ch->chi[CURRENT] > 0 )
	    chance -= (ch->chi[CURRENT] * 7);
	if (IS_CLASS(ch, CLASS_DROW) && IS_SET(ch->pcdata->powers[1], DPOWER_ARMS))
		chance -= 30;
        else if (IS_CLASS(ch, CLASS_ANGEL))
        {
            if ( IS_ANGPOWER(ch, ANG_SPEED) && !IS_ANGPOWER(ch, ANG_HALO )) chance -= 40;
            else if (IS_ANGPOWER(ch, ANG_SPEED) && IS_ANGPOWER(ch, ANG_HALO) && IS_EVIL(victim)) chance -= 70;
            else if (IS_ANGPOWER(ch, ANG_HALO) && !IS_ANGPOWER(ch, ANG_SPEED) && IS_EVIL(victim)) chance -= 40;
        }

	if (IS_SET(ch->newbits, NEW_MONKFLAME))
	    chance -= 3;
        if (IS_CLASS(ch, CLASS_WEREWOLF) &&
	    ch->power[DISC_WERE_MANT] < 11 )
	    chance -= (ch->power[DISC_WERE_MANT] * 4);
    }

    if (!IS_NPC(victim))
    {
	if (victim->pcdata->powers[NPOWER_CHIKYU] >= 5 && IS_CLASS(victim, CLASS_NINJA))
	chance += 25;
        if (victim->power[DISC_VAMP_CELE] > 0 && 
	    IS_CLASS(victim, CLASS_VAMPIRE)) 
            chance += (victim->power[DISC_VAMP_CELE]*4);
	if (IS_CLASS(victim, CLASS_DROW) && IS_SET(victim->pcdata->powers[1], DPOWER_ARMS))
		chance += 30;
	if (IS_CLASS(victim, CLASS_MONK) && ch->chi[CURRENT] > 0 )
		chance += (ch->chi[CURRENT] * 8);
	else if (IS_CLASS(ch, CLASS_DEMON) && IS_DEMPOWER(ch, DEM_SPEED) )
	    chance -= 25;
        else if (IS_CLASS(victim, CLASS_ANGEL))
        {
            if ( IS_ANGPOWER(victim, ANG_SPEED) && !IS_ANGPOWER(victim, ANG_HALO )) chance += 40;
            else if (IS_ANGPOWER(victim, ANG_SPEED) && IS_ANGPOWER(victim, ANG_HALO) && IS_EVIL(ch)) chance += 70;
            else if (IS_ANGPOWER(victim, ANG_HALO) && !IS_ANGPOWER(victim, ANG_SPEED) && IS_EVIL(ch)) chance += 40;
        }

	if (IS_SET(victim->newbits, NEW_MONKFLAME))
	   chance += 4;
    }

    if      (chance > 80) chance = 80;
    else if (chance < 20) chance = 20;

    if (!IS_NPC(ch) && ch->power[DISC_VAMP_CELE] > 0 && IS_CLASS(ch, CLASS_VAMPIRE))
    {
	if( ch->pcdata->rank == AGE_TRUEBLOOD)  chance -= 23;
	else if( ch->pcdata->rank == AGE_LA_MAGRA) chance -= 17;
	else if (ch->pcdata->rank == AGE_METHUSELAH) chance -= 15;
	else if (ch->pcdata->rank == AGE_ELDER) chance -= 10;
	else if (ch->pcdata->rank == AGE_ANCILLA) chance -= 5;
    }
    if(!IS_NPC(ch) &&  IS_CLASS(ch, CLASS_DRAGON))
    {
	chance -= ch->pcdata->dragonage * 3;
    }
    if(!IS_NPC(victim) &&  IS_CLASS(victim, CLASS_DRAGON))
    {
	chance += victim->pcdata->dragonage * 3;
    }

	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(victim, CLASS_MAGE) )
	{
	    if ( IS_SET(victim->mflags, MAGE_POLYAPPEAR) )
	        chance += 10;
	    if ( victim->spheres[MTIM] > 0 )
	        chance += ( victim->spheres[MTIM] * 2 );
	}

    if (!IS_NPC(victim) && victim->power[DISC_VAMP_CELE] > 0 && 
	IS_CLASS(victim, CLASS_VAMPIRE))
    {
	if( victim->pcdata->rank == AGE_TRUEBLOOD)  chance += 23;
	else if( victim->pcdata->rank == AGE_LA_MAGRA) chance += 17;
	else if (victim->pcdata->rank == AGE_METHUSELAH) chance += 15;
	else if (victim->pcdata->rank == AGE_ELDER) chance += 10;
	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 ( number_percent( ) < 100 && number_percent( ) >= chance )
	return FALSE;

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

    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(ch))
    {
	if (IS_CLASS(ch, CLASS_NINJA)  && ch->pcdata->powers[NPOWER_CHIKYU] >= 6
	&& ch->pcdata->powers[HARA_KIRI] > 0)
	chance -= 25;
	if (ch->pcdata->powers[NPOWER_CHIKYU] >= 5 && IS_CLASS(ch, CLASS_NINJA))
	chance -= 25;
        if (ch->power[DISC_VAMP_CELE] > 0 && IS_CLASS(ch, CLASS_VAMPIRE)) 
            chance -= (ch->power[DISC_VAMP_CELE]*4);
	else if (IS_CLASS(ch, CLASS_DEMON) && IS_DEMPOWER( ch, DEM_SPEED) )
	    chance -= 25;
	else if (IS_CLASS(ch, CLASS_WEREWOLF) &&
	    ch->power[DISC_WERE_MANT] < 11 )
	    chance -= (ch->power[DISC_WERE_MANT] * 4);
	else if (IS_CLASS(ch, CLASS_DROW) &&
	IS_SET(ch->pcdata->powers[1], DPOWER_SPEED))
	chance -= 25;
        else if (IS_CLASS(ch, CLASS_ANGEL))
        {
            if ( IS_ANGPOWER(ch, ANG_SPEED) && !IS_ANGPOWER(ch, ANG_HALO )) chance -= 40;
            else if (IS_ANGPOWER(ch, ANG_SPEED) && IS_ANGPOWER(ch, ANG_HALO) && IS_EVIL(victim)) chance -= 70;
            else if (IS_ANGPOWER(ch, ANG_HALO) && !IS_ANGPOWER(ch, ANG_SPEED) && IS_EVIL(victim)) chance -= 40;
        }

    }
    if (!IS_NPC(victim))
    {
	if (victim->pcdata->powers[NPOWER_CHIKYU] >= 5 && IS_CLASS(victim, CLASS_NINJA))
	chance += 30;
        if (victim->power[DISC_VAMP_CELE] > 0 && IS_CLASS(victim, CLASS_VAMPIRE)) 
            chance += (victim->power[DISC_VAMP_CELE]*4);
	else if (IS_CLASS(victim, CLASS_DEMON) && IS_DEMPOWER( victim, DEM_SPEED) )
	    chance += 25;
      else if (IS_CLASS(victim, CLASS_WEREWOLF) && victim->power[DISC_WERE_MANT] < 11)
            chance += (victim->power[DISC_WERE_MANT] * 5);
	else if (IS_CLASS(victim, CLASS_DROW) && 
	IS_SET(victim->pcdata->powers[1], DPOWER_SPEED))
	chance += 25;
        else if (IS_CLASS(victim, CLASS_ANGEL))
        {
            if ( IS_ANGPOWER(victim, ANG_SPEED) && !IS_ANGPOWER(victim, ANG_HALO )) chance -= 40;
            else if (IS_ANGPOWER(victim, ANG_SPEED) && IS_ANGPOWER(victim, ANG_HALO) && IS_EVIL(ch)) chance -= 70;
            else if (IS_ANGPOWER(victim, ANG_HALO) && !IS_ANGPOWER(victim, ANG_SPEED) && IS_EVIL(ch)) chance -= 40;
        }

    }

    if      (chance > 80) chance = 80;
    else if (chance < 20) chance = 20;

    if (!IS_NPC(ch) && IS_CLASS(ch, CLASS_VAMPIRE))
    {
	if( ch->pcdata->rank == AGE_TRUEBLOOD)  chance -= 19;
	else if( ch->pcdata->rank == AGE_LA_MAGRA) chance -= 17;
	else 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 -= 3;
    }
    if (!IS_NPC(victim) && IS_CLASS(victim, CLASS_VAMPIRE))
    {
	if(victim->pcdata->rank == AGE_TRUEBLOOD)  chance += 19;
	else if(victim->pcdata->rank == AGE_LA_MAGRA) chance += 17;
	else 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 += 3;
    }

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

    if ( number_percent( ) < 100 && number_percent( ) >= 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_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);

    return;
}



/*
 * Stop fights.
 */
void stop_embrace( CHAR_DATA *ch, CHAR_DATA *victim )
{
  if ( victim == NULL)
  {
    ch->embracing=NULL;
    return;
  }

  victim->embraced=NULL;
  ch->embracing=NULL;
  return;
}

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( 4, 8 );
	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( 25, 40 );
	/* Why should players keep their gold? */
	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;
	}
    }
if (IS_SET(ch->extra, EXTRA_ZOMBIE))
{
SET_BIT(corpse->quest, QUEST_ZOMBIE);
}

    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 you die in the shadowplane, your corpse should stay there */
    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,5);
	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(2,3); obj->item_type = ITEM_HEAD;}
	else if (!str_cmp(arg,"arm"))
	    SET_BIT(obj->extra_flags2, 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);
	    obj->item_type = ITEM_HEAD;
	}

	/* 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 *mount;
    stop_fighting( victim, TRUE );
    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 );
	return;
    }

    extract_char( victim, 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);
    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

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

Site Stats

Snippets: 1791
Codebases: 571