fight.c
Tartarus/src/fight.c · 258.6 KB
From the archive tartarus.tgz
Download the archive « Back to the archive contents
/***************************************************************************
* Original Diku Mud copyright (C) 1990, 1991 by Sebastian Hammer, *
* Michael Seifert, Hans Henrik St{rfeldt, Tom Madsen, and Katja Nyboe. *
* *
* Merc Diku Mud improvments copyright (C) 1992, 1993 by Michael *
* Chastain, Michael Quan, and Mitchell Tse. *
* *
* In order to use any part of this Merc Diku Mud, you must comply with *
* both the original Diku license in 'license.doc' as well the Merc *
* license in 'license.txt'. In particular, you may not remove either of *
* these copyright notices. *
* *
* Much time and thought has gone into this software and you are *
* benefitting. We hope that you share your changes too. What goes *
* around, comes around. *
***************************************************************************/
/***************************************************************************
* ROM 2.4 is copyright 1993-1996 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 Tartarus/doc/rom.license *
***************************************************************************/
/***************************************************************************
* Tartarus code is copyright (C) 1997-1998 by Daniel Graham *
* In using this code you agree to comply with the Tartarus license *
* found in the file /Tartarus/doc/tartarus.doc *
***************************************************************************/
#if defined(macintosh)
#include <types.h>
#else
#include <sys/types.h>
#endif
#include <stdio.h>
#include <string.h>
#include <time.h>
#include "merc.h"
#define HITS (dt==gsn_kick||dt==gsn_lunge||dt==gsn_downstrike||dt==gsn_throw||dt==gsn_crush||dt==gsn_bash)
/* command procedures needed */
DECLARE_DO_FUN(do_quit);
DECLARE_DO_FUN(do_say);
DECLARE_DO_FUN(do_backstab );
DECLARE_DO_FUN(do_emote );
DECLARE_DO_FUN(do_ambush );
DECLARE_DO_FUN(do_berserk );
DECLARE_DO_FUN(do_deathstyle );
DECLARE_DO_FUN(do_bash );
DECLARE_DO_FUN(do_trip );
DECLARE_DO_FUN(do_dirt );
DECLARE_DO_FUN(do_flee );
DECLARE_DO_FUN(do_kick );
DECLARE_DO_FUN(do_disarm );
DECLARE_DO_FUN(do_get );
DECLARE_DO_FUN(do_recall );
DECLARE_DO_FUN(do_yell );
DECLARE_DO_FUN(do_myell );
DECLARE_DO_FUN(do_sacrifice );
DECLARE_DO_FUN(do_circle_stab );
DECLARE_DO_FUN(do_battlecry );
DECLARE_DO_FUN(do_steel_nerves );
DECLARE_DO_FUN(do_breath_morph );
DECLARE_DO_FUN(do_look);
DECLARE_DO_FUN(do_crush);
DECLARE_DO_FUN(do_tail );
DECLARE_DO_FUN(do_undead_drain);
DECLARE_SPELL_FUN(spell_evil_eye);
DECLARE_SPELL_FUN(spell_power_word_kill);
/*
* Local functions.
*/
void check_downstrike args( (CHAR_DATA *ch, CHAR_DATA *victim) );
void check_assist args( ( CHAR_DATA *ch, CHAR_DATA *victim ) );
bool check_dodge args( ( CHAR_DATA *ch, CHAR_DATA *victim, int dt ) );
bool check_block args( ( CHAR_DATA *ch, CHAR_DATA *victim, int dt ) );
void check_killer args( ( CHAR_DATA *ch, CHAR_DATA *victim ) );
bool check_parry args( ( CHAR_DATA *ch, CHAR_DATA *victim, int dt ) );
bool check_shield_block args( ( CHAR_DATA *ch, CHAR_DATA *victim, int dt ) );
void dam_message args( ( CHAR_DATA *ch, CHAR_DATA *victim, int dam,
int dt, bool immune ) );
void death_cry args( ( CHAR_DATA *ch ) );
void group_gain args( ( CHAR_DATA *ch, CHAR_DATA *victim ) );
int xp_compute args( ( CHAR_DATA *gch, CHAR_DATA *victim,
int group_amount, int glevel ) );
bool is_safe args( ( CHAR_DATA *ch, CHAR_DATA *victim ) );
void make_corpse args( ( CHAR_DATA *killer, CHAR_DATA *ch ) );
void one_hit args( ( CHAR_DATA *ch, CHAR_DATA *victim, int dt ));
void mob_hit args( ( CHAR_DATA *ch, CHAR_DATA *victim, int dt ) );
void raw_kill args( ( CHAR_DATA *ch, CHAR_DATA *victim ) );
void set_fighting args( ( CHAR_DATA *ch, CHAR_DATA *victim ) );
void disarm args( ( CHAR_DATA *ch, CHAR_DATA *victim ) );
int battlecry_multiplier args( ( CHAR_DATA *ch, int dt) );
void do_counter_parry args( (CHAR_DATA *ch,CHAR_DATA *victim, int dt,int dam) );
void check_ground_control args( (CHAR_DATA *ch,CHAR_DATA *victim,int
chance,int dam) );
void check_ranger_staff args( (CHAR_DATA *ch,OBJ_DATA *wield) );
void check_outlaw_badge args( (CHAR_DATA *ch) );
bool check_counter args( (CHAR_DATA *ch,CHAR_DATA *victim, int dam,int dt) );
bool check_palm args( (CHAR_DATA *ch ) );
void check_follow_through args( ( CHAR_DATA *ch, CHAR_DATA *victim,
int dam) );
bool check_roll args( (CHAR_DATA *ch,CHAR_DATA *victim,int dt) );
void check_red_shield args(( CHAR_DATA *ch) );
void check_bracelets args((CHAR_DATA *ch));
void wing_beating args((CHAR_DATA *ch) );
bool check_crown_blood args((CHAR_DATA *ch,CHAR_DATA *victim,int dt, int dam, int dam_type));
void check_blue_talon args((CHAR_DATA *ch, CHAR_DATA *victim));
int check_cutter args((CHAR_DATA *ch,CHAR_DATA *victim));
bool eye_of_beholder_absorb args((CHAR_DATA *ch,CHAR_DATA *victim,
int dt, int dam, int dam_type));
/*
* Control the fights going on.
* Called periodically by update_handler.
*/
void violence_update( void )
{
CHAR_DATA *ch;
CHAR_DATA *ch_next;
CHAR_DATA *victim;
int regen, to_heal;
OBJ_DATA *torque;
OBJ_DATA *obj;
for ( ch = char_list; ch != NULL; ch = ch->next )
{
ch_next = ch->next;
obj = get_eq_char(ch,WEAR_HEAD);
if (obj != NULL && obj->pIndexData->vnum == OBJ_VNUM_TIARA)
{
ch->mana = UMIN(ch->mana + number_range(1,4),ch->max_mana);
}
obj = get_eq_char(ch,WEAR_HOLD);
if (obj != NULL && obj->pIndexData->vnum == 14739)
{
/* greater symbol of magic */
ch->mana = UMIN(ch->mana + number_range(1,3),ch->max_mana);
}
/* regen */
if (!IS_NPC(ch))
{
regen = get_skill(ch,gsn_regeneration);
to_heal = (ch->max_hit - ch->hit);
if (number_percent() <= ch->level*2)
{
if ((ch->hit < ch->max_hit)
&& ch->noregen_dam < to_heal
&& number_percent() < regen)
{
if (number_percent() < 3)
check_improve(ch,gsn_regeneration,TRUE,4);
ch->hit += number_range(1,3);
}
}
}
if (ch->regen_rate != 0)
{
if (ch->regen_rate > 0)
regen = number_range(1,ch->regen_rate);
else
regen = number_range(1,-ch->regen_rate);
if (ch->hit < ch->max_hit)
if (ch->regen_rate > 0)
ch->hit = UMIN(ch->hit + regen,ch->max_hit);
else
ch->hit = UMIN(ch->hit - regen,ch->max_hit);
}
torque = get_eq_char(ch,WEAR_NECK_1);
if (torque == NULL)
torque = get_eq_char(ch,WEAR_NECK_2);
if (torque != NULL)
{
if (torque->pIndexData->vnum == OBJ_VNUM_TORQUE)
if (ch->hit < ch->max_hit)
ch->hit = UMIN(ch->hit + dice(1,3),ch->max_hit);
}
if ( ( victim = ch->fighting ) == NULL || ch->in_room == NULL )
continue;
if (IS_NPC(ch) && (!IS_NPC(ch->fighting))
&& !IS_SET(ch->off_flags,NO_TRACK)
&& !IS_AFFECTED(ch,AFF_CHARM)
&& !IS_SET(ch->act,ACT_IS_HEALER)
&& !IS_SET(ch->act,ACT_BANKER))
ch->last_fought = ch->fighting;
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( ch ) )
{
if ( HAS_TRIGGER( ch, TRIG_FIGHT ) )
mp_percent_trigger( ch, victim, NULL, NULL, TRIG_FIGHT );
if ( HAS_TRIGGER( ch, TRIG_HPCNT ) )
mp_hprct_trigger( ch, victim );
}
/*
* Fun for the whole family!
*/
check_assist(ch,victim);
}
return;
}
/* for auto assisting */
void check_assist(CHAR_DATA *ch,CHAR_DATA *victim)
{
CHAR_DATA *rch, *rch_next;
for (rch = ch->in_room->people; rch != NULL; rch = rch_next)
{
rch_next = rch->next_in_room;
if (!IS_NPC(rch) && rch->ghost > 0)
continue;
if (IS_AWAKE(rch) && rch->fighting == NULL)
{
/* NPC assisting group (for charm, zombies, elementals..added by Ceran */
if (IS_NPC(rch) && (IS_AFFECTED(rch,AFF_CHARM)) && is_same_group(rch,ch) )
{
multi_hit(rch,victim,TYPE_UNDEFINED);
continue;
}
/* quick check for ASSIST_PLAYER */
if (!IS_NPC(ch) && IS_NPC(rch)
&& IS_SET(rch->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(ch) || IS_AFFECTED(ch,AFF_CHARM))
{
/* First check defending */
if (rch->defending != NULL)
{
CHAR_DATA *fch;
fch = ch->fighting;
if (rch->defending != NULL
&& rch->defending == ch
&& fch != NULL
&& fch->fighting == ch
&& number_percent() < get_skill(rch,gsn_defend)
&& number_percent() > 40
&& number_percent() < get_skill(rch,gsn_rescue))
{
act("$n leaps to $N's rescue!",rch,0,ch,TO_NOTVICT);
act("$n leaps to your rescue!",rch,0,ch,TO_VICT);
act("You leap to $N's rescue!",rch,0,ch,TO_CHAR);
if (is_safe(rch,fch))
return;
/*
if(IS_NPC(fch))
vnum=victim->fighting->pIndexData->vnum;
if(vnum==MOB_VNUM_CRUSADER||vnum==MOB_VNUM_ENFORCER||
vnum==MOB_VNUM_ANCIENT||vnum==MOB_VNUM_ARCANA||
vnum==MOB_VNUM_LIFE||vnum==MOB_VNUM_OUTLAW)
return;
}
*/
WAIT_STATE( rch, skill_table[gsn_rescue].beats );
WAIT_STATE(ch,12);
check_improve(rch,gsn_defend,TRUE,1);
stop_fighting( fch, FALSE );
stop_fighting( ch, FALSE );
set_fighting( rch, fch );
set_fighting( fch, rch );
if (IS_NPC(fch)
&& (fch->pIndexData->vnum == MOB_VNUM_ARCANA
|| fch->pIndexData->vnum == MOB_VNUM_ANCIENT
|| fch->pIndexData->vnum == MOB_VNUM_LIFE
|| fch->pIndexData->vnum == MOB_VNUM_CRUSADER
|| fch->pIndexData->vnum == MOB_VNUM_OUTLAW
|| fch->pIndexData->vnum == MOB_VNUM_ENFORCER) )
set_fighting(ch,fch);
continue;
}
}
if ( ( (!IS_NPC(rch) && IS_SET(rch->act,PLR_AUTOASSIST))
|| IS_AFFECTED(rch,AFF_CHARM))
&& is_same_group(ch,rch)
&& !is_safe(rch, victim))
multi_hit (rch,victim,TYPE_UNDEFINED);
continue;
}
/* now check the NPC cases */
if (IS_NPC(ch) && !IS_AFFECTED(ch,AFF_CHARM))
{
if ( (IS_NPC(rch) && IS_SET(rch->off_flags,ASSIST_ALL))
|| (IS_NPC(rch) && rch->group && rch->group == ch->group)
|| (IS_NPC(rch) && rch->race == ch->race
&& IS_SET(rch->off_flags,ASSIST_RACE))
|| (IS_NPC(rch) && IS_SET(rch->off_flags,ASSIST_ALIGN)
&& ((IS_GOOD(rch) && IS_GOOD(ch))
|| (IS_EVIL(rch) && IS_EVIL(ch))
|| (IS_NEUTRAL(rch) && IS_NEUTRAL(ch))))
|| (rch->pIndexData == ch->pIndexData
&& IS_SET(rch->off_flags,ASSIST_VNUM)))
{
CHAR_DATA *vch;
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)
{
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.
*/
void multi_hit( CHAR_DATA *ch, CHAR_DATA *victim, int dt )
{
int chance;
int dual_chance;
int trinal_chance;
OBJ_DATA *obj;
OBJ_DATA *wield;
if (is_affected(ch,gsn_timestop))
{
if (ch->fighting != NULL)
ch->fighting = NULL;
return;
}
/* decrement the wait */
if (ch->desc == NULL)
ch->wait = UMAX(0,ch->wait - PULSE_VIOLENCE);
if (ch->desc == NULL)
ch->daze = UMAX(0,ch->daze - PULSE_VIOLENCE);
/* no attacks for stunnies -- just a check */
if (ch->position < POS_RESTING)
return;
if (IS_NPC(ch))
{
mob_hit(ch,victim,dt);
return;
}
one_hit( ch, victim, dt );
if (ch->fighting != victim)
return;
check_bracelets(ch);
wing_beating(ch);
obj = get_eq_char(ch,WEAR_BRAND);
if (ch->fighting == victim)
if ( (wield = get_eq_char(ch,WEAR_WIELD)) != NULL)
{
if (ch->fighting == victim && wield->pIndexData->vnum == 14726)
check_blue_talon(ch,ch->fighting);
}
if ( ch->fighting != victim || dt == gsn_backstab || (dt == gsn_ambush) )
return;
if (IS_AFFECTED(ch,AFF_HASTE))
one_hit(ch,victim,dt);
chance = get_skill(ch,gsn_second_attack)/2;
dual_chance = get_skill(ch,gsn_dual_wield)/2;
trinal_chance = get_skill(ch,gsn_tertiary_wield)/2;
if (IS_AFFECTED(ch,AFF_SLOW))
{
chance /= 2;
dual_chance /= 2;
trinal_chance /= 2;
}
if ( number_percent( ) < chance )
{
one_hit( ch, victim, dt );
check_improve(ch,gsn_second_attack,TRUE,5);
if ( ch->fighting != victim )
return;
}
check_bracelets(ch);
wing_beating(ch);
if ( (wield = get_eq_char(ch,WEAR_WIELD)) != NULL)
{
if (ch->fighting == victim && wield->pIndexData->vnum == 14726)
check_blue_talon(ch,ch->fighting);
}
if (get_eq_char(ch,WEAR_DUAL_WIELD) != NULL
&& ch->pcdata->learned[gsn_second_attack] > 10)
{
if (number_percent( ) < dual_chance)
{
one_hit(ch,victim,gsn_dual_wield);
check_improve(ch,gsn_dual_wield,TRUE,3);
if (ch->fighting != victim)
return;
}
else
check_improve(ch,gsn_dual_wield,FALSE,3);
}
if (get_eq_char(ch,WEAR_TERTIARY_WIELD) != NULL
&& ch->pcdata->learned[gsn_second_attack] > 10)
{
if (number_percent( ) < trinal_chance)
{
one_hit(ch,victim,gsn_tertiary_wield);
check_improve(ch,gsn_tertiary_wield,TRUE,3);
if (ch->fighting != victim)
return;
}
else
check_improve(ch,gsn_tertiary_wield,FALSE,3);
}
if (!IS_NPC(ch) && !str_cmp(class_table[ch->class].name,"monk")
&& (get_eq_char(ch,WEAR_WIELD) != NULL) )
return; /* Monks can't get 3/4th attack with a weapon */
chance = get_skill(ch,gsn_third_attack)/4;
if (IS_AFFECTED(ch,AFF_SLOW))
chance = 0;;
if ( number_percent( ) < chance )
{
one_hit( ch, victim, dt );
check_improve(ch,gsn_third_attack,TRUE,6);
if ( ch->fighting != victim )
return;
}
dual_chance = get_skill(ch,gsn_dual_wield)/4;
if (get_eq_char(ch,WEAR_DUAL_WIELD) != NULL
&& ch->pcdata->learned[gsn_third_attack] > 10)
{
if (number_percent( ) < dual_chance)
{
one_hit(ch,victim,gsn_dual_wield);
check_improve(ch,gsn_dual_wield,TRUE,3);
if (ch->fighting != victim)
return;
}
else
check_improve(ch,gsn_dual_wield,FALSE,3);
}
trinal_chance = get_skill(ch,gsn_tertiary_wield)/3;
if (get_eq_char(ch,WEAR_TERTIARY_WIELD) != NULL
&& ch->pcdata->learned[gsn_third_attack] > 10)
{
if (number_percent( ) < trinal_chance)
{
one_hit(ch,victim,gsn_tertiary_wield);
check_improve(ch,gsn_tertiary_wield,TRUE,3);
if (ch->fighting != victim)
return;
}
else
check_improve(ch,gsn_tertiary_wield,FALSE,3);
}
chance = get_skill(ch,gsn_fourth_attack)/5;
if (IS_AFFECTED(ch,AFF_SLOW))
chance /= 2;
if ( number_percent() < chance )
{
one_hit( ch, victim, dt );
check_improve(ch,gsn_fourth_attack,TRUE,6);
if (ch->fighting != victim )
return;
}
dual_chance = get_skill(ch,gsn_dual_wield)/4;
if (get_eq_char(ch,WEAR_DUAL_WIELD) != NULL
&& ch->pcdata->learned[gsn_fourth_attack] > 10)
{
if (number_percent( ) < dual_chance)
{
one_hit(ch,victim,gsn_dual_wield);
check_improve(ch,gsn_dual_wield,TRUE,6);
if (ch->fighting != victim)
return;
}
else
check_improve(ch,gsn_dual_wield,FALSE,5);
}
trinal_chance = get_skill(ch,gsn_tertiary_wield)/6;
if (get_eq_char(ch,WEAR_TERTIARY_WIELD) != NULL
&& ch->pcdata->learned[gsn_fourth_attack] > 85)
{
if (number_percent( ) < trinal_chance)
{
one_hit(ch,victim,gsn_tertiary_wield);
check_improve(ch,gsn_tertiary_wield,TRUE,3);
if (ch->fighting != victim)
return;
}
else
check_improve(ch,gsn_tertiary_wield,FALSE,3);
}
return;
}
/* procedure for all mobile attacks */
void mob_hit (CHAR_DATA *ch, CHAR_DATA *victim, int dt)
{
int chance,number;
int dual_chance;
CHAR_DATA *vch, *vch_next;
one_hit(ch,victim,dt);
if (ch->fighting != victim)
return;
/* Area attack -- BALLS nasty! */
if (IS_SET(ch->off_flags,OFF_AREA_ATTACK))
{
for (vch = ch->in_room->people; vch != NULL; vch = vch_next)
{
vch_next = vch->next;
if ((vch != victim && vch->fighting == ch))
one_hit(ch,vch,dt);
}
}
if (IS_AFFECTED(ch,AFF_HASTE)
|| (IS_SET(ch->off_flags,OFF_FAST) && !IS_AFFECTED(ch,AFF_SLOW)))
one_hit(ch,victim,dt);
if (ch->fighting != victim || dt == gsn_backstab)
return;
chance = get_skill(ch,gsn_second_attack)/2;
dual_chance = ch->level*2/3;
if (IS_AFFECTED(ch,AFF_SLOW) && !IS_SET(ch->off_flags,OFF_FAST))
{
dual_chance /= 2;
chance /= 2;
}
if (number_percent() < chance)
{
one_hit(ch,victim,dt);
if (ch->fighting != victim)
return;
}
if (IS_AFFECTED(ch,AFF_HASTE))
dual_chance *= 5/4;
if (number_percent() < dual_chance && get_eq_char(ch,WEAR_DUAL_WIELD) != NULL)
{
one_hit(ch,victim,gsn_dual_wield);
if (ch->fighting != victim)
return;
}
chance = get_skill(ch,gsn_third_attack)/4;
dual_chance *= 2/3;
if (IS_AFFECTED(ch,AFF_SLOW) && !IS_SET(ch->off_flags,OFF_FAST))
{
dual_chance = 0;
chance = 0;
}
if (IS_AFFECTED(ch,AFF_HASTE))
dual_chance *= 3/2;
if (number_percent() < chance)
{
one_hit(ch,victim,dt);
if (ch->fighting != victim)
return;
}
if (number_percent() < dual_chance && get_eq_char(ch,WEAR_DUAL_WIELD) != NULL)
{
one_hit(ch,victim,gsn_dual_wield);
if (ch->fighting != victim)
return;
}
/* oh boy! Fun stuff! */
if (ch->wait > 0)
return;
number = number_range(0,2);
if (number == 1 && IS_SET(ch->act,ACT_MAGE))
{
/* { mob_cast_mage(ch,victim); return; } */ ;
}
if (number == 2 && IS_SET(ch->act,ACT_CLERIC))
{
/* { mob_cast_cleric(ch,victim); return; } */ ;
}
/* now for the skills */
number = number_range(0,9);
switch(number)
{
case (0) :
if (IS_SET(ch->off_flags,OFF_BASH))
do_bash(ch,"");
else if (IS_SET(ch->off_flags,OFF_TAIL))
do_tail(ch,"");
break;
case (1) :
if (IS_SET(ch->off_flags,OFF_BERSERK) && !IS_AFFECTED(ch,AFF_BERSERK))
do_berserk(ch,"");
break;
case (2) :
if (IS_SET(ch->off_flags,OFF_DISARM)
|| (get_weapon_sn(ch) != gsn_hand_to_hand
&& (IS_SET(ch->act,ACT_WARRIOR)
|| IS_SET(ch->act,ACT_THIEF))))
do_disarm(ch,"");
break;
case (3) :
if (IS_SET(ch->off_flags,OFF_KICK))
do_kick(ch,"");
break;
case (4) :
if (IS_SET(ch->off_flags,OFF_KICK_DIRT))
do_dirt(ch,"");
break;
case (5) :
if (IS_SET(ch->off_flags,OFF_TAIL))
{
do_tail(ch,"");
}
break;
case (6) :
if (IS_SET(ch->off_flags,OFF_TRIP))
do_trip(ch,"");
break;
case (7) :
if (IS_SET(ch->off_flags,OFF_CRUSH))
{
do_crush(ch,"") ;
}
break;
case (8) :
if (IS_SET(ch->off_flags,OFF_BACKSTAB))
{
do_backstab(ch,"");
}
else if (IS_SET(ch->off_flags,OFF_UNDEAD_DRAIN))
do_undead_drain(ch,"");
break;
case (9) :
if ( IS_SET(ch->off_flags,OFF_UNDEAD_DRAIN))
{
do_undead_drain(ch,"");
}
break;
}
}
/*
* Hit one guy once.
*/
void one_hit( CHAR_DATA *ch, CHAR_DATA *victim, int dt )
{
OBJ_DATA *wield;
int victim_ac;
int thac0;
OBJ_DATA *obj;
int bcry;
int thac0_00;
int thac0_32;
int dam, mdam;
int diceroll, diceroll2 = 0;
int sn,skill;
int dam_type;
int tmp_dt;
bool result;
sn = -1;
/* just in case */
if (victim == ch || ch == NULL || victim == NULL)
return;
/*
* Can't beat a dead char!
* Guard against weird room-leavings.
*/
if ( victim->position == POS_DEAD || ch->in_room != victim->in_room )
return;
/*
* Figure out the type of damage message.
*/
wield = get_eq_char( ch, WEAR_WIELD );
if ( dt == TYPE_UNDEFINED )
{
dt = TYPE_HIT;
if ( wield != NULL && wield->item_type == ITEM_WEAPON )
dt += wield->value[3];
else
dt += ch->dam_type;
}
if (dt < TYPE_HIT)
if (wield != NULL)
dam_type = attack_table[wield->value[3]].damage;
else
dam_type = attack_table[ch->dam_type].damage;
else
dam_type = attack_table[dt - TYPE_HIT].damage;
if (dam_type == -1)
dam_type = DAM_BASH;
/* get the weapon skill */
sn = get_weapon_sn(ch);
skill = 20 + get_weapon_skill(ch,sn);
/* DUAL WIELD..kinda messy here */
if (dt == gsn_dual_wield || dt == gsn_tertiary_wield)
{
if (dt == gsn_dual_wield)
wield = get_eq_char( ch, WEAR_DUAL_WIELD );
else
wield = get_eq_char(ch,WEAR_TERTIARY_WIELD);
tmp_dt = TYPE_HIT;
if ( wield != NULL && wield->item_type == ITEM_WEAPON )
tmp_dt += wield->value[3];
else
tmp_dt += ch->dam_type;
if (tmp_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;
if (wield == NULL) sn = -1;
else switch (wield->value[0])
{
default: sn = -1; break;
case (WEAPON_SWORD): sn = gsn_sword; break;
case (WEAPON_DAGGER): sn = gsn_dagger; break;
case (WEAPON_SPEAR): sn = gsn_spear; break;
case (WEAPON_MACE): sn = gsn_mace; break;
case (WEAPON_AXE): sn = gsn_axe; break;
case (WEAPON_FLAIL): sn = gsn_flail; break;
case (WEAPON_WHIP): sn = gsn_whip; break;
case (WEAPON_POLEARM): sn = gsn_polearm; break;
}
skill = 10 + get_weapon_skill(ch,sn);
}
/*
* Calculate to-hit-armor-class-0 versus armor.
*/
if ( IS_NPC(ch) )
{
thac0_00 = 20;
thac0_32 = -4; /* as good as a thief */
if (IS_SET(ch->act,ACT_WARRIOR))
thac0_32 = -10;
else if (IS_SET(ch->act,ACT_THIEF))
thac0_32 = -4;
else if (IS_SET(ch->act,ACT_CLERIC))
thac0_32 = 2;
else if (IS_SET(ch->act,ACT_MAGE))
thac0_32 = 6;
}
else
{
thac0_00 = class_table[ch->class].thac0_00;
thac0_32 = class_table[ch->class].thac0_32;
}
thac0 = interpolate( ch->level + ch->drain_level, thac0_00, thac0_32 );
if (thac0 < 0)
thac0 = thac0/2;
if (thac0 < -5)
thac0 = -5 + (thac0 + 5) / 2;
thac0 -= GET_HITROLL(ch) * skill/100;
thac0 += 5 * (100 - skill) / 100;
if (dt == gsn_backstab)
thac0 -= 10 * (100 - get_skill(ch,gsn_backstab));
if (dt == gsn_ambush)
thac0 -= 15 * (100 - get_skill(ch,gsn_ambush));
switch(dam_type)
{
case(DAM_PIERCE):victim_ac = GET_AC(victim,AC_PIERCE)/10; break;
case(DAM_BASH): victim_ac = GET_AC(victim,AC_BASH)/10; break;
case(DAM_SLASH): victim_ac = GET_AC(victim,AC_SLASH)/10; break;
default: victim_ac = GET_AC(victim,AC_EXOTIC)/10; break;
};
if (victim_ac < -15)
victim_ac = (victim_ac + 15) / 5 - 15;
if ( !can_see( ch, victim ) )
victim_ac -= 4;
if ( victim->position < POS_FIGHTING)
victim_ac += 4;
if (victim->position < POS_RESTING)
victim_ac += 6;
/*
* The moment of excitement!
*/
while ( ( diceroll = number_bits( 5 ) ) >= 20 )
;
if ( diceroll == 0
|| ( diceroll != 19 && diceroll < thac0 - victim_ac ) )
{
/* Miss. */
damage( ch, victim, 0, dt, dam_type, TRUE );
tail_chain( );
return;
}
/*
* Hit.
* Calc damage.
*/
if ( IS_NPC(ch) && (!ch->pIndexData->new_format || wield == NULL))
if (!ch->pIndexData->new_format)
{
dam = number_range( ( ch->level + ch->drain_level) / 2, (ch->drain_level + ch->level) * 3 / 2 );
if ( wield != NULL )
dam += dam / 2;
}
else
dam = dice(ch->damage[DICE_NUMBER],ch->damage[DICE_TYPE]);
else
{
if (sn != -1)
check_improve(ch,sn,TRUE,5);
if ( wield != NULL )
{
if (wield->pIndexData->new_format)
dam = dice(wield->value[1],wield->value[2]) * skill/100;
else
dam = number_range( wield->value[1] * skill/100,
wield->value[2] * skill/100);
if (get_eq_char(ch,WEAR_SHIELD) == NULL) /* no shield = more */
dam = dam * 11/10;
if (wield->level - (ch->drain_level + ch->level) >= 35)
dam = (dam*6)/10;
else if (wield->level - (ch->drain_level + ch->level) >= 25)
dam = (dam*7)/10;
else if (wield->level - (ch->drain_level + ch->level) >= 15)
dam = (dam*8)/10;
else if (wield->level - (ch->drain_level + ch->level) >= 5)
dam = (dam*9)/10;
/* sharpness! */
if (IS_WEAPON_STAT(wield,WEAPON_SHARP))
{
int percent;
if ((percent = number_percent()) <= (skill / 8))
dam = 2 * dam + (dam * 2 * percent / 100);
}
}
else
dam = number_range( 1 + 4 * skill/100, 2 * ch->level/3 * skill/100);
}
/*
* Bonuses.
*/
dam += (ch->drain_level + ch->level)/8;
if ( get_skill(ch,gsn_enhanced_damage) > 0 )
{
diceroll = number_percent();
if (get_skill(ch,gsn_enhanced_damage_two) > 0)
{
diceroll2 = number_percent();
if (diceroll2 < get_skill(ch,gsn_enhanced_damage_two)
&& diceroll2 < get_skill(ch,gsn_enhanced_damage) )
{
check_improve(ch,gsn_enhanced_damage_two,TRUE,5);
diceroll = diceroll2;
}
}
if (diceroll <= get_skill(ch,gsn_enhanced_damage))
{
check_improve(ch,gsn_enhanced_damage,TRUE,6);
dam += (dam * diceroll/125);
}
}
else
{
dam *= 7;
dam /= 10;
}
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 + ((ch->level + ch->drain_level) / 10) ;
else
dam *= 2 + ((ch->drain_level + ch->level) / 8);
if ( dt == gsn_ambush )
dam *= 5/2 + ((ch->drain_level + ch->level) / 9 );
mdam = GET_DAMROLL(ch);
/* Let's cut back on mage's damage a bit */
if (get_skill(ch,gsn_enhanced_damage) == 0)
if (mdam > 20)
mdam = ( (mdam - 20)/3 + 20);
dam += mdam * UMIN(100,skill) /100;
if (!IS_NPC(ch))
if (!str_cmp(class_table[ch->class].name,"monk"))
{
if (wield == NULL
&& get_eq_char(ch,WEAR_DUAL_WIELD) == NULL)
dam += (2*(ch->drain_level + ch->level)/5);
}
if (IS_NPC(victim) && victim->pIndexData->vnum == MOB_VNUM_HYDRA)
{
if (wield != NULL && wield->pIndexData->vnum == OBJ_VNUM_HYDRA_SLAYER)
dam = dice(17,50);
}
bcry = battlecry_multiplier(ch,dt);
if (wield != NULL && wield->pIndexData->vnum == 23265)
if (check_cutter(ch,victim) > 1)
dam += dice(10,3);
if (bcry == 1 && wield == NULL)
{
if (check_palm(ch))
{
act("$n strikes a powerful open handed blow!",ch,0,0,TO_ROOM);
act("You strike a powerful open handed blow!",ch,0,0,TO_CHAR);
if ((ch->drain_level + ch->level) <= 39)
{
dam *= 3;
dam /= 2;
}
else
dam *= 2;
}
}
if (bcry == 1 && ch->clan != CLAN_CRUSADER)
{
if ((obj = get_eq_char(ch,WEAR_HANDS)) != NULL
&& obj->pIndexData->vnum == 29711
&& number_percent() < 10)
{
act("$n delivers a blow of deadly force!",ch,0,0,TO_ROOM);
act("You deliver a blow of deadly force!",ch,0,0,TO_CHAR);
bcry = 2;
}
}
dam *= bcry;
if (wield != NULL && wield->pIndexData->vnum == OBJ_VNUM_AVENGER)
{
if (IS_WEAPON_STAT(wield,WEAPON_SHADOWBANE)
&& number_percent() < 7)
{
act("$p flares and sears $N!",ch,wield,victim,TO_CHAR);
act("$p flares and sears you!",ch,wield,victim,TO_VICT);
act("$p flares and sears $N!",ch,wield,victim,TO_NOTVICT);
dam *= 2;
}
if (IS_WEAPON_STAT(wield,WEAPON_LIGHTBRINGER)
&& number_percent() < 10)
{
act("$p flares and sears $N!",ch,wield,victim,TO_CHAR);
act("$p flares and sears you!",ch,wield,victim,TO_VICT);
act("$p flares and sears $N!",ch,wield,victim,TO_NOTVICT);
dam *= 3;
dam /=2;
}
}
if (bcry == 1)
{
if (wield != NULL && wield->pIndexData->vnum == 24309)
{
if (number_percent() < 6)
{
act("$n's $p lands a crushing blow!",ch,wield,0,TO_ROOM);
act("Your $p lands a crushing blow!",ch,wield,0,TO_CHAR);
dam *= 2;
}
}
/* sword of planes and mace disruption .. go right before damage report*/
if (wield != NULL && wield->pIndexData->vnum == OBJ_VNUM_SWORD_PLANES)
{
if (IS_NPC(victim)
&& ( IS_SET(victim->act,ACT_UNDEAD)
|| victim->pIndexData->vnum == MOB_VNUM_FIRE_ELEMENTAL
|| victim->pIndexData->vnum == MOB_VNUM_AIR_ELEMENTAL
|| victim->pIndexData->vnum == MOB_VNUM_WATER_ELEMENTAL
|| victim->pIndexData->vnum == MOB_VNUM_EARTH_ELEMENTAL
|| victim->pIndexData->vnum == MOB_VNUM_DRAGON
|| victim->pIndexData->vnum == MOB_VNUM_UNICORN
|| is_name(victim->name,"demon")
|| is_name(victim->name,"familiar")
|| is_name(victim->name,"golem") ) )
{
if (!(saves_spell(ch->level,victim,DAM_ENERGY))
&& (!saves_spell(ch->level + 3,victim,DAM_ENERGY))
&& (!saves_spell(wield->level,victim,DAM_OTHER))
&& number_percent() < 50)
{
act("$n's body suddenly crumples as $p draws $s lifeforce back to the outer planes!",
victim,wield,0,TO_ROOM);
raw_kill(ch,victim);
return;
}
else if (IS_SET(victim->affected_by, AFF_SANCTUARY) )
{
dam += (dam/2); /* partiallyNegates sanc */
}
}
}
else if (wield != NULL && wield->pIndexData->vnum == OBJ_VNUM_MACE_DISRUPTION)
{
if (IS_NPC(victim)
&& ( IS_SET(victim->act,ACT_UNDEAD)) )
{
if (!saves_spell(ch->level,victim,DAM_ENERGY)
&& !saves_spell(ch->level,victim,DAM_ENERGY)
&& !saves_spell(ch->level,victim,DAM_OTHER))
{
act("$N's body explodes under $n's mace of disruption!",ch,0,victim,TO_NOTVICT);
act("$N's body explodes under your mace of disruption!",ch,0,victim,TO_CHAR);
raw_kill(ch,victim);
return;
}
else if (IS_SET(victim->affected_by,AFF_SANCTUARY))
{
dam += (3* dam/4);
}
}
}
if (IS_NPC(ch)
&& ch->pIndexData->vnum == 19000
&& number_percent() < 4)
{
act("$n bellows a cry and unleashes a mighty blow upon you!",ch,0,victim,TO_VICT);
act("$n bellows a cry and unleashes a mighty blow upon $N",ch,0,victim,TO_NOTVICT);
dam += dice(ch->level,3);
}
}
if ( dam <= 0 )
dam = 1;
result = damage( ch, victim, dam, dt, dam_type, TRUE );
check_outlaw_badge(ch);
check_red_shield(ch);
if (wield != NULL && wield->pIndexData->vnum == OBJ_VNUM_RANGER_STAFF)
check_ranger_staff(ch,wield);
if (wield != NULL && wield->pIndexData->vnum == 8003)
check_ranger_staff(ch,wield); /* Staff of magi call */
/* but do we have a funky weapon? */
if (result && wield != NULL)
{
int 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))
{
send_to_char("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)
&& number_percent() < 8)
{
dam = number_range(wield->level/2, wield->level);
act("$p draws life from $n.",victim,wield,NULL,TO_ROOM);
act("You feel $p drawing your life away.",
victim,wield,NULL,TO_CHAR);
damage_old(ch,victim,dam,0,DAM_NEGATIVE,FALSE);
ch->hit = UMIN(ch->hit + dam, ch->max_hit);
}
if (ch->fighting == victim && IS_WEAPON_STAT(wield,WEAPON_FLAMING)
&& number_percent() < 15)
{
dam = number_range(1,wield->level / 4 + 1);
act("$n is burned by $p.",victim,wield,NULL,TO_ROOM);
act("$p sears your flesh.",victim,wield,NULL,TO_CHAR);
fire_effect( (void *) victim,wield->level/2,dam,TARGET_CHAR);
damage(ch,victim,dam,0,DAM_FIRE,FALSE);
}
if (ch->fighting == victim && IS_WEAPON_STAT(wield,WEAPON_FROST)
&& number_percent() < 15)
{
dam = number_range(1,wield->level / 6 + 2);
act("$p freezes $n.",victim,wield,NULL,TO_ROOM);
act("The cold touch of $p surrounds you with ice.",
victim,wield,NULL,TO_CHAR);
cold_effect(victim,wield->level/2,dam,TARGET_CHAR);
damage(ch,victim,dam,0,DAM_COLD,FALSE);
}
if (ch->fighting == victim && IS_WEAPON_STAT(wield,WEAPON_SHOCKING)
&& number_percent() < 15)
{
dam = number_range(1,wield->level/5 + 2);
act("$n is struck by lightning from $p.",victim,wield,NULL,TO_ROOM);
act("You are shocked by $p.",victim,wield,NULL,TO_CHAR);
shock_effect(victim,wield->level/2,dam,TARGET_CHAR);
damage(ch,victim,dam,0,DAM_LIGHTNING,FALSE);
}
}
tail_chain( );
return;
}
void check_red_shield(CHAR_DATA *ch)
{
OBJ_DATA *shield;
shield = get_eq_char(ch,WEAR_SHIELD);
if (shield == NULL)
return;
if (shield->pIndexData->vnum != 23728)
return;
if (number_percent() < 6)
{
act("The cross on $n's shield glows a soft red.",ch,shield,0,TO_ROOM);
act("The cross on your shield glows a soft red.",ch,shield,0,TO_CHAR);
obj_cast_spell(skill_lookup("cure critical"), 45, ch, ch, shield);
}
return;
}
void check_outlaw_badge(CHAR_DATA *ch)
{
OBJ_DATA *badge;
badge = get_eq_char(ch,WEAR_NECK_1);
if (badge == NULL)
badge = get_eq_char(ch,WEAR_NECK_2);
if (badge == NULL)
return;
if (badge->pIndexData->vnum == OBJ_VNUM_BADGE
&& number_percent() < 8)
{
act("$n's $p glows bright blue!",ch,badge,0,TO_ROOM);
act("Your $p glows bright blue!",ch,badge,0,TO_CHAR);
obj_cast_spell(skill_lookup("cure critical"), badge->level, ch, ch, badge);
}
return;
}
void check_ranger_staff(CHAR_DATA *ch,OBJ_DATA *wield)
{
if (number_percent() < 7)
{
if (wield->pIndexData->vnum == OBJ_VNUM_RANGER_STAFF)
{
act("$p glows blue!",ch,wield,0,TO_ROOM);
act("Your ranger staff glows blue!",ch,wield,0,TO_CHAR);
}
else
{
act("$p blows a burning green!",ch,wield,0,TO_ROOM);
act("Your staff of the magi glows burning green!",ch,wield,0,TO_CHAR);
}
obj_cast_spell(skill_lookup("cure critical"), wield->level, ch, ch,wield);
}
return;
}
int avenger_multiplier(CHAR_DATA *ch,OBJ_DATA *wield)
{
int avenge;
avenge = 1;
if (IS_EVIL(ch->fighting) && wield != NULL)
{
if (number_percent() < 7 && IS_WEAPON_STAT(wield,WEAPON_SHADOWBANE))
avenge = 2;
if (number_percent() < 7 && IS_WEAPON_STAT(wield,WEAPON_LIGHTBRINGER))
avenge = 3/2;
}
return avenge;
}
int battlecry_multiplier(CHAR_DATA *ch, int dt)
{
OBJ_DATA *obj;
int battlecry;
int chance;
int mod;
battlecry = 1;
if (!is_affected(ch,gsn_battlecry) && !IS_NPC(ch))
return battlecry;
if (IS_NPC(ch) && ch->pIndexData->vnum != MOB_VNUM_CRUSADER
&& !is_affected(ch,gsn_battlecry))
return battlecry;
if ((ch->drain_level + ch->level) < skill_table[gsn_battlecry].skill_level[ch->class]
&& !IS_NPC(ch))
return 1;
if ((obj = get_eq_char(ch,WEAR_HANDS)) != NULL
&& obj->pIndexData->vnum == 29711)
mod = 3;
else mod = 0;
if (number_percent( ) > (mod + 14))
return 1;
chance = get_skill(ch,gsn_battlecry);
if (IS_NPC(ch) )
chance = 100;
if (chance > 2)
{
if (number_percent( ) > chance )
{
send_to_char("You fail to deliver a blow of deadly force.\n\r",ch);
if (ch->pcdata->learned[gsn_battlecry] < 100 && number_percent() < 90)
{
send_to_char("You learn from your mistakes and become better at battlecry.\n\r",ch);
ch->pcdata->learned[gsn_battlecry]++;
}
}
else
{
send_to_char("You deliver a blow of deadly force!\n\r",ch);
act("$n delivers a blow of deadly force!",ch,NULL,NULL,TO_ROOM);
check_improve(ch,gsn_battlecry,TRUE,1);
if ((ch->drain_level + ch->level) <= 29) battlecry = 2;
else if ((ch->drain_level + ch->level) <= 39) battlecry = 3;
else if ((ch->drain_level + ch->level) <= 49) battlecry = 4;
else if ((ch->drain_level + ch->level) <= 59) battlecry = 5;
else battlecry = 5;
}
}
if (dt == gsn_circle)
battlecry = UMIN(battlecry,3);
if (dt == gsn_lunge)
battlecry = UMIN(battlecry,3);
if (dt == gsn_backstab)
battlecry = UMIN(battlecry,2);
if (dt == gsn_dual_backstab)
battlecry = UMIN(battlecry,2);
if (dt == gsn_ambush)
battlecry = UMIN(battlecry,2);
if (clan_down(ch,CLAN_CRUSADER))
battlecry = 1;
return battlecry;
}
/*
* Inflict damage from a hit.
*/
bool damage(CHAR_DATA *ch,CHAR_DATA *victim,int dam,int dt,int dam_type,
bool show)
{
OBJ_DATA *corpse;
bool immune;
OBJ_DATA *obj;
OBJ_DATA *wield;
if ( victim->position == POS_DEAD )
return FALSE;
if (IS_NPC(ch) && spellbaned(ch,victim,dt))
return FALSE;
if (is_safe(ch,victim))
return FALSE;
/*
* Stop up any residual loopholes.
*/
if ( dam > 1400 && dt >= TYPE_HIT)
{
dam = 1400;
}
/* damage reduction */
if (dam > 85)
{
dam = (dam - 85);
dam *= 7;
dam /= 10;
dam += 85;
}
if ( victim != ch )
{
/*
* Certain attacks are forbidden.
* Most other attacks are returned.
*/
if ( is_safe( ch, victim ) )
return FALSE;
check_killer( ch, victim );
if (check_counter(ch,victim,dam,dt))
return FALSE;
if ( victim->position > POS_STUNNED )
{
if ( victim->fighting == NULL )
{
set_fighting( victim, ch );
if ( IS_NPC( victim ) && HAS_TRIGGER( victim, TRIG_KILL ) )
mp_percent_trigger( victim, ch, NULL, NULL, TRIG_KILL );
}
if (victim->timer <= 4)
victim->position = POS_FIGHTING;
}
if ( victim->position > POS_STUNNED )
{
if ( ch->fighting == NULL )
set_fighting( ch, victim );
}
/*
* More charm stuff.
*/
if ( victim->master == ch )
stop_follower( victim );
}
un_camouflage( ch, NULL);
un_earthfade(ch,NULL);
un_hide(ch, NULL);
un_invis(ch, NULL);
un_sneak(ch, NULL);
/*
* Damage modifiers.
*/
if ( dam > 1 && !IS_NPC(victim)
&& victim->pcdata->condition[COND_DRUNK] > 10 )
dam = 9 * dam / 10;
if ( dam > 1 && IS_AFFECTED(victim, AFF_SANCTUARY) )
{
if ( (dt >= TYPE_HIT || dt == gsn_dual_wield || dt == gsn_tertiary_wield))
{
if (dt == gsn_dual_wield)
wield = get_eq_char(ch,WEAR_DUAL_WIELD);
else if (dt == gsn_tertiary_wield)
wield = get_eq_char(ch,WEAR_TERTIARY_WIELD);
else
wield = get_eq_char(ch,WEAR_WIELD);
if (wield == NULL )
dam /= 2;
else if (wield->pIndexData->vnum != 29724)
dam /= 2;
}
else
dam /= 2;
}
obj = get_eq_char(ch,WEAR_HEAD);
if (obj != NULL
&& obj->pIndexData->vnum == OBJ_VNUM_TIARA
&& (dam_type == DAM_COLD || dam_type == DAM_FIRE
|| dam_type == DAM_HOLY || dam_type == DAM_NEGATIVE
|| dam_type == DAM_ACID) )
{
if (dam > 125)
{
dam = (dam - 125);
dam *= 6;
dam /= 10;
dam += 125;
}
}
if (check_crown_blood(ch,victim,dt,dam,dam_type))
return FALSE;
if ((dt >= TYPE_HIT || dt==gsn_backstab || HITS) && (ch != victim) && (is_affected(victim,gsn_steel_nerves)) && dam > 1)
{
dam -= dam*4/10;
}
if ((dt >= TYPE_HIT || dt==gsn_backstab || HITS) && (ch != victim)
&& victim->morph_form[0] == MORPH_BEAR
&& dam > 1)
{
dam -= dam*3/10;
}
if ( dam > 1 && ((IS_AFFECTED(victim, AFF_PROTECT_EVIL) && IS_EVIL(ch) )
|| (IS_AFFECTED(victim, AFF_PROTECT_GOOD) && IS_GOOD(ch) )))
dam -= dam / 4;
if (is_affected(victim,gsn_spellbane))
{
if (dam_type > 3)
{
dam *= 7;
dam /= 10;
}
}
immune = FALSE;
/* Check for absorb */
if (check_absorb(ch,victim,dt))
return FALSE;
if (eye_of_beholder_absorb(ch,victim,dt,dam,dam_type))
return FALSE;
/*
* Check for parry, and dodge.
*/
if ( (dt >= TYPE_HIT || dt == gsn_dual_wield || dt == gsn_tertiary_wield)
&& ch != victim)
{
if ( check_parry( ch, victim, dt ) )
{
do_counter_parry(ch,victim,dt, dam);
return FALSE;
}
if ( check_block( ch, victim, dt) )
return FALSE;
if ( check_dodge( ch, victim, dt ) )
return FALSE;
if ( check_shield_block(ch,victim, dt))
return FALSE;
}
switch(check_immune(victim,dam_type))
{
case(IS_IMMUNE):
immune = TRUE;
dam = 0;
break;
case(IS_RESISTANT):
if (IS_NPC(victim))
dam -= dam/3;
else
dam -= dam/3;
break;
case(IS_VULNERABLE):
dam += dam/3;
break;
}
if (dt == gsn_dual_wield)
wield = get_eq_char(ch,WEAR_DUAL_WIELD);
else if ( dt == gsn_tertiary_wield )
wield = get_eq_char(ch,WEAR_TERTIARY_WIELD);
else wield = get_eq_char(ch,WEAR_WIELD);
if (show)
dam_message( ch, victim, dam, dt, immune );
if (dam == 0)
return FALSE;
/*
* Hurt the victim.
* Inform the victim of his new state.
*/
victim->hit -= dam;
if (dam_type == DAM_FIRE || dam_type == DAM_ACID)
victim->noregen_dam += dam;
if (victim->noregen_dam > victim->max_hit)
victim->noregen_dam = victim->max_hit;
if ( !IS_NPC(victim)
&& victim->level >= LEVEL_IMMORTAL
&& victim->hit < 1 )
victim->hit = 1;
update_pos( victim );
switch( victim->position )
{
case POS_MORTAL:
act( "$n is mortally wounded, and will die soon, if not aided.",
victim, NULL, NULL, TO_ROOM );
send_to_char(
"You are mortally wounded, and will die soon, if not aided.\n\r",
victim );
break;
case POS_INCAP:
act( "$n is incapacitated and will slowly die, if not aided.",
victim, NULL, NULL, TO_ROOM );
send_to_char(
"You are incapacitated and will slowly die, if not aided.\n\r",
victim );
break;
case POS_STUNNED:
act( "$n is stunned, but will probably recover.",
victim, NULL, NULL, TO_ROOM );
send_to_char("You are stunned, but will probably recover.\n\r",
victim );
break;
case POS_DEAD:
act( "$n is DEAD!!", victim, 0, 0, TO_ROOM );
send_to_char( "You have been KILLED!!\n\r\n\r", victim );
break;
default:
if ( dam > victim->max_hit / 4 )
send_to_char( "That really did HURT!\n\r", victim );
if ( victim->hit < victim->max_hit / 4 )
send_to_char( "You sure are BLEEDING!\n\r", victim );
break;
}
/*
* Sleep spells and extremely wounded folks.
*/
if ( !IS_AWAKE(victim) )
stop_fighting( victim, FALSE );
/*
* Payoff for killing things.
*/
if ( victim->position == POS_DEAD )
{
group_gain( ch, victim );
if ( !IS_NPC(victim) )
{
sprintf( log_buf, "%s killed by %s at %d",
victim->name,
(IS_NPC(ch) ? ch->short_descr : ch->name),
ch->in_room->vnum );
log_string( log_buf );
/*
* Dying penalty:
*/
if (IS_NPC(ch) && !IS_AFFECTED(ch, AFF_CHARM))
victim->exp = UMAX(0, victim->exp - UMIN(exp_per_level(victim),victim->exp*.15));
}
sprintf( log_buf, "%s got toasted by %s at %s [room %d]",
(IS_NPC(victim) ? victim->short_descr : victim->name),
(IS_NPC(ch) ? ch->short_descr : ch->name),
ch->in_room->name, ch->in_room->vnum);
if (IS_NPC(victim))
wiznet(log_buf,NULL,NULL,WIZ_MOBDEATHS,0,0);
else
wiznet(log_buf,NULL,NULL,WIZ_DEATHS,0,0);
raw_kill(ch, victim );
/*
* Death trigger
*/
if ( IS_NPC( victim ) && HAS_TRIGGER( victim, TRIG_DEATH) )
{
victim->position = POS_STANDING;
mp_percent_trigger( victim, ch, NULL, NULL, TRIG_DEATH );
}
if (!IS_NPC(ch)
&& (corpse = get_obj_list(ch,"corpse",ch->in_room->contents)) != NULL
&& corpse->item_type == ITEM_CORPSE_NPC && can_see_obj(ch,corpse))
{
OBJ_DATA *coins;
corpse = get_obj_list( ch, "corpse", ch->in_room->contents );
if ( IS_SET(ch->act, PLR_AUTOLOOT) &&
corpse && corpse->contains) /* exists and not empty */
do_get( ch, "all corpse" );
if (IS_SET(ch->act,PLR_AUTOGOLD) &&
corpse && corpse->contains && /* exists and not empty */
!IS_SET(ch->act,PLR_AUTOLOOT))
if ((coins = get_obj_list(ch,"gcash",corpse->contains))
!= NULL)
do_get(ch, "all.gcash corpse");
if ( IS_SET(ch->act, PLR_AUTOSAC) )
if ( IS_SET(ch->act,PLR_AUTOLOOT) && corpse && corpse->contains)
return TRUE; /* leave if corpse has treasure */
else
do_sacrifice( ch, "corpse" );
}
return TRUE;
}
if ( victim == ch )
return TRUE;
/*
* Take care of link dead people.
*/
if ( !IS_NPC(victim) && victim->desc == NULL )
{
if ( number_range( 0, victim->wait ) == 0 )
{
do_recall( victim, "" );
return TRUE;
}
}
/*
* Wimp out?
*/
if ( IS_NPC(victim) && dam > 0 && victim->wait < PULSE_VIOLENCE / 2)
{
if ( ( IS_SET(victim->act, ACT_WIMPY) && number_bits( 2 ) == 0
&& victim->hit < victim->max_hit / 5)
|| ( IS_AFFECTED(victim, AFF_CHARM) && victim->master != NULL
&& victim->master->in_room != victim->in_room ) )
do_flee( victim, "" );
}
if (victim->level >= 30)
{
if ( !IS_NPC(victim)
&& victim->hit > 0
&& victim->hit <= victim->wimpy
&& victim->wait < PULSE_VIOLENCE / 2 )
do_flee( victim, "" );
}
else
{
if ( !IS_NPC(victim)
&& victim->hit > 0
&& (victim->hit*100)/victim->max_hit <= victim->wimpy
&& victim->wait < PULSE_VIOLENCE / 2 )
do_flee( victim, "" );
}
tail_chain( );
return TRUE;
}
/*
* Inflict damage from a hit.
*/
bool damage_old( CHAR_DATA *ch, CHAR_DATA *victim, int dam, int dt, int
dam_type, bool show ) {
OBJ_DATA *corpse;
bool immune;
OBJ_DATA *obj;
OBJ_DATA *wield;
if ( victim->position == POS_DEAD )
return FALSE;
if (IS_NPC(ch) && spellbaned(ch,victim,dt))
return FALSE;
if (IS_NPC(victim) && victim->pIndexData->vnum == MOB_VNUM_CRUSADER)
{
if (spellbaned(ch,victim,dt))
return FALSE;
}
if (is_safe(ch,victim))
return FALSE;
/*
* Stop up any residual loopholes.
*/
if ( dam > 1200 && dt >= TYPE_HIT)
{
bug( "Damage: %d: more than 1400 points!", dam );
dam = 1200;
}
/* damage reduction */
if (dam > 85)
{
dam = (dam - 85);
dam *= 7;
dam /= 10;
dam += 85;
}
if ( victim != ch )
{
/*
* Certain attacks are forbidden.
* Most other attacks are returned.
*/
if ( is_safe( ch, victim ) )
return FALSE;
check_killer( ch, victim );
if ( (dt >= TYPE_HIT
|| dt == gsn_backstab
|| dt == gsn_ambush
|| dt == gsn_cleave
|| dt == gsn_deathstrike)
&& ch != victim)
{
if (check_counter(ch,victim,dam,dt))
return FALSE;
if(is_affected(victim,gsn_steel_nerves))
dam=dam*6/10;
if(victim->morph_form[0]==MORPH_BEAR) {
dam=dam*7/10;
}
}
if(dt==gsn_dual_backstab || HITS) {
if(is_affected(victim,gsn_steel_nerves))
dam=dam*6/10;
if(victim->morph_form[0]==MORPH_BEAR)
dam=dam*7/10;
}
if ( victim->position > POS_STUNNED )
{
if ( victim->fighting == NULL )
set_fighting( victim, ch );
if (victim->timer <= 4)
victim->position = POS_FIGHTING;
}
if ( victim->position > POS_STUNNED )
{
if ( ch->fighting == NULL )
set_fighting( ch, victim );
/*
* If victim is charmed, ch might attack victim's master.
*/
if ( IS_NPC(ch)
&& IS_NPC(victim)
&& IS_AFFECTED(victim, AFF_CHARM)
&& victim->master != NULL
&& victim->master->in_room == ch->in_room
&& number_bits( 3 ) == 0 )
{
stop_fighting( ch, FALSE );
multi_hit( ch, victim->master, TYPE_UNDEFINED );
return FALSE;
}
}
/*
* More charm stuff.
*/
if ( victim->master == ch )
stop_follower( victim );
}
/*
* Inviso attacks ... not.
*/
un_camouflage(ch,NULL);
un_hide(ch, NULL);
un_invis(ch, NULL);
un_sneak(ch, NULL);
/*
* Damage modifiers.
*/
if ( dam > 1 && !IS_NPC(victim)
&& victim->pcdata->condition[COND_DRUNK] > 10 )
dam = 9 * dam / 10;
if ( dam > 1 && IS_AFFECTED(victim, AFF_SANCTUARY) )
{
if ( (dt >= TYPE_HIT || dt == gsn_dual_wield || dt == gsn_tertiary_wield))
{
if (dt == gsn_dual_wield)
wield = get_eq_char(ch,WEAR_DUAL_WIELD);
else if (dt == gsn_tertiary_wield)
wield = get_eq_char(ch,WEAR_TERTIARY_WIELD);
else
wield = get_eq_char(ch,WEAR_WIELD);
if (wield == NULL )
dam /= 2;
else if (wield->pIndexData->vnum != 29724)
dam /= 2;
}
else
dam /=2;
}
obj = get_eq_char(ch,WEAR_HEAD);
if (obj != NULL
&& obj->pIndexData->vnum == OBJ_VNUM_TIARA
&& (dam_type == DAM_COLD || dam_type == DAM_FIRE
|| dam_type == DAM_HOLY || dam_type == DAM_NEGATIVE
|| dam_type == DAM_ACID) )
{
if (dam > 125)
{
dam = (dam - 125);
dam *= 6;
dam /= 10;
dam += 125;
}
}
if (check_crown_blood(ch,victim,dt,dam,dam_type))
return FALSE;
if ( dam > 1 && ((IS_AFFECTED(victim, AFF_PROTECT_EVIL) && IS_EVIL(ch) )
|| (IS_AFFECTED(victim, AFF_PROTECT_GOOD) && IS_GOOD(ch) )))
dam -= dam / 4;
if (is_affected(victim,gsn_spellbane))
{
if (dam_type > 3)
{
dam *= 7;
dam /= 10;
}
}
immune = FALSE;
if (check_absorb(ch,victim,dt))
return FALSE;
if (eye_of_beholder_absorb(ch,victim,dt,dam,dam_type))
return FALSE;
/*
* Check for parry, and dodge.
*/
if (( (dt >= TYPE_HIT || dt == gsn_dual_wield) || (dt == gsn_tertiary_wield) )
&& ch != victim)
{
if ( check_parry( ch, victim, dt ) )
{
do_counter_parry(ch,victim,dt, dam);
return FALSE;
}
if ( check_block( ch, victim, dt) )
return FALSE;
if ( check_dodge( ch, victim, dt ) )
return FALSE;
if ( check_shield_block(ch,victim, dt))
return FALSE;
}
switch(check_immune(victim,dam_type))
{
case(IS_IMMUNE):
immune = TRUE;
dam = 0;
break;
case(IS_RESISTANT):
if (IS_NPC(victim))
dam -= dam/3;
else
dam -= dam/5;
break;
case(IS_VULNERABLE):
dam += dam/3;
break;
}
if (show)
dam_message( ch, victim, dam, dt, immune );
if (dam == 0)
return FALSE;
/*
* Hurt the victim.
* Inform the victim of his new state.
*/
victim->hit -= dam;
if (dam_type == DAM_FIRE || dam_type == DAM_ACID)
victim->noregen_dam += dam;
if (victim->noregen_dam > victim->max_hit)
victim->noregen_dam = victim->max_hit;
if ( !IS_NPC(victim)
&& victim->level >= LEVEL_IMMORTAL
&& victim->hit < 1 )
victim->hit = 1;
update_pos( victim );
switch( victim->position )
{
case POS_MORTAL:
act( "$n is mortally wounded, and will die soon, if not aided.",
victim, NULL, NULL, TO_ROOM );
send_to_char(
"You are mortally wounded, and will die soon, if not aided.\n\r",
victim );
break;
case POS_INCAP:
act( "$n is incapacitated and will slowly die, if not aided.",
victim, NULL, NULL, TO_ROOM );
send_to_char(
"You are incapacitated and will slowly die, if not aided.\n\r",
victim );
break;
case POS_STUNNED:
act( "$n is stunned, but will probably recover.",
victim, NULL, NULL, TO_ROOM );
send_to_char("You are stunned, but will probably recover.\n\r",
victim );
break;
case POS_DEAD:
act( "$n is DEAD!!", victim, 0, 0, TO_ROOM );
send_to_char( "You have been KILLED!!\n\r\n\r", victim );
break;
default:
if ( dam > victim->max_hit / 4 )
send_to_char( "That really did HURT!\n\r", victim );
if ( victim->hit < victim->max_hit / 4 )
send_to_char( "You sure are BLEEDING!\n\r", victim );
break;
}
/*
* Sleep spells and extremely wounded folks.
*/
if ( !IS_AWAKE(victim) )
stop_fighting( victim, FALSE );
/*
* Payoff for killing things.
*/
if ( victim->position == POS_DEAD )
{
group_gain( ch, victim );
if ( !IS_NPC(victim) )
{
sprintf( log_buf, "%s killed by %s at %d",
victim->name,
(IS_NPC(ch) ? ch->short_descr : ch->name),
ch->in_room->vnum );
log_string( log_buf );
/*
* Dying penalty:
*/
if (IS_NPC(ch) && !IS_AFFECTED(ch, AFF_CHARM))
victim->exp = UMAX(0, victim->exp - UMIN(exp_per_level(victim),victim->exp*.15));
}
sprintf( log_buf, "%s got toasted by %s at %s [room %d]",
(IS_NPC(victim) ? victim->short_descr : victim->name),
(IS_NPC(ch) ? ch->short_descr : ch->name),
ch->in_room->name, ch->in_room->vnum);
if (IS_NPC(victim))
wiznet(log_buf,NULL,NULL,WIZ_MOBDEATHS,0,0);
else
wiznet(log_buf,NULL,NULL,WIZ_DEATHS,0,0);
raw_kill(ch, victim );
/* RT new auto commands */
if ( !IS_NPC(ch) && IS_NPC(victim) )
{
corpse = get_obj_list( ch, "corpse", ch->in_room->contents );
if ( IS_SET(ch->act, PLR_AUTOLOOT) &&
corpse && corpse->contains) /* exists and not empty */
do_get( ch, "all corpse" );
if (IS_SET(ch->act,PLR_AUTOGOLD) &&
corpse && corpse->contains && /* exists and not empty */
!IS_SET(ch->act,PLR_AUTOLOOT))
do_get(ch, "gold corpse");
if ( IS_SET(ch->act, PLR_AUTOSAC) )
if ( IS_SET(ch->act,PLR_AUTOLOOT) && corpse && corpse->contains)
return TRUE; /* leave if corpse has treasure */
else
do_sacrifice( ch, "corpse" );
}
return TRUE;
}
if ( victim == ch )
return TRUE;
/*
* Take care of link dead people.
*/
if ( !IS_NPC(victim) && victim->desc == NULL )
{
if ( number_range( 0, victim->wait ) == 0 )
{
do_recall( victim, "" );
return TRUE;
}
}
/*
* Wimp out?
*/
if ( IS_NPC(victim) && dam > 0 && victim->wait < PULSE_VIOLENCE / 2)
{
if ( ( IS_SET(victim->act, ACT_WIMPY) && number_bits( 2 ) == 0
&& victim->hit < victim->max_hit / 5)
|| ( IS_AFFECTED(victim, AFF_CHARM) && victim->master != NULL
&& victim->master->in_room != victim->in_room ) )
do_flee( victim, "" );
}
if ( !IS_NPC(victim)
&& victim->hit > 0
&& victim->hit <= victim->wimpy
&& victim->wait < PULSE_VIOLENCE / 2 )
do_flee( victim, "" );
tail_chain( );
return TRUE;
}
bool is_safe(CHAR_DATA *ch, CHAR_DATA *victim)
{
if (victim->in_room == NULL || ch->in_room == NULL)
return TRUE;
if (IS_NPC(ch) && victim->invis_level >= LEVEL_HERO)
return TRUE;
if (!IS_NPC(ch))
{
if (ch->pcdata->death_status == HAS_DIED)
return TRUE;
}
if (!IS_NPC(victim))
{
if (victim->pcdata->death_status == HAS_DIED)
return TRUE;
}
/* Handle Link dead players , only saves from PKS, not mobs -Ceran */
if (!IS_NPC(victim) && victim->desc == NULL && !IS_NPC(ch)
&& victim->fighting != ch && ch->fighting != victim)
{
act("The gods protect $N from $n.",ch,0,victim,TO_NOTVICT);
act("The gods protect $N from you.",ch,0,victim,TO_CHAR);
return TRUE;
}
if (is_affected(victim,gsn_timestop))
{
act("$n is stuck in time and the gods protect $m.",victim,0,0,TO_ROOM);
act("$N tries to do something but you are stuck in time and unaffected.",victim,0,ch,TO_CHAR);
if (victim->fighting != NULL)
victim->fighting = NULL;
return TRUE;
}
if (victim->fighting == ch || victim == ch)
return FALSE;
if (IS_NPC(ch) && ch->last_fought == victim)
return FALSE;
if (victim->ghost > 0)
{
act("The gods protect $N from $n.",ch,0,victim,TO_NOTVICT);
act("The gods protect you from $n.",ch,0,victim,TO_VICT);
act("The gods protect $N from you.",ch,0,victim,TO_CHAR);
return TRUE;
}
if (ch->ghost > 0)
{
if (!IS_NPC(victim))
{
act("The gods protect $N from $n.",ch,0,victim,TO_NOTVICT);
act("The gods protect you from $n.",ch,0,victim,TO_VICT);
act("The gods protect $N from you.",ch,0,victim,TO_CHAR);
return TRUE;
}
if (IS_AFFECTED(victim,AFF_CHARM) && victim->master != NULL
&& !IS_NPC(victim->master))
{
act("The gods protect $N from $n.",ch,0,victim,TO_NOTVICT);
act("The gods protect you from $n.",ch,0,victim,TO_VICT);
act("The gods protect $N from you.",ch,0,victim,TO_CHAR);
return TRUE;
}
}
if (IS_IMMORTAL(ch) && is_affected(ch,gsn_riot) && !IS_NPC(victim))
{
send_to_char("You can't riot on mortals.\n\r",ch);
return TRUE;
}
if (IS_IMMORTAL(ch) && ch->level > LEVEL_IMMORTAL)
return FALSE;
if (IS_SET(victim->act,PLR_CRIMINAL))
{
if (IS_NPC(ch) && ch->pIndexData->vnum == MOB_VNUM_ENFORCER)
return FALSE;
}
if(IS_NPC(victim)&&victim->pIndexData->vnum==MOB_VNUM_ENFORCER)
return FALSE;
/* killing mobiles */
if (IS_NPC(victim))
{
if (!IS_NPC(ch))
{
/* no charmed creatures unless in pk of master */
if (IS_AFFECTED(victim,AFF_CHARM) && !can_pk(ch,victim->master))
{
act("The gods protect $N from $n.",ch,0,victim,TO_NOTVICT);
act("The gods protect you from $n.",ch,0,victim,TO_VICT);
act("The gods protect $N from you.",ch,0,victim,TO_CHAR);
return TRUE;
}
}
else
{
if (IS_AFFECTED(ch,AFF_CHARM) && IS_AFFECTED(victim,AFF_CHARM)
&& !can_pk(ch->master,victim->master))
return TRUE;
}
}
/* killing players */
else
{
/* NPC doing the killing */
if (IS_NPC(ch))
{
/* charmed mobs and pets cannot attack players while owned */
if (IS_AFFECTED(ch,AFF_CHARM) && ch->master != NULL
&& ch->master->fighting != victim)
{
send_to_char("Players are your friends!\n\r",ch);
return TRUE;
}
}
/* player doing the killing */
else
{
if (!can_pk(ch, victim))
{
act("The gods protect $N from $n.",ch,0,victim,TO_NOTVICT);
act("The gods protect you from $n.",ch,0,victim,TO_VICT);
act("The gods protect $N from you.",ch,0,victim,TO_CHAR);
return TRUE;
}
}
}
return FALSE;
}
bool is_safe_spell(CHAR_DATA *ch, CHAR_DATA *victim, bool area )
{
if (victim->in_room == NULL || ch->in_room == NULL)
return TRUE;
if (victim == ch && area)
return TRUE;
if (victim->fighting == ch || victim == ch)
return FALSE;
if (IS_IMMORTAL(ch) && ch->level > LEVEL_IMMORTAL && !area)
return FALSE;
/* killing mobiles */
if (IS_NPC(victim))
{
/* safe room? */
if (IS_SET(victim->in_room->room_flags,ROOM_SAFE))
return TRUE;
if (victim->pIndexData->pShop != NULL)
return TRUE;
/* no killing healers, trainers, etc */
if (IS_SET(victim->act,ACT_TRAIN)
|| IS_SET(victim->act,ACT_PRACTICE)
|| IS_SET(victim->act,ACT_IS_HEALER)
|| IS_SET(victim->act,ACT_IS_CHANGER))
return TRUE;
if (!IS_NPC(ch))
{
/* no pets */
if (IS_SET(victim->act,ACT_PET))
return TRUE;
/* no charmed creatures unless owner */
if (IS_AFFECTED(victim,AFF_CHARM) && (area || ch != victim->master))
return TRUE;
/* legal kill? -- cannot hit mob fighting non-group member */
if (victim->fighting != NULL && !is_same_group(ch,victim->fighting))
return TRUE;
}
else
{
/* area effect spells do not hit other mobs */
if (area && !is_same_group(victim,ch->fighting))
return TRUE;
}
}
/* killing players */
else
{
if (area && IS_IMMORTAL(victim) && victim->level > LEVEL_IMMORTAL)
return TRUE;
/* NPC doing the killing */
if (IS_NPC(ch))
{
/* charmed mobs and pets cannot attack players while owned */
if (IS_AFFECTED(ch,AFF_CHARM) && ch->master != NULL
&& ch->master->fighting != victim)
return TRUE;
/* safe room? */
if (IS_SET(victim->in_room->room_flags,ROOM_SAFE))
return TRUE;
/* legal kill? -- mobs only hit players grouped with opponent*/
if (ch->fighting != NULL && !is_same_group(ch->fighting,victim))
return TRUE;
}
/* player doing the killing */
else
{
if (!is_clan(ch))
return TRUE;
if (IS_SET(victim->act,PLR_KILLER) || IS_SET(victim->act,PLR_THIEF))
return FALSE;
if (!is_clan(victim))
return TRUE;
if (ch->level > victim->level + 8)
return TRUE;
}
}
return FALSE;
}
/*
* See if an attack justifies a KILLER flag.
*/
void check_killer( CHAR_DATA *ch, CHAR_DATA *victim )
{
/*
* Follow charm thread to responsible character.
* Attacking someone's charmed char is hostile!
*/
while ( IS_AFFECTED(victim, AFF_CHARM) && victim->master != NULL )
victim = victim->master;
/*
* NPC's are fair game.
* So are killers and thieves.
*/
if ( IS_NPC(victim)
|| IS_SET(victim->act, PLR_KILLER)
|| IS_SET(victim->act, PLR_THIEF))
return;
/*
* NPC's are cool of course (as long as not charmed).
* Hitting yourself is cool too (bleeding).
* So is being immortal (Alander's idea).
* And current killers stay as they are.
*/
if ( IS_NPC(ch)
|| ch == victim
|| ch->level >= LEVEL_IMMORTAL
|| !is_clan(ch)
|| IS_SET(ch->act, PLR_KILLER)
|| ch->fighting == victim)
return;
save_char_obj( ch );
return;
}
/* Check a counter-parry */
void do_counter_parry(CHAR_DATA *ch,CHAR_DATA *victim,int dt, int dam)
{
int chance;
int tmp_dt;
char *attack;
OBJ_DATA *wield;
char buf1[MAX_STRING_LENGTH];
char buf2[MAX_STRING_LENGTH];
if ((chance = get_skill(victim,gsn_counter_parry)) == 0
|| IS_NPC(victim)
|| victim->level < skill_table[gsn_counter_parry].skill_level[victim->class])
return;
chance /= 5;
if (chance > 20)
chance = 20;
if (number_percent() < chance)
{
tmp_dt = TYPE_HIT;
if (dt == gsn_dual_wield)
wield = get_eq_char(ch,WEAR_DUAL_WIELD);
else if (dt == gsn_tertiary_wield)
wield = get_eq_char(ch,WEAR_TERTIARY_WIELD);
else
wield = get_eq_char(ch,WEAR_WIELD);
if (wield != NULL)
tmp_dt += wield->value[3];
else
tmp_dt += ch->dam_type;
if (tmp_dt > TYPE_HIT && tmp_dt < TYPE_HIT + MAX_DAMAGE_MESSAGE)
attack = attack_table[tmp_dt - TYPE_HIT].noun;
else
attack = attack_table[0].name;
sprintf(buf1,"You counter parry $n's %s!",attack);
sprintf(buf2,"$N counter parries your %s!",attack);
act(buf1,ch,0,victim,TO_VICT);
act(buf2,ch,0,victim,TO_CHAR);
if (clan_down(victim,CLAN_CRUSADER))
return;
damage_old(victim,ch,dam,gsn_counter_parry,TYPE_HIT,TRUE);
check_improve(victim,gsn_counter_parry,TRUE,3);
return;
}
check_improve(victim,gsn_counter_parry,FALSE,2);
return;
}
bool check_counter(CHAR_DATA *ch,CHAR_DATA *victim,int dam,int dt)
{
int chance;
if (dt == gsn_counter )
return FALSE;
if (dt == gsn_counter_parry)
return FALSE;
if (ch->fighting != NULL)
return FALSE;
if ( (chance = get_skill(victim,gsn_counter)) == 0
|| victim->level < skill_table[gsn_counter].skill_level[ch->class])
return FALSE;
if (!can_see(victim,ch))
chance -= 30;
if (get_eq_char(victim,WEAR_WIELD) == NULL)
chance -= 50;
chance += (victim->level - ch->level);
if (victim->position != POS_FIGHTING && IS_AWAKE(victim))
{
if (number_percent() < chance)
{
act("You counter $n's attack!",ch,0,victim,TO_VICT);
act("$N counters your attack!",ch,0,victim,TO_CHAR);
act("$N counters $n's attack!",ch,0,victim,TO_NOTVICT);
check_improve(victim,gsn_counter,TRUE,1);
damage_old(victim,ch,dam,gsn_counter,TYPE_UNDEFINED,TRUE);
return TRUE;
}
}
check_improve(victim,gsn_counter,FALSE,2);
return FALSE;
}
/*
* Check for parry.
*/
bool check_parry( CHAR_DATA *ch, CHAR_DATA *victim, int dt )
{
int chance;
int tmp_dt;
OBJ_DATA *wield;
char buf1[MAX_STRING_LENGTH];
char buf2[MAX_STRING_LENGTH];
char *attack;
if ( !IS_AWAKE(victim) )
return FALSE;
chance = get_skill(victim,gsn_parry) / 2;
if ( get_eq_char( victim, WEAR_WIELD ) == NULL )
{
if (IS_NPC(victim))
chance /= 2;
else
return FALSE;
}
if (!can_see(ch,victim))
chance /= 2;
if ( number_percent( ) >= chance + (victim->drain_level + victim->level) - (ch->drain_level + ch->level) )
{
check_improve(victim,gsn_parry,FALSE,6);
return FALSE;
}
/* The rest is all new dual wield stuff, with dam types displayed for
clarity when dual wielding - Ceran */
tmp_dt = TYPE_HIT;
if (dt == gsn_dual_wield)
wield = get_eq_char(ch,WEAR_DUAL_WIELD);
else if (dt == gsn_tertiary_wield)
wield = get_eq_char(ch,WEAR_TERTIARY_WIELD);
else
wield = get_eq_char(ch,WEAR_WIELD);
if (wield != NULL)
tmp_dt += wield->value[3];
else
tmp_dt += ch->dam_type;
if (tmp_dt > TYPE_HIT && tmp_dt < TYPE_HIT + MAX_DAMAGE_MESSAGE)
attack = attack_table[tmp_dt - TYPE_HIT].noun;
else
{
bug("In parry, bad dam message: dt %d.",tmp_dt);
sprintf(buf1,"Player: %s Target: %s.",ch->name,victim->name);
bug(buf1, 0);
attack = attack_table[0].name;
}
sprintf(buf1,"You parry $n's %s.",attack);
sprintf(buf2,"$N parries your %s.",attack);
act(buf1,ch,0,victim,TO_VICT);
act(buf2,ch,0,victim,TO_CHAR);
check_improve(victim,gsn_parry,TRUE,6);
return TRUE;
}
/* Block for monks */
bool check_block( CHAR_DATA *ch, CHAR_DATA *victim, int dt )
{
int chance;
int tmp_dt;
OBJ_DATA *wield;
char buf1[MAX_STRING_LENGTH];
char buf2[MAX_STRING_LENGTH];
char *attack;
if ( !IS_AWAKE(victim) )
return FALSE;
if (IS_NPC(victim))
return FALSE;
chance = get_skill(victim,gsn_block);
if ( victim->level <skill_table[gsn_block].skill_level[victim->class])
return FALSE;
chance /= 3;
if (get_eq_char(victim,WEAR_WIELD) != NULL)
return FALSE;
if (!can_see(ch,victim))
chance /= 2;
if ( number_percent( ) >= chance + (victim->drain_level + victim->level) - (ch->drain_level + ch->level) )
{
check_improve(victim,gsn_block,FALSE,5);
return FALSE;
}
/* The rest is all new dual wield stuff, with dam types displayed for
clarity when dual wielding - Ceran */
tmp_dt = TYPE_HIT;
if (dt == gsn_dual_wield)
wield = get_eq_char(ch,WEAR_DUAL_WIELD);
else if (dt == gsn_tertiary_wield)
wield = get_eq_char(ch,WEAR_TERTIARY_WIELD);
else
wield = get_eq_char(ch,WEAR_WIELD);
if (wield != NULL)
tmp_dt += wield->value[3];
else
tmp_dt += ch->dam_type;
if (tmp_dt > TYPE_HIT && tmp_dt < TYPE_HIT + MAX_DAMAGE_MESSAGE)
attack = attack_table[tmp_dt - TYPE_HIT].noun;
else
{
bug("In check_block, bad dam message: dt %d.",tmp_dt);
attack = attack_table[0].name;
}
sprintf(buf1,"You hand block $n's %s.",attack);
sprintf(buf2,"$N hand blocks your %s.",attack);
act(buf1,ch,0,victim,TO_VICT);
act(buf2,ch,0,victim,TO_CHAR);
check_improve(victim,gsn_block,TRUE,6);
return TRUE;
}
/*
* Check for shield block.
*/
bool check_shield_block( CHAR_DATA *ch, CHAR_DATA *victim, int dt )
{
int chance;
int tmp_dt;
OBJ_DATA *wield;
char buf1[MAX_STRING_LENGTH];
char buf2[MAX_STRING_LENGTH];
char *attack;
if ( !IS_AWAKE(victim) )
return FALSE;
if(victim->level < skill_table[gsn_shield_block].skill_level[victim->class])
return FALSE;
chance = (( get_skill(victim,gsn_shield_block) / 4) + 15);
if ( get_eq_char( victim, WEAR_SHIELD ) == NULL )
return FALSE;
chance += (victim->drain_level + victim->level - (ch->drain_level + ch->level));
if ( number_percent( ) >= chance )
{
check_improve(victim,gsn_shield_block,FALSE,4);
return FALSE;
}
tmp_dt = TYPE_HIT;
if (dt == gsn_dual_wield)
wield = get_eq_char(ch,WEAR_DUAL_WIELD);
else if (dt == gsn_tertiary_wield)
wield = get_eq_char(ch,WEAR_TERTIARY_WIELD);
else
wield = get_eq_char(ch,WEAR_WIELD);
if (wield != NULL)
tmp_dt += wield->value[3];
else
tmp_dt += ch->dam_type;
if (tmp_dt > TYPE_HIT && tmp_dt < TYPE_HIT + MAX_DAMAGE_MESSAGE)
attack = attack_table[tmp_dt - TYPE_HIT].noun;
else
{
bug("In shield block, bad dam message: dt %d.",tmp_dt);
attack = attack_table[0].name;
}
sprintf(buf1,"You shield block $n's %s.",attack);
sprintf(buf2,"$N shield blocks your %s.",attack);
act(buf1,ch,0,victim,TO_VICT);
act(buf2,ch,0,victim,TO_CHAR);
check_improve(victim,gsn_shield_block,TRUE,4);
return TRUE;
}
/*
* Check for dodge.
*/
bool check_dodge( CHAR_DATA *ch, CHAR_DATA *victim, int dt )
{
int chance;
int tmp_dt;
OBJ_DATA *wield;
char buf1[MAX_STRING_LENGTH];
char buf2[MAX_STRING_LENGTH];
char *attack;
int dex, dexa;
if ( !IS_AWAKE(victim) )
return FALSE;
chance = ( 3 * get_skill(victim,gsn_dodge) / 10);
dex = get_curr_stat(victim,STAT_DEX);
dexa= get_curr_stat(ch,STAT_DEX);
if (dex <= 5)
chance += 0;
else if (dex <= 10)
chance += dex/2;
else if (dex <=15)
chance += (2*dex/3);
else if (dex <= 20)
chance += (8*dex/10);
else
chance += dex;
chance+=dex-dexa;
chance+=(ch->size-victim->size)*5;
if (!can_see(victim,ch))
chance /= 2;
if ( number_percent( ) >= chance + (victim->drain_level + victim->level) - (ch->drain_level + ch->level) )
{
check_improve(victim,gsn_dodge,FALSE,4);
return FALSE;
}
/* The rest is all new dual wield stuff, with dam types displayed for
clarity when dual wielding - Ceran */
tmp_dt = TYPE_HIT;
if (dt == gsn_dual_wield)
wield = get_eq_char(ch,WEAR_DUAL_WIELD);
else if (dt == gsn_tertiary_wield)
wield = get_eq_char(ch,WEAR_TERTIARY_WIELD);
else
wield = get_eq_char(ch,WEAR_WIELD);
if (wield != NULL)
tmp_dt += wield->value[3];
else
tmp_dt += ch->dam_type;
if (tmp_dt > TYPE_HIT && tmp_dt < TYPE_HIT + MAX_DAMAGE_MESSAGE)
attack = attack_table[tmp_dt - TYPE_HIT].noun;
else
{
bug("In dodge, bad dam message: dt %d.",tmp_dt);
attack = attack_table[0].name;
}
sprintf(buf1,"You dodge $n's %s.",attack);
sprintf(buf2,"$N dodges your %s.",attack);
act(buf1,ch,0,victim,TO_VICT);
act(buf2,ch,0,victim,TO_CHAR);
check_improve(victim,gsn_dodge,TRUE,5);
return TRUE;
}
/*
* Set position of a victim.
*/
void update_pos( CHAR_DATA *victim )
{
if ( victim->hit > 0 )
{
if ( victim->position <= POS_STUNNED )
victim->position = POS_STANDING;
return;
}
if ( IS_NPC(victim) && victim->hit < 1 )
{
victim->position = POS_DEAD;
return;
}
if ( victim->hit <= -11 )
{
victim->position = POS_DEAD;
return;
}
if ( victim->hit <= -6 ) victim->position = POS_MORTAL;
else if ( victim->hit <= -3 ) victim->position = POS_INCAP;
else victim->position = POS_STUNNED;
return;
}
/*
* Start fights.
*/
void set_fighting( CHAR_DATA *ch, CHAR_DATA *victim )
{
if ( ch->fighting != NULL )
{
bug( "Set_fighting: already fighting", 0 );
return;
}
if ( IS_AFFECTED(ch, AFF_SLEEP) )
affect_strip( ch, gsn_sleep );
ch->fighting = victim;
ch->position = POS_FIGHTING;
return;
}
/*
* Stop fights.
*/
void stop_fighting( CHAR_DATA *ch, bool fBoth )
{
CHAR_DATA *fch;
for ( fch = char_list; fch != NULL; fch = fch->next )
{
if ( fch == ch || ( fBoth && fch->fighting == ch ) )
{
fch->fighting = NULL;
fch->position = IS_NPC(fch) ? fch->default_pos : POS_STANDING;
update_pos( fch );
}
}
return;
}
/*
* Make a corpse out of a character.
*/
void make_corpse( CHAR_DATA *killer,CHAR_DATA *ch )
{
char buf[MAX_STRING_LENGTH];
OBJ_DATA *corpse;
OBJ_DATA *obj;
OBJ_DATA *obj_next;
OBJ_DATA *head;
char *name;
if (IS_NPC(ch) && ch->pIndexData->vnum == 13724)
{
act("One of $n's massive heads falls decapitated onto the ground.",ch,0,0,TO_ROOM);
head = create_object(get_obj_index(OBJ_VNUM_HYDRA_HEAD),0);
if (head != NULL)
obj_to_room(head,ch->in_room);
}
if (IS_NPC(ch) && (ch->pIndexData->vnum == MOB_VNUM_PROTECTOR
|| ch->pIndexData->vnum == MOB_VNUM_ANCIENT
|| ch->pIndexData->vnum == MOB_VNUM_ARCANA
|| ch->pIndexData->vnum == MOB_VNUM_LIFE
|| ch->pIndexData->vnum == MOB_VNUM_OUTLAW
|| ch->pIndexData->vnum == MOB_VNUM_CRUSADER) )
{
act("$n's body crumples up and dissolves into dust.",ch,0,0,TO_ROOM);
for ( obj = ch->carrying; obj != NULL; obj = obj_next )
{
bool floating = FALSE;
obj_next = obj->next_content;
if (obj->wear_loc != WEAR_BRAND)
obj_from_char( obj );
if (obj->item_type == ITEM_POTION)
obj->timer = number_range(500,1000);
if (obj->item_type == ITEM_SCROLL)
obj->timer = number_range(1000,2500);
if (IS_SET(obj->extra_flags,ITEM_ROT_DEATH) && !floating)
{
obj->timer = number_range(5,10);
REMOVE_BIT(obj->extra_flags,ITEM_ROT_DEATH);
}
REMOVE_BIT(obj->extra_flags,ITEM_VIS_DEATH);
if (obj->pIndexData->limcount > obj->pIndexData->limtotal
&& obj->pIndexData->limtotal > 0)
{
act("$p flashes brightly and vaporizes.",ch,obj,NULL,TO_ROOM);
extract_obj( obj );
}
else if (floating)
{
if (IS_OBJ_STAT(obj,ITEM_ROT_DEATH)) /* get rid of it! */
{
if (obj->contains != NULL)
{
OBJ_DATA *in, *in_next;
act("$p evaporates,scattering its contents.",
ch,obj,NULL,TO_ROOM);
for (in = obj->contains; in != NULL; in = in_next)
{
in_next = in->next_content;
obj_from_obj(in);
obj_to_room(in,ch->in_room);
}
}
else
act("$p evaporates.",
ch,obj,NULL,TO_ROOM);
extract_obj(obj);
}
else
{
act("$p falls to the floor.",ch,obj,NULL,TO_ROOM);
obj_to_room(obj,ch->in_room);
}
}
else if (obj->wear_loc != WEAR_BRAND)
{
act("$p falls to the floor.",ch,obj,NULL,TO_ROOM);
obj_to_room(obj,ch->in_room);
}
}
return;
}
if ( IS_NPC(ch) )
{
name = ch->short_descr;
corpse = create_object(get_obj_index(OBJ_VNUM_CORPSE_NPC), 0);
corpse->timer = number_range( 5, 8 );
free_string(corpse->talked);
if (IS_NPC(killer))
corpse->talked = str_dup(killer->short_descr);
else
corpse->talked = str_dup(killer->name);
if ( ch->gold > 0 )
{
obj_to_obj( create_money( ch->gold, ch->silver ), corpse );
ch->gold = 0;
ch->silver = 0;
}
corpse->cost = 0;
}
else
{
name = ch->name;
corpse = create_object(get_obj_index(OBJ_VNUM_CORPSE_PC), 0);
corpse->timer = number_range( 20, 35 );
corpse->value[4] = ch->temple;
REMOVE_BIT(ch->act,PLR_CANLOOT);
free_string(corpse->talked);
if (IS_NPC(killer))
corpse->talked = str_dup(killer->short_descr);
else
corpse->talked = str_dup(killer->name);
if (!is_clan(ch))
corpse->owner = str_dup(ch->name);
else
{
if (ch->gold > 1 || ch->silver > 1)
{
obj_to_obj(create_money(ch->gold, ch->silver), corpse);
ch->gold = 0;
ch->silver = 0;
}
}
corpse->cost = 0;
}
corpse->level = ch->level;
if (IS_SET(ch->act,ACT_UNDEAD) || IS_SET(ch->form,FORM_UNDEAD))
SET_BIT(corpse->extra_flags,CORPSE_NO_ANIMATE);
sprintf( buf, corpse->short_descr, name );
free_string( corpse->short_descr );
corpse->short_descr = str_dup( buf );
sprintf( buf, corpse->description, name );
free_string( corpse->description );
corpse->description = str_dup( buf );
for ( obj = ch->carrying; obj != NULL; obj = obj_next )
{
bool floating = FALSE;
obj_next = obj->next_content;
if (obj->wear_loc != WEAR_BRAND)
obj_from_char( obj );
if (obj->item_type == ITEM_POTION)
obj->timer = number_range(500,1000);
if (obj->item_type == ITEM_SCROLL)
obj->timer = number_range(1000,2500);
/* Area specific objects, remove these if you don't use the area */
if (obj->pIndexData->vnum == OBJ_VNUM_HYDRA_SLAYER)
obj->timer = number_range(500,1500);
else if (obj->pIndexData->vnum == OBJ_VNUM_HYDRA_HEAD)
obj->timer = number_range(300,900);
if (IS_SET(obj->extra_flags,ITEM_ROT_DEATH) && !floating)
{
obj->timer = number_range(5,10);
REMOVE_BIT(obj->extra_flags,ITEM_ROT_DEATH);
}
REMOVE_BIT(obj->extra_flags,ITEM_VIS_DEATH);
if (obj->pIndexData->limcount > obj->pIndexData->limtotal
&& obj->pIndexData->limtotal > 0)
{
act("$p flashes brightly and vaporizes.",ch,obj,NULL,TO_ROOM);
extract_obj( obj );
}
else if (floating)
{
if (IS_OBJ_STAT(obj,ITEM_ROT_DEATH)) /* get rid of it! */
{
if (obj->contains != NULL)
{
OBJ_DATA *in, *in_next;
act("$p evaporates,scattering its contents.",
ch,obj,NULL,TO_ROOM);
for (in = obj->contains; in != NULL; in = in_next)
{
in_next = in->next_content;
obj_from_obj(in);
obj_to_room(in,ch->in_room);
}
}
else
act("$p evaporates.",
ch,obj,NULL,TO_ROOM);
extract_obj(obj);
}
else
{
act("$p falls to the floor.",ch,obj,NULL,TO_ROOM);
obj_to_room(obj,ch->in_room);
}
}
else if (obj->wear_loc != WEAR_BRAND)
obj_to_obj( obj, corpse );
}
obj_to_room( corpse, ch->in_room );
return;
}
/*
* Improved Death_cry contributed by Diavolo.
*/
void death_cry( CHAR_DATA *ch )
{
ROOM_INDEX_DATA *was_in_room;
char *msg;
int door;
int vnum;
vnum = 0;
msg = "You hear $n's death cry.";
switch ( number_bits(4))
{
case 0: msg = "$n hits the ground ... DEAD."; break;
case 1:
if (ch->material == 0)
{
msg = "$n splatters blood on your armor.";
break;
}
case 2:
if (IS_SET(ch->parts,PART_GUTS))
{
msg = "$n spills $s guts all over the floor.";
vnum = OBJ_VNUM_GUTS;
}
break;
case 3:
if (IS_SET(ch->parts,PART_HEAD))
{
msg = "$n's severed head plops on the ground.";
vnum = OBJ_VNUM_SEVERED_HEAD;
}
break;
case 4:
if (IS_SET(ch->parts,PART_HEART))
{
msg = "$n's heart is torn from $s chest.";
vnum = OBJ_VNUM_TORN_HEART;
}
break;
case 5:
if (IS_SET(ch->parts,PART_ARMS))
{
msg = "$n's arm is sliced from $s dead body.";
vnum = OBJ_VNUM_SLICED_ARM;
}
break;
case 6:
if (IS_SET(ch->parts,PART_LEGS))
{
msg = "$n's leg is sliced from $s dead body.";
vnum = OBJ_VNUM_SLICED_LEG;
}
break;
case 7:
if (IS_SET(ch->parts,PART_BRAINS))
{
msg = "$n's head is shattered, and $s brains splash all over you.";
vnum = OBJ_VNUM_BRAINS;
}
}
act( msg, ch, NULL, NULL, TO_ROOM );
if ( vnum != 0 )
{
char buf[MAX_STRING_LENGTH];
OBJ_DATA *obj;
char *name;
name = IS_NPC(ch) ? ch->short_descr : ch->name;
obj = create_object( get_obj_index( vnum ), 0 );
obj->timer = number_range( 4, 7 );
sprintf( buf, obj->short_descr, name );
free_string( obj->short_descr );
obj->short_descr = str_dup( buf );
sprintf( buf, obj->description, name );
free_string( obj->description );
obj->description = str_dup( buf );
if (obj->item_type == ITEM_FOOD)
{
if (IS_SET(ch->form,FORM_POISON))
obj->value[3] = 1;
else if (!IS_SET(ch->form,FORM_EDIBLE))
obj->item_type = ITEM_TRASH;
}
obj_to_room( obj, ch->in_room );
}
if ( IS_NPC(ch) )
msg = "You hear something's death cry.";
else
msg = "You hear someone's death cry.";
was_in_room = ch->in_room;
for ( door = 0; door <= 5; door++ )
{
EXIT_DATA *pexit;
if ( ( pexit = was_in_room->exit[door] ) != NULL
&& pexit->u1.to_room != NULL
&& pexit->u1.to_room != was_in_room )
{
ch->in_room = pexit->u1.to_room;
act( msg, ch, NULL, NULL, TO_ROOM );
}
}
ch->in_room = was_in_room;
return;
}
void raw_kill( CHAR_DATA *ch,CHAR_DATA *victim )
{
int i, cloak = 0;
char strsave[MAX_INPUT_LENGTH];
ROOM_INDEX_DATA *location;
AFFECT_DATA af;
CHAR_DATA *gch;
CHAR_DATA *gch_next;
CHAR_DATA *shadow;
char buf[MAX_STRING_LENGTH];
stop_fighting( victim, TRUE );
if (IS_NPC(victim) && victim->pIndexData->vnum == MOB_VNUM_DECOY)
{
death_cry(victim);
act("$n vanishes in a poof of smoke!",victim,0,0,TO_ROOM);
}
else
{
death_cry( victim );
/* Imm deaths */
if (!IS_NPC(victim) && IS_IMMORTAL(victim))
{
if (victim->pcdata->imm_death)
{
act("$t.",victim,NULL,NULL,TO_ROOM);
act("$t.",victim,NULL,NULL,TO_CHAR);
}
else
{
act("$n's skull glows brightly and $n rises from $s ashes!",victim,0,0,TO_ROOM);
send_to_char("Your skull glows brightly and you rise from your ashes!\n\r",victim);
}
return;
}
make_corpse( ch,victim );
victim->noregen_dam = 0;
}
for (gch = char_list; gch != NULL; gch = gch_next)
{
gch_next = gch->next;
if (IS_NPC(gch) && gch->master == victim)
extract_char(gch,TRUE);
}
/* This next bit handles the Nightfall spell */
if (victim->nightfall != NULL
&& victim->nightfall->in_room == victim->in_room)
{
act("$n's soul is torn from it's body and formed into a shadow!",victim,0,0,TO_ROOM);
act("$n rips your soul away and forms a shadow!",victim->nightfall,0,victim,TO_VICT);
shadow = create_mobile(get_mob_index(MOB_VNUM_NIGHTFALL));
char_to_room(shadow,victim->in_room);
free_string(shadow->short_descr);
free_string(shadow->long_descr);
sprintf(buf,"the shadow of %s",
IS_NPC(victim) ? victim->short_descr : victim->name);
shadow->short_descr = str_dup(buf);
sprintf(buf,"The shadow of %s is hovering here in silence.\n\r",
IS_NPC(victim) ? victim->short_descr : victim->name);
shadow->long_descr = str_dup(buf);
shadow->max_hit = victim->nightfall->max_hit;
shadow->hit = victim->max_hit;
shadow->damroll = victim->level/2;
shadow->hitroll = victim->level/3;
shadow->level = victim->level;
shadow->armor[0] = -victim->level*4;
shadow->armor[1] = -victim->level*4;
shadow->armor[2] = -victim->level*4;
shadow->armor[3] = -victim->level*3;
SET_BIT(shadow->comm,COMM_QUIET);
SET_BIT(shadow->affected_by,AFF_CHARM);
shadow->leader = victim->nightfall;
shadow->master = victim->nightfall;
}
if (victim->nightfall != NULL)
{
if (victim->nightfall->in_room == victim->in_room)
act("You grasp onto $n's soul for you own uses!",victim,0,victim->nightfall,TO_VICT);
else
act("Your grasp on $n's soul fades away.",victim,0,victim->nightfall,TO_VICT);
victim->nightfall = NULL;
}
/* Quick score time before we dump any NPCs..for 'ratings' command */
if (!IS_NPC(ch))
{
if (IS_NPC(victim) )
{
ch->pcdata->kills[MOB_LEVELS] += victim->level;
ch->pcdata->kills[MOB_KILLS]++;
}
else
{
ch->pcdata->kills[PK_KILLS]++;
ch->pcdata->kills[PK_LEVELS] += victim->level;
}
}
if (!IS_NPC(victim))
{
if (IS_NPC(ch) )
{
ch->pcdata->killed[MOB_KILLS]++;
}
else
{
ch->pcdata->killed[PK_KILLS]++;
}
}
if ( IS_NPC(victim) )
{
victim->pIndexData->killed++;
kill_table[URANGE(0, victim->level, MAX_LEVEL-1)].killed++;
extract_char( victim, TRUE );
return;
}
extract_char( victim, FALSE );
if(is_affected(victim,gsn_cloak_form)) cloak=1;
while(victim->affected)
affect_remove( victim, victim->affected );
victim->affected_by = race_table[victim->race].aff;
for (i = 0; i < 4; i++)
victim->armor[i]= 100;
victim->position = POS_RESTING;
victim->hit = victim->pcdata->perm_hit/2;
victim->mana = victim->pcdata->perm_mana/2;
victim->move = victim->pcdata->perm_move/2;
victim->pcdata->condition[COND_HUNGER] = 48;
victim->pcdata->condition[COND_THIRST] = 48;
victim->pcdata->condition[COND_DRUNK] = 0;
victim->pcdata->condition[COND_FULL] = 0;
victim->pcdata->condition[COND_DEHYDRATED] = 0;
victim->pcdata->condition[COND_STARVING] = 0;
REMOVE_BIT(victim->act,PLR_CRIMINAL);
save_char_obj( victim );
victim->ghost = 10;
send_to_char("You have died and turned into an invincible ghost for a few minutes.\n\r",victim);
if(cloak==1)
location=get_room_index(3808);
else if (victim->temple != 0)
location = get_room_index(victim->temple);
else
location = get_room_index(ROOM_VNUM_TEMPLE);
if (location == NULL)
location = get_room_index(1212);
if (ch->in_room != NULL && ch->in_room->vnum == 1212)
location = get_room_index(1212);
char_from_room(victim);
char_to_room(victim,location);
af.where = TO_AFFECTS;
af.type = skill_lookup("infravision");
af.duration = 20;
af.location = 0;
af.bitvector = AFF_INFRARED;
af.modifier = 0;
af.level=victim->level;
affect_to_char(victim,&af);
if(cloak==1) {
af.type=gsn_cloak_form;
af.duration=-1;
af.location=APPLY_MORPH_FORM;
af.modifier=9;
af.bitvector=AFF_SNEAK;
affect_to_char(victim,&af);
}
/* Con loss per 4 deaths. If you don't want this, and particularly perm
death by going below 4 con, then remove this code...(Ceran)
*/
if (!IS_NPC(victim))
{
victim->pcdata->death_count++;
if ( (victim->pcdata->death_count >= 5)
&& !IS_IMMORTAL(victim))
{
victim->perm_stat[STAT_CON] -= 1;
victim->pcdata->death_count = 0;
send_to_char("With this death you feel part of your life force slip away.\n\r",victim);
if (victim->perm_stat[STAT_CON] <= 3)
{
send_to_char("Your body crumples up into a useless husk.\n\r",victim);
act("$n's body crumples up into a lifeless husk.",victim,0,0,TO_ROOM);
victim->pause = 0;
sprintf(strsave, "%s%s.plr", PLAYER_DIR,capitalize(victim->name));
do_quit(victim,"");
wiznet("$N has died of con loss.",victim,NULL,0,0,0);
remove(strsave);
return;
}
}
}
do_look(victim,"auto");
return;
}
void group_gain( CHAR_DATA *ch, CHAR_DATA *victim )
{
char buf[MAX_STRING_LENGTH];
CHAR_DATA *gch;
CHAR_DATA *lch;
int xp;
int members;
int group_levels;
/*
* Monsters don't get kill xp's or alignment changes.
* P-killing doesn't help either.
* Dying of mortal wounds or poison doesn't give xp to anyone!
*/
if ( victim == ch )
return;
if (!IS_NPC(victim)) /* No xp for PKs */
return;
members = 0;
group_levels = 0;
for ( gch = ch->in_room->people; gch != NULL; gch = gch->next_in_room )
{
if ( is_same_group( gch, ch ) )
{
if(!IS_NPC(gch)) members++;
group_levels+=gch->level;
if(IS_NPC(gch)) group_levels+=gch->level;
}
}
if ( members == 0 )
{
members = 1;
}
lch = (ch->leader != NULL) ? ch->leader : ch;
for ( gch = ch->in_room->people; gch != NULL; gch = gch->next_in_room )
{
OBJ_DATA *obj;
OBJ_DATA *obj_next;
if ( !is_same_group( gch, ch ) || IS_NPC(gch))
continue;
if ( gch->level - lch->level > 8 )
{
send_to_char( "You are too high for this group.\n\r", gch );
continue;
}
if ( gch->level - lch->level < -8 )
{
send_to_char( "You are too low for this group.\n\r", gch );
continue;
}
xp = xp_compute( gch, victim, members, group_levels );
sprintf( buf, "You receive %d experience points.\n\r", xp );
send_to_char( buf, gch );
gain_exp( gch, xp );
for ( obj = ch->carrying; obj != NULL; obj = obj_next )
{
obj_next = obj->next_content;
if ( obj->wear_loc == WEAR_NONE )
continue;
if ( ( IS_OBJ_STAT(obj, ITEM_ANTI_EVIL) && IS_EVIL(ch) )
|| ( IS_OBJ_STAT(obj, ITEM_ANTI_GOOD) && IS_GOOD(ch) )
|| ( IS_OBJ_STAT(obj, ITEM_ANTI_NEUTRAL) && IS_NEUTRAL(ch) )
|| ( IS_OBJ_STAT(obj, ITEM_ANTI_LAWFUL) &&
(ch->pcdata->ethos > 0))
|| ( IS_OBJ_STAT(obj, ITEM_ANTI_NEUT) &&
(ch->pcdata->ethos == 0))
|| ( IS_OBJ_STAT(obj, ITEM_ANTI_CHAOTIC) &&
(ch->pcdata->ethos < 0)))
{
act( "You are zapped by $p.", ch, obj, NULL, TO_CHAR );
act( "$n is zapped by $p.", ch, obj, NULL, TO_ROOM );
obj_from_char( obj );
obj_to_room( obj, ch->in_room );
}
}
}
return;
}
/*
* Compute xp for a kill.
* Also adjust alignment of killer.
* Edit this function to change xp computations.
*/
int xp_compute( CHAR_DATA *gch, CHAR_DATA *victim, int group_amount, int glevel )
{
int xp,base_exp;
int level_range;
double mult;
mult=((double)(gch->level)/glevel)*group_amount;
if(mult>=1) { mult=(1+mult)/2;
} else {
mult=mult*mult;
}
mult = URANGE(.25,mult,1.1);
level_range = victim->level - gch->level;
/* compute the base exp */
switch (level_range)
{
default : base_exp = 0; break;
case -9 : base_exp = 2; break;
case -8 : base_exp = 4; break;
case -7 : base_exp = 7; break;
case -6 : base_exp = 12; break;
case -5 : base_exp = 14; break;
case -4 : base_exp = 25; break;
case -3 : base_exp = 36; break;
case -2 : base_exp = 55; break;
case -1 : base_exp = 70; break;
case 0 : base_exp = 88; break;
case 1 : base_exp = 110; break;
case 2 : base_exp = 131; break;
case 3 : base_exp = 153; break;
case 4 : base_exp = 165; break;
}
if (level_range > 4)
base_exp = 165 + 15 * (level_range - 4);
if(mult<1&&level_range>4)
base_exp = (2*base_exp+165)/3;
if (IS_SET(victim->act,ACT_NOALIGN))
xp = base_exp;
else if (gch->alignment > 0)
{
if (victim->alignment < 0)
xp = (base_exp *4)/3;
else if (victim->alignment > 0)
xp = -30;
else
xp = base_exp;
}
else if (gch->alignment < 0) /* for baddies */
{
if (victim->alignment > 0)
xp = (base_exp * 4)/3;
else if (victim->alignment < 0)
xp = base_exp/2;
else
xp = base_exp;
}
else /* neutral */
{
xp = base_exp;
}
xp = (xp*2)/3;
xp=xp*mult;
xp = number_range (xp, xp * 5/4);
/* adjust for grouping */
if (group_amount == 2)
xp = (xp * 5)/3;
if (group_amount == 3)
xp = (xp * 7)/3;
if (group_amount > 3)
xp /= (group_amount - 2);
return xp;
}
void dam_message( CHAR_DATA *ch, CHAR_DATA *victim,int dam,int dt,bool immune )
{
char buf1[256], buf2[256], buf3[256];
OBJ_DATA *wield;
CHAR_DATA *gch;
const char *vs;
const char *vp;
const char *attack;
char punct;
if (ch == NULL || victim == NULL)
return;
if ( dam == 0 ) { vs = "miss"; vp = "misses"; }
else if ( dam <= 2 ) { vs = "scratch"; vp = "scratches"; }
else if ( dam <= 4 ) { vs = "graze"; vp = "grazes"; }
else if ( dam <= 7 ) { vs = "hit"; vp = "hits"; }
else if ( dam <= 11 ) { vs = "injure"; vp = "injures"; }
else if ( dam <= 15 ) { vs = "wound"; vp = "wounds"; }
else if ( dam <= 20 ) { vs = "maul"; vp = "mauls"; }
else if ( dam <= 25 ) { vs = "decimate"; vp = "decimates"; }
else if ( dam <= 30 ) { vs = "devastate"; vp = "devastates"; }
else if ( dam <= 37 ) { vs = "maim"; vp = "maims"; }
else if ( dam <= 45 ) { vs = "MUTILATE"; vp = "MUTILATES"; }
else if ( dam <= 55 ) { vs = "DISEMBOWEL"; vp = "DISEMBOWELS"; }
else if ( dam <= 65 ) { vs = "DISMEMBER"; vp = "DISMEMBERS"; }
else if ( dam <= 85 ) { vs = "MASSACRE"; vp = "MASSACRES"; }
else if ( dam <= 100 ) { vs = "MANGLE"; vp = "MANGLES"; }
else if ( dam <= 135 ) { vs = "*** DEMOLISH ***";
vp = "*** DEMOLISHES ***"; }
else if ( dam <= 160 ) { vs = "*** DEVASTATE ***";
vp = "*** DEVASTATES ***"; }
else if ( dam <= 250) { vs = "=== OBLITERATE ===";
vp = "=== OBLITERATES ==="; }
else if ( dam <= 330) { vs = ">>> ANNIHILATE <<<";
vp = ">>> ANNIHILATES <<<"; }
else if ( dam <= 380) { vs = "<<< ERADICATE >>>";
vp = "<<< ERADICATES >>>"; }
else { vs = "do UNSPEAKABLE things to";
vp = "does UNSPEAKABLE things to"; }
punct = (dam <= 33) ? '.' : '!';
/* Now quickly set dual wield weapon dt to real weapon dt - this allows
dual wielded weapons to be kept track of until this point, now we no
longer need to know if the weapon doing the dam is the dual one, just what
it's actual dt is
-Ceran
*/
if (dt == gsn_dual_wield || dt == gsn_tertiary_wield)
{
if (dt == gsn_dual_wield)
wield = get_eq_char(ch,WEAR_DUAL_WIELD);
else
wield = get_eq_char(ch,WEAR_TERTIARY_WIELD);
dt = TYPE_HIT;
if (wield != NULL)
dt += wield->value[3];
else
dt += ch->dam_type;Showing the first 100 KB of 258.6 KB. Download the archive for the full file.