fight.c

muddy/src/fight.c · 209.0 KB

From the archive astrum.tar.bz2

Download the archive   « Back to the archive contents

/* $Id: fight.c,v 1.666 2004/09/20 10:49:48 shrike Exp $                            */

/************************************************************************************
 *    Copyright 2004 Astrum Metaphora consortium                                    *
 *                                                                                  *
 *    Licensed under the Apache License, Version 2.0 (the "License");               *
 *    you may not use this file except in compliance with the License.              *
 *    You may obtain a copy of the License at                                       *
 *                                                                                  *
 *    http://www.apache.org/licenses/LICENSE-2.0                                    *
 *                                                                                  *
 *    Unless required by applicable law or agreed to in writing, software           *
 *    distributed under the License is distributed on an "AS IS" BASIS,             *
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.      *
 *    See the License for the specific language governing permissions and           *
 *    limitations under the License.                                                *
 *                                                                                  *
 ************************************************************************************/
 /************************************************************************************
 *     ANATOLIA 2.1 is copyright 1996-1997 Serdar BULUT, Ibrahim CANPUNAR           *
 *     ANATOLIA has been brought to you by ANATOLIA consortium                      *
 *       Serdar BULUT {Chronos}         bulut@rorqual.cc.metu.edu.tr                *
 *       Ibrahim Canpunar  {Asena}      canpunar@rorqual.cc.metu.edu.tr             *
 *       Murat BICER  {KIO}             mbicer@rorqual.cc.metu.edu.tr               *
 *       D.Baris ACAR {Powerman}        dbacar@rorqual.cc.metu.edu.tr               *
 *     By using this code, you have agreed to follow the terms of the               *
 *     ANATOLIA license, in the file Anatolia/anatolia.licence                      *
 ***********************************************************************************/

/************************************************************************************
 *  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-1995 Russ Taylor                                  *
*       ROM has been brought to you by the ROM consortium                           *
*           Russ Taylor (rtaylor@pacinfo.com)                                       *
*           Gabrielle Taylor (gtaylor@pacinfo.com)                                  *
*           Brian Moore (rom@rom.efn.org)                                           *
*       By using this code, you have agreed to follow the terms of the              *
*       ROM license, in the file Rom24/doc/rom.license                              *
*************************************************************************************/

/************************************************************************************
 * Copyright (c) 1998 fjoe <fjoe@iclub.nsu.ru>                                      *
 * All rights reserved.                                                             *
 *                                                                                  *
 * Redistribution and use in source and binary forms, with or without               *
 * modification, are permitted provided that the following conditions               *
 * are met:                                                                         *
 * 1. Redistributions of source code must retain the above copyright                *
 *    notice, this list of conditions and the following disclaimer.                 *
 * 2. Redistributions in binary form must reproduce the above copyright             *
 *    notice, this list of conditions and the following disclaimer in the           *
 *    documentation and/or other materials provided with the distribution.          *
 *                                                                                  *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND           *
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE            *
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE       *
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE          *
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL       *
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS          *
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)            *
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT       *
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY        *
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF           *
 * SUCH DAMAGE.                                                                     *
 ************************************************************************************/

#define OLD_VERSION

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

#if !defined (WIN32)
    #include <unistd.h>
#endif

#include "merc.h"
#include "db/lang.h"
#include "comm/comm_act.h"
#include "quest.h"
#include "gquest.h"
#include "fight.h"
#include "rating.h"
#include "update.h"
#include "mob_prog.h"
#include "obj_prog.h"
#include "cyborg.h"
#include "conquer.h"
#include "artefacts.h"
#include "wanderers.h"
#include "align.h"
#include "shamans.h"

DECLARE_DO_FUN(do_yell          );
DECLARE_DO_FUN(do_quit_count    );
DECLARE_DO_FUN(do_crush         );
DECLARE_DO_FUN(do_crush_boots   );
DECLARE_DO_FUN(do_emote         );
DECLARE_DO_FUN(do_dismount      );
DECLARE_DO_FUN(do_bash          );
DECLARE_DO_FUN(do_berserk       );
DECLARE_DO_FUN(do_disarm        );
DECLARE_DO_FUN(do_kick          );
DECLARE_DO_FUN(do_horn_prick    );
DECLARE_DO_FUN(do_dirt          );
DECLARE_DO_FUN(do_trip          );
DECLARE_DO_FUN(do_tail          );
DECLARE_DO_FUN(do_look_in       );
DECLARE_DO_FUN(do_get           );
DECLARE_DO_FUN(do_sacrifice     );
DECLARE_DO_FUN(do_visible       );
DECLARE_DO_FUN(do_recall        );
DECLARE_DO_FUN(do_flee          );
DECLARE_DO_FUN(do_fly           );


void agent_net_printf(CHAR_DATA *ch, CHAR_DATA *victim, int);
/*
 * Local functions.
 */
void    check_assist        (CHAR_DATA *ch, CHAR_DATA *victim);
bool    check_dodge         (CHAR_DATA *ch, CHAR_DATA *victim);
bool    check_hand_block    (CHAR_DATA *ch, CHAR_DATA *victim);
bool    check_parry         (CHAR_DATA *ch, CHAR_DATA *victim, int loc);
bool    check_block         (CHAR_DATA *ch, CHAR_DATA *victim, int loc);
bool    check_blink         (CHAR_DATA *ch, CHAR_DATA *victim);
bool    check_shield        (CHAR_DATA *ch, CHAR_DATA *victim);
bool    check_towershield   (CHAR_DATA *ch, CHAR_DATA *victim);
bool    check_stand_off     (CHAR_DATA *ch, CHAR_DATA *victim);
bool    check_stoneskin     (CHAR_DATA *ch, CHAR_DATA *victim);
bool    check_mirror_image  (CHAR_DATA *ch, CHAR_DATA *victim);
void    dam_message         (CHAR_DATA *ch, CHAR_DATA *victim, int dam, int dt, bool immune ,int dam_type);
void    death_cry           (CHAR_DATA *ch);
void    death_cry_org       (CHAR_DATA *ch, int part);
void    group_gain          (CHAR_DATA *ch, CHAR_DATA *victim);
int     xp_compute          (CHAR_DATA *gch, CHAR_DATA *victim, int total_levels, int members);
bool    is_safe             (CHAR_DATA *ch, CHAR_DATA *victim);
void    make_corpse         (CHAR_DATA *ch);
void    one_hit             (CHAR_DATA *ch, CHAR_DATA *victim, int dt, int loc);
void    mob_hit             (CHAR_DATA *ch, CHAR_DATA *victim, int dt);
void    set_fighting        (CHAR_DATA *ch, CHAR_DATA *victim);
void    disarm              (CHAR_DATA *ch, CHAR_DATA *victim, OBJ_DATA *weapon);
int     critical_strike     (CHAR_DATA *ch, CHAR_DATA *victim, int dam);
void    check_eq_damage     (CHAR_DATA *ch, CHAR_DATA *victim, int loc);
void    check_shield_damage (CHAR_DATA *ch, CHAR_DATA *victim, int loc);
void    check_weapon_damage (CHAR_DATA *ch, CHAR_DATA *victim, int loc);

void    handle_death        (CHAR_DATA *ch, CHAR_DATA *victim);
extern bool check_perception(CHAR_DATA *ch, CHAR_DATA *victim);
extern bool check_riposte   (CHAR_DATA *ch, CHAR_DATA *victim, int dam);
extern bool check_restrike  (CHAR_DATA *ch, CHAR_DATA *victim);
extern bool check_absorb    (CHAR_DATA *ch, CHAR_DATA *victim, int sn, bool distant);
extern bool check_spellbane (CHAR_DATA *ch, CHAR_DATA *victim, int sn);
extern bool is_specialized  (CHAR_DATA *ch, int spec);
extern bool is_spec         (CHAR_DATA *ch, int sn);
extern void upgrade_npc (CHAR_DATA * mob);
extern bool does_not_affect_exp (CHAR_DATA * mob);
extern bool align_ok(CHAR_DATA *ch, int align);
int     check_forest_fighting        (CHAR_DATA *ch);

extern int *psi_attack[];
extern int *psi_defense[];

extern bool check_galka     (CHAR_DATA *ch);

extern STAT_DATA stat_record;

#define FOREST_ATTACK  1
#define FOREST_DEFENCE 2
#define FOREST_NONE    0

typedef struct damage_data DAMAGE_DATA;
struct damage_data
{
    int max_dam;
    char color;
    char *mes[3];
};

DAMAGE_DATA damage_table [] =
{
    {0,    'w', {"misses", "ÐpoÍaxÉ×aeÔcÑ ÍÉÍo", "ÐpoÍaxÉ×aÀÔcÑ ÍÉÍo"}},
    {4,    'c', {"scratches", "ÃapaÐaeÔ", "ÃapaÐaÀÔ"}},
    {8,    'c', {"grazes", "ÚaÄe×aeÔ", "ÚaÄe×aÀÔ"}},
    {12,   'c', {"hits", "ÂoÌØÎo ÚaÄe×aeÔ", "ÂoÌØÎo ÚaÄe×aÀÔ"}},
    {16,   'c', {"injures", "Ðo×peÖÄaeÔ", "Ðo×peÖÄaÀÔ"}},
    {20,   'c', {"wounds", "cÌeÇËa paÎÉÔ", "cÌeÇËa paÎÑÔ"}},
    {24,   'c', {"mauls", "paÎÉÔ", "paÎÑÔ"}},
    {28,   'c', {"decimates", "cÉÌØÎo paÎÉÔ", "cÉÌØÎo paÎÑÔ"}},
    {32,   'c', {"devastates", "oÐÕcÔoÛaeÔ", "oÐÕcÔoÛaÀÔ"}},
    {36,   'c', {"maims", "ËaÌeÞÉÔ", "ËaÌeÞÁÔ"}},
    {42,   'M', {"MUTILATES", "õPOäõET", "õPOäõàT"}},
    {52,   'M', {"DISEMBOWELS", "OðOTPOûáET", "OðOTPOûáàT"}},
    {65,   'M', {"DISMEMBERS", "PáCþìEHñET", "PáCþìEHñàT"}},
    {80,   'M', {"MASSACRES", "õHéþTOöáET", "õHéþTOöáàT"}},
    {100,  'M', {"MANGLES", "ðEPEMáìùBáET", "ðEPEMáìùBáàT"}},
    {130,  'y', {"** DEMOLISHES **", "** COKPõûáET **", "** COKPõûáàT **"}},
    {175,  'y', {"*** DEVASTATES ***", "*** Pá3PùBáET ***", "*** Pá3PùBáàT ***"}},
    {250,  'Y', {"== OBLITERATES ==", "== CTéPáET B ðOPOûOK ==", "== CTéPáàT B ðOPOûOK =="}},
    {325,  'Y', {"=== ATOMIZES ===", "=== PáCýEðìñET Há áTOMù ===", "=== PáCýEðìñàT Há áTOMù ==="}},
    {400,  'M', {">> ANNIHILATES <<", ">> áHHéçéìéPõET <<", ">> áHHéçéìéPõàT <<"}},
    {500,  'M', {">>> ERADICATES <<<", ">>> BùPùBáET C KOPHEM <<<", ">>> BùPùBáàT C KOPHEM <<<"}},
    {650,  'M', {"-=> ELECTRONIZES <=-", "-=> üìEKTPOHé3éPõET <=-", "-=> üìEKTPOHé3éPõàT <=-"}},
    {800,  'M', {"-==> SKELETONIZES <==-", "-==> CKEìETOHé3éPõET <==-", "-==> CKEìETOHé3éPõàT <==-"}},
    {1000, 'R', {"## NUKES ##", "## CTéPáET C ìéãá 3EMìé ##", "## CTéPáàT C ìéãá 3EMìé ##"}},
    {1250, 'R', {"### TERMINATES ###", "### äE3éHTEçPéPõET ###", "### äE3éHTEçPéPõàT ###"}},
    {1500, 'R', {"[*][*] TEARS UP [*][*]",
            "[*][*] Pá3äéPáET Há þáCTé [*][*]",
            "[*][*] Pá3äéPáàT Há þáCTé [*][*]"}},
    {3000, 'R', {"{*[*][*][*] POWER HITS [*][*][*]",
            "{*[*][*][*] POWER HITS [*][*][*]",
            "{*[*][*][*] POWER HITS [*][*][*]"}},
    {5000, 'R', {"{*<(*)><(*)> U.N.S.P.E.A.K.A.B.L.E <(*)><(*)>",
            "{*<(*)><(*)> U.N.S.P.E.A.K.A.B.L.E <(*)><(*)>",
            "{*<(*)><(*)> U.N.S.P.E.A.K.A.B.L.E <(*)><(*)>"}},
    {10000,'C', {"{*{R<{Y*{D={W(+){D={Y*{R> {CH{W*{CI{W*{CT{W*{CS {R<{Y*{D={W(+){D={Y*{R>",
            "{*{R<{Y*{D={W(+){D={Y*{R> {CH{W*{CI{W*{CT{W*{CS {R<{Y*{D={W(+){D={Y*{R>",
            "{*{R<{Y*{D={W(+){D={Y*{R> {CH{W*{CI{W*{CT{W*{CS {R<{Y*{D={W(+){D={Y*{R>"}},
    {50000,'C', {"{*{R<{Y*{D={W(+){D={Y*{R> {CS{W*{CU{W*{CP{W*{CE{W*{CR {CH{W*{CI{W*{CT{W*{CS {R<{Y*{D={W(+){D={Y*{R>",
            "{*{R<{Y*{D={W(+){D={Y*{R> {CS{W*{CU{W*{CP{W*{CE{W*{CR {CH{W*{CI{W*{CT{W*{CS {R<{Y*{D={W(+){D={Y*{R>",
            "{*{R<{Y*{D={W(+){D={Y*{R> {CS{W*{CU{W*{CP{W*{CE{W*{CR {CH{W*{CI{W*{CT{W*{CS {R<{Y*{D={W(+){D={Y*{R>"}},
    {-1,   'W', {"[{R*{W][{R*{W][{R*{W] DIVINE HITS [{R*{W][{R*{W][{R*{W]",
            "[{R*{W][{R*{W][{R*{W] DIVINE HITS [{R*{W][{R*{W][{R*{W]",
            "[{R*{W][{R*{W][{R*{W] DIVINE HITS [{R*{W][{R*{W][{R*{W]"}},
};

