area/
build/testing/
log/
player/
player/backup/
/***************************************************************************
 *  Original Diku Mud copyright (C) 1990, 1991 by Sebastian Hammer,        *
 *  Michael Seifert, Hans Henrik St{rfeldt, Tom Madsen, and Katja Nyboe.   *
 *                                                                         *
 *  Merc Diku Mud improvments copyright (C) 1992, 1993 by Michael          *
 *  Chastain, Michael Quan, and Mitchell Tse.                              *
 *                                                                         *
 *  In order to use any part of this Merc Diku Mud, you must comply with   *
 *  both the original Diku license in 'license.doc' as well the Merc       *
 *  license in 'license.txt'.  In particular, you may not remove either of *
 *  these copyright notices.                                               *
 *                                                                         *
 *  Much time and thought has gone into this software and you are          *
 *  benefitting.  We hope that you share your changes too.  What goes      *
 *  around, comes around.                                                  *
 ***************************************************************************/
#include <glib.h>

#if defined(macintosh)
#include <types.h>
#else
#include <sys/types.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <merc.h>
#include <tables.h>
#include <interp.h>
#include <fight.h>

extern void	check_killer	args( ( CHAR_DATA *ch, CHAR_DATA *victim ) );
extern void	set_fighting	args( ( CHAR_DATA *ch, CHAR_DATA *victim ) );
extern GString *get_player_class_string args(( CHAR_DATA *ch ));
extern	void calc_stat args((CHAR_DATA *ch, CHAR_DATA *victim));
extern bool check_artifact args(( CHAR_DATA *ch ));
extern void diab_finish args(( CHAR_DATA *victim ));

void do_kill( CHAR_DATA *ch, char *argument )
{
	char arg[MAX_INPUT_LENGTH];
	CHAR_DATA *victim;
	
	one_argument( argument, arg );
	
	if ( arg[0] == '\0' )
	{
		send_to_char( "Kill whom?\n\r", ch );
		return;
	}
	
	if ( ( victim = get_char_room( ch, arg ) ) == NULL )
	{
		send_to_char( "They aren't here.\n\r", ch );
		return;
	}
	
	if ( ch->in_room != NULL && IS_RAFFECTED(ch->in_room,ROOM_AFF_REINA))
	{
		send_to_char("You feel too peaceful.\n\r", ch);
		return;
	}
	
	if ( victim == ch )
	{
		send_to_char( "You cannot kill yourself!\n\r", ch );
		return;
	}
	
	if ( is_safe( ch, victim ) )
		return;
	
	if (check_pk(ch,victim,CHECK_DELAY|CHECK_ATTACK))
		return;

	if ( IS_AFFECTED(ch, AFF_CHARM) && ch->master == victim )
	{
		act( "$N is your beloved master.", ch, NULL, victim, TO_CHAR );
		return;
	}
	
	if ( ch->position == POS_FIGHTING )
	{
		send_to_char( "You do the best you can!\n\r", ch );
		return;
	}
	
	if(ch->move <= 0)
	{
		send_to_char("You can't find the energy to.\n\r",ch);
		return;
	}
	
	if (!IS_NPC(ch) && (IS_SET(ch->extra, EXTRA_STANCE)) )
	{
		switch (ch->stance[11])
		{
			case STANCE_VIPER:    do_stance(ch,"viper");     break;
			case STANCE_CRANE:    do_stance(ch,"crane");     break;
			case STANCE_CRAB:     do_stance(ch,"crab");      break;
			case STANCE_MONGOOSE: do_stance(ch,"mongoose");  break;
			case STANCE_BULL:     do_stance(ch,"bull");      break;
			case STANCE_DRAGON:   do_stance(ch,"dragon");    break;
			case STANCE_MANTIS:   do_stance(ch,"mantis");    break;
			case STANCE_SWALLOW:  do_stance(ch,"swallow");   break;
			case STANCE_TIGER:    do_stance(ch,"tiger");     break;
			case STANCE_MONKEY:   do_stance(ch,"monkey");    break;
			default:              do_stance(ch,"none");      break;
		}
	}

    if (!IS_NPC(ch) && !IS_NPC(victim))
    {
    	ch->pk_timer = 8;
        victim->pk_timer = 8;
    }
	
	WAIT_STATE( ch, 1 * PULSE_VIOLENCE );
	check_killer( ch, victim );
	if (!IS_NPC(ch) && IS_CLASS(ch, CLASS_WEREWOLF) 
		&& number_range(1,3) == 1
		&& ch->pcdata->powers[WPOWER_BOAR] > 1 
		&& victim->position == POS_STANDING)
	{
		if ( ch->pcdata->powers[WPOWER_RAT] > 4 )
		{
			ch->damroll += 400;
			multi_hit( ch, victim, TYPE_UNDEFINED );
			ch->damroll -= 400;
			multi_hit( ch, victim, TYPE_UNDEFINED );
		}
		else
		{
			ch->damroll += 200;
			multi_hit( ch, victim, TYPE_UNDEFINED );
			ch->damroll -= 200;
		}
		if ( victim != NULL)
		{
			act("You charge into $N, knocking $M from $S feet.",ch,NULL,victim,TO_CHAR);
			act("$n charges into $N, knocking $M from $S feet.",ch,NULL,victim,TO_NOTVICT);
			act("$n charges into you, knocking you from your feet.",ch,NULL,victim,TO_VICT);
			victim->position = POS_STUNNED;
			set_attack_flag(ch,victim);
			multi_hit( ch, victim, TYPE_UNDEFINED );
			multi_hit( ch, victim, TYPE_UNDEFINED );
		}
		return;
	}
	set_attack_flag(ch,victim);
	multi_hit( ch, victim, TYPE_UNDEFINED );
	return;
}



void do_backstab( CHAR_DATA *ch, char *argument )
{
	char arg[MAX_INPUT_LENGTH];
	CHAR_DATA *victim;
	OBJ_DATA *obj;
	
	one_argument( argument, arg );
	
	if ( arg[0] == '\0' )
	{
		send_to_char( "Backstab whom?\n\r", ch );
		return;
	}
	
	if ( ( victim = get_char_room( ch, arg ) ) == NULL )
	{
		send_to_char( "They aren't here.\n\r", ch );
		return;
	}
	
	if (check_disc(ch,victim,CDISC_PK|CDISC_TSAFE|CDISC_PLANE|CDISC_REINA))
		return;
	
	if ( victim == ch )
	{
		send_to_char( "How can you sneak up on yourself?\n\r", ch );
		return;
	}
	
	if ( is_safe( ch, victim ) )
		return;
	
	if ( ( ( obj = get_eq_char( ch, WEAR_WIELD ) ) == NULL
		||   obj->value[3] != 11 )
		&&   ( ( obj = get_eq_char( ch, WEAR_HOLD ) ) == NULL
			||   obj->value[3] != 11 ) )
	{
		send_to_char( "You need to wield a piercing weapon.\n\r", ch );
		return;
	}
	
	if ( victim->fighting != NULL )
	{
		send_to_char( "You can't backstab a fighting person.\n\r", ch );
		return;
	}
	
	if ( victim->hit < victim->max_hit / 10 )  /* up to 10% - Dominion */
	{
		act( "$N is pretty hurt and suspicious ... you can't sneak up.",
			ch, NULL, victim, TO_CHAR );
		return;
	}
	
	if(ch->move <= 0)
	{
		send_to_char("You can't find the energy to lift your weapon.\n\r",ch);
		return;
	}

        if (check_pk(ch,victim,CHECK_DELAY|CHECK_ATTACK))
        {
                return;
        }
	
	set_attack_flag(ch,victim);
	check_killer( ch, victim );
	WAIT_STATE( ch, skill_table[gsn_backstab].beats );
	if ( !IS_NPC(victim) && IS_IMMMERIT(victim, IMM_MERIT_BACKSTAB) )
		damage( ch, victim, 0, gsn_backstab );
	else if ( !IS_NPC(victim) && IS_IMMFLAW(victim, IMM_FLAW_BACKSTAB))
		damage( ch, victim, 2000, gsn_backstab );	
	else if ( !IS_AWAKE(victim)
		||   IS_NPC(ch)
		||   number_percent( ) < ch->pcdata->learned[gsn_backstab] )
		multi_hit( ch, victim, gsn_backstab );
	else
		damage( ch, victim, 0, gsn_backstab );
	playwave_toch(ch,10);
	
	return;
}



