RaM Fire Updated/
/*
 * RAM $Id: fight.c 69 2009-01-11 18:13:26Z quixadhal $
 */

/***************************************************************************
 *  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.                                                  *
 ***************************************************************************/

/***************************************************************************
*       ROM 2.4 is copyright 1993-1998 Russ Taylor                         *
*       ROM has been brought to you by the ROM consortium                  *
*           Russ Taylor (rtaylor@hypercube.org)                            *
*           Gabrielle Taylor (gtaylor@hypercube.org)                       *
*           Brian Moore (zump@rom.org)                                     *
*       By using this code, you have agreed to follow the terms of the     *
*       ROM license, in the file Rom24/doc/rom.license                     *
***************************************************************************/

#include <sys/types.h>
#include <stdio.h>
#include <string.h>
#include <time.h>

#include "merc.h"
#include "strings.h"
#include "random.h"
#include "db.h"
#include "interp.h"
#include "act.h"
#include "magic.h"
#include "tables.h"

/*
 * Control the fights going on.
 * Called periodically by update_handler.
 */
void violence_update( void )
{
    CHAR_DATA              *ch = NULL;
    CHAR_DATA              *ch_next = NULL;
    CHAR_DATA              *victim = NULL;

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

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

        if ( IS_AWAKE( ch ) && ch->in_room == victim->in_room )
            multi_hit( ch, victim, TYPE_UNDEFINED );
        else
            stop_fighting( ch, false );

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

        /*
         * Fun for the whole family!
         */
        check_assist( ch, victim );

        if ( IS_NPC( ch ) )
        {
            if ( HAS_TRIGGER( ch, TRIG_FIGHT ) )
                mp_percent_trigger( ch, victim, NULL, NULL, TRIG_FIGHT );
            if ( HAS_TRIGGER( ch, TRIG_HPCNT ) )
                mp_hprct_trigger( ch, victim );
        }
    }

    return;
}

/* for auto assisting */
void check_assist( CHAR_DATA *ch, CHAR_DATA *victim )
{
    CHAR_DATA              *rch = NULL;
    CHAR_DATA              *rch_next = NULL;

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

        if ( IS_AWAKE( rch ) && rch->fighting == NULL )
        {
            /*
             * quick check for ASSIST_PLAYER 
             */
            if ( !IS_NPC( ch ) && IS_NPC( rch )
                 && IS_SET( rch->off_flags, ASSIST_PLAYERS )
                 && rch->level + 6 > victim->level && can_see( rch, ch ) )
            {
                do_function( rch, &do_emote, "screams and attacks!" );
                multi_hit( rch, victim, TYPE_UNDEFINED );
                continue;
            }

            /*
             * PCs next 
             */
            if ( !IS_NPC( ch ) || IS_AFFECTED( ch, AFF_CHARM ) )
            {
                if ( ( ( !IS_NPC( rch ) && IS_SET( rch->act, PLR_AUTOASSIST ) )
                       || IS_AFFECTED( rch, AFF_CHARM ) )
                     && is_same_group( ch, rch ) && !is_safe( rch, victim )
                     && can_see( rch, ch ) )
                    multi_hit( rch, victim, TYPE_UNDEFINED );
                continue;
            }

            /*
             * now check the NPC cases 
             */
            if ( IS_NPC( ch ) && !IS_AFFECTED( ch, AFF_CHARM ) )
            {
                if ( ( IS_NPC( rch ) && IS_SET( rch->off_flags, ASSIST_ALL ) )
                     || ( IS_NPC( rch ) && rch->group && rch->group == ch->group )
                     || ( IS_NPC( rch ) && rch->race == ch->race
                          && IS_SET( rch->off_flags, ASSIST_RACE ) )
                     || ( IS_NPC( rch ) && IS_SET( rch->off_flags, ASSIST_ALIGN )
                          && ( ( IS_GOOD( rch ) && IS_GOOD( ch ) )
                               || ( IS_EVIL( rch ) && IS_EVIL( ch ) )
                               || ( IS_NEUTRAL( rch ) && IS_NEUTRAL( ch ) ) ) )
                     || ( rch->pIndexData == ch->pIndexData
                          && IS_SET( rch->off_flags, ASSIST_VNUM ) ) )

                {
                    CHAR_DATA              *vch = NULL;
                    CHAR_DATA              *target = NULL;
                    int                     number = 0;

                    if ( number_bits( 1 ) == 0 )
                        continue;

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

                    if ( target != NULL )
                    {
                        do_function( rch, &do_emote, "screams and attacks!" );
                        multi_hit( rch, target, TYPE_UNDEFINED );
                    }
                }
            }
        }
    }
}

/*
 * Do one group of attacks.
 */
void multi_hit( CHAR_DATA *ch, CHAR_DATA *victim, int dt )
{
    int                     chance = 0;
    int                     sa = -1;
    int                     ta = -1;

    if ( ( sa = skill_lookup( "second attack" ) ) == -1 )
    {
        log_error( "Can't find the \"%s\" skill in %s?", "second attack", __FUNCTION__ );
        return;
    }

    if ( ( ta = skill_lookup( "third attack" ) ) == -1 )
    {
        log_error( "Can't find the \"%s\" skill in %s?", "third attack", __FUNCTION__ );
        return;
    }

    /*
     * decrement the wait 
     */
    if ( ch->desc == NULL )
        ch->wait = UMAX( 0, ch->wait - PULSE_VIOLENCE );

    if ( ch->desc == NULL )
        ch->daze = UMAX( 0, ch->daze - PULSE_VIOLENCE );

    /*
     * no attacks for stunnies -- just a check 
     */
    if ( ch->position < POS_RESTING )
        return;

    if ( IS_NPC( ch ) )
    {
        mob_hit( ch, victim, dt );
        return;
    }

    one_hit( ch, victim, dt );

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

    if ( IS_AFFECTED( ch, AFF_HASTE ) )
        one_hit( ch, victim, dt );

    if ( ch->fighting != victim || dt == skill_lookup( "backstab" ) )
        return;

    chance = get_skill( ch, sa ) / 2;

    if ( IS_AFFECTED( ch, AFF_SLOW ) )
        chance /= 2;

    if ( number_percent(  ) < chance )
    {
        one_hit( ch, victim, dt );
        check_improve( ch, sa, true, 5 );
        if ( ch->fighting != victim )
            return;
    }

    chance = get_skill( ch, ta ) / 4;

    if ( IS_AFFECTED( ch, AFF_SLOW ) )
        chance = 0;;

    if ( number_percent(  ) < chance )
    {
        one_hit( ch, victim, dt );
        check_improve( ch, ta, true, 6 );
        if ( ch->fighting != victim )
            return;
    }

    return;
}

/* procedure for all mobile attacks */
void mob_hit( CHAR_DATA *ch, CHAR_DATA *victim, int dt )
{
    int                     chance = 0;
    int                     number = 0;
    CHAR_DATA              *vch = NULL;
    CHAR_DATA              *vch_next = NULL;

    one_hit( ch, victim, dt );

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

    /*
     * Area attack -- BALLS nasty! 
     */

    if ( IS_SET( ch->off_flags, OFF_AREA_ATTACK ) )
    {
        for ( vch = ch->in_room->people; vch != NULL; vch = vch_next )
        {
            vch_next = vch->next;
            if ( ( vch != victim && vch->fighting == ch ) )
                one_hit( ch, vch, dt );
        }
    }

    if ( IS_AFFECTED( ch, AFF_HASTE )
         || ( IS_SET( ch->off_flags, OFF_FAST ) && !IS_AFFECTED( ch, AFF_SLOW ) ) )
        one_hit( ch, victim, dt );

    if ( ch->fighting != victim || dt == skill_lookup( "backstab" ) )
        return;

    chance = get_skill( ch, skill_lookup( "second attack" ) ) / 2;

    if ( IS_AFFECTED( ch, AFF_SLOW ) && !IS_SET( ch->off_flags, OFF_FAST ) )
        chance /= 2;

    if ( number_percent(  ) < chance )
    {
        one_hit( ch, victim, dt );
        if ( ch->fighting != victim )
            return;
    }

    chance = get_skill( ch, skill_lookup( "third attack" ) ) / 4;

    if ( IS_AFFECTED( ch, AFF_SLOW ) && !IS_SET( ch->off_flags, OFF_FAST ) )
        chance = 0;

    if ( number_percent(  ) < chance )
    {
        one_hit( ch, victim, dt );
        if ( ch->fighting != victim )
            return;
    }

    /*
     * oh boy! Fun stuff! 
     */

    if ( ch->wait > 0 )
        return;

    number = number_range( 0, 2 );

    if ( number == 1 && IS_SET( ch->act, ACT_MAGE ) )
    {
        /*
         * { mob_cast_mage(ch,victim); return; } 
         */ ;
    }

    if ( number == 2 && IS_SET( ch->act, ACT_CLERIC ) )
    {
        /*
         * { mob_cast_cleric(ch,victim); return; } 
         */ ;
    }

    /*
     * now for the skills 
     */

    number = number_range( 0, 8 );

    switch ( number )
    {
        case ( 0 ):
            if ( IS_SET( ch->off_flags, OFF_BASH ) )
                do_function( ch, &do_bash, "" );
            break;

        case ( 1 ):
            if ( IS_SET( ch->off_flags, OFF_BERSERK ) && !IS_AFFECTED( ch, AFF_BERSERK ) )
                do_function( ch, &do_berserk, "" );
            break;

        case ( 2 ):
            if ( IS_SET( ch->off_flags, OFF_DISARM )
                 || ( get_weapon_sn( ch ) != skill_lookup( "hand to hand" )
                      && ( IS_SET( ch->act, ACT_WARRIOR )
                           || IS_SET( ch->act, ACT_THIEF ) ) ) )
                do_function( ch, &do_disarm, "" );
            break;

        case ( 3 ):
            if ( IS_SET( ch->off_flags, OFF_KICK ) )
                do_function( ch, &do_kick, "" );
            break;

        case ( 4 ):
            if ( IS_SET( ch->off_flags, OFF_KICK_DIRT ) )
                do_function( ch, &do_dirt, "" );
            break;

        case ( 5 ):
            if ( IS_SET( ch->off_flags, OFF_TAIL ) )
            {
                /*
                 * do_function(ch, &do_tail, "") 
                 */ ;
            }
            break;

        case ( 6 ):
            if ( IS_SET( ch->off_flags, OFF_TRIP ) )
                do_function( ch, &do_trip, "" );
            break;

        case ( 7 ):
            if ( IS_SET( ch->off_flags, OFF_CRUSH ) )
            {
                /*
                 * do_function(ch, &do_crush, "") 
                 */ ;
            }
            break;
        case ( 8 ):
            if ( IS_SET( ch->off_flags, OFF_BACKSTAB ) )
            {
                do_function( ch, &do_backstab, "" );
            }
    }
}