/*
 * Gets all money from the corpse.
 */
void get_gold_corpse(CHAR_DATA *ch, OBJ_DATA *corpse)
{
    OBJ_DATA *tmp, *tmp_next;
    OBJ_DATA *get_coins=NULL;
    for (tmp = corpse->contains; tmp; tmp = tmp_next)
    {
        tmp_next = tmp->next_content;
        if (tmp->pIndexData->item_type == ITEM_MONEY)
            if (IS_SET(ch->plr_flags, PLR_AUTOGOLD)
            && !IS_SET(ch->in_room->room_flags, ROOM_BATTLE_ARENA))
            {
                if (IS_SET(ch->plr_flags, PLR_AUTOSILVER))
                {
                    if (!can_get_obj(ch, tmp, TRUE))
                        get_obj(ch, tmp, corpse, TRUE);
                }
                else
                    if (tmp->value[1])
                {
                    obj_to_obj(get_coins = create_money(tmp->value[1], 0), corpse);
                    if (!can_get_obj(ch, get_coins, TRUE))
                    {
                        get_obj(ch, get_coins, corpse, TRUE);
                        if (tmp->value[0]) obj_to_obj(create_money(0, tmp->value[0]), corpse);
                        extract_obj(tmp);
                    }
                    else extract_obj(get_coins);
                }
            }
    }
}

int check_forest_fighting(CHAR_DATA* ch)
{
    AFFECT_DATA* paf;

    if (ch->in_room->sector_type != SECT_FOREST
    && ch->in_room->sector_type != SECT_HILLS
    && ch->in_room->sector_type != SECT_MOUNTAIN)
        return FOREST_NONE;
    for (paf = ch->affected; paf; paf = paf->next)
    {
        if (paf->type == gsn_forest_fighting)
        {
            if (paf->location == APPLY_AC)
                return FOREST_DEFENCE;
            else
                return FOREST_ATTACK;
        }
    }
    return FOREST_NONE;
}

/*
 * Control the fights going on.
 * Called periodically by update_handler.
 */
void violence_update(void)
{
    CHAR_DATA *ch;
    CHAR_DATA *ch_next;
    CHAR_DATA *victim;
    OBJ_DATA *obj;
    OBJ_DATA *obj_next;
    bool room_trig = FALSE;

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

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

        // here we will demonstrate the wrath of gods towards those
        // who have wrong align

        if(!IS_NPC(ch))
            if (!align_ok (ch, RALIGN(ch)))
                wrath_of_gods (ch);

        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;

        if (!IS_NPC(victim))
            ch->last_fought = victim;

        SET_FIGHT_TIME(ch);

        for (obj = ch->carrying; obj; obj = obj_next)
        {
            obj_next = obj->next_content;
            if (ch->fighting == NULL)
                break;
            oprog_call(OPROG_FIGHT, obj, ch, NULL);
        }

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

        /*
         * Fun for the whole family!
         */
        check_assist(ch, victim);
        if (IS_NPC(ch))
        {
            if (HAS_TRIGGER_MOB(ch, TRIG_FIGHT))
                p_percent_trigger(ch, NULL, NULL, victim, NULL, NULL, TRIG_FIGHT);
            if (HAS_TRIGGER_MOB(ch, TRIG_HPCNT))
                p_hprct_trigger(ch, victim);
        }

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

            if (obj->wear_loc != WEAR_NONE && HAS_TRIGGER_OBJ(obj, TRIG_FIGHT))
                p_percent_trigger(NULL, obj, NULL, victim, NULL, NULL, TRIG_FIGHT);
        }

        if (ch && ch->in_room)
        {
              if ( HAS_TRIGGER_ROOM(ch->in_room, TRIG_FIGHT) && room_trig == FALSE)
              {
                  room_trig = TRUE;
                  p_percent_trigger(NULL, NULL, ch->in_room, victim, NULL, NULL, TRIG_FIGHT);
              }
        }
    }
}

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

    if (ch->in_room == NULL)
        return;

    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->pIndexData->off_flags, ASSIST_PLAYERS)
            && rch->level + 6 > victim->level)
            {
                do_emote(rch, "screams and attacks!");
                multi_hit(rch,victim,TYPE_UNDEFINED);
                continue;
            }

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

            if (!IS_NPC(ch) && RIDDEN(rch) == ch)
            {
                multi_hit(rch,victim,TYPE_UNDEFINED);
                continue;
            }

            /* now check the NPC cases */

            if (IS_NPC(ch))
            {
                if ((IS_NPC(rch) && IS_SET(rch->pIndexData->off_flags,ASSIST_ALL))
                || (IS_NPC(rch) && rch->race == ch->race
                && IS_SET(rch->pIndexData->off_flags,ASSIST_RACE))
                || (IS_NPC(rch) && IS_SET(rch->pIndexData->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->pIndexData->off_flags,ASSIST_VNUM)))
                {
                    CHAR_DATA *vch;
                    CHAR_DATA *target;
                    int number;

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

                    target = NULL;
                    number = 0;

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

                    if (target != NULL)
                    {
                        do_emote(rch,"screams and attacks!");
                        multi_hit(rch,target,TYPE_UNDEFINED);
                    }
                }
            }
        }
    }
}
/* Do one group of attacks.
 * Used by :  void multi_hit(..)
 */
int one_attack(CHAR_DATA *ch, CHAR_DATA *victim, int dt, int dex, int con, int att, int dual, int haste)
{
    if (number_percent() < dex || att == 1);
       one_hit(ch, victim, dt, WEAR_WIELD);

    if (JUST_KILLED(victim) || JUST_KILLED(ch))
        return 1;

    if (number_range(1,con)<++att)
    {
        ch->move -= att/2;
        return 0;
    }

    if (number_percent() < dex * dual/100)
    {
        one_hit(ch, victim, dt, WEAR_SECOND_WIELD);
        if (get_eq_char(ch, WEAR_SECOND_WIELD) != NULL)
            check_improve(ch, gsn_second_weapon, TRUE, 7);
        else
            check_improve(ch, gsn_hand_to_hand, TRUE, 7);

        if (JUST_KILLED(victim) || JUST_KILLED(ch))
            return 1;

        if (number_range(1, con) < ++att)
        {
            ch->move -= att / 2;
            return 0;
        }
    }

    if (number_range(0, ch->level) < haste)
        return one_attack(ch, victim, dt, dex/2, con, att, dual, 0);
    return 0;
}

/*
 * Do one serie of attacks.
 */
void multi_hit(CHAR_DATA *ch, CHAR_DATA *victim, int dt)
{
    int chance, dual, dex, con, att, bonus, haste;
    OBJ_DATA *wield;
    int nhits;


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

#if 0
    /* become CRIMINAL in Law rooms */
    if (!IS_NPC(ch) && !IS_NPC(victim)
    && IS_SET(ch->in_room->room_flags, ROOM_LAW)
    && !IS_SET(victim->plr_flags, PLR_WANTED)
    && !IS_SET(ch->plr_flags, PLR_WANTED))
    {
        char_act("This room is under supervision of the law! Now you're {RCRIMINAL{x!", ch);
        SET_BIT(ch->plr_flags, PLR_WANTED);
    }
#endif

    /* ridden's adjustment */
    if (RIDDEN(victim) && !IS_NPC(victim->mount))
    {
        if (victim->mount->fighting == NULL
        || victim->mount->fighting == ch)
            victim = victim->mount;
        //else
        //    do_dismount(victim->mount, str_empty);
    }

    if (IS_AFFECTED(ch, AFF_WEAK_STUN))
    {
        act_puts("You are too stunned to respond $N's attack.",
            ch, NULL, victim, TO_CHAR, POS_FIGHTING);
        act_puts("$n is too stunned to respond your attack.",
            ch, NULL, victim, TO_VICT, POS_FIGHTING);
        REMOVE_BIT(ch->affected_by, AFF_WEAK_STUN);
        return;
    }

    if (IS_AFFECTED(ch, AFF_STUN))
    {
        act_puts("You are too stunned to respond $N's attack.",
            ch, NULL, victim, TO_CHAR, POS_FIGHTING);
        act_puts("$n is too stunned to respond your attack.",
            ch, NULL, victim, TO_VICT, POS_FIGHTING);
        act_puts("$n seems to be stunned.",
            ch, NULL, victim, TO_NOTVICT, POS_FIGHTING);
        affect_bit_strip(ch, TO_AFFECTS, AFF_STUN);
        SET_BIT(ch->affected_by, AFF_WEAK_STUN);
        return;
    }

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

    if (ch->move <= 0)
    {
        act_puts("You are too tired for attack.", ch, NULL, victim, TO_CHAR, POS_FIGHTING);
        return;
    }

    if (number_percent() < get_skill(ch, gsn_area_attack))
    {
        int count = 0, max_count;
        CHAR_DATA *vch, *vch_next;

        check_improve(ch, gsn_area_attack, TRUE, 6);

        max_count = 3 + (LVL(ch)>=70) + (LVL(ch)>=80) + (LVL(ch)>=90);

        // GM : ADV FURY
        if (is_affected(ch, gsn_adv_fury))
        {
            max_count += LVL(ch) / 20;
            check_improve(ch, gsn_adv_fury, TRUE, 6);
        }

        for (vch = ch->in_room->people; vch; vch = vch_next)
        {
            vch_next = vch->next_in_room;
            if (vch != victim && vch->fighting == ch)
            {
                one_hit(ch, vch, dt, WEAR_WIELD);
                if (JUST_KILLED(ch))
                    return;
                if (++count == max_count)
                    break;
            }
        }
    }

    if ((chance = get_skill(ch, gsn_zeal)))
    {
        if (number_percent() < chance / 10)
        {
            int count = 0, max_count;
            bool found =  TRUE;
            CHAR_DATA *vch, *vch_next;
            check_improve(ch, gsn_zeal, TRUE, 2);
            max_count = URANGE(1, LVL(ch) / 10, 8);
            char_act("ôÙ ÂØ£ÛØ Ó×ÏÉÈ ×ÒÁÇÏ× Ó âÏÖÅÓÔ×ÅÎÎÏÊ ÓÉÌÏÊ", ch);
            act("$n ÂØ£Ô Ó×ÏÉÈ ×ÒÁÇÏ× Ó âÏÖÅÓÔ×ÅÎÎÏÊ ÓÉÌÏÊ.",  ch, NULL, NULL, TO_ROOM);
            while (found && count < max_count && ch->fighting != NULL)
            {
                found = FALSE;
                for (vch = ch->in_room->people; vch; vch = vch_next)
                {
                    vch_next = vch->next_in_room;
                    if (vch->fighting == ch)
                    {
                        found = TRUE;
                        one_hit(ch, vch, dt, WEAR_WIELD);
                        if (JUST_KILLED(ch))
                            return;
                        if (++count == max_count)
                            break;
                    }
                }
            }
        }
        else
            check_improve(ch, gsn_zeal, FALSE, 1);
    }

/*
 *  ðÏÄÇÏÔÏ×ÉÔÅÌØÎÁÑ ÓÔÁÄÉÑ
 *  dex - ÞÅÍ ÂÏÌØÛÅ, ÔÅÍ ÂÙÓÔÒÅÅ ÐÅÒÓÏÎÁÖ ÎÁÎÏÓÉÔ ÁÔÁËÉ É, ÓÌÅÄÏ×ÁÔÅÌØÎÏ,
 *  ÂÏÌØÛÅ ÛÔÕË ÚÁ ÒÁÕÎÄ ÓÍÏÖÅÔ ÎÁÎÅÓÔÉ.
 *  haste ÒÁÓÃÅÎÉ×ÁÅÔÓÑ ËÁË ÂÏÎÕÓ Ë dexÕ, ÐÒÉÞÅÍ ÅÓÌÉ ÎÁ ÐÅÒÓÏÎÁÖÅ
 *  ×ÉÓÉÔ ÎÅÓËÏÌØËÏ haste'Ï×, ÔÏ ËÁÖÄÙÊ ÉÚ ÎÉÈ ×ÎÅÓÅÔ Ó×ÏÊ ×ËÌÁÄ.
 *  con - ÅÓÌÉ ÐÅÒÓÏÎÁÖ ÐÅÒÅÕÓÅÒÄÓÔ×ÕÅÔ × ÎÁÎÅÓÅÎÉÉ ÁÔÔÁË, ÔÏ
 *  ÐÏÔÅÒÑÅÔ ÚÁ ÜÔÏ 1 mv, ÐÒÉ ËÁÖÄÏÍ ÐÅÒÅÕÓÅÒÄÓÔ×Ï×ÁÎÉÉ
 *  ( × ÐÒÉÎÃÉÐÅ, ×ÏÚÍÏÖÅÎ ÁÌÔÅÒÎÁÔÉ×ÎÙÊ ×ÁÒÉÁÎÔ - ÐÅÒÅÓÔÁÎÅÔ ÁÔÁËÏ×ÁÔØ )
 */

    dex = dex_app[get_curr_stat(ch, STAT_DEX)].att;
    con = get_curr_stat(ch, STAT_CON)-3;
    haste = 0;
    bonus = 0;
    if (IS_AFFECTED(ch, AFF_SLOW))
        dex /= 2;
    else if (IS_AFFECTED(ch, AFF_HASTE))
    {
        AFFECT_DATA *af;
        for (af = ch->affected; af != NULL; af = af->next)
        {
            if (af->bitvector == AFF_HASTE)
            {
                bonus += URANGE(2, af->level/10, 10);
                haste = UMAX(haste, af->level);
            }
        }
        if (!haste)
            haste = ch->level;
        bonus += ch->mod_stat[STAT_DEX];
        dex += bonus/3;
    }

    if (IS_SET(victim->form, FORM_BEAR)) dex += 20;
    if (IS_SET(ch->form, FORM_WOLF)) dex += 20;

    switch (ch->stance)
    {
    case STANCE_OFFENSE_II  : break;
    case STANCE_OFFENSE     : dex -= 10; break;
    case STANCE_DEFENSE     : dex -= 30; break;
    case STANCE_DEFENSE_II  : dex -= 40; break;
    default                 : dex -= 20;
    }
    dex = URANGE(0, dex, dex_app[get_curr_stat(ch, STAT_DEX)].att + 15);

/*
 * åÓÌÉ Õ ÞÕ×ÁËÁ Ä×Á ÏÒÕÖÉÑ ÉÌÉ Ä×Å Ó×ÏÂÏÄÎÙÅ ÒÕËÉ, ÔÏ ÂØÅÔÓÑ ÐÕÓÔØ Ä×ÕÍÑ.
 * åÓÌÉ × ÐÒÁ×ÏÊ ÒÕËÅ Ä×ÕÒÕÞÎÏÅ ÏÒÕÖÉÅ, Á × ÌÅ×ÏÊ ÎÉÞÅÇÏ,
 * ÔÏ ÐÕÓÔØ ÓÒÁÖÁÅÔÓÑ ËÁË Ä×ÕÒÕÞÎÙÍ, ÅÓÌÉ ÖÅ × ÐÒÁ×ÏÊ ÒÕËÅ ÏÂÙÞÎÏÅ ÏÒÕÖÉÅ,
 * Á ÌÅ×ÁÑ ÐÕÓÔÁ, ÔÏ ÐÕÓÔØ ÏÎ ËÕÌÁËÏÍ ÌÅ×ÙÍ ÂØÅÔ.
 */
    if (get_eq_char(ch, WEAR_WIELD))
        dual = get_skill(ch, gsn_second_weapon) * 2 / 3;
    else
        dual = get_skill(ch, gsn_hand_to_hand) * 2 / 3;

    if (get_eq_char(ch, WEAR_SHIELD) || get_eq_char(ch, WEAR_HOLD))
        dual = 0;

    if (((wield=get_eq_char(ch,WEAR_WIELD)) != NULL)
    && (IS_WEAPON_STAT(wield, WEAPON_TWO_HANDS)
    || IS_WEAPON_STAT(wield, WEAPON_KATANA))
    && (get_eq_char(ch,WEAR_SECOND_WIELD) == NULL))
        dual = 0;

    // before all attacks because of all those returns
    if (altar_works (ch, ALTAR_HASTE_POS))
    {
        nhits = number_range (0,2);
        while (nhits--)
        {
            if (number_percent () < 80)
            {
                act("$n becomes blurred and starts to move very fast.",
                    ch, NULL, NULL, TO_ROOM);
                char_act("You become blurred and start to move very fast.", ch);

                one_hit(ch, ch->fighting, TYPE_UNDEFINED, WEAR_WIELD);
            }
        }
    }

    if (check_forest_fighting(ch) == FOREST_ATTACK)
    {
        chance = get_skill(ch, gsn_forest_fighting);
        while (number_percent() < chance)
        {
            one_hit(ch, victim, dt, WEAR_WIELD);
            check_improve (ch, gsn_forest_fighting, TRUE, 8);
            if (ch->fighting != victim || JUST_KILLED(ch) || JUST_KILLED(victim))
                return;
            chance /= 3;
        }
    }

// ôÅÐÅÒØ ÐÏÛÌÉ ÓÁÍÉ ÁÔÁËÉ.
    att = 0;
// ðÅÒ×ÁÑ
    if (one_attack(ch, victim, dt, dex, con, ++att, dual, haste))
        return;
// ÷ÔÏÒÁÑ
    if (number_percent() < get_skill(ch, gsn_second_attack))
    {
        check_improve(ch, gsn_second_attack, TRUE, 7);
        if (one_attack(ch, victim, dt, dex, con, ++att, dual, haste))
            return;
    }
    if (ch->stance == STANCE_DEFENSE_II)
        return;
// ôÒÅÔØÑ
    if (number_percent() < get_skill(ch, gsn_third_attack))
    {
        check_improve(ch, gsn_third_attack, TRUE, 7);
        if (one_attack(ch, victim, dt, dex, con, ++att, dual, haste))
            return;
    }
    if (ch->stance == STANCE_DEFENSE || ch->stance == STANCE_DEFENSE_II)
        return;
// þÅÔ×ÅÒÔÁÑ
    if (number_percent() < get_skill(ch, gsn_fourth_attack))
    {
        check_improve(ch, gsn_fourth_attack, TRUE, 7);
        if (one_attack(ch, victim, dt, dex, con, ++att, dual, haste))
            return;
    }
    if (ch->stance == STANCE_DEFENSE || ch->stance == STANCE_DEFENSE_II
    || ch->stance == STANCE_NORMAL)
        return;
// ðÑÔÁÑ
    if (number_percent() < get_skill(ch, gsn_fifth_attack))
    {
        check_improve(ch,gsn_fifth_attack,TRUE, 7);
        if (one_attack(ch, victim, dt, dex, con, ++att, dual, haste))
            return;
    }
}

