fight.c

tmw/orig/fight.c · 185.6 KB

From the archive tmw.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.                              *
 *                                                                         *
 *  Envy Diku Mud improvements copyright (C) 1994 by Michael Quan, David   *
 *  Love, Guilherme 'Willie' Arnold, and Mitchell Tse.                     *
 *                                                                         *
 *  In order to use any part of this Envy Diku Mud, you must comply with   *
 *  the original Diku license in 'license.doc', the Merc license in        *
 *  'license.txt', as well as the Envy license in 'license.nvy'.           *
 *  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.                                                  *
 ***************************************************************************/

#define unix 1
#if defined( macintosh )
#include <types.h>
#else
#include <sys/types.h>
#endif
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "merc.h"



/*
 * Local functions.
 */
void bomb_explode args(( OBJ_DATA *bomb, ROOM_INDEX_DATA *in_room )); 
bool	check_dodge	     args( ( CHAR_DATA *ch, CHAR_DATA *victim ) );
bool    check_sidestep       args( ( CHAR_DATA *ch, CHAR_DATA *victim ) );  
void	check_killer	     args( ( CHAR_DATA *ch, CHAR_DATA *victim ) );
bool	check_parry	     args( ( CHAR_DATA *ch, CHAR_DATA *victim ) );
void	dam_message	     args( ( CHAR_DATA *ch, CHAR_DATA *victim, int dam,
				    int dt ) );
void	death_cry	     args( ( CHAR_DATA *ch ) );
void	death_xp_loss	     args( ( CHAR_DATA *victim ) );
void	group_gain	     args( ( CHAR_DATA *ch, CHAR_DATA *victim ) );
int	xp_compute	     args( ( CHAR_DATA *gch, CHAR_DATA *victim )
);
bool	is_safe		     args( ( CHAR_DATA *ch, CHAR_DATA *victim ) );
bool	is_bare_hand	     args( ( CHAR_DATA *ch ) );
bool    is_wielding_poisoned args( ( CHAR_DATA *ch ) );
bool    is_wielding_flaming  args( ( CHAR_DATA *ch ) );
bool    is_wielding_chaos    args( ( CHAR_DATA *ch ) );
bool    is_wielding_icy      args( ( CHAR_DATA *ch ) );

void	make_corpse	     args( ( CHAR_DATA *ch ) );
void	newbie_corpse	     args( ( CHAR_DATA *ch ) );
void	one_hit		     args( ( CHAR_DATA *ch, CHAR_DATA *victim,
				    int dt ) );
void	one_dual	     args( ( CHAR_DATA *ch, CHAR_DATA *victim,
				    int dt ) );
void	one_triple	args(( CHAR_DATA *ch, CHAR_DATA *victim,
				int dt ));
void	raw_kill	     args( ( CHAR_DATA *ch, CHAR_DATA *victim ) );
void	set_fighting	     args( ( CHAR_DATA *ch, CHAR_DATA *victim ) );
void	disarm		     args( ( CHAR_DATA *ch, CHAR_DATA *victim ) );
void	trip		     args( ( CHAR_DATA *ch, CHAR_DATA *victim ) );
void    item_damage             args( ( CHAR_DATA *ch, int dam ) );
void	do_lure			args( ( CHAR_DATA *ch, char *argument ) );
void    do_image		args( ( CHAR_DATA *ch, CHAR_DATA *victim ) );
void	do_flip			args( ( CHAR_DATA *ch, char *argument ) );
void    ranged_damage           args( ( CHAR_DATA *ch, CHAR_DATA *victim, 
				int dam, int dt ) );
OBJ_DATA * parmor_check args ( ( CHAR_DATA *ch ) );
bool    check_counter       args( ( CHAR_DATA *ch, CHAR_DATA *victim ) );     

/*
 * Control the fights going on.
 * Called periodically by update_handler.
 * Slightly less efficient than Merc 2.2.  Takes 10% of 
 *  total CPU time.
 */
void violence_update( void )
{
    CHAR_DATA *ch;
    CHAR_DATA *victim;
    CHAR_DATA *rch;
    bool       mobfighting;
    int stun;

    for ( ch = char_list; ch; ch = ch->next )
    {
	if ( !ch->in_room || ch->deleted )
	    continue;

	for (stun = 0; stun < STUN_MAX; stun++)
	{
	  if ( IS_STUNNED( ch, stun ) )
	    ch->stunned[stun]--;
	}

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


	if ( IS_AFFECTED( ch, AFF_BLIND )
	    || ( IS_NPC( ch ) && ch->pIndexData->pShop ) )
	    continue;

	/* Ok. So ch is not fighting anyone.
	 * Is there a fight going on?
	 */

	mobfighting = FALSE;

	for ( rch = ch->in_room->people; rch; rch = rch->next_in_room )
	{
	    if ( rch->deleted
		|| !IS_AWAKE( rch )
		|| !( victim = rch->fighting ) )
	        continue;

	    if ( !IS_NPC( ch )
		&& ( !IS_NPC( rch ) || IS_AFFECTED( rch, AFF_CHARM ) )
		&& is_same_group( ch, rch )
		&& IS_NPC( victim ) )
		break;

	    if ( IS_NPC( ch )
		&& IS_NPC( rch )
		&& !IS_NPC( victim ) )
	    {
		mobfighting = TRUE;
		break;
	    }
	}

	if ( !victim || !rch )
	    continue;

	/*
	 * Now that someone is fighting, consider fighting another pc
	 * or not at all.
	 */
	if ( mobfighting )
	{
	    CHAR_DATA *vch;
	    int        number;

	    number = 0;
	    for ( vch = ch->in_room->people; vch; vch = vch->next_in_room )
	    {
		if ( can_see( ch, vch )
		    && ( vch->level > 5 )
		    && is_same_group( vch, victim )
/*		    && IS_SET( vch->act, PLR_AUTOASSIST ) */
		    && number_range( 0, number ) == 0 )
		{
		    victim = vch;
		    number++;
		}
	    }

	    if ( ( rch->pIndexData != ch->pIndexData && number_bits( 3 ) != 0 )
		|| ( IS_GOOD( ch ) && IS_GOOD( victim ) )
		|| abs( victim->level - ch->level ) > 3 )
	        continue;
	}

	if (IS_SET(ch->act2, PLR_AUTOASSIST ))
	{ 
        mprog_hitprcnt_trigger( ch, victim );
        mprog_fight_trigger( ch, victim );
	multi_hit( ch, victim, TYPE_UNDEFINED );
	}

    }

    return;
}

/*
 * Do one group of attacks.
 */
void multi_hit( CHAR_DATA *ch, CHAR_DATA *victim, int dt )
{
    int chance;
    int chance2;
 
    if ( IS_NPC( ch ) )
    {
      mprog_hitprcnt_trigger( ch, victim );
      mprog_fight_trigger( ch, victim );
    }
    
    if ( ( IS_AFFECTED2( ch, AFF_CONFUSED ) )
       && number_percent ( ) < 10 )
    {
      act(AT_YELLOW, "$n looks around confused at what's going on.", ch, NULL, NULL, TO_ROOM );
      send_to_char( AT_YELLOW, "You stand confused.\n\r", ch );
      return;
    }
    
    one_hit( ch, victim, dt );
    if(IS_AFFECTED(ch, AFF_HASTE))
      one_hit( ch, victim, dt );
    if (IS_AFFECTED2( ch, AFF_RUSH ) )
      one_hit( ch, victim, dt );
    if (ch->race == RACE_TABAXI)
      one_hit( ch, victim, dt );	
    if ( ch->fighting != victim || dt == gsn_backstab )
	return;

    if ( !IS_NPC( ch )
/*    && ( ( is_class( ch, CLASS_MONK ) && ch->pcdata->learned[gsn_blackbelt] > 0 )
    || ( is_class( ch, CLASS_WEREWOLF ) && ch->pcdata->learned[gsn_dualclaw] > 0 ) */
    && ch->pcdata->learned[gsn_dual] > 0 ) 
       {
        one_dual( ch, victim, dt );
	if(IS_AFFECTED(ch, AFF_HASTE))
	  one_dual( ch, victim, dt );
	if ( IS_AFFECTED2( ch, AFF_RUSH ) )
	  one_dual( ch, victim, dt );
	if (ch->race == RACE_TABAXI)
    	  one_dual( ch, victim, dt );
/*  ok, so now these skills notch */
	if ( can_use_skpell( ch, gsn_blackbelt ))
          update_skpell( ch, gsn_blackbelt );           
	if ( can_use_skpell( ch, gsn_dualclaw ))
	  update_skpell( ch, gsn_dualclaw );   
        if ( ch->fighting != victim )
	   return;
       }
    if ( ( IS_NPC( ch ) ) && ( ch->level > 15 ) )
       {
        one_dual( ch, victim, dt );
        if ( ch->fighting != victim )
           return;
       }
    if ( ch->race == RACE_KREEN )
	one_triple( ch, victim, dt );

    chance = IS_NPC( ch ) ? ch->level - 5
                          : ch->pcdata->learned[gsn_second_attack]/2;
/*    if ( is_class( ch, CLASS_WEREWOLF ) )
    chance2 = IS_NPC( ch ) ? ch->level / 2 - 5
			   : ch->pcdata->learned[gsn_dualclaw] / 2;
    else if ( is_class( ch, CLASS_MONK ) && !get_eq_char( ch, WEAR_WIELD_2 ) )
    chance2 = IS_NPC( ch ) ? ch->level / 2 - 5
			   : ch->pcdata->learned[gsn_blackbelt] / 2;
    else */
    chance2 = IS_NPC( ch ) ? ch->level/2 - 5
                          : ch->pcdata->learned[gsn_dual]/2;
    if ( number_percent( ) < chance )
    {
	one_hit( ch, victim, dt );
	update_skpell( ch, gsn_second_attack );
	if ( ch->fighting != victim )
	    return;
        if ( number_percent( ) < chance2 )
        {
         one_dual( ch, victim, dt );

         if ( ch->fighting != victim )
           return;
        }
	if ( number_percent( ) < chance2 )
	one_triple(ch,victim,dt);
    }

    chance = IS_NPC( ch ) ? ch->level
                          : ch->pcdata->learned[gsn_third_attack]/4;
/*    if ( is_class( ch, CLASS_WEREWOLF ) )
    chance2 = IS_NPC( ch ) ? ch->level / 2
			   : ch->pcdata->learned[gsn_dualclaw] / 4;
    else if ( is_class( ch, CLASS_MONK ) && !get_eq_char( ch, WEAR_WIELD_2 ) )
    chance2 = IS_NPC( ch ) ? ch->level / 2 
			   : ch->pcdata->learned[gsn_blackbelt] / 4;
    else */
    chance2 = IS_NPC( ch ) ? ch->level/2
                           :ch->pcdata->learned[gsn_dual]/4;
    if ( number_percent( ) < chance )
    {
	one_hit( ch, victim, dt );
	update_skpell( ch, gsn_third_attack );
	if ( ch->fighting != victim )
	    return;
        if ( number_percent( ) < chance2 )
        {
         one_dual( ch, victim, dt );
         if ( ch->fighting != victim )
           return;
        }
        if ( number_percent( ) < chance2 )
	one_triple(ch,victim,dt);
    }

    chance = IS_NPC( ch ) ? ch->level/2
                          : ch->pcdata->learned[gsn_fourth_attack]/4;
    if ( number_percent( ) < chance && ch->wait == 0 )
    {
	one_hit( ch, victim, dt );
	update_skpell( ch, gsn_fourth_attack );
	if ( ch->fighting != victim )
	    return;
    }

    chance = IS_NPC( ch ) ? ch->level/2
                          : ch->pcdata->learned[gsn_fifth_attack]/8;
/*    if ( is_class( ch, CLASS_WEREWOLF ) )
    chance2 = IS_NPC( ch ) ? ch->level / 6
			   : ch->pcdata->learned[gsn_dualclaw] / 8;
    else if ( is_class( ch, CLASS_MONK ) && !get_eq_char( ch, WEAR_WIELD_2 ) )
    chance2 = IS_NPC( ch ) ? ch->level / 6
			   : ch->pcdata->learned[gsn_blackbelt] / 8;
    else */
    chance2 = IS_NPC( ch ) ? ch->level/6
                          : ch->pcdata->learned[gsn_dual]/8;
    if ( number_percent( ) < chance && ch->wait == 0 )
    {
	one_hit( ch, victim, dt );
	update_skpell( ch, gsn_fifth_attack );
	if ( ch->fighting != victim )
	    return;
        if ( number_percent( ) < chance2 )
        {
         one_dual( ch, victim, dt );
         if ( ch->fighting != victim )
           return;
        }
        if ( number_percent( ) < chance2 )
	one_triple(ch,victim,dt);
    }

    chance = IS_NPC( ch ) ? ch->level/4
                          : ch->pcdata->learned[gsn_sixth_attack]/16;
    if ( number_percent( ) < chance && ch->wait == 0 )
    {
	one_hit( ch, victim, dt );
	update_skpell( ch, gsn_sixth_attack );
	if ( ch->fighting != victim )
	    return;
    }

    chance = IS_NPC( ch ) ? ch->level/4
                          : ch->pcdata->learned[gsn_seventh_attack]/32;
/*    if ( is_class( ch, CLASS_WEREWOLF ) )
    chance2 = IS_NPC( ch ) ? ch->level / 4
			   : ch->pcdata->learned[gsn_dualclaw] / 32;
    else if ( is_class( ch, CLASS_MONK ) && !get_eq_char( ch, WEAR_WIELD_2 ) )
    chance2 = IS_NPC( ch ) ? ch->level / 4
			   : ch->pcdata->learned[gsn_blackbelt] / 22;
    else */
    chance2 = IS_NPC( ch ) ? ch->level/4
                          : ch->pcdata->learned[gsn_dual]/32;
    if ( number_percent( ) < chance && ch->wait == 0 )
    {
	one_hit( ch, victim, dt );
	update_skpell( ch, gsn_seventh_attack );
	if ( ch->fighting != victim )
	    return;
        if ( number_percent( ) < chance2 )
        {
         one_dual( ch, victim, dt );
         if ( ch->fighting != victim )
           return;
        }
        if ( number_percent( ) < chance2 )
        one_triple(ch,victim,dt);          
    }

    if ( IS_AFFECTED2(ch, AFF_BERSERK) )
    {
      one_hit( ch, victim, dt );
      if (ch->fighting != victim )
	return;
      one_dual( ch, victim, dt );
      if (ch->fighting != victim )
	return;
      one_triple( ch, victim, dt );
      if (ch->fighting != victim )
	return;
    }

    chance = IS_NPC( ch ) ? ch->level / 4
                          : 0;
    chance2 = IS_NPC( ch ) ? ch->level / 8
                          : 0;
    if ( number_percent( ) < chance )
	one_hit( ch, victim, dt );
    if ( number_percent( ) < chance2 )
         one_dual( ch, victim, dt );
    if ( number_percent( ) < chance2 )
         one_triple( ch, victim, dt );
    
    return;
}



/*
 * Hit one guy once.
 */