/*
 * Hit one guy once.
 */
void one_hit( CHAR_DATA *ch, CHAR_DATA *victim, int dt )
{
    OBJ_DATA               *wield = NULL;
    int                     victim_ac = 0;
    int                     thac0 = 0;
    int                     thac0_00 = 0;
    int                     thac0_32 = 0;
    int                     dam = 0;
    int                     diceroll = 0;
    int                     sn = -1;
    int                     skill = 0;
    int                     dam_type = 0;
    bool                    result = false;

    /*
     * just in case 
     */
    if ( victim == ch || ch == NULL || victim == NULL )
        return;

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

    /*
     * Figure out the type of damage message.
     */
    wield = get_eq_char( ch, WEAR_WIELD );

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

    if ( dt < TYPE_HIT )
        if ( wield != NULL )
            dam_type = attack_table[wield->value[3]].damage;
        else
            dam_type = attack_table[ch->dam_type].damage;
    else
        dam_type = attack_table[dt - TYPE_HIT].damage;

    if ( dam_type == -1 )
        dam_type = DAM_BASH;

    /*
     * get the weapon skill 
     */
    sn = get_weapon_sn( ch );
    skill = 20 + get_weapon_skill( ch, sn );

    /*
     * Calculate to-hit-armor-iclass-0 versus armor.
     */
    if ( IS_NPC( ch ) )
    {
        thac0_00 = 20;
        thac0_32 = -4;                                 /* as good as a thief */
        if ( IS_SET( ch->act, ACT_WARRIOR ) )
            thac0_32 = -10;
        else if ( IS_SET( ch->act, ACT_THIEF ) )
            thac0_32 = -4;
        else if ( IS_SET( ch->act, ACT_CLERIC ) )
            thac0_32 = 2;
        else if ( IS_SET( ch->act, ACT_MAGE ) )
            thac0_32 = 6;
    }
    else
    {
        thac0_00 = class_table[ch->iclass].thac0_00;
        thac0_32 = class_table[ch->iclass].thac0_32;
    }
    thac0 = interpolate( ch->level, thac0_00, thac0_32 );

    if ( thac0 < 0 )
        thac0 = thac0 / 2;

    if ( thac0 < -5 )
        thac0 = -5 + ( thac0 + 5 ) / 2;

    thac0 -= GET_HITROLL( ch ) * skill / 100;
    thac0 += 5 * ( 100 - skill ) / 100;

    if ( dt == skill_lookup( "backstab" ) )
        thac0 -= 10 * ( 100 - get_skill( ch, dt ) );

    switch ( dam_type )
    {
        case ( DAM_PIERCE ):
            victim_ac = GET_AC( victim, AC_PIERCE ) / 10;
            break;
        case ( DAM_BASH ):
            victim_ac = GET_AC( victim, AC_BASH ) / 10;
            break;
        case ( DAM_SLASH ):
            victim_ac = GET_AC( victim, AC_SLASH ) / 10;
            break;
        default:
            victim_ac = GET_AC( victim, AC_EXOTIC ) / 10;
            break;
    };

    if ( victim_ac < -15 )
        victim_ac = ( victim_ac + 15 ) / 5 - 15;

    if ( !can_see( ch, victim ) )
        victim_ac -= 4;

    if ( victim->position < POS_FIGHTING )
        victim_ac += 4;

    if ( victim->position < POS_RESTING )
        victim_ac += 6;

    /*
     * The moment of excitement!
     */
    while ( ( diceroll = number_bits( 5 ) ) >= 20 )
        ;

    if ( diceroll == 0 || ( diceroll != 19 && diceroll < thac0 - victim_ac ) )
    {
        /*
         * Miss. 
         */
        damage( ch, victim, 0, dt, dam_type, true );
        tail_chain(  );
        return;
    }

    /*
     * Hit.
     * Calc damage.
     */
    if ( IS_NPC( ch ) && ( !ch->pIndexData->new_format || wield == NULL ) )
        if ( !ch->pIndexData->new_format )
        {
            dam = number_range( ch->level / 2, ch->level * 3 / 2 );
            if ( wield != NULL )
                dam += dam / 2;
        }
        else
            dam = dice( ch->damage[DICE_NUMBER], ch->damage[DICE_TYPE] );

    else
    {
        if ( sn != -1 )
            check_improve( ch, sn, true, 5 );
        if ( wield != NULL )
        {
            if ( wield->pIndexData->new_format )
                dam = dice( wield->value[1], wield->value[2] ) * skill / 100;
            else
                dam = number_range( wield->value[1] * skill / 100,
                                    wield->value[2] * skill / 100 );

            if ( get_eq_char( ch, WEAR_SHIELD ) == NULL )       /* no shield = more */
                dam = dam * 11 / 10;

            /*
             * sharpness! 
             */
            if ( IS_WEAPON_STAT( wield, WEAPON_SHARP ) )
            {
                int                     percent = 0;

                if ( ( percent = number_percent(  ) ) <= ( skill / 8 ) )
                    dam = 2 * dam + ( dam * 2 * percent / 100 );
            }
        }
        else
            dam = number_range( 1 + 4 * skill / 100, 2 * ch->level / 3 * skill / 100 );
    }

    /*
     * Bonuses.
     */
    {
        int                     ed = -1;

        if ( ( ed = skill_lookup( "enhanced damage" ) ) == -1 )
        {
            log_error( "Can't find the \"%s\" skill in %s?", "enhanced damage",
                       __FUNCTION__ );
            return;
        }
        if ( get_skill( ch, ed ) > 0 )
        {
            diceroll = number_percent(  );
            if ( diceroll <= get_skill( ch, ed ) )
            {
                check_improve( ch, ed, true, 6 );
                dam += 2 * ( dam * diceroll / 300 );
            }
        }
    }

    if ( !IS_AWAKE( victim ) )
        dam *= 2;
    else if ( victim->position < POS_FIGHTING )
        dam = dam * 3 / 2;

    if ( dt == skill_lookup( "backstab" ) && wield != NULL )
    {
        if ( wield->value[0] != 2 )
            dam *= 2 + ( ch->level / 10 );
        else
            dam *= 2 + ( ch->level / 8 );
    }
    dam += GET_DAMROLL( ch ) * UMIN( 100, skill ) / 100;

    if ( dam <= 0 )
        dam = 1;

    result = damage( ch, victim, dam, dt, dam_type, true );

    /*
     * but do we have a funky weapon? 
     */
    if ( result && wield != NULL )
    {
        if ( ch->fighting == victim && IS_WEAPON_STAT( wield, WEAPON_POISON ) )
        {
            int                     level = 0;
            AFFECT_DATA            *poison = NULL;
            AFFECT_DATA             af;
            int                     ps = -1;

            if ( ( ps = skill_lookup( "poison" ) ) == -1 )
            {
                log_error( "Can't find the \"%s\" skill in %s?", "poison", __FUNCTION__ );
                return;
            }
            if ( ( poison = affect_find( wield->affected, ps ) ) == NULL )
                level = wield->level;
            else
                level = poison->level;

            if ( !saves_spell( level / 2, victim, DAM_POISON ) )
            {
                ch_printf( victim, "You feel poison coursing through your veins." );
                act( "$n is poisoned by the venom on $p.", victim, wield, NULL, TO_ROOM );

                af.where = TO_AFFECTS;
                af.type = ps;
                af.level = level * 3 / 4;
                af.duration = level / 2;
                af.location = APPLY_STR;
                af.modifier = -1;
                af.bitvector = AFF_POISON;
                affect_join( victim, &af );
            }

            /*
             * weaken the poison if it's temporary 
             */
            if ( poison != NULL )
            {
                poison->level = UMAX( 0, poison->level - 2 );
                poison->duration = UMAX( 0, poison->duration - 1 );

                if ( poison->level == 0 || poison->duration == 0 )
                    act( "The poison on $p has worn off.", ch, wield, NULL, TO_CHAR );
            }
        }

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

        if ( ch->fighting == victim && IS_WEAPON_STAT( wield, WEAPON_FLAMING ) )
        {
            dam = number_range( 1, wield->level / 4 + 1 );
            act( "$n is burned by $p.", victim, wield, NULL, TO_ROOM );
            act( "$p sears your flesh.", victim, wield, NULL, TO_CHAR );
            fire_effect( ( void * ) victim, wield->level / 2, dam, TARGET_CHAR );
            damage( ch, victim, dam, 0, DAM_FIRE, false );
        }

        if ( ch->fighting == victim && IS_WEAPON_STAT( wield, WEAPON_FROST ) )
        {
            dam = number_range( 1, wield->level / 6 + 2 );
            act( "$p freezes $n.", victim, wield, NULL, TO_ROOM );
            act( "The cold touch of $p surrounds you with ice.",
                 victim, wield, NULL, TO_CHAR );
            cold_effect( victim, wield->level / 2, dam, TARGET_CHAR );
            damage( ch, victim, dam, 0, DAM_COLD, false );
        }

        if ( ch->fighting == victim && IS_WEAPON_STAT( wield, WEAPON_SHOCKING ) )
        {
            dam = number_range( 1, wield->level / 5 + 2 );
            act( "$n is struck by lightning from $p.", victim, wield, NULL, TO_ROOM );
            act( "You are shocked by $p.", victim, wield, NULL, TO_CHAR );
            shock_effect( victim, wield->level / 2, dam, TARGET_CHAR );
            damage( ch, victim, dam, 0, DAM_LIGHTNING, false );
        }
    }
    tail_chain(  );
    return;
}

/*
 * Inflict damage from a hit.
 */