/* procedure for all mobile attacks */
void mob_hit(CHAR_DATA *ch, CHAR_DATA *victim, int dt)
{
    CHAR_DATA *vch, *vch_next;
    flag64_t act = ch->pIndexData->act;
    flag64_t off = ch->pIndexData->off_flags;
    int chance;

    /* no attack by ridden mobiles except spec_casts */
    if (RIDDEN(ch))
    {
        if (ch->fighting != victim)
            set_fighting(ch, victim);
        return;
    }

    one_hit(ch, victim, dt, WEAR_WIELD);

    if (JUST_KILLED(ch) || JUST_KILLED(victim))
        return;

    /* Area attack -- BALLS nasty! */

    if (IS_SET(off, OFF_AREA_ATTACK))
    {
        for (vch = ch->in_room->people; vch != NULL; vch = vch_next)
        {
            vch_next = vch->next_in_room;
            if ((vch != victim && vch->fighting == ch))
                one_hit(ch, vch, dt, WEAR_WIELD);
            if (JUST_KILLED(ch))
                return;
        }
    }

    if (IS_AFFECTED(ch, AFF_HASTE) || IS_SET(off, OFF_FAST))
        one_hit(ch, victim, dt, WEAR_WIELD);

    if (JUST_KILLED(ch) || JUST_KILLED(victim))
        return;

    if (ch->fighting != victim || dt == gsn_backstab || dt == gsn_circle
    || dt == gsn_dual_backstab || dt == gsn_cleave || dt == gsn_ambush
    || dt == gsn_vampiric_bite || dt == gsn_charge)
        return;

    if (number_percent() < (get_skill(ch, gsn_second_attack) / 2) + 20)
    {
        one_hit(ch, victim, dt, WEAR_WIELD);
        if (ch->fighting != victim || JUST_KILLED(ch) || JUST_KILLED(victim))
            return;
    }

    if ((number_percent() < (get_skill(ch, gsn_third_attack) / 3) + 12)
        && !IS_AFFECTED(ch, AFF_SLOW))
    {
        one_hit(ch, victim, dt, WEAR_WIELD);
        if (ch->fighting != victim || JUST_KILLED(ch) || JUST_KILLED(victim))
            return;
    }

    if ((number_percent() < (get_skill(ch, gsn_fourth_attack) / 4) + 8)
        && !IS_AFFECTED(ch, AFF_SLOW))
    {
        one_hit(ch, victim, dt, WEAR_WIELD);
        if (ch->fighting != victim || JUST_KILLED(ch) || JUST_KILLED(victim))
            return;
    }


    if (check_forest_fighting(ch) == FOREST_ATTACK)
    {
        chance = get_skill(ch, gsn_forest_fighting);
        while (number_percent() < chance)
        {
            one_hit(ch, victim, dt, WEAR_WIELD);
            check_improve (ch, gsn_forest_fighting, TRUE, 8);
            if (ch->fighting != victim || JUST_KILLED(ch) || JUST_KILLED(victim))
                return;
            chance /= 3;
        }
    }

    if (!MOUNTED(ch))
    {
        affect_strip(ch, gsn_mount_fighting);
        affect_strip(ch, gsn_mount_control);
    }

    if (number_percent() < get_skill(ch, gsn_mount_fighting)
    && MOUNTED(ch))
    {
        chance = get_skill(ch, gsn_mount_fighting);
        while (number_percent() < chance)
        {
            one_hit(ch, victim, dt, WEAR_WIELD);
            check_improve (ch, gsn_mount_fighting, TRUE, 8);
            if (ch->fighting != victim || JUST_KILLED(ch) || JUST_KILLED(victim))
                return;
            chance /= 3;
        }
    }

    /* PC waits */

    if (ch->wait > 0)
        return;

    if (ch->fighting && number_bits(2) == 1
    && IS_CYBORG(ch))
    {
        do_annihilate(ch, str_empty);
        return;
    }

    if (ch->fighting && number_bits(3) == 1
    && IS_MECH(ch))
    {
        do_flamethrower(ch, str_empty);
        return;
    }

    if (ch->fighting && number_bits(3) == 1
    && IS_MECH(ch))
    {
        do_machinegun(ch, str_empty);
        return;
    }


#if 0
    switch (number_range(0, 2))
    {
    case 1:
        if (IS_SET(act, ACT_MAGE))
        {
            mob_cast_mage(ch, victim);
            return;
        }
        break;
    case 2:
        if (IS_SET(act, ACT_CLERIC))
        {
            mob_cast_cleric(ch, victim);
            return;
        }
        break;
    }
#endif

    /* now for the skills */

    switch (number_range(0, 10))
    {
    case 0:
        if (IS_SET(off, OFF_BASH))
            do_bash(ch, str_empty);
        break;

    case 1:
        if (IS_SET(off, OFF_BERSERK)
        && !IS_AFFECTED(ch, AFF_BERSERK))
            do_berserk(ch, str_empty);
        break;


    case 2:
        if (IS_SET(off, OFF_DISARM)
        || IS_SET(act, ACT_WARRIOR | ACT_THIEF))
        {
            if (number_range(0, 1)
            && get_eq_char(victim, WEAR_SECOND_WIELD))
                do_disarm(ch, "second");
            else if (get_eq_char(victim, WEAR_WIELD))
                do_disarm(ch, str_empty);
        }
        break;

    case 3:
        if (IS_SET(off, OFF_KICK))
            do_kick(ch, str_empty);
        break;

    case 4:
        if (IS_SET(off, OFF_DIRT_KICK))
        {
            if (IS_AFFECTED(ch, AFF_FLYING))
            {
                do_fly(ch, "down");
                do_dirt(ch, str_empty);
                do_fly(ch, "up");
            }
            else
                do_dirt(ch, str_empty);
        }
        break;

    case 5:
        if (IS_SET(off, OFF_TAIL))
            do_tail(ch, str_empty);
        break;

    case 6:
        if (IS_SET(off, OFF_TRIP)
        && !IS_AFFECTED(victim, AFF_FLYING))
            do_trip(ch, str_empty);
        break;
    case 7:
        if (IS_SET(off, OFF_CRUSH))
        {
            if (get_eq_char(ch, WEAR_FEET) != NULL)
                do_crush_boots(ch, str_empty);
            else
                do_crush(ch, str_empty);
        }
        break;
    }
}

int get_dam_type(CHAR_DATA *ch, OBJ_DATA *wield, int *dt)
{
    int dam_type;

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

    if (*dt < TYPE_HIT)
        if (wield)
            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 == TYPE_UNDEFINED)
        dam_type = DAM_BASH;

    return dam_type;
}

/*
 * Hit one guy once.
 */