void one_hit( CHAR_DATA *ch, CHAR_DATA *victim, int dt )
{
    OBJ_DATA *wield;
    char      buf [ MAX_STRING_LENGTH ];
    int       victim_ac;
    int       thac0;
    int       thac0_00;
    int       thac0_97;
    int       dam;
    int       diceroll;

    /*
     * 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_STUNNED( ch, STUN_NON_MAGIC ) ||
	 IS_STUNNED( ch, STUN_TOTAL ) )
      return;

    /*
     * Figure out the type of damage message.
     */
    wield = get_eq_char( ch, WEAR_WIELD );
    if ( dt == TYPE_UNDEFINED )
    {
	dt = TYPE_HIT;
	if ( wield && wield->item_type == ITEM_WEAPON )
	    dt += wield->value[3];
/*	else if ( is_class( ch, CLASS_WEREWOLF ) && !wield )
	    dt += 5;
	else if ( is_class( ch, CLASS_MONK ) && !wield )
	    dt += 14; */
    }

    /*
     * Calculate to-hit-armor-class-0 versus armor.
     */
    if ( IS_NPC( ch ) )
    {
	thac0_00 =  18;
	thac0_97 = -24;
    }
    else
    {
	thac0_00 = class_table[prime_class(ch)].thac0_00;
	thac0_97 = class_table[prime_class(ch)].thac0_97;
    }
    
    if (!IS_NPC(ch))
        thac0     = interpolate( ch->level, thac0_00, thac0_97 )
                  - GET_HITROLL( ch );
    else
        thac0     = interpolate(ch->level, thac0_00, thac0_97 )
                  - (ch->level + ch->level/2);
    
    if ( ( !IS_NPC( ch ) ) && ( ch->pcdata->learned[gsn_enhanced_hit] > 0 ) ) 
    {
       thac0 -= ch->pcdata->learned[gsn_enhanced_hit] / 5;
       update_skpell( ch, gsn_enhanced_hit );
    }

    victim_ac = UMAX( -15, GET_AC( victim ) / 10 );
/*
    if ( victim->level < L_APP && victim->class == CLASS_VAMPIRE )
     if ( !IS_SET( victim->in_room->room_flags, ROOM_INDOORS ) )
     {
      if ( time_info.hour > 6 && time_info.hour < 18 )
      {
	victim_ac += victim->level * 2;
      }
    }
*/    
    if ( !can_see( ch, victim ) )
	victim_ac -= 4;
    
    /*
     * 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( );
	return;
    }

    

    /*
     * Hit.
     * Calc damage.
     */
         if ( IS_AFFECTED( victim, AFF_FIRESHIELD ) )
           {
             if ( number_percent( ) < 50 )
	     {
	       if ( !IS_NPC(victim) )
		 spell_fireball ( skill_lookup("fireball"), 15, victim, ch );
	       else
		 spell_fireball ( skill_lookup("fireball"), 25, victim, ch );
	     }
           }
  if ( !victim || victim->position == POS_DEAD || ch->in_room != victim->in_room )
	return;
	if ( IS_AFFECTED( victim, AFF_ICESHIELD ) )
           {
             if ( ( number_percent( ) < 50 )
	       || ( number_percent( ) < 17 ) )
	     {
	       if ( !IS_NPC(victim) )
		 spell_icestorm ( skill_lookup("icestorm"), 20, victim, ch );
	       else
		 spell_fireball ( skill_lookup("icestorm"), 40, victim, ch );
	     }
	   }
  if ( !victim || victim->position == POS_DEAD || ch->in_room != victim->in_room )
	return;
	if ( IS_AFFECTED( victim, AFF_SHOCKSHIELD ) )
           {
             if ( ( number_percent( ) < 50 )
	       || ( number_percent( ) < 17 ) )
	     {
	       if ( !IS_NPC(victim) )
		 spell_lightning_bolt ( skill_lookup("lightning bolt"), 15, victim, ch );
	       else
		 spell_lightning_bolt ( skill_lookup("lightning bolt"), 35, victim, ch );
	     }
	   }
  if ( !victim || victim->position == POS_DEAD || ch->in_room != victim->in_room )
	return;
	if ( IS_AFFECTED( victim, AFF_CHAOS ) )  
           {
             if ( number_percent( ) < 50 )
	     {
	       if ( !IS_NPC(victim) )
		 spell_energy_drain ( skill_lookup("energy drain"), 30, victim, ch );
	       else
		 spell_energy_drain ( skill_lookup("energy drain"), 40, victim, ch );
	     }
           }
  if ( !victim || victim->position == POS_DEAD || ch->in_room != victim->in_room )
	return;
	if ( IS_AFFECTED( victim, AFF_VIBRATING ) )
           {
             if ( ( number_percent( ) < 50 )
	       || ( number_percent( ) < 17 ) )
	       spell_psionic_blast ( skill_lookup("psionic blast"), 25, victim, ch );
           }
  if ( !victim || victim->position == POS_DEAD || ch->in_room != victim->in_room )
	return;
	if ( IS_AFFECTED2( victim, AFF_BLADE ) )
           {
             if ( number_percent( ) < 40 )
                spell_holy_fires( skill_lookup("holy fires"), 45, victim, ch );
           }
  if ( !victim || victim->position == POS_DEAD || ch->in_room != victim->in_room )
	return;
	if ( IS_AFFECTED2( victim, AFF_FIELD ) )
	   {
	     if ( number_percent( ) < 10 )
		spell_death_field( skill_lookup("death field"),
		victim->level, victim, ch );        
	   }
  if ( !victim || victim->position == POS_DEAD || ch->in_room != victim->in_room )
	return;
    if ( IS_NPC( ch ) )
    {
	dam = number_range( ch->level / 3, ch->level * 3 / 2 );
	if ( wield )
	    dam += dam / 3;
    }
    else
    {
	if ( wield )
	    dam = number_range( wield->value[1], wield->value[2] );
/*	else if ( (is_class( ch, CLASS_WEREWOLF )
	     || is_class( ch, CLASS_MONK ))
	     && !wield )
	    dam = UMAX( number_fuzzy( ch->level / 2 + ch->level / 15 ),
			number_fuzzy( 5 ) ); */
	else
	    dam = number_range( 1, 4 );
	if ( wield && dam > 1000 && !IS_IMMORTAL(ch) )
	{
	    sprintf( buf, "One_hit dam range > 1000 from %d to %d",
		    wield->value[1], wield->value[2] );
	    bug( buf, 0 );
	    if ( wield->name )
	      bug( wield->name, 0 );
	}
    }

    /*
     * Bonuses.
     */
    dam += GET_DAMROLL( ch );
    if ( wield && IS_SET( wield->extra_flags, ITEM_POISONED ) )
        dam += dam / 8;
    if ( 
	(wield && IS_SET( wield->extra_flags, ITEM_FLAME ) )
    ||	(!wield && is_affected( ch, gsn_flamehand ) )
       )
        dam += dam / 8;
     if ( 
	(wield && IS_SET( wield->extra_flags, ITEM_CHAOS ) )
     ||	(!wield && is_affected( ch, gsn_chaoshand ) )
        )
        dam += dam / 4;
    if ( 
	(wield && IS_SET( wield->extra_flags, ITEM_ICY   ) )
    ||	(!wield && is_affected( ch, gsn_frosthand ) )
       )
        dam += dam / 8;
/*    if ( is_class( ch, CLASS_WEREWOLF ) && !wield )
	dam += dam / 8; */
    if ( !IS_NPC( ch ) && ch->pcdata->learned[gsn_enhanced_damage] > 0 )
    {
	dam += dam * ch->pcdata->learned[gsn_enhanced_damage] / 150;
	update_skpell( ch, gsn_enhanced_damage );
    }
    if ( !IS_NPC( ch ) && ch->pcdata->learned[gsn_enhanced_claw] > 0 
    && !wield )
    {
	dam += dam / 4 * ch->pcdata->learned[gsn_enhanced_claw] / 150;
	update_skpell( ch, gsn_enhanced_claw );
    }
    if ( !IS_NPC( ch ) && ch->pcdata->learned[gsn_enhanced_two] > 0 )
    {
        dam += dam / 4 * ch->pcdata->learned[gsn_enhanced_two] / 150;
	update_skpell( ch, gsn_enhanced_two );
    }
    if ( !IS_NPC( ch ) && ch->pcdata->learned[gsn_enhanced_three] > 0 )
    {
        dam += dam / 4 * ch->pcdata->learned[gsn_enhanced_three] / 150;
	update_skpell( ch, gsn_enhanced_three );
    }
    if ( !IS_AWAKE( victim ) )
	dam *= 2;
    if ( dt == gsn_backstab )
       {
        if (ch->clan == 4)
           dam *= number_range ( 3, 8 );
	else
	   dam *= 2 + UMIN( ( ch->level / 8) , 4 );
       }
    if ( dam <= 0 )
	dam = 1;
/*    if (IS_NPC(ch) && IS_SET(ch->act, ACT_NODAMAGE))
	dam = 0; */
    damage( ch, victim, dam, dt );
    tail_chain( );
    return;
}

void one_dual( CHAR_DATA *ch, CHAR_DATA *victim, int dt )
{
    OBJ_DATA *wield;
    char      buf [ MAX_STRING_LENGTH ];
    int       victim_ac;
    int       thac0;
    int       thac0_00;
    int       thac0_97;
    int       dam;
    int       diceroll;

	/*
     * Can't beat a dead char!
     * Guard against weird room-leavings.
     */
/*    if ( !(get_eq_char( ch, WEAR_WIELD_2 ))
    && !is_class( ch, CLASS_WEREWOLF )
    && !is_class( ch, CLASS_MONK ) )
 	return;
    if ( is_class( ch, CLASS_WEREWOLF )
    && ( get_eq_char( ch, WEAR_SHIELD )
    || get_eq_char( ch, WEAR_HOLD ) ) )
	return;
    if ( is_class( ch, CLASS_MONK )
    && ( get_eq_char( ch, WEAR_SHIELD )
    || get_eq_char( ch, WEAR_HOLD ) ) )
	return;
    if ( ( is_class( ch, CLASS_MONK ) && ch->pcdata->learned[gsn_blackbelt] == 0 )
    && ( is_class( ch, CLASS_WEREWOLF ) && ch->pcdata->learned[gsn_dualclaw] == 0 )
    && !get_eq_char( ch, WEAR_WIELD_2 ) )
	return;  */
    if ( victim->position == POS_DEAD || ch->in_room != victim->in_room )
	return;

    if ( IS_STUNNED( ch, STUN_NON_MAGIC ) ||
	 IS_STUNNED( ch, STUN_TOTAL ) )
      return;

    /*
     * Figure out the type of damage message.
     */
    wield = get_eq_char( ch, WEAR_WIELD_2 );
    if ( dt == TYPE_UNDEFINED )
    {
	dt = TYPE_HIT;
	if ( wield && wield->item_type == ITEM_WEAPON )
	    dt += wield->value[3];
/*	else if ( is_class( ch, CLASS_WEREWOLF ) && !wield )
	    dt += 5;
	else if ( is_class( ch, CLASS_MONK ) && !wield )
	    dt += 15; */
    }

    /*
     * Calculate to-hit-armor-class-0 versus armor.
     */
    if ( IS_NPC( ch ) )
    {
	thac0_00 =  20;
	thac0_97 = -20;
    }
    else
    {
	thac0_00 = class_table[prime_class(ch)].thac0_00;
	thac0_97 = class_table[prime_class(ch)].thac0_97;
    }
    thac0     = interpolate( ch->level, thac0_00, thac0_97 )
              - GET_HITROLL( ch );
    victim_ac = UMAX( -15, GET_AC( victim ) / 10 );
/*
    if ( victim->level < L_APP && victim->class == CLASS_VAMPIRE )
     if ( !IS_SET( victim->in_room->room_flags, ROOM_INDOORS ) )
     {
      if ( time_info.hour > 6 && time_info.hour < 18 )
      {
	victim_ac += victim->level * 2;
      }
    }
*/
    if ( !can_see( ch, victim ) )
	victim_ac -= 4;

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

    update_skpell( ch, gsn_dual );

    /*
     * Hit.
     * Calc damage.
     */
/*	if ( IS_AFFECTED( victim, AFF_FIRESHIELD ) )
           {
             if ( number_percent( ) < 50 )
                spell_fireball ( skill_lookup("fireball"), 5, victim, ch );
           }
	if ( IS_AFFECTED( victim, AFF_SHOCKSHIELD ) )
           {
             if ( number_percent( ) < 50 )
                spell_lightning_bolt ( skill_lookup("lightning bolt"), 15, victim, ch );
           }
	if ( IS_AFFECTED( victim, AFF_CHAOS ) )
           {
	     if ( number_percent( ) < 50 )
                spell_energy_drain ( skill_lookup("energy drain"), 25, victim, ch );
           }
	if ( IS_AFFECTED( victim, AFF_VIBRATING ) )
           {
             if ( number_percent( ) < 50 )
                spell_psionic_blast ( skill_lookup("psionic blast"), 25, victim, ch );
           }*/
    
    if ( IS_NPC( ch ) )
    {
	dam = number_range( ch->level / 3, ch->level );
	if ( wield )
	    dam += dam / 4;
    }
    else
    {
	if ( wield )
	    dam = number_range( wield->value[1], wield->value[2] );
/*	else if ( (is_class( ch, CLASS_WEREWOLF ) 
	     || is_class( ch, CLASS_MONK ))
	     && !wield )
	    dam = UMAX( number_fuzzy( ch->level / 2 + ch->level / 15 ),
			number_fuzzy( 5 ) ); */
	else
	    dam = number_range( 1, 4 );
	if ( wield && dam > 1000 )
	{
	    sprintf( buf, "One_hit dam range > 1000 from %d to %d",
		    wield->value[1], wield->value[2] );
	    bug( buf, 0 );
	}
    }

    /*
     * Bonuses.
     */
    dam += GET_DAMROLL( ch );
    if ( wield && IS_SET( wield->extra_flags, ITEM_POISONED ) )
        dam += dam / 4;
    if (
	(wield && IS_SET( wield->extra_flags, ITEM_FLAME ) )
    ||	(!wield && is_affected( ch, gsn_flamehand ) )
       )
        dam += dam / 8;
    if ( 
	(wield && IS_SET( wield->extra_flags, ITEM_CHAOS ) )
    ||	(!wield && is_affected( ch, gsn_chaoshand ) )
       )
        dam += dam / 8;
    if ( 
	(wield && IS_SET( wield->extra_flags, ITEM_ICY   ) )
    ||	(!wield && is_affected( ch, gsn_frosthand ) )
       )
        dam += dam / 4;
/*    if ( is_class( ch, CLASS_WEREWOLF ) && !wield )
	dam += dam / 4; */
    if ( !IS_NPC( ch ) && ch->pcdata->learned[gsn_enhanced_damage] > 0 )
    {
	dam += dam * ch->pcdata->learned[gsn_enhanced_damage] / 150;
	update_skpell( ch, gsn_enhanced_damage );
    }
    if ( !IS_NPC( ch ) && ch->pcdata->learned[gsn_enhanced_claw] > 0
    && !wield )
    {
	dam += dam * ch->pcdata->learned[gsn_enhanced_claw] / 150;
	update_skpell( ch, gsn_enhanced_claw );
    }
    if ( !IS_NPC( ch ) && ch->pcdata->learned[gsn_enhanced_two] > 0 )
    {
        dam += dam * ch->pcdata->learned[gsn_enhanced_two] / 150;
	update_skpell( ch, gsn_enhanced_two );
    }
    if ( !IS_NPC( ch ) && ch->pcdata->learned[gsn_enhanced_three] > 0 )
    {
        dam += dam * ch->pcdata->learned[gsn_enhanced_three] / 150;
	update_skpell( ch, gsn_enhanced_three );
    }
    if ( !IS_AWAKE( victim ) )
	dam *= 2;
    if ( dt == gsn_backstab )
	dam *= 2 + UMIN( ( ch->level / 8) , 4 );

    if ( dam <= 0 )
	dam = 1;
    if (IS_NPC(ch) && IS_SET(ch->act, ACT_NODAMAGE))
        dam = 0;

    damage( ch, victim, dam, dt );
    tail_chain( );
    return;
}