bool damage( CHAR_DATA *ch, CHAR_DATA *victim, int dam, int dt, int dam_type, bool show )
{
    OBJ_DATA               *corpse = NULL;
    bool                    immune = false;

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

    /*
     * Stop up any residual loopholes.
     */
    if ( dam > 1200 && dt >= TYPE_HIT )
    {
        log_balance( ch, "%d damage: more than 1200 points!", dam );
        dam = 1200;
        if ( !IS_IMMORTAL( ch ) )
        {
            OBJ_DATA               *obj;

            obj = get_eq_char( ch, WEAR_WIELD );
            ch_printf( ch, "You really shouldn't cheat.\r\n" );
            if ( obj != NULL )
                extract_obj( obj );
        }

    }

    /*
     * damage reduction 
     */
    if ( dam > 35 )
        dam = ( dam - 35 ) / 2 + 35;
    if ( dam > 80 )
        dam = ( dam - 80 ) / 2 + 80;

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

        if ( victim->position > POS_STUNNED )
        {
            if ( victim->fighting == NULL )
            {
                set_fighting( victim, ch );
                if ( IS_NPC( victim ) && HAS_TRIGGER( victim, TRIG_KILL ) )
                    mp_percent_trigger( victim, ch, NULL, NULL, TRIG_KILL );
            }
            if ( victim->timer <= 4 )
                victim->position = POS_FIGHTING;
        }

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

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

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

    /*
     * Damage modifiers.
     */

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

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

    if ( dam > 1 && ( ( IS_AFFECTED( victim, AFF_PROTECT_EVIL ) && IS_EVIL( ch ) )
                      || ( IS_AFFECTED( victim, AFF_PROTECT_GOOD ) && IS_GOOD( ch ) ) ) )
        dam -= dam / 4;

    immune = false;

    /*
     * Check for parry, and dodge.
     */
    if ( dt >= TYPE_HIT && ch != victim )
    {
        if ( check_parry( ch, victim ) )
            return false;
        if ( check_dodge( ch, victim ) )
            return false;
        if ( check_shield_block( ch, victim ) )
            return false;

    }

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

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

    if ( dam == 0 )
        return false;

    /*
     * Hurt the victim.
     * Inform the victim of his new state.
     */
    victim->hit -= dam;
    if ( !IS_NPC( victim ) && victim->level >= LEVEL_IMMORTAL && victim->hit < 1 )
        victim->hit = 1;
    update_pos( victim );

    switch ( victim->position )
    {
        case POS_MORTAL:
            act( "$n is mortally wounded, and will die soon, if not aided.",
                 victim, NULL, NULL, TO_ROOM );
            ch_printf( victim,
                       "You are mortally wounded, and will die soon, if not aided.\r\n" );
            break;

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

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

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

        default:
            if ( dam > victim->max_hit / 4 )
                ch_printf( victim, "That really did HURT!\r\n" );
            if ( victim->hit < victim->max_hit / 4 )
                ch_printf( victim, "You sure are BLEEDING!\r\n" );
            break;
    }

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

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

        if ( !IS_NPC( victim ) )
        {
            /*
             * Dying penalty:
             * 2/3 way back to previous level.
             */
            if ( victim->exp > exp_per_level( victim, victim->pcdata->points )
                 * victim->level )
                gain_exp( victim, ( 2 * ( exp_per_level( victim, victim->pcdata->points )
                                          * victim->level - victim->exp ) / 3 ) + 50 );
        }

        log_kill( ch, victim, "%s killed by %s at %s [#%d]",
                  NAME( victim ), NAME( ch ), ch->in_room->name, ch->in_room->vnum );

        wiz_printf( NULL, NULL, IS_NPC( victim ) ? WIZ_MOBDEATHS : WIZ_DEATHS, 0, 0,
                    "%s killed by %s at %s [#%d]", NAME( victim ), NAME( ch ),
                    ch->in_room->name, ch->in_room->vnum );
        /*
         * Death trigger
         */
        if ( IS_NPC( victim ) && HAS_TRIGGER( victim, TRIG_DEATH ) )
        {
            victim->position = POS_STANDING;
            mp_percent_trigger( victim, ch, NULL, NULL, TRIG_DEATH );
        }

        raw_kill( victim );
        /*
         * dump the flags 
         */
        if ( ch != victim && !IS_NPC( ch ) && !is_same_clan( ch, victim ) )
        {
            if ( IS_SET( victim->act, PLR_KILLER ) )
                REMOVE_BIT( victim->act, PLR_KILLER );
            else
                REMOVE_BIT( victim->act, PLR_THIEF );
        }

        /*
         * RT new auto commands 
         */

        if ( !IS_NPC( ch )
             && ( corpse = get_obj_list( ch, "corpse", ch->in_room->contents ) ) != NULL
             && corpse->item_type == ITEM_CORPSE_NPC && can_see_obj( ch, corpse ) )
        {
            OBJ_DATA               *coins;

            corpse = get_obj_list( ch, "corpse", ch->in_room->contents );

            if ( IS_SET( ch->act, PLR_AUTOLOOT ) && corpse && corpse->contains )
            {
                /*
                 * exists and not empty 
                 */
                do_function( ch, &do_get, "all corpse" );
            }

            if ( IS_SET( ch->act, PLR_AUTOGOLD ) && corpse && corpse->contains
                 && !IS_SET( ch->act, PLR_AUTOLOOT ) )
            {
                /*
                 * exists and not empty 
                 */
                if ( ( coins = get_obj_list( ch, "gcash", corpse->contains ) ) != NULL )
                {
                    do_function( ch, &do_get, "all.gcash corpse" );
                }
            }

            if ( IS_SET( ch->act, PLR_AUTOSAC ) )
            {
                if ( IS_SET( ch->act, PLR_AUTOLOOT ) && corpse && corpse->contains )
                {
                    return true;                       /* leave if corpse has treasure */
                }
                else
                {
                    do_function( ch, &do_sacrifice, "corpse" );
                }
            }
        }

        return true;
    }

    if ( victim == ch )
        return true;

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

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

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

    tail_chain(  );
    return true;
}

bool is_safe( CHAR_DATA *ch, CHAR_DATA *victim )
{
    if ( victim->in_room == NULL || ch->in_room == NULL )
        return true;

    if ( victim->fighting == ch || victim == ch )
        return false;

    if ( IS_IMMORTAL( ch ) && ch->level > LEVEL_IMMORTAL )
        return false;

    /*
     * killing mobiles 
     */
    if ( IS_NPC( victim ) )
    {

        /*
         * safe room? 
         */
        if ( IS_SET( victim->in_room->room_flags, ROOM_SAFE ) )
        {
            ch_printf( ch, "Not in this room.\r\n" );
            return true;
        }

        if ( victim->pIndexData->pShop != NULL )
        {
            ch_printf( ch, "The shopkeeper wouldn't like that.\r\n" );
            return true;
        }

        /*
         * no killing healers, trainers, etc 
         */
        if ( IS_SET( victim->act, ACT_TRAIN )
             || IS_SET( victim->act, ACT_PRACTICE )
             || IS_SET( victim->act, ACT_IS_HEALER )
             || IS_SET( victim->act, ACT_IS_CHANGER ) )
        {
            ch_printf( ch, "I don't think Mota would approve.\r\n" );
            return true;
        }

        if ( !IS_NPC( ch ) )
        {
            /*
             * no pets 
             */
            if ( IS_SET( victim->act, ACT_PET ) )
            {
                act( "But $N looks so cute and cuddly...", ch, NULL, victim, TO_CHAR );
                return true;
            }

            /*
             * no charmed creatures unless owner 
             */
            if ( IS_AFFECTED( victim, AFF_CHARM ) && ch != victim->master )
            {
                ch_printf( ch, "You don't own that monster.\r\n" );
                return true;
            }
        }
    }
    /*
     * killing players 
     */
    else
    {
        /*
         * NPC doing the killing 
         */
        if ( IS_NPC( ch ) )
        {
            /*
             * safe room check 
             */
            if ( IS_SET( victim->in_room->room_flags, ROOM_SAFE ) )
            {
                ch_printf( ch, "Not in this room.\r\n" );
                return true;
            }

            /*
             * charmed mobs and pets cannot attack players while owned 
             */
            if ( IS_AFFECTED( ch, AFF_CHARM ) && ch->master != NULL
                 && ch->master->fighting != victim )
            {
                ch_printf( ch, "Players are your friends!\r\n" );
                return true;
            }
        }
        /*
         * player doing the killing 
         */
        else
        {
            if ( !is_clan( ch ) )
            {
                ch_printf( ch, "Join a clan if you want to kill players.\r\n" );
                return true;
            }

            if ( IS_SET( victim->act, PLR_KILLER ) || IS_SET( victim->act, PLR_THIEF ) )
                return false;

            if ( !is_clan( victim ) )
            {
                ch_printf( ch, "They aren't in a clan, leave them alone.\r\n" );
                return true;
            }

            if ( ch->level > victim->level + 8 )
            {
                ch_printf( ch, "Pick on someone your own size.\r\n" );
                return true;
            }
        }
    }
    return false;
}