void one_hit_new( CHAR_DATA *ch, CHAR_DATA *victim, int dt, int loc )
{
    OBJ_DATA *wield,*worn;
/*    int victim_ac;
    int thac0;
    int thac0_00;
    int thac0_32;
*/
    long           dam=0,part=0;
    int            diceroll;
    int            sn,skill,num1,i,j,todam,eqdam;
    int            dam_type;
    bool           result;
    char buf[256], *word;
    material_t     *material;


    material = NULL;
    sn = -1;


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

    /*
     * Can't beat a dead char!
     * Guard against weird room-leavings.
     */
     //ch->position == POS_DEAD are necessary
    if (victim->position == POS_DEAD ||  ch->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->pIndexData->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(wield);
    skill = get_weapon_skill(ch,sn);
    if (wield) skill*=str_app[get_curr_stat(ch, STAT_STR)].wield/
                      UMAX(str_app[get_curr_stat(ch, STAT_STR)].wield,wield->weight/5);


    /* ÄÌÑ ÒÁÚÌÉÞÅÎÉÑ ËÕÄÁ ÂØÅÍ */
    num1 = number_range(0, victim->pcnt);
    i=0;
    j=0;
    /*
       ÐÒÏÂÅÇÁÅÍ ×ÓÅ ×ÏÚÍÏÖÎÙÅ ÞÁÓÔÉ ÔÅÌÁ, Õ×ÅÌÉÞÉ×ÁÑ i ËÁÖÄÙÊ ÒÁÚ
       ËÁË ÎÁÔÏÌËÎÅÍÓÑ ÎÁ ÞÁÓÔØ ÔÅÌÁ, ÜÔÏÊ ÒÁÓÅ ÐÒÉÎÁÄÌÅÖÁÝÕÀ.
       ËÏÇÄÁ i ÄÏÓÔÉÇÎÅÔ num1, part ÂÕÄÅÔ ÔÁ, ËÏÔÏÒÁÑ ÔÒÅÂÕÅÔÓÑ.
    */
    while (i<num1 && j<MAX_PARTS)
    {
        if (IS_SET(victim->parts,(flag64_t) 1 << j))
        {
            i++;
            part = (flag64_t) 1 << j;
        }
        j++;
    }
    switch (part)
    {
    default:     word="ÐÏ"; break;
    case  PART_HEAD: word="ÐÏ ÇÏÌÏ×Å"; break;
    case  PART_ARMS: word="ÐÏ ÐÌÅÞÕ"; break;
    case  PART_LEGS: word="ÐÏ ÎÏÇÅ"; break;
    case  PART_HEART: word="× ÓÅÒÄÃÅ"; break;
    case  PART_BRAINS: word="× ÍÏÚÇ"; break;
    case  PART_GUTS: word="× ÖÉ×ÏÔ"; break;
    case  PART_HANDS: word="ÐÏ ÒÕËÅ"; break;
    case  PART_FEET: word="ÐÏ ÓÔÕÐÎÅ"; break;
    case  PART_FINGERS: word="ÐÏ ÐÁÌØÃÁÍ"; break;
    case  PART_EAR: word="ÐÏ ÕÈÕ"; break;
    case  PART_EYE: word="× ÇÌÁÚ"; break;
    case  PART_LONG_TONGUE: word="ÐÏ ÑÚÙËÕ"; break;
    case  PART_EYESTALKS: word="ÐÏ ÇÌÁÚÎÉÃÅ"; break;
    case  PART_TENTACLES: word="ÐÏ ÝÕÐÁÌØÃÕ"; break;
    case  PART_FINS: word="ÐÏ ÌÁÓÔÅ"; break;
    case  PART_WINGS: word="× ËÒÙÌÏ"; break;
    case  PART_TAIL: word="ÐÏ È×ÏÓÔÕ"; break;
    case  PART_CLAWS: word="ÐÏ ËÏÇÔÑÍ"; break;
    case  PART_FANGS: word="ÐÏ ËÌÙËÁÍ"; break;
    case  PART_HORNS: word="ÐÏ ÒÏÇÁÍ"; break;
    case  PART_SCALES: word="ÐÏ ÞÅÛÕÊÞÁÔÏÍÕ ÔÅÌÕ"; break;
    case  PART_TUSKS: word="× ÂÉ×ÅÎØ"; break;
    }
    snprintf(buf, sizeof(buf), "ôÙ ÂØÅÛØ %s %s.\n", word, IS_NPC(victim) ? mlstr_cval(victim->short_descr, ch) : victim->name);
    if (strcmp(word,"ÐÏ"))
        snprintf(buf, sizeof(buf), "%s ÂØÅÔ ÔÅÂÅ %s.\n", IS_NPC(ch) ? mlstr_cval(ch->short_descr, ch) : ch->name, word );
    else
        snprintf(buf, sizeof(buf), "%s ÂØÅÔ ÐÏ ÔÅÂÅ.\n", IS_NPC(ch) ? mlstr_cval(ch->short_descr, ch) : ch->name);

    /*
     * ÕÖÅ ÉÚ×ÅÓÔÎÏ, ËÕÄÁ ÂØÀÔ, ÔÅÐÅÒØ ÐÒÏ×ÅÒÑÅÍ ×ÓÑËÉÅ ÕÓÌÏ×ÉÑ ÐÏÐÁÄÁÎÉÑ:
     * 1) ÖÅÒÔ×Á ÕËÌÏÎÉÌÁÓØ
     * 2) ÐÒÏÍÁÈÎÕÌÉÓØ ÐÏ ÐÒÉÞÉÎÅ ÐÌÏÈÏÇÏ ÏÐÙÔÁ (<100) ÐÏ ÏÒÕÖÉÀ
     */
    if (check_dodge(ch, victim))
    {
        damage( ch, victim, 0, dt, dam_type, FALSE );
        tail_chain();
        return;
    }
    if (number_percent()>skill)
    {
        damage( ch, victim, 0, dt, dam_type, TRUE );
        tail_chain();
        return;
    }

    todam=ch->size/5;
    eqdam=ch->size/victim->size;

    /* ÐÏÄÓÞÉÔÙ×ÁÅÍ ÓÉÌÕ ÕÄÁÒÁ */
    if (wield == NULL)
        dam = number_range(ch->level / 2, ch->level)*
              ch->size * skill / 100;
    else
    {
        if (!IS_NPC(ch) && sn!=-1) check_improve(ch, sn, TRUE, 5);
        dam = dice(wield->value[1], wield->value[2]) * skill/100;
        /* sharpness! */
        if (IS_WEAPON_STAT(wield,WEAPON_SHARP))
        {
            int percent;
            if ((percent = number_percent()) <= (skill / 8))
                dam = 2 * dam + (dam * 8 * percent / 100);
            todam+=percent/3;
        }
    }

    if ( get_skill(ch,gsn_enhanced_damage) > 0 )
    {
        diceroll = number_percent();
        if (diceroll <= get_skill(ch,gsn_enhanced_damage))
        {
            check_improve(ch,gsn_enhanced_damage,TRUE,6);
            dam += dam * diceroll/120;
            eqdam+= diceroll/50;
        }
    }

    worn=NULL;

/* ÐÒÏ×ÅÒÑÅÍ sh/b, parry - ËÁË ÓÒÅÄÓÔ×Á ÉÚÂÅÖÁÔØ ÕÄÁÒÁ ÐÏ ÞÁÓÔÉ ÔÅÌÁ ÎÅË. */
    if (check_block(ch, victim, WEAR_WIELD))
    {
        worn = get_eq_char(victim, WEAR_SHIELD);
        if (worn)
        {
            eq_damage(ch, victim, worn, todam/5, eqdam/3+1);
            dam/=2;
        }
    }
    else if (check_parry(ch, victim, WEAR_WIELD))
    {
        worn = get_eq_char(victim, WEAR_WIELD);
        if (worn)
        {
            eq_damage(ch, victim, worn, todam/4, eqdam/4+1);
            damage( ch, victim, 0, dt, dam_type, FALSE );
            tail_chain();
            return;
        }
        /* ÅÓÌÉ ÏÎ ÔÁËÏÊ ÓÍÅÌÙÊ É ÐÁÒÉÒÕÅÔ ÒÕËÏÊ, ÔÏ ÐÒÏ×ÅÒÉÍ ÅÅ ÎÁ ÎÁÌÉÞÉÅ
           ÁÒÍÏÒÉÎÙ, Á ÕÄÁÒ ÐÏ ÎÅÊ, É ÒÁÚÒÕÛÅÎÉÅ ÁÒÍÏÒÉÎÙ ×ÙÛÅ ÔÁË ËÁË
           ÏÎ ÐÁÒÉÒÕÅÔ, Á ÎÅ ÐÒÏÓÔÏ ÐÁÓÓÉ×ÎÏ ÐÒÉÎÉÍÁÅÔ ÕÄÁÒ */
        else
        {
            part=PART_HANDS;
            dam*=1.5;
            todam*=1.3;
            eqdam*=1.5;
        }
    }

/*
   ÅÓÌÉ ÕÄÁÒ ÐÒÉÎÑÔ ÎÁ ÝÉÔ, ÔÏ worn!=0,
   ÅÓÌÉ ÕÄÁÒ ÐÒÉÎÑÔ ÎÁ ÏÒÕÖÉÅ, ÔÏ ÓÀÄÁ ÎÅ ÐÏÐÁÄÁÅÍ,
   ÅÓÌÉ ÝÉÔÁ ÎÅ ÂÙÌÏ, ÔÏ shield block ÎÅ ÚÁÓÞÉÔÙ×ÁÅÔÓÑ,
   Á ÅÓÌÉ ÎÅ ÂÙÌÏ ÏÒÕÖÉÑ, ÔÏ worn=0, ÎÏ ÞÁÓÔØ ÔÅÌÁ ÁÔÁËÕÅÍÁÑ - ÒÕËÁ
*/

    if (!worn)
        worn = get_eq_char(victim, part2wear(part));

    if (worn && worn->material)
        material = material_lookup(worn->material);

     if (material == NULL)
          material = MATERIAL(0);

    if (worn && (IS_SET(material->flag, MAT_ARMOR)))
    {
        /* ÄÌÑ ÐÒÏÎÉËÁÀÝÉÈ ÕÄÁÒÏ× - ÇÌÕÂÉÎÁ ÐÒÏÎÉËÎÏ×ÅÎÉÑ */
        float glubina;
//      printf("todam: %d, eqdam: %d, ", todam, eqdam);
        switch (dam_type)
        {
        case DAM_SLASH:
            if (material->rigidity &&  material->density)
                /* ÂÕÄÅÔ - ÄÌÉÎÁ * ÍÎÏÖÉÔÅÌØ / ...ÔÒÁÌÑÌÑ... */
                glubina=2000/(float)(material->rigidity *  material->density);
            else glubina=100;
//          printf("glubina: %f, dam old: %ld, ", glubina, dam);

            if (glubina>0 && glubina<worn->value[4]+1)
            {
                eq_damage(ch, victim, worn, todam,
                          eqdam*glubina*100/((worn->value[4]+1)*
                                             (number_percent()>ch->damroll?20:10)));
                dam=wield ? wield->weight * ch->level *
                    material->rigidity/(4500) :
                    dam*material->rigidity/100;
            }
            else
            {
                eq_damage(ch, victim, worn, todam, glubina*100/((worn->value[4]+1)*
                                                                (number_percent()>ch->damroll?10:5)));
                if (glubina<100 && glubina>0)
                    dam*=glubina/(glubina+worn->value[4]+1);
            }
//          printf("dam: %ld\n",dam);
            break;
        case DAM_BASH:
//          printf("glubina: 0(bash), dam old: %ld, ", dam);
            dam*=(100 + material->rigidity*5)/(worn->value[4]*600+600);
            eq_damage(ch, victim, worn, todam * material->fragility, eqdam * material->fragility);
//        printf("dam: %ld\n",dam);
            break;
        case DAM_PIERCE:
            /* ÅÓÌÉ ÐÒÏÂÉ×ÁÅÍ, ÔÏ ÍÁËÓÉÍÕÍ ÎÁ ÄÌÉÎÕ ÌÅÚ×ÉÑ;
                ÐÏËÁ ÄÌÉÎÁ ÎÅ ÚÁÄÁÅÔÓÑ */
            if (material->density>50 &&
                material->rigidity>20)
                glubina=1000/(float)
                        (material->rigidity*material->density);
            else glubina=100;
//          printf("glubina: %f, dam old: %ld, ", glubina, dam);
            if (glubina>0 && glubina<=worn->value[4]+1)
            {
                if (material->density>40)
                    eq_damage(ch, victim, worn,
                              todam*material->rigidity/5,
                              eqdam*material->rigidity/5);
                if (material->density>0)
                    glubina*=40/(float)material->density;
            }
            else if (glubina>0 && glubina>worn->value[4]+1)
            {
                if (material->density>40)
                    eq_damage(ch, victim, worn,
                              todam*material->rigidity/3,
                              eqdam*material->rigidity/2);
                if (material->density>0)
                    glubina*=40/(float)material->density;
            }
            if (glubina<worn->value[4]+1)
                dam*=glubina/(worn->value[4]+1);
            else
                dam*=(glubina-worn->value[4]-1)/glubina;
//        printf("dam: %ld\n",dam);
            break;
        default:
            break;
        }
    }

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

    if ( dt == gsn_backstab && wield != NULL)
    {
        if ( wield->value[0] != 2 )
            dam *= 2 + (LVL(ch) / 10);
        else
            dam *= 2 + (LVL(ch) / 8);
    }

    dam = UMAX(dam,1);
    result = damage( ch, victim, dam, dt, dam_type, TRUE );
    check_improve(ch, sn, result!=0, 2);

    /* but do we have a funky weapon? */
    if (result && wield != NULL)
    {
        long dam;

        if (ch->fighting == victim && IS_WEAPON_STAT(wield,WEAPON_POISON))
        {
            int level;
            AFFECT_DATA *poison, af;

            if ((poison = affect_find(wield->affected,gsn_poison)) == NULL)
                level = wield->level;
            else
                level = poison->level;

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

                af.where     = TO_AFFECTS;
                af.type      = gsn_poison;
                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);
            // max dam for vamp
            if (IS_SET(ch->form, FORM_VAMPIRE))
                dam = 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 | ACT_VERBOSE);
            damage(ch, victim, dam, 0, DAM_NEGATIVE, FALSE);
//        ch->alignment = UMAX(-1000, ch->alignment - 1);
            // more hp for vamp (max == 200)
            if (IS_SET(ch->form, FORM_VAMPIRE))
                ch->hit += dam * 10;
            else
                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_VERBOSE);
            act("$p sears your flesh.",victim,wield,NULL,TO_CHAR | ACT_VERBOSE);
            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_VERBOSE);
            act("The cold touch of $p surrounds you with ice.", victim,wield,NULL,TO_CHAR | ACT_VERBOSE);
            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_VERBOSE);
            act("You are shocked by $p.", victim,wield,NULL,TO_CHAR | ACT_VERBOSE);
            shock_effect(victim,wield->level/2,dam,TARGET_CHAR);
            damage(ch,victim,dam,0,DAM_LIGHTNING,FALSE);
        }

        if (ch->fighting == victim && IS_WEAPON_STAT(wield,WEAPON_RADIATION))
        {
            dam = number_range(1,wield->level/5 + 2);
            act("$n ÏÂÌÕÞÅÎ ÒÁÄÉÁÃÉÅÊ ÉÚ $p.", victim,wield,NULL,TO_ROOM | ACT_VERBOSE);
            act("ôÙ ÏÂÌÕÞÅÎ ÒÁÄÁÃÉÅÊ ÉÚ $p.", victim,wield,NULL,TO_CHAR | ACT_VERBOSE);
            radiation_effect(victim, wield->level, TARGET_CHAR);
            damage(ch,victim,dam,0,DAM_RADIATION,FALSE);
        }

        if (ch->fighting == victim && IS_OBJ_STAT(wield,ITEM_DEATH))
        {
            dam = number_range(3,wield->level/4 + 4);
            act("The death power of $p torments $n.", victim,wield,NULL,TO_ROOM | ACT_VERBOSE);
            act("The death power of $p torments you.", victim,wield,NULL,TO_CHAR | ACT_VERBOSE);
            damage(ch,victim,dam,0,DAM_NEGATIVE,FALSE);
        }
        if (ch->fighting == victim && IS_OBJ_STAT(wield, ITEM_SINGING))
        {
            dam = number_range(10,wield->level/4 + 4);
            act("$p ÐÏ£Ô ÊÏÄÌØ!!\n$n, ËÁÖÅÔÓÑ ÓÅÊÞÁÓ ÏÇÌÏÈÎÅÔ!", victim, wield, NULL, TO_ROOM | ACT_VERBOSE);
            act("$p ÐÏ£Ô ÊÏÄÌØ!!\nôÙ ÓÅÊÞÁÓ ÏÇÌÏÈÎÅÛØ!", victim, wield, NULL, TO_CHAR | ACT_VERBOSE);
            damage(ch,victim,dam,0,DAM_SOUND,FALSE);


        }

    }
    tail_chain( );
    return;
}