void do_flee( CHAR_DATA *ch, char *argument )
{
	ROOM_INDEX_DATA *was_in;
	ROOM_INDEX_DATA *now_in;
	CHAR_DATA *victim;
	char buf[MAX_STRING_LENGTH];
	GString *mxpout;
	int attempt;
	int number;
	
	if ( ( victim = ch->fighting ) == NULL )
	{
		if ( ch->position == POS_FIGHTING )
			ch->position = POS_STANDING;
		send_to_char( "You aren't fighting anyone.\n\r", ch );
		return;
	}
	if(ch->move <= 0)
	{
		send_to_char("You can't find the energy to leave.\n\r",ch);
		return;
	}
	
	if (IS_AFFECTED(ch, AFF_WEBBED))
	{
		send_to_char("You are unable to move with all this sticky webbing on.\n\r",ch);
		return;
	}
	
	if (!IS_NPC(ch) && IS_ADDED(ch,ADDED_FRENZY) 
			&& ch->pcdata->frenzy_action == FRENZY_FIGHT)
	{
		send_to_char("Not in this frenzy!\n\r",ch);
		return;
	}


	if (!IS_NPC(victim) && (victim->pcdata->powers[WPOWER_SHARK] >= 2 || (IS_SWWF(victim) && get_auspice(victim,AUSPICE_AHROUN) > 3)) )
	{
		number = number_range(1,100);
		if (number <= 25)
		{
			act( "You attempt to flee, but $n has clamped $s powerful jaws on your leg!", ch, NULL, victim, TO_CHAR );
			act( "You clam your powerful jaws on $N preventing them from fleeing!", ch, NULL, victim,  TO_VICT );
			act( "$N tries to flee as $n clamps $s powerful jaws on $N holding $M in place!", ch, NULL, victim, TO_NOTVICT );
			return;	
		}
	}
	
	
	if (!IS_NPC(ch) && ch->pcdata->stats[UNI_RAGE] >= 0)
	{
		if (IS_CLASS(ch,CLASS_VAMPIRE) && number_percent() <= ch->pcdata->stats[UNI_RAGE])
		{
			send_to_char("Your inner beast refuses to let you run!\n\r",ch);
			WAIT_STATE(ch,12);
			return;
		}
		else if (IS_CLASS(ch, CLASS_WEREWOLF) && number_percent() <= ch->pcdata->stats[UNI_RAGE] * 0.3)
		{
			send_to_char("Your rage is too great!\n\r",ch);
			WAIT_STATE(ch,12);
			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 == NULL
			||   IS_SET(pexit->exit_info, EX_CLOSED)
			|| ( IS_NPC(ch)
				&&   IS_SET(pexit->to_room->room_flags, ROOM_NO_MOB) ) )
			continue;
		
		move_char( ch, door );
		if ( ( now_in = ch->in_room ) == was_in )
			continue;
		
		ch->in_room = was_in;
		
		if (!IS_NPC(victim) && victim->pcdata->powers[WPOWER_CHAMELEON] >= 4)
		{
			mxpout = g_string_new("");
			mxpconv(mxpout,dir_name[door],victim);
			sprintf(buf,"%s has fled %s!", ch->name->str,mxpout->str);
			send_to_char(buf,victim);
			g_string_free(mxpout,TRUE);
		}	
		else
			act( "$n has fled!", ch, NULL, NULL, TO_ROOM );
		
		playwave_toroom(ch, 3);
		ch->in_room = now_in;
		
		if ( !IS_NPC(ch) )
			playwave_toch(ch,3);
		send_to_char( "{yYou flee from combat!  Coward!{x\n\r", ch );
		send_to_char( "You lost 100 exp.\n\r", ch);
		gain_exp( ch, -100 );
		
		stop_fighting( ch, TRUE );
		send_to_char("You pause to catch your breath.\n\r", ch );
		WAIT_STATE(ch,PULSE_VIOLENCE);
		return;
	}
	
	send_to_char( "{YPANIC! {yYou were unable to escape!{x\n\r", ch );
	return;
}



void do_rescue( CHAR_DATA *ch, char *argument )
{
	char arg[MAX_INPUT_LENGTH];
	CHAR_DATA *victim;
	CHAR_DATA *fch;
	
	one_argument( argument, arg );
	if ( arg[0] == '\0' )
	{
		send_to_char( "Rescue whom?\n\r", ch );
		return;
	}
	
	if ( ( victim = get_char_room( ch, arg ) ) == NULL )
	{
		send_to_char( "They aren't here.\n\r", ch );
		return;
	}
	
	if ( victim == ch )
	{
		send_to_char( "What about fleeing instead?\n\r", ch );
		return;
	}
	
	if ( !IS_NPC(ch) && IS_NPC(victim) )
	{
		send_to_char( "Doesn't need your help!\n\r", ch );
		return;
	}
	
	if ( ch->fighting == victim )
	{
		send_to_char( "Too late.\n\r", ch );
		return;
	}
	
	if ( ( fch = victim->fighting ) == NULL )
	{
		send_to_char( "That person is not fighting right now.\n\r", ch );
		return;
	}
	
	if (check_pk(ch,victim,CHECK_DELAY|CHECK_ATTACK))
	{
		return;
	}

	if (IS_AVATAR(ch) && (ch->creature != victim->creature))
	{
		send_to_char("Umm now that is just wrong... go rescue someone of your own class jerky.\n\r",ch);
		return;
	}

	if(ch->move <= 0)
	{
		send_to_char("You can't find the energy to lift your weapon.\n\r",ch);
		return;
	}
	
	if ( is_safe(ch, fch) || is_safe(ch, victim) ) return;
	
	WAIT_STATE( ch, skill_table[gsn_rescue].beats );
	if ( !IS_NPC(ch) && number_percent( ) > ch->pcdata->learned[gsn_rescue] )
	{
		send_to_char( "You fail the rescue.\n\r", ch );
		return;
	}

	if (!IS_NPC(victim) && IS_ADDED(victim,ADDED_FRENZY) 
			&& victim->pcdata->frenzy_action == FRENZY_FIGHT)
	{
		send_to_char("They connot be saved.\n\r",ch);
		return;
	}


	act( "You rescue $N!",  ch, NULL, victim, TO_CHAR    );
	act( "$n rescues you!", ch, NULL, victim, TO_VICT    );
	act( "$n rescues $N!",  ch, NULL, victim, TO_NOTVICT );
	
	stop_fighting( fch, FALSE );
	stop_fighting( victim, FALSE );
	check_killer( ch, fch );
	if (ch->fighting == NULL)
		set_fighting( ch, fch );
	if (fch->fighting == NULL)
		set_fighting( fch, ch );
	set_attack_flag(ch,fch);
	
	do_humanity(ch,"");
	return;
}