bool is_safe_spell( CHAR_DATA *ch, CHAR_DATA *victim, bool area )
{
    if ( victim->in_room == NULL || ch->in_room == NULL )
        return true;

    if ( victim == ch && area )
        return true;

    if ( victim->fighting == ch || victim == ch )
        return false;

    if ( IS_IMMORTAL( ch ) && ch->level > LEVEL_IMMORTAL && !area )
        return false;

    /*
     * killing mobiles 
     */
    if ( IS_NPC( victim ) )
    {
        /*
         * safe room? 
         */
        if ( IS_SET( victim->in_room->room_flags, ROOM_SAFE ) )
            return true;

        if ( victim->pIndexData->pShop != NULL )
            return true;

        /*
         * no killing healers, trainers, etc 
         */
        if ( IS_SET( victim->act, ACT_TRAIN )
             || IS_SET( victim->act, ACT_PRACTICE )
             || IS_SET( victim->act, ACT_IS_HEALER )
             || IS_SET( victim->act, ACT_IS_CHANGER ) )
            return true;

        if ( !IS_NPC( ch ) )
        {
            /*
             * no pets 
             */
            if ( IS_SET( victim->act, ACT_PET ) )
                return true;

            /*
             * no charmed creatures unless owner 
             */
            if ( IS_AFFECTED( victim, AFF_CHARM ) && ( area || ch != victim->master ) )
                return true;

            /*
             * legal kill? -- cannot hit mob fighting non-group member 
             */
            if ( victim->fighting != NULL && !is_same_group( ch, victim->fighting ) )
                return true;
        }
        else
        {
            /*
             * area effect spells do not hit other mobs 
             */
            if ( area && !is_same_group( victim, ch->fighting ) )
                return true;
        }
    }
    /*
     * killing players 
     */
    else
    {
        if ( area && IS_IMMORTAL( victim ) && victim->level > LEVEL_IMMORTAL )
            return true;

        /*
         * NPC doing the killing 
         */
        if ( IS_NPC( ch ) )
        {
            /*
             * charmed mobs and pets cannot attack players while owned 
             */
            if ( IS_AFFECTED( ch, AFF_CHARM ) && ch->master != NULL
                 && ch->master->fighting != victim )
                return true;

            /*
             * safe room? 
             */
            if ( IS_SET( victim->in_room->room_flags, ROOM_SAFE ) )
                return true;

            /*
             * legal kill? -- mobs only hit players grouped with opponent
             */
            if ( ch->fighting != NULL && !is_same_group( ch->fighting, victim ) )
                return true;
        }

        /*
         * player doing the killing 
         */
        else
        {
            if ( !is_clan( ch ) )
                return true;

            if ( IS_SET( victim->act, PLR_KILLER ) || IS_SET( victim->act, PLR_THIEF ) )
                return false;

            if ( !is_clan( victim ) )
                return true;

            if ( ch->level > victim->level + 8 )
                return true;
        }

    }
    return false;
}

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

    /*
     * NPC's are fair game.
     * So are killers and thieves.
     */
    if ( IS_NPC( victim )
         || IS_SET( victim->act, PLR_KILLER ) || IS_SET( victim->act, PLR_THIEF ) )
        return;

    /*
     * Charm-o-rama.
     */
    if ( IS_SET( ch->affected_by, AFF_CHARM ) )
    {
        if ( ch->master == NULL )
        {
            log_balance( ch, "AFF_CHARM set on %s, but no master is set?", NAME( ch ) );
            affect_strip( ch, skill_lookup( "charm person" ) );
            REMOVE_BIT( ch->affected_by, AFF_CHARM );
            return;
        }
/*
        ch_printf( ch->master, "*** You are now a KILLER!! ***\r\n" );
          SET_BIT(ch->master->act, PLR_KILLER);
*/

        stop_follower( ch );
        return;
    }

    /*
     * NPC's are cool of course (as long as not charmed).
     * Hitting yourself is cool too (bleeding).
     * So is being immortal (Alander's idea).
     * And current killers stay as they are.
     */
    if ( IS_NPC( ch )
         || ch == victim
         || ch->level >= LEVEL_IMMORTAL
         || !is_clan( ch ) || IS_SET( ch->act, PLR_KILLER ) || ch->fighting == victim )
        return;

    ch_printf( ch, "*** You are now a KILLER!! ***\r\n" );
    SET_BIT( ch->act, PLR_KILLER );
    wiz_printf( ch, NULL, WIZ_FLAGS, 0, 0,
                "$N is attempting to murder %s", NAME( victim ) );
    save_char_obj( ch );
    return;
}

/*
 * Check for parry.
 */
bool check_parry( CHAR_DATA *ch, CHAR_DATA *victim )
{
    int                     chance = 0;
    int                     sn = -1;

    if ( !IS_AWAKE( victim ) )
        return false;

    if ( ( sn = skill_lookup( "parry" ) ) == -1 )
    {
        log_error( "Can't find the \"%s\" skill in %s?", "parry", __FUNCTION__ );
        return false;
    }

    chance = get_skill( victim, sn ) / 2;

    if ( get_eq_char( victim, WEAR_WIELD ) == NULL )
    {
        if ( IS_NPC( victim ) )
            chance /= 2;
        else
            return false;
    }

    if ( !can_see( ch, victim ) )
        chance /= 2;

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

    act( "You parry $n's attack.", ch, NULL, victim, TO_VICT );
    act( "$N parries your attack.", ch, NULL, victim, TO_CHAR );
    check_improve( victim, sn, true, 6 );
    return true;
}

/*
 * Check for shield block.
 */
bool check_shield_block( CHAR_DATA *ch, CHAR_DATA *victim )
{
    int                     chance = 0;
    int                     sn = -1;

    if ( !IS_AWAKE( victim ) )
        return false;

    if ( ( sn = skill_lookup( "shield block" ) ) == -1 )
    {
        log_error( "Can't find the \"%s\" skill in %s?", "shield block", __FUNCTION__ );
        return false;
    }

    chance = get_skill( victim, sn ) / 5 + 3;

    if ( get_eq_char( victim, WEAR_SHIELD ) == NULL )
        return false;

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

    act( "You block $n's attack with your shield.", ch, NULL, victim, TO_VICT );
    act( "$N blocks your attack with a shield.", ch, NULL, victim, TO_CHAR );
    check_improve( victim, sn, true, 6 );
    return true;
}

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

    if ( !IS_AWAKE( victim ) )
        return false;

    if ( ( sn = skill_lookup( "dodge" ) ) == -1 )
    {
        log_error( "Can't find the \"%s\" skill in %s?", "dodge", __FUNCTION__ );
        return false;
    }

    chance = get_skill( victim, sn ) / 2;

    if ( !can_see( victim, ch ) )
        chance /= 2;

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

    act( "You dodge $n's attack.", ch, NULL, victim, TO_VICT );
    act( "$N dodges your attack.", ch, NULL, victim, TO_CHAR );
    check_improve( victim, sn, true, 6 );
    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 < 1 )
    {
        victim->position = POS_DEAD;
        return;
    }

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

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

    return;
}

/*
 * Start fights.
 */
void set_fighting( CHAR_DATA *ch, CHAR_DATA *victim )
{
    if ( ch->fighting != NULL )
    {
        log_error( "%s already fighting in call to set_fighting.", NAME( ch ) );
        return;
    }

    if ( IS_AFFECTED( ch, AFF_SLEEP ) )
        affect_strip( ch, skill_lookup( "sleep" ) );

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

    return;
}

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

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

    return;
}

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

    if ( IS_NPC( ch ) )
    {
        name = ch->short_descr;
        corpse = create_object( get_obj_index( OBJ_VNUM_CORPSE_NPC ), 0 );
        corpse->timer = number_range( 3, 6 );
        if ( ch->gold > 0 || ch->silver > 0 )
        {
            obj_to_obj( create_money( ch->gold, ch->silver ), corpse );
            ch->gold = 0;
            ch->silver = 0;
        }
        corpse->cost = 0;
    }
    else
    {
        name = ch->name;
        corpse = create_object( get_obj_index( OBJ_VNUM_CORPSE_PC ), 0 );
        corpse->timer = number_range( 25, 40 );
        REMOVE_BIT( ch->act, PLR_CANLOOT );
        if ( !is_clan( ch ) )
            corpse->owner = str_dup( ch->name );
        else
        {
            corpse->owner = NULL;
            if ( ch->gold > 0 || ch->silver > 0 )
            {
                obj_to_obj( create_money( ch->gold, ch->silver ), corpse );
                ch->gold = 0;
                ch->silver = 0;
            }
        }
        corpse->cost = 0;
    }

    corpse->level = ch->level;

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

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

    for ( obj = ch->carrying; obj != NULL; obj = obj_next )
    {
        bool                    floating = false;

        obj_next = obj->next_content;
        if ( obj->wear_loc == WEAR_FLOAT )
            floating = true;
        obj_from_char( obj );
        if ( obj->item_type == ITEM_POTION )
            obj->timer = number_range( 500, 1000 );
        if ( obj->item_type == ITEM_SCROLL )
            obj->timer = number_range( 1000, 2500 );
        if ( IS_SET( obj->extra_flags, ITEM_ROT_DEATH ) && !floating )
        {
            obj->timer = number_range( 5, 10 );
            REMOVE_BIT( obj->extra_flags, ITEM_ROT_DEATH );
        }
        REMOVE_BIT( obj->extra_flags, ITEM_VIS_DEATH );

        if ( IS_SET( obj->extra_flags, ITEM_INVENTORY ) )
            extract_obj( obj );
        else if ( floating )
        {
            if ( IS_OBJ_STAT( obj, ITEM_ROT_DEATH ) )  /* get rid of it! */
            {
                if ( obj->contains != NULL )
                {
                    OBJ_DATA               *in = NULL;
                    OBJ_DATA               *in_next = NULL;

                    act( "$p evaporates,scattering its contents.",
                         ch, obj, NULL, TO_ROOM );
                    for ( in = obj->contains; in != NULL; in = in_next )
                    {
                        in_next = in->next_content;
                        obj_from_obj( in );
                        obj_to_room( in, ch->in_room );
                    }
                }
                else
                    act( "$p evaporates.", ch, obj, NULL, TO_ROOM );
                extract_obj( obj );
            }
            else
            {
                act( "$p falls to the floor.", ch, obj, NULL, TO_ROOM );
                obj_to_room( obj, ch->in_room );
            }
        }
        else
            obj_to_obj( obj, corpse );
    }

    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 = NULL;
    const char             *msg = NULL;
    int                     door = 0;
    int                     vnum = 0;

    vnum = 0;
    msg = "You hear $n's death cry.";

    switch ( number_bits( 4 ) )
    {
        case 0:
            msg = "$n hits the ground ... DEAD.";
            break;
        case 1:
            if ( ch->material == 0 )
            {
                msg = "$n splatters blood on your armor.";
                break;
            }
        case 2:
            if ( IS_SET( ch->parts, PART_GUTS ) )
            {
                msg = "$n spills $s guts all over the floor.";
                vnum = OBJ_VNUM_GUTS;
            }
            break;
        case 3:
            if ( IS_SET( ch->parts, PART_HEAD ) )
            {
                msg = "$n's severed head plops on the ground.";
                vnum = OBJ_VNUM_SEVERED_HEAD;
            }
            break;
        case 4:
            if ( IS_SET( ch->parts, PART_HEART ) )
            {
                msg = "$n's heart is torn from $s chest.";
                vnum = OBJ_VNUM_TORN_HEART;
            }
            break;
        case 5:
            if ( IS_SET( ch->parts, PART_ARMS ) )
            {
                msg = "$n's arm is sliced from $s dead body.";
                vnum = OBJ_VNUM_SLICED_ARM;
            }
            break;
        case 6:
            if ( IS_SET( ch->parts, PART_LEGS ) )
            {
                msg = "$n's leg is sliced from $s dead body.";
                vnum = OBJ_VNUM_SLICED_LEG;
            }
            break;
        case 7:
            if ( IS_SET( ch->parts, PART_BRAINS ) )
            {
                msg = "$n's head is shattered, and $s brains splash all over you.";
                vnum = OBJ_VNUM_BRAINS;
            }
    }

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

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

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

        if ( obj->item_type == ITEM_FOOD )
        {
            if ( IS_SET( ch->form, FORM_POISON ) )
                obj->value[3] = 1;
            else if ( !IS_SET( ch->form, FORM_EDIBLE ) )
                obj->item_type = ITEM_TRASH;
        }

        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 < MAX_EXIT; door++ )
    {
        EXIT_DATA              *pexit;

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

    return;
}