void delete_player(CHAR_DATA *victim, char* msg)
{
    char *name;

    char_act("You became a ghost permanently and leave the realm.", victim);
    act("$n is dead, and will not rise again.", victim, NULL, NULL, TO_ROOM);
    victim->hit = 1;
    victim->position = POS_STANDING;
    wiznet_printf(victim, NULL, 0, 0, 0, "$N is deleted due to %s.", msg);
    RESET_FIGHT_TIME(victim);
    name = capitalize(victim->name);
    do_quit_count(victim, str_empty);
    dunlink(PLAYER_PATH, name);
}

/*
 * handle_death - called from `damage' if `ch' has killed `victim'
 */
void handle_death(CHAR_DATA *ch, CHAR_DATA *victim)
{
    char *penalty=str_empty;
    bool vnpc = IS_NPC(victim);
    bool is_duel = (!IS_NPC(victim))
                   && (!IS_NPC(ch) || IS_AFFECTED(ch, AFF_CHARM))
                   && (IS_SET(victim->in_room->room_flags, ROOM_BATTLE_ARENA));
//    int chance = 0;
    int headprice = 0;
    OBJ_DATA *corpse;
    CHAR_EXPLORED_DATA *curr_expl_area;
    bool area_found;
    CHAR_DATA *gch;

    clan_t *clan = NULL;

    if (ch == victim && victim->fighting != NULL)
    {
        ch = victim->fighting;
    }

    if (IS_AFFECTED(ch, AFF_CHARM))
    {
        if (ch->master != NULL)
            ch = ch->master;
    }
    // TODO temporary artefacts removed
    // check_artefact_appearance(ch, victim, artefactList);
    clan = CLAN(ch->clan);

    if (!IS_NPC(victim))
        wiznet_printf(ch, NULL, WIZ_DEATHS, 0, 0, "$N kills %s.", victim->name);

    if (!IS_NPC(victim))
        log_printf("Kill: %s kills %s.", ch->name, victim->name);

    if (!IS_NPC(ch) && !IS_NPC(victim))
        agent_net_printf(victim, ch, ANET_KILLED);

    if ((!IS_NPC(ch)
    || IS_AFFECTED(ch, AFF_CHARM))
    && !IS_NPC(victim) && ch != victim)
    {
        if (victim->level == LEVEL_HERO)
            info(victim, LEVEL_HERO, "{r[{RINFO{r]{W The so-called hero {Y%s {Wwas killed!{x\n", victim->name);
        else
            info(victim, LEVEL_HERO, "{r[{RINFO{r]{W Someone called {y%s {Wwas killed!{x", victim->name);
    }

    if (IS_NPC (victim))
        ++stat_record.mobs_killed;
    else
    {
        if (IS_NPC(ch))
            ++stat_record.pc_killed_by_mobs;
        else
        {
            ++stat_record.PK_count;
            if (IS_SET (victim->in_room->room_flags, ROOM_BATTLE_ARENA))
                ++stat_record.PK_on_CR;
        }
    }

    if (victim->in_war)
    {
        // when true - this death was during the war and was handled - so we must return
        if (war_handle_death (ch, victim)) // in this function we reset fight_time
        {
            victim->position = POS_RESTING;
            return;
        }
    }

    if (!IS_NPC(ch)
    && !IS_NPC(victim)
    && !IS_SET(victim->in_room->room_flags, ROOM_BATTLE_ARENA)
    && victim->pcdata->headprice > 0)
    {
        headprice = victim->pcdata->headprice;
        if (IS_SET(clan->flags, CLAN_HIDDEN))
            headprice = number_range(headprice * 2, headprice * 10);
        act("You recive a $j gold as headprice, for killing $N.",
            ch, (const void *) headprice, victim, TO_CHAR);
        ch->pcdata->bank_g += headprice;
        victim->pcdata->headprice = 0;
    }

    if (!IS_NPC(victim))
    {
        if (victim->daze > 0)
            victim->daze = 0;
        if (victim->wait > 0)
            victim->wait = 0;
    }

    group_gain(ch, victim);

    if (IS_NPC(ch) && ch->pIndexData->vnum == MOB_VNUM_STALKER)
        ch->status = 10;

     // Death trigger
    if (vnpc && HAS_TRIGGER_MOB(victim, TRIG_DEATH))
    {
        victim->position = POS_STANDING;
        p_percent_trigger(victim, NULL, NULL, ch, NULL, NULL, TRIG_DEATH);
    }

    // moved here from raw_kill to avoid bugs
    // where death is avoided thru death_prog
    {
        OBJ_DATA* obj;
        OBJ_DATA* obj_next;

        for (obj = victim->carrying; obj != NULL; obj = obj_next)
        {
            obj_next = obj->next_content;
            if (obj->wear_loc != WEAR_NONE
            && oprog_call(OPROG_DEATH, obj, victim, ch))
            {
                victim->position = POS_STANDING;
                return;
            }
        }
    }

    // tattoo 'nine green spiders'
    {
        int ssn = sn_lookup ("nine green spiders");

        if (is_affected (victim, ssn) && check_tattoo (victim, ssn)
            && (number_percent() < get_skill (victim, ssn) - 10))
        {
            check_improve(victim, ssn, TRUE, 1);

            while (victim->affected)
                affect_remove(victim, victim->affected);

            if (ch && IS_NPC(ch) && !IS_SET (ch->pIndexData->act, ACT_CLAN_GUARD))
            {
                remove_mind(ch, victim->name);
                ch->last_fought = NULL;
            }

            stop_fighting(victim, TRUE);

            RESET_FIGHT_TIME(victim);

            victim->last_death_time = current_time;

            victim->hit     = (victim->max_hit/2);
            victim->mana    = (victim->max_mana/5);
            victim->move    = (victim->max_move/10);
            victim->position = POS_STANDING;

            char_act ("Nine green spiders give you their energy. One more time you've tricked death.", victim);
            act ("Nine green spiders on $n's tattoo glow brightly and are gone.", victim, NULL, NULL, TO_ROOM);

            return;
        }
    }

    // take revenge
/*    if (HAS_SKILL(victim, gsn_take_revenge))
    {
        chance = get_skill(victim, gsn_take_revenge) / 3;
        char_act("Loading skill data............[ {GOK{x ]", victim);

        if (!IS_NPC(ch))
            chance += get_curr_stat(victim, STAT_LCK) - get_curr_stat(ch, STAT_LCK);
        else
            chance += get_curr_stat(victim, STAT_LCK);
        char_act("Loading luck bonus............[ {GOK{x ]", victim);

        if (IS_RAFFECTED(victim->in_room, RAFF_PREVENT))
        {
            char_act("Prevent found.................[{YEXIT{x]", victim);
            chance = 0;
            check_improve (victim, gsn_take_revenge, FALSE, 1);
        }
        if (IS_SET(victim->in_room->room_flags, ROOM_BATTLE_ARENA))
        {
            char_act("Battle arena found............[{YEXIT{x]", victim);
            chance = 0;
            check_improve (victim, gsn_take_revenge, FALSE, 1);
        }

        if (chance >= number_percent())
        {
            while (victim->affected)
                affect_remove(victim, victim->affected);

            if (ch && IS_NPC(ch))
                remove_mind(ch, victim->name);

            stop_fighting(victim, TRUE);

            RESET_FIGHT_TIME(ch);

            victim->last_death_time = current_time;

            char_act("Loading char stats............[ {GOK{x ]", victim);

            victim->hit     = (victim->max_hit) / 10;
            victim->mana    = (victim->max_mana) / 10;
            victim->move    = (victim->max_move) / 10;
            char_act("Creating life form ( 1/10)....[ {GOK{x ]", victim);

            if (number_percent() < (get_curr_stat(victim, STAT_LCK) * 2) + 60)
            {
                victim->hit     += (victim->max_hit) / 10;
                victim->mana    += (victim->max_mana) / 10;
                victim->move    += (victim->max_move) / 10;
                char_act("Creating life form ( 2/10)....[ {GOK{x ]", victim);
            } else
            {
                char_act("Creating life form ( 2/10)....[{RFAIL{x]", victim);
            }
            if (number_percent() < (get_curr_stat(victim, STAT_LCK) * 2) + 50)
            {
                victim->hit     += (victim->max_hit) / 10;
                victim->mana    += (victim->max_mana) / 10;
                victim->move    += (victim->max_move) / 10;
                char_act("Creating life form ( 3/10)....[ {GOK{x ]", victim);
            } else
            {
                char_act("Creating life form ( 3/10)....[{RFAIL{x]", victim);
            }
            if (number_percent() < (get_curr_stat(victim, STAT_LCK) * 2) + 40)
            {
                victim->hit     += (victim->max_hit) / 10;
                victim->mana    += (victim->max_mana) / 10;
                victim->move    += (victim->max_move) / 10;
                char_act("Creating life form ( 4/10)....[ {GOK{x ]", victim);
            } else
            {
                char_act("Creating life form ( 4/10)....[{RFAIL{x]", victim);
            }
            if (number_percent() < (get_curr_stat(victim, STAT_LCK) * 2) + 30)
            {
                victim->hit     += (victim->max_hit) / 10;
                victim->mana    += (victim->max_mana) / 10;
                victim->move    += (victim->max_move) / 10;
                char_act("Creating life form ( 5/10)....[ {GOK{x ]", victim);
            } else
            {
                char_act("Creating life form ( 5/10)....[{RFAIL{x]", victim);
            }
            if (number_percent() < (get_curr_stat(victim, STAT_LCK) * 2) + 20)
            {
                victim->hit     += (victim->max_hit) / 10;
                victim->mana    += (victim->max_mana) / 10;
                victim->move    += (victim->max_move) / 10;
                char_act("Creating life form ( 6/10)....[ {GOK{x ]", victim);
            } else
            {
                char_act("Creating life form ( 6/10)....[{RFAIL{x]", victim);
            }
            if (number_percent() < (get_curr_stat(victim, STAT_LCK) * 2) + 10)
            {
                victim->hit     += (victim->max_hit) / 10;
                victim->mana    += (victim->max_mana) / 10;
                victim->move    += (victim->max_move) / 10;
                char_act("Creating life form ( 7/10)....[ {GOK{x ]", victim);
            } else
            {
                char_act("Creating life form ( 7/10)....[{RFAIL{x]", victim);
            }
            if (number_percent() < (get_curr_stat(victim, STAT_LCK) * 2) - 0)
            {
                victim->hit     += (victim->max_hit) / 10;
                victim->mana    += (victim->max_mana) / 10;
                victim->move    += (victim->max_move) / 10;
                char_act("Creating life form ( 8/10)....[ {GOK{x ]", victim);
            } else
            {
                char_act("Creating life form ( 8/10)....[{RFAIL{x]", victim);
            }
            if (number_percent() < (get_curr_stat(victim, STAT_LCK) * 2) - 10)
            {
                victim->hit     += (victim->max_hit) / 10;
                victim->mana    += (victim->max_mana) / 10;
                victim->move    += (victim->max_move) / 10;
                char_act("Creating life form ( 9/10)....[ {GOK{x ]", victim);
            } else
            {
                char_act("Creating life form ( 9/10)....[{RFAIL{x]", victim);
            }
            if (number_percent() < (get_curr_stat(victim, STAT_LCK) * 2) - 20)
            {
                victim->hit     += (victim->max_hit) / 10;
                victim->mana    += (victim->max_mana) / 10;
                victim->move    += (victim->max_move) / 10;
                char_act("Creating life form (10/10)....[ {GOK{x ]", victim);
            } else
            {
                char_act("Creating life form (10/10)....[{RFAIL{x]", victim);
            }

            victim->position = POS_STANDING;
            check_improve (victim, gsn_take_revenge, TRUE, 1);

            return;
        } else
        {
            check_improve (victim, gsn_take_revenge, FALSE, 1);
            char_act("Loading char stats............[{RFAIL{x]", victim);
        }
    }*/

    for (gch = ch->in_room->people; gch; gch = gch->next_in_room)
    {
        if (is_same_group(gch, ch))
        {
            if (!IS_NPC(gch) && gch->pcdata && gch->pcdata->explored_areas && gch->in_room &&
                gch->level > 5 && !IS_SET(gch->in_room->room_flags, ROOM_BATTLE_ARENA) &&
                gch->in_room && gch->in_room->area && !gch->in_room->area->clan)
            {
                area_found = FALSE;
                for (curr_expl_area = gch->pcdata->explored_areas ; curr_expl_area ; curr_expl_area=curr_expl_area->next)
                    if (!str_cmp (gch->in_room->area->name, curr_expl_area->name))
                    {
                        area_found = TRUE;
                        break;
                    }
                if (!area_found)
                {
                    curr_expl_area = new_char_explored_data () ;
                    curr_expl_area->name = str_dup (gch->in_room->area->name) ;
                    curr_expl_area->explored_room_count    = 0 ;
                    if (gch->pcdata->explored_areas)
                        curr_expl_area->next = gch->pcdata->explored_areas ;
                    gch->pcdata->explored_areas = curr_expl_area ;
                }
                if (IS_EVIL(victim))
                {
                    curr_expl_area->attitude_evil    -= 4;
                    curr_expl_area->attitude_good    += 2;
                    if (number_percent() > 50)
                        curr_expl_area->attitude_neutral += 1;
                    else
                        curr_expl_area->attitude_neutral -= 1;
                }
                else if (IS_GOOD(victim))
                {
                    curr_expl_area->attitude_evil    += 2;
                    curr_expl_area->attitude_good    -= 4;
                    curr_expl_area->attitude_neutral += 1 ;
                }
                else if (IS_NEUTRAL(victim))
                {
                    curr_expl_area->attitude_evil    -= 2;
                    if (number_percent() > 50)
                        curr_expl_area->attitude_evil += 1;
                    else
                        curr_expl_area->attitude_evil -= 1;
                    curr_expl_area->attitude_good    -= 2;
                    if (number_percent() > 50)
                        curr_expl_area->attitude_good += 1;
                    else
                        curr_expl_area->attitude_good -= 1;
                    curr_expl_area->attitude_neutral -= 4;
                }
                if (IS_IMMORTAL(gch))
                {
                    char_printf(gch, "New attitude for area %s: good = %d, neutral = %d, evil = %d\n",
                        gch->in_room->area->name, curr_expl_area->attitude_good, curr_expl_area->attitude_neutral, curr_expl_area->attitude_evil);
                }
            }
            // alignment changes
            // Welesh : commented out
            /*if (! (IS_NPC (gch) || (gch->in_war && gch->war_status == PS_ALIVE)
                   || IS_SET(gch->in_room->room_flags, ROOM_BATTLE_ARENA)))
            {
                int old_align = RALIGN(gch), new_align;

                // we change char's alignment
                if (IS_GOOD (victim) || (IS_NEUTRAL (victim) && (number_percent() > 50)))
                    gch->alignment -= 1;
                if (IS_EVIL (victim))
                    gch->alignment += 1;

                new_align = RALIGN(gch);
                if (new_align != old_align)
                    new_align_msg (gch, old_align, new_align);
            }*/
        }
    }

    if (!is_duel && !IS_NPC (victim))
    {
        if (IS_SAMURAI(victim))
        {
            if (is_affected(victim, gsn_dishonor))
                ++victim->pcdata->death;
        }
        else
            ++victim->pcdata->death;
    }

    raw_kill(ch, victim);

    /* RT new auto commands */
    if (!IS_NPC(ch) && vnpc
    && (corpse = get_obj_list(ch, "corpse", ch->in_room->contents)))
    {
        if (HAS_SKILL(ch, gsn_vampire))
        {
            act_puts("$n suck {Rblood{z from $N's corpse!!", ch, NULL, victim, TO_ROOM, POS_SLEEPING);
            char_act("You suck {Rblood{z from the corpse!!", ch);
            gain_condition(ch, COND_BLOODLUST, 3);
        } else if (IS_UNDEAD(ch))
        {
            act_puts("$n look much better, after kill!", ch, NULL, victim, TO_ROOM, POS_SLEEPING);
            char_act("You look much better now!!", ch);
            ch->hit  += corpse->level;
            ch->hit  =  UMIN(ch->hit,ch->max_hit);
            ch->mana += corpse->level * 2;
            ch->mana =  UMIN(ch->mana,ch->max_mana);
            ch->move += corpse->level / 2;
            ch->move =  UMIN(ch->move,ch->max_move);
        }

        if (IS_SET(ch->plr_flags, PLR_AUTOLOOK))
            do_look_in(ch, "corpse");
        if (corpse->contains)
        {
            /* corpse exists and not empty */
            if (IS_SET(ch->plr_flags, PLR_AUTOLOOT))
                do_get(ch, "all corpse");
            else if (IS_SET(ch->plr_flags, PLR_AUTOGOLD))
                get_gold_corpse(ch, corpse);
        }

        if (IS_SET(ch->plr_flags, PLR_AUTOSAC))
            do_sacrifice(ch, "corpse");
    }

    if (vnpc || victim->position == POS_STANDING)
        return;

    if (is_duel
    && !IS_SAMURAI(victim)
    && ((victim->pcdata != NULL) && !IS_NEWBIE(victim)))
    {
        if (victim->pcdata)
        {
            if (victim->pcdata->questpoints >= 10)
            {
                victim->pcdata->questpoints -= 10;
                char_act("The cost of this death for you is {Y10{y qp{x.", victim);
            } else
            {
                is_duel = FALSE;
                char_act("You've just died.", victim);
            }

        }
    }

    if (IS_NEWBIE(victim))
    {
        if (!is_duel)
            if ((victim->pcdata->death > 0) && ((victim->pcdata->death % 5) == 0))
            {
                --victim->perm_stat[STAT_CON];
                char_act("You feel your life power has decreased after 5th death.(HELP CONDEATH)", victim);
            }
    } else
    {
        if (IS_NPC(ch)
        && !IS_AFFECTED(victim, AFF_CHARM)
        && !IS_AFFECTED(ch, AFF_CHARM)
        && number_percent() > get_curr_stat(victim, STAT_LCK)
        && victim->level > 9)
        {
            switch (number_range(0,3))
            {
            case 0:
                penalty = "Strength";
                if (--victim->perm_stat[STAT_STR] < 3)
                    victim->perm_stat[STAT_STR] = 3;
                break;
            case 1:
                penalty = "Intelligence";
                if (--victim->perm_stat[STAT_INT] < 3)
                    victim->perm_stat[STAT_INT] = 3;
                break;
            case 2:
                penalty = "Wisdom";
                if (--victim->perm_stat[STAT_WIS] < 3)
                    victim->perm_stat[STAT_WIS] = 3;
                break;
            case 3:
                penalty = "Dexterity";
                if (--victim->perm_stat[STAT_DEX] < 3)
                    victim->perm_stat[STAT_DEX] = 3;
                break;
            }
            act_puts("You lose one point of {W$t{z.", victim, penalty, NULL, TO_CHAR | ACT_TRANS, POS_DEAD);
        } else
        {
            if (!is_duel && ((victim->pcdata->death > 0) && ((victim->pcdata->death % 3) == 0)) && victim->level > 9)
            {
                if (!IS_SAMURAI(victim))
                {
                    --victim->perm_stat[STAT_CON];
                    char_act("You feel your life power has decreased with this death. ({CHELP CONDEATH{x)", victim);
                }
            }
        }
    }

    if ((victim->perm_stat[STAT_CON] < 10) && (victim->pcdata != NULL))
    {
        delete_player(victim, "CON-death");
        return;
    }

    /* Dying penalty: 2/3 way back. */
    if (IS_SET(victim->plr_flags, PLR_WANTED) && victim->level > 1)
    {
        REMOVE_BIT(victim->plr_flags, PLR_WANTED);
        victim->level--;
        victim->pcdata->plevels++;
        victim->exp = exp_for_level(victim, victim->level);
        victim->exp_tl = 0;

        ++stat_record.criminals_killed;

    } else if (!is_duel)
    {
        if (victim->exp_tl > 0)
            gain_exp(victim, -victim->exp_tl*2/3);
    } else
    {
        if (victim->exp_tl > 0)
            gain_exp(victim, -victim->exp_tl/15);
    }

    /* Die too much and is deleted ... :( */

    if (IS_SAMURAI(victim))
    {
        if (victim->pcdata->death >= 25)
        {
            delete_player(victim, "25 deaths limit for Samurai");
            return;
        }
    }
}