void one_triple( CHAR_DATA *ch, CHAR_DATA *victim, int dt )
{
    OBJ_DATA *wield;
    char      buf [ MAX_STRING_LENGTH ];
    int       victim_ac;
    int       thac0;
    int       thac0_00;
    int       thac0_97;
    int       dam;
    int       diceroll;

    /*
     * Can't beat a dead char!
     * Guard against weird room-leavings.
     */
/*    if ( !(get_eq_char( ch, WEAR_WIELD_3 ))
    && !is_class( ch, CLASS_WEREWOLF ) )
 	return; */
    if (ch->race != RACE_KREEN )
	return;
/*    if ( is_class( ch, CLASS_WEREWOLF )
    && ( get_eq_char( ch, WEAR_SHIELD )
    || get_eq_char( ch, WEAR_HOLD ) ) )
	return;
    if ( is_class( ch, CLASS_MONK )
    && ( get_eq_char( ch, WEAR_SHIELD )
    || get_eq_char( ch, WEAR_HOLD ) ) )
	return;
    if ( is_class( ch, CLASS_WEREWOLF ) &&
    ch->pcdata->learned[gsn_dualclaw] == 0 
    && !get_eq_char( ch, WEAR_WIELD_3 ) )
	return; */
    if ( victim->position == POS_DEAD || ch->in_room != victim->in_room )
	return;

    if ( IS_STUNNED( ch, STUN_NON_MAGIC ) ||
	 IS_STUNNED( ch, STUN_TOTAL ) )
      return;

    /*
     * Figure out the type of damage message.
     */
    wield = get_eq_char( ch, WEAR_WIELD_3 );
    if ( dt == TYPE_UNDEFINED )
    {
	dt = TYPE_HIT;
	if ( wield && wield->item_type == ITEM_WEAPON )
	    dt += wield->value[3];
/*	else if ( is_class( ch, CLASS_WEREWOLF ) && !wield )
	    dt += 5; */
    }

    /*
     * Calculate to-hit-armor-class-0 versus armor.
     */
    if ( IS_NPC( ch ) )
    {
	thac0_00 =  20;
	thac0_97 = -20;
    }
    else
    {
	thac0_00 = class_table[prime_class(ch)].thac0_00;
	thac0_97 = class_table[prime_class(ch)].thac0_97;
    }
    thac0     = interpolate( ch->level, thac0_00, thac0_97 )
              - GET_HITROLL( ch );
    victim_ac = UMAX( -15, GET_AC( victim ) / 10 );
    if ( !can_see( ch, victim ) )
	victim_ac -= 4;

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


    /*
     * Hit.
     * Calc damage.
     */
/*	if ( IS_AFFECTED( victim, AFF_FIRESHIELD ) )
           {
             if ( number_percent( ) < 50 )
                spell_fireball ( skill_lookup("fireball"), 5, victim, ch
);
           }
	if ( IS_AFFECTED( victim, AFF_SHOCKSHIELD ) )
           {
             if ( number_percent( ) < 50 )
                spell_lightning_bolt ( skill_lookup("lightning bolt"), 15,
victim, ch );
           }
	if ( IS_AFFECTED( victim, AFF_CHAOS ) )
           {
	     if ( number_percent( ) < 50 )
                spell_energy_drain ( skill_lookup("energy drain"), 25,
victim, ch );
           }
	if ( IS_AFFECTED( victim, AFF_VIBRATING ) )
           {
             if ( number_percent( ) < 50 )
                spell_psionic_blast ( skill_lookup("psionic blast"), 25,
victim, ch );
           }*/
    
    if ( IS_NPC( ch ) )
    {
	dam = number_range( ch->level / 3, ch->level );
	if ( wield )
	    dam += dam / 4;
    }
    else
    {
	if ( wield )
	    dam = number_range( wield->value[1], wield->value[2] );
/*	else if ( is_class( ch, CLASS_WEREWOLF )
	     && !wield )
	    dam = UMAX( number_fuzzy( ch->level / 2 + ch->level / 15 ),
			number_fuzzy( 5 ) ); */
	else
	    dam = number_range( 1, 4 );
	if ( wield && dam > 1000 )
	{
	    sprintf( buf, "One_hit dam range > 1000 from %d to %d",
		    wield->value[1], wield->value[2] );
	    bug( buf, 0 );
	}
    }

    /*
     * Bonuses.
     */
    dam += GET_DAMROLL( ch );
    if ( wield && IS_SET( wield->extra_flags, ITEM_POISONED ) )
        dam += dam / 4;
    if (
	(wield && IS_SET( wield->extra_flags, ITEM_FLAME ) )
    ||	(!wield && is_affected( ch, gsn_flamehand ) )
       )
        dam += dam / 8;
    if ( 
	(wield && IS_SET( wield->extra_flags, ITEM_CHAOS ) )
    ||	(!wield && is_affected( ch, gsn_chaoshand ) )
       )
        dam += dam / 8;
    if ( 
	(wield && IS_SET( wield->extra_flags, ITEM_ICY   ) )
    ||	(!wield && is_affected( ch, gsn_frosthand ) )
       )
        dam += dam / 4;
/*    if ( is_class( ch, CLASS_WEREWOLF ) && !wield )
	dam += dam / 4; */
    if ( !IS_NPC( ch ) && ch->pcdata->learned[gsn_enhanced_damage] > 0 )
    {
	dam += dam * ch->pcdata->learned[gsn_enhanced_damage] / 150;
	update_skpell( ch, gsn_enhanced_damage );
    }
    if ( !IS_NPC( ch ) && ch->pcdata->learned[gsn_enhanced_claw] > 0
    && !wield )
    {
	dam += dam * ch->pcdata->learned[gsn_enhanced_claw] / 150;
	update_skpell( ch, gsn_enhanced_claw );
    }
    if ( !IS_NPC( ch ) && ch->pcdata->learned[gsn_enhanced_two] > 0 )
    {
        dam += dam * ch->pcdata->learned[gsn_enhanced_two] / 150;
	update_skpell( ch, gsn_enhanced_two );
    }
    if ( !IS_NPC( ch ) && ch->pcdata->learned[gsn_enhanced_three] > 0 )
    {
        dam += dam * ch->pcdata->learned[gsn_enhanced_three] / 150;
	update_skpell( ch, gsn_enhanced_three );
    }
    if ( !IS_AWAKE( victim ) )
	dam *= 2;
    if ( dt == gsn_backstab )
	dam *= 2 + UMIN( ( ch->level / 8) , 4 );

    if ( dam <= 0 )
	dam = 1;
    if (IS_NPC(ch) && IS_SET(ch->act, ACT_NODAMAGE))
        dam = 0;

    damage( ch, victim, dam, dt );
    tail_chain( );
    return;
}


/*
 * Inflict damage from a hit.
 */
void damage( CHAR_DATA *ch, CHAR_DATA *victim, int dam, int dt )
{
    OBJ_DATA *parmor;
    DESCRIPTOR_DATA *d;
	float soak;

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

    if(!IS_NPC(ch) && !IS_NPC(victim))
    {
      if (!(ch == victim) )
      {
       ch->combat_timer = 90;
       victim->combat_timer = 90;
      }
    }

    /*
     * Stop up any residual loopholes.
     */

    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 )
		set_fighting( victim, ch );
	    victim->position = POS_FIGHTING;
	}

	if ( victim->position > POS_STUNNED )
	{
	    if ( !ch->fighting )
		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
		&& victim->master->in_room == ch->in_room
		&& number_bits( 3 ) == 0 )
	    {
		stop_fighting( ch, FALSE );
		set_fighting( ch, victim->master );
		return;
	    }
	}

	/*
	 * 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(AT_GREY, "$n fades into existence.", ch, NULL, NULL, TO_ROOM );
	}
	if (IS_AFFECTED2( ch, AFF_PHASED ) )
	{
            affect_strip ( ch, skill_lookup("phase shift") );
	    affect_strip ( ch, skill_lookup("mist form") );
	    REMOVE_BIT( ch->affected_by2, AFF_PHASED );
	    act(AT_GREY, "$n returns from an alternate plane.", ch, NULL, NULL, TO_ROOM );
	}
	/*
	 * Damage modifiers.
	 */
	if ( ch->race == RACE_OGRE )
            dam -= dam / 20;
	if ( ( ( parmor = parmor_check( victim ) ) != NULL )
        && ( parmor->value[1] > 0 ) )
	{
/*        dam -= dam * pow( parmor->value[1], -1 ); */
		soak = (10 - parmor->value[1]) / 10;
	dam = dam * soak;
	}
	/*
    if ( ch->level < L_APP && ch->class == CLASS_VAMPIRE )
     if ( !IS_SET( ch->in_room->room_flags, ROOM_INDOORS ) )
     {
      if ( time_info.hour > 6 && time_info.hour < 18 )
      {
       send_to_char( AT_RED, 
       "The sunlight has weakened your attack.\n\r", ch );
       dam -= dam / 2;
      }
    }

    if ( victim->level < L_APP && victim->class == CLASS_VAMPIRE )
     if ( !IS_SET( victim->in_room->room_flags, ROOM_INDOORS ) )
     {
      if ( time_info.hour > 6 && time_info.hour < 18 )
      {
       send_to_char( AT_RED, 
       "The sunlight has weakened your defence.\n\r", victim );
       dam += dam / 2;
      }
    }

    if ( ch->class == CLASS_VAMPIRE )
     if ( !IS_SET( ch->in_room->room_flags, ROOM_INDOORS ) )
     {
      if ( time_info.hour > 23 || time_info.hour < 1 )
      {
	dam *= 2;
      }
    }

    if ( victim->class == CLASS_VAMPIRE )
     if ( !IS_SET( victim->in_room->room_flags, ROOM_INDOORS ) )
     {
      if ( time_info.hour > 23 || time_info.hour < 1 )
      {
	dam /= 2;
      }
    }
*/
	/*
	 * Check for disarm, trip, parry, and dodge.
	 */
	if (    dt >= TYPE_HIT           || dt == gsn_feed
	     || dt == gsn_jab_punch      || dt == gsn_kidney_punch
	     || dt == gsn_cross_punch    || dt == gsn_roundhouse_punch
	     || dt == gsn_uppercut_punch || dt == gsn_punch
	     || dt == gsn_flykick        || dt == gsn_high_kick
	     || dt == gsn_jump_kick      || dt == gsn_spin_kick 
	     || dt == gsn_kick
  	   )
	{
	    int leveldiff = ch->level - victim->level;

	    if ( IS_NPC( ch ) && number_percent( )
		< ( leveldiff < -5 ? ch->level / 2 : UMAX( 10, leveldiff ) )
		&& dam == 0 && number_bits(4) == 0)
		disarm( ch, victim );
	    if ( IS_NPC( ch ) && number_percent( )
		< ( leveldiff < -5 ? ch->level / 2 : UMAX( 20, leveldiff ) )
		&& dam == 0 && number_bits(4) == 0)
		trip( ch, victim );
	    if ( check_parry( ch, victim ) && dam > 0 )
		return;
	    if ( check_dodge( ch, victim ) && dam > 0 )
		return;
	    if ( check_sidestep( ch, victim ) && dam > 0 )
		return;   
/*	if (can_use_skpell( ch, gsn_counter )) {
	    if ( check_counter( ch, victim ) && dam > 0 )
		return; } */
       }