void do_kick( CHAR_DATA *ch, char *argument )
{
	CHAR_DATA *victim;
	OBJ_DATA *boots;
	double dam;
	int stance;
	
	if ( !IS_NPC(ch)
		&&   ch->level < skill_table[gsn_kick].skill_level)
	{
		send_to_char(
			"First you should learn to kick.\n\r", ch );
		return;
	}

	if ( ( victim = ch->fighting ) == NULL )
	{
		send_to_char( "You aren't fighting anyone.\n\r", ch );
		return;
	}
	
	if (check_disc(ch,victim,CDISC_PK|CDISC_TSAFE|CDISC_PLANE|CDISC_REINA))
		return;
	
	if(ch->move <= 0)
	{
		send_to_char("You can't find the energy to kick.\n\r",ch);
		return;
	}
	
	WAIT_STATE( ch, skill_table[gsn_kick].beats );
	if ( IS_NPC(ch) || number_percent( ) < ch->pcdata->learned[gsn_kick] )
		dam = number_range(1,4);
	else
	{
		dam = 0;
		damage( ch, victim, (int)dam, gsn_kick );
		return;
	}
	
	dam += char_damroll(ch);
	if (dam == 0) dam = 1;
	if ( !IS_AWAKE(victim) )
		dam *= 2;
	if ( !IS_NPC(ch) && IS_CLASS(ch, CLASS_VAMPIRE) 
		&& get_disc(ch, DISC_POTENCE) > 0 
		&& ch->pcdata->condition[COND_THIRST] > 20 )
		dam *= (.25 * get_disc(ch, DISC_POTENCE) + 1);
	if ( !IS_NPC(victim) && IS_CLASS(victim, CLASS_WEREWOLF) )
	{
		if (IS_SET(victim->special, SPC_WOLFMAN))
		{
			dam *= 0.5;
			if (victim->pcdata->powers[WPOWER_BOAR] > 2 ) dam *= 0.5;
		}
		if ( ( boots = get_eq_char( ch, WEAR_FEET ) ) != NULL 
			&& IS_SET(boots->spectype, SITEM_SILVER)) dam *= 2;
	}
    /* Vampires should be tougher at night and weaker during the day. */
	if ( !IS_NPC(ch) && IS_CLASS(ch, CLASS_VAMPIRE) )
	{
		switch (weather_info[ch->in_room->sector_type].sunlight)
		{
			case SUN_LIGHT:
				if (IS_SET(ch->added,ADDED_NIGHTFALL))
					dam *= 1.5;
				else
					dam /= 1.5;
			case SUN_DARK:
				dam *= 1.5;
			default:
				if (IS_SET(ch->added,ADDED_NIGHTFALL))
					dam *= 1.5;
				
		}
		
	}
	if ( !IS_NPC(ch) ) dam = dam + (dam * ((ch->wpn[0]+1) / 100));
	
	if ( !IS_NPC(ch) )
	{
		stance = ch->stance[0];
		if ( IS_STANCE(ch, STANCE_NORMAL) ) dam *= 1.25;
		else dam = dambonus(ch,victim,(int)dam,stance);
	}
	
	if ( dam <= 0 )
		dam = 1;
	
	if ( !IS_NPC(victim) && IS_IMMMERIT(victim, IMM_MERIT_KICK) )
	{
		act("$N's blocks your attempt to kick!",ch,NULL,victim,TO_CHAR);
	}
	else
	{	
		if (!IS_NPC(victim) && IS_IMMFLAW(victim,IMM_FLAW_KICK))
			dam += dam;
		damage( ch, victim, (int)dam, gsn_kick );
	}
	return;
}
void do_punch( CHAR_DATA *ch, char *argument )
{
	char arg [MAX_INPUT_LENGTH];
	CHAR_DATA *victim;
	int dam;
	int store;
	bool broke = FALSE;
	
	one_argument(argument,arg);
	
	if ( IS_NPC(ch) ) return;
	
	if ( ch->level < skill_table[gsn_punch].skill_level)
	{
		send_to_char( "First you should learn to punch.\n\r", ch );
		return;
	}
	
	if ( ( victim = get_char_room( ch, arg ) ) == NULL )
	{
		send_to_char( "You aren't fighting anyone.\n\r", ch );
		return;
	}
	
	if ( ch == victim )
	{
		send_to_char( "You cannot punch yourself!\n\r", ch );
		return;
	}
	
	if (check_disc(ch,victim,CDISC_PK|CDISC_TSAFE|CDISC_PLANE|CDISC_REINA))
		return;
	
	if (is_safe(ch,victim)) return;
	
	if ( victim->hit < victim->max_hit )
	{
		send_to_char( "They are hurt and suspicious.\n\r", ch );
		return;
	}
	
	if ( victim->position < POS_FIGHTING )
	{
		send_to_char( "You can only punch someone who is standing.\n\r", ch );
		return;
	}
	
	if(ch->move <= 0)
	{
		send_to_char("You can't find the energy to lift your arms.\n\r",ch);
		return;
	}
	
        if (check_pk(ch,victim,CHECK_DELAY|CHECK_ATTACK))
        {
                return;
        }

	playwave_toroom(ch,8);
	act("You draw your fist back and aim a punch at $N.",ch,NULL,victim,TO_CHAR);
	act("$n draws $s fist back and aims a punch at you.",ch,NULL,victim,TO_VICT);
	act("$n draws $s fist back and aims a punch at $N.",ch,NULL,victim,TO_NOTVICT);
	WAIT_STATE( ch, skill_table[gsn_punch].beats );
	if ( IS_NPC(ch) || number_percent( ) < ch->pcdata->learned[gsn_punch] )
		dam = number_range(1,4);
	else
	{
		dam = 0;
		damage( ch, victim, dam, gsn_punch );
		return;
	}
	
	dam += char_damroll(ch);
	if (dam == 0) dam = 1;
	if ( !IS_AWAKE(victim) )
		dam *= 2;
	if ( !IS_NPC(ch) ) dam = dam + (dam * (ch->wpn[0] / 100));
	
	if ( dam <= 0 )
		dam = 1;
	
	if (!IS_NPC(victim) && IS_CLASS(victim, CLASS_WEREWOLF) && IS_SET(victim->special, SPC_WOLFMAN) && victim->pcdata->powers[WPOWER_BOAR] > 3)
	{
		store = victim->hit;
		victim->hit += dam;
		damage( ch, victim, dam, gsn_punch );
		victim->hit = store;
		if (number_percent() <= 25 && !IS_ARM_L(ch,LOST_ARM) && 
			!IS_ARM_L(ch,LOST_HAND))
		{
			if (!IS_ARM_L(ch, LOST_FINGER_I) && !IS_ARM_L(ch, BROKEN_FINGER_I))
			{SET_BIT(ch->loc_hp[LOC_ARM_L],BROKEN_FINGER_I);broke = TRUE;}
			if (!IS_ARM_L(ch, LOST_FINGER_M) && !IS_ARM_L(ch, BROKEN_FINGER_M))
			{SET_BIT(ch->loc_hp[LOC_ARM_L],BROKEN_FINGER_M);broke = TRUE;}
			if (!IS_ARM_L(ch, LOST_FINGER_R) && !IS_ARM_L(ch, BROKEN_FINGER_R))
			{SET_BIT(ch->loc_hp[LOC_ARM_L],BROKEN_FINGER_R);broke = TRUE;}
			if (!IS_ARM_L(ch, LOST_FINGER_L) && !IS_ARM_L(ch, BROKEN_FINGER_L))
			{SET_BIT(ch->loc_hp[LOC_ARM_L],BROKEN_FINGER_L);broke = TRUE;}
			if (broke)
			{
				act("The fingers on your left hand shatter under the impact of the blow!",ch,NULL,NULL,TO_CHAR);
				act("The fingers on $n's left hand shatter under the impact of the blow! ",ch,NULL,NULL,TO_ROOM);
			}
		}
		else if (number_percent() <= 25 && !IS_ARM_R(ch,LOST_ARM) && 
			!IS_ARM_R(ch,LOST_HAND))
		{
			if (!IS_ARM_R(ch, LOST_FINGER_I) && !IS_ARM_R(ch, BROKEN_FINGER_I))
			{SET_BIT(ch->loc_hp[LOC_ARM_R],BROKEN_FINGER_I);broke = TRUE;}
			if (!IS_ARM_R(ch, LOST_FINGER_M) && !IS_ARM_R(ch, BROKEN_FINGER_M))
			{SET_BIT(ch->loc_hp[LOC_ARM_R],BROKEN_FINGER_M);broke = TRUE;}
			if (!IS_ARM_R(ch, LOST_FINGER_R) && !IS_ARM_R(ch, BROKEN_FINGER_R))
			{SET_BIT(ch->loc_hp[LOC_ARM_R],BROKEN_FINGER_R);broke = TRUE;}
			if (!IS_ARM_R(ch, LOST_FINGER_L) && !IS_ARM_R(ch, BROKEN_FINGER_L))
			{SET_BIT(ch->loc_hp[LOC_ARM_R],BROKEN_FINGER_L);broke = TRUE;}
			if (broke)
			{
				act("The fingers on your right hand shatter under the impact of the blow!",ch,NULL,NULL,TO_CHAR);
				act("The fingers on $n's right hand shatter under the impact of the blow! ",ch,NULL,NULL,TO_ROOM);
			}
		}
		stop_fighting(victim,TRUE);
		return;
	}
	
	damage( ch, victim, dam, gsn_punch );
	if (victim == NULL || victim->position == POS_DEAD || dam < 1) return;
	if (victim->position == POS_FIGHTING) stop_fighting(victim,TRUE);
	if (number_percent() <= 25 && !IS_HEAD(victim,BROKEN_NOSE)
		&& !IS_HEAD(victim,LOST_NOSE))
	{
		act("Your nose shatters under the impact of the blow!",victim,NULL,NULL,TO_CHAR);
		act("$n's nose shatters under the impact of the blow!",victim,NULL,NULL,TO_ROOM);
		SET_BIT(victim->loc_hp[LOC_HEAD],BROKEN_NOSE);
	}
	else if (number_percent() <= 25 && !IS_HEAD(victim,BROKEN_JAW))
	{
		act("Your jaw shatters under the impact of the blow!",victim,NULL,NULL,TO_CHAR);
		act("$n's jaw shatters under the impact of the blow!",victim,NULL,NULL,TO_ROOM);
		SET_BIT(victim->loc_hp[LOC_HEAD],BROKEN_JAW);
	}
	if (IS_NPC(victim) && !IS_NPC(ch))
	{
		set_mob_stance(victim);
		mob_remember(victim,ch,MEM_HOSTILE);
	}
	act("You fall to the ground stunned!",victim,NULL,NULL,TO_CHAR);
	act("$n falls to the ground stunned!",victim,NULL,NULL,TO_ROOM);
	victim->position = POS_STUNNED;
	return;
}


void do_berserk( CHAR_DATA *ch, char *argument )
{
	char       arg [MAX_INPUT_LENGTH];
	CHAR_DATA *vch;
	CHAR_DATA *vch_next;
	CHAR_DATA *mount;
	int number_hit = 0;
	int Berserk_Num;

	argument = one_argument( argument, arg );
	
	if (IS_NPC(ch)) return;
	
	if ( ch->level < skill_table[gsn_berserk].skill_level)
	{
		send_to_char( "You are not wild enough to go berserk.\n\r", ch );
		return;
	}
	

	if(ch->move <= 0)
	{
		send_to_char("You can't find the energy to move.\n\r",ch);
		return;
	}
	
	WAIT_STATE( ch, skill_table[gsn_berserk].beats );
	if ( number_percent( ) > ch->pcdata->learned[gsn_berserk] )
	{
		act("You rant and rave, but nothing much happens.",ch,NULL,NULL,TO_CHAR);
		act("$n gets a wild look in $s eyes, but nothing much happens.",ch,NULL,NULL,TO_ROOM);
		return;
	}
	
	act("You go BERSERK!",ch,NULL,NULL,TO_CHAR);
	act("$n goes BERSERK!",ch,NULL,NULL,TO_ROOM);
    put_stance(ch);
	Berserk_Num = number_range(1,10);
	for ( vch = ch->in_room->people; vch != NULL; vch = vch_next )
	{

		vch_next	= vch->next_in_room;
		if (number_hit > Berserk_Num) continue;
		if ( vch->in_room == NULL )
			continue;
		if ( !IS_NPC(vch) && vch->pcdata->chobj != NULL )
			continue;
		if ( ch == vch )
			continue;
		if ( vch->in_room == ch->in_room )
		{
			if (check_pk(ch, vch, CHECK_DELAY|CHECK_ATTACK))
			continue;
			if ( ( mount = ch->mount ) != NULL ) {if ( mount == vch ) continue;}
			if (can_see(ch,vch))
			{
				if (!IS_NPC(vch))
					set_attack_flag(ch,vch);
				multi_hit( ch, vch, TYPE_UNDEFINED );
				number_hit++;
			}
		}
	}
	do_beastlike(ch,"");
	return;
}