bool cant_kill(CHAR_DATA *ch, CHAR_DATA *victim)
{
    int clan;
    /*
     * ghosts are safe
     * this check must be done first to avoid
     * suicyco muttafuckas who recite 'leather-bound book' (#5743)
     * without any target specified
     * extracted NPCs are safe too
     */

    char msg[MAX_INPUT_LENGTH];
    int i;

    if (!victim)
        return TRUE;

    // before all
    if (!IS_NPC(ch) && !IS_NPC(victim) && ch->in_war && (ch->in_war == victim->in_war)
    && !IS_SET (ch->in_war->flags, WS_PREPARING | WS_SET_PARMS)
    && (ch->war_status == PS_ALIVE) && (victim->war_status == PS_ALIVE))
        return FALSE;

    // area_guards can't be attacked by non-clan players
    for (i = 0; i < MAX_GUARD_COUNT; ++i)
    {
        if (victim->in_room && victim->in_room->area && (victim == victim->in_room->area->areaguards[i]))
        {
            if  (!ch->clan)
                return TRUE;
            else
            {
                if ((ch->clan != victim->clan) && (ch->fighting != victim))
                {
                    sprintf (msg, "{RAttention! Area %s {Ris attacked by %s{x!!!",
                        victim->in_room->area->name, ch->name);
                    do_clan (victim, msg);
                }
                return FALSE;
            }
        }
    }

    for (i = 0; i < MAX_ALTAR_COUNT; ++i)
    {
        if (victim->in_room && victim->in_room->area && (victim == victim->in_room->area->priests[i]))
        {
            if  ((!ch->clan) || victim->in_room->area->guards_left)
                return TRUE;
            else
            {
                if ((ch->clan != victim->clan) && (ch->fighting != victim))
                {
                    sprintf (msg, "Help! %s tries to demolish an altar in te area %s{x!!!",
                        ch->name, victim->in_room->area->name);
                    do_clan (victim, msg);
                }
                return FALSE;
            }
        }
    }

    if (!IS_NPC(victim))
    {
        if (IS_SET(victim->plr_flags, PLR_GHOST))
            return TRUE;
        if (ch != victim
        && !IS_NPC(ch)
        && IS_SET(ch->plr_flags, PLR_GHOST))
            return TRUE;
    } else if (victim->extracted)
        return TRUE;

    // GM : Ally can kill in ally clan_area
    if (ch != victim
    && !IS_NPC(victim)
    && (clan = victim->in_room->area->clan)
    && victim->clan != clan
    && (ch->clan == clan
    || CLAN(ch->clan)->diplomacy[clan] == DIP_ALLY))
        return FALSE;

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

    /* handle ROOM_PEACE flags */
    if ((victim->in_room
    && IS_SET(victim->in_room->room_flags, ROOM_PEACE))
    || (ch->in_room
    && IS_SET(ch->in_room->room_flags, ROOM_PEACE)))
        return TRUE;

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

    /* link dead players whose adrenalin is not gushing are safe */
    if (!IS_NPC(victim) && !IS_PUMPED(victim) && victim->desc == NULL)
        return TRUE;

    return !in_PK(ch, victim);
}

bool is_safe_nomessage(CHAR_DATA *ch, CHAR_DATA *victim)
{
    bool safe;
    CHAR_DATA *mount;

    if (IS_NPC(victim)
    &&  IS_SET(victim->affected_by, AFF_CHARM)
    &&  victim->master)
        return is_safe_nomessage(ch, victim->master);

    if (IS_NPC(ch)
    &&  IS_SET(ch->affected_by, AFF_CHARM)
    &&  ch->master)
        return is_safe_nomessage(ch->master, victim);

    if ((mount = RIDDEN(victim)))
        return is_safe_nomessage(ch, mount);

    if ((safe = cant_kill(ch, victim)))
        return safe;

    if (victim != ch && IS_SET(ch->plr_flags, PLR_GHOST))
    {
        char_act("You return to your normal form.", ch);
        REMOVE_BIT(ch->plr_flags, PLR_GHOST);
    }

    return safe;
}

bool is_safe(CHAR_DATA *ch, CHAR_DATA *victim)
{
    if (is_safe_nomessage(ch, victim))
    {
        act("The gods protect $N.", ch, NULL, victim, TO_CHAR);
        act("The gods protect $N from $n.", ch, NULL, victim, TO_ROOM);
        return TRUE;
    }
    return FALSE;
}

bool is_safe_spell(CHAR_DATA *ch, CHAR_DATA *victim, bool area)
{
#if 0
    if (ch == victim && !area)
        return TRUE;
#endif
    if (area)
    {
        if (IS_IMMORTAL(victim)
        || is_same_group(ch, victim)
        || (RIDDEN(victim) && is_same_group(ch, victim->mount))
        || ch == victim
        || RIDDEN(ch) == victim
        || MOUNTED(ch) == victim)
            return TRUE;
    }

    return is_safe(ch, victim);
}

/*
 * Check for parry.
 */