/*    if ( !IS_NPC( ch )
    && ( dt == 1014 || dt == 1015                   
		    || ( dt == 1005                
			 && is_class( ch, CLASS_WEREWOLF )
			 && is_class( ch, CLASS_MONK )
			 && is_bare_hand( ch ) ) )
    && ch->pcdata->learned[gsn_anatomyknow] > 0
    && number_percent( ) <= ch->pcdata->learned[gsn_anatomyknow] / 9 )
	{
	update_skpell( ch, gsn_anatomyknow );
	send_to_char( AT_RED, "You hit a pressure point!\n\r", ch );
	act( AT_RED, "$n hit one of $N's pressure points!",
		     ch, NULL, victim, TO_NOTVICT );
	act( AT_RED, "$n hit you with a precise shot.", 
		     ch, NULL, victim, TO_VICT );
	if ( number_percent( ) < 2 )
		{
		victim->hit = 1;
		}
	else if ( number_percent( ) < 10 )
		{
		STUN_CHAR( victim, 2, STUN_TOTAL );
		victim->position = POS_STUNNED;
		dam *= 4;
		}
	else
		dam += 500;
	} */

	
	if ( IS_AFFECTED( victim, AFF_SANCTUARY ) )
	    dam /= 2;
        if ( IS_AFFECTED2( victim, AFF_GOLDEN ) )
	    dam /= 4;
	if ( IS_AFFECTED2( victim, AFF_DANCING ) )
	    dam += dam/2;
	if ( IS_AFFECTED( victim, AFF_FIRESHIELD )
        && !( dt == gsn_backstab && chance( number_range( 5, 10 ) ) ) )
	    dam -= dam / 8;
	if ( IS_AFFECTED( victim, AFF_ICESHIELD )
        && !( dt == gsn_backstab && chance( number_range( 5, 10 ) ) ) )
	    dam -= dam / 8;
	if ( IS_AFFECTED( victim, AFF_CHAOS )
        && !( dt == gsn_backstab && chance( number_range( 5, 10 ) ) ) )
	    dam -= dam / 4;
	if ( IS_AFFECTED( victim, AFF_SHOCKSHIELD )
        && !( dt == gsn_backstab && chance( number_range( 5, 10 ) ) ) )
	    dam -= dam / 4;
	if ( IS_AFFECTED( victim, AFF_VIBRATING )
        && !( dt == gsn_backstab && chance( number_range( 5, 10 ) ) ) )
	    dam -= dam / 4;
	if ( IS_AFFECTED2( victim, AFF_INERTIAL ) )
	    dam -= dam / 8;
        if ( IS_SET( victim->act, UNDEAD_TYPE( victim ) ) )
            dam -= dam / 8;      
	if ( IS_AFFECTED2( victim, AFF_BLADE )
        && !( dt == gsn_backstab && chance( number_range( 5, 10 ) ) ) )
	    dam -= dam / 4;
	if ( IS_AFFECTED2( victim, AFF_FIELD )
        && !( dt == gsn_backstab && chance( number_range( 5, 10 ) ) ) )
	    dam -= dam / 4;
	if ( IS_AFFECTED( victim, AFF_PROTECT   )
	    && IS_EVIL( ch ) )
	    dam -= dam / 4;
	if ( IS_AFFECTED2( victim, AFF_PROTECTION_GOOD )
	    && IS_EVIL( ch ) )
	    dam -= dam / 4;
	if ( dam < 0 )
	    dam = 0;

    }

    /* We moved dam_message out of the victim != ch if above
     * so self damage would show.  Other valid type_undefined
     * damage is ok to avoid like mortally wounded damage - Kahn
     */
    if ( ( !IS_NPC(ch) ) && ( !IS_NPC(victim) ) )
       dam -= dam/4;

    /*
     * Hurt the victim.
     * Inform the victim of his new state.
     */
    if ( !IS_NPC(ch) && prime_class( ch ) == CLASS_SOLDIER )
       dam += dam/2;
    if ( ( !IS_NPC(ch) ) && (ch->race == RACE_OGRE ) )
       dam += dam/10;
    if (!IS_NPC(ch) && !IS_NPC(victim))
      dam /= number_range(2, 4);
    if ( dt != TYPE_UNDEFINED )
	if ( dam > 0 )
        dam_message( ch, victim, dam, dt );                                    

    if ( dam > 25 && number_range( 0, 100 ) <= 15 )
      item_damage(victim, dam);

    victim->hit -= dam;
    if ( ( ( !IS_NPC( victim )                  /* so imms only die by */
	   && IS_NPC( ch )                      /* the hands of a PC   */
	   && victim->level >= LEVEL_IMMORTAL )
	 ||
	   ( !IS_NPC( victim )                   /* so imms don,t die  */
	   && victim->level >= LEVEL_IMMORTAL    /* by poison type dmg */
	   && ch == victim ) )                   /* since an imm == pc */
	 && victim->hit < 1 )
	    victim->hit = 1;

    if ( dam > 0 && dt > TYPE_HIT
	&& ( ( is_wielding_poisoned( ch )
	&& !saves_spell( ch->level, victim ) )
/*	|| ( is_class( ch, CLASS_WEREWOLF ) && is_bare_hand( ch ) ) */
        && victim->race != RACE_GHOUL ))
    {
	AFFECT_DATA af;

	af.type      = gsn_poison;
	af.duration  = 1;
	af.location  = APPLY_STR;
	af.modifier  = -2;
	af.bitvector = AFF_POISON;
	affect_join( victim, &af );
    }
    if ( dam > 0 && dt > TYPE_HIT
       && is_wielding_flaming( ch )
       && number_percent( ) < 10 )
          spell_fireball ( skill_lookup("fireball"), 20, ch, victim );
  if ( victim->position == POS_DEAD || ch->in_room != victim->in_room )
	return;

    if ( dam > 0 && ( dt == 1014 
		 || dt == 1015 
		 || ( dt == 1005 
/*		      && is_class( ch, CLASS_WEREWOLF )
		      && is_class( ch, CLASS_MONK ) */
		      && is_bare_hand( ch ) ) )
    && is_affected( ch, gsn_flamehand )
    && number_percent( ) < 33 )
	  spell_burning_hands( skill_lookup("burning hands"),
	  ch->level, ch, victim );
  if ( victim->position == POS_DEAD || ch->in_room != victim->in_room )
	return;

    if ( dam > 0 && dt > TYPE_HIT
       && is_wielding_icy( ch )
       && number_percent( ) < 20 )
          spell_icestorm ( skill_lookup("icestorm"), 30, ch, victim );  
  if ( victim->position == POS_DEAD || ch->in_room != victim->in_room )
	return;
    if ( dam > 0 && ( dt == 1014 
		 || dt == 1015 
		 || ( dt == 1005 
/*		      && is_class( ch, CLASS_WEREWOLF )
		      && is_class( ch, CLASS_MONK ) */
		      && is_bare_hand( ch ) ) )
    && is_affected( ch, gsn_frosthand )
    && number_percent( ) < 20 )
	spell_chill_touch( skill_lookup("chill touch"), ch->level * 3,
	ch, victim );
  if ( victim->position == POS_DEAD || ch->in_room != victim->in_room )
	return;

    if ( dam > 0 && dt > TYPE_HIT
       && is_wielding_chaos( ch )
       && number_percent( ) < 20 )
          spell_energy_drain ( skill_lookup("energy drain"), 45, ch, victim );
   if ( victim->position == POS_DEAD || ch->in_room != victim->in_room )
	return;
   if ( dam > 0 && ( dt == 1014 
		 || dt == 1015 
		 || ( dt == 1005 
/*		      && is_class( ch, CLASS_WEREWOLF )
		      && is_class( ch, CLASS_MONK ) */
		      && is_bare_hand( ch ) ) )
  && is_affected( ch, gsn_chaoshand )
  && number_percent( ) < 10 )
	spell_energy_drain( skill_lookup("energy drain"), 
	ch->level * 1.5, ch, victim );
  if ( victim->position == POS_DEAD || ch->in_room != victim->in_room )
	return;
       
    if (  IS_SET( ch->act, UNDEAD_TYPE( ch ) )
       && !saves_spell(ch->level, victim )
       && victim->race != RACE_GHOUL )
    {
	AFFECT_DATA af;

	af.type      = gsn_poison;
	af.duration  = 2;
	af.location  = APPLY_CON;
	af.modifier  = -1;
	af.bitvector = AFF_POISON;
	affect_join( victim, &af );
    }
       
    update_pos( victim );	
    switch( victim->position )
    {
    case POS_MORTAL:
	send_to_char(AT_RED, 
	    "You are mortally wounded, and will die soon, if not aided.\n\r",
	    victim );
	act(AT_RED, "$n is mortally wounded, and will die soon, if not aided.",
	    victim, NULL, NULL, TO_ROOM );
	break;

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

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

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

    default:
	if ( dam > MAX_HIT(victim) / 4 )
	    send_to_char(AT_RED, "That really did HURT!\n\r", victim );
	if ( victim->hit < MAX_HIT(victim) / 4 )
	    send_to_char(AT_RED, "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 )
    {
		if ( !IS_ARENA(ch) && !IS_SET( victim->act2, PLR_WAR ))
        {
			group_gain( ch, victim );
             if(((ch->guild != NULL) ? ch->guild->type & GUILD_CHAOS : 0)
              && ch->guild == victim->guild
              && victim->guild_rank > ch->guild_rank)
			 {
             int temp;
             temp = ch->guild_rank;
             ch->guild_rank = victim->guild_rank;
             victim->guild_rank = temp;
			 }
             if ( ( !IS_NPC(ch) ) && ( !IS_NPC(victim) ) )
			 { 
             CLAN_DATA  *pClan;
             CLAN_DATA  *Cland;
                if ( ch->clan != victim->clan )
				{
                   if ( !(abs(ch->level - victim->level) > 10 ))
				   {
                     if ( (pClan = get_clan_index(ch->clan)) != NULL )
                     pClan->pkills++;
                     if ( (Cland = get_clan_index(victim->clan)) != NULL )
                     Cland->pdeaths++;
				   }
				}
/*            REMOVE_BIT(victim->act, PLR_THIEF);*/
			 }
             if ( ( !IS_NPC(ch) ) && ( !IS_NPC(victim) ) )
			 {
                 if ( !(abs(ch->level - victim->level) > 10 ) )
				 {
	             ch->pkills++;
		         victim->pkilled++;
				 }
			 }
             if ( ( !IS_NPC(ch) ) && ( IS_NPC(victim) ) )
			 {
             CLAN_DATA    *pClan;
                if ( (pClan=get_clan_index(ch->clan)) != NULL )
                pClan->mkills++;
			 }
             if ( ( IS_NPC(ch) ) && (!IS_NPC(victim)) )
			 {
             CLAN_DATA   *pClan;
                if ( (pClan=get_clan_index(victim->clan)) != NULL )
                pClan->mdeaths++;
			 }
        
	         if ( !IS_NPC( victim ) )
			 {
	             if ( victim->level < LEVEL_HERO 
	             || ( victim->level >= LEVEL_HERO && IS_NPC( ch ) ) )
/*		         death_xp_loss( victim ); */
	             sprintf( log_buf, "%s killed by %s at %d.", victim->name,
	             ch->name, victim->in_room->vnum );
	             log_string( log_buf, CHANNEL_LOG, -1 );
                 wiznet(log_buf,NULL,NULL,WIZ_DEATHS,0,0);
	               if ( !IS_NPC( ch )
	               && IS_SET( victim->act, PLR_THIEF )
	               && ch->guild
	               && !strcmp( ch->guild->name, "MERCENARY" ) )
				   {
		           REMOVE_BIT( victim->act, PLR_THIEF );	
		           info( "%s the puny thief gets destroyed by the &rMERCENARY&C %s!",
		           (int)victim->name, (int)ch->name );
				   }
	             else if ( !IS_NPC( ch )
	             && IS_SET( ch->act, PLR_THIEF )
	             && victim->guild
	             && !strcmp( victim->guild->name, "MERCENARY" ) )
		         info( "%s, the sly thief, has killed the &rMERCENARY&C %s.",
		         (int)ch->name, (int)victim->name );
	             else
	             info( "%s gets slaughtered by %s!", (int)victim->name,
                  (int)(IS_NPC(ch) ? ch->short_descr : ch->name) );
	             save_clans();
			 }
	}
	else if(war.iswar == TRUE && IS_SET(victim->act2, PLR_WAR))
	{
	   char  buf[MAX_STRING_LENGTH];
	 
	   sprintf(buf, "&C%s &chas become a casualty of war.", victim->name );
	   info(buf, 0, 0 );
	   ch->warpts = ch->warpts + 1;
	   send_to_char(C_DEFAULT, "You have been awarded 1 war point for your kill.\n\r", ch);
	   ch->warkills = ch->warkills + 1;
	   victim->wardeaths = victim->wardeaths + 1;
       if(IS_SET(victim->act2, TEAM_RED))
	   {
		   war.team_red--;
       REMOVE_BIT(victim->act2, TEAM_RED);
	   }
       if(IS_SET(victim->act2, TEAM_BLUE))
	   {
		   war.team_blue--;
       REMOVE_BIT(victim->act2, TEAM_BLUE);
	   }
	   war.inwar--;
	    if (war.wartype == 1 && war.inwar == 1)
		{
	       sprintf( buf, "&C%s &Rhas survived iron man war!", ch->name );
	       info( buf, 0, 0 );
		   ch->warpts = ch->warpts + 100;
		   send_to_char(C_DEFAULT, "You have been awarded 100 war points for your victory.\n\r", ch);
	       war.wartype = 0;
	       war.max_level = 0;
	       war.max_level = 0;
	       war.inwar = 0;
	       war.count = 0;
	       war.timeleft = 0;
           war.iswar = FALSE;
	       REMOVE_BIT(ch->act2, PLR_WAR);
           if(IS_SET(ch->act2, TEAM_RED))
           REMOVE_BIT(ch->act2, TEAM_RED);
           if(IS_SET(ch->act2, TEAM_BLUE))
           REMOVE_BIT(ch->act2, TEAM_BLUE);
	       char_from_room(ch);
	       char_to_room(ch, get_room_index(ROOM_VNUM_TEMPLE));
		}
		else if(war.team_red == 0)
		{
	       sprintf( buf, "&CThe &BBLUE TEAM &chas won the war!" );
	       info( buf, 0, 0 );
		   ch->warpts = ch->warpts + 20;
		   send_to_char(C_DEFAULT, "You have been awarded 20 war points for the winning kill.\n\r", ch);
	       war.wartype = 0;
	       war.max_level = 0;
	       war.max_level = 0;
	       war.inwar = 0;
	       war.count = 0;
	       war.timeleft = 0;
           war.iswar = FALSE;
	       REMOVE_BIT(ch->act2, PLR_WAR);
           if(IS_SET(ch->act2, TEAM_RED))
           REMOVE_BIT(ch->act2, TEAM_RED);
           if(IS_SET(ch->act2, TEAM_BLUE))
           REMOVE_BIT(ch->act2, TEAM_BLUE);
	       char_from_room(ch);
	       char_to_room(ch, get_room_index(ROOM_VNUM_TEMPLE));

  for (d = descriptor_list; d != NULL; d = d->next)
  {
	if (!IS_NPC(d->character))
    {
      if (IS_SET(d->character->act2, PLR_WAR))
        REMOVE_BIT(d->character->act2, PLR_WAR);
          if(IS_SET(d->character->act2, TEAM_RED))
           REMOVE_BIT(d->character->act2, TEAM_RED);
           if(IS_SET(d->character->act2, TEAM_BLUE))
		   {
			ch->warpts = ch->warpts + 10;
			send_to_char(C_DEFAULT, "You have been awarded 10 war points for your victory.\n\r", ch);
           REMOVE_BIT(d->character->act2, TEAM_BLUE);
		   }
    }
		}
		}
				else if(war.team_blue == 0)
		{
	       sprintf( buf, "&CThe &RRED TEAM &chas won the war!" );
	       info( buf, 0, 0 );
		   ch->warpts = ch->warpts + 20;
		   send_to_char(C_DEFAULT, "You have been awarded 20 war points for the winning kill.\n\r", ch);
	       war.wartype = 0;
	       war.max_level = 0;
	       war.max_level = 0;
	       war.inwar = 0;
	       war.count = 0;
	       war.timeleft = 0;
           war.iswar = FALSE;
	       REMOVE_BIT(ch->act2, PLR_WAR);
           if(IS_SET(ch->act2, TEAM_RED))
           REMOVE_BIT(ch->act2, TEAM_RED);
           if(IS_SET(ch->act2, TEAM_BLUE))
           REMOVE_BIT(ch->act2, TEAM_BLUE);
	       char_from_room(ch);
	       char_to_room(ch, get_room_index(ROOM_VNUM_TEMPLE));
  for (d = descriptor_list; d != NULL; d = d->next)
  {
    if (!IS_NPC(d->character))
    {
      if (IS_SET(d->character->act2, PLR_WAR))
        REMOVE_BIT(d->character->act2, PLR_WAR);
          if(IS_SET(d->character->act2, TEAM_RED))
		   {
			ch->warpts = ch->warpts + 10;
			send_to_char(C_DEFAULT, "You have been awarded 10 war points for your victory.\n\r", ch);
           REMOVE_BIT(d->character->act2, TEAM_RED);
		  }
           if(IS_SET(d->character->act2, TEAM_BLUE))
           REMOVE_BIT(d->character->act2, TEAM_BLUE);
    }
  }
		}
		}
	    else if(!IS_SET(victim->act2, PLR_WAR))
		{
	    sprintf(log_buf, "&C%s &chas defeated &C%s &cin the arena!",
	          ch->name, victim->name);
	    wiznet(log_buf, NULL, NULL, WIZ_DEATHS, 0, 0);
	    log_string(log_buf, CHANNEL_LOG, -1);
	    challenge(log_buf, 0, 0);
	    ch->arenawon++;
	    victim->arenalost++;
		}

	      raw_kill( ch, victim );

	/* Ok, now we want to remove the deleted flag from the
	 * PC victim.
	 */
	       if ( !IS_NPC( victim ) )
	       victim->deleted = FALSE;

	     if ( !IS_NPC( ch ) && IS_NPC( victim ) )
		 {
	     if ( IS_SET( ch->act, PLR_AUTOLOOT ) )
		 do_get( ch, "all corpse" );
	     else
		 do_look( ch, "in corpse" );

	     if ( IS_SET( ch->act, PLR_AUTOCOINS ) )
	        do_get( ch, "all.coin corpse" );
	     if ( IS_SET( ch->act, PLR_AUTOSAC  ) )
		 do_sacrifice( ch, "corpse" );
		 }

	return;
    }

    if ( victim == ch )
	return;

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

    /*
     * Wimp out?
     */
    if ( IS_NPC( victim ) && dam > 0 )
    {
	if ( ( IS_SET( victim->act, ACT_WIMPY ) && number_bits( 1 ) == 0
	      && victim->hit < MAX_HIT(victim) / 2 )
	    || ( IS_AFFECTED( victim, AFF_CHARM ) && victim->master
		&& 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;
}

void item_damage( CHAR_DATA *ch, int dam )
{
        OBJ_DATA  *obj_lose;
        OBJ_DATA  *obj_next;
        
	for ( obj_lose = ch->carrying; obj_lose; obj_lose = obj_next )
	{
            char *msg;

	    obj_next = obj_lose->next_content;
	    if ( obj_lose->deleted )
	        continue;
	    if ( number_bits( 2 ) != 0 )
   		continue;
#ifdef NEW_MONEY
/* Check if total cost in copper is less than 500,000 */

	    if ( ( (obj_lose->pIndexData->cost.gold*C_PER_G) +
		    (obj_lose->pIndexData->cost.silver*S_PER_G) +
		    (obj_lose->pIndexData->cost.copper) ) < 5000*100 )
		continue;
#else
            if ( obj_lose->pIndexData->cost < 5000 )
                continue; 
#endif
	    if ( obj_lose->wear_loc == WEAR_NONE )
	        continue;
	    if ( IS_SET( obj_lose->extra_flags, ITEM_NO_DAMAGE ) )
	        continue;
       	    switch ( obj_lose->item_type )
	    {
	    default:
	      msg = "Your $p gets ruined!";
	      extract_obj( obj_lose );
	      break;
	    case ITEM_DRINK_CON:
	    case ITEM_POTION:
	    case ITEM_CONTAINER:
	    case ITEM_LIGHT:
	      msg = "Your $p shatters!";
	      extract_obj( obj_lose );
	      break;
            case ITEM_WEAPON:
	    case ITEM_ARMOR:
#ifdef NEW_MONEY
/*		 if ( ( obj_lose->cost.gold +
		      (obj_lose->cost.silver/SILVER_PER_GOLD) +
		      (obj_lose->cost.copper/COPPER_PER_GOLD) ) != 0 )
*/
		 if ( ( (obj_lose->cost.gold*100) +
			(obj_lose->cost.silver*10) +
			(obj_lose->cost.copper) ) != 0 )
		 {
		    obj_lose->cost.gold   = ( obj_lose->cost.gold > 0 ) ? 
					    (obj_lose->cost.gold - dam/6) : 0;
		    obj_lose->cost.silver = ( obj_lose->cost.silver > 0 ) ?
					    (obj_lose->cost.silver - dam/6) : 0;
		    obj_lose->cost.copper = ( obj_lose->cost.copper > 0 ) ?
					    (obj_lose->cost.copper - dam/6) : 0;
		 }
/*		 if ( (obj_lose->cost.gold +
 		      (obj_lose->cost.silver/SILVER_PER_GOLD) +
		      (obj_lose->cost.copper/COPPER_PER_GOLD) ) < 0 )
*/
		 if ( ( (obj_lose->cost.gold*100) +
			(obj_lose->cost.silver*10) +
			(obj_lose->cost.copper) ) < 0 )
#else
              	 if ( obj_lose->cost != 0 )
              	    obj_lose->cost -= dam/6;
              	 if (obj_lose->cost < 0)
#endif
              	   {
              	    OBJ_DATA       *pObj;
              	    OBJ_INDEX_DATA *pObjIndex;
              	    char           *name;
              	    char           buf[MAX_STRING_LENGTH];
              	    
              	    pObjIndex = get_obj_index(4);
              	    pObj = create_object(pObjIndex, obj_lose->level);
              	    name = obj_lose->short_descr;
              	    sprintf(buf, pObj->description, name);
              	    free_string(pObj->description);
              	    pObj->description = str_dup(buf);
              	    pObj->weight = obj_lose->weight;
              	    pObj->timer = obj_lose->level;
              	    msg = "$p has been destroyed!";
              	    extract_obj( obj_lose );
              	    obj_to_room ( pObj, ch->in_room );
              	   }
              	  else
              	   {
              	    msg = "$p has been damaged!";
              	   }
              	  break;
              	    
	    }

	    act(AT_YELLOW, msg, ch, obj_lose, NULL, TO_CHAR );
            return;	
  	}
    return;
}

bool is_safe( CHAR_DATA *ch, CHAR_DATA *victim )
{
  CLAN_DATA *pClan;

  if ( IS_SET( ch->in_room->room_flags, ROOM_SAFE ) ||
       IS_SET( victim->in_room->room_flags, ROOM_SAFE ) )
    return TRUE;

  if ( !IS_NPC(ch) && !IS_NPC(victim) &&
       (IS_SET(ch->in_room->room_flags, ROOM_NO_PKILL) ||
	IS_SET(victim->in_room->room_flags, ROOM_NO_PKILL)) )
    return TRUE;

  if ( IS_AFFECTED( ch, AFF_PEACE ) )
      return TRUE;

  if ( IS_SET( ch->in_room->room_flags, ROOM_PKILL ) &&
       IS_SET( victim->in_room->room_flags, ROOM_PKILL ) )
    return FALSE;

  if ( IS_NPC( victim ) )
    return FALSE;

  if ( IS_SET( victim->act, PLR_THIEF )
  && ( ch->guild && !strcmp( ch->guild->name, "MERCENARY" ) ) )
	return FALSE;
  if ( IS_SET( ch->act, PLR_THIEF )
  && ( victim->guild && !strcmp( victim->guild->name, "MERCENARY" ) ) )
/*	return FALSE; */
        return TRUE;

/* SIGH
  if ( !(IS_SET(ch->act, PLR_PKILLER)) || ( (IS_SET(ch->act, PLR_PKILLER)) &&
       !(IS_SET(victim->act, PLR_PKILLER)) ) )
  {
    send_to_char(AT_WHITE, "You cannot pkill unless you are BOTH pkillers!\n\r", ch );
    return TRUE;
  }
*/
/*
  if ( abs(ch->level - victim->level) > 10 && ( !IS_NPC(ch) ) )
  {
    send_to_char(AT_WHITE, "That is not in the pkill range... valid range is +/- 10 levels.\n\r", ch );
    return TRUE;
  }
*/
  if ( IS_NPC( ch ) )
  {
    if ( IS_SET(ch->affected_by, AFF_CHARM) && ch->master )
    {
      CHAR_DATA *nch;

      for ( nch = ch->in_room->people; nch; nch = nch->next )
	if ( nch == ch->master )
	  break;

      if ( nch == NULL )
	return FALSE;
      else
	ch = nch; /* Check person who ordered mob for clan stuff.. */
    }
    else
      return FALSE;
  }

/* give pkill guilds ability to pkill */
/* Err.. we might not want pkill guilds attacking unguilded.. */
  if ( (ch->guild && (ch->guild->type & GUILD_PKILL)) &&
       (victim->guild && (victim->guild->type & GUILD_PKILL)) )
  {
    return FALSE;
  }

  pClan = get_clan_index( ch->clan );

  if ( ( ch->clan == 0 ) && ( !IS_SET(pClan->settings, CLAN_PKILL) ) )
  {
    send_to_char(AT_WHITE, "You must be clanned to murder.\n\r", ch );
    return TRUE;
  }

  pClan = get_clan_index( victim->clan);

  if ( ( victim->clan == 0 ) && ( !IS_SET(pClan->settings, CLAN_PKILL) ) )
  {
    send_to_char(AT_WHITE, "You can only murder clanned players.\n\r",ch);
    return TRUE;
  }

  pClan = get_clan_index( ch->clan );

  if ( ch->clan == victim->clan &&
       IS_SET( pClan->settings, CLAN_CIVIL_PKILL) )
  {
   return FALSE;
  }

/* can murder self for testing =) */
  if ( ch->clan == victim->clan && ch != victim && ch->clan != 0 )
  {
    send_to_char(AT_WHITE, "You cannot murder your own clan member.\n\r",ch);
    return TRUE;
  }

  if ( !IS_SET(pClan->settings, CLAN_PKILL) )
  {
    send_to_char(AT_WHITE, "Peaceful clan members cannot murder.\n\r",ch);
    return TRUE;
  }

  pClan = get_clan_index( victim->clan );
  if ( !IS_SET(pClan->settings, CLAN_PKILL ))
  {
    send_to_char(AT_WHITE, "You may not murder peaceful clan members.\n\r",ch);
    return TRUE;
  }

  if ( IS_SET( victim->act, PLR_KILLER ) )
    return FALSE;


  return FALSE;
}



/*
 * See if an attack justifies a KILLER flag.
 */
void check_killer( CHAR_DATA *ch, CHAR_DATA *victim )
{
    CLAN_DATA *pClan;
    char 	buf [ MAX_STRING_LENGTH ];
    
    if ( IS_ARENA(victim) )
      return;
    /*
     * NPC's are fair game.
     * So are killers and thieves.
     */
    if (   IS_NPC( victim )
	|| IS_SET( victim->act, PLR_KILLER )
	|| IS_SET( victim->act, PLR_THIEF  ) )
	return;
     
    /*
     * NPC's are cool of course
     * Hitting yourself is cool too (bleeding).
     * And current killers stay as they are.
     */
    if ( IS_NPC( ch )
	|| ch == victim
	|| IS_SET( ch->act, PLR_KILLER ) 
	|| IS_SET( ch->act, PLR_THIEF ) )
	return;
    pClan = get_clan_index( ch->clan );
    if ( /*ch->clan != 0 ||*/ ( IS_SET(pClan->settings, CLAN_PKILL) ) ||
( ch->clan == victim->clan && IS_SET(pClan->settings, CLAN_CIVIL_PKILL)) )
       return;
    send_to_char(AT_RED, "*** You are now a KILLER!! ***\n\r", ch );
    sprintf(buf,"$N is attempting to murder %s",victim->name);
    wiznet(buf,ch,NULL,WIZ_FLAGS,0,0);
    SET_BIT(ch->act, PLR_KILLER);
    save_char_obj( ch, FALSE );
    return;
}

bool is_bare_hand( CHAR_DATA *ch )
{
    if ( !get_eq_char( ch, WEAR_WIELD ) 
    && !get_eq_char( ch, WEAR_WIELD_2 ) )
	return TRUE;
    return FALSE;
}

/*
 * Check to see if weapon is poisoned.
 */
bool is_wielding_poisoned( CHAR_DATA *ch )
{
    OBJ_DATA *obj;

    if ( ( obj = get_eq_char( ch, WEAR_WIELD ) )
	&& IS_SET( obj->extra_flags, ITEM_POISONED ) )
        return TRUE;

    return FALSE;

}
bool is_wielding_flaming( CHAR_DATA *ch )
{
    OBJ_DATA *obj;

    if ( ( obj = get_eq_char( ch, WEAR_WIELD ) )
	&& IS_SET( obj->extra_flags, ITEM_FLAME ) )
        return TRUE;

    return FALSE;

}

bool is_wielding_icy( CHAR_DATA *ch )
{
    OBJ_DATA *obj;

    if ( ( obj = get_eq_char( ch, WEAR_WIELD ) )
	&& IS_SET( obj->extra_flags, ITEM_ICY ) )
        return TRUE;

    return FALSE;

}
bool is_wielding_chaos( CHAR_DATA *ch )
{
    OBJ_DATA *obj;

    if ( ( obj = get_eq_char( ch, WEAR_WIELD ) )
	&& IS_SET( obj->extra_flags, ITEM_CHAOS ) )
        return TRUE;

    return FALSE;

}


/*
 * Check for parry.
 */
bool check_parry( CHAR_DATA *ch, CHAR_DATA *victim )
{
    int chance;

    if ( !IS_AWAKE( victim ) )
	return FALSE;

    if (!can_use_skpell( ch, gsn_parry ) )
	return FALSE;

    if ( IS_NPC( victim ) )
    {
	/* Tuan was here.  :) */
	chance	= UMIN( 60, 2 * victim->level );
	if ( !get_eq_char( victim, WEAR_WIELD ) )
	    chance = chance / 2;
    }
    else
    {
	if ( !get_eq_char( victim, WEAR_WIELD ) )
	    return FALSE;
	chance	= victim->pcdata->learned[gsn_parry] / 2;
    }

    if ( ch->wait != 0 )
      chance /= 4;

    if ( number_percent( ) >= chance + victim->level - ch->level )
	return FALSE;

    update_skpell( ch, gsn_parry );

    if ( IS_SET( ch->act, PLR_COMBAT ) )
      act(AT_GREEN, "$N parries your attack.", ch, NULL, victim, TO_CHAR    );
    if ( IS_SET( victim->act, PLR_COMBAT ) )
      act(AT_GREEN, "You parry $n's attack.",  ch, NULL, victim, TO_VICT    );
    return TRUE;
}



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

    if ( !IS_AWAKE( victim ) )
	return FALSE;

    if (!can_use_skpell( ch, gsn_dodge ))
        return FALSE;

    if ( IS_NPC( victim ) )
	/* Tuan was here.  :) */
        chance  = UMIN( 60, 2 * victim->level );
    else
        chance  = victim->pcdata->learned[gsn_dodge] / 2
		+ victim->pcdata->learned[gsn_dodge_two] / 2;

    if ( ch->wait != 0 )
      chance /= 4;

    if ( number_percent( ) >= chance + victim->level - ch->level )
        return FALSE;

    update_skpell( ch, gsn_dodge );

    if ( can_use_skpell( ch, gsn_dodge_two ) )
	update_skpell( ch, gsn_dodge_two );

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

bool check_sidestep( CHAR_DATA *ch, CHAR_DATA *victim )
{
    int chance;

    if ( !IS_AWAKE( victim ) )
        return FALSE;
    
    if ( IS_NPC( victim ) )
        /* Tuan was here.  :) */
        return FALSE;
    
    if ( victim->race != RACE_SHADOW )
        return FALSE;
    
    chance = 50;
    
    if ( number_percent( ) >= chance + victim->level - ch->level )
        return FALSE;         
            
    if ( IS_SET( ch->act, PLR_COMBAT ) )
      act(AT_GREEN, "$N sidesteps your attack.", ch, NULL, victim, TO_CHAR    );
    if ( IS_SET( victim->act, PLR_COMBAT ) )
      act(AT_GREEN, "You sidestep $n's attack.", ch, NULL, victim, TO_VICT    );
    return TRUE;
}
bool    check_counter( CHAR_DATA *ch, CHAR_DATA *victim )
{
	int chance;

    if ( !IS_AWAKE( victim ) )
        return FALSE;

    if (!can_use_skpell( ch, gsn_counter ))
        return FALSE;

    if ( IS_NPC( victim ) )
    {
        return FALSE;
    }
    else
    {
        chance  = victim->pcdata->learned[gsn_counter] / 2;
    }

    if ( ch->wait != 0 )
      chance /= 4;

    if ( number_percent( ) >= chance + victim->level - ch->level )
        return FALSE;

    update_skpell( ch, gsn_counter );

    if ( IS_SET( ch->act, PLR_COMBAT ) )
      act(AT_GREEN, "$N counters your attack...OUCH!", 
      ch, NULL, victim, TO_CHAR );
    if ( IS_SET( victim->act, PLR_COMBAT ) )
      act(AT_GREEN, "You counter $n's attack.",  
      ch, NULL, victim, TO_VICT );
        damage( victim, ch, number_range( 400, ch->level*4 )*(2 + UMIN( (
                ch->level / 8) , 4 )), gsn_counter );
    return TRUE;
}


/*
 * Set position of a victim.
 */
void update_pos( CHAR_DATA *victim )
{
    if ( victim->hit > 0 )
    {
    	if ( victim->position < POS_STUNNED )
	    victim->position = POS_STANDING;
	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 )
{

    char buf [ MAX_STRING_LENGTH ];

    if ( ch->fighting )
    {
	bug( "Set_fighting: already fighting", 0 );
	sprintf( buf, "...%s attacking %s at %d", 
		( IS_NPC( ch )     ? ch->short_descr     : ch->name     ),
		( IS_NPC( victim ) ? victim->short_descr : victim->name ),
		victim->in_room->vnum );
	bug( buf , 0 );
	return;
    }

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

    ch->fighting = victim;
    ch->position = POS_FIGHTING;

    return;
}



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

    for ( fch = char_list; fch; fch = fch->next )
    {
	if ( fch == ch || ( fBoth && fch->fighting == ch ) )
	{
	    fch->fighting	= NULL;
	    fch->hunting        = NULL;
	    fch->position	= POS_STANDING;
	    if ( is_affected( fch, gsn_berserk ) )
	    {
	      affect_strip( fch, gsn_berserk );
	      send_to_char(C_DEFAULT, skill_table[gsn_berserk].msg_off,fch);
	      send_to_char(C_DEFAULT, "\n\r",fch);
	      
	      act(C_DEFAULT, skill_table[gsn_berserk].room_msg_off,fch,
		  NULL, NULL, TO_ROOM);
	    }
	    else if ( is_affected( fch, gsn_frenzy ) )
	    {
	      affect_strip( fch, gsn_frenzy );
	      send_to_char(C_DEFAULT, skill_table[gsn_frenzy].msg_off,fch);
	      send_to_char(C_DEFAULT, "\n\r",fch);
	      act(C_DEFAULT,skill_table[gsn_frenzy].room_msg_off,fch,
		  NULL, NULL, TO_ROOM);
	    }
	    if ( IS_AFFECTED2(fch, AFF_BERSERK) )
              REMOVE_BIT(fch->affected_by2, AFF_BERSERK);
	    update_pos( fch );
	}
    }

    return;
}



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

    /* No corpses in the arena. -- Altrag */
    if ( IS_ARENA(ch) )
    {
      CHAR_DATA *gch = (ch == arena.fch ? arena.sch : arena.fch);
      int award;
      
      /* Arena master takes 1/5.. *wink* */
      award = (arena.award * 4) / 5;
      sprintf(log_buf, "&C%s &chas been awarded &W%d &ccoins for %s victory.",
              gch->name, award, (gch->sex == SEX_NEUTRAL ? "its" :
              (gch->sex == SEX_MALE ? "his" : "her")));
      /* wiznet(log_buf, NULL, NULL, WIZ_DEATHS, 0, 0); */
      log_string(log_buf, CHANNEL_LOG, -1);
      challenge(log_buf, 0, 0);
#ifdef NEW_MONEY
      gch->money.gold += award;
#else
      gch->gold += award;
#endif
      sprintf(log_buf, "You have been awarded %d credits for your victory."
              "\n\r", award);
      send_to_char(AT_YELLOW, log_buf, gch);
      char_from_room(gch);
      char_to_room(gch, get_room_index(ROOM_VNUM_ALTAR));
      return;
    }
      if ( !IS_NPC( ch ) && ch->level <= 20 )
    {
	char_from_room( ch );
	char_to_room( ch, get_room_index(ROOM_VNUM_MORGUE) );
    } 
    if ( IS_NPC( ch ) )
    {
        /*
	 * This longwinded corpse creation routine comes about because
	 * we dont want anything created AFTER a corpse to be placed  
	 * INSIDE a corpse.  This had caused crashes from obj_update()
	 * in extract_obj() when the updating list got shifted from
	 * object_list to obj_free.          --- Thelonius (Monk)
	 */
#ifdef NEW_MONEY
	if ( (ch->money.gold > 0) || (ch->money.silver > 0) ||
	     (ch->money.copper > 0) )
#else
	if ( ch->gold > 0 )
#endif
	{
	    OBJ_DATA * coins;
#ifdef NEW_MONEY
	    coins	  = create_money( &ch->money );
#else
	    coins         = create_money( ch->gold );
#endif
	    name	  = ch->short_descr;
	    corpse	  = create_object(
					  get_obj_index( OBJ_VNUM_CORPSE_NPC ),
					  0 );
	    corpse->timer = number_range( 2, 4 );
	    obj_to_obj( coins, corpse );
#ifdef NEW_MONEY
	    ch->money.gold = ch->money.silver = ch->money.copper = 0;
#else
	    ch->gold = 0;
#endif
	}
	else
	{
	    name	  = ch->short_descr;
	    corpse	  = create_object(
					  get_obj_index( OBJ_VNUM_CORPSE_NPC ),
					  0 );
	    corpse->timer = number_range( 2, 4 );
	}
    }
    else
    {
	name		= ch->name;
	corpse		= create_object(
					get_obj_index( OBJ_VNUM_CORPSE_PC ),
					0 );
	corpse->timer	= number_range( 25, 40 );

#ifdef NEW_MONEY
/* Check if ch has any money, doesn't matter about converting */

	if ( ( ( ch->money.gold + ch->money.silver + 
		 ch->money.copper ) > 0 ) &&
	        ( ch->level > 5 ) )
	{
	  OBJ_DATA * coins;
	  coins = create_money( &ch->money );
	  obj_to_obj( coins, corpse );
	  ch->money.gold = ch->money.silver = ch->money.copper = 0;
	}
#else
	if ( ( ch->gold > 0 ) && ( ch->level > 5 ) )
	{
	  OBJ_DATA * coins;
	  coins = create_money( ch->gold );
	  obj_to_obj( coins, corpse );
	  ch->gold = 0;
	}
#endif
    }

    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 );
	corpse->dimension = ch -> dimension;

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

        if ( obj->deleted )
	    continue;
	obj_from_char( obj );
	obj->dimension = corpse->dimension;
	if ( IS_SET( obj->extra_flags, ITEM_INVENTORY ) )
	    extract_obj( obj );
	else
	    obj_to_obj( obj, corpse );
    }
	if ( ch->dimension > 0 )
	{
		dimension.used[ch->dimension] = NULL;
		change_dimension( ch, 0 );
	}

/*    sprintf( buf, "NPC killed: %s -> %d", ch->name, ch->in_room->vnum );
    log_string( buf, CHANNEL_NONE, -1 );
    wiznet(buf,NULL,NULL,WIZ_MOBDEATHS,0,0);*/
    if ( ( IS_NPC( ch ) ) && ( !IS_SET( ch->act, UNDEAD_TYPE( ch ) ) ) )
       corpse->ac_vnum=ch->pIndexData->vnum;
    obj_to_room( corpse, ch->in_room );
    if ( !IS_NPC( ch ) )
    corpse_back( ch, corpse );
    
    return;
}

void newbie_corpse( CHAR_DATA *ch )
{
    OBJ_DATA        *corpse;
/*    OBJ_DATA        *obj;
    OBJ_DATA        *obj_next; */
/*    ROOM_INDEX_DATA *location;*/
    char            *name;
    char             buf [ MAX_STRING_LENGTH ];

    /* No corpses in the arena. -- Altrag */
    if ( IS_ARENA(ch) )
    {
      CHAR_DATA *gch = (ch == arena.fch ? arena.sch : arena.fch);
      int award;
      
      /* Arena master takes 1/5.. *wink* */
      award = (arena.award * 4) / 5;
      sprintf(log_buf, "&C%s &chas been awarded &W%d &ccoins for %s victory.",
              gch->name, award, (gch->sex == SEX_NEUTRAL ? "its" :
              (gch->sex == SEX_MALE ? "his" : "her")));
      /* wiznet(log_buf, NULL, NULL, WIZ_DEATHS, 0, 0); */
      log_string(log_buf, CHANNEL_LOG, -1);
      challenge(log_buf, 0, 0);
#ifdef NEW_MONEY
      gch->money.gold += award;
#else
      gch->gold += award;
#endif
      sprintf(log_buf, "You have been awarded %d credits for your victory."
              "\n\r", award);
      send_to_char(AT_YELLOW, log_buf, gch);
      char_from_room(gch);
      char_to_room(gch, get_room_index(ROOM_VNUM_ALTAR));
      return;
    }
      if ( !IS_NPC( ch ) && ch->level <= 20 )
    {
	char_from_room( ch );
	char_to_room( ch, get_room_index(ROOM_VNUM_MORGUE) );
    } 
    if ( IS_NPC( ch ) )
    {
        /*
	 * This longwinded corpse creation routine comes about because
	 * we dont want anything created AFTER a corpse to be placed  
	 * INSIDE a corpse.  This had caused crashes from obj_update()
	 * in extract_obj() when the updating list got shifted from
	 * object_list to obj_free.          --- Thelonius (Monk)
	 */
#ifdef NEW_MONEY
	if ( (ch->money.gold > 0) || (ch->money.silver > 0) ||
	     (ch->money.copper > 0) )
#else
	if ( ch->gold > 0 )
#endif
	{
	    OBJ_DATA * coins;
#ifdef NEW_MONEY
	    coins	  = create_money( &ch->money );
#else
	    coins         = create_money( ch->gold );
#endif
	    name	  = ch->short_descr;
	    corpse	  = create_object(
					  get_obj_index(
OBJ_VNUM_CORPSE_NPC ),
					  0 );
	    corpse->timer = number_range( 2, 4 );
	    obj_to_obj( coins, corpse );
#ifdef NEW_MONEY
	    ch->money.gold = ch->money.silver = ch->money.copper = 0;
#else
	    ch->gold = 0;
#endif
	}
	else
	{
	    name	  = ch->short_descr;
	    corpse	  = create_object(
					  get_obj_index(
OBJ_VNUM_CORPSE_NPC ),
					  0 );
	    corpse->timer = number_range( 2, 4 );
	}
    }
    else
    {
	name		= ch->name;
	corpse		= create_object(
					get_obj_index( OBJ_VNUM_CORPSE_PC
),
					0 );
	corpse->timer	= number_range( 25, 40 );
	}
    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 );
	corpse->dimension = ch -> dimension;
	if ( ch->dimension > 0 )
	{
		dimension.used[ch->dimension] = NULL;
		change_dimension( ch, 0 );
	}

/*    sprintf( buf, "NPC killed: %s -> %d", ch->name, ch->in_room->vnum );
    log_string( buf, CHANNEL_NONE, -1 );
    wiznet(buf,NULL,NULL,WIZ_MOBDEATHS,0,0);*/
    if ( ( IS_NPC( ch ) ) && ( !IS_SET( ch->act, UNDEAD_TYPE( ch ) ) ) )
       corpse->ac_vnum=ch->pIndexData->vnum;
    obj_to_room( corpse, ch->in_room );

    
    return;
}


