fight.c
R2b5/src/fight.c · 203.3 KB
From the archive RoT2.0b5.zip
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-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 'rom.license' *
***************************************************************************/
/***************************************************************************
* ROT 2.0 is copyright 1996-1999 by Russ Walsh *
* By using this code, you have agreed to follow the terms of the *
* ROT license, in the file 'rot.license' *
***************************************************************************/
#if defined(macintosh)
#include <types.h>
#else
#include <sys/types.h>
#endif
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <ctype.h>
#include "merc.h"
#include "tables.h"
#include "interp.h"
float cpo_stat, vpo_stat; //actual pay-off ratio for arena
const int vam_str[] = {
6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5,
6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5
};
/*
* Local functions.
*/
void check_assist args ( ( CHAR_DATA * ch, CHAR_DATA * victim ) );
bool check_dodge args ( ( CHAR_DATA * ch, CHAR_DATA * victim ) );
bool check_parry args ( ( CHAR_DATA * ch, CHAR_DATA * victim ) );
bool check_shield_block args ( ( CHAR_DATA * ch, CHAR_DATA * victim ) );
void dam_message args ( ( CHAR_DATA * ch, CHAR_DATA * victim, int dam, int dt, bool immune ) );
void death_cry args ( ( CHAR_DATA * ch, CHAR_DATA * killer ) );
void group_gain args ( ( CHAR_DATA * ch, CHAR_DATA * victim ) );
int xp_compute args ( ( CHAR_DATA * gch, CHAR_DATA * victim, int total_levels ) );
bool can_bypass args ( ( CHAR_DATA * ch, CHAR_DATA * victim ) );
int dambonus args ( ( CHAR_DATA * ch, CHAR_DATA * victim, int dam, int stance ) );
void special_move args ( ( CHAR_DATA * ch, CHAR_DATA * victim ) );
bool can_counter args ( ( CHAR_DATA * ch ) );
bool is_safe args ( ( CHAR_DATA * ch, CHAR_DATA * victim ) );
bool is_safe_mock args ( ( CHAR_DATA * ch, CHAR_DATA * victim ) );
bool is_voodood args ( ( CHAR_DATA * ch, CHAR_DATA * victim ) );
void make_corpse args ( ( CHAR_DATA * ch, CHAR_DATA * killer ) );
void one_hit args ( ( CHAR_DATA * ch, CHAR_DATA * victim, int dt, bool secondary ) );
void one_hit_mock args ( ( CHAR_DATA * ch, CHAR_DATA * victim, int dt, bool secondary ) );
void mob_hit args ( ( CHAR_DATA * ch, CHAR_DATA * victim, int dt ) );
void raw_kill args ( ( CHAR_DATA * victim, CHAR_DATA * killer ) );
void set_fighting args ( ( CHAR_DATA * ch, CHAR_DATA * victim ) );
void disarm args ( ( CHAR_DATA * ch, CHAR_DATA * victim ) );
bool check_fade args ( ( CHAR_DATA *ch, CHAR_DATA *victim ) );
void check_arena args((CHAR_DATA * ch, CHAR_DATA * victim));
/*
* Control the fights going on.
* Called periodically by update_handler.
*/
void violence_update(void)
{
CHAR_DATA *ch;
CHAR_DATA *ch_next;
CHAR_DATA *victim;
for (ch = char_list; ch != NULL; ch = ch->next) {
ch_next = ch->next;
if ((victim = ch->fighting) == NULL || ch->in_room == NULL)
continue;
if (IS_AWAKE(ch) && ch->in_room == victim->in_room)
multi_hit(ch, victim, TYPE_UNDEFINED);
else
stop_fighting(ch, FALSE);
if ((victim = ch->fighting) == NULL)
continue;
/*
* Fun for the whole family!
*/
check_assist(ch, victim);
if ( IS_NPC( ch ) )
{
if ( HAS_TRIGGER( ch, TRIG_FIGHT ) )
mp_percent_trigger( ch, victim, NULL, NULL, TRIG_FIGHT );
if ( HAS_TRIGGER( ch, TRIG_HPCNT ) )
mp_hprct_trigger( ch, victim );
}
}
return;
}
/* for auto assisting */
void check_assist(CHAR_DATA * ch, CHAR_DATA * victim)
{
CHAR_DATA *rch, *rch_next;
for (rch = ch->in_room->people; rch != NULL; rch = rch_next) {
rch_next = rch->next_in_room;
if (IS_AWAKE(rch) && rch->fighting == NULL) {
/* quick check for ASSIST_PLAYER */
if (!IS_NPC(ch) && IS_NPC(rch)
&& IS_SET(rch->off_flags, ASSIST_PLAYERS)
&& rch->level + 6 > victim->level) {
do_emote(rch, "{Rscreams and attacks!{x");
multi_hit(rch, victim, TYPE_UNDEFINED);
continue;
}
/* PCs next */
if (!IS_NPC(ch) || IS_AFFECTED(ch, AFF_CHARM)) {
if (!IS_NPC(rch) && !IS_NPC(victim)
&& (!is_pkill(rch) || !is_pkill(victim))
&& !IS_SET(victim->act, PLR_TWIT))
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, "{Rscreams and attacks!{x");
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 count = 1; // DB
/* 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 (ch->shadow) {
ch->shadowing->shadowed = FALSE;
ch->shadowing->shadower = NULL;
ch->shadowing = NULL;
ch->shadow = FALSE;
}
if (ch->stunned) {
ch->stunned--;
if (!ch->stunned) {
send_to_char("You regain your equilibrium.\n\r", ch);
act("$n regains $s equilibrium.", ch, NULL, NULL, TO_ROOM);
}
return;
}
if (IS_NPC(ch)) {
mob_hit(ch, victim, dt);
return;
}
one_hit(ch, victim, dt, FALSE);
if (get_eq_char(ch, WEAR_SECONDARY)) {
chance = (get_skill(ch, gsn_dual_wield) / 3) * 2;
chance += 33;
if (number_percent() < chance) {
one_hit(ch, victim, dt, TRUE);
if (get_skill(ch, gsn_dual_wield) != 0 && (!IS_NPC(ch)
&& ch->level >=
skill_table
[gsn_dual_wield].
skill_level[ch->
class]))
{
check_improve(ch, gsn_dual_wield, TRUE, 1);
} else if (!IS_NPC(ch) && (ch->pcdata->tier == 2)) {
if (get_skill(ch, gsn_dual_wield) != 0 && (!IS_NPC(ch)
&& ch->level >=
skill_table
[gsn_dual_wield].
skill_level[ch->
clasb]))
{
check_improve(ch, gsn_dual_wield, TRUE, 1);
}
}
}
if (ch->fighting != victim)
return;
}
if (ch->fighting != victim)
return;
if (IS_AFFECTED(ch, AFF_HASTE))
one_hit(ch, victim, dt, FALSE);
if (IS_STANCE(ch, STANCE_SERPENT) && number_percent() >
ch->stance[STANCE_SERPENT] * 0.5)
count += 1;
else if (IS_STANCE(ch, STANCE_MANTIS) && number_percent() >
ch->stance[STANCE_MANTIS] * 0.5)
count += 1;
else if (IS_STANCE(ch, STANCE_TIGER) && number_percent() >
ch->stance[STANCE_TIGER] * 0.5)
count += 3;
if (ch->fighting != victim || dt == gsn_backstab || dt == gsn_circle)
return;
chance = get_skill(ch, gsn_second_attack) / 2;
if (IS_AFFECTED(ch, AFF_SLOW))
chance /= 2;
if (number_percent() < chance) {
one_hit(ch, victim, dt, FALSE);
check_improve(ch, gsn_second_attack, TRUE, 5);
if (ch->fighting != victim)
return;
} else {
return;
}
chance = get_skill(ch, gsn_third_attack) / 2;
if (IS_AFFECTED(ch, AFF_SLOW))
chance /= 2;
if (number_percent() < chance) {
one_hit(ch, victim, dt, FALSE);
check_improve(ch, gsn_third_attack, TRUE, 6);
if (ch->fighting != victim)
return;
} else {
return;
}
chance = get_skill(ch, gsn_fourth_attack) / 2;
if (IS_AFFECTED(ch, AFF_SLOW))
chance /= 3;
if (number_percent() < chance) {
one_hit(ch, victim, dt, FALSE);
check_improve(ch, gsn_fourth_attack, TRUE, 6);
if (ch->fighting != victim)
return;
} else {
return;
}
chance = get_skill(ch, gsn_fifth_attack) / 2;
if (IS_AFFECTED(ch, AFF_SLOW))
chance = 0;
if (ch->stance[0] > 0 && number_percent() == 1) {
int stance = ch->stance[0];
if (ch->stance[stance] >= 200) {
special_move(ch, victim);
return;
}
}
if (number_percent() < chance) {
one_hit(ch, victim, dt, FALSE);
check_improve(ch, gsn_fifth_attack, TRUE, 6);
if (ch->fighting != victim)
return;
}
return;
}
/* procedure for all mobile attacks */
void mob_hit(CHAR_DATA * ch, CHAR_DATA * victim, int dt)
{
int chance, number;
CHAR_DATA *vch, *vch_next;
one_hit(ch, victim, dt, FALSE);
if (ch->fighting != victim)
return;
if (ch->stunned)
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, FALSE);
}
}
if (ch->fighting != victim)
return;
if (get_eq_char(ch, WEAR_SECONDARY)) {
chance = (get_skill(ch, gsn_dual_wield) / 3) * 2;
chance += 33;
if (number_percent() < chance) {
one_hit(ch, victim, dt, TRUE);
}
if (ch->fighting != victim)
return;
}
if (IS_AFFECTED(ch, AFF_HASTE)
|| (IS_SET(ch->off_flags, OFF_FAST) && !IS_AFFECTED(ch, AFF_SLOW)))
one_hit(ch, victim, dt, FALSE);
if (ch->fighting != victim || dt == gsn_backstab || dt == gsn_circle)
return;
chance = get_skill(ch, gsn_second_attack) / 2;
if (IS_AFFECTED(ch, AFF_SLOW) && !IS_SET(ch->off_flags, OFF_FAST))
chance /= 2;
if (number_percent() < chance) {
one_hit(ch, victim, dt, FALSE);
if (ch->fighting != victim)
return;
chance = get_skill(ch, gsn_third_attack) / 2;
if (IS_AFFECTED(ch, AFF_SLOW) && !IS_SET(ch->off_flags, OFF_FAST))
chance /= 2;
if (number_percent() < chance) {
one_hit(ch, victim, dt, FALSE);
if (ch->fighting != victim)
return;
chance = get_skill(ch, gsn_fourth_attack) / 2;
if (IS_AFFECTED(ch, AFF_SLOW)
&& !IS_SET(ch->off_flags, OFF_FAST)) chance /= 3;
if (number_percent() < chance) {
one_hit(ch, victim, dt, FALSE);
if (ch->fighting != victim)
return;
chance = get_skill(ch, gsn_fifth_attack) / 2;
if (IS_AFFECTED(ch, AFF_SLOW)
&& !IS_SET(ch->off_flags, OFF_FAST)) chance = 0;
if (number_percent() < chance) {
one_hit(ch, victim, dt, FALSE);
if (ch->fighting != victim)
return;
}
}
}
}
/* oh boy! Fun stuff! */
if (ch->wait > 0)
return;
number = number_range(0, 2);
if (number == 1 && IS_SET(ch->act, ACT_MAGE)) {
/* { mob_cast_mage(ch,victim); return; } */ ;
}
if (number == 2 && IS_SET(ch->act, ACT_CLERIC)) {
/* { mob_cast_cleric(ch,victim); return; } */ ;
}
/* now for the skills */
number = number_range(0, 8);
switch (number) {
case (0):
if (IS_SET(ch->off_flags, OFF_BASH))
do_bash(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_VAMPIRE)
|| 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, "");
}
}
}
/*
* Hit one guy once.
*/
void one_hit(CHAR_DATA * ch, CHAR_DATA * victim, int dt, bool secondary)
{
OBJ_DATA *wield;
int victim_ac;
int thac0;
int thac0_00;
int thac0_32;
int dam;
int stance;
int diceroll;
int sn, skill;
int dam_type;
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
|| victim->spirit) return;
/*
* Figure out the type of damage message.
* if secondary == true, use the second weapon.
*/
if (!secondary)
wield = get_eq_char(ch, WEAR_WIELD);
else
wield = get_eq_char(ch, WEAR_SECONDARY);
if (dt == TYPE_UNDEFINED) {
dt = TYPE_HIT;
if (wield != NULL && wield->item_type == ITEM_WEAPON)
dt += wield->value[3];
else
dt += ch->dam_type;
}
if (dt < TYPE_HIT)
if (wield != NULL)
dam_type = attack_table[wield->value[3]].damage;
else
dam_type = attack_table[ch->dam_type].damage;
else
dam_type = attack_table[dt - TYPE_HIT].damage;
if (dam_type == -1)
dam_type = DAM_BASH;
/* get the weapon skill */
sn = get_weapon_sn(ch);
skill = 20 + get_weapon_skill(ch, sn);
/*
* Calculate to-hit-armor-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_VAMPIRE))
thac0_32 = -30;
else if (IS_SET(ch->act, ACT_DRUID))
thac0_32 = 0;
else if (IS_SET(ch->act, ACT_RANGER))
thac0_32 = -4;
else 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;
if (ch->pcdata->tier == 2) {
thac0_00 = UMIN(class_table[ch->class].thac0_00,
class_table[ch->clasb].thac0_00);
thac0_32 = UMIN(class_table[ch->class].thac0_32,
class_table[ch->clasb].thac0_32);
}
}
thac0 = interpolate(ch->level, thac0_00, thac0_32);
if (thac0 < 0)
thac0 = thac0 / 2;
if (thac0 < -5)
thac0 = -5 + (thac0 + 5) / 2;
thac0 -= GET_HITROLL(ch) * skill / 100;
thac0 += 5 * (100 - skill) / 100;
if (dt == gsn_backstab)
thac0 -= 10 * (100 - get_skill(ch, gsn_backstab));
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 (((!strcmp(class_table[victim->class].name, "vampire"))
|| (!strcmp(class_table[victim->class].name, "lich")))
&& (IS_OUTSIDE(victim))
&& (vam_str[time_info.hour] != 0)) {
if ((time_info.hour > 6) && (time_info.hour < 18)) {
victim_ac += (victim_ac * (vam_str[time_info.hour] / 100));
} else {
victim_ac -= (victim_ac * (vam_str[time_info.hour] / 100));
}
} else if (!IS_NPC(victim) && (victim->pcdata->tier == 2)) {
if ((!strcmp(class_table[victim->clasb].name, "vampire"))
&& (IS_OUTSIDE(victim))
&& (vam_str[time_info.hour] != 0)) {
if ((time_info.hour > 6) && (time_info.hour < 18)) {
victim_ac += (victim_ac * (vam_str[time_info.hour] / 100));
} else {
victim_ac -= (victim_ac * (vam_str[time_info.hour] / 100));
}
}
}
if (victim_ac < -15)
victim_ac = (victim_ac + 15) / 5 - 15;
if (!can_see(ch, victim))
victim_ac -= 4;
if (victim->position < POS_FIGHTING)
victim_ac += 4;
if (victim->position < POS_RESTING)
victim_ac += 6;
/*
* The moment of excitement!
*/
while ((diceroll = number_bits(5)) >= 20);
if (diceroll == 0 || (diceroll != 19 && diceroll < thac0 - victim_ac)) {
/* Miss. */
damage(ch, victim, 0, dt, dam_type, TRUE);
tail_chain();
return;
}
/*
* Hit.
* Calc damage.
*/
if (IS_NPC(ch) && (!ch->pIndexData->new_format || wield == NULL))
if (!ch->pIndexData->new_format) {
dam = number_range(ch->level / 2, ch->level * 3 / 2);
if (wield != NULL)
dam += dam / 2;
if (global_damq){ 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->clan) {
float adlev, inclev;
int cntr;
adlev = 8;
inclev = .01;
for (cntr = 0; cntr <= ch->level; cntr++) {
adlev += .57;
adlev += inclev;
inclev += .005;
}
cntr = (int) adlev;
dam = dice(cntr / 3, 3) * skill / 100;
if (global_damq){ dam = dam*2; }
} else {
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 (global_damq){ dam = dam*2; }
}
if (get_eq_char(ch, WEAR_SHIELD) == NULL) /* no shield = more */
dam = dam * 11 / 10;
if (global_damq){ dam = dam*2; }
/* sharpness! */
if (IS_WEAPON_STAT(wield, WEAPON_SHARP)) {
int percent;
if ((percent = number_percent()) <= (skill / 8))
dam = 2 * dam + (dam * 2 * percent / 100);
if (global_damq){ dam = dam*2; }
}
} else
dam =
number_range(1 + 4 * skill / 100,
2 * ch->level / 3 * skill / 100);
if (global_damq){ dam = dam*2; }
}
/*
* Bonuses.
*/
if (((!strcmp(class_table[ch->class].name, "vampire"))
|| (!strcmp(class_table[ch->class].name, "lich")))
&& (IS_OUTSIDE(ch))
&& (vam_str[time_info.hour] != 0)) {
if ((time_info.hour > 6) && (time_info.hour < 18)) {
dam -= (dam * (vam_str[time_info.hour] / 100));
if (global_damq){ dam = dam*2; }
} else {
dam += (dam * (vam_str[time_info.hour] / 100));
if (global_damq){ dam = dam*2; }
}
} else if (!IS_NPC(ch) && (ch->pcdata->tier == 2)) {
if ((!strcmp(class_table[ch->clasb].name, "vampire"))
&& (IS_OUTSIDE(ch))
&& (vam_str[time_info.hour] != 0)) {
if ((time_info.hour > 6) && (time_info.hour < 18)) {
dam -= (dam * (vam_str[time_info.hour] / 100));
} else {
dam += (dam * (vam_str[time_info.hour] / 100));
}
}
if (global_damq){ dam = dam*2; }
}
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);
if (str_cmp(class_table[ch->class].name, "gladiator"))
dam += 2 * (dam * diceroll / 300);
else
dam += 2 * (dam * diceroll / 200);
}
if (global_damq){ dam = 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 + (ch->level / 10);
else
dam *= 2 + (ch->level / 8);
}
if (dt == gsn_circle && wield != NULL) {
if (wield->value[0] != 2)
dam *= 1.5 + (ch->level / 15);
else
dam *= 1.5 + (ch->level / 12);
}
dam += GET_DAMROLL(ch) * UMIN(100, skill) / 100;
if (global_damq){ dam = dam*2; }
if (dam <= 0)
dam = 1;
result = damage(ch, victim, dam, dt, dam_type, TRUE);
/* but do we have a funky weapon? */
if (result && wield != NULL) {
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
("{cYou feel {ypoison{c coursing through your veins.\n{x",
victim);
act("$n is {ypoisoned{x 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 {ypoison{x on $p has worn off.", ch, wield,
NULL, TO_CHAR);
}
}
if (ch->fighting == victim
&& IS_WEAPON_STAT(wield, WEAPON_VAMPIRIC)) {
dam = number_range(1, wield->level / 5 + 1);
act("$p draws life from $n.{x", victim, wield, NULL,
TO_ROOM);
act("You feel $p drawing your life away.{x", victim, wield,
NULL, TO_CHAR);
damage(ch, victim, dam, 0, DAM_NEGATIVE, FALSE);
ch->alignment = UMAX(-1000, ch->alignment - 1);
if (ch->pet != NULL)
ch->pet->alignment = ch->alignment;
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 {rburned by $p.{x", victim, wield, NULL,
TO_ROOM);
act("$p {rsears your flesh.{x", victim, wield, NULL,
TO_CHAR);
fire_effect((void *) victim, wield->level / 2, dam,
TARGET_CHAR);
damage(ch, victim, dam, 0, DAM_FIRE, FALSE);
}
if (ch->fighting == victim && IS_WEAPON_STAT(wield, WEAPON_FROST)) {
dam = number_range(1, wield->level / 6 + 2);
act("$p {cfreezes $n.{x", victim, wield, NULL, TO_ROOM);
act("The {Ccold touch of $p surrounds you with {Cice.{x",
victim, wield, NULL, TO_CHAR);
cold_effect(victim, wield->level / 2, dam, TARGET_CHAR);
damage(ch, victim, dam, 0, DAM_COLD, FALSE);
}
if (ch->fighting == victim
&& IS_WEAPON_STAT(wield, WEAPON_SHOCKING)) {
dam = number_range(1, wield->level / 5 + 2);
act("$n is struck by {Ylightning from $p.{x", victim,
wield, NULL, TO_ROOM);
act("You are {Yshocked by $p.{x", victim, wield, NULL,
TO_CHAR);
shock_effect(victim, wield->level / 2, dam, TARGET_CHAR);
damage(ch, victim, dam, 0, DAM_LIGHTNING, FALSE);
}
if (global_damq){ dam = dam*2; }
}
if (ch->fighting == victim);
{
if (result) {
if (IS_SHIELDED(victim, SHD_ICE)) {
if (!IS_SHIELDED(ch, SHD_ICE)) {
dt = skill_lookup("iceshield");
dam = number_range(5, 15);
damage(victim, ch, dam, dt, DAM_COLD, TRUE);
}
}
if (IS_SHIELDED(victim, SHD_FIRE)) {
if (!IS_SHIELDED(ch, SHD_FIRE)) {
dt = skill_lookup("fireshield");
dam = number_range(10, 20);
damage(victim, ch, dam, dt, DAM_FIRE, TRUE);
}
}
if (!IS_NPC(ch)) {
stance = ch->stance[0];
if (IS_STANCE(ch, STANCE_NORMAL))
dam *= 1.75;
else
dam = dambonus(ch, victim, dam, stance);
dambonus(ch, victim, dam, stance);
improve_stance(ch);
}
if (IS_NPC(ch)) {
stance = ch->stance[0];
if (IS_STANCE(ch, STANCE_NORMAL))
dam *= 1.95;
else
dam = dambonus(ch, victim, dam, stance);
dambonus(ch, victim, dam, stance);
improve_stance(ch);
improve_stance(ch);
}
if (IS_SHIELDED(victim, SHD_SHOCK)) {
if (!IS_SHIELDED(ch, SHD_SHOCK)) {
dt = skill_lookup("shockshield");
dam = number_range(15, 25);
damage(victim, ch, dam, dt, DAM_LIGHTNING, TRUE);
}
}
}
if (global_damq){ dam = dam*2; }
}
tail_chain();
return;
}
/*
* Mock hit one guy once.
*/
void one_hit_mock(CHAR_DATA * ch, CHAR_DATA * victim, int dt,
bool secondary)
{
OBJ_DATA *wield;
int victim_ac;
int thac0;
int thac0_00;
int thac0_32;
int dam;
int diceroll;
int sn, skill;
int dam_type;
bool result;
sn = -1;
/* just in case */
if (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.
* if secondary == true, use the second weapon.
*/
if (!secondary)
wield = get_eq_char(ch, WEAR_WIELD);
else
wield = get_eq_char(ch, WEAR_SECONDARY);
if (dt == TYPE_UNDEFINED) {
dt = TYPE_HIT;
if (wield != NULL && wield->item_type == ITEM_WEAPON)
dt += wield->value[3];
else
dt += ch->dam_type;
}
if (dt < TYPE_HIT)
if (wield != NULL)
dam_type = attack_table[wield->value[3]].damage;
else
dam_type = attack_table[ch->dam_type].damage;
else
dam_type = attack_table[dt - TYPE_HIT].damage;
if (dam_type == -1)
dam_type = DAM_BASH;
/* get the weapon skill */
sn = get_weapon_sn(ch);
skill = 20 + get_weapon_skill(ch, sn);
/*
* Calculate to-hit-armor-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_VAMPIRE))
thac0_32 = -30;
else if (IS_SET(ch->act, ACT_DRUID))
thac0_32 = 0;
else if (IS_SET(ch->act, ACT_RANGER))
thac0_32 = -4;
else 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;
if (ch->pcdata->tier == 2) {
thac0_00 = UMIN(class_table[ch->class].thac0_00,
class_table[ch->clasb].thac0_00);
thac0_32 = UMIN(class_table[ch->class].thac0_32,
class_table[ch->clasb].thac0_32);
}
}
thac0 = interpolate(ch->level, thac0_00, thac0_32);
if (thac0 < 0)
thac0 = thac0 / 2;
if (thac0 < -5)
thac0 = -5 + (thac0 + 5) / 2;
thac0 -= GET_HITROLL(ch) * skill / 100;
thac0 += 5 * (100 - skill) / 100;
if (dt == gsn_backstab)
thac0 -= 10 * (100 - get_skill(ch, gsn_backstab));
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_mock(ch, victim, 0, dt, dam_type, TRUE);
tail_chain();
return;
}
/*
* Hit.
* Calc damage.
*/
if (IS_NPC(ch) && (!ch->pIndexData->new_format || wield == NULL))
if (!ch->pIndexData->new_format) {
dam = number_range(ch->level / 2, ch->level * 3 / 2);
if (wield != NULL)
dam += dam / 2;
} else
dam = dice(ch->damage[DICE_NUMBER], ch->damage[DICE_TYPE]);
else {
if (sn != -1)
check_improve(ch, sn, TRUE, 5);
if (wield != NULL) {
if (wield->clan) {
float adlev, inclev;
int cntr;
adlev = 8;
inclev = .01;
for (cntr = 0; cntr <= ch->level; cntr++) {
adlev += .57;
adlev += inclev;
inclev += .005;
}
cntr = (int) adlev;
dam = dice(cntr / 3, 3) * skill / 100;
} else {
if (wield->pIndexData->new_format)
dam =
dice(wield->value[1],
wield->value[2]) * skill / 100;
else
dam =
number_range(wield->value[1] * skill / 100,
wield->value[2] * skill / 100);
}
if (get_eq_char(ch, WEAR_SHIELD) == NULL) /* no shield = more */
dam = dam * 11 / 10;
/* sharpness! */
if (IS_WEAPON_STAT(wield, WEAPON_SHARP)) {
int percent;
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.
*/
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);
if (str_cmp(class_table[ch->class].name, "gladiator"))
dam += 2 * (dam * diceroll / 300);
else
dam += 2 * (dam * diceroll / 200);
}
}
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 / 10);
else
dam *= 2 + (ch->level / 8);
}
if (dt == gsn_circle && wield != NULL) {
if (wield->value[0] != 2)
dam *= 1.5 + (ch->level / 15);
else
dam *= 1.5 + (ch->level / 12);
}
dam += GET_DAMROLL(ch) * UMIN(100, skill) / 100;
if (dam <= 0)
dam = 1;
result = damage_mock(ch, victim, dam, dt, dam_type, TRUE);
tail_chain();
return;
}
/*
* Inflict damage from a hit.
*/
bool damage(CHAR_DATA * ch, CHAR_DATA * victim, int dam, int dt,
int dam_type, bool show)
{
OBJ_DATA *corpse;
bool immune;
int stance;
if (victim->position == POS_DEAD)
return FALSE;
if (ch->spirit || victim->spirit)
return FALSE;
/*
* Stop up any residual loopholes.
*/
if (IS_NPC(ch)) {
stance = ch->stance[0];
if (IS_STANCE(ch, STANCE_NORMAL))
dam *= 1.75;
else
dam = dambonus(ch, victim, dam, stance);
dambonus(ch, victim, dam, stance);
improve_stance(ch);
}
if (!IS_NPC(ch)) {
stance = ch->stance[0];
if (IS_STANCE(ch, STANCE_NORMAL))
dam *= 1.95;
else
dam = dambonus(ch, victim, dam, stance);
dambonus(ch, victim, dam, stance);
improve_stance(ch);
}
/*
if (dam > 25000 && dt >= TYPE_HIT && !IS_IMMORTAL(ch)) {
bug("Damage: %d: more than 25000 points!", dam);
dam = 5200;
if (!IS_IMMORTAL(ch)) {
OBJ_DATA *obj;
obj = get_eq_char(ch, WEAR_WIELD);
send_to_char("Damage more than 25000 points!", ch);
// send_to_char("{cYou {z{Breally{x{c shouldn't cheat.{x\n\r", ch);
if (obj != NULL)
extract_obj(obj);
obj = get_eq_char(ch, WEAR_SECONDARY);
if (obj != NULL)
extract_obj(obj);
}
}
*/
/* damage reduction */
if (dam > 35)
dam = (dam - 35) / 2 + 35;
if (dam > 80)
dam = (dam - 80) / 2 + 80;
if (victim != ch) {
/*
* Certain attacks are forbidden.
* Most other attacks are returned.
*/
if (is_safe(ch, victim))
return FALSE;
if (ch->spirit || victim->spirit)
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);
}
/*
* Inviso attacks ... not.
*/
if (IS_SHIELDED(ch, SHD_INVISIBLE)) {
affect_strip(ch, gsn_invis);
affect_strip(ch, gsn_mass_invis);
REMOVE_BIT(ch->shielded_by, SHD_INVISIBLE);
act("$n fades into existence.", ch, NULL, NULL, TO_ROOM);
}
/*
* Damage modifiers.
*/
if (dam > 1 && !IS_NPC(victim)
&& victim->pcdata->condition[COND_DRUNK] > 10)
dam = 9 * dam / 10;
if (dam > 1 && IS_SHIELDED(victim, SHD_SANCTUARY))
dam /= 2;
if (dam > 1 && ((IS_SHIELDED(victim, SHD_PROTECT_EVIL) && IS_EVIL(ch))
|| (IS_SHIELDED(victim, SHD_PROTECT_GOOD)
&& IS_GOOD(ch)))) dam -= dam / 4;
immune = FALSE;
/*
* Check for parry, and dodge.
*/
if (dt >= TYPE_HIT && ch != victim) {
if (check_parry(ch, victim))
return FALSE;
if (check_dodge(ch, victim))
return FALSE;
if (check_shield_block(ch, victim))
return FALSE;
if ( check_fade( ch, victim ))
return FALSE;
if (IS_STANCE(victim, STANCE_CRANE) &&
victim->stance[STANCE_CRANE] > 100 && !can_counter(ch)
&& !can_bypass(ch, victim))
return FALSE;
if (IS_STANCE(victim, STANCE_MANTIS) &&
victim->stance[STANCE_MANTIS] > 100 && !can_counter(ch)
&& !can_bypass(ch, victim))
return FALSE;
if (IS_STANCE(victim, STANCE_MONGOOSE) &&
victim->stance[STANCE_MONGOOSE] > 100 && !can_counter(ch)
&& !can_bypass(ch, victim))
return FALSE;
if (IS_STANCE(victim, STANCE_SWALLOW) &&
victim->stance[STANCE_SWALLOW] > 100 && !can_counter(ch)
&& !can_bypass(ch, victim))
return FALSE;
}
switch (check_immune(victim, dam_type)) {
case (IS_IMMUNE):
immune = TRUE;
dam = 0;
break;
case (IS_RESISTANT):
dam -= dam / 3;
break;
case (IS_VULNERABLE):
dam += dam / 2;
break;
}
if (ch->spirit || victim->spirit)
return FALSE;
if (show)
dam_message(ch, victim, dam, dt, immune);
if (dam == 0)
return FALSE;
/*
* Hurt the victim.
* Inform the victim of his new state.
*/
victim->hit -= dam;
if (!IS_NPC(victim)
&& victim->level >= LEVEL_IMMORTAL && victim->hit < 1)
victim->hit = 1;
update_pos(victim);
if (dt == gsn_feed && !victim->spirit) {
ch->hit = UMIN(ch->hit + ((dam / 4) * 3), ch->max_hit);
update_pos(ch);
}
switch (victim->position) {
case POS_MORTAL:
act("{c$n is mortally wounded, and will die soon, if not aided.{x",
victim, NULL, NULL, TO_ROOM);
send_to_char
("{cYou are mortally wounded, and will die soon, if not aided.{x\n\r",
victim);
break;
case POS_INCAP:
act("{c$n is incapacitated and will slowly die, if not aided.{x",
victim, NULL, NULL, TO_ROOM);
send_to_char
("{cYou are incapacitated and will slowly {z{Rdie{x{c, if not aided.{x\n\r",
victim);
break;
case POS_STUNNED:
act("{c$n is stunned, but will probably recover.{x",
victim, NULL, NULL, TO_ROOM);
send_to_char("{cYou are stunned, but will probably recover.{x\n\r",
victim);
break;
case POS_DEAD:
if ((IS_NPC(victim)) && (victim->die_descr[0] != '\0')) {
act("{c$n $T{x", victim, 0, victim->die_descr, TO_ROOM);
} else {
act("{c$n is {CDEAD!!{x", victim, 0, 0, TO_ROOM);
}
send_to_char("{cYou have been {RKILLED!!{x\n\r\n\r", victim);
break;
default:
if (dam > victim->max_hit / 4)
send_to_char("{cThat really did {RHURT!{x\n\r", victim);
if (victim->hit < victim->max_hit / 4)
send_to_char("{cYou sure are {z{RBLEEDING!{x\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:
* 5/6 way back to previous level.
*/
if (victim->exp > exp_per_level(victim, victim->pcdata->points)
* victim->level)
if (!IS_SET(victim->act, PLR_LQUEST))
gain_exp(victim, (5 *
(exp_per_level
(victim,
victim->pcdata->points) *
victim->level - victim->exp) / 6) +
50);
}
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);
/*
* Death trigger
*/
if ( IS_NPC( victim ) && HAS_TRIGGER( victim, TRIG_DEATH) )
{
victim->position = POS_STANDING;
mp_percent_trigger( victim, ch, NULL, NULL, TRIG_DEATH );
}
raw_kill(victim, ch);
/* dump the flags */
if (IS_SET(victim->exbit1_flags, RECRUIT)) {
REMOVE_BIT(victim->exbit1_flags, RECRUIT);
}
if (IS_SET(victim->exbit1_flags, PK_KILLER)) {
REMOVE_BIT(victim->exbit1_flags, PK_KILLER);
SET_BIT(ch->exbit1_flags, PK_LAWFUL);
}
if (ch != victim && !IS_NPC(ch) && (!is_same_clan(ch, victim)
|| clan_table[victim->clan].
independent)) {
if (IS_SET(victim->act, PLR_TWIT))
REMOVE_BIT(victim->act, PLR_TWIT);
}
if (!IS_NPC(ch) && !IS_NPC(victim)
&& IS_SET(ch->in_room->room_flags, ROOM_ARENA)
&& IS_SET(victim->in_room->room_flags, ROOM_ARENA)) {
check_arena(ch, victim);
return TRUE;
}
/* RT new auto commands */
if (!IS_NPC(ch) && IS_NPC(victim)) {
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 (!IS_NPC(victim)
&& victim->hit > 0
&& victim->hit <= victim->wimpy
&& victim->wait < PULSE_VIOLENCE / 2) do_flee(victim, "");
tail_chain();
return TRUE;
}
/*
* Show damage from a mock hit.
*/
bool damage_mock(CHAR_DATA * ch, CHAR_DATA * victim, int dam, int dt,
int dam_type, bool show)
{
long immdam;
bool immune;
char buf1[256], buf2[256], buf3[256];
const char *attack;
if (victim->position == POS_DEAD)
return FALSE;
if (dam > 35)
dam = (dam - 35) / 2 + 35;
if (dam > 80)
dam = (dam - 80) / 2 + 80;
if (is_safe_mock(ch, victim))
return FALSE;
/*
* Damage modifiers.
*/
if (dam > 1 && !IS_NPC(victim)
&& victim->pcdata->condition[COND_DRUNK] > 10)
dam = 9 * dam / 10;
if (dam > 1 && IS_SHIELDED(victim, SHD_SANCTUARY))
dam /= 2;
if (dam > 1 && ((IS_SHIELDED(victim, SHD_PROTECT_EVIL) && IS_EVIL(ch))
|| (IS_SHIELDED(victim, SHD_PROTECT_GOOD)
&& IS_GOOD(ch)))) dam -= dam / 4;
immune = FALSE;
switch (check_immune(victim, dam_type)) {
case (IS_IMMUNE):
immune = TRUE;
dam = 0;
break;
case (IS_RESISTANT):
dam -= dam / 3;
break;
case (IS_VULNERABLE):
dam += dam / 2;
break;
}
if (dt >= 0 && dt < MAX_SKILL)
attack = skill_table[dt].noun_damage;
else if (dt >= TYPE_HIT && dt <= TYPE_HIT + MAX_DAMAGE_MESSAGE)
attack = attack_table[dt - TYPE_HIT].noun;
else {
bug("Dam_message: bad dt %d.", dt);
dt = TYPE_HIT;
attack = attack_table[0].name;
}
immdam = 0;
if (ch->level == MAX_LEVEL) {
immdam = dam * 63;
}
if (ch == victim) {
sprintf(buf1,
"{y$n's {gmock {B%s{g would have done {R%d hp{g damage to {y$mself{g.{x",
attack, dam);
sprintf(buf2,
"{yYour {gmock {B%s{g would have done {R%d hp{g damage to {yyourself{g.{x",
attack, dam);
act(buf1, ch, NULL, NULL, TO_ROOM);
act(buf2, ch, NULL, NULL, TO_CHAR);
} else if (ch->level < MAX_LEVEL) {
sprintf(buf1,
"{y$n's {gmock {B%s{g would have done {R%d hp{g damage to {y$N{g.{x",
attack, dam);
sprintf(buf2,
"{yYour {gmock {B%s{g would have done {R%d hp{g damage to {y$N{g.{x",
attack, dam);
sprintf(buf3,
"{y$n's {gmock {B%s{g would have done {R%d hp{g damage to {yyou{g.{x",
attack, dam);
act(buf1, ch, NULL, victim, TO_NOTVICT);
act(buf2, ch, NULL, victim, TO_CHAR);
act(buf3, ch, NULL, victim, TO_VICT);
} else {
sprintf(buf1,
"{y$n's {gmock {B%s{g would have done {R%lu hp{g damage to {y$N{g.{x",
attack, immdam);
sprintf(buf2,
"{yYour {gmock {B%s{g would have done {R%lu hp{g damage to {y$N{g.{x",
attack, immdam);
sprintf(buf3,
"{y$n's {gmock {B%s{g would have done {R%lu hp{g damage to {yyou{g.{x",
attack, immdam);
act(buf1, ch, NULL, victim, TO_NOTVICT);
act(buf2, ch, NULL, victim, TO_CHAR);
act(buf3, ch, NULL, victim, TO_VICT);
}
tail_chain();
return TRUE;
}
bool is_safe(CHAR_DATA * ch, CHAR_DATA * victim)
{
if (victim->in_room == NULL || ch->in_room == NULL)
return TRUE;
if (victim->fighting == ch || victim == ch)
return FALSE;
if (!IS_NPC(ch) && IS_IMMORTAL(ch))
return FALSE;
if (ch->spirit) {
send_to_char("You need a body for that!\n\r", ch);
return TRUE;
}
if (victim->spirit) {
send_to_char("Spirits are difficult to harm.\n\r", ch);
return TRUE;
}
/* killing mobiles */
if (IS_NPC(victim)) {
/* safe room? */
if (IS_SET(victim->in_room->room_flags, ROOM_SAFE)) {
send_to_char("Not in this room.\n\r", ch);
return TRUE;
}
if (IS_SET(victim->exbit1_flags, RECRUIT)
|| IS_SET(victim->exbit1_flags, PK_VETERAN)
|| IS_SET(victim->exbit1_flags, PK_LAWFUL)
|| IS_SET(victim->exbit1_flags, PK_KILLER)
|| IS_SET(victim->exbit1_flags, PK_KILLER2)) {
return FALSE;
}
if (IS_SET(victim->in_room->room_flags, ROOM_ARENA))
return FALSE;
if (IS_SET(victim->in_room->room_flags, ROOM_ARENA))
return FALSE;
if (!IS_NPC(ch)
&& IS_SET(victim->in_room->room_flags, ROOM_CLAN_ENT)) {
send_to_char("Not in this room.\n\r", ch);
return TRUE;
}
if (victim->pIndexData->pShop != NULL) {
send_to_char("The shopkeeper wouldn't like that.\n\r", ch);
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_BANKER)
|| IS_SET(victim->act, ACT_IS_SATAN)
|| IS_SET(victim->act, ACT_IS_PRIEST)) {
act("I don't think $g would approve.", ch, NULL, NULL,
TO_CHAR);
return TRUE;
}
if (!IS_NPC(ch)) {
/* no pets */
if (IS_SET(victim->act, ACT_PET)) {
act("But $N looks so cute and cuddly...",
ch, NULL, victim, TO_CHAR);
return TRUE;
}
/* no charmed creatures unless owner */
if (IS_AFFECTED(victim, AFF_CHARM) && ch != victim->master) {
send_to_char("You don't own that monster.\n\r", ch);
return TRUE;
}
}
}
/* killing players */
else {
/* NPC doing the killing */
if (IS_NPC(ch)) {
/* safe room check */
if (IS_SET(victim->in_room->room_flags, ROOM_SAFE)) {
send_to_char("Not in this room.\n\r", ch);
return TRUE;
}
/* 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 (IS_SET(victim->in_room->room_flags, ROOM_ARENA))
return FALSE;
if (IS_SET(victim->act, PLR_TWIT))
return FALSE;
if (((victim->level > 19)
|| ((victim->class >= MCLT_1)
&& (victim->level > 14)))
&& (is_voodood(ch, victim)))
return FALSE;
if (IS_SET(victim->in_room->room_flags, ROOM_SAFE)) {
send_to_char("Not in this room.\n\r", ch);
return TRUE;
}
if (ch->on_gquest) {
send_to_char("Not while you are on a quest.\n\r", ch);
return TRUE;
}
if (victim->on_gquest) {
send_to_char("They are on a quest, leave them alone.\n\r",
ch);
return TRUE;
}
if (!is_clan(ch)) {
send_to_char
("Join a clan if you want to fight players.\n\r", ch);
return TRUE;
}
if (!is_pkill(ch)) {
send_to_char
("Your clan does not allow player fighting.\n\r", ch);
return TRUE;
}
if (!is_clan(victim)) {
send_to_char
("They aren't in a clan, leave them alone.\n\r", ch);
return TRUE;
}
if (!is_pkill(victim)) {
send_to_char
("They are in a no pkill clan, leave them alone.\n\r",
ch);
return TRUE;
}
if (is_same_clan(ch, victim)) {
send_to_char("You can't fight your own clan members.\n\r",
ch);
return TRUE;
}
if (((ch->pcdata->tier == 2)
&& (victim->pcdata->tier == 2))
|| ((ch->pcdata->tier == 1)
&& (victim->pcdata->tier == 1))
|| ((ch->pcdata->tier == 0)
&& (victim->pcdata->tier == 0))) {
if (ch->level > victim->level + 10) {
send_to_char("Pick on someone your own size.\n\r", ch);
return TRUE;
}
if (ch->level < victim->level - 20) {
send_to_char
("If you wish to die, there are less painful methods.\n\r",
ch);
return TRUE;
}
}
if ((ch->pcdata->tier == 2)
&& (victim->pcdata->tier == 0)) {
send_to_char("Pick on someone your own size.\n\r", ch);
return TRUE;
}
if ((ch->pcdata->tier == 0)
&& (victim->pcdata->tier == 2)) {
send_to_char
("If you wish to die, there are less painful methods.\n\r",
ch);
return TRUE;
}
if (((ch->pcdata->tier == 1)
&& (victim->pcdata->tier == 0))
|| ((ch->pcdata->tier == 2)
&& (victim->pcdata->tier == 1))) {
if (ch->level < (victim->level - 30)) {
send_to_char
("If you wish to die, there are less painful methods.\n\r",
ch);
return TRUE;
}
if (ch->level > victim->level) {
send_to_char("Pick on someone your own size.\n\r", ch);
return TRUE;
}
}
if (((ch->pcdata->tier == 0)
&& (victim->pcdata->tier == 1))
|| ((ch->pcdata->tier == 1)
&& (victim->pcdata->tier == 2))) {
if (ch->level < (victim->level - 10)) {
send_to_char
("If you wish to die, there are less painful methods.\n\r",
ch);
return TRUE;
}
if (ch->level > (victim->level + 20)) {
send_to_char("Pick on someone your own size.\n\r", ch);
return TRUE;
}
}
}
}
return FALSE;
}
bool is_safe_mock(CHAR_DATA * ch, CHAR_DATA * victim)
{
if (victim->in_room == NULL || ch->in_room == NULL)
return TRUE;
if (!IS_NPC(ch) && IS_IMMORTAL(ch))
return FALSE;
if (ch->spirit) {
send_to_char("You need a body for that!\n\r", ch);
return TRUE;
}
if (victim->spirit) {
send_to_char("Spirits are difficult to harm.\n\r", ch);
return TRUE;
}
if (IS_SET(victim->in_room->room_flags, ROOM_SAFE)) {
send_to_char("Not in this room.\n\r", ch);
return TRUE;
}
if (IS_NPC(victim)) {
send_to_char("{RYou can only use this on a player.{x\n\r", ch);
return TRUE;
}
return FALSE;
}
/*=======================================================================*
* function: do_challenge *
* purpose: sends initial arena match query *
* written by: Doug Araya (whiplash@tft.nacs.net) 6-10-96 *
*=======================================================================*/
// DB
void do_challenge(CHAR_DATA * ch, char *argument)
{
CHAR_DATA *victim;
char buf[MSL];
DESCRIPTOR_DATA *d;
/* == First make all invalid checks == */
if (IS_NPC(ch))
return;
if ((ch->in_room->vnum == ROOM_VNUM_CORNER)
&& (!IS_IMMORTAL(ch))) {
send_to_char
("Just keep your nose in the corner like a good little player.\n\r",
ch);
return;
}
if (arena == FIGHT_START) {
send_to_char
("Sorry, some one else has already started a challenge, please try later.\n\r",
ch);
return;
}
if (arena == FIGHT_BUSY) {
send_to_char
("Sorry, there is a fight in progress, please wait a few moments.\n\r",
ch);
return;
}
if (arena == FIGHT_LOCK) {
send_to_char("Sorry, the arena is currently locked from use.\n\r",
ch);
return;
}
if (IS_SET(ch->exbit1_flags, EXBIT1_CHALLENGED)) {
send_to_char
("You have already been challenged, either ACCEPT or DECLINE first.\n\r",
ch);
return;
}
if (ch->hit < ch->max_hit) {
send_to_char("You must be fully healed to fight in the arena.\n\r",
ch);
return;
}
if (IS_AFFECTED(ch, SHD_INVISIBLE) || IS_AFFECTED(ch, AFF_SNEAK)
|| IS_AFFECTED(ch, AFF_HIDE)) {
send_to_char
("You can't challenge while invis, sneaking, or hidden.\n\r",
ch);
return;
}
if (argument[0] == '\0') {
send_to_char("You must specify whom you wish to challenge.\n\r",
ch);
return;
}
if ((victim = get_char_world(ch, argument)) == NULL) {
send_to_char("They are not playing.\n\r", ch);
return;
}
if ((victim->in_room->vnum == ROOM_VNUM_CORNER)) {
send_to_char("They are in the corner, leave them alone.\n\r", ch);
return;
}
/*
if( IS_IMMORTAL(ch) )
{
send_to_char("Immortals are not allowed to battle in the arena.\n\r",ch);
return;
}
*/
if (IS_NPC(victim) || victim == ch) {
send_to_char("You cannot challenge NPC's, or yourself.\n\r", ch);
return;
}
if (IS_AFFECTED(victim, AFF_BLIND)) {
send_to_char("That person is blind right now.\n\r", ch);
return;
}
if (IS_SET(victim->exbit1_flags, EXBIT1_CHALLENGER)) {
send_to_char("They have already challenged someone else.\n\r", ch);
return;
}
if (victim->fighting != NULL) {
send_to_char("That person is engaged in battle right now.\n\r",
ch);
return;
}
if (victim->hit < victim->max_hit) {
send_to_char
("That player is not healthy enough to fight right now.\n\r",
ch);
return;
}
if (IS_SET(victim->comm, COMM_AFK)) {
send_to_char
("That player is AFK at the moment, try them later.\n\r", ch);
return;
}
if (victim->desc == NULL) {
send_to_char
("That player is linkdead at the moment, try them later.\n\r",
ch);
return;
}
if (IS_SET(ch->comm, COMM_NOARENA)) {
send_to_char
("Why should you be allowed to challenge if no one can challenge you?\n\r",
ch);
return;
}
if (IS_SET(victim->comm, COMM_NOARENA)) {
send_to_char("That player is blocking all challenges.\n\r", ch);
return;
}
if (victim->level <= 10) {
send_to_char("That player is just a newbie!\n\r", ch);
return;
}
if (ch->level > (victim->level + 50)) {
send_to_char("That player would be no challenge at all!\r", ch);
return;
}
if (ch->level < (victim->level - 50)) {
act("{bThey laugh at you mercilessly!{x\r.",
ch, NULL, victim, TO_VICT);
return;
}
/* == Now for the challenge == */
ch->challenged = victim;
SET_BIT(ch->exbit1_flags, EXBIT1_CHALLENGER);
victim->challenger = ch;
SET_BIT(victim->exbit1_flags, EXBIT1_CHALLENGED);
arena = FIGHT_START;
send_to_char("Challenge has been sent\n\r", ch);
act("{b$n{x has {ychallenged{x you to a {rdeath match{x.",
ch, NULL, victim, TO_VICT);
sprintf(buf,
"{W^{x{gArena{x{W^{x {R%s{x has {rchallenged{x {B%s{x to a duel.\n\r",
ch->name, victim->name);
for (d = descriptor_list; d; d = d->next) {
if (d->connected == CON_PLAYING &&
(d->character != victim && d->character != ch)
&& !IS_SET(d->character->comm, COMM_NOARENA)) {
send_to_char(buf, d->character);
}
}
sprintf(buf, "type: {gACCEPT{x {b%s{x to meet the challenge.\n\r",
ch->name);
send_to_char(buf, victim);
sprintf(buf, "type: {gDECLINE{x {b%s{x to chicken out.\n\r", ch->name);
send_to_char(buf, victim);
return;
}
/*=======================================================================*
* function: do_accept *
* purpose: to accept the arena match, and move the players to the arena *
* written by: Doug Araya (whiplash@tft.nacs.net) 6-10-96 *
*=======================================================================*/
void do_accept(CHAR_DATA * ch, char *argument)
{
float vafl, vdfl, cafl, cdfl, vpd, vpk, cpd, cpk;
float clvl, vlvl, cw, vw, clo, vlo;
// the preceding variables before this point can be redefined to use less space.
// all variables following need to be set at what they are.
float cha_stat, vha_stat; //base odds from arena wins
float chl_stat, vhl_stat; //base odds from level diff
float chpk_stat, vhpk_stat; //base odds from pk/pd ratio
float cht_stat, vht_stat; //Average odds of winning based
// off previous statistics
DESCRIPTOR_DATA *d;
CHAR_DATA *victim;
char buf1[MSL];
char buf2[MSL];
char buf3[MSL];
int char_room;
int vict_room;
char_room = number_range(27001, 27032);
vict_room = number_range(27001, 27032);
if (IS_NPC(ch))
return;
if (!IS_SET(ch->exbit1_flags, EXBIT1_CHALLENGED)) {
send_to_char("You have not been challenged.\n\r", ch);
return;
}
if (arena == FIGHT_BUSY) {
send_to_char
("Sorry, there is a fight in progress, please wait a few moments.\n\r",
ch);
return;
}
if (arena == FIGHT_LOCK) {
send_to_char("Sorry, the arena is currently locked from use.\n\r",
ch);
return;
}
if (argument[0] == '\0') {
send_to_char
("You must specify whose challenge you wish to accept.\n\r",
ch);
return;
}
if ((victim = get_char_world(ch, argument)) == NULL) {
send_to_char("They aren't logged in!\n\r", ch);
return;
}
if (victim == ch) {
send_to_char("You haven't challenged yourself!\n\r", ch);
return;
}
if (!IS_SET(victim->exbit1_flags, EXBIT1_CHALLENGER)
|| victim != ch->challenger) {
send_to_char("That player hasn't challenged you!\n\r", ch);
return;
}
send_to_char("You have accepted the challenge!\n\r", ch);
act("$n accepts your challenge!", ch, NULL, victim, TO_VICT);
cw = ch->pcdata->awins;
vw = victim->pcdata->awins;
clo = ch->pcdata->alosses;
vlo = victim->pcdata->alosses;
clvl = ch->level;
vlvl = victim->level;
vafl = victim->pcdata->aflee;
vdfl = victim->pcdata->dflee;
cafl = ch->pcdata->aflee;
cdfl = ch->pcdata->dflee;
vpd = victim->pcdata->pdeath;
vpk = victim->pcdata->pkills;
cpd = ch->pcdata->pdeath;
cpk = ch->pcdata->pkills;
/* flee record is currently not taken into account */
/* until a fair adjustment can be decided using it. *
vafl = victim->pcdata->aflee;
vdfl = victim->pcdata->dflee;
cafl = ch->pcdata->aflee;
cdfl = ch->pcdata->dflee;
* can add later
*/
/* This sets base odds of winning to 1. Needed to maintain accurate ratio's */
/* and to also keep this function from having 'division by zero' errors */
if (cw == 0) {
cw = 1;
}
if (clo == 0) {
clo = 1;
}
if (cpd == 0) {
cpd = 1;
}
if (cpk == 0) {
cpk = 1;
}
if (vw == 0) {
vw = 1;
}
if (vlo == 0) {
vlo = 1;
}
if (vpd == 0) {
vpd = 1;
}
if (vpk == 0) {
vpk = 1;
}
/* Sample odds from a test fight are commented in to the right
Please take a look at these and notice how much of an extreme
in odds you get by having each base stat use both peoples stats */
/* Base odds from previous arena wins/loss ratio */
cha_stat = ((cw / clo) / (vw / vlo));
/* (1/4) / (100/10) = 0.025 */
vha_stat = ((vw / vlo) / (cw / clo));
/* (100/10) / (1/4) = 40.00 */
/* Base odds from pk/pdeath ratio */
chpk_stat = ((cpk / cpd) / (vpk / vpd));
/* (1/5) / (2/20) = 2.0 */
vhpk_stat = ((vpk / vpd) / (cpk / cpd));
/* (2/20) / (1/5) = 0.5 */
/* Base odds from level differences */
chl_stat = ((clvl / vlvl)); // 20/40 = 0.5
vhl_stat = ((vlvl / clvl)); // 40/20 = 2.0
/* Calculate winning odds = AVG of other ratio's */
/* Does NOT always equal payoff ratio */
cht_stat = ((cha_stat + chpk_stat + chl_stat) / 3); // 2.0 + 0.5 + .025 = 2.25/3 = .750
vht_stat = ((vha_stat + vhpk_stat + vhl_stat) / 3); // 0.5 + 2.0 + 40.0 = 42.5/3 = 14.x
/* Enforce payoff ratio limits
Max payoff is 300% profit
Min payoff is 20% profit */
if (cha_stat > 3) {
cha_stat = 3;
}
if (chl_stat > 3) {
chl_stat = 3;
}
if (chpk_stat > 3) {
chpk_stat = 3;
}
if (vha_stat > 3) {
vha_stat = 3;
}
if (vhl_stat > 3) {
vhl_stat = 3;
}
if (vhpk_stat > 3) {
vhpk_stat = 3;
}
if (cha_stat < .2) {
cha_stat = .2;
}
if (chl_stat < .2) {
chl_stat = .2;
}
if (chpk_stat < .2) {
chpk_stat = .2;
}
if (vha_stat < .2) {
vha_stat = .2;
}
if (vhl_stat < .2) {
vhl_stat = .2;
}
if (vhpk_stat < .2) {
vhpk_stat = .2;
}
/* the aditional +1 is set here to make sure the original bet
is also returned with the profits */
/*bet is not deducted in the first place, so +1 removed */
cpo_stat = ((cha_stat + chpk_stat + chl_stat) / 3);
vpo_stat = ((vha_stat + vhpk_stat + vhl_stat) / 3);
if (cpo_stat > 10) {
cpo_stat = 10;
}
if (vpo_stat > 10) {
vpo_stat = 10;
}
sprintf(buf1,
"^{gArena{x^ {b%s{x {m({y%d {gwins{m) ({y%d {rlosses{m){x Payoff odds %f\n\r",
victim->name, victim->pcdata->awins, victim->pcdata->alosses,
vht_stat);
sprintf(buf2,
"^{gArena{x^ {b%s{x {m({y%d {gwins{m) ({y%d {rlosses{m){x Payoff odds %f\n\r",
ch->name, ch->pcdata->awins, ch->pcdata->alosses, cht_stat);
strcpy(buf3,
"{x^{gArena{x^ To wager on the fight, type: {gbet{x ({yamount{x) ({bplayer name{x)\n\r");
for (d = descriptor_list; d; d = d->next) {
if (d->connected == CON_PLAYING &&
(d->character != victim && d->character != ch)
&& !IS_SET(d->character->comm, COMM_NOARENA)) {
send_to_char(buf1, d->character);
send_to_char(buf2, d->character);
send_to_char(buf3, d->character);
d->character->gladiator = NULL;
}
}
/* == now move them both to an arena for the fun == */
send_to_char("You make your way into the arena.\n\r", ch);
char_from_room(ch);
char_to_room(ch, get_room_index(char_room));
do_look(ch, "auto");
SET_BIT(ch->comm, COMM_NOCHANNELS);
SET_BIT(ch->act, PLR_NORESTORE);
send_to_char("You make your way to the arena.\n\r", victim);
char_from_room(victim);
char_to_room(victim, get_room_index(vict_room));
do_look(victim, "auto");
SET_BIT(victim->comm, COMM_NOCHANNELS);
SET_BIT(victim->act, PLR_NORESTORE);
arena = FIGHT_BUSY;
return;
}
/*=======================================================================*
if( !IS_SET(fighter->in_room->room_flags,ROOM_ARENA) )
* function: do_decline *
* purpose: to chicken out from a sent arena challenge *
* written by: Doug Araya (whiplash@tft.nacs.net) 6-10-96 *
*=======================================================================*/
void do_decline(CHAR_DATA * ch, char *argument)
{
CHAR_DATA *victim;
char buf[MSL];
DESCRIPTOR_DATA *d;
/*== make all invalid checks == */
if (IS_NPC(ch))
return;
if (!IS_SET(ch->exbit1_flags, EXBIT1_CHALLENGED)) {
send_to_char
("You have niether given a challenge or been challenged.\n\r",
ch);
return;
}
if (argument[0] == '\0') {
send_to_char
("You must specify whose challenge you wish to decline.\n\r",
ch);
return;
}
if ((victim = get_char_world(ch, argument)) == NULL) {
send_to_char("They aren't logged in!\n\r", ch);
return;
}
if (!IS_SET(victim->exbit1_flags, EXBIT1_CHALLENGER)
|| victim != ch->challenger) {
send_to_char("That player hasn't challenged you.\n\r", ch);
return;
}
/*== now actually decline == */
victim->challenged = NULL;
REMOVE_BIT(victim->exbit1_flags, EXBIT1_CHALLENGER);
ch->challenger = NULL;
REMOVE_BIT(ch->exbit1_flags, EXBIT1_CHALLENGED);
arena = FIGHT_OPEN;
send_to_char("Challenge declined!\n\r", ch);
act("$n has withdrawn from the challenge.", ch, NULL, victim, TO_VICT);
sprintf(buf,
"^{gArena{x^ {b%s{x {bhas withdrawn from the challenge{x.\n\r",
ch->name);
for (d = descriptor_list; d; d = d->next) {
if (d->connected == CON_PLAYING &&
(d->character != victim && d->character != ch)
&& !IS_SET(d->character->comm, COMM_NOARENA)) {
send_to_char(buf, d->character);
}
}
return;
}
void do_dismiss(CHAR_DATA * ch, char *argument)
{
CHAR_DATA *victim;
char buf[MSL];
DESCRIPTOR_DATA *d;
/*== make all invalid checks == */
if (IS_NPC(ch))
return;
if (!IS_SET(ch->exbit1_flags, EXBIT1_CHALLENGER)) {
send_to_char
("You have niether given a challenge or been challenged.\n\r",
ch);
return;
}
if (argument[0] == '\0') {
send_to_char
("You must specify whose challenge you wish to decline.\n\r",
ch);
return;
}
if ((victim = get_char_world(ch, argument)) == NULL) {
send_to_char("They aren't logged in!\n\r", ch);
return;
}
if (!IS_SET(victim->exbit1_flags, EXBIT1_CHALLENGER)
|| victim != ch->challenger) {
send_to_char("That player hasn't challenged you.\n\r", ch);
return;
}
/*== now actually decline == */
victim->challenged = NULL;
REMOVE_BIT(victim->exbit1_flags, EXBIT1_CHALLENGER);
ch->challenger = NULL;
REMOVE_BIT(ch->exbit1_flags, EXBIT1_CHALLENGED);
arena = FIGHT_OPEN;
send_to_char("Challenge declined!\n\r", ch);
act("$n has withdrawn from the challenge.", ch, NULL, victim, TO_VICT);
sprintf(buf,
"^{gArena{x^ {b%s{x {bhas withdrawn from the challenge{x.\n\r",
ch->name);
for (d = descriptor_list; d; d = d->next) {
if (d->connected == CON_PLAYING &&
(d->character != victim && d->character != ch)
&& !IS_SET(d->character->comm, COMM_NOARENA)) {
send_to_char(buf, d->character);
}
}
return;
}
void do_arec(CHAR_DATA * ch, char *argument)
{
CHAR_DATA *victim;
char buf[MSL];
DESCRIPTOR_DATA *d;
/* == First make all invalid checks == */
if (IS_NPC(ch)) {
send_to_char("Arec will not recover mobs in the arena!\n\r", ch);
return;
}
if (argument[0] == '\0') {
send_to_char
("Syntax: Arec <player-name> to recover somebody stuck in the Arena.\n\r",
ch);
return;
}
if ((victim = get_char_world(ch, argument)) == NULL) {
send_to_char("They are not playing.\n\r", ch);
return;
}
/* == Removing the flags == */
stop_fighting(victim, TRUE);
char_from_room(victim);
victim->hit = victim->max_hit;
victim->mana = victim->max_mana;
victim->move = victim->max_move;
update_pos(victim);
do_look(victim, "auto");
char_to_room(victim, get_room_index(ROOM_VNUM_AWINNER));
if (IS_SET(ch->exbit1_flags, EXBIT1_CHALLENGER))
REMOVE_BIT(ch->exbit1_flags, EXBIT1_CHALLENGER);
if (IS_SET(victim->exbit1_flags, EXBIT1_CHALLENGER))
REMOVE_BIT(victim->exbit1_flags, EXBIT1_CHALLENGER);
if (IS_SET(victim->exbit1_flags, EXBIT1_CHALLENGED))
REMOVE_BIT(victim->exbit1_flags, EXBIT1_CHALLENGED);
if (IS_SET(ch->exbit1_flags, EXBIT1_CHALLENGED))
REMOVE_BIT(ch->exbit1_flags, EXBIT1_CHALLENGED);
victim->challenger = NULL;
victim->challenged = NULL;
REMOVE_BIT(victim->comm, COMM_NOCHANNELS);
REMOVE_BIT(victim->act, PLR_NORESTORE);
arena = FIGHT_OPEN;
for (d = descriptor_list; d; d = d->next) {
if (d->connected == CON_PLAYING &&
(d->character != victim && d->character != ch)) {
send_to_char(buf, d->character);
}
}
send_to_char("Player recovered from the arena.\n\r", ch);
return;
}
/*======================================================================*
* function: do_bet *
* purpose: to allow players to wager on the outcome of arena battles *
* written by: Doug Araya (whiplash@tft.nacs.net) 6-10-96 *
*======================================================================*/
void do_bet(CHAR_DATA * ch, char *argument)
{
char arg[MIL];
char buf[MSL];
CHAR_DATA *fighter;
int wager;
argument = one_argument(argument, arg);
if (argument[0] == '\0' || !is_number(arg)) {
send_to_char("Syntax: BET [amount] [player]\n\r", ch);
return;
}
if (ch->gladiator != NULL) {
send_to_char("You have already placed a bet on this fight.\n\r",
ch);
return;
}
/*== disable the actual fighters from betting ==*/
if (IS_SET(ch->exbit1_flags, EXBIT1_CHALLENGER)
|| IS_SET(ch->exbit1_flags, EXBIT1_CHALLENGED)) {
send_to_char("You can't bet on this battle.\n\r", ch);
return;
}
fighter = get_char_world(ch, argument);
/*== make sure the choice is valid ==*/
if (fighter == NULL) {
send_to_char("That player is not logged in.\n\r", ch);
return;
}
if (IS_NPC(ch)) {
send_to_char("Why bet on a mob? They aren't fighting...\n\r", ch);
return;
}
if (!IS_SET(fighter->in_room->room_flags, ROOM_ARENA)) {
send_to_char("That player is not in the arena.\n\r", ch);
return;
}
/*== do away with the negative number trickery ==*/
if (!str_prefix("-", arg)) {
send_to_char("Error: Invalid argument!\n\r", ch);
return;
}
wager = atoi(arg);
if (wager > 10001 || wager < 1) {
send_to_char("Wager range is between 1 and 10000\n\r", ch);
return;
}
/*== make sure they have the cash ==*/
if (wager > ch->gold + (ch->platinum * 100)) {
send_to_char("You don't have that much gold to wager!\n\r", ch);
return;
}
/*== now set the info ==*/
ch->gladiator = fighter;
ch->pcdata->plr_wager = wager;
sprintf(buf, "You have placed a {y%d{x gold wager on {b%s{x\n\r",
wager, fighter->name);
send_to_char(buf, ch);
return;
}
bool is_voodood(CHAR_DATA * ch, CHAR_DATA * victim)
{
OBJ_DATA *object;
bool found;
if (ch->level > HERO)
return FALSE;
found = FALSE;
for (object = victim->carrying; object != NULL;
object = object->next_content) {
if (object->pIndexData->vnum == OBJ_VNUM_VOODOO) {
char arg[MIL];
one_argument(object->name, arg);
if (!str_cmp(arg, ch->name)) {
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_NPC(ch) && IS_IMMORTAL(ch))
return FALSE;
if (ch->spirit)
return TRUE;
if (victim->spirit)
return TRUE;
/* killing mobiles */
if (IS_NPC(victim)) {
/* safe room? */
if (IS_SET(victim->in_room->room_flags, ROOM_SAFE))
return TRUE;
if (!IS_NPC(ch)
&& IS_SET(victim->in_room->room_flags,
ROOM_CLAN_ENT)) 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_BANKER)
|| IS_SET(victim->act, ACT_IS_SATAN)
|| IS_SET(victim->act, ACT_IS_PRIEST))
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_SET(victim->in_room->room_flags, ROOM_ARENA))
return FALSE;
if (IS_SET(victim->act, PLR_TWIT))
return FALSE;
if (((victim->level > 19)
|| ((victim->class >= MCLT_1)
&& (victim->level > 14)))
&& (is_voodood(ch, victim)))
return FALSE;
if (!is_clan(ch))
return TRUE;
if (!is_pkill(ch))
return TRUE;
if (IS_SET(victim->in_room->room_flags, ROOM_SAFE))
return TRUE;
if (ch->on_gquest)
return TRUE;
if (victim->on_gquest)
return TRUE;
if (!is_clan(victim))
return TRUE;
if (!is_pkill(victim))
return TRUE;
if (is_same_clan(ch, victim))
return TRUE;
if (((ch->pcdata->tier == 2)
&& (victim->pcdata->tier == 2))
|| ((ch->pcdata->tier == 1)
&& (victim->pcdata->tier == 1))
|| ((ch->pcdata->tier == 0)
&& (victim->pcdata->tier == 0))) {
if (ch->level > victim->level + 10) {
return TRUE;
}
if (ch->level < victim->level - 20) {
return TRUE;
}
}
if ((ch->pcdata->tier == 2)
&& (victim->pcdata->tier == 0)) {
return TRUE;
}
if ((ch->pcdata->tier == 0)
&& (victim->pcdata->tier == 2)) {
return TRUE;
}
if (((ch->pcdata->tier == 1)
&& (victim->pcdata->tier == 0))
|| ((ch->pcdata->tier == 2)
&& (victim->pcdata->tier == 1))) {
if (ch->level < (victim->level - 30)) {
return TRUE;
}
if (ch->level > victim->level) {
return TRUE;
}
}
if (((ch->pcdata->tier == 0)
&& (victim->pcdata->tier == 1))
|| ((ch->pcdata->tier == 1)
&& (victim->pcdata->tier == 2))) {
if (ch->level < (victim->level - 10)) {
return TRUE;
}
if (ch->level > (victim->level + 20)) {
return TRUE;
}
}
}
}
return FALSE;
}
/*
* Check for parry.
*/
bool check_parry(CHAR_DATA * ch, CHAR_DATA * victim)
{
int chance;
int bill;
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 (victim->stunned)
return FALSE;
if (!can_see(ch, victim))
chance /= 2;
if (number_percent() >= chance + victim->level - ch->level)
return FALSE;
if (IS_STANCE(victim, STANCE_CRANE) &&
victim->stance[STANCE_CRANE] > 0 && !can_counter(ch) &&
!can_bypass(ch, victim))
chance += (victim->stance[STANCE_CRANE] * 0.25);
else if (IS_STANCE(victim, STANCE_MANTIS) &&
victim->stance[STANCE_MANTIS] > 0 && !can_counter(ch) &&
!can_bypass(ch, victim))
chance += (victim->stance[STANCE_MANTIS] * 0.25);
/* fuk */
bill = number_range(1, 24);
if (bill == 1) {
act("With cat like speed you parry $n's attack.", ch, NULL, victim,
TO_VICT);
act("With cat like speed $N parries your attack.", ch, NULL,
victim, TO_CHAR);
act("With cat like speed $n parries $N's attack.", ch, NULL,
victim, TO_NOTVICT);
check_improve(victim, gsn_parry, TRUE, 6);
} else if (bill == 2) {
act("You move your weapon up parrying $n's attack.", ch, NULL,
victim, TO_VICT);
act("$N moves $s weapon up parrying your blow.", ch, NULL, victim,
TO_CHAR);
act("$n moves $s weapon up parrying $N's blow.", ch, NULL, victim,
TO_NOTVICT);
check_improve(victim, gsn_parry, TRUE, 6);
} else if (bill == 3) {
act("You move your weapon to the side parrying $n's blow.", ch,
NULL, victim, TO_VICT);
act("$N moves $s weapon to the side parrying your blow.", ch, NULL,
victim, TO_CHAR);
act("$n moves $s weapon to the side parring $N's blow.", ch, NULL,
victim, TO_NOTVICT);
check_improve(victim, gsn_parry, TRUE, 6);
} else if (bill == 4) {
act("You deftly move your weapon between $n's attack.", ch, NULL,
victim, TO_VICT);
act("$N deftly moves $s weapon between your attack", ch, NULL,
victim, TO_CHAR);
act("$n deftly moves $s weapon between $N's attack.", ch, NULL,
victim, TO_NOTVICT);
} else if (bill == 5) {
act("You spin your weapon in a defensive move parrying $n's blow.",
ch, get_eq_char(ch, WEAR_WIELD), victim, TO_VICT);
act("$N spins $s weapon in a defensive move parrying your blow.",
ch, get_eq_char(ch, WEAR_WIELD), victim, TO_CHAR);
act("$n spins $s weapon in a defensive move parrying $N's blow.",
ch, get_eq_char(ch, WEAR_WIELD), victim, TO_NOTVICT);
check_improve(victim, gsn_parry, TRUE, 6);
} else if (bill == 6) {
act("With a bone-jarring skill you parry $n's blow.", ch, NULL,
victim, TO_VICT);
act("With a bone-jarring skill $N parries your blow.", ch, NULL,
victim, TO_CHAR);
act("With a bone-jarring skill $n parries $N's blow.", ch, NULL,
victim, TO_NOTVICT);
check_improve(victim, gsn_parry, TRUE, 6);
} else if (bill == 7) {
act("You swiftly parry $n's attack.", ch, NULL, victim, TO_VICT);
act("$N swiftly parries your attack.", ch, NULL, victim, TO_CHAR);
act("$n swiftly parries $N's attack.", ch, NULL, victim,
TO_NOTVICT);
check_improve(victim, gsn_parry, TRUE, 6);
} else if (bill == 8) {
act("Moving like a panther you parry $n's attack.", ch, NULL,
victim, TO_VICT);
act("$N moves like a panther parrying your attack.", ch, NULL,
victim, TO_CHAR);
act("$n moves like a panther parrying $N's attack.", ch, NULL,
victim, TO_NOTVICT);
check_improve(victim, gsn_parry, TRUE, 6);
}
return TRUE;
}
/*
* Check for shield block.
*/
bool check_shield_block(CHAR_DATA * ch, CHAR_DATA * victim)
{
int chance;
if (!IS_AWAKE(victim))
return FALSE;
chance = get_skill(victim, gsn_shield_block) / 5 + 3;
if (get_eq_char(victim, WEAR_SHIELD) == NULL)
return FALSE;
if (number_percent() >= chance + victim->level - ch->level)
return FALSE;
if (victim->stunned)
return FALSE;
act("You block $n's attack with your shield.{x", ch, NULL, victim,
TO_VICT);
act("{h$N blocks your attack with a shield.{x", ch, NULL, victim,
TO_CHAR);
check_improve(victim, gsn_shield_block, TRUE, 6);
return TRUE;
}
/*
* Check for dodge.
*/
bool check_dodge(CHAR_DATA * ch, CHAR_DATA * victim)
{
int chance;
int bill;
if (!IS_AWAKE(victim))
return FALSE;
chance = get_skill(victim, gsn_dodge) / 2;
if (!can_see(victim, ch))
chance /= 2;
if (number_percent() >= chance + victim->level - ch->level)
return FALSE;
if (victim->stunned)
return FALSE;
if (IS_STANCE(victim, STANCE_MONGOOSE) &&
victim->stance[STANCE_MONGOOSE] > 0 && !can_counter(ch) &&
!can_bypass(ch, victim))
(chance += victim->stance[STANCE_MONGOOSE] * 0.25);
if (IS_STANCE(victim, STANCE_SWALLOW) &&
victim->stance[STANCE_SWALLOW] > 0 && !can_counter(ch) &&
!can_bypass(ch, victim))
(chance += victim->stance[STANCE_SWALLOW] * 0.25);
bill = number_range(1, 27);
if (bill == 1) {
act("You feint to the right dodging $n's blow.", ch, NULL, victim,
TO_VICT);
act("$N feints to the right dodging your blow.", ch, NULL, victim,
TO_CHAR);
act("$n feints to the right dodging $N's blow.", ch, NULL, victim,
TO_NOTVICT);
check_improve(victim, gsn_dodge, TRUE, 6);
} else if (bill == 2) {
act("You quickly duck dodging $n's attack.", ch, NULL, victim,
TO_VICT);
act("$N ducks quickly dodging your attack.", ch, NULL, victim,
TO_CHAR);
act("$n ducks quickly dodging $N's attack.", ch, NULL, victim,
TO_NOTVICT);
check_improve(victim, gsn_dodge, TRUE, 6);
} else if (bill == 3) {
act("You roll to the ground dodging $n's blow.", ch, NULL, victim,
TO_VICT);
act("$N rolls to the ground dodging your blow.", ch, NULL, victim,
TO_CHAR);
act("$n rolls to the ground dodging $N's blow.", ch, NULL, victim,
TO_NOTVICT);
act("$n leaps back up!", ch, NULL, victim, TO_NOTVICT);
act("You leap back up!", ch, NULL, victim, TO_VICT);
act("$N leaps back up!", ch, NULL, victim, TO_CHAR);
check_improve(victim, gsn_dodge, TRUE, 6);
} else if (bill == 4) {
act("You dodge $n's useless attack.", ch, NULL, victim, TO_VICT);
act("$N dodges your useless attack.", ch, NULL, victim, TO_CHAR);
act("$n dodges $N's useless attack.", ch, NULL, victim,
TO_NOTVICT);
check_improve(victim, gsn_dodge, TRUE, 6);
} else if (bill == 5) {
act("You bob and weave dodging $n's blow.", ch, NULL, victim,
TO_VICT);
act("$N bobs and weaves dodging your blow.", ch, NULL, victim,
TO_CHAR);
act("$n bobs and weaves dodging $N's blow.", ch, NULL, victim,
TO_NOTVICT);
check_improve(victim, gsn_dodge, TRUE, 6);
} else if (bill == 6) {
act("You roll with the blow dodging $n's attack.", ch, NULL,
victim, TO_VICT);
act("$N rolls with the blow dodging your attack.", ch, NULL,
victim, TO_CHAR);
act("$n rolls with the blow dodging $N's attack.", ch, NULL,
victim, TO_NOTVICT);
} else if (bill == 7) {
act("You twist right dodging $n.", ch, NULL, victim, TO_VICT);
act("$N twists right dodging your blow.", ch, NULL, victim,
TO_CHAR);
act("$n twists right dodging $N's blow.", ch, NULL, victim,
TO_NOTVICT);
check_improve(victim, gsn_dodge, TRUE, 6);
} else if (bill == 8) {
act("You twist left dodging $n.", ch, NULL, victim, TO_VICT);
act("$N twists left dodging your blow.", ch, NULL, victim,
TO_CHAR);
act("$n twists left dodging $N's blow.", ch, NULL, victim,
TO_NOTVICT);
check_improve(victim, gsn_dodge, TRUE, 6);
} else if (bill == 9) {
act("You roll to the ground dodging $n's blow.", ch, NULL, victim,
TO_VICT);
act("$N rolls to the ground dodging your blow.", ch, NULL, victim,
TO_CHAR);
act("$n rolls to the ground dodging $N's blow.", ch, NULL, victim,
TO_NOTVICT);
act("$n deftly springs to their feet!", ch, NULL, victim,
TO_NOTVICT);
act("deftly... you spring to your feet!", ch, NULL, victim,
TO_VICT);
act("$N deftly springs to their feet!", ch, NULL, victim, TO_CHAR);
check_improve(victim, gsn_dodge, TRUE, 6);
}
return TRUE;
}
/*
* Set position of a victim.
*/
void update_pos(CHAR_DATA * victim)
{
if (victim->hit > 0) {
if (victim->position <= POS_STUNNED)
victim->position = POS_STANDING;
return;
}
if (IS_NPC(victim) && victim->hit < 1) {
victim->position = POS_DEAD;
return;
}
if (victim->hit <= -11) {
if (IS_SET(victim->exbit1_flags, RECRUIT)
&& (victim->pcdata->pdeath >= 5
|| victim->pcdata->pkills >= 5)) {
send_to_char("Your skill at PK has improved.\n\r", victim);
REMOVE_BIT(victim->exbit1_flags, RECRUIT);
SET_BIT(victim->exbit1_flags, PK_VETERAN);
}
victim->position = POS_DEAD;
victim->spirit = 1;
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);
if (ch->shadow) {
ch->shadowing->shadowed = FALSE;
ch->shadowing->shadower = NULL;
ch->shadowing = NULL;
ch->shadow = FALSE;
}
ch->fighting = victim;
ch->position = POS_FIGHTING;
ch->stunned = 0;
return;
}
/*
* Stop fights.
*/
void stop_fighting(CHAR_DATA * ch, bool fBoth)
{
CHAR_DATA *fch;
char buf[MSL];
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;
fch->stunned = 0;
update_pos(fch);
if (IS_SET(fch->comm, COMM_STORE))
if (fch->tells) {
sprintf(buf, "You have {R%d{x tells waiting.\n\r",
fch->tells);
send_to_char(buf, fch);
send_to_char("Type 'replay' to see tells.\n\r", fch);
}
if (IS_SET(ch->exbit1_flags, RECRUIT)
&& (ch->pcdata->pdeath >= 5 || ch->pcdata->pkills >= 5)) {
send_to_char("Your skill at PK has improved.\n\r", ch);
REMOVE_BIT(ch->exbit1_flags, RECRUIT);
SET_BIT(ch->exbit1_flags, PK_VETERAN);
}
}
}
return;
}
/*
* Make a corpse out of a character.
*/
void make_corpse(CHAR_DATA * ch, CHAR_DATA * killer)
{
char buf[MSL];
OBJ_DATA *corpse;
OBJ_DATA *obj;
OBJ_DATA *obj_next;
char *name;
int gold, silver, platinum;
int wearloc;
if (IS_NPC(ch)) {
if (IS_SET(ch->act, ACT_NO_BODY)) {
if (IS_SET(ch->act, ACT_NB_DROP)) {
for (obj = ch->carrying; obj != NULL; obj = obj_next) {
obj_next = obj->next_content;
obj_from_char(obj);
if (!IS_NPC(killer) && killer->pcdata->is_aquest) {
obj->got_from = ch->pIndexData->vnum;
} else {
obj->got_from = 0;
}
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)) {
obj->timer = number_range(5, 10);
REMOVE_BIT(obj->extra_flags, ITEM_ROT_DEATH);
}
REMOVE_BIT(obj->extra_flags, ITEM_VIS_DEATH);
if (IS_SET(obj->extra_flags, ITEM_INVENTORY))
extract_obj(obj);
act("$p falls to the floor.", ch, obj, NULL, TO_ROOM);
obj_to_room(obj, ch->in_room);
}
}
return;
}
name = ch->short_descr;
corpse = create_object(get_obj_index(OBJ_VNUM_CORPSE_NPC), 0);
corpse->timer = number_range(3, 6);
if (ch->silver > 0 || ch->gold > 0 || ch->platinum > 0) {
obj_to_obj(create_money(ch->platinum, ch->gold, ch->silver),
corpse);
ch->platinum = 0;
ch->gold = 0;
ch->silver = 0;
}
corpse->cost = 0;
} else {
name = ch->name;
corpse = create_object(get_obj_index(OBJ_VNUM_CORPSE_PC), 0);
corpse->timer = number_range(25, 40);
REMOVE_BIT(ch->act, PLR_CANLOOT);
if (!is_clan(ch)) {
corpse->owner = str_dup(ch->name);
corpse->killer = NULL;
} else {
corpse->owner = str_dup(ch->name);
corpse->killer = str_dup(killer->name);
if (ch->platinum > 1 || ch->gold > 1 || ch->silver > 1) {
silver = number_range(0, ch->silver / 3);
gold = number_range(0, ch->gold / 3);
platinum = number_range(0, ch->platinum / 3);
obj_to_obj(create_money
((ch->platinum / 2) - platinum,
(ch->gold / 2) - gold,
(ch->silver / 2) - silver), corpse);
ch->platinum -= ch->platinum / 2;
ch->gold -= ch->gold / 2;
ch->silver -= ch->silver / 2;
obj_to_room(create_money(platinum, gold, silver),
ch->in_room);
act("Some money spills across the floor.", ch, NULL, NULL,
TO_ROOM);
act("Some of your money spills across the floor.", ch,
NULL, NULL, TO_CHAR);
}
}
corpse->cost = 0;
}
corpse->level = ch->level;
sprintf(buf, corpse->short_descr, name);
free_string(corpse->short_descr);
corpse->short_descr = str_dup(buf);
sprintf(buf, corpse->description, name);
free_string(corpse->description);
corpse->description = str_dup(buf);
if (!IS_NPC(ch) && !IS_NPC(killer)) {
wearloc = number_range(0, MAX_WEAR - 1);
if ((obj = get_eq_char(ch, wearloc)) != NULL) {
if ((obj->wear_loc != WEAR_FLOAT)
&& (obj->item_type != ITEM_PASSBOOK)
&& (!obj->clan)
&& (!obj->quest)) {
obj_from_char(obj);
obj_to_room(obj, ch->in_room);
act("$p falls to the floor.", ch, obj, NULL, TO_ROOM);
act("$p falls to the floor.", ch, obj, NULL, TO_CHAR);
}
}
wearloc = number_range(0, MAX_WEAR - 1);
if ((obj = get_eq_char(ch, wearloc)) != NULL) {
if ((obj->wear_loc != WEAR_FLOAT)
&& (obj->item_type != ITEM_PASSBOOK)
&& (!obj->clan)
&& (!obj->quest)) {
obj_from_char(obj);
obj_to_room(obj, ch->in_room);
act("$p falls to the floor.", ch, obj, NULL, TO_ROOM);
act("$p falls to the floor.", ch, obj, NULL, TO_CHAR);
}
}
wearloc = number_range(0, MAX_WEAR - 1);
if ((obj = get_eq_char(ch, wearloc)) != NULL) {
if ((obj->wear_loc != WEAR_FLOAT)
&& (obj->item_type != ITEM_PASSBOOK)
&& (!obj->clan)
&& (!obj->quest)) {
obj_from_char(obj);
obj_to_room(obj, ch->in_room);
act("$p falls to the floor.", ch, obj, NULL, TO_ROOM);
act("$p falls to the floor.", ch, obj, NULL, TO_CHAR);
}
}
}
for (obj = ch->carrying; obj != NULL; obj = obj_next) {
bool floating = FALSE;
obj_next = obj->next_content;
if (IS_OBJ_STAT(obj, ITEM_LQUEST))
continue;
if (obj->pIndexData->vnum == OBJ_VNUM_QPOUCH)
continue;
if (obj->wear_loc == WEAR_FLOAT)
floating = TRUE;
obj_from_char(obj);
if (IS_NPC(ch) && !IS_NPC(killer) && killer->pcdata->is_aquest) {
obj->got_from = ch->pIndexData->vnum;
} else {
obj->got_from = 0;
}
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->item_type == ITEM_PASSBOOK) {
change_banklist(ch, FALSE, obj->value[0], obj->value[1], 0,
obj->name);
extract_obj(obj);
} else if (IS_SET(obj->extra_flags, ITEM_INVENTORY)) {
extract_obj(obj);
} else if (floating) {
if (IS_OBJ_STAT(obj, ITEM_ROT_DEATH)) { /* get rid of it! */
if (obj->contains != NULL) {
OBJ_DATA *in, *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
obj_to_obj(obj, corpse);
}
if (!IS_NPC(ch)) {
act("$p vanishes in a bright flash.", ch, corpse, NULL, TO_ROOM);
act("Your corpse vanishes in a bright flash.", ch, corpse, NULL,
TO_CHAR);
if (ch->level < 10 && ch->pcdata->tier < 1 )
obj_to_room(corpse, get_room_index(ROOM_VNUM_MORGUE_SCHOOL));
else
obj_to_room(corpse,
get_room_index(home_table[ch->home].morgue));
} else {
obj_to_room(corpse, ch->in_room);
}
return;
}
/*
* Improved Death_cry contributed by Diavolo.
* PK Token modifications added by D. A. C.
*/
void death_cry(CHAR_DATA * ch, CHAR_DATA * killer)
{
ROOM_INDEX_DATA *was_in_room;
char buf[MSL];
OBJ_DATA *token2, *token3, *token4, *token5, *token6;
// CHAR_DATA *victim;
char *msg;
int door;
int vnum;
vnum = 0;
msg = "You hear $n's death cry.";
if (!IS_SET(ch->act, ACT_NO_BODY)) {
switch (number_bits(4)) {
case 0:
msg = "$n hits the ground ... DEAD.";
vnum = OBJ_VNUM_BLOOD;
break;
case 1:
msg = "$n splatters blood on your armor.";
vnum = OBJ_VNUM_BLOOD;
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;
}
break;
case 8:
msg = "$n hits the ground ... DEAD.";
vnum = OBJ_VNUM_BLOOD;
break;
case 9:
msg = "$n hits the ground ... DEAD.";
vnum = OBJ_VNUM_BLOOD;
}
}
else if (ch->level > 19) {
switch (number_bits(4)) {
case 0:
msg = "$n hits the ground ... DEAD.";
vnum = OBJ_VNUM_BLOOD;
break;
case 1:
msg = "$n splatters blood on your armor.";
vnum = OBJ_VNUM_BLOOD;
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;
}
break;
case 8:
msg = "$n hits the ground ... DEAD.";
vnum = OBJ_VNUM_BLOOD;
break;
case 9:
msg = "$n hits the ground ... DEAD.";
vnum = OBJ_VNUM_BLOOD;
break;
case 10:
if (IS_SET(ch->parts, PART_HEAD)) {
msg = "$n's severed head plops on the ground.";
vnum = OBJ_VNUM_SEVERED_HEAD;
}
break;
case 11:
if (IS_SET(ch->parts, PART_HEART)) {
msg = "$n's heart is torn from $s chest.";
vnum = OBJ_VNUM_TORN_HEART;
}
break;
case 12:
if (IS_SET(ch->parts, PART_ARMS)) {
msg = "$n's arm is sliced from $s dead body.";
vnum = OBJ_VNUM_SLICED_ARM;
}
break;
case 13:
if (IS_SET(ch->parts, PART_LEGS)) {
msg = "$n's leg is sliced from $s dead body.";
vnum = OBJ_VNUM_SLICED_LEG;
}
break;
case 14:
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) && !IS_SET(ch->act, ACT_NO_BODY) && (!IS_SET(ch->in_room->room_flags, ROOM_ARENA)))
{
switch (number_bits(4)) {
case 0:
if (killer == ch) // This part here is where I want it to return if its a self kill
return;
if ( !IS_NPC( ch ) ) {
vnum = OVPKT1;
} else {
; // vnum = vnum;
}
break;
case 1:
if (killer == ch)
return;
token2 = get_eq_char(killer, WEAR_HOLD);
token4 = create_object(get_obj_index(OVPKT4), 0);
if (!IS_NPC(ch)
&& token2 != NULL && token2->pIndexData->vnum == OVPKT2) {
sprintf(buf, token4->short_descr, killer->name, ch->name);
free_string(token4->short_descr);
token4->short_descr = str_dup(buf);
sprintf(buf, token4->description, killer->name, ch->name);
free_string(token4->description);
token4->description = str_dup(buf);
sprintf(buf, token4->name, killer->name, ch->name);
free_string(token4->name);
token4->name = str_dup(buf);
obj_from_char(token2);
extract_obj(token2);
obj_to_char(token4, killer);
DAZE_STATE(killer, 17 + (5 * PULSE_VIOLENCE));
} else if ( !IS_NPC( ch ) ) {
vnum = OVPKT1;
} else {
vnum = OBJ_VNUM_BLOOD;
}
break;
case 2:
if (killer == ch)
return;
if ( !IS_NPC( ch ) ) {
vnum = OVPKT1;
} else {
vnum = OBJ_VNUM_BLOOD;
}
break;
case 3:
if (killer == ch)
return;
token2 = get_eq_char(killer, WEAR_HOLD);
token4 = create_object(get_obj_index(OVPKT4), 0);
if (!IS_NPC(ch)
&& token2 != NULL && token2->pIndexData->vnum == OVPKT2) {
sprintf(buf, token4->short_descr, killer->name, ch->name);
free_string(token4->short_descr);
token4->short_descr = str_dup(buf);
sprintf(buf, token4->description, killer->name, ch->name);
free_string(token4->description);
token4->description = str_dup(buf);
sprintf(buf, token4->name, killer->name, ch->name);
free_string(token4->name);
token4->name = str_dup(buf);
obj_from_char(token2);
extract_obj(token2);
obj_to_char(token4, killer);
DAZE_STATE(killer, 17 + (5 * PULSE_VIOLENCE));
} else if ( !IS_NPC( ch ) ) {
vnum = OVPKT2;
} else {
vnum = OBJ_VNUM_BLOOD;
}
break;
case 4:
if (killer == ch)
return;
token2 = get_eq_char(killer, WEAR_HOLD);
token4 = get_eq_char(killer, WEAR_NECK_1);
token5 = create_object(get_obj_index(OVPKT5), 0);
if (!IS_NPC(ch)
&& token2 != NULL
&& token2->pIndexData->vnum == OVPKT2
&& token4 != NULL && token4->pIndexData->vnum == OVPKT4) {
obj_from_char(token2);
extract_obj(token2);
obj_to_char(token5, killer);
DAZE_STATE(killer, 24 + (5 * PULSE_VIOLENCE));
} else if ( !IS_NPC( ch ) ) {
vnum = OVPKT1;
} else {
vnum = OBJ_VNUM_BLOOD;
}
break;
case 5:
if (killer == ch)
return;
if ( !IS_NPC( ch ) ) {
vnum = OVPKT1;
} else {
vnum = OBJ_VNUM_BLOOD;
}
break;
case 6:
if (killer == ch)
return;
token2 = get_eq_char(killer, WEAR_HOLD);
token4 = get_eq_char(killer, WEAR_NECK_1);
token5 = create_object(get_obj_index(OVPKT5), 0);
if (!IS_NPC(ch)
&& token2 != NULL
&& token2->pIndexData->vnum == OVPKT2
&& token4 != NULL && token4->pIndexData->vnum == OVPKT4) {
obj_from_char(token2);
extract_obj(token2);
obj_to_char(token5, killer);
DAZE_STATE(killer, 24 + (5 * PULSE_VIOLENCE));
} else if ( !IS_NPC( ch ) ) {
vnum = OVPKT2;
} else {
vnum = OBJ_VNUM_BLOOD;
}
break;
case 7:
if (killer == ch)
return;
if ( !IS_NPC( ch ) ) {
vnum = OVPKT2;
} else {
vnum = OBJ_VNUM_BLOOD;
}
break;
case 8:
if (killer == ch)
return;
token2 = get_eq_char(killer, WEAR_HOLD);
token4 = get_eq_char(killer, WEAR_NECK_1);
token5 = create_object(get_obj_index(OVPKT5), 0);
if (!IS_NPC(ch)
&& token2 != NULL
&& token2->pIndexData->vnum == OVPKT2
&& token4 != NULL && token4->pIndexData->vnum == OVPKT4) {
obj_from_char(token2);
extract_obj(token2);
obj_to_char(token5, killer);
DAZE_STATE(killer, 24 + (5 * PULSE_VIOLENCE));
} else if ( !IS_NPC( ch ) ) {
vnum = OVPKT2;
} else {
vnum = OBJ_VNUM_BLOOD;
}
break;
case 9:
if (killer == ch)
return;
token2 = get_eq_char(killer, WEAR_HOLD);
token3 = create_object(get_obj_index(OVPKT3), 0);
if (!IS_NPC(ch)
&& token2 != NULL && token2->pIndexData->vnum == OVPKT2) {
obj_from_char(token2);
extract_obj(token2);
obj_to_char(token3, killer);
do_wear(killer, "token");
DAZE_STATE(killer, 12 + (5 * PULSE_VIOLENCE));
} else {
vnum = OBJ_VNUM_BLOOD;
}
break;
case 10:
if (killer == ch)
return;
token2 = get_eq_char(killer, WEAR_HOLD);
token4 = create_object(get_obj_index(OVPKT4), 0);
if (!IS_NPC(ch)
&& token2 != NULL && token2->pIndexData->vnum == OVPKT2) {
sprintf(buf, token4->short_descr, killer->name, ch->name);
free_string(token4->short_descr);
token4->short_descr = str_dup(buf);
sprintf(buf, token4->description, killer->name, ch->name);
free_string(token4->description);
token4->description = str_dShowing the first 100 KB of 203.3 KB. Download the archive for the full file.