/* Hurl skill by KaVir */
void do_hurl( CHAR_DATA *ch, char *argument )
{
	CHAR_DATA       *victim;
	CHAR_DATA       *mount;
	ROOM_INDEX_DATA *to_room;
	EXIT_DATA       *pexit;
	EXIT_DATA       *pexit_rev;
	char            buf       [MAX_INPUT_LENGTH];
	char            direction [MAX_INPUT_LENGTH];
	char            arg1      [MAX_INPUT_LENGTH];
	char            arg2      [MAX_INPUT_LENGTH];
	int             door;
	int             rev_dir;
	int             dam;
	
	argument = one_argument( argument, arg1 );
	argument = one_argument( argument, arg2 );
	
	if ( !IS_NPC(ch) && ch->pcdata->learned[gsn_hurl] < 1 )
	{
		send_to_char("Maybe you should learn the skill first?\n\r",ch);
		return;
	}

	if ( ( victim = get_char_room( ch, arg1 ) ) == NULL )
	{
		send_to_char("They are not here.\n\r", ch);
		return;
	}
	
	if ( victim == ch )
	{
		send_to_char( "How can you hurl yourself?\n\r", ch );
		return;
	}
	
	if ( is_safe( ch, victim ) )
		return;
	
	if ( (mount = victim->mount) != NULL && victim->mounted == IS_MOUNT)
	{
		send_to_char("But they have someone on their back!\n\r",ch);
		return;
	}
	else if ( (mount = victim->mount) != NULL && victim->mounted == IS_RIDING)
	{
		send_to_char("But they are riding!\n\r",ch);
		return;
	}
	
	if ( !IS_NPC(victim) && IS_IMMMERIT(victim, IMM_MERIT_HURL) )
	{
		send_to_char("You are unable to get their feet off the ground.\n\r",ch);
		return;
	}
	
	if ( IS_NPC(victim) && victim->level > 90 )
	{
		send_to_char("You are unable to get their feet off the ground.\n\r",ch);
		return;
	}
	
	if ( (victim->hit < victim->max_hit)
		|| ( victim->position == POS_FIGHTING && victim->fighting != ch) )
	{
		act( "$N is hurt and suspicious, and you are unable to approach $M.",
			ch, NULL, victim, TO_CHAR );
		return;
	}
	
	if(ch->move <= 0)
	{
		send_to_char("You can't find the energy to move.\n\r",ch);
		return;
	}
	
    if (check_disc(ch,victim,CDISC_PK|CDISC_TSAFE|CDISC_PLANE|CDISC_REINA))
		return;
	
	WAIT_STATE( ch, skill_table[gsn_hurl].beats );
	if (!IS_NPC(victim) && !IS_IMMFLAW(victim,IMM_FLAW_HURL))
	{
		if ( !IS_NPC(ch) && number_percent( ) > ch->pcdata->learned[gsn_hurl] )
		{
			send_to_char("You are unable to get their feet off the ground.\n\r",ch);
			multi_hit( victim, ch, TYPE_UNDEFINED );
			return;
		}
	}
	rev_dir = 0;
	
	if ( arg2[0] == '\0' )
		door = number_range(0,3);
	else
	{
		if      ( !str_cmp( arg2, "n" ) || !str_cmp( arg2, "north" ) )
			door = 0;
		else if ( !str_cmp( arg2, "e" ) || !str_cmp( arg2, "east" ) )
			door = 1;
		else if ( !str_cmp( arg2, "s" ) || !str_cmp( arg2, "south" ) )
			door = 2;
		else if ( !str_cmp( arg2, "w" ) || !str_cmp( arg2, "west" ) )
			door = 3;
		else
		{
			send_to_char("You can only hurl people north, south, east or west.\n\r", ch);
			return;
		}
	}
	
	if (door == 0) {sprintf(direction,"north");rev_dir = 2;}
	if (door == 1) {sprintf(direction,"east");rev_dir = 3;}
	if (door == 2) {sprintf(direction,"south");rev_dir = 0;}
	if (door == 3) {sprintf(direction,"west");rev_dir = 1;}
	
	if (( pexit = ch->in_room->exit[door]) == NULL || (to_room = pexit->to_room) == NULL)
	{
		sprintf(buf,"$n hurls $N into the %s wall.", direction);
		act(buf,ch,NULL,victim,TO_NOTVICT);
		sprintf(buf,"You hurl $N into the %s wall.", direction);
		act(buf,ch,NULL,victim,TO_CHAR);
		sprintf(buf,"$n hurls you into the %s wall.", direction);
		act(buf,ch,NULL,victim,TO_VICT);
		dam = number_range(ch->level, (ch->level * 4));
		victim->hit = victim->hit - dam;
		update_pos(victim);
		if (IS_NPC(victim) && !IS_NPC(ch)) ch->mkill = ch->mkill + 1;
		if (!IS_NPC(victim) && IS_NPC(ch)) victim->mdeath = victim->mdeath + 1;
		if (victim->position == POS_DEAD) {hurt_person(ch,victim,0);return;}
		return;
	}
	
	pexit = victim->in_room->exit[door];
	if (IS_SET(pexit->exit_info, EX_CLOSED) && 
		!IS_AFFECTED(victim,AFF_PASS_DOOR ) &&
		!ch->plane != PLANE_ETHEREAL)
	{
		if (IS_SET(pexit->exit_info, EX_LOCKED))
			REMOVE_BIT(pexit->exit_info, EX_LOCKED);
		if (IS_SET(pexit->exit_info, EX_CLOSED))
			REMOVE_BIT(pexit->exit_info, EX_CLOSED);
		sprintf(buf,"$n hoists $N in the air and hurls $M %s.", direction);
		act(buf,ch,NULL,victim,TO_NOTVICT);
		sprintf(buf,"You hoist $N in the air and hurl $M %s.", direction);
		act(buf,ch,NULL,victim,TO_CHAR);
		sprintf(buf,"$n hurls you %s, smashing you through the %s.", direction,pexit->keyword);
		act(buf,ch,NULL,victim,TO_VICT);
		sprintf(buf,"There is a loud crash as $n smashes through the $d.");
		act(buf,victim,NULL,pexit->keyword,TO_ROOM);
		
		if ( ( to_room   = pexit->to_room               ) != NULL
			&&   ( pexit_rev = to_room->exit[rev_dir] ) != NULL
			&&   pexit_rev->to_room == ch->in_room
			&&   pexit_rev->keyword != NULL )
		{
			if (IS_SET(pexit_rev->exit_info, EX_LOCKED))
				REMOVE_BIT( pexit_rev->exit_info, EX_LOCKED );
			if (IS_SET(pexit_rev->exit_info, EX_CLOSED))
				REMOVE_BIT( pexit_rev->exit_info, EX_CLOSED );
			if (door == 0) sprintf(direction,"south");
			if (door == 1) sprintf(direction,"west");
			if (door == 2) sprintf(direction,"north");
			if (door == 3) sprintf(direction,"east");
			char_from_room(victim);
			char_to_room(victim,to_room);
			sprintf(buf,"$n comes smashing in through the %s $d.", direction);
			act(buf,victim,NULL,pexit->keyword,TO_ROOM);
			dam = number_range(ch->level, (ch->level * 6));
			victim->hit = victim->hit - dam;
			update_pos(victim);
			if (IS_NPC(victim) && !IS_NPC(ch)) ch->mkill = ch->mkill + 1;
			if (!IS_NPC(victim) && IS_NPC(ch)) victim->mdeath = victim->mdeath + 1;
			if (victim->position == POS_DEAD) {hurt_person(ch,victim,0);return;}
		}
	}
	else
	{
		sprintf(buf,"$n hurls $N %s.", direction);
		act(buf,ch,NULL,victim,TO_NOTVICT);
		sprintf(buf,"You hurl $N %s.", direction);
		act(buf,ch,NULL,victim,TO_CHAR);
		sprintf(buf,"$n hurls you %s.", direction);
		act(buf,ch,NULL,victim,TO_VICT);
		if (door == 0) sprintf(direction,"south");
		if (door == 1) sprintf(direction,"west");
		if (door == 2) sprintf(direction,"north");
		if (door == 3) sprintf(direction,"east");
		char_from_room(victim);
		char_to_room(victim,to_room);
		sprintf(buf,"$n comes flying in from the %s.", direction);
		act(buf,victim,NULL,NULL,TO_ROOM);
		dam = number_range(ch->level, (ch->level * 2));
		victim->hit = victim->hit - dam;
		update_pos(victim);
		if (IS_NPC(victim) && !IS_NPC(ch)) ch->mkill = ch->mkill + 1;
		if (!IS_NPC(victim) && IS_NPC(ch)) victim->mdeath = victim->mdeath + 1;
		if (victim->position == POS_DEAD) {hurt_person(ch,victim,0);return;}
	}
	return;
}



void do_disarm( CHAR_DATA *ch, char *argument )
{
	CHAR_DATA *victim;
	OBJ_DATA *obj;
	int percent;
	
	if ( !IS_NPC(ch)
		&&   ch->level < skill_table[gsn_disarm].skill_level)
	{
		send_to_char( "You don't know how to disarm opponents.\n\r", ch );
		return;
	}
	
	if ( ( get_eq_char( ch, WEAR_WIELD ) == NULL )
		&&   ( get_eq_char( ch, WEAR_HOLD  ) == NULL ) )
	{
		send_to_char( "You must wield a weapon to disarm.\n\r", ch );
		return;
	}

	if ( ( victim = ch->fighting ) == NULL )
	{
		send_to_char( "You aren't fighting anyone.\n\r", ch );
		return;
	}
	
	if ( ( ( obj = get_eq_char( victim, WEAR_WIELD ) ) == NULL )
		&&   ( ( obj = get_eq_char( victim, WEAR_HOLD  ) ) == NULL ) )
	{
		send_to_char( "Your opponent is not wielding a weapon.\n\r", ch );
		return;
	}
	
	WAIT_STATE( ch, skill_table[gsn_disarm].beats );
	percent = number_percent( ) + victim->level - ch->level;
	if (!IS_NPC(victim) && IS_IMMFLAW(victim, IMM_FLAW_DISARM))
		percent -= 40;
	if (!IS_NPC(victim) && IS_IMMMERIT(victim, IMM_MERIT_DISARM))
		send_to_char( "You failed.\n\r", ch );
	else if ( IS_NPC(ch) || percent < ch->pcdata->learned[gsn_disarm] * 2 / 3 )
		disarm( ch, victim );
	else
		send_to_char( "You failed.\n\r", ch );
	return;
}



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