/*
 * Improved Death_cry contributed by Diavolo.
 */
void death_cry( CHAR_DATA *ch )
{
    ROOM_INDEX_DATA *was_in_room;
    char            *msg;
    int              vnum;
    int              door;
    OBJ_DATA *obj;

    if ( IS_ARENA(ch) )
      return;

    vnum = 0;
    switch ( number_bits( 4 ) )
    {
    default: msg  = "You hear $n's death cry.";				break;
    case  0: msg  = "$n hits the ground ... DEAD.";			break;
    case  1: msg  = "$n splatters blood on your armor.";		break;
    case  2: msg  = "$n's innards fall to the ground with a wet splat.";     break;
    case  3: msg  = "$n's severed head plops on the ground.";
	     vnum = OBJ_VNUM_SEVERED_HEAD;				break;
    case  4: msg  = "$n's heart is torn from $s chest.";
	     vnum = OBJ_VNUM_TORN_HEART;				break;
    case  5: msg  = "$n's arm is sliced from $s dead body.";
	     vnum = OBJ_VNUM_SLICED_ARM;				break;
    case  6: msg  = "$n's leg is sliced from $s dead body.";
	     vnum = OBJ_VNUM_SLICED_LEG;				break;
    }

    act(AT_BLOOD, msg, ch, NULL, NULL, TO_ROOM );

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

	name		= IS_NPC( ch ) ? ch->short_descr : ch->name;
	obj		= create_object( get_obj_index( vnum ), 0 );
	obj->timer	= number_range( 4, 7 );

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

	obj_to_room( obj, ch->in_room );
    }

    obj		= create_object( get_obj_index(OBJ_VNUM_FINAL_TURD), 0 );
    obj->timer	= number_range( 3, 5 );
    obj_to_room( obj, ch->in_room );
    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] )
	    && pexit->to_room
	    && pexit->to_room != was_in_room )
	{
	    ch->in_room = pexit->to_room;
	    act(AT_BLOOD, msg, ch, NULL, NULL, TO_ROOM );
	}
    }
    ch->in_room = was_in_room;

    return;
}