void raw_kill( CHAR_DATA *victim )
{
    int                     i = 0;

    stop_fighting( victim, true );
    death_cry( victim );
    make_corpse( victim );

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

    extract_char( victim, false );
    while ( victim->affected )
        affect_remove( victim, victim->affected );
    victim->affected_by = race_table[victim->race].aff;
    for ( i = 0; i < 4; i++ )
        victim->armor[i] = 100;
    victim->position = POS_RESTING;
    victim->hit = UMAX( 1, victim->hit );
    victim->mana = UMAX( 1, victim->mana );
    victim->move = UMAX( 1, victim->move );
/*  save_char_obj( victim ); we're stable enough to not need this :) */
    return;
}

void group_gain( CHAR_DATA *ch, CHAR_DATA *victim )
{
    CHAR_DATA              *gch = NULL;
    CHAR_DATA              *lch = NULL;
    int                     xp = 0;
    int                     members = 0;
    int                     group_levels = 0;
    int                     highest_level = 0;

    /*
     * 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 ( victim == ch )
        return;

    for ( gch = ch->in_room->people; gch != NULL; gch = gch->next_in_room )
    {
        if ( is_same_group( gch, ch ) )
        {
            members++;
            group_levels += IS_NPC( gch ) ? gch->level / 2 : gch->level;
        }
    }

    if ( members == 0 )
    {
        log_error( "Group with %d members", members );
        members = 1;
        group_levels = ch->level;
    }

    for ( lch = ch->in_room->people; lch != NULL; lch = lch->next_in_room )
    {
        if ( !is_same_group( lch, ch ) || IS_NPC( lch ) )
            continue;

        if ( lch->level > highest_level )
            highest_level = lch->level;
    }

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

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

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

/*        Taken out, add it back if you want it
        if ( gch->level - highest_level >= 5 )
        {
            ch_printf( gch, "You are too high for this group.\r\n" );
            continue;
        }

        if ( gch->level - highest_level <= -5 )
        {
            ch_printf( gch, "You are too low for this group.\r\n" );
            continue;
        }
*/

        xp = xp_compute( gch, victim, group_levels );
        ch_printf( gch, "You receive %d experience points.\r\n", xp );
        gain_exp( gch, xp );

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

            if ( ( IS_OBJ_STAT( obj, ITEM_ANTI_EVIL ) && IS_EVIL( gch ) )
                 || ( IS_OBJ_STAT( obj, ITEM_ANTI_GOOD ) && IS_GOOD( gch ) )
                 || ( IS_OBJ_STAT( obj, ITEM_ANTI_NEUTRAL ) && IS_NEUTRAL( gch ) ) )
            {
                act( "You are zapped by $p.", gch, obj, NULL, TO_CHAR );
                act( "$n is zapped by $p.", gch, obj, NULL, TO_ROOM );
                obj_from_char( obj );
                if ( IS_OBJ_STAT( obj, ITEM_NODROP ) )
                {
                    obj_to_char( obj, gch );
                }
                else
                {
                    obj_to_room( obj, gch->in_room );
                    if ( IS_OBJ_STAT( obj, ITEM_MELT_DROP ) )
                    {
                        act( "$p dissolves into smoke.", gch, obj, NULL, TO_ROOM );
                        act( "$p dissolves into smoke.", gch, obj, NULL, TO_CHAR );
                        extract_obj( obj );
                    }
                }
            }
        }
    }

    return;
}

/*
 * Compute xp for a kill.
 * Also adjust alignment of killer.
 * Edit this function to change xp computations.
 */
int xp_compute( CHAR_DATA *gch, CHAR_DATA *victim, int total_levels )
{
    int                     xp = 0;
    int                     base_exp = 0;
    int                     align = 0;
    int                     level_range = 0;
    int                     change = 0;
    int                     time_per_level = 0;

    level_range = victim->level - gch->level;

    /*
     * compute the base exp 
     */
    switch ( level_range )
    {
        default:
            base_exp = 0;
            break;
        case -9:
            base_exp = 1;
            break;
        case -8:
            base_exp = 2;
            break;
        case -7:
            base_exp = 5;
            break;
        case -6:
            base_exp = 9;
            break;
        case -5:
            base_exp = 11;
            break;
        case -4:
            base_exp = 22;
            break;
        case -3:
            base_exp = 33;
            break;
        case -2:
            base_exp = 50;
            break;
        case -1:
            base_exp = 66;
            break;
        case 0:
            base_exp = 83;
            break;
        case 1:
            base_exp = 99;
            break;
        case 2:
            base_exp = 121;
            break;
        case 3:
            base_exp = 143;
            break;
        case 4:
            base_exp = 165;
            break;
    }

    if ( level_range > 4 )
        base_exp = 160 + 20 * ( level_range - 4 );

    /*
     * do alignment computations 
     */

    align = victim->alignment - gch->alignment;

    if ( IS_SET( victim->act, ACT_NOALIGN ) )
    {
        /*
         * no change 
         */
    }

    else if ( align > 500 )                            /* monster is more good than
                                                        * slayer */
    {
        change = ( align - 500 ) * base_exp / 500 * gch->level / total_levels;
        change = UMAX( 1, change );
        gch->alignment = UMAX( -1000, gch->alignment - change );
    }

    else if ( align < -500 )                           /* monster is more evil than
                                                        * slayer */
    {
        change = ( -1 * align - 500 ) * base_exp / 500 * gch->level / total_levels;
        change = UMAX( 1, change );
        gch->alignment = UMIN( 1000, gch->alignment + change );
    }

    else                                               /* improve this someday */
    {
        change = gch->alignment * base_exp / 500 * gch->level / total_levels;
        gch->alignment -= change;
    }

    /*
     * calculate exp multiplier 
     */
    if ( IS_SET( victim->act, ACT_NOALIGN ) )
        xp = base_exp;

    else if ( gch->alignment > 500 )                   /* for goodie two shoes */
    {
        if ( victim->alignment < -750 )
            xp = ( base_exp * 4 ) / 3;

        else if ( victim->alignment < -500 )
            xp = ( base_exp * 5 ) / 4;

        else if ( victim->alignment > 750 )
            xp = base_exp / 4;

        else if ( victim->alignment > 500 )
            xp = base_exp / 2;

        else if ( victim->alignment > 250 )
            xp = ( base_exp * 3 ) / 4;

        else
            xp = base_exp;
    }

    else if ( gch->alignment < -500 )                  /* for baddies */
    {
        if ( victim->alignment > 750 )
            xp = ( base_exp * 5 ) / 4;

        else if ( victim->alignment > 500 )
            xp = ( base_exp * 11 ) / 10;

        else if ( victim->alignment < -750 )
            xp = base_exp / 2;

        else if ( victim->alignment < -500 )
            xp = ( base_exp * 3 ) / 4;

        else if ( victim->alignment < -250 )
            xp = ( base_exp * 9 ) / 10;

        else
            xp = base_exp;
    }

    else if ( gch->alignment > 200 )                   /* a little good */
    {

        if ( victim->alignment < -500 )
            xp = ( base_exp * 6 ) / 5;

        else if ( victim->alignment > 750 )
            xp = base_exp / 2;

        else if ( victim->alignment > 0 )
            xp = ( base_exp * 3 ) / 4;

        else
            xp = base_exp;
    }

    else if ( gch->alignment < -200 )                  /* a little bad */
    {
        if ( victim->alignment > 500 )
            xp = ( base_exp * 6 ) / 5;

        else if ( victim->alignment < -750 )
            xp = base_exp / 2;

        else if ( victim->alignment < 0 )
            xp = ( base_exp * 3 ) / 4;

        else
            xp = base_exp;
    }

    else                                               /* neutral */
    {

        if ( victim->alignment > 500 || victim->alignment < -500 )
            xp = ( base_exp * 4 ) / 3;

        else if ( victim->alignment < 200 && victim->alignment > -200 )
            xp = base_exp / 2;

        else
            xp = base_exp;
    }

    /*
     * more exp at the low levels 
     */
    if ( gch->level < 6 )
        xp = 10 * xp / ( gch->level + 4 );

    /*
     * less at high 
     */
    if ( gch->level > 35 )
        xp = 15 * xp / ( gch->level - 25 );

    /*
     * reduce for playing time 
     */

    {
        /*
         * compute quarter-hours per level 
         */
        time_per_level = 4 *
            ( gch->played + ( int ) ( current_time - gch->logon ) ) / 3600 / gch->level;

        time_per_level = URANGE( 2, time_per_level, 12 );
        if ( gch->level < 15 )                         /* make it a curve */
            time_per_level = UMAX( time_per_level, ( 15 - gch->level ) );
        xp = xp * time_per_level / 12;
    }

    /*
     * randomize the rewards 
     */
    xp = number_range( xp * 3 / 4, xp * 5 / 4 );

    /*
     * adjust for grouping 
     */
    xp = xp * gch->level / ( UMAX( 1, total_levels - 1 ) );

    return xp;
}