bool check_parry(CHAR_DATA *ch, CHAR_DATA *victim, int loc)
{
    int chance;//, wchance, schance; // removed automated shield and weapon cleave
    OBJ_DATA *wield, *wield2; //, *cobj;

    if (!IS_AWAKE(victim))
        return FALSE;

    wield = get_eq_char(victim, WEAR_WIELD);
    wield2 = get_eq_char(victim, WEAR_SECOND_WIELD);

    if (IS_NPC(victim))
        chance  = UMIN(35, LVL(victim));
    else
    {
        if (wield == NULL)
            return FALSE;
        chance = get_skill(victim, gsn_parry) / 2;
        if (wield && wield2 && wield->value[0] == WEAPON_SWORD
        && wield2->value[0] == WEAPON_SWORD)
            chance += get_skill(victim, gsn_flourentine) / 4;

        if (wield && wield->value[0] == WEAPON_SWORD)
            chance += get_skill(victim, gsn_mastering_sword) / 6;

        if (victim->stance != STANCE_NORMAL)
        {
            if (number_percent() < get_skill(victim,gsn_stance))
            {
                if (victim->stance == STANCE_DEFENSE)
                    chance += 10;
                else if (victim->stance == STANCE_DEFENSE_II)
                    chance += 20;
                else if (victim->stance == STANCE_OFFENSE)
                    chance  -= 10;
                else
                    chance -= 20;
            }
            else
                check_improve(victim, gsn_stance, FALSE, 4);
        }
    }

    if (IS_AFFECTED(victim, AFF_BLIND))
    {
        chance -= chance / 3;
        chance += chance * get_skill(victim, gsn_blind_fighting) / 300;
    }

    if (IS_AFFECTED(ch, AFF_HASTE))     chance -= 5;
    if (IS_AFFECTED(ch, AFF_SLOW))      chance += 10;
    if (IS_AFFECTED(victim, AFF_HASTE)) chance += 5;
    if (IS_AFFECTED(victim, AFF_SLOW))  chance -= 5;

    if (is_affected(victim, gsn_bash))  chance = chance * 2 / 3;
    if (is_affected(victim, gsn_throw)) chance = chance * 3 / 4;
    if (is_affected(victim, gsn_trip))  chance = chance * 4 / 5;

    if (check_forest_fighting(victim) == FOREST_DEFENCE
    && (number_percent() < get_skill(victim, gsn_forest_fighting)))
    {
        chance = chance * 120 / 100;
        check_improve (victim, gsn_forest_fighting, TRUE, 7);
    }

    if (number_percent() < get_skill(victim, gsn_mount_control)
    && MOUNTED(victim))
    {
        chance = chance * 120 / 100;
        check_improve (victim, gsn_mount_control, TRUE, 7);
    }

    if (number_percent() < get_skill(victim, gsn_mount_fighting)
    && MOUNTED(victim))
    {
        chance = chance * 140 / 100;
        check_improve (victim, gsn_mount_fighting, TRUE, 7);
    }

    if (number_percent() < get_skill(victim, gsn_thumbling))
    {
        chance = chance * 130 / 100;
        check_improve (victim, gsn_thumbling, TRUE, 7);
    }

    if (is_affected(victim, sn_lookup("combat mind")))
        chance = chance * 13/10;

    if (is_affected(ch, sn_lookup("combat mind")))
        chance = chance * 10/13;

    // ADV FURY
    if (is_affected(ch, gsn_adv_fury))
    {
        chance /= 10;
        check_improve(ch, gsn_adv_fury, TRUE, 6);
    }

    chance += LVL(victim) - LVL(ch);
    chance = URANGE(10, chance, 80);

    if (number_percent() >= chance)
        return FALSE;

    act("You parry $n's attack.", ch, NULL, victim, TO_VICT | ACT_VERBOSE);
    act("$N parries your attack.", ch, NULL, victim, TO_CHAR | ACT_VERBOSE);


/*    // GM : weapon and shield cleave
    wchance = get_skill(victim, gsn_weapon_cleave) / 10;

    if (HAS_SKILL(victim, gsn_weapon_cleave)
    && (cobj = get_eq_char(ch, WEAR_WIELD)) != NULL)
    {
        wchance += get_curr_stat(victim, STAT_DEX) + get_curr_stat(victim, STAT_STR);
        wchance -= get_curr_stat(ch, STAT_STR) + get_curr_stat(ch, STAT_DEX);
        wchance += LVL(victim) - LVL(ch);
        wchance += cobj->level - wield->level;

        if (IS_NPC(ch))
        {
            if (IS_AFFECTED(ch, AFF_CHARM))
                wchance += 15;
            else
                wchance += 10;
        }

        if (IS_OBJ_STAT(cobj, ITEM_HIDURABILITY))
            wchance /= 10;

        if (cobj->pIndexData->limit != -1
        || IS_OBJ_STAT(cobj, ITEM_INDESTRUCTABLE)
        || IS_SET(cobj->pIndexData->extra_flags, ITEM_QUEST))
            wchance = 0;

        if (wield)
        {
            if (wield->value[0] != WEAPON_AXE)
                wchance /= 2;
            if (wield->value[0] != WEAPON_SWORD
            && wield->value[0] != WEAPON_AXE)
                wchance = 0;
        }

        if (ch->in_war && ch->war_status == PS_ALIVE)
            wchance = 0;

        if (number_percent() < wchance)
        {
            act("ôÙ ÓÒÕÂÁÅÛØ ÏÒÕÖÉÅ $N Õ ÓÁÍÏÊ ÒÕËÏÑÔÉ.", victim, NULL, ch, TO_CHAR);
            act("$n ÓÒÕÂÁÅÔ Ô×ÏÅ ÏÒÕÖÉÅ Õ ÓÁÍÏÊ ÒÕËÏÑÔÉ.", victim, NULL, ch, TO_VICT);
            act("$n ÓÒÕÂÁÅÔ ÏÒÕÖÉÅ $N Õ ÓÁÍÏÊ ÒÕËÏÑÔÉ.", victim, NULL, ch, TO_NOTVICT);
            check_improve(victim, gsn_weapon_cleave, TRUE, 1);
            extract_obj(get_eq_char(ch, WEAR_WIELD));
        } else
        {
            check_improve(victim, gsn_weapon_cleave, FALSE, 1);
        }
    }

    schance = get_skill(victim, gsn_shield_cleave) / 10;

    if (HAS_SKILL(victim, gsn_shield_cleave)
    && (cobj = get_eq_char(ch, WEAR_SHIELD)) != NULL)
    {
        schance += get_curr_stat(victim, STAT_DEX) + get_curr_stat(victim, STAT_STR);
        schance -= get_curr_stat(ch, STAT_STR) + get_curr_stat(ch, STAT_DEX);
        schance += LVL(victim) - LVL(ch);
        schance += cobj->level - wield->level;

        if (IS_NPC(ch))
        {
            if (IS_AFFECTED(ch, AFF_CHARM))
                schance += 15;
            else
                schance += 10;
        }

        if (IS_OBJ_STAT(cobj, ITEM_HIDURABILITY))
            schance /= 10;

        if (cobj->pIndexData->limit != -1
        || IS_OBJ_STAT(cobj, ITEM_INDESTRUCTABLE)
        || check_material(cobj, "titanium")
        || IS_SET(cobj->pIndexData->extra_flags, ITEM_QUEST))
            schance = 0;

        if (wield)
        {
            if (wield->value[0] != WEAPON_AXE)
                schance /= 2;
            if (wield->value[0] != WEAPON_SWORD
            && wield->value[0] != WEAPON_AXE)
                schance = 0;
        }

        if (ch->in_war && ch->war_status == PS_ALIVE)
            schance = 0;

        if (number_percent() < schance)
        {
            act("ôÙ ÒÁÚÂÉ×ÁÅÛØ ÝÉÔ $N.", victim, NULL, ch, TO_CHAR);
            act("$n ÒÁÚÂÉ×ÁÅÔ Ô×ÏÊ ÝÉÔ.",victim, NULL, ch, TO_VICT);
            act("$n ÒÁÚÂÉ×ÁÅÔ ÝÉÔ $N.", victim, NULL, ch, TO_NOTVICT);
            check_improve(victim, gsn_shield_cleave, TRUE, 1);
            extract_obj(get_eq_char(ch, WEAR_SHIELD));
        } else
        {
            check_improve(victim, gsn_shield_cleave, FALSE, 1);
        }
    }*/

    check_weapon_damage(ch, victim, loc);

    if (number_percent() >  get_skill(victim, gsn_parry))
    {
        //ÐÒÏ×ÅÒËÕ ÎÁ ×ÅÓ ×ÏÏÂÝÅ ÕÂÉÒÁÅÍ .. ÓÌÉÛËÏÍ ÎÅÏÄÎÏÚÎÁÞÎÏ
        /* size */
        if (ch->size < victim->size)
            chance += (ch->size - victim->size) * 3;
        else
            chance += (ch->size - victim->size) * 7 / 5;

        /* stats */
        chance += get_curr_stat(ch, STAT_STR);
        chance -= get_curr_stat(victim, STAT_DEX) * 4/3;

        if (IS_AFFECTED(ch, AFF_FLYING))
            chance -= 10;

        /* speed */
        if (IS_NPC(ch) && IS_SET(ch->pIndexData->off_flags, OFF_FAST))
            chance += 10;
        if (IS_NPC(victim) && IS_SET(victim->pIndexData->off_flags, OFF_FAST))
            chance -= 20;

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

        /* now the attack */
        if (number_percent() < (chance / 20 ))
        {
            act("You couldn't manage to keep your position!", ch, NULL, victim, TO_VICT | ACT_VERBOSE);
            act("You fall down!", ch, NULL, victim, TO_VICT | ACT_VERBOSE);
            act("$N couldn't manage to hold your attack and falls down!", ch, NULL, victim, TO_CHAR | ACT_VERBOSE);
            act("$n stunning force makes $N falling down.", ch, NULL, victim, TO_NOTVICT | ACT_VERBOSE);

            DAZE_STATE(victim, PULSE_VIOLENCE * number_range(1, 3));
            victim->position = POS_RESTING;
        }
    }

    check_improve(victim, gsn_parry, TRUE, 6);
    if (!IS_NPC(victim) && wield != NULL && wield2 != NULL
    && wield->value[0] == WEAPON_SWORD
    && wield2->value[0] == WEAPON_SWORD)
        check_improve(victim, gsn_flourentine, TRUE, 6);
    return TRUE;
}

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

    if (!is_affected(victim, gsn_shield)
    || get_eq_char(victim, WEAR_SHIELD) != NULL)
        return FALSE;

    if (number_percent() > 5 + affect_level(victim, gsn_shield)/8 -
        (LVL(ch) - LVL(victim))/3)
        return FALSE;

    act("íÁÇÉÞÅÓËÉÊ ÝÉÔ ÐÅÒÅÄ ÔÏÂÏÊ ÏÔÒÁÖÁÅÔ ÁÔÁËÕ $c1{$n}.",  ch, NULL, victim, TO_VICT | ACT_VERBOSE);
    act("íÁÇÉÞÅÓËÉÊ ÝÉÔ ÐÅÒÅÄ $c4{$N} ÏÔÒÁÖÁÅÔ Ô×ÏÀ ÁÔÁËÕ.", ch, NULL, victim, TO_CHAR | ACT_VERBOSE);
    return TRUE;
}

bool check_towershield(CHAR_DATA *ch, CHAR_DATA *victim)
{
    int chance;
    int sn = sn_lookup("tower shield");

    if (!check_tattoo (ch, sn)
        || get_eq_char(victim, WEAR_SHIELD) != NULL)
        return FALSE;

    chance = get_skill (ch, sn)/10 -  (LVL(ch) - LVL(victim))/3;
    chance = URANGE(5, chance, 10);

    if (number_percent() > chance)
        return FALSE;

    act("íÁÇÉÞÅÓËÉÊ ÝÉÔ ÐÅÒÅÄ ÔÏÂÏÊ ÏÔÒÁÖÁÅÔ ÁÔÁËÕ $c1{$n}.",  ch, NULL, victim, TO_VICT | ACT_VERBOSE);
    act("íÁÇÉÞÅÓËÉÊ ÝÉÔ ÐÅÒÅÄ $c4{$N} ÏÔÒÁÖÁÅÔ Ô×ÏÀ ÁÔÁËÕ.", ch, NULL, victim, TO_CHAR | ACT_VERBOSE);
    return TRUE;
}

/*
 * check blink
 */
bool check_blink(CHAR_DATA *ch, CHAR_DATA *victim)
{
    int chance;

    if (!IS_NPC (victim) && !IS_SET(victim->plr_flags, PLR_BLINK))
        return FALSE;

    if (IS_NPC(victim))
    {
        if (IS_SET (victim->abilities, EA_BLINK))
            chance = 25;
        else
            return FALSE;
    }
    else
        chance = get_skill(victim, gsn_blink) / 2;

    if (is_affected(victim, gsn_bash)) chance = chance * 2 / 3;
    if (is_affected(victim, gsn_throw)) chance = chance * 3 / 4;
    if (is_affected(victim, gsn_trip)) chance = chance * 4 / 5;

    if (chance != 0)
        chance += LVL(victim) - LVL(ch);
    chance += get_skill(victim, gsn_blur) / 3;
    check_improve(victim, gsn_blur, TRUE, 1);

    if (number_percent() >= chance
    || victim->mana < 10)
        return FALSE;
    if (check_perception(ch, victim))
        return FALSE;

    victim->mana -= UMAX(LVL(victim) / 10, 1);

    act("You blink out $n's attack.", ch, NULL, victim, TO_VICT);
    act("$N blinks out your attack.", ch, NULL, victim, TO_CHAR);

    check_improve(victim, gsn_blink, TRUE, 4);
    return TRUE;
}

/*
 * Check for shield block.
 */
bool check_block(CHAR_DATA *ch, CHAR_DATA *victim, int loc)
{
    int chance;

    if (!IS_AWAKE(victim))
        return FALSE;

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

    if (IS_NPC(victim))
        chance = 10;
    else
    {
        if (get_skill(victim,gsn_shield_block) <= 1)
            return FALSE;
        chance = get_skill(victim,gsn_shield_block) / 2;
        chance -= (victim->class == CLASS_WARRIOR) ? 0 : 10;
    }

    if (IS_AFFECTED(victim, AFF_BLIND))
    {
        chance -= chance / 3;
        chance += chance * get_skill(victim, gsn_blind_fighting) / 300;
    }

    if (IS_AFFECTED(ch, AFF_HASTE))       chance -= 5;
    if (IS_AFFECTED(ch, AFF_SLOW))        chance += 5;
    if (IS_AFFECTED(victim, AFF_HASTE))   chance += 5;
    if (IS_AFFECTED(victim, AFF_SLOW))    chance -= 5;

    if (is_affected(victim, gsn_bash)) chance = chance * 2 / 3;
    if (is_affected(victim, gsn_throw)) chance = chance * 3 / 4;
    if (is_affected(victim, gsn_trip)) chance = chance * 4 / 5;

    if (check_forest_fighting(victim) == FOREST_DEFENCE
    && (number_percent() < get_skill(victim, gsn_forest_fighting)))
    {
        chance = chance * 6/5;
        check_improve (victim, gsn_forest_fighting, TRUE, 7);
    }

    if (MOUNTED(victim))
        chance = chance * 6/5;

    if (number_percent() < get_skill(victim, gsn_mount_control)
        && MOUNTED(victim))
    {
        chance = chance * 120 / 100;
        check_improve (victim, gsn_mount_control, TRUE, 7);
    }

    if (number_percent() < get_skill(victim, gsn_mount_fighting)
        && MOUNTED(victim))
    {
        chance = chance * 140 / 100;
        check_improve (victim, gsn_mount_fighting, TRUE, 7);
    }

    if (is_affected(victim, sn_lookup("combat mind")))
    chance = chance * 6/5;

    if (is_affected(victim, sn_lookup("combat mind")))
    chance = chance * 5/6;

    chance = URANGE(5, chance, 80);

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

    act("Your shield blocks $n's attack.", ch, NULL, victim, TO_VICT);
    act("$N deflects your attack with $gN{his} shield.", ch, NULL, victim, TO_CHAR);
    check_shield_damage(ch, victim, loc);
    check_improve(victim, gsn_shield_block, TRUE, 6);
    return TRUE;
}