void raw_kill( CHAR_DATA *ch, CHAR_DATA *victim )
{
    AFFECT_DATA *paf;
    AFFECT_DATA *paf_next;
    bool is_arena = IS_ARENA(ch);
    bool simulator;

    stop_fighting( victim, TRUE );

    if ( ch != victim )
        mprog_death_trigger( victim, ch );

    rprog_death_trigger( victim->in_room, victim );

	if ( ch->dimension > 0 )
		simulator = TRUE;

		/* pk range */
	  if (!IS_SET(victim->act2, PLR_WAR))
	  {
		  if ( abs(ch->level - victim->level) > 10 && ( !IS_NPC(ch) && !IS_NPC(victim) ) )
			 {
			  send_to_char( AT_RED, "Out of range pkill. Keeping Equipment/inv.\n\r", victim);
			newbie_corpse( victim );
			 }
			 else
			 {
				make_corpse( victim );
			 }
	   }
			/*remove affects*/
    for ( paf = victim->affected; paf; paf = paf_next )
        {
     	 paf_next = paf->next;
         affect_remove( victim, paf );
        }
    for ( paf = victim->affected2; paf; paf = paf_next )
      {
       paf_next = paf->next;
       affect_remove2( victim, paf );
      }
    victim->affected_by	= 0;
    victim->affected_by2 = 0;

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

  if (( abs(ch->level - victim->level) > 10 && ( !IS_NPC(ch) && !IS_NPC(victim) )) ||
       IS_SET(victim->act2, PLR_WAR) )
  {
    /* newbie extraction here */
    char_from_room( victim );
    char_to_room( victim, get_room_index(ROOM_VNUM_MORGUE ));
  }
  else if (simulator == TRUE)
  {
	  char_from_room( victim );
	  char_to_room( victim, victim->simulator );
  }
  else
  {
    extract_char( victim, FALSE );    
  }

    if (!(abs(ch->level - victim->level) > 10 && !IS_NPC(
        ch ))) {
    if ( !is_arena )
    {
      victim->armor        = 100;
      victim->hitroll      = 0;
      victim->damroll      = 0;
      victim->saving_throw = 0;
      victim->carry_weight = 0;
      victim->carry_number = 0;
    }}
    victim->position     = POS_RESTING;
    victim->hit	         = UMAX( 1, victim->hit  );
    victim->mana         = UMAX( 1, victim->mana );
    victim->bp           = UMAX( 1, victim->bp   );
    victim->move         = UMAX( 1, victim->move );
    if (IS_SET(victim->act2, PLR_WAR))
    REMOVE_BIT(victim->act2, PLR_WAR);
    save_char_obj( victim, FALSE );
    return;
}