void dam_message( CHAR_DATA *ch, CHAR_DATA *victim, int dam, int dt, bool immune )
{
    char                    buf1[256] = "\0\0\0\0\0\0\0";
    char                    buf2[256] = "\0\0\0\0\0\0\0";
    char                    buf3[256] = "\0\0\0\0\0\0\0";
    const char             *vs = NULL;
    const char             *vp = NULL;
    const char             *attack = NULL;
    char                    punct = '\0';

    if ( ch == NULL || victim == NULL )
        return;

    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 = "DISMEMBER";
        vp = "DISMEMBERS";
    }
    else if ( dam <= 52 )
    {
        vs = "MASSACRE";
        vp = "MASSACRES";
    }
    else if ( dam <= 56 )
    {
        vs = "MANGLE";
        vp = "MANGLES";
    }
    else if ( dam <= 60 )
    {
        vs = "*** DEMOLISH ***";
        vp = "*** DEMOLISHES ***";
    }
    else if ( dam <= 75 )
    {
        vs = "*** DEVASTATE ***";
        vp = "*** DEVASTATES ***";
    }
    else if ( dam <= 100 )
    {
        vs = "=== OBLITERATE ===";
        vp = "=== OBLITERATES ===";
    }
    else if ( dam <= 125 )
    {
        vs = ">>> ANNIHILATE <<<";
        vp = ">>> ANNIHILATES <<<";
    }
    else if ( dam <= 150 )
    {
        vs = "<<< ERADICATE >>>";
        vp = "<<< ERADICATES >>>";
    }
    else
    {
        vs = "do UNSPEAKABLE things to";
        vp = "does UNSPEAKABLE things to";
    }

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

    if ( dt == TYPE_HIT )
    {
        if ( ch == victim )
        {
            sprintf( buf1, "$n %s $melf%c", vp, punct );
            sprintf( buf2, "You %s yourself%c", vs, punct );
        }
        else
        {
            sprintf( buf1, "$n %s $N%c", vp, punct );
            sprintf( buf2, "You %s $N%c", vs, punct );
            sprintf( buf3, "$n %s you%c", vp, punct );
        }
    }
    else
    {
        if ( dt >= 0 && dt < MAX_SKILL )
            attack = skill_table[dt].noun_damage;
        else if ( dt >= TYPE_HIT && dt < TYPE_HIT + MAX_DAMAGE_MESSAGE )
            attack = attack_table[dt - TYPE_HIT].noun;
        else
        {
            log_error( "Bad damage type %d", dt );
            dt = TYPE_HIT;
            attack = attack_table[0].name;
        }

        if ( immune )
        {
            if ( ch == victim )
            {
                sprintf( buf1, "$n is unaffected by $s own %s.", attack );
                sprintf( buf2, "Luckily, you are immune to that." );
            }
            else
            {
                sprintf( buf1, "$N is unaffected by $n's %s!", attack );
                sprintf( buf2, "$N is unaffected by your %s!", attack );
                sprintf( buf3, "$n's %s is powerless against you.", attack );
            }
        }
        else
        {
            if ( ch == victim )
            {
                sprintf( buf1, "$n's %s %s $m%c", attack, vp, punct );
                sprintf( buf2, "Your %s %s you%c", attack, vp, punct );
            }
            else
            {
                sprintf( buf1, "$n's %s %s $N%c", attack, vp, punct );
                sprintf( buf2, "Your %s %s $N%c", attack, vp, punct );
                sprintf( buf3, "$n's %s %s you%c", attack, vp, punct );
            }
        }
    }

    if ( ch == victim )
    {
        act( buf1, ch, NULL, NULL, TO_ROOM );
        act( buf2, ch, NULL, NULL, TO_CHAR );
    }
    else
    {
        act( buf1, ch, NULL, victim, TO_NOTVICT );
        act( buf2, ch, NULL, victim, TO_CHAR );
        act( buf3, ch, NULL, victim, TO_VICT );
    }

    return;
}

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

    if ( ( obj = get_eq_char( victim, WEAR_WIELD ) ) == NULL )
        return;

    if ( IS_OBJ_STAT( obj, ITEM_NOREMOVE ) )
    {
        act( "$S weapon won't budge!", ch, NULL, victim, TO_CHAR );
        act( "$n tries to disarm you, but your weapon won't budge!",
             ch, NULL, victim, TO_VICT );
        act( "$n tries to disarm $N, but fails.", ch, NULL, victim, TO_NOTVICT );
        return;
    }

    act( "$n DISARMS you and sends your weapon flying!", ch, NULL, victim, TO_VICT );
    act( "You disarm $N!", ch, NULL, victim, TO_CHAR );
    act( "$n disarms $N!", ch, NULL, victim, TO_NOTVICT );

    obj_from_char( obj );
    if ( IS_OBJ_STAT( obj, ITEM_NODROP ) || IS_OBJ_STAT( obj, ITEM_INVENTORY ) )
        obj_to_char( obj, victim );
    else
    {
        obj_to_room( obj, victim->in_room );
        if ( IS_NPC( victim ) && victim->wait == 0 && can_see_obj( victim, obj ) )
            get_obj( victim, obj, NULL );
    }

    return;
}

void do_berserk( CHAR_DATA *ch, const char *argument )
{
    int                     chance = 0;
    int                     hp_percent = 0;
    int                     sn = -1;

    if ( ( sn = skill_lookup( "berserk" ) ) == -1 )
    {
        log_error( "Can't find the \"%s\" skill in %s?", "berserk", __FUNCTION__ );
        return;
    }
    if ( ( chance = get_skill( ch, sn ) ) == 0
         || ( IS_NPC( ch ) && !IS_SET( ch->off_flags, OFF_BERSERK ) )
         || ( !IS_NPC( ch ) && ch->level < skill_table[sn].skill_level[ch->iclass] ) )
    {
        ch_printf( ch, "You turn red in the face, but nothing happens.\r\n" );
        return;
    }

    if ( IS_AFFECTED( ch, AFF_BERSERK ) || is_affected( ch, sn )
         || is_affected( ch, skill_lookup( "frenzy" ) ) )
    {
        ch_printf( ch, "You get a little madder.\r\n" );
        return;
    }

    if ( IS_AFFECTED( ch, AFF_CALM ) )
    {
        ch_printf( ch, "You're feeling to mellow to berserk.\r\n" );
        return;
    }

    if ( ch->mana < 50 )
    {
        ch_printf( ch, "You can't get up enough energy.\r\n" );
        return;
    }

    /*
     * modifiers 
     */

    /*
     * fighting 
     */
    if ( ch->position == POS_FIGHTING )
        chance += 10;

    /*
     * damage -- below 50% of hp helps, above hurts 
     */
    hp_percent = 100 * ch->hit / ch->max_hit;
    chance += 25 - hp_percent / 2;

    if ( number_percent(  ) < chance )
    {
        AFFECT_DATA             af;

        WAIT_STATE( ch, PULSE_VIOLENCE );
        ch->mana -= 50;
        ch->move /= 2;

        /*
         * heal a little damage 
         */
        ch->hit += ch->level * 2;
        ch->hit = UMIN( ch->hit, ch->max_hit );

        ch_printf( ch, "Your pulse races as you are consumed by rage!\r\n" );
        act( "$n gets a wild look in $s eyes.", ch, NULL, NULL, TO_ROOM );
        check_improve( ch, sn, true, 2 );

        af.where = TO_AFFECTS;
        af.type = sn;
        af.level = ch->level;
        af.duration = number_fuzzy( ch->level / 8 );
        af.modifier = UMAX( 1, ch->level / 5 );
        af.bitvector = AFF_BERSERK;

        af.location = APPLY_HITROLL;
        affect_to_char( ch, &af );

        af.location = APPLY_DAMROLL;
        affect_to_char( ch, &af );

        af.modifier = UMAX( 10, 10 * ( ch->level / 5 ) );
        af.location = APPLY_AC;
        affect_to_char( ch, &af );
    }

    else
    {
        WAIT_STATE( ch, 3 * PULSE_VIOLENCE );
        ch->mana -= 25;
        ch->move /= 2;

        ch_printf( ch, "Your pulse speeds up, but nothing happens.\r\n" );
        check_improve( ch, sn, false, 2 );
    }
}

void do_bash( CHAR_DATA *ch, const char *argument )
{
    char                    arg[MAX_INPUT_LENGTH] = "\0\0\0\0\0\0\0";
    CHAR_DATA              *victim = NULL;
    int                     chance = 0;
    int                     sn = -1;

    one_argument( argument, arg );

    if ( ( sn = skill_lookup( "bash" ) ) == -1 )
    {
        log_error( "Can't find the \"%s\" skill in %s?", "bash", __FUNCTION__ );
        return;
    }
    if ( ( chance = get_skill( ch, sn ) ) == 0
         || ( IS_NPC( ch ) && !IS_SET( ch->off_flags, OFF_BASH ) )
         || ( !IS_NPC( ch ) && ch->level < skill_table[sn].skill_level[ch->iclass] ) )
    {
        ch_printf( ch, "Bashing? What's that?\r\n" );
        return;
    }

    if ( arg[0] == '\0' )
    {
        victim = ch->fighting;
        if ( victim == NULL )
        {
            ch_printf( ch, "But you aren't fighting anyone!\r\n" );
            return;
        }
    }
    else if ( ( victim = get_char_room( ch, arg ) ) == NULL )
    {
        ch_printf( ch, "They aren't here.\r\n" );
        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 )
    {
        ch_printf( ch, "You try to bash your brains out, but fail.\r\n" );
        return;
    }

    if ( is_safe( ch, victim ) )
        return;

    if ( IS_NPC( victim ) &&
         victim->fighting != NULL && !is_same_group( ch, victim->fighting ) )
    {
        ch_printf( ch, "Kill stealing is not permitted.\r\n" );
        return;
    }

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

    /*
     * modifiers 
     */

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

    if ( ch->size < victim->size )
        chance += ( ch->size - victim->size ) * 15;
    else
        chance += ( ch->size - victim->size ) * 10;

    /*
     * stats 
     */
    chance += get_curr_stat( ch, STAT_STR );
    chance -= ( get_curr_stat( victim, STAT_DEX ) * 4 ) / 3;
    chance -= GET_AC( victim, AC_BASH ) / 25;
    /*
     * speed 
     */
    if ( IS_SET( ch->off_flags, OFF_FAST ) || IS_AFFECTED( ch, AFF_HASTE ) )
        chance += 10;
    if ( IS_SET( victim->off_flags, OFF_FAST ) || IS_AFFECTED( victim, AFF_HASTE ) )
        chance -= 30;

    /*
     * level 
     */
    chance += ( ch->level - victim->level );

    if ( !IS_NPC( victim ) && chance < get_skill( victim, skill_lookup( "dodge" ) ) )
    {
/*
 * act("$n tries to bash you, but you dodge* it.",ch,NULL,victim,TO_VICT);
 * act("$N dodges your bash, you fall flat on your face.",ch,NULL,victim,TO_CHAR);
 * WAIT_STATE(ch,skill_table[sn].beats);
 * return;
 */
        chance -= 3 * ( get_skill( victim, skill_lookup( "dodge" ) ) - chance );
    }

    /*
     * now the attack 
     */
    if ( number_percent(  ) < chance )
    {

        act( "$n sends you sprawling with a powerful bash!", ch, NULL, victim, TO_VICT );
        act( "You slam into $N, and send $M flying!", ch, NULL, victim, TO_CHAR );
        act( "$n sends $N sprawling with a powerful bash.",
             ch, NULL, victim, TO_NOTVICT );
        check_improve( ch, sn, true, 1 );

        DAZE_STATE( victim, 3 * PULSE_VIOLENCE );
        WAIT_STATE( ch, skill_table[sn].beats );
        victim->position = POS_RESTING;
        damage( ch, victim, number_range( 2, 2 + 2 * ch->size + chance / 20 ), sn,
                DAM_BASH, false );

    }
    else
    {
        damage( ch, victim, 0, sn, DAM_BASH, false );
        act( "You fall flat on your face!", ch, NULL, victim, TO_CHAR );
        act( "$n falls flat on $s face.", ch, NULL, victim, TO_NOTVICT );
        act( "You evade $n's bash, causing $m to fall flat on $s face.",
             ch, NULL, victim, TO_VICT );
        check_improve( ch, sn, false, 1 );
        ch->position = POS_RESTING;
        WAIT_STATE( ch, skill_table[sn].beats * 3 / 2 );
    }
    check_killer( ch, victim );
}