void do_slay( CHAR_DATA *ch, char *argument )
{
	CHAR_DATA *victim;
	char arg[MAX_INPUT_LENGTH];
	char arg2[MAX_INPUT_LENGTH];
	
	argument = one_argument( argument, arg );
	one_argument( argument, arg2 );
	if ( arg[0] == '\0' )
	{
		send_to_char( "Syntax: slay [Char] [Type]\n\r", ch );
		send_to_char( " Types: Skin, Slit, Immolate, Demon, Shatter, Slit, Deheart, Pounce.\n\r", ch);
		return;
	}
	
	if ( ( victim = get_char_room( ch, arg ) ) == NULL )
	{
		send_to_char( "They aren't here.\n\r", ch );
		return;
	}
	
	if ( ch == victim )
	{
		send_to_char( "Suicide is a mortal sin.\n\r", ch );
		return;
	}
	
	if ( !IS_NPC(victim) && get_trust( victim ) >= get_trust( ch ) )
	{
		send_to_char( "You failed.\n\r", ch );
		return;
	}
	
	if ( !str_cmp( arg2, "skin" ) )
	{
		act( "You rip the flesh from $N and send his soul to the fiery depths of hell.", ch, NULL, victim, TO_CHAR );
		act( "Your flesh has been torn from your bones!", ch, NULL, victim, TO_VICT );
		act( "Your bodyless soul now watches your bones incenerate in the fires of hell.", ch, NULL, victim, TO_VICT );
		act( "$n rips the flesh off of $N, releasing his soul into the fiery depths of hell.", ch, NULL, victim, TO_NOTVICT );
	}
	
	else if ( !str_cmp( arg2, "deheart" ) )
	{
		act( "You rip through $N's chest and pull out $M beating heart in your hand.", ch, NULL, victim, TO_CHAR );
		act( "You feel a sharp pain as $n rips into your chest!", ch, NULL, victim, TO_VICT );
		act( "$n pulls our your beating heart in $M hand.", ch, NULL, victim, TO_VICT );
		act( "Specks of blood hit your face as $n rips through $N's chest pulling out $M's beating heart.", ch, NULL, victim, TO_NOTVICT );
	}
	
	else if ( !str_cmp( arg2, "immolate" ) )
	{
		act( "Your fireball turns $N into a blazing inferno.",  ch, NULL, victim, TO_CHAR    );
		act( "$n releases a searing fireball in your direction.", ch, NULL, victim, TO_VICT    );
		act( "$n points at $N, who bursts into a flaming inferno.",  ch, NULL, victim, TO_NOTVICT );
	}
	
	else if ( !str_cmp( arg2, "shatter" ) )
	{
		act( "You freeze $N with a glance and shatter the frozen corpse into tiny shards.",  ch, NULL, victim, TO_CHAR    );
		act( "$n freezes you with a glance and shatters your frozen body into tiny shards.", ch, NULL, victim, TO_VICT    );
		act( "$n freezes $N with a glance and shatters the frozen body into tiny shards.",  ch, NULL, victim, TO_NOTVICT );
	}
	
	else if ( !str_cmp( arg2, "demon" ) )
	{
		act( "You gesture, and a demon appears.  With a horrible grin, the creature turns on $N!",  ch, NULL, victim, TO_CHAR );
		act( "$N screams in panic before being eaten alive.",  ch, NULL, victim, TO_CHAR );
		act( "$n gestures, and a demon appears.  The creature turns on you with a horrible grin.",  ch, NULL, victim, TO_VICT );
		act( "You scream in panic before being eaten alive.",  ch, NULL, victim, TO_VICT );
		act( "$n gestures, and a slavering demon appears.  With a horrible grin, the foul creature turns on $N.",  ch, NULL, victim, TO_NOTVICT );
		act( "$N screams in panic before being eaten alive.",  ch, NULL, victim, TO_NOTVICT );
	}
	
	else if ( !str_cmp( arg2, "pounce" ) )
	{
		act( "Leaping upon $N with bared fangs, you tear open $S throat and toss the corpse to the ground...",  ch, NULL, victim, TO_CHAR );
		act( "In a heartbeat, $n rips $s fangs through your throat!", ch, NULL, victim, TO_VICT );
		act( "Your blood sprays and pours to the ground as your life ends...", ch, NULL, victim, TO_VICT );
		act( "Leaping suddenly, $n sinks $s fangs into $N's throat!",  ch, NULL, victim, TO_NOTVICT );
		act( "As blood sprays and gushes to the ground, $n tosses $N's dying body away.",  ch, NULL, victim, TO_NOTVICT );
	}
	
	else if ( !str_cmp( arg2, "slit" ))
	{
		act( "You calmly slit $N's throat.", ch, NULL, victim, TO_CHAR );
		act( "$n reaches out with a clawed finger and calmly slits your throat.", ch, NULL, victim, TO_VICT );
		act( "A claw extends from $n's hand as $M calmly slits $N's throat.", ch, NULL, victim, TO_NOTVICT );
	}
	
	else
	{
		act( "You slay $N in cold blood!",  ch, NULL, victim, TO_CHAR    );
		act( "$n slays you in cold blood!", ch, NULL, victim, TO_VICT    );
		act( "$n slays $N in cold blood!",  ch, NULL, victim, TO_NOTVICT );
	}
	
	raw_kill(victim);
	return;
}


/* Had problems with people not dying when POS_DEAD...KaVir */
void do_killperson( CHAR_DATA *ch, char *argument )
{
	CHAR_DATA *victim;
	char arg[MAX_INPUT_LENGTH];
	
	one_argument( argument, arg );
	if ( arg[0] == '\0' )
		return;
	if ( ( victim = get_char_room( ch, arg ) ) == NULL )
		return;
	send_to_char( "{RYou have been KILLED!!{x\n\r\n\r", victim );
	if (IS_NPC(victim) && !IS_NPC(ch)) ch->mkill = ch->mkill + 1;
	if (!IS_NPC(victim) && IS_NPC(ch)) victim->mdeath = victim->mdeath + 1;
	raw_kill( victim );
	return;
}


/* For decapitating players - KaVir */
void do_decapitate( CHAR_DATA *ch, char *argument )
{
	CHAR_DATA *victim;
	OBJ_DATA  *obj;
	OBJ_DATA  *obj2;
	char arg[MAX_INPUT_LENGTH];
	GString *ch_class;
	GString *vic_class;
	GString *final_string;
	
	int cap_bonus;
	bool fHas_Arti = FALSE;

    one_argument( argument, arg );
	
	if ( IS_NPC(ch) ) return;
	
	obj2 = get_eq_char( ch, WEAR_HOLD );
	if ( ( obj = get_eq_char( ch, WEAR_WIELD ) ) == NULL )
	{
		if ( ( obj2 = get_eq_char( ch, WEAR_HOLD ) ) == NULL )
		{
			send_to_char( "First you better get a weapon out!\n\r", ch );
			return;
		}
	}
	
	if ( ( obj != NULL && obj->item_type != ITEM_WEAPON ) )
	{
		if ( ( obj2 != NULL && obj2->item_type != ITEM_WEAPON ) )
		{
			send_to_char( "But you are not wielding any weapons!\n\r", ch );
			return;
		}
	}
	
	if ( ( obj  != NULL && obj->value[3]  != 1 && obj->value[3]  != 3 )
		&&   ( obj2 != NULL && obj2->value[3] != 1 && obj2->value[3] != 3 ) )
	{
		send_to_char( "You need to wield a slashing or slicing weapon to decapitate.\n\r", ch );
		return;
	}
	
	if ( arg[0] == '\0' )
	{
		send_to_char( "Decapitate whom?\n\r", ch );
		return;
	}
	
		if ( ( victim = get_char_room( ch, arg ) ) == NULL )
	{
		send_to_char( "They aren't here.\n\r", ch );
		return;
	}
	
	if ( ch == victim )
	{
		send_to_char( "That might be a bit tricky...\n\r", ch );
		return;
	}

	if (!IS_NPC(ch) && IS_SET(ch->pcdata->comm,COMM_AUTOPROTECT) && check_pk_range(ch,victim) )
	{
			send_to_char("You have been protected from decapatating a lower stat player\n\r",ch);
			return;
	}


	if ( IS_NPC(victim) )
	{
		send_to_char( "You can only decapitate other players.\n\r", ch );
		return;
	}
	
	if ( !CAN_PK(ch) )
	{
		send_to_char( "You must be an avatar to decapitate someone.\n\r", ch );
		return;
	}
	
	if ( !CAN_PK(victim) )
	{
		send_to_char( "You can only decapitate other avatars.\n\r", ch );
		return;
	}
	
	if ( victim->position > 1 )
	{
		send_to_char( "You can only do this to mortally wounded players.\n\r", ch );
		return;
	}
	
	if (is_safe(ch,victim)) return;
	
	if ( IS_CLASS(ch, CLASS_VAMPIRE) && IS_SET(ch->special, SPC_INCONNU) && 
		(IS_CLASS(victim, CLASS_VAMPIRE) || IS_VAMPAFF(victim, VAM_MORTAL)))
	{
		send_to_char( "You cannot decapitate another vampire.\n\r", ch );
		return;
	}
	
	if ( IS_CLASS(victim, CLASS_VAMPIRE) && IS_SET(victim->special, SPC_INCONNU) && 
		(IS_CLASS(ch, CLASS_VAMPIRE) || IS_VAMPAFF(ch, VAM_MORTAL)))
	{
		send_to_char( "You cannot decapitate an Inconnu vampire.\n\r", ch );
		return;
	}
	
	if(ch->move <= 0)
	{
		send_to_char("You can't find the energy to lift your weapon.\n\r",ch);
		return;
	}

        if (check_pk(ch,victim,CHECK_DELAY|CHECK_ATTACK))
        {
                return;
        }

        if ( ch->pk_timer < 1 )
        {       
                send_to_char("You can't seem to get close enough.\n\r",ch);
                send_to_char("Maybe if you were involved in the combat you'd have a better angle?\n\r",ch);
                return;
        }
    ch_class = get_player_class_string(ch);
    vic_class = get_player_class_string(victim);
    
	final_string = g_string_new("");
	g_string_sprintf(final_string,"a %s has been decapitated by a %s.",vic_class->str,ch_class->str);
    do_info(ch,final_string->str);
    
    
    act( "You bring your weapon down upon $N's neck!",  ch, NULL, victim, TO_CHAR    );
	send_to_char( "Your head is sliced from your shoulders!\n\r", victim);
	act( "$n swings $s weapon down towards $N's neck!",  ch, NULL, victim, TO_NOTVICT );
	act( "$n's head is sliced from $s shoulders!", victim, NULL, NULL, TO_ROOM);
    act( "A misty white vapour pours from $N's corpse into your body.",ch,NULL,victim, TO_CHAR    );
    act( "A misty white vapour pours from $N's corpse into $n's body.",ch,NULL,victim, TO_NOTVICT );
    act( "You double over in agony as raw energy pulses through your veins.",ch,NULL,NULL,TO_CHAR);
    act( "$n doubles over in agony as sparks of energy crackle around $m.",ch,NULL,NULL,TO_NOTVICT);

    if (IS_CLASS(victim, CLASS_VAMPIRE))      do_mortalvamp(victim,"");
    else if (IS_SET(victim->special, SPC_WOLFMAN)) do_unwerewolf(victim,"");
    if (IS_CLASS(victim, CLASS_MAGE) && IS_AFFECTED(victim, AFF_POLYMORPH))
            do_unpolymorph(victim,"");
    
    fHas_Arti = check_artifact(victim);

    behead( victim );
    do_beastlike(ch,"");
    ch->pk_timer = 8;
    victim->pcdata->stats[UNI_RAGE] = 0;
    victim->level = 2;
    do_save(ch,"");
    do_save(victim,"");
    victim->last_attacked = NULL;

    if (IS_SWWF(victim))
		shape_shift(victim, SHAPE_HOMID);
    
    set_attack_flag(ch,victim);
    
    cap_bonus = 0;
	cap_bonus += ( number_range(10000,80000) * victim->race) ;
	
	ch->exp += cap_bonus;
	
	calc_stat(ch,victim);
		    
    g_string_sprintf( final_string, "{WYou gain {R%d{W experience points.{x\n\r", cap_bonus);
	send_to_char( final_string->str, ch );
	
	g_string_free(ch_class,TRUE);
    g_string_free(vic_class,TRUE);
    g_string_free(final_string,TRUE);
    
	sprintf( log_buf, "%s decapitated by %s at %d.",
		victim->name->str, ch->name->str, victim->in_room->vnum );
	log_string2( log_buf );
	logchan(log_buf,NULL,NULL,WIZ_DECAP,0,LEVEL_IMMORTAL);
    //decap_note(ch,victim,DECAPT_DECAP,DECAPO_FOR_STAT);
    return;
}