void group_gain( CHAR_DATA *ch, CHAR_DATA *victim )
{
    CHAR_DATA *gch;
    CHAR_DATA *lch;
    char       buf[ MAX_STRING_LENGTH ];
    int        members;
    int        xp;
    int        wrpts = victim->level;

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

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

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

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

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

	if (victim->level < 30)
	   wrpts = 0;

	if ( gch->level - lch->level >= 11 )
	{
	    send_to_char(AT_BLUE, "You are too high level for this group.\n\r", gch );
	    continue;
	}

	if ( gch->level - lch->level <= -11 )
	{
	    send_to_char(AT_BLUE, "You are too low level for this group.\n\r",  gch );
	    continue;
	}

	if (IS_SET(victim->act, ACT_PET))
	   return;

	xp = xp_compute( gch, victim ) / members;
/*    sprintf( buf, "%s -> gains %dxp", gch->name, xp);
    log_string( buf, CHANNEL_NONE, -1 );*/
	sprintf( buf, "You receive %d experience points.\n\r", xp );
	send_to_char(AT_WHITE, buf, gch );
	gain_exp( gch, xp );


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

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

    if ( IS_SET(ch->act, PLR_QUESTOR ) && IS_NPC( victim ))
    {
        if ( ch->questmob && victim == ch->questmob )
        {
           send_to_char(AT_WHITE, "You have almost completed your QUEST!\n\r", ch);
           send_to_char(AT_WHITE, "Return to the QuestMaster before your time runs out!\n\r", ch );
           ch->questmob = NULL;
        }
    }

    return;
}



/*
 * Compute xp for a kill.
 * Also adjust alignment of killer.
 * Edit this function to change xp computations.
 * NOTE: New xp system by Hannibal
 */
int xp_compute( CHAR_DATA *gch, CHAR_DATA *victim )
{
    int xp;
    int xp_cap = 10000;
    int align;


    align = gch->alignment - victim->alignment;
    if ( align > 500 )
    gch->alignment = UMIN( gch->alignment + ( align - 500 ) / 4, 1000 );
    else if ( align < -500 )
    gch->alignment = UMAX( gch->alignment + ( align + 500 ) / 4, -1000 );
    else
    gch->alignment -= victim->alignment / 3;
    
    /* mob lvl is 5 lvls lower than pc or more */
    if ( victim->level + 5 <= gch->level )
	return 0;
    /* 3-4 levels lower */
    if ( victim->level + 3 == gch->level 
    || victim->level + 4 == gch->level )
	{
	xp = ( gch->level < 10 ) ? number_range( 50, 100 ) + 10 : 0;
	return xp;
	}
    /* if same lvl or up to 2 lvls lower */
    if ( victim->level > gch->level - 3 
    && victim->level <= gch->level )
	{
	xp = number_range( 0, 10 ) + number_range( 10, 15 );
	xp = ( gch->level < 10 ) ? xp + number_range( 50, 100 ) : xp;
	return xp;
	}
    /* if higher lvl then... */
    xp = ( victim->level - gch->level ) * number_range( 25, 40 );
    xp = ( gch->level < 10 ) ? xp + number_range( 50, 100 ) : xp;

    /* if they kill 5 lvls bigger then them or more add 0-50xp */
    xp = ( victim->level >= gch->level + 5 ) ? xp + number_range( 50, 100 )
					     : xp;
    /* Enforce xp cap */
    xp = UMIN( xp_cap, xp );
    xp = UMAX( 0, xp );

    /* champ bonus */
    if ( gch->level >= LEVEL_HERO && victim->level > gch->level )
	xp = xp + ( 10 * ( victim->level - gch->level ) );
	if ( doubleexp() == TRUE )
		xp = xp * 2;
    return xp;
    
/* OLD xp system
    int xp;
    int align;
    int extra;
    int level;
    int number;

    xp    = 150 - URANGE( -10, gch->level - victim->level, 10 ) * 30;
    align = gch->alignment - victim->alignment;

    if ( align >  500 )
    {
	gch->alignment  = UMIN( gch->alignment + ( align - 500 ) / 4,  1000 );
	xp = 5 * xp / 4;
    }
    else if ( align < -500 )
    {
	gch->alignment  = UMAX( gch->alignment + ( align + 500 ) / 4, -1000 );
	xp = 5 * xp / 4;
    }
    else
    {
	gch->alignment -= victim->alignment / 3;
	xp = 3 * xp / 4;
    }
*/
    /*
     * Adjust for popularity of target:
     *   -1/8 for each target over  'par' (down to - 50%)
     *   +1/8 for each target under 'par' (  up to + 25%)
     */
/*    level  = URANGE( 0, victim->level, 99 );
    number = UMAX( 1, kill_table[level].number );
    if(IS_NPC(victim))
      extra  = victim->pIndexData->killed - kill_table[level].killed / number;
    else
      extra = 0;
    xp    -= xp * URANGE( -2, extra, 4 ) / 8;

    xp     = number_range( xp * 3 / 4, xp * 5 / 4 );
    xp     = UMAX( 0, xp );
    return xp;
*/
}



void dam_message( CHAR_DATA *ch, CHAR_DATA *victim, int dam, int dt )
{
    static char * const  attack_table [ ] =
    {
	"hit",
	"slice",  "stab",    "slash", "whip", "claw",
	"blast",  "pound",   "crush", "grep", "bite",
	"pierce", "suction", "chop", "left fist", "right fist"
    };
    const  char         *vs;
    const  char         *vp;
    const  char         *attack;
           char          buf          [ MAX_STRING_LENGTH ];
           char          buf1         [ 256 ];
           char          buf2         [ 256 ];
           char          buf3         [ 256 ];
           char          buf4         [ 256 ];
           char          buf5         [ 256 ];
           char          punct;

	 if ( dam <=   0 ) { vs = "miss";	vp = "misses";		}
    else if ( dam <=   4 ) { vs = "scratch";	vp = "scratches";	}
    else if ( dam <=   8 ) { vs = "graze";	vp = "grazes";		}
    else if ( dam <=  12 ) { vs = "hit";	vp = "hits";		}
    else if ( dam <=  16 ) { vs = "injure";	vp = "injures";		}
    else if ( dam <=  20 ) { vs = "wound";	vp = "wounds";		}
    else if ( dam <=  24 ) { vs = "maul";       vp = "mauls";		}
    else if ( dam <=  28 ) { vs = "decimate";	vp = "decimates";	}
    else if ( dam <=  32 ) { vs = "devastate";	vp = "devastates";	}
    else if ( dam <=  36 ) { vs = "maim";	vp = "maims";		}
    else if ( dam <=  40 ) { vs = "MUTILATE";	vp = "MUTILATES";	}
    else if ( dam <=  44 ) { vs = "DISEMBOWEL";	vp = "DISEMBOWELS";	}
    else if ( dam <=  48 ) { vs = "EVISCERATE";	vp = "EVISCERATES";	}
    else if ( dam <=  52 ) { vs = "MASSACRE";	vp = "MASSACRES";	}
    else if ( dam <= 100 ) { vs = "*** DEMOLISH ***";
			     vp = "*** DEMOLISHES ***";			}
    else if ( dam <= 150 ) { vs = "*** DEVASTATE ***";
			     vp = "*** DEVASTATES ***";			}
    else if ( dam <= 250 ) { vs = "*** OBLITERATE ***";
			     vp = "*** OBLITERATES ***";		}
    else if ( dam <= 300 ) { vs = "=== OBLITERATE ===";
			     vp = "=== OBLITERATES ===";		}
    else if ( dam <= 500 ) { vs = "*** ANNIHILATE ***";
			     vp = "*** ANNIHILATES ***";		}
    else if ( dam <= 750 ) { vs = ">>> ANNIHILATE <<<";
			     vp = ">>> ANNIHILATES <<<";		}
    else if ( dam <= 1000) { vs = "<<< ERADICATE >>>";
			     vp = "<<< ERADICATES >>>";			}
    else                   { vs = "&Xdo &rUNSPEAKABLE&X things to";
			     vp = "&Xdoes &rUNSPEAKABLE&X things to";
}

    punct   = ( dam <= 24 ) ? '.' : '!';

    if ( dt == TYPE_HIT )
    {
	sprintf( buf1, "You &r%s&X $N%c (%d)",       vs, punct, dam );
	sprintf( buf2, "$n &G%s&X you%c (%d)",       vp, punct, dam );
	sprintf( buf3, "$n &z%s&X $N%c (%d)",        vp, punct, dam );
	sprintf( buf4, "You &G%s&X yourself%c (%d)", vs, punct, dam );
	sprintf( buf5, "$n &z%s&X $mself%c (%d)",    vp, punct, dam );
    }
    else
    {
	if ( is_sn(dt) )
	    attack	= skill_table[dt].noun_damage;
	else if (   dt >= TYPE_HIT
		 && dt  < TYPE_HIT
		        + sizeof( attack_table )/sizeof( attack_table[0] ) )
	    attack	= attack_table[dt - TYPE_HIT];
	else
	{
	    sprintf( buf, "Dam_message: bad dt %d caused by %s.", dt,
		    ch->name );
	    bug( buf, 0 );
	    dt      = TYPE_HIT;
	    attack  = attack_table[0];
	}

	if ( dt > TYPE_HIT && is_wielding_poisoned( ch ) )
	{
    sprintf( buf1, "Your &gpoisoned&X %s &r%s&X $N%c (%d)",  attack, vp,
punct, dam );
    sprintf( buf2, "$n's &gpoisoned&X %s &G%s&X you%c (%d)", attack, vp,
punct, dam );
    sprintf( buf3, "$n's &gpoisoned&X %s &z%s&X $N%c (%d)",  attack, vp,
punct, dam );
    sprintf( buf4, "Your &gpoisoned&X %s &G%s&X you%c (%d)", attack, vp,
punct, dam );
    sprintf( buf5, "$n's &gpoisoned&X %s &z%s&X $n%c (%d)",  attack, vp,
punct, dam );
	}
	else
	{
	    sprintf( buf1, "Your %s &r%s&X $N%c (%d)",  attack, vp, punct,
dam );
	    sprintf( buf2, "$n's %s &G%s&X you%c (%d)", attack, vp, punct,
dam );
	    sprintf( buf3, "$n's %s &z%s&X $N%c (%d)",  attack, vp, punct,
dam );
	    sprintf( buf4, "Your %s &G%s&X you%c (%d)", attack, vp, punct,
dam );
	    sprintf( buf5, "$n's %s &z%s&X $n%c (%d)",  attack, vp, punct,
dam );
	}
    }

    if ( victim != ch )
    {
        if ( dam != 0 || IS_SET( ch->act, PLR_COMBAT ) )
	  act(AT_WHITE, buf1, ch, NULL, victim, TO_CHAR    );
	if ( dam != 0 || IS_SET( victim->act, PLR_COMBAT ) )
	  act(AT_WHITE, buf2, ch, NULL, victim, TO_VICT    );
	act(AT_GREY, buf3, ch, NULL, victim, 
	    dam == 0 ? TO_COMBAT : TO_NOTVICT );
    }
    else
    {
        if ( dam != 0 || IS_SET( ch->act, PLR_COMBAT ) )
	  act(AT_WHITE, buf4, ch, NULL, victim, TO_CHAR    );
  	act(AT_GREY, buf5, ch, NULL, victim,
	    dam == 0 ? TO_COMBAT : TO_NOTVICT );
     }
      
    return;
}



/*
 * Disarm a creature.
 * Caller must check for successful attack.
 */
void disarm( CHAR_DATA *ch, CHAR_DATA *victim )
{
    OBJ_DATA *obj;

    if ( !( obj = get_eq_char( victim, WEAR_WIELD ) ) )
	if ( !( obj = get_eq_char( victim, WEAR_WIELD_2 ) ) )
	   return;

    if ( !get_eq_char( ch, WEAR_WIELD ) && number_bits( 1 ) == 0 )
	if ( !get_eq_char( ch, WEAR_WIELD_2 ) && number_bits( 1 ) == 0 )
	   return;

    act(AT_YELLOW, "You disarm $N!",  ch, NULL, victim, TO_CHAR    );
    act(AT_YELLOW, "$n DISARMS you!", ch, NULL, victim, TO_VICT    );
    act(AT_GREY, "$n DISARMS $N!",  ch, NULL, victim, TO_NOTVICT );

    obj_from_char( obj );
    if ( IS_NPC( victim ) )
	obj_to_char( obj, victim );
    else
	obj_to_room( obj, victim->in_room );

    return;
}



/*
 * Trip a creature.
 * Caller must check for successful attack.
 */
void trip( CHAR_DATA *ch, CHAR_DATA *victim )
{
    if ( ( IS_AFFECTED( victim, AFF_FLYING ) )
       || (victim->race == RACE_PIXIE )
       || (victim->race == RACE_ELDER ) )
       return;
       
    if ( !IS_STUNNED( victim, STUN_COMMAND ) && !IS_STUNNED(ch, STUN_TO_STUN) )
    {
	act(AT_CYAN, "You trip $N and $N goes down!", ch, NULL, victim, TO_CHAR    );
	act(AT_CYAN, "$n trips you and you go down!", ch, NULL, victim, TO_VICT    );
	act(AT_GREY, "$n trips $N and $N goes down!", ch, NULL, victim, TO_NOTVICT );

	WAIT_STATE( ch, PULSE_VIOLENCE );
	STUN_CHAR(victim, 2, STUN_COMMAND);
	STUN_CHAR(ch, 3, STUN_TO_STUN);
	victim->position = POS_RESTING;
    }

    return;
}



void do_kill( CHAR_DATA *ch, char *argument )
{
    CHAR_DATA *victim;
    char       arg [ MAX_INPUT_LENGTH ];

    one_argument( argument, arg );
 
    if ( !( victim = get_char_room( ch, arg ) ) )
    {
      send_to_char( AT_WHITE, "That person is not here.\n\r", ch );
      return;
    }

    if ( is_safe( ch, victim ) )
      {
       send_to_char( AT_WHITE, "You cannot.\n\r", ch );
       return;
      }	   
    
    if ( arg[0] == '\0' )
    {
	send_to_char(AT_WHITE, "Kill whom?\n\r", ch );
	return;
    }

    if ( !( victim = get_char_room( ch, arg ) ) ||
		victim->in_vehicle != NULL )
    {
	send_to_char(AT_WHITE, "They aren't here.\n\r", ch );
	return;
    }

    if ( IS_AFFECTED(victim, AFF_PEACE ))
    {
      send_to_char(AT_WHITE, "A wave of peace overcomes you.\n\r", ch);
      return;
    }
    if ( IS_AFFECTED( ch, AFF_PEACE ) )
    {
	    affect_strip( ch, skill_lookup("aura of peace" ));
	    REMOVE_BIT( ch->affected_by, AFF_PEACE );
    }
    if ( !IS_NPC( victim ) && !IS_ARENA(victim) )
    {
	if (   !IS_SET( victim->act, PLR_KILLER )
	    && !IS_SET( victim->act, PLR_THIEF  ) )
	{
	    send_to_char(AT_WHITE, "You must MURDER a player.\n\r", ch );
	    return;
	}
    }
    else
    {
	if ( IS_AFFECTED( victim, AFF_CHARM ) && victim->master )
	{
	    send_to_char(AT_WHITE, "You must MURDER a charmed creature.\n\r", ch );
	    return;
	}
    }

    if ( victim == ch )
    {
	send_to_char(AT_RED, "You hit yourself.  Stupid!\n\r", ch );
	multi_hit( ch, ch, TYPE_UNDEFINED );
	return;
    }

    if ( IS_AFFECTED( ch, AFF_CHARM ) && ch->master == victim )
    {
	act(AT_BLUE, "$N is your beloved master!", ch, NULL, victim, TO_CHAR );
	return;
    }

    if ( ch->position == POS_FIGHTING )
    {
	send_to_char(C_DEFAULT, "You do the best you can!\n\r", ch );
	return;
    }

    WAIT_STATE( ch, PULSE_VIOLENCE );
    check_killer( ch, victim );
    multi_hit( ch, victim, TYPE_UNDEFINED );
    return;
}