void do_dirt( CHAR_DATA *ch, const char *argument )
{
    char                    arg[MAX_INPUT_LENGTH] = "\0\0\0\0\0\0\0";
    CHAR_DATA              *victim = NULL;
    int                     chance = 0;
    int                     sn = -1;

    one_argument( argument, arg );

    if ( ( sn = skill_lookup( "dirt" ) ) == -1 )
    {
        log_error( "Can't find the \"%s\" skill in %s?", "dirt", __FUNCTION__ );
        return;
    }
    if ( ( chance = get_skill( ch, sn ) ) == 0
         || ( IS_NPC( ch ) && !IS_SET( ch->off_flags, OFF_KICK_DIRT ) )
         || ( !IS_NPC( ch ) && ch->level < skill_table[sn].skill_level[ch->iclass] ) )
    {
        ch_printf( ch, "You get your feet dirty.\r\n" );
        return;
    }

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

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

    if ( IS_AFFECTED( victim, AFF_BLIND ) )
    {
        act( "$E's already been blinded.", ch, NULL, victim, TO_CHAR );
        return;
    }

    if ( victim == ch )
    {
        ch_printf( ch, "Very funny.\r\n" );
        return;
    }

    if ( is_safe( ch, victim ) )
        return;

    if ( IS_NPC( victim ) &&
         victim->fighting != NULL && !is_same_group( ch, victim->fighting ) )
    {
        ch_printf( ch, "Kill stealing is not permitted.\r\n" );
        return;
    }

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

    /*
     * modifiers 
     */

    /*
     * dexterity 
     */
    chance += get_curr_stat( ch, STAT_DEX );
    chance -= 2 * get_curr_stat( victim, STAT_DEX );

    /*
     * speed 
     */
    if ( IS_SET( ch->off_flags, OFF_FAST ) || IS_AFFECTED( ch, AFF_HASTE ) )
        chance += 10;
    if ( IS_SET( victim->off_flags, OFF_FAST ) || IS_AFFECTED( victim, AFF_HASTE ) )
        chance -= 25;

    /*
     * level 
     */
    chance += ( ch->level - victim->level ) * 2;

    /*
     * sloppy hack to prevent false zeroes 
     */
    if ( chance % 5 == 0 )
        chance += 1;

    /*
     * terrain 
     */

    switch ( ch->in_room->sector_type )
    {
        case ( SECT_INSIDE ):
            chance -= 20;
            break;
        case ( SECT_CITY ):
            chance -= 10;
            break;
        case ( SECT_FIELD ):
            chance += 5;
            break;
        case ( SECT_FOREST ):
            break;
        case ( SECT_HILLS ):
            break;
        case ( SECT_MOUNTAIN ):
            chance -= 10;
            break;
        case ( SECT_WATER_SWIM ):
            chance = 0;
            break;
        case ( SECT_WATER_NOSWIM ):
            chance = 0;
            break;
        case ( SECT_AIR ):
            chance = 0;
            break;
        case ( SECT_DESERT ):
            chance += 10;
            break;
    }

    if ( chance == 0 )
    {
        ch_printf( ch, "There isn't any dirt to kick.\r\n" );
        return;
    }

    /*
     * now the attack 
     */
    if ( number_percent(  ) < chance )
    {
        AFFECT_DATA             af;

        act( "$n is blinded by the dirt in $s eyes!", victim, NULL, NULL, TO_ROOM );
        act( "$n kicks dirt in your eyes!", ch, NULL, victim, TO_VICT );
        damage( ch, victim, number_range( 2, 5 ), sn, DAM_NONE, false );
        ch_printf( victim, "You can't see a thing!\r\n" );
        check_improve( ch, sn, true, 2 );
        WAIT_STATE( ch, skill_table[sn].beats );

        af.where = TO_AFFECTS;
        af.type = sn;
        af.level = ch->level;
        af.duration = 0;
        af.location = APPLY_HITROLL;
        af.modifier = -4;
        af.bitvector = AFF_BLIND;

        affect_to_char( victim, &af );
    }
    else
    {
        damage( ch, victim, 0, sn, DAM_NONE, true );
        check_improve( ch, sn, false, 2 );
        WAIT_STATE( ch, skill_table[sn].beats );
    }
    check_killer( ch, victim );
}

void do_trip( CHAR_DATA *ch, const char *argument )
{
    char                    arg[MAX_INPUT_LENGTH] = "\0\0\0\0\0\0\0";
    CHAR_DATA              *victim = NULL;
    int                     chance = 0;
    int                     sn = -1;

    one_argument( argument, arg );

    if ( ( sn = skill_lookup( "trip" ) ) == -1 )
    {
        log_error( "Can't find the \"%s\" skill in %s?", "trip", __FUNCTION__ );
        return;
    }
    if ( ( chance = get_skill( ch, sn ) ) == 0
         || ( IS_NPC( ch ) && !IS_SET( ch->off_flags, OFF_TRIP ) )
         || ( !IS_NPC( ch ) && ch->level < skill_table[sn].skill_level[ch->iclass] ) )
    {
        ch_printf( ch, "Tripping?  What's that?\r\n" );
        return;
    }

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

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

    if ( is_safe( ch, victim ) )
        return;

    if ( IS_NPC( victim ) &&
         victim->fighting != NULL && !is_same_group( ch, victim->fighting ) )
    {
        ch_printf( ch, "Kill stealing is not permitted.\r\n" );
        return;
    }

    if ( IS_AFFECTED( victim, AFF_FLYING ) )
    {
        act( "$S feet aren't on the ground.", ch, NULL, victim, TO_CHAR );
        return;
    }

    if ( victim->position < POS_FIGHTING )
    {
        act( "$N is already down.", ch, NULL, victim, TO_CHAR );
        return;
    }

    if ( victim == ch )
    {
        ch_printf( ch, "You fall flat on your face!\r\n" );
        WAIT_STATE( ch, 2 * skill_table[sn].beats );
        act( "$n trips over $s own feet!", ch, NULL, NULL, TO_ROOM );
        return;
    }

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

    /*
     * modifiers 
     */

    /*
     * size 
     */
    if ( ch->size < victim->size )
        chance += ( ch->size - victim->size ) * 10;    /* bigger = harder to trip */

    /*
     * dex 
     */
    chance += get_curr_stat( ch, STAT_DEX );
    chance -= get_curr_stat( victim, STAT_DEX ) * 3 / 2;

    /*
     * speed 
     */
    if ( IS_SET( ch->off_flags, OFF_FAST ) || IS_AFFECTED( ch, AFF_HASTE ) )
        chance += 10;
    if ( IS_SET( victim->off_flags, OFF_FAST ) || IS_AFFECTED( victim, AFF_HASTE ) )
        chance -= 20;

    /*
     * level 
     */
    chance += ( ch->level - victim->level ) * 2;

    /*
     * now the attack 
     */
    if ( number_percent(  ) < chance )
    {
        act( "$n trips you and you go down!", ch, NULL, victim, TO_VICT );
        act( "You trip $N and $N goes down!", ch, NULL, victim, TO_CHAR );
        act( "$n trips $N, sending $M to the ground.", ch, NULL, victim, TO_NOTVICT );
        check_improve( ch, sn, true, 1 );

        DAZE_STATE( victim, 2 * PULSE_VIOLENCE );
        WAIT_STATE( ch, skill_table[sn].beats );
        victim->position = POS_RESTING;
        damage( ch, victim, number_range( 2, 2 + 2 * victim->size ), sn, DAM_BASH, true );
    }
    else
    {
        damage( ch, victim, 0, sn, DAM_BASH, true );
        WAIT_STATE( ch, skill_table[sn].beats * 2 / 3 );
        check_improve( ch, sn, false, 1 );
    }
    check_killer( ch, victim );
}