void do_tear( CHAR_DATA *ch, char *argument )
{
	CHAR_DATA *victim;
	char arg[MAX_INPUT_LENGTH];
	char buf[MAX_STRING_LENGTH];
	bool fHas_Arti = FALSE;
	int cap_bonus;
	GString *ch_class;
	GString *vic_class;
	GString *final_string;
	
	one_argument( argument, arg );
	final_string = g_string_new("");
	
	if ( IS_NPC(ch) ) return;
	
	if ( !IS_CLASS(ch, CLASS_WEREWOLF) && !IS_CLASS(ch, CLASS_SWWF))
	{
		send_to_char( "Huh?\n\r", ch );
		return;
	}
	
	if ( IS_CLASS(ch, CLASS_WEREWOLF) && !IS_SET(ch->special, SPC_WOLFMAN))
	{
		send_to_char( "You can only tear heads off while in Crinos form.\n\r", ch );
		return;
	}

    if (IS_SWWF(ch) && ch->pcdata->wwf_shape == SHAPE_HOMID)
    {
        send_to_char("You must be in some other form other then Homid.\n\r",ch);
        return;
    }
	
	if ( !IS_VAMPAFF(ch, VAM_CLAWS))
	{
		send_to_char( "You better get your claws out first.\n\r", ch );
		return;
	}
	
	if ( arg[0] == '\0' )
	{
		send_to_char("Who's head do you wish to tear off?\n\r", ch );
		return;
	}
	
	if ( ( victim = get_char_room( ch, arg ) ) == NULL )
	{
		send_to_char( "They aren't here.\n\r", ch );
		return;
	}
	
	if ( ch == victim )
	{
		send_to_char( "That might be a bit tricky...\n\r", ch );
		return;
	}
	
	if ( IS_NPC(victim) )
	{
		send_to_char( "You can only tear the heads off other players.\n\r", ch );
		return;
	}

	
	if ( !CAN_PK(ch) )
	{
		send_to_char( "You must be an avatar to tear someone's head off.\n\r", ch );
		return;
	}
	
	if ( !CAN_PK(victim) )
	{
		send_to_char( "You can only tear the head off another avatar.\n\r", ch );
		return;
	}
	
	if ( victim->position > 1 )
	{
		send_to_char( "You can only do this to mortally wounded players.\n\r", ch );
		return;
	}
	
	if(ch->move <= 0)
	{
		send_to_char("You can't find the energy to swipe your claws.\n\r",ch);
		return;
	}

        if (check_pk(ch,victim,CHECK_DELAY))
        {
                send_to_char("Not with a delay timer...\n\r",ch);
                return;
        }

        if ( ch->pk_timer < 1 )
        {
                send_to_char("You can't seem to get close enough.\n\r",ch);
                send_to_char("Maybe if you were involved in the combat you'd have a better angle?\n\r",ch);
                return;
        }

	if (!IS_NPC(ch) && IS_SET(ch->pcdata->comm,COMM_AUTOPROTECT) && check_pk_range(ch,victim) )
	{
			send_to_char("You have been protected from tearing a lower stat player\n\r",ch);
			return;
	}


	if (is_safe(ch,victim)) return;
	
	act( "You tear $N's head from $S shoulders!",  ch, NULL, victim, TO_CHAR    );
	send_to_char( "Your head is torn from your shoulders!\n\r", victim);
	act( "$n tears $N's head from $S shoulders!",  ch, NULL, victim, TO_NOTVICT );
/*
    if ( victim->race < 1 && ch->race > 0 )
    {
    	sprintf(buf,"%s has been decapitated by %s.",victim->name,ch->name);
    	do_info(ch,buf);
	sprintf( log_buf, "%s decapitated by %s at %d for no status.",
	    victim->name, ch->name, victim->in_room->vnum );
	log_string2( log_buf );
	if (IS_CLASS(victim, CLASS_VAMPIRE))      do_mortalvamp(victim,"");
	else if (IS_SET(victim->special, SPC_WOLFMAN)) do_unwerewolf(victim,"");
	if (IS_CLASS(victim, CLASS_MAGE) && IS_AFFECTED(victim, AFF_POLYMORPH)) 
	    do_unpolymorph(victim,"");
	behead( victim );
	do_beastlike(ch,"");
	ch->pkill = ch->pkill + 1;
	victim->pdeath = victim->pdeath + 1;
	return;
    }
*/  
    ch_class = get_player_class_string(ch);
    vic_class = get_player_class_string(victim);
    
	g_string_sprintf(final_string,"a %s got thier head torn clean off by a %s.",vic_class->str,ch_class->str);
    do_info(ch,final_string->str);
    
    g_string_free(ch_class,TRUE);
    g_string_free(vic_class,TRUE);
    g_string_free(final_string,TRUE);
    
    victim->pdeath = victim->pdeath + 1;
	victim->pcdata->stats[UNI_RAGE] = 0;
	victim->level = 2;
    
    if (IS_SWWF(victim))
		shape_shift(victim, SHAPE_HOMID);
    
    set_attack_flag(ch,victim);
    
    victim->last_attacked = NULL;
    
    act( "A misty white vapour pours from $N's corpse into your body.",  ch, NULL, victim, TO_CHAR    );
	act( "A misty white vapour pours from $N's corpse into $n's body.",  ch, NULL, victim, TO_NOTVICT );
	act( "You double over in agony as raw energy pulses through your veins.",  ch, NULL, NULL, TO_CHAR    );
	act( "$n doubles over in agony as sparks of energy crackle around $m.",  ch, NULL, NULL, TO_NOTVICT );
	
    if (IS_CLASS(victim, CLASS_VAMPIRE))      
        do_mortalvamp(victim,"");
	else if (IS_SET(victim->special, SPC_WOLFMAN)) 
        do_unwerewolf(victim,"");
	if (IS_CLASS(victim, CLASS_MAGE) && IS_AFFECTED(victim, AFF_POLYMORPH)) 
		do_unpolymorph(victim,"");
	
    fHas_Arti = check_artifact(victim);

    behead( victim );
	do_beastlike(ch,"");
    
    ch->pk_timer = 8;
    
    do_save(ch,"");
    do_save(victim,"");

    if (fHas_Arti) 
    {
        sprintf( log_buf, "%s decapitated by %s at %d for artifact.",
           victim->name->str, ch->name->str, victim->in_room->vnum );
        log_string2( log_buf );
        logchan(log_buf,NULL,NULL,WIZ_DECAP,0,LEVEL_IMMORTAL);
        //decap_note(ch,victim,DECAPT_TEAR,DECAPO_FOR_ARTI);
        return;
    }

    cap_bonus = 0;
	cap_bonus += ( number_range(10000,80000) * victim->race) ;
	
	calc_stat(ch,victim);
	
	sprintf( buf, "{WYou gain {R%d{W experience points.{x\n\r", cap_bonus);
	send_to_char( buf, ch );
	
	sprintf( log_buf, "%s decapitated by %s at %d.",
		victim->name->str, ch->name->str, victim->in_room->vnum );
	logchan(log_buf,NULL,NULL,WIZ_DECAP,0,LEVEL_IMMORTAL);
    log_string2( log_buf );
    //decap_note(ch,victim,DECAPT_TEAR,DECAPO_FOR_STAT);
	return;
}

void do_crack( CHAR_DATA *ch, char *argument )
{
	OBJ_DATA  *obj;
	OBJ_DATA  *right;
	OBJ_DATA  *left;
	
	right = get_eq_char( ch, WEAR_WIELD );
	left = get_eq_char( ch, WEAR_HOLD );
	if (right != NULL && right->pIndexData->vnum == 12) obj = right;
	else if (left != NULL && left->pIndexData->vnum == 12) obj = left;
	else
	{
		send_to_char("You are not holding any heads.\n\r",ch);
		return;
	}
	act("You hurl $p at the floor.", ch, obj, NULL, TO_CHAR);
	act("$n hurls $p at the floor.", ch, obj, NULL, TO_ROOM);
	act("$p cracks open, leaking brains out across the floor.", ch, obj, NULL, TO_CHAR);
	if (obj->chobj != NULL)
	{act("$p cracks open, leaking brains out across the floor.", ch, obj, obj->chobj, TO_NOTVICT);
	act("$p crack open, leaking brains out across the floor.", ch, obj, obj->chobj, TO_VICT);}
	else
	{act("$p cracks open, leaking brains out across the floor.", ch, obj, NULL, TO_ROOM);}
	crack_head(ch,obj,obj->name->str);
	obj_from_char(obj);
	extract_obj(obj);
}
/* Voodoo skill by KaVir */