/* check for stand off skill */
bool check_stand_off(CHAR_DATA *ch, CHAR_DATA *victim)
{
    int chance;
    OBJ_DATA *obj1;

    obj1 = get_eq_char(victim, WEAR_WIELD);

    if (!IS_AWAKE(victim))
        return FALSE;

    if (IS_NPC(victim))
        return FALSE;


    if (!obj1)
        return FALSE;


    if ((obj1->value[0] != WEAPON_SPEAR) &&
        (obj1->value[0] != WEAPON_POLEARM) &&
        (obj1->value[0] != WEAPON_LANCE))
        return FALSE;

    chance = get_skill(victim, gsn_stand_off) / 2;

    if (chance == 0)
        return FALSE;

    /* chance for high dex // not only victim's.. *grin* :E*/
    chance += 4 * (get_curr_stat(victim,STAT_DEX)
                   - get_curr_stat(victim,STAT_DEX));

    if (victim->stance != STANCE_NORMAL)
    {
        if (number_percent() < get_skill(victim,gsn_stance))
        {
            check_improve(victim,gsn_stance,TRUE,6);
            if (victim->stance == STANCE_DEFENSE)
                chance += 10;
            else if (victim->stance == STANCE_DEFENSE_II)
                chance  += 20;
            else if (victim->stance == STANCE_OFFENSE)
                chance = -10;
            else if (victim->stance == STANCE_OFFENSE_II)
                chance = -20;
        }
    }

    if (MOUNTED(victim))
    {
        chance += 5;
        // it's harder to parry small character when mounted
        // so as it's easier to parry bigger
        chance += (ch->size - victim->size) * 5;

        if (number_percent() < get_skill(victim, gsn_mount_control))
        {
            chance += 5;
            check_improve (victim, gsn_mount_control, TRUE, 6);
        }

        if (number_percent() < get_skill(victim, gsn_mount_fighting))
        {
            chance += 10;
            check_improve (victim, gsn_mount_fighting, TRUE, 6);
        }
    }
    else
    {
        // and it just a lil'bit easier to parry when not mounted
        chance += (ch->size - victim->size) * 2;
    }

    if (IS_AFFECTED(ch,AFF_HASTE))       chance -= 5;
    if (IS_AFFECTED(ch,AFF_SLOW))        chance += 10;
    if (IS_AFFECTED(victim,AFF_HASTE))   chance += 5;
    if (IS_AFFECTED(victim,AFF_SLOW))    chance -= 5;

    chance = URANGE(5, chance, 80);

    if (number_percent() >= chance + (LVL(victim) - LVL(ch)) / 2)
    {
        check_improve(victim, gsn_stand_off, FALSE, 4);
        return FALSE;
    }

    act("ó×ÏÉÍ ÏÒÕÖÉÅÍ ÔÙ ÕÄÅÒÖÉ×ÁÅÛØ $n ÎÁ ÒÁÓÓÔÏÑÎÉÉ.", ch, NULL,
        victim, TO_VICT);
    act("ó×ÏÉÍ ÏÒÕÖÉÅÍ $N ÕÄÅÒÖÉ×ÁÅÔ ÔÅÂÑ ÎÁ ÒÁÓÓÔÏÑÎÉÉ", ch, NULL, victim,
        TO_CHAR);

    check_improve(victim, gsn_stand_off, TRUE, 6);
    return TRUE;

}

/*
 * Check for dodge.
 */
bool check_dodge(CHAR_DATA *ch, CHAR_DATA *victim)
{
    int chance, val;
    race_t *r;
    class_t *cl;

    if (!IS_AWAKE(victim))
        return FALSE;

    if (MOUNTED(victim))
        return FALSE;

    if (IS_NPC(victim))
        chance  = UMIN(30, LVL(victim));
    else
    {
        chance  = get_skill(victim, gsn_dodge) / 2;

        // GM : ÷ÏÔËÎ£Í ÒÁÓÏ×ÙÊ-ËÌÁÓÓÏ×ÙÊ ÄÏÄÖ ÏÔ äÏÍÉÎÉ.
        // GM : ñ ÐÏËÁ ÒÜÄÖ ÓÄÅÌÁÀ 20. ðÏÔÏÍ ÄÏÏÂÓÕÄÉÍ.

        if ((cl = class_lookup(victim->class)) != NULL)
        {
            if (cl->dodge)
                chance += cl->dodge / 2;
        }

//        r = RACE(ORG_RACE(victim));
        r = RACE(victim->race);

        if (r->dodge)
            chance += r->dodge / 2;

        /* chance for high dex. */
        chance += 2 * (get_curr_stat(victim, STAT_DEX) - 20);
        chance += 2 * (ch->size - victim->size);

        if (victim->class == CLASS_THIEF || victim->class == CLASS_NINJA)
            chance = chance * 11 / 10;

        if (IS_SET(victim->form, FORM_VAMPIRE))
            chance = get_skill(victim, gsn_dodge) * 3 / 5;
        else if (IS_SET(ch->form, FORM_VAMPIRE))
            chance = chance * 3 / 5;
        if (is_affected(victim, sn_lookup("mind focusing")))
            chance += 5;

        if (victim->stance != STANCE_NORMAL)
        {
            if (number_percent() < get_skill(victim, gsn_stance))
            {
                check_improve(victim, gsn_stance, TRUE, 6);
                if (victim->stance == STANCE_DEFENSE)
                    chance += 10;
                else if (victim->stance == STANCE_DEFENSE_II)
                    chance  += 20;
                else if (victim->stance == STANCE_OFFENSE)
                    chance = -10;
                else if (victim->stance == STANCE_OFFENSE_II)
                    chance = -20;
            }
        }
    }

    if (IS_AFFECTED(victim, AFF_BLIND))
    {
        chance -= chance/3;
        chance += chance * get_skill(victim, gsn_blind_fighting) / 300;
    }

    if (IS_AFFECTED(ch, AFF_HASTE))       chance -= 5;
    if (IS_AFFECTED(ch, AFF_SLOW))        chance += 10;
    if (IS_AFFECTED(victim, AFF_HASTE))   chance += 10;
    if (IS_AFFECTED(victim ,AFF_SLOW))    chance -= 15;

    if (is_affected(victim, gsn_bash))    chance = chance * 2 / 3;
    if (is_affected(victim, gsn_throw))   chance = chance * 3 / 4;
    if (is_affected(victim, gsn_trip))    chance = chance * 4 / 5;

    if (check_forest_fighting(victim) == FOREST_DEFENCE
    && (get_skill(victim, gsn_forest_fighting) > number_percent()))
    {
        chance = chance * 6/5;
        check_improve (victim, gsn_forest_fighting, TRUE, 7);
    }

    if (number_percent () < get_skill (victim, gsn_thumbling))
    {
        chance = chance * 13 / 10 ;
        check_improve (victim, gsn_thumbling, TRUE, 7);
    }

    if (number_percent () < get_skill (victim, gsn_awareness))
    {
        chance = chance * 12 / 10 ;
        check_improve (victim, gsn_awareness, TRUE, 7);
    }

    if (is_affected(victim, sn_lookup("combat mind")))
    {
        chance = chance * 11 / 10;
        if (is_affected(victim, sn_lookup("mind focusing")))
            chance = chance * 13 / 11;
    }

    if (is_affected(ch, sn_lookup("combat mind")))
    {
        chance = chance * 10 / 11;
        if (is_affected(ch, sn_lookup("mind focusing")))
            chance = chance * 11 / 13;
    }

    chance += (LVL(victim) - LVL(ch)) / 2;

    if ((val = get_skill(ch, gsn_perception)) > 0)
    {
        if (number_percent() > val / 4)
        {
            check_improve(ch, gsn_perception, TRUE, 4);
            if (number_percent() < val / 3)
                chance -= number_range(0, ch->level / 3);
            else
                chance -= number_range(0, ch->level / 4);
        }
        else
            check_improve(ch, gsn_perception, FALSE, 3);
    }

    if (!IS_NPC(ch) && ch->pcdata && ch->pcdata->security == 1)
        char_printf(ch, "ch dodge : chance = %d", chance);
    if (!IS_NPC(victim) && victim->pcdata && victim->pcdata->security == 1)
        char_printf(victim, "victim dodge : chance = %d", chance);

    if (!IS_NPC (victim))
    {
        if (!is_class_warrior(victim) && is_class_mage(victim))
            chance = URANGE(5, chance, 60);
        else if (is_class_warrior(victim) && is_class_mage(victim))
            chance = URANGE(5, chance, 70);
        else if (is_class_warrior(victim) && !is_class_mage(victim))
            chance = URANGE(5, chance, 80);
        else
            chance = URANGE(5, chance, 70);
    }
    else
        chance = URANGE(5, chance, 80);

    if (is_contacted(ch, victim))
        chance /= 10;

    if (number_percent() >= chance)
        return FALSE;

    act("You dodge $n's attack.", ch, NULL, victim, TO_VICT | ACT_VERBOSE);
    act("$N dodges your attack.", ch, NULL, victim, TO_CHAR | ACT_VERBOSE);
//    act("You dodge $n's attack.", ch, NULL, victim, TO_VICT);
//    act("$N dodges your attack.", ch, NULL, victim, TO_CHAR);

    if (number_percent() < get_skill(victim,gsn_dodge) / 20
    && !(IS_AFFECTED(ch, AFF_FLYING) || ch->position < POS_FIGHTING))
    {
        /* size */
        if (victim->size < ch->size)
            /* bigger = harder to trip */
            chance += (victim->size - ch->size) * 2;

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

        if (IS_AFFECTED(victim, AFF_FLYING))
            chance -= 10;

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

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

        /* now the attack */
        if (number_percent() < (chance / 20))
        {
            act("$n lost his postion and fall down!",  ch, NULL, victim, TO_VICT);
            act("As $N moves you lost your position fall down!", ch, NULL, victim, TO_CHAR);
            act("As $N dodges $n's attack, $n lost his position and falls down.", ch, NULL, victim, TO_NOTVICT);

            DAZE_STATE(ch, PULSE_VIOLENCE * number_range(1, 3));
            ch->position = POS_RESTING;
        }
    }
    check_improve(victim, gsn_dodge, TRUE, 6);
    return TRUE;
}

bool check_hand_block(CHAR_DATA *ch, CHAR_DATA *victim)
{
    int chance;
    OBJ_DATA *wield;
    OBJ_DATA *swield;

    if (!IS_AWAKE(victim)
    || IS_NPC(victim)
    || ((chance=get_skill(victim, gsn_hand_block)) <= 0))
        return FALSE;

    if (get_eq_char(victim, WEAR_WIELD)
    || get_eq_char(victim, WEAR_SECOND_WIELD)
    || get_eq_char(victim, WEAR_HOLD)
    || get_eq_char(victim, WEAR_SHIELD))
        return FALSE;

    chance /= 3;

    if (get_eq_char(victim, WEAR_WIELD))
        chance -= 10;
    if (get_eq_char(victim, WEAR_SECOND_WIELD))
        chance -= 10;
    if (get_eq_char(victim, WEAR_HOLD))
        chance -= 5;
    if (get_eq_char(victim, WEAR_SHIELD))
        chance -= 5;

    if (victim->style)
    {
        if (victim->style == STYLE_IRONBODY)
            chance += 10;
        if (victim->style == STYLE_DRUNKMAN)
            chance -= 20;
    }

    chance += LVL(victim) - LVL(ch);
    chance += 2 * (get_curr_stat(victim, STAT_DEX) - get_curr_stat(ch, STAT_DEX));
    if (victim->stance != STANCE_NORMAL)
    {
        if (number_percent() < get_skill(victim, gsn_stance))
        {
            check_improve(victim, gsn_stance, TRUE, 6);
            if (victim->stance == STANCE_DEFENSE)
                chance += 40;
            else if (victim->stance == STANCE_DEFENSE_II)
                chance += 20;
            else if (victim->stance == STANCE_OFFENSE)
                chance -= 10;
            else if (victim->stance == STANCE_OFFENSE_II)
                chance -= 20;
        }
    }

    if (IS_AFFECTED(victim, AFF_BLIND))
    {
        chance -= chance / 3;
        chance += chance * get_skill(victim, gsn_blind_fighting) / 300;
    }

    if (IS_AFFECTED(ch, AFF_HASTE))     chance -= 5;
    if (IS_AFFECTED(ch, AFF_SLOW))      chance += 10;
    if (IS_AFFECTED(victim, AFF_HASTE)) chance += 5;
    if (IS_AFFECTED(victim, AFF_SLOW))  chance -= 5;


    if (is_affected(victim, gsn_bash))  chance = chance * 2 / 3;
    if (is_affected(victim, gsn_throw)) chance = chance * 3 / 4;
    if (is_affected(victim, gsn_trip))  chance = chance * 4 / 5;

    if (number_percent() < get_skill(victim, gsn_thumbling))
    {
        chance = chance * 3 / 2;
        check_improve (victim, gsn_thumbling, TRUE, 7);
    }

    if (is_affected(victim, sn_lookup("mind focusing")))
        chance = chance * 4 / 3;
    if (is_affected(victim, sn_lookup("combat mind")))
        chance = chance * 4 / 3;
    if (is_affected(ch, sn_lookup("combat mind")))
        chance = chance * 4 / 5;

    chance = URANGE(5, chance, 80);

    if (number_percent() < chance)
    {
        // GM : aikido skill
        if (number_range(0, 9000) < get_skill(victim, sn_lookup("aikido")))
        {
            act("Your hand blocks $n's attack and use aikido power.", ch, NULL, victim, TO_VICT);
            act("$N blocks your attack with $gN{his} hand and use aikido power.", ch, NULL, victim, TO_CHAR);
            DAZE_STATE(ch, PULSE_VIOLENCE * 2);
            check_improve(victim, sn_lookup("aikido"), TRUE, 1);
        }
        else
        {
            act("Your hand blocks $n's attack.", ch, NULL, victim, TO_VICT);
            act("$N blocks your attack with $gN{his} hand.", ch, NULL, victim, TO_CHAR);
            check_improve(victim, sn_lookup("aikido"), FALSE, 4);
        }

        check_improve(victim, gsn_hand_block, TRUE, 1);
        // GM : code for auto-disarm
        if (number_percent() < 99 || (wield = get_eq_char(ch, WEAR_WIELD)) == NULL)
            return TRUE;
        chance = get_skill(victim, gsn_disarm) / 3;
        chance += get_skill(victim, sn_lookup("aikido")) / 20;
        chance += get_skill(victim, gsn_hand_to_hand) - get_weapon_skill(ch, get_weapon_sn(wie

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

Site Stats

Snippets: 1791
Codebases: 571