void do_murde( CHAR_DATA *ch, char *argument )
{
    send_to_char(C_DEFAULT, "If you want to MURDER, spell it out.\n\r", ch );
    return;
}



void do_murder( CHAR_DATA *ch, char *argument )
{
    CHAR_DATA *victim;
    char       buf [ MAX_STRING_LENGTH ];
    char       arg [ MAX_INPUT_LENGTH  ];

    one_argument( argument, arg );

    if ( arg[0] == '\0' )
    {
	send_to_char(C_DEFAULT, "Murder whom?\n\r", ch );
	return;
    }

    if ( !( victim = get_char_room( ch, arg ) ) ||
		victim->in_vehicle != NULL )
    {
	send_to_char(C_DEFAULT, "They aren't here.\n\r", ch );
	return;
    }

    if ( IS_AFFECTED(victim, AFF_PEACE ))
    {
      send_to_char(AT_WHITE, "A wave of peace overcomes you.\n\r", ch);
      return;
    }
    if ( IS_AFFECTED( ch, AFF_PEACE ))
    {
	    affect_strip( ch, skill_lookup("aura of peace") );
	    REMOVE_BIT( ch->affected_by, AFF_PEACE );
    }

    if ( is_affected( victim, gsn_image ))
    {
	do_image( victim, ch );
	affect_strip( victim, skill_lookup("image"));
	REMOVE_BIT( victim->affected_by, gsn_image );
	return;
    }

    if ( victim == ch )
    {
	send_to_char(C_DEFAULT, "Suicide is a mortal sin.\n\r", ch );
	return;
    }
    if ( is_safe( ch, victim ) )
	return;
    if ( IS_AFFECTED( ch, AFF_CHARM ) && ch->master == victim )
    {
	act(C_DEFAULT, "$N is your beloved master!", ch, NULL, victim, TO_CHAR );
	return;
    }

	if (!IS_SET(ch->act2, PLR_WAR) && !IS_SET(ch->act2, PLR_WAR ))
	{
        if ( !IS_SET( ch->act, PLR_PKILLER ) && !IS_ARENA( ch ) &&
	     !IS_NPC( victim ) )  /* chars can murder mobs */
		{
	     send_to_char(C_DEFAULT, 
 		"You must be a Pkiller to kill another mortal!\n\r", ch );
	     return;
		}

       if ( !IS_SET( victim->act, PLR_PKILLER ) && !IS_ARENA( victim ) 
    	 && !IS_NPC( victim ) ) /* chars can murder mobs */
	   {
  	    send_to_char(C_DEFAULT, "You can only pkill other Pkillers.\n\r", ch );
	    return;
	   }
	}
    if ( ch->position == POS_FIGHTING )
    {
	send_to_char(C_DEFAULT, "You do the best you can!\n\r", ch );
	return;
    }

    WAIT_STATE( ch, PULSE_VIOLENCE );
    if ( !IS_NPC( victim ) )
    {
        sprintf( buf, "Help!  I am being attacked by %s!", ch->name );
        do_shout( victim, buf );
    }
    multi_hit( ch, victim, TYPE_UNDEFINED );
    return;
}


void do_backstab( CHAR_DATA *ch, char *argument )
{
    OBJ_DATA  *obj;
    CHAR_DATA *victim;
    char       arg [ MAX_INPUT_LENGTH ];

      if ( !IS_NPC( ch )
	&& !can_use_skpell( ch, gsn_backstab ) )
      {
	send_to_char(C_DEFAULT,
		   "You better leave the assassin trade to thieves.\n\r", ch );
	return;
      }

    one_argument( argument, arg );
    
    if ( arg[0] == '\0' )
    {
	send_to_char(C_DEFAULT, "Backstab whom?\n\r", ch );
	return;
    }

    if ( !( victim = get_char_room( ch, arg ) ) ||
		victim->in_vehicle != NULL)
    {
	send_to_char(C_DEFAULT, "They aren't here.\n\r", ch );
	return;
    }

    if ( victim == ch )
    {
	send_to_char(C_DEFAULT, "How can you sneak up on yourself?\n\r", ch );
	return;
    }
    if ( is_safe( ch, victim ) )
	return;

	if (!IS_SET(ch->act2, PLR_WAR) && !IS_SET(ch->act2, PLR_WAR ))
	{
        if ( !IS_SET( ch->act, PLR_PKILLER ) && !IS_ARENA( ch ) &&
	     !IS_NPC( victim ) )  /* chars can murder mobs */
		{
	     send_to_char(C_DEFAULT, 
 		"You must be a Pkiller to kill another mortal!\n\r", ch );
	     return;
		}

       if ( !IS_SET( victim->act, PLR_PKILLER ) && !IS_ARENA( victim ) 
    	 && !IS_NPC( victim ) ) /* chars can murder mobs */
	   {
  	    send_to_char(C_DEFAULT, "You can only pkill other Pkillers.\n\r", ch );
	    return;
	   }
	}

    if ( !( obj = get_eq_char( ch, WEAR_WIELD ) )
	|| ( obj->value[3] != 11 && obj->value[3] != 2 ) )
    {
	send_to_char(C_DEFAULT, "You need to wield a piercing or stabbing weapon.\n\r", ch );
	return;
    }

    if ( is_affected( victim, gsn_image ))
    {
        do_image( victim, ch );
        affect_strip( victim, skill_lookup("image"));
        REMOVE_BIT( victim->affected_by, gsn_image );
        return;
    }         

    if ( victim->fighting )
    {
	send_to_char(C_DEFAULT, "You can't backstab a fighting person.\n\r", ch );
	return;
    }

    if ( victim->hit < MAX_HIT(victim) * 0.3 )
    {
	act(C_DEFAULT, "$N is hurt and suspicious ... you can't sneak up.",
	    ch, NULL, victim, TO_CHAR );
	return;
    }

    check_killer( ch, victim );
    WAIT_STATE( ch, skill_table[gsn_backstab].beats );
    if ( !IS_AWAKE( victim )
	|| IS_NPC( ch )
	|| number_percent( ) < ch->pcdata->learned[gsn_backstab] )
    {
	multi_hit( ch, victim, gsn_backstab );
	update_skpell( ch, gsn_backstab );
	if ( ( obj = get_eq_char( ch, WEAR_WIELD_2 ) )
	&& ( !IS_NPC( ch ) && ch->pcdata->learned[gsn_backstab_2] > 0 )
	&& ( obj->value[3] == 11 || obj->value[3] == 2 ) )
	    {
	    multi_hit( ch, victim, gsn_backstab );
	    update_skpell( ch, gsn_backstab_2 );
	    }
        if ( ( obj = get_eq_char( ch, WEAR_WIELD_3 ) )
        && ( !IS_NPC( ch ) && ch->pcdata->learned[gsn_backstab_2] > 0 )
        && ( obj->value[3] == 11 || obj->value[3] == 2 ) )
            {
            multi_hit( ch, victim, gsn_backstab );
            update_skpell( ch, gsn_backstab_2 );
            }
    }
    else
	damage( ch, victim, 0, gsn_backstab );

    return;
}
void do_assasinate( CHAR_DATA *ch, char *argument )
{
    OBJ_DATA  *obj;
    CHAR_DATA *victim;
    char       arg [ MAX_INPUT_LENGTH ];

    if (ch->clan != 4)
      {
	send_to_char( C_DEFAULT, "Huh?\n\r", ch );
	return;
      }

    one_argument( argument, arg );
    
    if ( arg[0] == '\0' )
    {
	send_to_char(C_DEFAULT, "Assasinate whom?\n\r", ch );
	return;
    }

    if ( !( victim = get_char_room( ch, arg ) ) )
    {
	send_to_char(C_DEFAULT, "They aren't here.\n\r", ch );
	return;
    }

    if ( victim == ch )
    {
	send_to_char(C_DEFAULT, "How can you sneak up on yourself?\n\r", ch );
	return;
    }

    if ( is_safe( ch, victim ) )
      return;

	if (!IS_SET(ch->act2, PLR_WAR) && !IS_SET(ch->act2, PLR_WAR ))
	{
        if ( !IS_SET( ch->act, PLR_PKILLER ) && !IS_ARENA( ch ) &&
	     !IS_NPC( victim ) )  /* chars can murder mobs */
		{
	     send_to_char(C_DEFAULT, 
 		"You must be a Pkiller to kill another mortal!\n\r", ch );
	     return;
		}

       if ( !IS_SET( victim->act, PLR_PKILLER ) && !IS_ARENA( victim ) 
    	 && !IS_NPC( victim ) ) /* chars can murder mobs */
	   {
  	    send_to_char(C_DEFAULT, "You can only pkill other Pkillers.\n\r", ch );
	    return;
	   }
	}

    if ( !( obj = get_eq_char( ch, WEAR_WIELD ) )
	|| obj->value[3] != 11 )
    {
	send_to_char(C_DEFAULT, "You need to wield a piercing weapon.\n\r", ch );
	return;
    }

    if ( victim->fighting )
    {
	send_to_char(C_DEFAULT, "You can't assasinate a fighting person.\n\r", ch );
	return;
    }

    if ( victim->hit < (MAX_HIT(victim)-50) )
    {
	act(C_DEFAULT, "$N is hurt and suspicious ... you can't sneak up.",
	    ch, NULL, victim, TO_CHAR );
	return;
    }

    WAIT_STATE( ch, skill_table[gsn_backstab].beats );
    multi_hit( ch, victim, gsn_backstab );

    return;
}



void do_flee( CHAR_DATA *ch, char *argument )
{
    CHAR_DATA       *victim;
    ROOM_INDEX_DATA *was_in;
    ROOM_INDEX_DATA *now_in;
    int              attempt;

    if ( IS_AFFECTED( ch, AFF_ANTI_FLEE ) )
    {
      send_to_char( AT_RED, "You cannot!", ch );
      return;
    }
    
    if ( !( victim = ch->fighting ) )
    {
	if ( ch->position == POS_FIGHTING )
	    ch->position = POS_STANDING;
	send_to_char(C_DEFAULT, "You aren't fighting anyone.\n\r", ch );
	return;
    }
    if ( IS_SET( ch->in_room->room_flags, ROOM_NO_FLEE ) )
    {
      if ( !IS_ARENA(ch) )
      {
        send_to_char(C_DEFAULT, "You failed!  You lose 10 exps.\n\r", ch );
        gain_exp( ch, -10 );
      }
      else
        send_to_char(C_DEFAULT, "You failed!\n\r", ch);
      return;
    }	   

    was_in = ch->in_room;
    for ( attempt = 0; attempt < 6; attempt++ )
    {
	EXIT_DATA *pexit;
	int        door;

	door = number_door( );
	if ( ( pexit = was_in->exit[door] ) == 0
	    ||   !pexit->to_room
	    ||   IS_SET( pexit->exit_info, EX_CLOSED )
	    ||   IS_SET( pexit->exit_info, EX_ISWALL )
	    ||   IS_SET( pexit->exit_info, EX_ISWINDOW )
	    || ( IS_NPC( ch )
		&& ( IS_SET( pexit->to_room->room_flags, ROOM_NO_MOB )
		    || ( IS_SET( ch->act, ACT_STAY_AREA )
			&& pexit->to_room->area != ch->in_room->area ) ) ) )
	    continue;

	move_char( ch, door, FALSE );
	if ( ( now_in = ch->in_room ) == was_in )
	    continue;

	ch->in_room = was_in;
	act(C_DEFAULT, "$n has fled!", ch, NULL, NULL, TO_ROOM );
	if ( IS_ARENA(ch) )
	  act(AT_RED, "$n has escaped!  After $m!", ch, NULL, victim,
	      TO_VICT);
	ch->in_room = now_in;

	if ( !IS_NPC( ch ) )
	{
	  if ( !IS_ARENA(ch) )
	  {
	    send_to_char(C_DEFAULT, "You flee from combat!  You lose 25 exps.\n\r", ch );
	    gain_exp( ch, -25 );
	  }
	  else
	    send_to_char(C_DEFAULT, "You flee from combat!\n\r", ch);
	}

        if ( ch->fighting && IS_NPC( ch->fighting ) )
          if ( IS_SET( ch->fighting->act, ACT_TRACK ) )
            ch->fighting->hunting = ch;

	stop_fighting( ch, TRUE );
	return;
    }

    if ( !IS_ARENA(ch) )
    {
      send_to_char(C_DEFAULT, "You failed!  You lose 10 exps.\n\r", ch );
      gain_exp( ch, -10 );
    }
    else
      send_to_char(C_DEFAULT, "You failed!\n\r", ch );
    return;
}



void do_rescue( CHAR_DATA *ch, char *argument )
{
    CHAR_DATA *victim;
    CHAR_DATA *fch;
    char       arg [ MAX_INPUT_LENGTH ];

    if ( !IS_NPC( ch )
	&& !can_use_skpell( ch, gsn_rescue ) )
    {
	send_to_char(C_DEFAULT,
	    "You'd better leave the heroic acts to warriors.\n\r", ch );
	return;
    }

    one_argument( argument, arg );

    if ( arg[0] == '\0' )
    {
	send_to_char(C_DEFAULT, "Rescue whom?\n\r", ch );
	return;
    }

    if ( !( victim = get_char_room( ch, arg ) ) )
    {
	send_to_char(C_DEFAULT, "They aren't here.\n\r", ch );
	return;
    }

    if ( victim == ch )
    {
	send_to_char(C_DEFAULT, "What about fleeing instead?\n\r", ch );
	return;
    }

    if ( !IS_NPC( ch ) && IS_NPC( victim ) )
    {
	send_to_char(C_DEFAULT, "Doesn't need your help!\n\r", ch );
	return;
    }

    if ( ch->fighting == victim )
    {
	send_to_char(C_DEFAULT, "Too late.\n\r", ch );
	return;
    }

    if ( !( fch = victim->fighting ) )
    {
	send_to_char(C_DEFAULT, "That person is not fighting right now.\n\r", ch );
	return;
    }

    if ( !is_same_group( ch, victim ) )
    {
	send_to_char(C_DEFAULT, "Why would you want to?\n\r", ch );
	return;
    }

    if ( !check_blind ( ch ) )
        return;

    WAIT_STATE( ch, skill_table[gsn_rescue].beats );
    if ( !IS_NPC( 

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

Site Stats

Snippets: 1791
Codebases: 571