void do_voodoo( CHAR_DATA *ch, char *argument )
{
	CHAR_DATA *victim;
	OBJ_DATA  *obj;
	char      arg1 [MAX_INPUT_LENGTH];
	char      arg2 [MAX_INPUT_LENGTH];
	char       buf [MAX_INPUT_LENGTH];
	char     part1 [MAX_INPUT_LENGTH];
	char     part2 [MAX_INPUT_LENGTH];
	
	argument = one_argument( argument, arg1 );
	argument = one_argument( argument, arg2 );
	
	if ( arg1[0] == '\0')
	{
		send_to_char( "Who do you wish to use voodoo magic on?\n\r", ch );
		return;
	}
	
	if ( ( obj = get_eq_char( ch, WEAR_HOLD ) ) == NULL)
	{
		if ( ( obj = get_eq_char( ch, WEAR_WIELD ) ) == NULL)
		{
			send_to_char( "You are not holding a voodoo doll.\n\r", ch );
			return;
		}
	}
	
	if ( ( victim = get_char_world( ch, arg1 ) ) == NULL )
	{
		send_to_char( "They are not here.\n\r", ch );
		return;
	}
	
	if ( IS_NPC(victim) )
	{
		send_to_char( "Not on NPC's.\n\r", ch );
		return;
	}
	
	sprintf(part2,obj->name->str);
	sprintf(part1,"%s voodoo doll",victim->name->str);
	
	if ( str_infix(part1,part2) )
	{
		sprintf(buf,"But you are holding %s, not %s!\n\r",obj->short_descr->str,victim->name->str);
		send_to_char( buf, ch );
		return;
	}
	
	if ( arg2[0] == '\0')
	{
		send_to_char( "You can 'stab', 'burn' or 'throw' the doll.\n\r", ch );
	}
	else if ( !str_cmp(arg2, "stab") )
	{
		WAIT_STATE(ch,12);
		act("You stab a pin through $p.", ch, obj, NULL, TO_CHAR); 
		act("$n stabs a pin through $p.", ch, obj, NULL, TO_ROOM);
		if (!IS_NPC(victim) && IS_IMMMERIT(victim, IMM_MERIT_VOODOO)) return;
		act("You feel an agonizing pain in your chest!", victim, NULL, NULL, TO_CHAR);
		act("$n clutches $s chest in agony!", victim, NULL, NULL, TO_ROOM);
		if (!IS_NPC(victim) && IS_IMMFLAW(victim, IMM_FLAW_VOODOO))
		   damage(ch,victim,100,0);		
	}
	else if ( !str_cmp(arg2, "burn") )
	{
		WAIT_STATE(ch,12);
		act("You set fire to $p.", ch, obj, NULL, TO_CHAR);
		act("$n sets fire to $p.", ch, obj, NULL, TO_ROOM);
		act("$p burns to ashes.", ch, obj, NULL, TO_CHAR);
		act("$p burns to ashes.", ch, obj, NULL, TO_ROOM);
		obj_from_char(obj);
		extract_obj(obj);
		if (!IS_NPC(victim) && IS_IMMMERIT(victim, IMM_MERIT_VOODOO)) return;
		if (IS_AFFECTED(victim,AFF_FLAMING) )
			return;
		SET_BIT(victim->affected_by, AFF_FLAMING);
		act("You suddenly burst into flames!", victim, NULL, NULL, TO_CHAR);
		act("$n suddenly bursts into flames!", victim, NULL, NULL, TO_ROOM);
		if (!IS_NPC(victim) && IS_IMMFLAW(victim, IMM_FLAW_VOODOO))
		   damage(ch,victim,100,0);		
	}
	else if ( !str_cmp(arg2, "throw") )
	{
		WAIT_STATE(ch,12);
		act("You throw $p to the ground.", ch, obj, NULL, TO_CHAR);
		act("$n throws $p to the ground.", ch, obj, NULL, TO_ROOM);
		obj_from_char(obj);
		obj_to_room(obj, ch->in_room);
		if (!IS_NPC(victim) && IS_IMMMERIT(victim, IMM_MERIT_VOODOO)) return;
		if (victim->position < POS_STANDING)
			return;
		if (victim->position == POS_FIGHTING)
			stop_fighting(victim, TRUE);
		act("A strange force picks you up and hurls you to the ground!", victim, NULL, NULL, TO_CHAR);
		act("$n is hurled to the ground by a strange force.", victim, NULL, NULL, TO_ROOM);
		victim->position = POS_RESTING;
		victim->hit = victim->hit - number_range(ch->level,(5*ch->level));
		if (!IS_NPC(victim) && IS_IMMFLAW(victim, IMM_FLAW_VOODOO))
		   damage(ch,victim,100,0);		
		update_pos(victim);
	}
	else
	{
		send_to_char( "You can 'stab', 'burn' or 'throw' the doll.\n\r", ch );
	}
	return;
}