void do_kill( CHAR_DATA *ch, const char *argument )
{
    char                    arg[MAX_INPUT_LENGTH] = "\0\0\0\0\0\0\0";
    CHAR_DATA              *victim = NULL;

    one_argument( argument, arg );

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

    if ( ( victim = get_char_room( ch, arg ) ) == NULL )
    {
        ch_printf( ch, "They aren't here.\r\n" );
        return;
    }
/*  Allow player killing
    if ( !IS_NPC(victim) )
    {
        if ( !IS_SET(victim->act, PLR_KILLER)
        &&   !IS_SET(victim->act, PLR_THIEF) )
        {
            ch_printf( ch, "You must MURDER a player.\r\n" );
            return;
        }
    }
*/
    if ( victim == ch )
    {
        ch_printf( ch, "You hit yourself.  Ouch!\r\n" );
        multi_hit( ch, ch, TYPE_UNDEFINED );
        return;
    }

    if ( is_safe( ch, victim ) )
        return;

    if ( victim->fighting != NULL && !is_same_group( ch, victim->fighting ) )
    {
        ch_printf( ch, "Kill stealing is not permitted.\r\n" );
        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 )
    {
        ch_printf( ch, "You do the best you can!\r\n" );
        return;
    }

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

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

void do_murder( CHAR_DATA *ch, const char *argument )
{
    char                    buf[MAX_STRING_LENGTH] = "\0\0\0\0\0\0\0";
    char                    arg[MAX_INPUT_LENGTH] = "\0\0\0\0\0\0\0";
    CHAR_DATA              *victim = NULL;

    one_argument( argument, arg );

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

    if ( IS_AFFECTED( ch, AFF_CHARM ) || ( IS_NPC( ch ) && IS_SET( ch->act, ACT_PET ) ) )
        return;

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

    if ( victim == ch )
    {
        ch_printf( ch, "Suicide is a mortal sin.\r\n" );
        return;
    }

    if ( is_safe( ch, victim ) )
        return;

    if ( IS_NPC( victim ) &&
         victim->fighting != NULL && !is_same_group( ch, victim->fighting ) )
    {
        ch_printf( ch, "Kill stealing is not permitted.\r\n" );
        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 )
    {
        ch_printf( ch, "You do the best you can!\r\n" );
        return;
    }

    WAIT_STATE( ch, 1 * PULSE_VIOLENCE );
    if ( IS_NPC( ch ) )
        sprintf( buf, "Help! I am being attacked by %s!", ch->short_descr );
    else
        sprintf( buf, "Help!  I am being attacked by %s!", ch->name );
    do_function( victim, &do_yell, buf );
    check_killer( ch, victim );
    multi_hit( ch, victim, TYPE_UNDEFINED );
    return;
}

void do_backstab( CHAR_DATA *ch, const char *argument )
{
    char                    arg[MAX_INPUT_LENGTH] = "\0\0\0\0\0\0\0";
    CHAR_DATA              *victim = NULL;
    OBJ_DATA               *obj = NULL;
    int                     sn = -1;

    one_argument( argument, arg );

    if ( ( sn = skill_lookup( "backstab" ) ) == -1 )
    {
        log_error( "Can't find the \"%s\" skill in %s?", "backstab", __FUNCTION__ );
        return;
    }
    if ( arg[0] == '\0' )
    {
        ch_printf( ch, "Backstab whom?\r\n" );
        return;
    }

    if ( ch->fighting != NULL )
    {
        ch_printf( ch, "You're facing the wrong end.\r\n" );
        return;
    }

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

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

    if ( is_safe( ch, victim ) )
        return;

    if ( IS_NPC( victim ) &&
         victim->fighting != NULL && !is_same_group( ch, victim->fighting ) )
    {
        ch_printf( ch, "Kill stealing is not permitted.\r\n" );
        return;
    }

    if ( ( obj = get_eq_char( ch, WEAR_WIELD ) ) == NULL )
    {
        ch_printf( ch, "You need to wield a weapon to backstab.\r\n" );
        return;
    }

    if ( victim->hit < victim->max_hit / 3 )
    {
        act( "$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[sn].beats );
    if ( number_percent(  ) < get_skill( ch, sn )
         || ( get_skill( ch, sn ) >= 2 && !IS_AWAKE( victim ) ) )
    {
        check_improve( ch, sn, true, 1 );
        multi_hit( ch, victim, sn );
    }
    else
    {
        check_improve( ch, sn, false, 1 );
        damage( ch, victim, 0, sn, DAM_NONE, true );
    }

    return;
}

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

    if ( ( victim = ch->fighting ) == NULL )
    {
        if ( ch->position == POS_FIGHTING )
            ch->position = POS_STANDING;
        ch_printf( ch, "You aren't fighting anyone.\r\n" );
        return;
    }

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

        door = number_door(  );
        if ( ( pexit = was_in->exit[door] ) == 0
             || pexit->u1.to_room == NULL
             || IS_SET( pexit->exit_info, EX_CLOSED )
             || number_range( 0, ch->daze ) != 0
             || ( IS_NPC( ch ) && IS_SET( pexit->u1.to_room->room_flags, ROOM_NO_MOB ) ) )
            continue;

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

        ch->in_room = was_in;
        act( "$n has fled!", ch, NULL, NULL, TO_ROOM );
        ch->in_room = now_in;

        if ( !IS_NPC( ch ) )
        {
            ch_printf( ch, "You flee from combat!\r\n" );
            if ( ( ch->iclass == 2 ) && ( number_percent(  ) < 3 * ( ch->level / 2 ) ) )
                ch_printf( ch, "You snuck away safely.\r\n" );
            else
            {
                ch_printf( ch, "You lost 10 exp.\r\n" );
                gain_exp( ch, -10 );
            }
        }

        stop_fighting( ch, true );
        return;
    }

    ch_printf( ch, "PANIC! You couldn't escape!\r\n" );
    return;
}

void do_rescue( CHAR_DATA *ch, const char *argument )
{
    char                    arg[MAX_INPUT_LENGTH] = "\0\0\0\0\0\0\0";
    CHAR_DATA              *victim = NULL;
    CHAR_DATA              *fch = NULL;
    int                     sn = -1;

    one_argument( argument, arg );
    if ( ( sn = skill_lookup( "rescue" ) ) == -1 )
    {
        log_error( "Can't find the \"%s\" skill in %s?", "rescue", __FUNCTION__ );
        return;
    }
    if ( arg[0] == '\0' )
    {
        ch_printf( ch, "Rescue whom?\r\n" );
        return;
    }

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

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

    if ( !IS_NPC( ch ) && IS_NPC( victim ) )
    {
        ch_printf( ch, "%s doesn't need your help!\r\n", NAME( victim ) );
        return;
    }

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

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

    if ( IS_NPC( fch ) && !is_same_group( ch, victim ) )
    {
        ch_printf( ch, "Kill stealing is not permitted.\r\n" );
        return;
    }

    if ( ch->fighting == victim->fighting && fch->fighting == ch )
    {
        ch_printf( ch, "You are already fighting that target!\r\n" );
        return;
    }

    WAIT_STATE( ch, skill_table[sn].beats );
    if ( number_percent(  ) > get_skill( ch, sn ) )
    {
        ch_printf( ch, "You fail the rescue.\r\n" );
        check_improve( ch, sn, false, 1 );
        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 );
    check_improve( ch, sn, true, 1 );

    stop_fighting( ch, false );
    stop_fighting( fch, false );
    stop_fighting( victim, false );

    check_killer( ch, fch );
    set_fighting( ch, fch );
    set_fighting( fch, ch );
    return;
}

void do_kick( CHAR_DATA *ch, const char *argument )
{
    CHAR_DATA              *victim = NULL;
    int                     sn = -1;

    if ( ( sn = skill_lookup( "kick" ) ) == -1 )
    {
        log_error( "Can't find the \"%s\" skill in %s?", "kick", __FUNCTION__ );
        return;
    }
    if ( !IS_NPC( ch ) && ch->level < skill_table[sn].skill_level[ch->iclass] )
    {
        ch_printf( ch, "You better leave the martial arts to fighters.\r\n" );
        return;
    }

    if ( IS_NPC( ch ) && !IS_SET( ch->off_flags, OFF_KICK ) )
        return;

    if ( ( victim = ch->fighting ) == NULL )
    {
        ch_printf( ch, "You aren't fighting anyone.\r\n" );
        return;
    }

    WAIT_STATE( ch, skill_table[sn].beats );
    if ( get_skill( ch, sn ) > number_percent(  ) )
    {
        damage( ch, victim, number_range( 1, ch->level ), sn, DAM_BASH, true );
        check_improve( ch, sn, true, 1 );
    }
    else
    {
        damage( ch, victim, 0, sn, DAM_BASH, true );
        check_improve( ch, sn, false, 1 );
    }
    check_killer( ch, victim );
    return;
}

void do_disarm( CHAR_DATA *ch, const char *argument )
{
    CHAR_DATA              *victim = NULL;
    OBJ_DATA               *obj = NULL;
    int                     chance = 0;
    int                     hth = 0;
    int                     ch_weapon = 0;
    int                     vict_weapon = 0;
    int                     ch_vict_weapon = 0;
    int                     sn = -1;

    if ( ( sn = skill_lookup( "disarm" ) ) == -1 )
    {
        log_error( "Can't find the \"%s\" skill in %s?", "disarm", __FUNCTION__ );
        return;
    }

    if ( ( chance = get_skill( ch, sn ) ) == 0 )
    {
        ch_printf( ch, "You don't know how to disarm opponents.\r\n" );
        return;
    }

    if ( get_eq_char( ch, WEAR_WIELD ) == NULL
         && ( ( hth = get_skill( ch, skill_lookup( "hand to hand" ) ) ) == 0
              || ( IS_NPC( ch ) && !IS_SET( ch->off_flags, OFF_DISARM ) ) ) )
    {
        ch_printf( ch, "You must wield a weapon to disarm.\r\n" );
        return;
    }

    if ( ( victim = ch->fighting ) == NULL )
    {
        ch_printf( ch, "You aren't fighting anyone.\r\n" );
        return;
    }

    if ( ( obj = get_eq_char( victim, WEAR_WIELD ) ) == NULL )
    {
        ch_printf( ch, "Your opponent is not wielding a weapon.\r\n" );
        return;
    }

    /*
     * find weapon skills 
     */
    ch_weapon = get_weapon_skill( ch, get_weapon_sn( ch ) );
    vict_weapon = get_weapon_skill( victim, get_weapon_sn( victim ) );
    ch_vict_weapon = get_weapon_skill( ch, get_weapon_sn( victim ) );

    /*
     * modifiers 
     */

    /*
     * skill 
     */
    if ( get_eq_char( ch, WEAR_WIELD ) == NULL )
        chance = chance * hth / 150;
    else
        chance = chance * ch_weapon / 100;

    chance += ( ch_vict_weapon / 2 - vict_weapon ) / 2;

    /*
     * dex vs. strength 
     */
    chance += get_curr_stat( ch, STAT_DEX );
    chance -= 2 * get_curr_stat( victim, STAT_STR );

    /*
     * level 
     */
    chance += ( ch->level - victim->level ) * 2;

    /*
     * and now the attack 
     */
    if ( number_percent(  ) < chance )
    {
        WAIT_STATE( ch, skill_table[sn].beats );
        disarm( ch, victim );
        check_improve( ch, sn, true, 1 );
    }
    else
    {
        WAIT_STATE( ch, skill_table[sn].beats );
        act( "You fail to disarm $N.", ch, NULL, victim, TO_CHAR );
        act( "$n tries to disarm you, but fails.", ch, NULL, victim, TO_VICT );
        act( "$n tries to disarm $N, but fails.", ch, NULL, victim, TO_NOTVICT );
        check_improve( ch, sn, false, 1 );
    }
    check_killer( ch, victim );
    return;
}

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

void do_slay( CHAR_DATA *ch, const char *argument )
{
    CHAR_DATA              *victim = NULL;
    char                    arg[MAX_INPUT_LENGTH] = "\0\0\0\0\0\0\0";

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

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

    if ( ch == victim )
    {
        ch_printf( ch, "Suicide is a mortal sin.\r\n" );
        return;
    }

    if ( !IS_NPC( victim ) && victim->level >= get_trust( ch ) )
    {
        ch_printf( ch, "You failed.\r\n" );
        return;
    }

    act( "You slay $M 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;
}

void do_surrender( CHAR_DATA *ch, const char *argument )
{
    CHAR_DATA              *mob = NULL;

    if ( ( mob = ch->fighting ) == NULL )
    {
        ch_printf( ch, "But you're not fighting!\r\n" );
        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 );
    }
}