void do_stomp( CHAR_DATA *ch, char *argument )
{
	char arg [MAX_INPUT_LENGTH];
	CHAR_DATA *victim;
	int dam;
	int might_break = 0;
	
	one_argument(argument,arg);
	
	if ( IS_NPC(ch) ) return;

	if ( ch->level < skill_table[gsn_stomp].skill_level)
	{
		send_to_char( "First you should learn to stomp.\n\r", ch );
		return;
	}
	
        if ( arg == NULL  )
        {
                if ( ch->fighting != NULL )
                {
                        victim = ch->fighting;
                }
                else
                {
                        send_to_char( "You aren't fighting anyone.\n\r", ch );
                        return;
                }
        }
	
	if ( ( victim = get_char_room( ch, arg ) ) == NULL )
	{
		send_to_char( "Stomp who?\n\r", ch);
		return;
	}
	
	if ( ch == victim )
	{
		send_to_char( "You cannot stomp yourself!\n\r", ch );
		return;
	}
	
	if (check_pk(ch,victim,CHECK_DELAY|CHECK_ATTACK))
		return;	
	if (is_safe(ch,victim)) return;
	
	if ( victim->position < POS_FIGHTING )
	{
		send_to_char( "You can only stomp someone who is standing.\n\r", ch );
		return;
	}
	
	if(victim->move <= -300)
	{
		send_to_char("They aren't going anywhere.\n\r",ch);
		return;
	}
	
	if(ch->move <= 0)
	{
		send_to_char("You can't find the energy to stomp your foot.\n\r",ch);
		return;
	}
	
	if (check_disc(ch,victim,CDISC_PK|CDISC_TSAFE|CDISC_PLANE|CDISC_REINA))
		return;
	
	WAIT_STATE( ch, skill_table[gsn_stomp].beats );
	if ( IS_NPC(ch) || number_percent( ) < ch->pcdata->learned[gsn_stomp] )
	{
		dam = number_range(100,400);
		victim->move -= number_range(400,600);
	}
	else
	{
		dam = 0;
		damage( ch, victim, dam, gsn_stomp );
		return;
	}
        set_attack_flag(ch,victim);	
	switch ( number_range(1,3) )
	{
		case 1:
			act("You lift your leg up and stomp $N's foot hard.",ch,NULL,victim,TO_CHAR);
			act("$n brings a stomp down hard on your foot.",ch,NULL,victim,TO_VICT);
			act("$n stomps hard on $N's foot.",ch,NULL,victim,TO_NOTVICT);
			might_break = -1; /* Pick a toe */
			break;
			
		case 2:
			act("You rake your heel across $N's shin.",ch,NULL,victim,TO_CHAR);
			act("$n's heel cuts into your shin as $s stomps down on your leg.",ch,NULL,victim,TO_VICT);
			act("$n rakes $s heel hard across $N's shin.",ch,NULL,victim,TO_NOTVICT);
			might_break = BROKEN_LEG;
			break;
			
		case 3:
			act("Your heel tears into $S calf.",ch,NULL,victim,TO_CHAR);
			act("$n's heel rips into your calf with a powerful stomp.",ch,NULL,victim,TO_VICT);
			act("$n's powerful stomp rips into $N's calf.",ch,NULL,victim,TO_NOTVICT);
			might_break = BROKEN_LEG;
			break;
			
	}
	
	if ( !IS_AWAKE(victim) )
		dam *= 2;
	
	damage( ch, victim, dam, gsn_stomp );
	if (victim == NULL || victim->position == POS_DEAD || dam < 1) return;
	if (number_percent() <= 10 && might_break == -1)
	{
        /* Gotta break a toe. Pick a leg, and pick a toe. */
		might_break = 2^(number_range(8,12)); /* get the number for the TOE bits */
		if ( number_percent() < 50 && !IS_LEG_R(victim, might_break) ) /* 50/50 left or right */
		{
			SET_BIT(victim->loc_hp[LOC_LEG_R], might_break);
			act("Your toe shatters under the impact of the stomp!",victim,NULL,NULL,TO_CHAR);
			act("$n's toe shatters under the impact of the stomp!",victim,NULL,NULL,TO_ROOM);
		}
		else if ( !IS_LEG_L(victim, might_break) )
		{
			SET_BIT(victim->loc_hp[LOC_LEG_L], might_break);
			act("Your toe shatters under the impact of the stomp!",victim,NULL,NULL,TO_CHAR);
			act("$n's toe shatters under the impact of the stomp!",victim,NULL,NULL,TO_ROOM);
		}
        /* Maybe we broke something, maybe it was already broke, but we are done here */
		return;
	}
	else if (number_percent() <= 10 && might_break == BROKEN_LEG && !IS_LEG_R(victim,might_break))
	{
		act("Your right leg shatters under the impact of the stomp!",victim,NULL,NULL,TO_CHAR);
		act("$n's right leg shatters under the impact of the stomp!",victim,NULL,NULL,TO_ROOM);
		SET_BIT(victim->loc_hp[LOC_LEG_R], might_break);
	}
	else if (number_percent() <= 10 && might_break == BROKEN_LEG && !IS_LEG_L(victim,might_break))
	{
		act("Your left leg shatters under the impact of the stomp!",victim,NULL,NULL,TO_CHAR);
		act("$n's left leg shatters under the impact of the stomp!",victim,NULL,NULL,TO_ROOM);
		SET_BIT(victim->loc_hp[LOC_LEG_L], might_break);
	}
	return;
}
void do_surrender( CHAR_DATA *ch, char *argument )
{
	CHAR_DATA *mob;
	if ( ch->level > 2 )
	{
		send_to_char( "I don't think so...\n\r", ch );
		return;
	}
	
	if ( (mob = ch->fighting) == NULL )
	{
		send_to_char( "But you're not fighting!\n\r", ch );
		return;
	}
	act( "You surrender to $N!", ch, NULL, mob, TO_CHAR );
	act( "$n surrenders to you!", ch, NULL, mob, TO_VICT );
	act( "$n tries to surrender to $N!", ch, NULL, mob, TO_NOTVICT );
	stop_fighting( ch, TRUE );
	if ( !IS_NPC( ch ) && IS_NPC( mob ) 
		&&   ( !HAS_TRIGGER( mob, TRIG_SURR ) 
			|| !mp_percent_trigger( mob, ch, NULL, NULL, TRIG_SURR ) ) )
	{
		act( "$N seems to ignore your cowardly act!", ch, NULL, mob, TO_CHAR );
		multi_hit( mob, ch, TYPE_UNDEFINED );
	}
}
void do_bash( CHAR_DATA *ch, char *argument )
{
    char arg[MAX_INPUT_LENGTH];
    CHAR_DATA *victim;
    int chance = 50;

    one_argument(argument,arg);
 	
 	if (arg[0] == '\0')
    {
		victim = ch->fighting;
		if (victim == NULL)
		{
	    	send_to_char("But you aren't fighting anyone!\n\r",ch);
	    	return;
		}
    }

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

    if (victim->position < POS_FIGHTING)
    {
		act("You'll have to let $M get back up first.",ch,NULL,victim,TO_CHAR);
		return;
    } 

    if (victim == ch)
    {
		send_to_char("You try to bash your brains out, but fail.\n\r",ch);
		return;
    }

    if (is_safe(ch,victim))
		return;

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

    if ( !can_see( ch, victim ) )
    {
		send_to_char("You get a running start, and slam right into a wall.\n\r",ch);
		return;
    }

    /* modifiers */

    /* size  and weight */
    chance += ch->carry_weight / 250;
    chance -= victim->carry_weight / 200;

    /* stats */
    chance += get_curr_str(ch);
    chance -= (get_curr_dex(victim) * 4)/3;
    chance -= GET_AC(victim) / 5;
    
    if (number_percent() < chance )
    {
    
		act("{i$n sends you sprawling with a powerful bash!{x",
			ch,NULL,victim,TO_VICT);
		act("{hYou slam into $N, and send $M flying!{x",ch,NULL,victim,TO_CHAR);
		act("{k$n sends $N sprawling with a powerful bash.{x",
			ch,NULL,victim,TO_NOTVICT);
	
		WAIT_STATE(ch,24);
		victim->position = POS_RESTING;
		damage(ch,victim,number_range(2,2 + 2 + chance/20),TYPE_BASH);
	}
    else
    {
		damage(ch,victim,0,TYPE_BASH);
		act("{hYou fall flat on your face!{x",
	   	 ch,NULL,victim,TO_CHAR);
		act("{k$n falls flat on $s face.{x",
	  	  ch,NULL,victim,TO_NOTVICT);
		act("{iYou evade $n's bash, causing $m to fall flat on $s face.{x",
	    	ch,NULL,victim,TO_VICT);
		ch->position = POS_RESTING;
		WAIT_STATE(ch,24); 
    }
}
/* For decapitating players - KaVir */
void do_diablerize( CHAR_DATA *ch, char *argument )
{
	CHAR_DATA *victim;
	char arg[MAX_INPUT_LENGTH];
	char buf[MAX_STRING_LENGTH];
	int cap_bonus;
	bool fHas_Arti = FALSE;
	GString *ch_class;
	GString *vic_class;
	GString *final_string;
	
    one_argument( argument, arg );
	final_string = g_string_new("");
	
	if ( IS_NPC(ch) ) return;
	
	
	if (!IS_CLASS(ch,CLASS_VAMPIRE))
	{
		send_to_char("Huh?\n\r",ch);
		return;
	}

	if ( arg[0] == '\0' )
	{
		send_to_char( "Diablerize whom?\n\r", ch );
		return;
	}
	
		if ( ( victim = get_char_room( ch, arg ) ) == NULL )
	{
		send_to_char( "They aren't here.\n\r", ch );
		return;
	}
	
	if (!IS_NPC(ch) && !IS_VAMPAFF(ch,VAM_FANGS))
	{
		send_to_char("You might wanna have your fangs out for this one.\n\r",ch);
		return;
	}
	
	if ( ch == victim )
	{
		send_to_char( "That might be a bit tricky...\n\r", ch );
		return;
	}

	if (!IS_NPC(ch) && IS_SET(ch->pcdata->comm,COMM_AUTOPROTECT) && check_pk_range(ch,victim) )
	{
			send_to_char("You have been protected from diablerizing a lower stat player\n\r",ch);
			return;
	}


	if ( IS_NPC(victim) )
	{
		send_to_char( "You can only diablerize other players.\n\r", ch );
		return;
	}
	
	if ( !CAN_PK(ch) )
	{
		send_to_char( "You must be an avatar to diablerize someone.\n\r", ch );
		return;
	}
	
	if ( !CAN_PK(victim) )
	{
		send_to_char( "You can only diablerize other avatars.\n\r", ch );
		return;
	}
	
	if ( victim->position > 1 )
	{
		send_to_char( "You can only do this to mortally wounded players.\n\r", ch );
		return;
	}
	
	if (is_safe(ch,victim)) return;
	
	if ( !IS_CLASS(victim, CLASS_VAMPIRE) )
	{
		send_to_char( "You can only diablerize other vampires.\n\r", ch );
		return;
	}
	
	if ( IS_CLASS(victim, CLASS_VAMPIRE) && IS_SET(victim->special, SPC_INCONNU) && 
		(IS_CLASS(ch, CLASS_VAMPIRE) || IS_VAMPAFF(ch, VAM_MORTAL)))
	{
		send_to_char( "You cannot diablerize an Inconnu vampire.\n\r", ch );
		return;
	}
	
	if(ch->move <= 0)
	{
		send_to_char("You can't find the energy to lift your head.\n\r",ch);
		return;
	}

        if (check_pk(ch,victim,CHECK_DELAY|CHECK_ATTACK))
        {
                return;
        }

        if ( ch->pk_timer < 1 )
        {       
                send_to_char("You can't seem to get close enough.\n\r",ch);
                send_to_char("Maybe if you were involved in the combat you'd have a better angle?\n\r",ch);
                return;
        }

	act( "You bring your fangs down upon $N's neck!",  ch, NULL, victim, TO_CHAR    );
	send_to_char( "Your blood starts to burn as you feel your life force slipping away!\n\r", victim);
	act( "$n swings $s head towards $N's neck!",  ch, NULL, victim, TO_NOTVICT );
	act( "$n's falls to the ground lifeless.", victim, NULL, NULL, TO_ROOM);
    
    victim->last_attacked = NULL;
    ch_class = get_player_class_string(ch);
    vic_class = get_player_class_string(victim);
    
	g_string_sprintf(final_string,"a %s has been Diablerized by a %s.",vic_class->str,ch_class->str);
    do_info(ch,final_string->str);
    
    g_string_free(ch_class,TRUE);
    g_string_free(vic_class,TRUE);
    g_string_free(final_string,TRUE);
    
    act( "A misty white vapour pours from $N's corpse into your body.",ch,NULL,victim, TO_CHAR    );
    act( "A misty white vapour pours from $N's corpse into $n's body.",ch,NULL,victim, TO_NOTVICT );
    act( "You double over in agony as raw energy pulses through your veins.",ch,NULL,NULL,TO_CHAR);
    act( "$n doubles over in agony as sparks of energy crackle around $m.",ch,NULL,NULL,TO_NOTVICT);

    if (IS_CLASS(victim, CLASS_VAMPIRE))      do_mortalvamp(victim,"");
    else if (IS_SET(victim->special, SPC_WOLFMAN)) do_unwerewolf(victim,"");
    if (IS_CLASS(victim, CLASS_MAGE) && IS_AFFECTED(victim, AFF_POLYMORPH))
            do_unpolymorph(victim,"");
    
    fHas_Arti = check_artifact(victim);

    diab_finish( victim );
    do_beastlike(ch,"");
    ch->pk_timer = 8;
    victim->pcdata->stats[UNI_RAGE] = 0;
    victim->level = 2;
    if (!IS_SET(ch->added,ADDED_DIABLERIE))
        SET_BIT(ch->added,ADDED_DIABLERIE);
    ch->pcdata->diab[DIAB_TIME] = 20;
    ch->pcdata->diab[DIAB_EVER]++;
    send_to_char("You feel wicked as a aura of diablerie surrounds your body.\n\r",ch);
    set_attack_flag(ch,victim);
    if (IS_SWWF(victim))
		shape_shift(victim, SHAPE_HOMID);
    do_save(ch,"");
    do_save(victim,"");

    if (fHas_Arti) 
    {
        sprintf( log_buf, "%s decapitated by %s at %d for artifact.",
           victim->name->str, ch->name->str, victim->in_room->vnum );
        log_string2( log_buf );
        logchan(log_buf,NULL,NULL,WIZ_DECAP,0,LEVEL_IMMORTAL);
        //decap_note(ch,victim,DECAPT_DIAB,DECAPO_FOR_ARTI);
        return;
    }


	cap_bonus = 0;
	cap_bonus += ( number_range(10000,80000) * victim->race) ;
	
	calc_stat(ch,victim);
	
	sprintf( buf, "{WYou gain {R%d{W experience points.{x\n\r", cap_bonus);
	send_to_char( buf, ch );
	
	sprintf( log_buf, "%s diablerized by %s at %d.",
		victim->name->str, ch->name->str, victim->in_room->vnum );
	log_string2( log_buf );
	logchan(log_buf,NULL,NULL,WIZ_DECAP,0,LEVEL_IMMORTAL);
    //decap_note(ch,victim,DECAPT_DIAB,DECAPO_FOR_STAT);
    return;
}