fight.c
exodus2/src/fight.c · 386.9 KB
From the archive exodus2.tar.gz
Download the archive « Back to the archive contents
#include <sys/types.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <ctype.h>
#include <unistd.h>
#include "merc.h"
#include "interp.h"
#include "clans/new_clans.h"
#include "clans/new_clans_comm.h"
#include "clans/new_clans_io.h"
#include "clans/new_clans_util.h"
#include "obj_trig.h"
extern struct clan_type clan_table[MAX_CLAN];
extern char *color_table[];
extern char const *dir_name[];
extern bool half;
extern bool quad;
extern bool doub;
extern bool battle_royale;
extern bool killed_by_chain; //A lousy fix for a mob chaining itself to death
extern bool ignore_hitroll; //Used to test hitroll affects
extern bool ignore_ac;
extern bool new_ac;
bool no_check_skeletal=FALSE;
bool missed_attack = FALSE;
// Iblis 1/05/04 for Necromancers
void feign_death args((CHAR_DATA* ch, char* argument));
void feed_death args((CHAR_DATA* victim, CHAR_DATA* killer));
void check_skeletal_mutation args((CHAR_DATA* ch, bool on_round));
bool check_clasp args((CHAR_DATA *ch));
bool damage2 args((CHAR_DATA * ch, CHAR_DATA * victim, int dam, int dt, int dam_type, bool show));
bool damage_old2 args((CHAR_DATA * ch, CHAR_DATA * victim, int dam, int dt, int dam_type, bool show));
void stun_char args((CHAR_DATA *ch, CHAR_DATA *victim));
void reset_race args((CHAR_DATA* ch));
void death_spasms args((CHAR_DATA *ch));
void switched_return args((CHAR_DATA *mob, ROOM_INDEX_DATA *location));
CHAR_DATA *get_gravity_char_room args((ROOM_INDEX_DATA *rid));
bool equip_char_slot_new args((CHAR_DATA * ch, OBJ_DATA * obj, long slot));
void larva_hit args((CHAR_DATA *ch,CHAR_DATA *victim));
//IBLIS 6/20/03 - Needed for Battle Royale;
CHAR_DATA *br_leader = NULL;
CHAR_DATA *last_br_kill = NULL;
CHAR_DATA *last_br_victim = NULL;
int last_br_points = 0;
bool is_tail_attack=FALSE; // Cheap fix for Nerix's tail attacks
//Iblis 11/15/03 - Used to prevent critical strike on
// weapon FLAG hits
bool crit_strike_possible = TRUE;
extern short br_death_counter;
extern short battle_royale_dead_amount;
bool nodam_message = FALSE;
extern AREA_DATA *area_first;
extern const sh_int movement_loss[SECT_MAX];
// Variable, holding the status of the safe-nopk flag
// Morgan on June 29. 2000
extern bool safe_nopk;
extern bool make_backup;
extern bool isorder;
int realxp;
#define MAX_DAMAGE_MESSAGE 45
//external function
bool can_move_char_door
args ((CHAR_DATA * ch, int door, bool follow, bool show_messages));
int wall_damage args ((CHAR_DATA * ch, OBJ_DATA * wall));
void display_track args ((CHAR_DATA * ch));
AGGRESSOR_LIST *new_aggressor args ((void));
void free_aggressor_list args ((AGGRESSOR_LIST * b));
void superduel_ends args((CHAR_DATA *winner, CHAR_DATA *loser));
void pk_chan args((char* text));
long int level_cost args ((int level));
void group_gain_exp args ((CHAR_DATA * ch, int gain));
long int low_gain_exp args ((CHAR_DATA * ch, int gain));
void check_assist args ((CHAR_DATA * ch, CHAR_DATA * victim));
bool check_dodge args ((CHAR_DATA * ch, CHAR_DATA * victim));
bool check_eldritch_miasma 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, bool not_mob_killer));
bool group_gain args ((CHAR_DATA * ch, CHAR_DATA * victim));
int align_compute args ((CHAR_DATA * gch, CHAR_DATA * victim));
bool is_safe args ((CHAR_DATA * ch, CHAR_DATA * victim));
void make_corpse args ((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 disarm args ((CHAR_DATA * ch, CHAR_DATA * victim));
void clan_leader args ((CHAR_DATA * ch, char *argument));
int check_entangle args ((CHAR_DATA * ch));
void do_murder args ((CHAR_DATA * ch, char *argument));
void clan_defect args ((CHAR_DATA * ch));
bool check_flicker args((CHAR_DATA * ch, CHAR_DATA * victim));
//IBLIS 5/30/03 - calculate and returns xp including bonuses for act,imm,res,dam,ac
long add_xp_bonuses args ((long xp, CHAR_DATA * victim));
void save_player_corpse args((OBJ_DATA * pObj));
//IBLIS 5/31/03 - monk's dirty tactic functions
void do_eyegouge args ((CHAR_DATA * ch, CHAR_DATA * victim));
void do_dirtytrip args ((CHAR_DATA * ch, CHAR_DATA * victim));
//IBLIS 5/31/03 - monk's functions
bool check_block args ((CHAR_DATA * ch, CHAR_DATA * victim));
void counter_attack args ((CHAR_DATA * ch, CHAR_DATA * victim));
void do_feign args ((CHAR_DATA * ch, char *argument));
void do_dive args ((CHAR_DATA * ch, char *argument));
void prevent_escape args ((CHAR_DATA * ch, CHAR_DATA * victim));
bool awareness args ((CHAR_DATA * victim, CHAR_DATA * ch));
bool hear_the_wind
args ((CHAR_DATA * victim, CHAR_DATA * ch, OBJ_DATA * obj));
bool insta_kill
args ((CHAR_DATA * ch, CHAR_DATA * victim, int dam, int dt, int dam_type,
bool show, bool magic));
void calculate_br_points args ((CHAR_DATA * ch, CHAR_DATA * victim));
bool IS_AGGRESSOR args ((CHAR_DATA * ch, CHAR_DATA * victim));
void update_aggressor args ((CHAR_DATA * ch, CHAR_DATA * victim));
void update_aggressor2 args((CHAR_DATA * ch, CHAR_DATA * victim, bool show_messages));
void remove_aggressor args ((CHAR_DATA * ch, CHAR_DATA * victim));
void decrease_level args ((CHAR_DATA * ch));
OBJ_DATA *get_obj_vnum_char args((CHAR_DATA* ch, int vnum));
int adjust_damage args((int dam_to_do));
//Iblis 10/19/03 - Needed for Kalian corpse eating bonuses
void spell_giant_strength args((int sn, int level, CHAR_DATA * ch, void *vo, int target));
void spell_aqua_breathe args((int sn, int level, CHAR_DATA * ch, void *vo, int target));
void spell_pass_door args((int sn, int level, CHAR_DATA * ch, void *vo, int target));
void spell_haste args((int sn, int level, CHAR_DATA * ch, void *vo, int target));
void prayer_sanctuary args((int sn, int level, CHAR_DATA * ch, void *vo, int target));
void prayer_frenzy args((int sn, int level, CHAR_DATA * ch, void *vo, int target));
void spell_fireshield args((int sn, int level, CHAR_DATA * ch, void *vo, int target));
void spell_heal args((int sn, int level, CHAR_DATA * ch, void *vo, int target));
void spell_plague args((int sn, int level, CHAR_DATA * ch, void *vo, int target));
void spell_bark_skin args((int sn, int level, CHAR_DATA * ch, void *vo, int target));
void spell_protection_evil args((int sn, int level, CHAR_DATA * ch, void *vo, int target));
void spell_protection_good args((int sn, int level, CHAR_DATA * ch, void *vo, int target));
void set_wanted (CHAR_DATA * ch)
{
if (ch->class == PC_CLASS_CHAOS_JESTER)
return;
if (!IS_SET (ch->act, PLR_WANTED) && !IS_IMMORTAL (ch))
{
send_to_char ("*** You are now WANTED.\n\r", ch);
SET_BIT (ch->act, PLR_WANTED);
wiznet ("$N has become wanted.", ch, NULL, WIZ_PENALTIES, 0, 0);
if (ch->times_wanted < 65)
{
ch->times_wanted++;
ch->want_jail_time = 11 + (5 * ch->times_wanted) - ch->times_wanted;
}
else
ch->want_jail_time = 999999;
}
}
void unjail (CHAR_DATA * ch)
{
char tcbuf[15];
remove_wanted (ch);
REMOVE_BIT (ch->comm, COMM_NOCHANNELS);
if (IS_IMMORTAL (ch))
REMOVE_BIT (ch->comm, COMM_NOWIZ);
if (ch->in_room->vnum < 4255 || ch->in_room->vnum > 4266)
return;
send_to_char
("A prison guard enters and drags you gruffly into the guard room.\n\r",
ch);
act ("A prison guard enters and drags $n gruffly into the guard room.",
ch, NULL, NULL, TO_ROOM);
wiznet ("$N has been released from jail.", ch, NULL, WIZ_PENALTIES, 0, 0);
char_from_room (ch);
char_to_room (ch, get_room_index (4023));
trip_triggers(ch, OBJ_TRIG_ENTER_ROOM, NULL, NULL, OT_SPEC_NONE);
trap_check(ch,"room",ch->in_room,NULL);
sprintf(tcbuf,"%d",ch->in_room->vnum);
trip_triggers_arg(ch, OBJ_TRIG_CHAR_TO_ROOM, NULL, NULL, OT_SPEC_NONE,tcbuf);
check_aggression(ch);
}
void arrest (CHAR_DATA * ch, CHAR_DATA * victim)
{
char buf[MAX_INPUT_LENGTH];
ROOM_INDEX_DATA *location;
//OBJ_DATA *obj, *obj_next, *pit_obj;
bool placed = FALSE;
int vnum;
if (ch->in_room != victim->in_room)
return;
act ("$n grabs $N and hauls $M off to jail.", ch, NULL, victim, TO_NOTVICT);
act ("$n grabs you and hauls you off to jail.", ch, NULL, victim, TO_VICT);
act ("You grab $N and haul $M off to jail.", ch, NULL, victim, TO_CHAR);
sprintf (buf, "%s has been arrested by $N.", victim->name);
wiznet (buf, ch, NULL, WIZ_PENALTIES, 0, 0);
char_from_room (victim);
for (vnum = ROOM_VNUM_JAIL_START; vnum < ROOM_VNUM_JAIL_END; vnum++)
{
location = get_room_index (vnum);
if (location->people == NULL)
{
char_to_room (victim, location);
placed = TRUE;
break;
}
}
if (placed == FALSE)
{
location =
get_room_index (number_range
(ROOM_VNUM_JAIL_START, ROOM_VNUM_JAIL_END));
char_to_room (victim, location);
}
/* if (victim->carrying != NULL)
{
for (pit_obj = object_list; pit_obj; pit_obj = pit_obj->next)
if (pit_obj->pIndexData->vnum == OBJ_VNUM_PIT)
break;
if (pit_obj != NULL)
{
act
("$N drops a prisoner's confiscated items into the donation box.",
pit_obj->in_room->people, NULL, ch, TO_ALL);
for (obj = victim->carrying; obj; obj = obj_next)
{
obj_next = obj->next_content;
unequip_char (victim, obj);
obj_from_char (obj);
obj_to_obj (obj, pit_obj);
}
}
}*/
if (IS_NPC (ch))
extract_char (ch, TRUE);
REMOVE_BIT (victim->act, PLR_WANTED);
SET_BIT (victim->act, PLR_JAILED);
SET_BIT (victim->comm, COMM_NOCHANNELS);
if (!IS_NPC(victim))
victim->pcdata->nochan_ticks = 0;
victim->want_jail_time =
UMAX (11 + (5 * victim->times_wanted) - victim->times_wanted, 15);
if (victim->want_jail_time > 250)
victim->want_jail_time = 250;
save_char_obj (victim);
trip_triggers(victim, OBJ_TRIG_ENTER_ROOM, NULL, NULL, OT_SPEC_NONE);
trap_check(victim,"room",victim->in_room,NULL);
sprintf(buf,"%d",victim->in_room->vnum);
trip_triggers_arg(victim, OBJ_TRIG_CHAR_TO_ROOM, NULL, NULL, OT_SPEC_NONE,buf);
check_aggression(victim);
}
void remove_wanted (CHAR_DATA * ch)
{
REMOVE_BIT (ch->act, PLR_WANTED);
REMOVE_BIT (ch->act, PLR_JAILED);
ch->want_jail_time = 0;
}
void check_saddle (CHAR_DATA * ch)
{
int chance;
if (IS_NPC (ch))
return;
if (ch->mount == NULL)
return;
if (get_eq_char (ch->mount, WEAR_ABOUT) != NULL)
return;
chance = get_skill (ch, gsn_riding) / 2 + 10;
chance += get_curr_stat (ch, STAT_DEX);
chance += ch->mount->pIndexData->defbonus;
if (number_percent () > chance)
{
char tcbuf[MAX_STRING_LENGTH];
sprintf (tcbuf,
"You lose your balance and fall precariously off of %s.\n\r",
ch->mount->short_descr);
send_to_char (tcbuf, ch);
sprintf (tcbuf,
"$n loses $s balance and falls precariously off of %s.",
ch->mount->short_descr);
act (tcbuf, ch, NULL, NULL, TO_ROOM);
ch->mount->riders = NULL;
ch->mount = NULL;
ch->position = POS_SITTING;
}
}
/*
* 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_NPC (ch) && HAS_SCRIPT (ch))
{
TRIGGER_DATA *pTrig;
for (pTrig = ch->triggers; pTrig != NULL; pTrig = pTrig->next)
{
if (pTrig->trigger_type == TRIG_COMBAT
&& pTrig->current == NULL && !IS_SET (ch->act, ACT_HALT))
{
act_trigger (ch, pTrig->name, NULL, NAME (victim), NULL);
pTrig->current = pTrig->script;
pTrig->bits = SCRIPT_ADVANCE;
}
}
}
if (IS_NPC (ch) && ch->color == 42 && ch->wait <= 0)
{
do_stand (ch, "");
if (ch->position == POS_STANDING)
ch->color = 0;
}
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);
}
return;
}
bool should_assist (CHAR_DATA * rch, CHAR_DATA * victim)
{
/* if (!IS_SET (rch->act, PLR_AUTOASSIST) || IS_NPC (rch))
{
SET_BIT (rch->act, PLR_AUTOASSIST);
rch->pcdata->autoassist_level = AASSIST_MOBS;
}|*/
// if (rch->pcdata->autoassist_level == AASSIST_PLAYERS)
// rch->pcdata->autoassist_level = AASSIST_ALL;
// Minax 12-20-02 Anyone who does not autoassist will now. Set to mobs for safety.
// Iblis 6/29/03 Fixed it so autoassist mobs was not set everytime this function was ran,
// thus overriding autoassist ALL or autoassist players.
// Iblis 6/29/03 (1.5 hours later) removed it to deal with MUCH less hassle with aggressor flags/etc
if (IS_SET(rch->act2,ACT_FAMILIAR))
return TRUE;
// Iblis 10/24/03 - Charmies no longer autoassist against players..tis only fair..
if (!IS_NPC (victim))
return FALSE;
if (IS_NPC (rch))
return TRUE;
if (IS_NPC (victim) && !(IS_SET(rch->pcdata->autoassist_level,AASSIST_NONE)))
return TRUE;
/* {
if (rch->pcdata->autoassist_level == AASSIST_MOBS ||
rch->pcdata->autoassist_level == AASSIST_ALL)
return (TRUE);
else
return (FALSE); */
/* }
else
{
if (rch->pcdata->autoassist_level == AASSIST_PLAYERS ||
rch->pcdata->autoassist_level == AASSIST_ALL)
return (TRUE);
else
return (FALSE);
}*/
return (FALSE);
}
void check_assist (CHAR_DATA * ch, CHAR_DATA * victim)
{
CHAR_DATA *rch, *rch_next;
//Iblis - 10-24-03 - Quick fix, if victim = player, no assists period
// if (!IS_NPC(victim))
// return;
for (rch = ch->in_room->people; rch != NULL; rch = rch_next)
{
rch_next = rch->next_in_room;
if (IS_AWAKE (rch) && rch->fighting == NULL)
{
/* quick check for ASSIST_PLAYER */
if (!IS_NPC (ch) && IS_NPC (rch)
&& IS_SET (rch->off_flags, ASSIST_PLAYERS)
&& rch->level + 6 > victim->level)
{
do_emote (rch, "screams and attacks!");
multi_hit (rch, victim, TYPE_UNDEFINED);
continue;
}
if (rch->riders == ch)
{
do_emote (rch, "screams and attacks!");
multi_hit (rch, victim, TYPE_UNDEFINED);
continue;
}
if (ch->race == PC_RACE_NERIX && IS_SET(rch->act,ACT_MOUNT)
&& !str_cmp(rch->afkmsg,ch->name))
{
do_emote (rch, "screams and attacks!");
multi_hit (rch, victim, TYPE_UNDEFINED);
continue;
}
if (IS_NPC(rch) && rch->pIndexData->vnum == MOB_VNUM_DARKHOUNDS
&& !str_cmp(rch->afkmsg,ch->name))
{
do_emote (rch, "screams and attacks!");
multi_hit (rch, victim, TYPE_UNDEFINED);
continue;
}
if (IS_NPC(rch) && rch->pIndexData->vnum == MOB_VNUM_VIVIFY
&& !str_cmp(rch->afkmsg,ch->name))
{
// do_emote (rch, "screams and attacks!");
multi_hit (rch, victim, TYPE_UNDEFINED);
continue;
}
if ((rch->group != 0 && (rch->group == ch->group)) ||
(is_same_group (ch, rch) && !IS_NPC(ch) && ch->pcdata->familiar == rch))
{
do_emote (rch, "screams and attacks!");
multi_hit (rch, victim, TYPE_UNDEFINED);
continue;
}
// if (!IS_NPC(victim))
// continue;
/* PCs next */
if ((!IS_NPC (ch) || IS_AFFECTED (ch, AFF_CHARM)))
{
if (((!IS_NPC (rch) && should_assist (rch, victim))
|| IS_AFFECTED (rch, AFF_CHARM) || (!IS_NPC(ch) && ch->pcdata->familiar == rch))
&& is_same_group (ch, rch) && !is_safe (rch, victim) && IS_NPC(victim))
multi_hit (rch, victim, TYPE_AUTOASSIST);
continue;
}
if (IS_NPC (rch) && IS_NPC(ch) &&
IS_SET(rch->off_flags,ASSIST_EXACT_ALIGN) && rch->alignment == ch->alignment)
{
do_emote (rch, "screams and attacks!");
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) && IS_SET(rch->off_flags,ASSIST_EXACT_ALIGN) &&
rch->alignment == ch->alignment)
|| (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))
{
if (is_same_group (vch, victim)
&& number_range (0, number) == 0)
{
target = vch;
number++;
}
}
else
{
if (number_percent () <
get_skill (rch, gsn_blindfighting))
{
if (is_same_group (vch, victim)
&& number_range (0, number) == 0)
{
target = vch;
number++;
}
check_improve (ch, gsn_blindfighting, TRUE, 2);
}
else
check_improve (ch, gsn_blindfighting, FALSE, 2);
}
}
if (target != NULL)
{
do_emote (rch, "screams and attacks!");
multi_hit (rch, target, TYPE_UNDEFINED);
}
}
}
}
}
}
inline bool leads_group (CHAR_DATA * ch)
{
CHAR_DATA *gch;
for (gch = char_list; gch; gch = gch->next)
{
if (IS_NPC (gch))
continue;
if (gch->leader == ch)
return (TRUE);
}
return (FALSE);
}
//IBLIS 5/20/03 - Changed leadership to make it a lot better
inline int adjust_hitroll (CHAR_DATA * ch)
{
int hr_adj = 0, charisma;
CHAR_DATA *leader = NULL;
if ((leader = ch->leader) == NULL)
{
leader = ch;
if (!leads_group (leader))
return (0);
}
if (number_percent () < get_skill (leader, gsn_leadership))
{
hr_adj = leader->level / 10 + (leader->level == 90 ? 3 : 0);
}
charisma = get_curr_stat (leader, STAT_CHA);
if (charisma < 16)
hr_adj -= 2;
else if (charisma < 20);
else if (charisma < 23)
hr_adj += 1;
else if (charisma < 25)
hr_adj += 2;
else
hr_adj += 3;
if (hr_adj > 0)
{
check_improve (leader, gsn_leadership, TRUE, 6);
if (!ignore_hitroll)
return (hr_adj);
else return 0;
}
else
{
check_improve (leader, gsn_leadership, FALSE, 6);
return (0);
}
}
inline int adjust_damroll (CHAR_DATA * ch)
{
int dm_adj = 0, charisma;
CHAR_DATA *leader = NULL;
if ((leader = ch->leader) == NULL)
{
leader = ch;
if (!leads_group (leader))
return (0);
}
if (number_percent () < get_skill (leader, gsn_leadership))
{
dm_adj = leader->level / 10 + (leader->level == 90 ? 3 : 0);
}
charisma = get_curr_stat (leader, STAT_CHA);
if (charisma < 16)
dm_adj -= 2;
else if (charisma < 20);
else if (charisma < 23)
dm_adj += 1;
else if (charisma < 25)
dm_adj += 2;
else
dm_adj += 3;
if (dm_adj > 0)
return (dm_adj);
else
return (0);
}
inline int get_hitroll2 (CHAR_DATA * ch)
{
int hroll = 0;
hroll = get_hitroll(ch);
// hroll = (ch)->hitroll + str_app[get_curr_stat (ch, STAT_STR)].tohit;
if (!IS_NPC (ch))
if (ch->mount != NULL)
hroll += ch->mount->pIndexData->attackbonus;
if (!ignore_hitroll)
return (hroll);
else return 0;
}
/*
* Do one group of attacks.
*/
void multi_hit (CHAR_DATA * ch, CHAR_DATA * victim, int dt)
{
int chance;
char buf[20];
OBJ_DATA *weapon_obj;
if (ch == victim && IS_NPC (ch))
return;
if (IS_SET(ch->act2, ACT_ILLUSION) || IS_SET(victim->act2, ACT_ILLUSION) || IS_SET(victim->act2, ACT_NO_KILL)
|| IS_SET(ch->act2, ACT_NO_KILL))
{
return;
}
if (IS_SET (ch->in_room->room_flags, ROOM_SAFE))
{
send_to_char ("This room is safe from bullies like you.\n\r", ch);
stop_fighting (ch, TRUE);
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;
}
if (ch->stunned > 0)
{
ch->stunned--;
return;
}
//Iblis 10/02/04
if (IS_SET(ch->act2,ACT_WARPED))
{
long res_flag1=0,res_flag2=0;
int i=0;
//Makes sure an added resistance doesn't overright a vuln/imm
//Also makes sure they don't have every flag set, so we only check up to 25 times
for (i=0; i < 25;++i)
{
res_flag1 = 1<<number_range(1,25);
if ((ch->vuln_flags & res_flag1) || (ch->imm_flags & res_flag1))
continue;
break;
}
if (i >= 25)
res_flag1 = 0;
for (i=0; i < 25;++i)
{
res_flag2 = 1<<number_range(1,25);
if ((ch->vuln_flags & res_flag1) || (ch->imm_flags & res_flag1))
continue;
break;
}
if (i >= 25)
res_flag2 = 0;
ch->dam_type = number_range(1,MAX_DAMAGE_MESSAGE);
ch->res_flags = (res_flag1 + res_flag2 + race_table[ch->race].res);
}
chance = get_skill (ch, gsn_stun);
if (number_percent() < chance*.03)
{
stun_char(ch,victim);
}
if (ch->race == PC_RACE_SWARM)
{
if (damage(ch, victim, ch->hit - dice(1,20), gsn_likobe, DAM_NEGATIVE, FALSE))
{
act("The swarm feeds on $N!",ch,NULL,victim,TO_CHAR);
send_to_char("`bThe black cloud of flies is eating you alive!``\n\r",victim);
act("$N swings at the buzzing swarm of flies as it consumes $m!",ch,NULL,victim,TO_VICT);
if (number_percent() <= 3 && !saves_spell (ch->level / 2, victim, DAM_POISON))
{
AFFECT_DATA af;
send_to_char
("You feel poison coursing through your veins.", victim);
act ("$n is poisoned by the venom of the swarm.", victim, NULL,
NULL, TO_ROOM);
af.where = TO_AFFECTS;
af.type = gsn_poison;
af.level = ch->level * 3 / 4;
af.duration = ch->level / 4;
af.location = APPLY_STR;
af.modifier = -1;
af.bitvector = AFF_POISON;
af.permaff = FALSE;
af.composition = FALSE;
af.comp_name = str_dup (ch->name);
affect_join (victim, &af);
}
}
else
{
act("The swarm attempts to feed on $N, but it does no good!",ch,NULL,victim,TO_CHAR);
send_to_char("`bThe black cloud of flies flies can't seem to hurt you!``\n\r",victim);
act("$N swings at the buzzing swarm of flies annoying $m!",ch,NULL,victim,TO_VICT);
}
return;
}
one_hit (ch, victim, dt);
if (ch->fighting != victim)
return;
if (dt == gsn_throwing)
return;
if (IS_AFFECTED (ch, AFF_HASTE))
one_hit (ch, victim, dt);
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);
check_improve (ch, gsn_second_attack, TRUE, 5);
if (ch->fighting != victim)
return;
}
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;
}
//Iblis 10/31/03 - Extra attack for Kalians at night
if (ch->race == PC_RACE_KALIAN && (time_info.hour < 5 || time_info.hour >= 19))
{
one_hit (ch, victim, dt);
if (ch->fighting != victim)
return;
}
//Iblis 2/18/04 - Extra attack for Nidaes in the water
if (ch->race == PC_RACE_NIDAE && ch->in_room
&& (ch->in_room->sector_type == SECT_UNDERWATER
|| ch->in_room->sector_type == SECT_WATER_OCEAN))
{
one_hit (ch, victim, dt);
if (ch->fighting != victim)
return;
}
trip_triggers(ch, OBJ_TRIG_CHANCE_ON_ROUND, NULL, victim, OT_SPEC_NONE);
//This is just so the innards checking of this doesn't happen very often
if (ch->class == PC_CLASS_CHAOS_JESTER)
{
int chance = get_skill(ch,gsn_death_spasms);
if (is_affected(ch,gsn_death_spasms))
{
if (ch->hit >= ch->max_hit*.20)
{
send_to_char("You feel weaker.\n\r",ch);
affect_strip(ch,gsn_death_spasms);
}
}
else
{
if (ch->hit <= ch->max_hit *.10*(chance/100.0))
death_spasms(ch);
}
}
check_skeletal_mutation(ch, TRUE);
if (ch->fighting == NULL)
return;
if (ch->max_hit > 0)
{
sprintf(buf, "%d", (ch->hit * 100 / ch->max_hit));
trip_triggers_arg(ch, OBJ_TRIG_CHAR_HP_PCT, NULL, victim, OT_SPEC_NONE, buf);
}
if (victim->max_hit > 0)
{
sprintf(buf, "%d", (victim->hit * 100 / victim->max_hit));
trip_triggers_arg(ch, OBJ_TRIG_VICT_HP_PCT, NULL, victim, OT_SPEC_NONE, buf);
}
if (ch->max_mana > 0)
{
sprintf(buf, "%d", (ch->mana * 100 / ch->max_mana));
trip_triggers_arg(ch, OBJ_TRIG_MANA_PCT, NULL, victim, OT_SPEC_NONE, buf);
}
if (ch->max_move > 0)
{
sprintf(buf, "%d", (ch->move * 100 / ch->max_move));
trip_triggers_arg(ch, OBJ_TRIG_MOVE_PCT, NULL, victim, OT_SPEC_NONE, buf);
}
chance = get_skill (ch, gsn_dirty_tactics) / 20.0;
if (IS_AFFECTED (ch, AFF_SLOW))
chance /= 2;
if (number_percent () < chance /*&& !IS_NPC (ch)*/)
{
chance = number_percent ();
if (chance < 20)
do_dirtytrip (ch, victim);
else if (chance < 30)
do_eyegouge (ch, victim);
//Choose stomp or headbutt IN damage
else
damage (ch, victim,
50 * (get_skill (ch, gsn_dirty_tactics) / 100.0),
gsn_dirty_tactics, DAM_BASH, TRUE);
check_improve (ch, gsn_dirty_tactics, TRUE, 6);
if (ch->fighting != victim)
return;
}
chance = get_skill (ch, gsn_dual_wield);
if (is_class_tiers(ch,PC_CLASS_MONK,1) || ch->race == PC_RACE_NERIX)
chance = 100;
if (ch->race == PC_RACE_NERIX && get_eq_char (ch, WEAR_HOLD))
chance = 0;
weapon_obj = get_eq_char (ch, WEAR_WIELD_R);
if (weapon_obj == NULL)
weapon_obj = get_eq_char (ch, WEAR_WIELD_L);
if (weapon_obj != NULL)
if (IS_SET (weapon_obj->value[4], WEAPON_TWO_HANDS) && (ch->race != PC_RACE_VROATH))
return;
if (weapon_obj != NULL && get_eq_char (ch, WEAR_SHIELD) != NULL
&& !(IS_CLASS (ch, PC_CLASS_MONK)))
return;
if (number_percent () < chance)
{
one_dual_hit (ch, victim, dt);
if (!IS_CLASS (ch, PC_CLASS_MONK) && ch->race != PC_RACE_NERIX)
check_improve (ch, gsn_dual_wield, TRUE, 8);
if (ch->fighting != victim)
return;
}
if (ch->race == PC_RACE_NERIX)
{
is_tail_attack = TRUE;
one_dual_hit (ch, victim, dt);
is_tail_attack = FALSE;
if (ch->fighting != victim)
return;
}
chance = get_skill (ch, gsn_falconry) / 10.0;
if (number_percent () < chance && !IS_NPC (ch) && IS_OUTSIDE (ch)
&& ch->pcdata->falcon_wait == 0)
{
act
("`hYour falcon swoops down and claws $N with its talons before flying off.``",
ch, NULL, victim, TO_CHAR);
act
("`h$n's falcon swoops down and claws you with its talons before flying off.``",
ch, NULL, victim, TO_VICT);
act
("`h$n's falcon swoops down and claws $N with its talons before flying off.``",
ch, NULL, victim, TO_NOTVICT);
damage (ch, victim, 50, gsn_falconry, DAM_CLAWING, FALSE);
if (ch->fighting != victim)
return;
}
if (is_affected (ch, gsn_spider_vine) && number_percent() > 50)
{
int dam;
act("`bThe vines on $n's arms come to life and tear into your flesh!``",
ch,NULL,victim,TO_VICT);
act("`bThe vines on $n's arms come to life and tear into $N's flesh!``",
ch,NULL,victim,TO_NOTVICT);
act("`bThe vines on your arms come to life and tear into $N's flesh!``",
ch,NULL,victim,TO_CHAR);
dam = dice(3,30);
damage (ch, victim, dam, 0, DAM_CLAWING, FALSE);
dam = number_range (1, dam / 5 + 1);
damage_old (ch, victim, dam, 0, DAM_NEGATIVE, FALSE);
ch->hit += dam / 2;
if (!saves_spell (ch->level / 2, victim, DAM_POISON))
{
AFFECT_DATA af;
send_to_char
("You feel poison coursing through your veins.", victim);
act ("$n is poisoned by the venom on $N's vines.", victim, NULL,
ch, TO_NOTVICT);
act ("$n is poisoned by the venom on your vines.", victim, NULL, ch, TO_CHAR);
af.where = TO_AFFECTS;
af.type = gsn_poison;
af.level = ch->level * 3 / 4;
af.duration = ch->level / 2;
af.location = APPLY_STR;
af.modifier = -1;
af.bitvector = AFF_POISON;
af.permaff = FALSE;
af.composition = FALSE;
af.comp_name = str_dup (ch->name);
affect_join (victim, &af);
}
if (ch->fighting != victim)
return;
}
if (ch->class == PC_CLASS_CHAOS_JESTER)
{
++ch->pcdata->pain_points;
if (ch->fighting && IS_NPC(ch->fighting) && ch->pcdata->pain_points > 15)
ch->pcdata->pain_points = 15;
}
if (!IS_NPC(ch) && !IS_NPC(victim) && !IS_IMMORTAL(victim) && ch->pcdata->aggression)
{
if ((60 - ch->pcdata->aggression*10) > number_percent())
{
one_dual_hit (ch, victim, dt);
if (ch->fighting != victim)
return;
}
if (ch->pcdata->aggression < 4)
++ch->pcdata->aggression;
}
return;
}
void mob_throw (CHAR_DATA * ch)
{
OBJ_DATA *obj;
for (obj = ch->carrying; obj; obj = obj->next_content)
{
if (obj->item_type != ITEM_WEAPON)
continue;
if (IS_SET (obj->value[4], WEAPON_THROWING))
{
do_throw (ch, obj->name);
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;
char buf[30];
if (ch->stunned > 0)
{
ch->stunned--;
return;
}
if (ch->race == PC_RACE_SWARM)
{
if (damage(ch, victim, ch->hit - dice(1,20), gsn_likobe, DAM_NEGATIVE, FALSE))
{
act("The swarm feeds on $N!",ch,NULL,victim,TO_CHAR);
send_to_char("`bThe black cloud of flies is eating you alive!``\n\r",victim);
act("$N swings at the buzzing swarm of flies as it consumes $m!",ch,NULL,victim,TO_VICT);
if (number_percent() <= 3 && !saves_spell (ch->level / 2, victim, DAM_POISON))
{
AFFECT_DATA af;
send_to_char
("You feel poison coursing through your veins.", victim);
act ("$n is poisoned by the venom of the swarm.", victim, NULL,
NULL, TO_ROOM);
af.where = TO_AFFECTS;
af.type = gsn_poison;
af.level = ch->level * 3 / 4;
af.duration = ch->level / 4;
af.location = APPLY_STR;
af.modifier = -1;
af.bitvector = AFF_POISON;
af.permaff = FALSE;
af.composition = FALSE;
af.comp_name = str_dup (ch->name);
affect_join (victim, &af);
}
}
else
{
act("The swarm attempts to feed on $N, but it does no good!",ch,NULL,victim,TO_CHAR);
send_to_char("`bThe black cloud of flies flies can't seem to hurt you!``\n\r",victim);
act("$N swings at the buzzing swarm of flies annoying $m!",ch,NULL,victim,TO_VICT);
}
return;
}
//Iblis 9/13/04
if (IS_SET(ch->act2,ACT_WARPED))
{
long res_flag1=0,res_flag2=0;
int i=0;
//Makes sure an added resistance doesn't overright a vuln/imm
//Also makes sure they don't have every flag set, so we only check up to 25 times
for (i=0; i < 25;++i)
{
res_flag1 = 1<<number_range(1,25);
if ((ch->vuln_flags & res_flag1) || (ch->imm_flags & res_flag1))
continue;
break;
}
if (i >= 25)
res_flag1 = 0;
for (i=0; i < 25;++i)
{
res_flag2 = 1<<number_range(1,25);
if ((ch->vuln_flags & res_flag1) || (ch->imm_flags & res_flag1))
continue;
break;
}
if (i >= 25)
res_flag2 = 0;
ch->dam_type = number_range(1,MAX_DAMAGE_MESSAGE);
ch->res_flags = (res_flag1 + res_flag2 + ch->pIndexData->res_flags);
}
if (ch->number_of_attacks > -1)
{
int i;
for (i = 0;i < ch->number_of_attacks;i++)
{
one_hit (ch, victim, dt);
if (ch->fighting != victim)
return;
}
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);
}
}
}
else
{
one_hit (ch, victim, dt);
if (ch->fighting != victim)
return;
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;
if (IS_AFFECTED (ch, AFF_SLOW) && !IS_SET (ch->off_flags, OFF_FAST))
chance /= 2;
if (number_percent () < chance)
{
one_hit (ch, victim, dt);
if (ch->fighting != victim)
return;
}
chance = get_skill (ch, gsn_third_attack) / 4;
if (IS_AFFECTED (ch, AFF_SLOW) && !IS_SET (ch->off_flags, OFF_FAST))
chance = 0;
if (number_percent () < chance)
{
one_hit (ch, victim, dt);
if (ch->fighting != victim)
return;
}
}
trip_triggers(ch, OBJ_TRIG_CHANCE_ON_ROUND, NULL, victim, OT_SPEC_NONE);
//This is just so the innards checking of this doesn't happen very often
if (ch->class == PC_CLASS_CHAOS_JESTER)
{
int chance = get_skill(ch,gsn_death_spasms);
if (is_affected(ch,gsn_death_spasms))
{
if (ch->hit >= ch->max_hit*.20)
{
send_to_char("You feel weaker.\n\r",ch);
affect_strip(ch,gsn_death_spasms);
}
}
else
{
if (ch->hit <= ch->max_hit *.10*(chance/100.0))
death_spasms(ch);
}
}
check_skeletal_mutation(ch, TRUE);
if (ch->fighting == NULL)
return;
if (ch->max_hit > 0)
{
sprintf(buf, "%d", (ch->hit * 100 / ch->max_hit));
trip_triggers_arg(ch, OBJ_TRIG_CHAR_HP_PCT, NULL, victim, OT_SPEC_NONE, buf);
}
if (victim->max_hit > 0)
{
sprintf(buf, "%d", (victim->hit * 100 / victim->max_hit));
trip_triggers_arg(ch, OBJ_TRIG_VICT_HP_PCT, NULL, victim, OT_SPEC_NONE, buf);
}
if (ch->max_mana > 0)
{
sprintf(buf, "%d", (ch->mana * 100 / ch->max_mana));
trip_triggers_arg(ch, OBJ_TRIG_MANA_PCT, NULL, victim, OT_SPEC_NONE, buf);
}
if (ch->max_move > 0)
{
sprintf(buf, "%d", (ch->move * 100 / ch->max_move));
trip_triggers_arg(ch, OBJ_TRIG_MOVE_PCT, NULL, victim, OT_SPEC_NONE, buf);
}
/* oh boy! Fun stuff! */
if (ch->wait > 0)
return;
number = number_range (0, 2);
if (number == 1 && IS_SET (ch->act, ACT_MAGE))
{
number = number_range (0,10);
switch (number)
{
case (0) : if (skill_table[skill_lookup("dispel magic")].skill_level[PC_CLASS_MAGE] <= ch->level)
interpret (ch,"cast dispel");
break;
case (1) : if (skill_table[skill_lookup("blindess")].skill_level[PC_CLASS_MAGE] <= ch->level)
interpret (ch,"cast blindness");
break;
case (2) : if (skill_table[skill_lookup("weakness")].skill_level[PC_CLASS_MAGE] <= ch->level)
interpret (ch,"cast weakness");
break;
case (3) : if (skill_table[skill_lookup("curse")].skill_level[PC_CLASS_MAGE] <= ch->level)
interpret (ch,"cast curse");
break;
case (4) : if (skill_table[skill_lookup("web")].skill_level[PC_CLASS_MAGE] <= ch->level)
interpret (ch,"cast web");
break;
case (5) : if (skill_table[skill_lookup("fireshield")].skill_level[PC_CLASS_MAGE] <= ch->level)
interpret (ch,"cast fireshield");break;
break;
case (6) : if (skill_table[skill_lookup("heat metal")].skill_level[PC_CLASS_MAGE] <= ch->level)
interpret (ch,"cast 'heat metal'");break;
case (7) :
case (8) :
case (9) :
case (10) :if (skill_table[skill_lookup("energy drain")].skill_level[PC_CLASS_MAGE] > ch->level)
{
if (number%2 == 1)
interpret (ch,"cast 'magic missle'");
else interpret (ch,"cast 'colour spray'");
}
else if (skill_table[skill_lookup("fireball")].skill_level[PC_CLASS_MAGE] > ch->level)
{
if (number%2 == 1)
interpret (ch,"cast 'colour spray'");
else interpret (ch,"cast 'energy drain'");
}
else if (skill_table[skill_lookup("acid blast")].skill_level[PC_CLASS_MAGE] > ch->level)
{
if (number%2 == 1)
interpret (ch,"cast 'energy drain'");
else interpret (ch,"cast 'acid blast'");
}
else
{
if (number%2 == 1)
interpret (ch,"cast 'acid blast'");
else interpret (ch,"cast 'firestorm'");
}
return;
}
/* { mob_cast_mage(ch,victim); return; } */ ;
}
if (number == 1 && IS_SET (ch->act2, ACT_MONK))
{
number = number_range (0, 5);
switch (number)
{
case (0) : interpret (ch, "strike");break;
case (1) : interpret (ch, "kick");break;
case (2) : interpret (ch, "whirlwind");break;
case (3) : interpret (ch, "flee");
sprintf(buf, "dive %s",victim->name);
interpret (ch,buf);
break;
case (4) : interpret (ch, "kick");break;
}
return;
}
if (number == 2 && IS_SET (ch->act2, ACT_NECROMANCER))
{
number = number_range (0, 13);
switch (number)
{
case (0) : if (skill_table[skill_lookup("nearsight")].skill_level[PC_CLASS_NECROMANCER] <= ch->level)
interpret (ch, "chant nearsight");break;
case (1) : if (skill_table[skill_lookup("pox")].skill_level[PC_CLASS_NECROMANCER] <= ch->level)
interpret (ch, "chant pox");break;
case (2) : if (skill_table[skill_lookup("jinx")].skill_level[PC_CLASS_NECROMANCER] <= ch->level)
interpret (ch, "chant jinx");break;
case (3) : if (skill_table[skill_lookup("atrophy")].skill_level[PC_CLASS_NECROMANCER] <= ch->level)
interpret (ch, "chant atrophy");break;
case (4) : if (skill_table[skill_lookup("brain blisters")].skill_level[PC_CLASS_NECROMANCER] <= ch->level)
interpret (ch, "chant 'brain blisters'");break;
case (5) : if (skill_table[skill_lookup("intoxicate")].skill_level[PC_CLASS_NECROMANCER] <= ch->level)
interpret (ch, "chant intoxicate");break;
case (6) : if (skill_table[skill_lookup("vomit")].skill_level[PC_CLASS_NECROMANCER] <= ch->level)
interpret (ch, "chant vomit");break;
case (7) : if (skill_table[skill_lookup("clasp")].skill_level[PC_CLASS_NECROMANCER] <= ch->level)
interpret (ch, "chant clasp");break;
case (8) : if (skill_table[skill_lookup("greymantle")].skill_level[PC_CLASS_NECROMANCER] <= ch->level)
interpret (ch, "chant greymantle");break;
case (9) : if (skill_table[skill_lookup("death shroud")].skill_level[PC_CLASS_NECROMANCER] <= ch->level)
interpret (ch, "chant 'death shroud'");break;
case (10) : if (skill_table[skill_lookup("drain aura")].skill_level[PC_CLASS_NECROMANCER] <= ch->level)
interpret (ch, "chant 'drain aura'");break;
case (11) : if (skill_table[skill_lookup("wind of death")].skill_level[PC_CLASS_NECROMANCER] <= ch->level)
interpret (ch, "chant 'wind of death'");break;
case (12) : if (skill_table[skill_lookup("death palm")].skill_level[PC_CLASS_NECROMANCER] <= ch->level)
interpret (ch, "chant 'death palm'");break;
case (13) : if (skill_table[skill_lookup("corrupt")].skill_level[PC_CLASS_NECROMANCER] <= ch->level)
{
CHAR_DATA *vch, *vch_next;
for (vch = ch->in_room->people; vch != NULL; vch = vch_next)
{
vch_next = vch->next_in_room;
if (!IS_AFFECTED (vch, AFF_CHARM))
continue;
if (vch->master == NULL)
continue;
if (vch->master->fighting != ch)
continue;
break;
}
if (vch != NULL)
{
char buf[MAX_STRING_LENGTH];
sprintf(buf,"corrupt %s",vch->name);
interpret(ch,buf);
}
}
break;
}
return;
}
if (number == 2 && IS_SET (ch->act, ACT_CLERIC))
{
/* { mob_cast_cleric(ch,victim); return; } */ ;
}
/* now for the skills */
number = number_range (0, 100);
if (IS_SET (ch->off_flags, OFF_TRAMPLE) && number < 20)
do_trample (ch, "");
number = number_range (0, 11);
switch (number)
{
case (0):
if (IS_SET (ch->off_flags, OFF_BASH))
interpret (ch, "bash");
break;
case (1):
if (IS_SET (ch->off_flags, OFF_BERSERK)
&& !IS_AFFECTED (ch, AFF_BERSERK))
interpret (ch, "berserk");
break;
case (2):
if (IS_SET (ch->off_flags, OFF_DISARM)
|| (get_weapon_sn (ch, WEAR_WIELD_R) != gsn_hand_to_hand
&& (IS_SET (ch->act, ACT_WARRIOR)
|| IS_SET (ch->act, ACT_THIEF))))
interpret (ch, "disarm");
break;
case (3):
if (IS_SET (ch->off_flags, OFF_KICK))
interpret (ch, "kick");
break;
case (4):
if (IS_SET (ch->off_flags, OFF_KICK_DIRT))
interpret (ch, "dirt");
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))
interpret (ch, "trip");
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))
{
interpret (ch, "backstab");
}
break;
case (9):
if (IS_SET (ch->off_flags, OFF_CHARGE))
{
interpret (ch, "charge");
}
break;
case (10):
if (IS_SET (ch->off_flags, OFF_SWEEP))
{
interpret (ch, "sweep");
}
break;
case (11):
if (IS_SET (ch->off_flags, OFF_THROWING))
mob_throw (ch);
break;
case (7):
if (IS_SET (ch->off_flags, OFF_KAI))
interpret (ch, "kai");
break;
case (5):
if (IS_SET (ch->off_flags, OFF_HELLBREATH))
interpret (ch, "hellbreath");
break;
}
}
/*
* Hit one guy once.
*/
void one_hit (CHAR_DATA * ch, CHAR_DATA * victim, int dt)
{
OBJ_DATA *wield;
int victim_ac;
int thac0;
int thac0_00;
int thac0_32;
int dam;
int diceroll;
int sn, skill;
int dam_type = DAM_BASH, wield_type;
bool result=TRUE;
missed_attack = FALSE;
sn = -1;
if (ch == victim && IS_NPC (ch) && dt != -5)
return;
if (victim == ch->mount)
{
act ("$N bucks wildly, throwing you to the ground.", ch, NULL,
victim, TO_CHAR);
act ("You buck wildly, throwing $n to the ground.", ch, NULL,
victim, TO_VICT);
act ("$N bucks wildly, throwing $n to the ground.", ch, NULL,
victim, TO_NOTVICT);
ch->mount->riders = NULL;
ch->mount = NULL;
if (!ch->bashed)
ch->position = POS_FIGHTING;
}
if ((victim == ch && dt != -5) || ch == NULL || victim == NULL)
return;
if (dt == -5)
dt = TYPE_UNDEFINED;
if (IS_NPC (ch))
wield_type = WEAR_WIELD_R;
else
{
if (ch->pcdata->primary_hand == HAND_RIGHT
|| ch->pcdata->primary_hand == HAND_AMBIDEXTROUS)
wield_type = WEAR_WIELD_R;
else
wield_type = WEAR_WIELD_L;
}
if (victim->position == POS_DEAD ||
(ch->in_room != victim->in_room && dt != gsn_throwing))
return;
wield = get_eq_char (ch, wield_type);
if (dt == TYPE_UNDEFINED || dt == gsn_whirlwind)
{
dt = TYPE_HIT;
if (wield != NULL && wield->item_type == ITEM_WEAPON)
dt += wield->value[3];
else
dt += ch->dam_type;
}
if (!IS_NPC (ch) && ch->mount != NULL)
{
if (wield != NULL)
{
if (!IS_SET (wield->value[4], WEAPON_LANCE)
&& (wield->value[0] != WEAPON_POLEARM))
{
act ("Your $p is useless while mounted.", ch, wield, NULL, TO_CHAR);
damage (ch, victim, 0, dt, dam_type, FALSE);
return;
}
}
else
{
send_to_char ("You cannot punch from your mount.\n\r", ch);
damage (ch, victim, 0, dt, dam_type, FALSE);
return;
}
}
if (victim->mount != NULL && wield == NULL && !IS_NPC (ch) && ch->race != PC_RACE_NERIX)
{
act ("You swing your arms wildly, but you fail to reach $N.", ch,
NULL, victim, TO_CHAR);
act ("$n swings $s arms wildly, but fails to reach $N.", ch, NULL,
victim, TO_NOTVICT);
act ("$n swings $s arms wildly, but fails to reach you.", ch,
NULL, victim, TO_VICT);
return;
}
if (wield && wield->item_type == ITEM_WEAPON && wield->value[0] == WEAPON_DICE)
{
wield->value[3] = number_range(1,MAX_DAMAGE_MESSAGE);
}
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
{
if ((dt - TYPE_HIT) < 0 || (dt - TYPE_HIT) > MAX_DAMAGE_MESSAGE)
{
char logbuf[MAX_STRING_LENGTH];
dam_type = DAM_BASH;
sprintf (logbuf, "DAMTYPE/attack_table error: %s", ch->name);
if (IS_NPC (ch))
sprintf (logbuf + strlen (logbuf), " (vnum: %d)",
ch->pIndexData->vnum);
log_string (logbuf);
}
else
dam_type = attack_table[dt - TYPE_HIT].damage;
}
if (dam_type == -1)
dam_type = DAM_BASH;
if (ch->race == PC_RACE_NERIX)
skill = 120;
else
{
sn = get_weapon_sn (ch, wield_type);
skill = 20 + get_weapon_skill (ch, sn);
}
if (!new_ac)
{
/*
* 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[current_class (ch)].thac0_00;
thac0_32 = class_table[current_class (ch)].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_hitroll2 (ch) + adjust_hitroll (ch)) * skill / 100;
thac0 += 5 * (100 - skill) / 100;
if (dt == gsn_backstab)
thac0 -= 10 * (100 - get_skill (ch, gsn_backstab));
else if (dt == gsn_eviscerate)
thac0 -= 10 * (100 - get_skill (ch, gsn_eviscerate));
else if (dt == gsn_throwing)
thac0 -= 7 * (100 - get_skill (ch, gsn_assassinate));
else if (dt == gsn_circle)
thac0 -= 7 * (100 - get_skill (ch, gsn_circle));
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))
{
if (number_percent () < get_skill (ch, gsn_blindfighting))
check_improve (ch, gsn_blindfighting, TRUE, 2);
else
{
check_improve (ch, gsn_blindfighting, FALSE, 2);
victim_ac -= 4;
}
}
if (victim->position < POS_FIGHTING)
victim_ac += 4;
if (victim->position < POS_RESTING)
victim_ac += 6;
if (ignore_ac)
victim_ac = 0;
/*
* The moment of excitement!
*/
while ((diceroll = number_bits (5)) >= 20);
if (diceroll == 0 || (diceroll != 19 && diceroll < thac0 - victim_ac))
{
damage (ch, victim, 0, dt, dam_type, TRUE);
if (!missed_attack || !(wield != NULL && ch->fighting == victim && IS_WEAPON_STAT (wield, WEAPON_WINDSLASH)))
{
return;
//act("A force of air slashes into $n!",victim,NULL,ch,TO_ROOM);
//act("A force of air slashes into you!",victim,NULL,ch,TO_CHAR);
//damage(ch,victim,dam/3,dt,DAM_WIND,FALSE);
}
//return;
}
}
else
{
int hitroll = get_hitroll2 (ch) + adjust_hitroll (ch);
int chance = 0,i,class;
switch (dam_type)
{
case (DAM_PIERCE):
victim_ac = GET_AC (victim, AC_PIERCE);
break;
case (DAM_BASH):
victim_ac = GET_AC (victim, AC_BASH);
break;
case (DAM_SLASH):
victim_ac = GET_AC (victim, AC_SLASH);
break;
default:
victim_ac = GET_AC (victim, AC_EXOTIC);
break;
}
if (hitroll >= 100)
chance = 50 + (hitroll-100)/20.0;
else if (hitroll > 10)
chance = 30+((hitroll-10)*(20/90.0));
else if (hitroll == 10)
chance = 30;
else if (hitroll > -20)
chance = (hitroll+20)*(30/30.0);
else chance = 1;
if (victim_ac > 500)
chance += 50;
else if (victim_ac > 0)
chance += 30+(victim_ac*(20/500.0));
else if (victim_ac == 0)
chance += 30;
else if (victim_ac > -600)
chance += 30 - (-victim_ac*(30/600.0));
else chance += 1;
for (i = 0, class=0; i<3; i++)
{
if (i==0)
class = ch->class;
else if (i==1)
class = ch->class2;
else class = ch->class3;
if (i==1 && ch->level < 31)
break;
if (i==2 && ch->level < 61)
break;
switch (class)
{
case PC_CLASS_MAGE:
case PC_CLASS_CLERIC:
case PC_CLASS_NECROMANCER:
case PC_CLASS_BARD:
default:
break;
case PC_CLASS_THIEF:
case PC_CLASS_ASSASSIN:
chance += 1; break;
case PC_CLASS_WARRIOR:
chance += 5; break;
case PC_CLASS_PALADIN:
case PC_CLASS_REAVER:
case PC_CLASS_RANGER:
case PC_CLASS_MONK:
chance += 3; break;
}
}
if (number_percent() >= chance)
{
damage (ch, victim, 0, dt, dam_type, TRUE);
if (!missed_attack || !(wield != NULL && ch->fighting == victim && IS_WEAPON_STAT (wield, WEAPON_WINDSLASH)))
{
return;
}
}
}
if (IS_NPC (ch) && (wield == NULL))
{
if (!IS_SET(ch->act2,ACT_FAMILIAR))
dam = dice (ch->damage[DICE_NUMBER], ch->damage[DICE_TYPE]);
else dam = number_range (1 + 4 * skill / 100, 2 * ch->level / 3 * skill / 100);
}
else
{
if (sn != -1)
check_improve (ch, sn, TRUE, 5);
if (wield != NULL)
{
dam = dice (wield->value[1], 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
{
if (ch->race == PC_RACE_NERIX)
{
int percent;
//Need a way to differentiate normal / tail attacks
if (is_tail_attack)
{
dam = (dice (ch->level/3 + 5,1) + 2*(ch->level/30))/ 2;
}
else
{
dam = dice (ch->level/3 + 5,1); /* Normal claw attack */
dam += 2*(ch->level/30);
if ((percent = number_percent ()) <= (skill / 8))
dam = 2 * dam + (dam * 2 * percent / 100); /* Simulated sharp claw */
}
}
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);
dam += 2 * (dam * diceroll / 300);
}
}
if (!IS_NPC(ch) && ch->class == PC_CLASS_CHAOS_JESTER)
{
dam += ch->pcdata->pain_points;
if (ch->pcdata->pain_points > 4)
{
send_to_char("Sweet pain inspires you to hit harder!\n\r",ch);
act("Pain inspires $n to hit harder.",ch,NULL,NULL,TO_ROOM);
}
}
if (get_eq_char (ch, WEAR_WIELD_R) == NULL
&& get_eq_char (ch, WEAR_WIELD_L) == NULL
&& get_skill (ch, gsn_fisticuffery) > 0)
{
diceroll = number_percent ();
if (diceroll <= get_skill (ch, gsn_fisticuffery))
{
check_improve (ch, gsn_fisticuffery, TRUE, 6);
dam += 2 * (dam * diceroll / 300);
}
}
if (!IS_AWAKE (victim))
dam *= 2;
else if (victim->position < POS_FIGHTING)
dam = dam * 3 / 2;
if (dt == gsn_uppercut || dt == gsn_strike)
{
if (victim->mount != NULL)
{
act
("You reach back to deliver a mighty blow, but your hand never makes contact with $N.",
ch, NULL, victim, TO_CHAR);
act
("$n reaches back to deliver a mighty blow, but $s hand never makes contact with $N.",
ch, NULL, victim, TO_NOTVICT);
act
("$n reaches back to deliver a mighty blow, but $s hand never makes contact with you.",
ch, NULL, victim, TO_VICT);
return;
}
dam = ch->level + (get_curr_stat (ch, STAT_STR) * number_range (1, 4));
dam = dam / 2;
dam += (get_skill (ch, gsn_hand_to_hand) / 8);
dam += (get_skill (ch, gsn_fisticuffery) / 6);
}
if (dt == gsn_backstab && wield != NULL)
{
if (wield->value[0] != 2)
dam = ((dam * 7) + (ch->level / 9)) / 3;
else
dam = ((dam * 7) + (ch->level / 7)) / 3;
}
dam += (get_damroll (ch) + adjust_damroll (ch)) * UMIN (100, skill) / 100;
if (dam <= 0)
dam = 1;
if (is_affected (victim, gsn_mirror) && dam_type != DAM_ACID
&& dam_type != DAM_ENERGY && dam_type != DAM_HOLY
&& dam_type != DAM_LIGHTNING && dam_type != DAM_FIRE
&& dam_type != DAM_COLD && dam_type != DAM_NEGATIVE
&& dam_type != DAM_MENTAL && dam_type != DAM_LIGHT
&& dam_type != DAM_CHARM && dam_type != DAM_DISEASE
&& dam_type != DAM_SOUND && dam_type != DAM_HARM)
{
if (ch->level >= (victim->level + 10) && number_percent () > 50)
{
char *attack;
char buf1[MAX_STRING_LENGTH], buf2[MAX_STRING_LENGTH];
char buf3[MAX_STRING_LENGTH];
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;
}
if (is_tail_attack)
attack = "lightning tail";
sprintf (buf1,
"$n's %s is absorbed by the magic of $N's mirror.",
attack);
sprintf (buf2,
"Your %s is absorbed by the magic of $N's mirror.",
attack);
sprintf (buf3,
"$n's %s is absorbed by the magic of your mirror.",
attack);
act (buf1, ch, NULL, victim, TO_NOTVICT);
act (buf2, ch, NULL, victim, TO_CHAR);
act (buf3, ch, NULL, victim, TO_VICT);
return;
}
victim = ch;
}
//Iblis 10/11/04 - dealing with wood/silver/iron shit
if (wield)
{
if (!str_cmp(wield->material,"wood"))
{
if (IS_SET(victim->vuln_flags,VULN_WOOD))
dam += dam*.10;
if (IS_SET(victim->res_flags,RES_WOOD))
dam -= dam*.10;
//this should generate the "Your weapon is powerless" message but this is good enough for now
if (IS_SET(victim->imm_flags,IMM_WOOD))
dam = 0;
}
else if (!str_cmp(wield->material,"silver"))
{
if (IS_SET(victim->vuln_flags,VULN_SILVER))
dam += dam*.10;
if (IS_SET(victim->res_flags,RES_SILVER))
dam -= dam*.10;
if (IS_SET(victim->imm_flags,IMM_SILVER))
dam = 0;
}
else if (!str_cmp(wield->material,"iron") || !str_cmp(wield->material,"steel"))
{
if (IS_SET(victim->vuln_flags,VULN_IRON))
dam += dam*.10;
if (IS_SET(victim->res_flags,RES_IRON))
dam -= dam*.10;
if (IS_SET(victim->imm_flags,IMM_IRON))
dam = 0;
}
}
if (!missed_attack)
{
if (dt != gsn_strike) // && dt != gsn_counter)
result = damage (ch, victim, dam, dt, dam_type, TRUE);
else
result = damage (ch, victim, dam, dt, dam_type, FALSE);
}
//Iblis 10/11/04
else
{
missed_attack = FALSE;
crit_strike_possible = FALSE;
if (wield != NULL && ch->fighting == victim && IS_WEAPON_STAT (wield, WEAPON_WINDSLASH))
{
act("A force of air slashes into $n!",victim,NULL,ch,TO_ROOM);
act("A force of air slashes into you!",victim,NULL,ch,TO_CHAR);
damage(ch,victim,dam/3,dt,DAM_WIND,FALSE);
result = FALSE;
wield = NULL;
}
}
crit_strike_possible = FALSE;
if (result && IS_NPC(ch) && ch->pIndexData->vnum == MOB_VNUM_DARKHOUNDS)
{
act("`aA darkhound returns to the underworld.``",ch,NULL,NULL,TO_ROOM);
extract_char (ch, TRUE);
return;
}
if (result && is_affected (victim, gsn_festering_boils) && number_percent() <= 3)
{
spell_plague(gsn_plague,ch->level,ch,(void *)ch,TARGET_CHAR);
}
if (result && is_affected (victim, gsn_fireshield))
if (!saves_spell (ch->level + 2, ch, DAM_FIRE))
{
damage (victim, ch, dam / 2, 0, DAM_FIRE, FALSE);
act ("$N's scorching shield of flame burns you as you attack.",
ch, NULL, victim, TO_CHAR);
act ("$n is burnt by your scorching shield of flame.", ch,
NULL, victim, TO_VICT);
}
if (ch->fighting == victim && ch->race == PC_RACE_NERIX && result)
{
dam = number_range (1, dam / 5 + 2);
if (!is_tail_attack)
{
act ("$n is struck by lightning from $N's lightning claw.", victim, NULL, ch, TO_ROOM);
act ("You are shocked by $N's lightning claw.", victim, NULL, ch, TO_CHAR);
}
else
{
act ("$n is struck by lightning from $N's lightning tail.", victim, NULL, ch, TO_ROOM);
act ("You are shocked by $N's lightning tail.", victim, NULL, ch, TO_CHAR);
}
shock_effect (victim, ch->level / 2, dam, TARGET_CHAR);
damage (ch, victim, dam, 0, DAM_LIGHTNING, FALSE);
}
crit_strike_possible = TRUE;
/* but do we have a funky weapon? */
//Iblis 6/13/04 - For Liches who have contaminated the victim
if (result && wield == NULL && ch->fighting == victim && (victim->contaminator != NULL && victim->contaminator == ch))
{
dam = number_range (1, dam / 5 + 1);
act ("Life is drawn from $n.", victim, NULL, 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);
if (!IS_CLASS (ch, PC_CLASS_REAVER))
change_alignment(ch,-1);
ch->hit += dam / 2;
}
//Iblis 9/29/04 - For Chaos Jesters with Fire Dance
if (result && wield == NULL && ch->fighting == victim && is_affected(ch,gsn_fire_dance))
{
dam = number_range (1, dam / 4 + 1);
act ("$n is burned.", victim, NULL, NULL, TO_ROOM);
act ("Your flesh is seared.", victim, NULL, NULL, TO_CHAR);
fire_effect ((void *) victim, ch->level / 2, dam, TARGET_CHAR);
damage (ch, victim, dam, 0, DAM_FIRE, FALSE);
}
if (result && wield != NULL)
{
crit_strike_possible = FALSE;
//5-11-03 Iblis - We need the old value of dam, so we don't create a new dam now
if (dam > 100)
dam = 100; //to set dam to a more reasonable value
//10/11/04 - New HOLY weapon flag
if (ch->fighting == victim && IS_WEAPON_STAT (wield, WEAPON_HOLY) && number_percent() <= 3 && !IS_WEAPON_STAT(wield,WEAPON_HOLY_ACTIVATED))
{
SET_BIT(wield->value[4],WEAPON_HOLY_ACTIVATED);
act ("$p bursts into white flames!",ch,wield,NULL,TO_ALL);
}
if (ch->fighting == victim && IS_WEAPON_STAT (wield, WEAPON_HOLY_ACTIVATED))
{
act ("$p scorches $n with holy flames!",victim,wield,NULL,TO_ROOM);
act ("$p scorches you with holy flames!",victim,wield,NULL,TO_CHAR);
damage (ch, victim, 10, 0, DAM_HOLY, FALSE);
}
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;
af.permaff = FALSE;
af.composition = FALSE;
af.comp_name = str_dup (ch->name);
affect_join (victim, &af);
}
}
if (ch->fighting == victim && (IS_WEAPON_STAT (wield, WEAPON_VAMPIRIC) || (victim->contaminator != NULL && victim->contaminator == ch)))
{
//Iblis 5-11-03 In attempting to fix the fact that vampiric does nothing
//when activated on a reaver weapon, it was determined that was because
//reaver weapons are level 0. Iverath and I decided extra flags should
//do damage based on the damage your attack does.
dam = number_range (1, dam / 5 + 1);
act ("$p draws life from $n.", victim, wield, NULL, TO_ROOM);
act ("You feel $p drawing your life away.", victim, wield,
NULL, TO_CHAR);
damage_old (ch, victim, dam, 0, DAM_NEGATIVE, FALSE);
// Minax 1-17-03 Reavers do not get alignment lowered by vampiric use
if (!IS_CLASS (ch, PC_CLASS_REAVER))
change_alignment(ch,-1);
ch->hit += dam / 2;
}
if (ch->fighting == victim && IS_OBJ_STAT (wield, ITEM_BLESS))
change_alignment(ch,1);
if (ch->fighting == victim && IS_WEAPON_STAT (wield, WEAPON_FLAMING))
{
//5-11-03 Iblis - Change the damage due to depend on the damage of the weapon
//attack instead of the weapon's level
dam = number_range (1, dam / 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))
{
//5-11-03 Iblis - Change the damage due to depend on the damage of the weapon
//attack instead of the weapon's level
dam = number_range (1, dam / 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))
{
//5-11-03 Iblis - Change the damage due to depend on the damage of the weapon
//attack instead of the weapon's level
dam = number_range (1, dam / 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);
}
if (ch->fighting == victim && IS_WEAPON_STAT (wield, WEAPON_LARVA) && number_percent() <= 10)
{
act("As $p hits you, a larva burrows into your skin.",victim,wield,NULL,TO_CHAR);
act("As $p hits $n, a larva burrows into $s skin.",victim,wield,NULL,TO_ROOM);
larva_hit(ch,victim);
}
crit_strike_possible = TRUE;
}
//Iblis 10/03/04 - dice weapon's spell hit
if (ch->fighting == victim && wield && wield->item_type == ITEM_WEAPON && wield->value[0] == WEAPON_DICE && number_percent() <= 5
&& wield->value[5] > 0 && wield->value[5] < MAX_SKILL && skill_table[wield->value[5]].name != NULL
&& skill_table[wield->value[5]].type != SKILL_NORMAL && get_skill(ch,gsn_dice) > 1)
{
(*skill_table[wield->value[5]].spell_fun) (wield->value[5], ch->level, ch, (void*)victim, TARGET_CHAR);
}
trip_triggers(ch, OBJ_TRIG_CHANCE_ON_HIT, NULL, victim, OT_SPEC_NONE);
return;
}
void
one_hit_throw (CHAR_DATA * ch, CHAR_DATA * victim, int dt, OBJ_DATA * wield)
{
int victim_ac;
int thac0;
int thac0_00;
int thac0_32;
int dam;
int diceroll;
int sn;
int dam_type = DAM_BASH;
bool result;
sn = -1;
/* just in case */
if (victim == ch || ch == NULL || victim == NULL)
return;
if (victim->position == POS_DEAD)
return;
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
{
if ((dt - TYPE_HIT) < 0 || (dt - TYPE_HIT) > MAX_DAMAGE_MESSAGE)
{
char logbuf[MAX_STRING_LENGTH];
dam_type = DAM_BASH;
sprintf (logbuf, "DAMTYPE/attack_table error: %s", ch->name);
if (IS_NPC (ch))
sprintf (logbuf + strlen (logbuf), " (vnum: %d)",
ch->pIndexData->vnum);
log_string (logbuf);
}
else
dam_type = attack_table[dt - TYPE_HIT].damage;
}
if (dam_type == -1)
dam_type = DAM_BASH;
/*
* 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[current_class (ch)].thac0_00;
thac0_32 = class_table[current_class (ch)].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_hitroll2 (ch);
thac0 += 5 * 0 / 100;
if (dt == gsn_backstab)
thac0 -= 10 * (100 - get_skill (ch, gsn_backstab));
if (dt == gsn_eviscerate)
thac0 -= 10 * (100 - get_skill (ch, gsn_eviscerate));
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))
{
if (number_percent () < get_skill (ch, gsn_blindfighting))
check_improve (ch, gsn_blindfighting, TRUE, 2);
else
{
check_improve (ch, gsn_blindfighting, FALSE, 2);
victim_ac -= 4;
}
}
if (victim->position < POS_FIGHTING)
victim_ac += 4;
if (victim->position < POS_RESTING)
victim_ac += 6;
/*
* Hit.
* Calc damage.
*/
if (IS_NPC (ch) && (wield == NULL))
dam = dice (ch->damage[DICE_NUMBER], ch->damage[DICE_TYPE]);
else
{
if (sn != -1)
check_improve (ch, sn, TRUE, 5);
if (wield != NULL)
{
dam = dice (wield->value[1], wield->value[2]);
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 ()) <= (100 / 8))
dam = 2 * dam + (dam * 2 * percent / 100);
}
}
else
{
if (ch->race == PC_RACE_NERIX)
{
int percent;
//Need a way to differentiate normal / tail attacks
if (is_tail_attack)
{
dam = (dice (ch->level/3 + 5,1) + 2*(ch->level/30))/ 4;
}
else
{
dam = dice (ch->level/3 + 5,1); /* Normal claw attack */
dam += 2*(ch->level/30);
if ((percent = number_percent ()) <= (100 / 8))
dam = 2 * dam + (dam * 2 * percent / 100); /* Simulated sharp claw */
}
}
else dam = number_range (1 + 4, 2 * ch->level / 3);
}
}
/*
* 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);
dam += 2 * (dam * diceroll / 300);
}
}
if (!IS_AWAKE (victim))
dam *= 2;
else if (victim->position < POS_FIGHTING)
dam = dam * 3 / 2;
if (dt == gsn_uppercut || dt == gsn_strike)
{
dam = ch->level + (get_curr_stat (ch, STAT_STR) * number_range (1, 4));
dam += (get_skill (ch, gsn_hand_to_hand) / 3);
}
if (dt == gsn_backstab && wield != NULL)
{
if (wield->value[0] != 2)
dam *= 2 + (ch->level / 10);
else
dam *= 2 + (ch->level / 8);
}
else if (dt == gsn_assassinate)
//Iblis 6/22/03 -changed below a bit to compensate for other asssassinate changes
dam *= 3 + (90 / 2);
else if (dt == gsn_throwing)
dam *= 2 + (ch->level / 16);
dam += get_damroll (ch) * UMIN (100, 100) / 100;
if (dam <= 0)
dam = 1;
if (dt == gsn_assassinate)
{
short counter1 = 0, denom = 0;
if (ch->class == 7 || ch->class == 2)
counter1++;
if (ch->level > 30 && (ch->class2 == 7 || ch->class2 == 2))
counter1++;
if (ch->level > 60 && (ch->class3 == 7 || ch->class3 == 2))
counter1++;
dam = dam * (counter1 / 3.0);
dam = dam * (500.0 / 950);
denom = number_range (1, 100);
if (((counter1 == 2 && denom == 46)
|| (counter1 == 3 && denom == 47))
&& !IS_IMMORTAL(ch) && check_immune (victim, dam_type) != IS_IMMUNE)
{
insta_kill (ch, victim, dam, dt, dam_type, TRUE, FALSE);
return;
}
}
//Iblis 10/03/04 - For Flick and Shuffle skill
if (wield != NULL && wield->item_type == ITEM_CARD)
{
dam = dice(wield->value[2],wield->value[3]) + wield->value[4];
dam_type = DAM_SLASH;
}
//Iblis 10/11/04 - dealing with wood/silver/iron shit
if (wield)
{
if (!str_cmp(wield->material,"wood"))
{
if (IS_SET(victim->vuln_flags,VULN_WOOD))
dam += dam*.10;
if (IS_SET(victim->res_flags,RES_WOOD))
dam -= dam*.10;
//this should generate the "Your weapon is powerless" message but this is good enough for now
if (IS_SET(victim->imm_flags,IMM_WOOD))
dam = 0;
}
else if (!str_cmp(wield->material,"silver"))
{
if (IS_SET(victim->vuln_flags,VULN_SILVER))
dam += dam*.10;
if (IS_SET(victim->res_flags,RES_SILVER))
dam -= dam*.10;
if (IS_SET(victim->imm_flags,IMM_SILVER))
dam = 0;
}
else if (!str_cmp(wield->material,"iron") || !str_cmp(wield->material,"steel"))
{
if (IS_SET(victim->vuln_flags,VULN_IRON))
dam += dam*.10;
if (IS_SET(victim->res_flags,RES_IRON))
dam -= dam*.10;
if (IS_SET(victim->imm_flags,IMM_IRON))
dam = 0;
}
}
result = damage (ch, victim, dam, dt, dam_type, TRUE);
if (is_affected (victim, gsn_mirror) && dam_type != DAM_ACID
&& dam_type != DAM_ENERGY && dam_type != DAM_HOLY
&& dam_type != DAM_LIGHTNING && dam_type != DAM_FIRE
&& dam_type != DAM_COLD && dam_type != DAM_NEGATIVE
&& dam_type != DAM_MENTAL && dam_type != DAM_LIGHT
&& dam_type != DAM_CHARM && dam_type != DAM_DISEASE
&& dam_type != DAM_SOUND && dam_type != DAM_HARM)
{
if (ch->level >= (victim->level + 10) && number_percent () > 50)
{
char *attack;
char buf1[MAX_STRING_LENGTH];
char buf2[MAX_STRING_LENGTH];
char buf3[MAX_STRING_LENGTH];
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;
}
if (is_tail_attack)
attack = "lightning tail";
sprintf (buf1,
"$n's %s is absorbed by the magic of $N's mirror.",
attack);
sprintf (buf2,
"Your %s is absorbed by the magic of $N's mirror.",
attack);
sprintf (buf3,
"$n's %s is absorbed by the magic of your mirror.",
attack);
act (buf1, ch, NULL, victim, TO_NOTVICT);
act (buf2, ch, NULL, victim, TO_CHAR);
act (buf3, ch, NULL, victim, TO_VICT);
return;
}
victim = ch;
}
//Iblis 6/13/04 - For Liches who have contaminated the victims
if (result && wield == NULL && ch->fighting == victim && (victim->contaminator != NULL && victim->contaminator == ch))
{
dam = number_range (1, dam / 5 + 1);
act ("Life is drawn from $n.", victim, NULL, 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);
if (!IS_CLASS (ch, PC_CLASS_REAVER))
change_alignment(ch,-1);
ch->hit += dam / 2;
}
//Iblis 9/29/04 - For Chaos Jesters with Fire Dance
if (result && wield == NULL && ch->fighting == victim && is_affected(ch,gsn_fire_dance))
{
dam = number_range (1, dam / 4 + 1);
act ("$n is burned.", victim, NULL, NULL, TO_ROOM);
act ("Your flesh is seared.", victim, NULL, NULL, TO_CHAR);
fire_effect ((void *) victim, ch->level / 2, dam, TARGET_CHAR);
damage (ch, victim, dam, 0, DAM_FIRE, FALSE);
}
if (result && wield != NULL && wield->item_type != ITEM_CARD)
{
crit_strike_possible = FALSE;
//5-11-03 Iblis - We need the old value of dam, so we don't create a new dam now
if (dam > 100)
dam = 100; //to set dam to a more reasonable value
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;
af.permaff = FALSE;
af.composition = FALSE;
af.comp_name = str_dup (ch->name);
affect_join (victim, &af);
}
}
if (ch->fighting == victim && (IS_WEAPON_STAT (wield, WEAPON_VAMPIRIC) || (victim->contaminator != NULL && victim->contaminator == ch)))
{
//Iblis 5-11-03 In attempting to fix the fact that vampiric does nothing
//when activated on a reaver weapon, it was determined that was because
//reaver weapons are level 0. Iverath and I decided extra flags should
//do damage based on the damage your attack does.
dam = number_range (1, dam / 5 + 1);
act ("$p draws life from $n.", victim, wield, NULL, TO_ROOM);
act ("You feel $p drawing your life away.", victim, wield,
NULL, TO_CHAR);
damage_old (ch, victim, dam, 0, DAM_NEGATIVE, FALSE);
// Minax 1-17-03 Reavers do not get alignment lowered by vampiric use
if (!IS_CLASS (ch, PC_CLASS_REAVER))
change_alignment(ch,-1);
ch->hit += dam / 2;
}
if (ch->fighting == victim && IS_OBJ_STAT (wield, ITEM_BLESS))
change_alignment(ch,1);
if (ch->fighting == victim && IS_WEAPON_STAT (wield, WEAPON_FLAMING))
{
//5-11-03 Iblis - Change the damage due to depend on the damage of the weapon
//attack instead of the weapon's level
dam = number_range (1, dam / 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))
{
//5-11-03 Iblis - Change the damage due to depend on the damage of the weapon
//attack instead of the weapon's level
dam = number_range (1, dam / 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))
{
//5-11-03 Iblis - Change the damage due to depend on the damage of the weapon
//attack instead of the weapon's level
dam = number_range (1, dam / 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);
}
if (ch->fighting == victim && IS_WEAPON_STAT (wield, WEAPON_LARVA) && number_percent() <= 10)
{
act("As $p hits you, a larva burrows into your skin.",victim,wield,NULL,TO_CHAR);
act("As $p hits $n, a larva burrows into $s skin.",victim,wield,NULL,TO_ROOM);
larva_hit(ch,victim);
}
crit_strike_possible = TRUE;
}
trip_triggers(ch, OBJ_TRIG_CHANCE_ON_HIT, NULL, victim, OT_SPEC_NONE);
return;
}
void one_dual_hit (CHAR_DATA * ch, CHAR_DATA * victim, int dt)
{
OBJ_DATA *wield;
int victim_ac;
int thac0;
int thac0_00;
int thac0_32;
int dam;
int diceroll;
int sn, skill;
int dam_type = DAM_BASH, wield_type;
bool result=TRUE;
missed_attack = FALSE;
sn = -1;
if (victim == ch->mount)
{
act ("$N bucks wildly, throwing you to the ground.", ch, NULL,
victim, TO_CHAR);
act ("You buck wildly, throwing $n to the ground.", ch, NULL,
victim, TO_VICT);
act ("$N bucks wildly, throwing $n to the ground.", ch, NULL,
victim, TO_NOTVICT);
ch->mount->riders = NULL;
ch->mount = NULL;
if (!ch->bashed)
ch->position = POS_FIGHTING;
}
if (IS_NPC (ch))
wield_type = WEAR_WIELD_L;
else
{
if (ch->pcdata->primary_hand == HAND_LEFT)
wield_type = WEAR_WIELD_R;
else
wield_type = WEAR_WIELD_L;
}
/* 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, wield_type);
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 (!IS_NPC (ch) && ch->mount != NULL)
{
if (wield != NULL)
{
if (!IS_SET (wield->value[4], WEAPON_LANCE)
&& (wield->value[0] != WEAPON_POLEARM))
{
char tcbuf[MAX_STRING_LENGTH];
sprintf (tcbuf, "Your %s is useless while mounted.\n\r",
wield->name);
send_to_char (tcbuf, ch);
damage (ch, victim, 0, dt, dam_type, FALSE);
return;
}
}
else
{
send_to_char ("You cannot punch from your mount.\n\r", ch);
damage (ch, victim, 0, dt, dam_type, FALSE);
return;
}
}
if (victim->mount != NULL && wield == NULL && !IS_NPC (ch) && ch->race != PC_RACE_NERIX)
{
act ("You swing your arms wildly, but you fail to reach $N.", ch,
NULL, victim, TO_CHAR);
act ("$n swings $s arms wildly, but fails to reach $N.", ch, NULL,
victim, TO_NOTVICT);
act ("$n swings $s arms wildly, but fails to reach you.", ch,
NULL, victim, TO_VICT);
return;
}
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;
if (ch->race == PC_RACE_NERIX)
skill = 120;
else
{
/* get the weapon skill */
sn = get_weapon_sn (ch, wield_type);
skill = 20 + get_weapon_skill (ch, sn);
}
if (!new_ac)
{
/*
* 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[current_class (ch)].thac0_00;
thac0_32 = class_table[current_class (ch)].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_hitroll2 (ch) + adjust_hitroll (ch)) * skill / 100;
thac0 += 5 * (100 - skill) / 100;
if (dt == gsn_backstab)
thac0 -= 10 * (100 - get_skill (ch, gsn_backstab));
if (dt == gsn_eviscerate)
thac0 -= 10 * (100 - get_skill (ch, gsn_eviscerate));
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))
{
if (number_percent () < get_skill (ch, gsn_blindfighting))
check_improve (ch, gsn_blindfighting, TRUE, 2);
else
{
check_improve (ch, gsn_blindfighting, FALSE, 2);
victim_ac -= 4;
}
}
if (victim->position < POS_FIGHTING)
victim_ac += 4;
if (victim->position < POS_RESTING)
victim_ac += 6;
if (ignore_ac)
victim_ac = 0;
/*
* 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);
if (!(wield != NULL && ch->fighting == victim && IS_WEAPON_STAT (wield, WEAPON_WINDSLASH)))
return;
}
}
else
{
int hitroll = get_hitroll2 (ch) + adjust_hitroll (ch);
int chance=0,i,class;
switch (dam_type)
{
case (DAM_PIERCE):
victim_ac = GET_AC (victim, AC_PIERCE);
break;
case (DAM_BASH):
victim_ac = GET_AC (victim, AC_BASH);
break;
case (DAM_SLASH):
victim_ac = GET_AC (victim, AC_SLASH);
break;
default:
victim_ac = GET_AC (victim, AC_EXOTIC);
break;
}
if (hitroll >= 100)
chance = 50 + (hitroll-100)/20.0;
else if (hitroll > 10)
chance = 30+((hitroll-10)*(20/90.0));
else if (hitroll == 10)
chance = 30;
else if (hitroll > -20)
chance = (hitroll+20)*(30/30.0);
else chance = 1;
if (victim_ac > 500)
chance += 50;
else if (victim_ac > 0)
chance += 30+(victim_ac*(20/500.0));
else if (victim_ac == 0)
chance += 30;
else if (victim_ac > -600)
chance += 30 - (-victim_ac*(30/600.0));
else chance += 1;
for (i = 0,class=0;i<3;i++)
{
if (i==0)
class = ch->class;
else if (i==1)
class = ch->class2;
else class = ch->class3;
if (i==1 && ch->level < 31)
break;
if (i==2 && ch->level < 61)
break;
switch (class)
{
case PC_CLASS_MAGE:
case PC_CLASS_CLERIC:
case PC_CLASS_NECROMANCER:
case PC_CLASS_BARD:
default:
break;
case PC_CLASS_THIEF:
case PC_CLASS_ASSASSIN:
chance += 1;break;
case PC_CLASS_WARRIOR:
chance += 5;break;
case PC_CLASS_PALADIN:
case PC_CLASS_REAVER:
case PC_CLASS_RANGER:
case PC_CLASS_MONK:
chance += 3;break;
}
}
if (number_percent() >= chance)
{
damage (ch, victim, 0, dt, dam_type, TRUE);
if (!(wield != NULL && ch->fighting == victim && IS_WEAPON_STAT (wield, WEAPON_WINDSLASH)))
return;
}
}
/*
* Hit.
* Calc damage.
*/
if (IS_NPC (ch) && (wield == NULL))
dam = dice (ch->damage[DICE_NUMBER], ch->damage[DICE_TYPE]);
else
{
if (sn != -1)
check_improve (ch, sn, TRUE, 5);
if (wield != NULL)
{
dam = dice (wield->value[1], 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
{
if (ch->race == PC_RACE_NERIX)
{
int percent;
//Need a way to differentiate normal / tail attacks
if (is_tail_attack)
{
dam = (dice (ch->level/3 + 5,1) + 2*(ch->level/30))/ 4;
}
else
{
dam = dice (ch->level/3 + 5,1); /* Normal claw attack */
dam += 2*(ch->level/30);
if ((percent = number_percent ()) <= (skill / 8))
dam = 2 * dam + (dam * 2 * percent / 100); /* Simulated sharp claw */
}
}
else dam = number_range (1 + 4 * skill / 100, 2 * ch->level / 3 * skill / 100);
}
}
if (!IS_AWAKE (victim))
dam *= 2;
else if (victim->position < POS_FIGHTING)
dam = dam * 3 / 2;
dam += (get_damroll (ch) + adjust_damroll (ch)) * UMIN (100, skill) / 100;
if (dam <= 0)
dam = 1;
//Iblis 10/11/04 - dealing with wood/silver/iron shit
if (wield)
{
if (!str_cmp(wield->material,"wood"))
{
if (IS_SET(victim->vuln_flags,VULN_WOOD))
dam += dam*.10;
if (IS_SET(victim->res_flags,RES_WOOD))
dam -= dam*.10;
//this should generate the "Your weapon is powerless" message but this is good enough for now
if (IS_SET(victim->imm_flags,IMM_WOOD))
dam = 0;
}
else if (!str_cmp(wield->material,"silver"))
{
if (IS_SET(victim->vuln_flags,VULN_SILVER))
dam += dam*.10;
if (IS_SET(victim->res_flags,RES_SILVER))
dam -= dam*.10;
if (IS_SET(victim->imm_flags,IMM_SILVER))
dam = 0;
}
else if (!str_cmp(wield->material,"iron") || !str_cmp(wield->material,"steel"))
{
if (IS_SET(victim->vuln_flags,VULN_IRON))
dam += dam*.10;
if (IS_SET(victim->res_flags,RES_IRON))
dam -= dam*.10;
if (IS_SET(victim->imm_flags,IMM_IRON))
dam = 0;
}
}
if (!missed_attack)
result = damage (ch, victim, dam, dt, dam_type, TRUE);
else
{
crit_strike_possible = FALSE;
missed_attack = FALSE;
if (wield != NULL && ch->fighting == victim && IS_WEAPON_STAT (wield, WEAPON_WINDSLASH))
{
act("A force of air slashes into $n!",victim,NULL,ch,TO_ROOM);
act("A force of air slashes into you!",victim,NULL,ch,TO_CHAR);
damage(ch,victim,dam/3,dt,DAM_WIND,FALSE);
result = FALSE;
wield = NULL;
}
}
if (is_affected (victim, gsn_mirror) && dam_type != DAM_ACID
&& dam_type != DAM_ENERGY && dam_type != DAM_HOLY
&& dam_type != DAM_LIGHTNING && dam_type != DAM_FIRE
&& dam_type != DAM_COLD && dam_type != DAM_NEGATIVE
&& dam_type != DAM_MENTAL && dam_type != DAM_LIGHT
&& dam_type != DAM_CHARM && dam_type != DAM_DISEASE
&& dam_type != DAM_SOUND && dam_type != DAM_HARM)
{
if (ch->level >= (victim->level + 10) && number_percent () > 50)
{
char *attack;
char buf1[MAX_STRING_LENGTH];
char buf2[MAX_STRING_LENGTH];
char buf3[MAX_STRING_LENGTH];
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;
}
if (is_tail_attack)
attack = "lightning tail";
sprintf (buf1,
"$n's %s is absorbed by the magic of $N's mirror.",
attack);
sprintf (buf2,
"Your %s is absorbed by the magic of $N's mirror.",
attack);
sprintf (buf3,
"$n's %s is absorbed by the magic of your mirror.",
attack);
act (buf1, ch, NULL, victim, TO_NOTVICT);
act (buf2, ch, NULL, victim, TO_CHAR);
act (buf3, ch, NULL, victim, TO_VICT);
return;
}
victim = ch;
}
crit_strike_possible = FALSE;
if (result && is_affected (victim, gsn_fireshield))
if (!saves_spell (ch->level + 2, ch, DAM_FIRE))
{
damage (victim, ch, dam / 2, 0, DAM_FIRE, FALSE);
act ("$N's scorching shield of flame burns you as you attack.",
ch, NULL, victim, TO_CHAR);
act ("$n is burnt by your scorching shield of flame.", ch,
NULL, victim, TO_VICT);
}
if (ch->fighting == victim && ch->race == PC_RACE_NERIX && result)
{
dam = number_range (1, dam / 5 + 2);
if (!is_tail_attack)
{
act ("$n is struck by lightning from $N's lightning claw.", victim, NULL, ch, TO_ROOM);
act ("You are shocked by $N's lightning claw.", victim, NULL, ch, TO_CHAR);
}
else
{
act ("$n is struck by lightning from $N's lightning tail.", victim, NULL, ch, TO_ROOM);
act ("You are shocked by $N's lightning tail.", victim, NULL, ch, TO_CHAR);
}
shock_effect (victim, ch->level / 2, dam, TARGET_CHAR);
damage (ch, victim, dam, 0, DAM_LIGHTNING, FALSE);
}
crit_strike_possible = TRUE;
/* but do we have a funky weapon? */
//Iblis 6/13/04 - For Liches who have contaminated the victim
if (result && wield == NULL && ch->fighting == victim && (victim->contaminator != NULL && victim->contaminator == ch))
{
dam = number_range (1, dam / 5 + 1);
act ("Life is drawn from $n.", victim, NULL, 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);
if (!IS_CLASS (ch, PC_CLASS_REAVER))
change_alignment(ch,-1);
ch->hit += dam / 2;
}
//Iblis 9/29/04 - For Chaos Jesters with Fire Dance
if (result && wield == NULL && ch->fighting == victim && is_affected(ch,gsn_fire_dance))
{
dam = number_range (1, dam / 4 + 1);
act ("$n is burned.", victim, NULL, NULL, TO_ROOM);
act ("Your flesh is seared.", victim, NULL, NULL, TO_CHAR);
fire_effect ((void *) victim, ch->level / 2, dam, TARGET_CHAR);
damage (ch, victim, dam, 0, DAM_FIRE, FALSE);
}
if (result && wield != NULL)
{
crit_strike_possible = FALSE;
//5-11-03 Iblis - We need the old value of dam, so we don't create a new dam now
if (dam > 100)
dam = 100; //to set dam to a more reasonable value
//10/11/04 - New HOLY weapon flag
if (ch->fighting == victim && IS_WEAPON_STAT (wield, WEAPON_HOLY) && number_percent() <= 3 && !IS_WEAPON_STAT(wield,WEAPON_HOLY_ACTIVATED))
{
SET_BIT(wield->value[4],WEAPON_HOLY_ACTIVATED);
act ("$p bursts into white flames!",ch,wield,NULL,TO_ALL);
}
if (ch->fighting == victim && IS_WEAPON_STAT (wield, WEAPON_HOLY_ACTIVATED))
{
act ("$p scorches $n with holy flames!",victim,wield,NULL,TO_ROOM);
act ("$p scorches you with holy flames!",victim,wield,NULL,TO_CHAR);
damage (ch, victim, 10, 0, DAM_HOLY, FALSE);
}
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;
af.permaff = FALSE;
af.composition = FALSE;
af.comp_name = str_dup (ch->name);
affect_join (victim, &af);
}
}
if (ch->fighting == victim && (IS_WEAPON_STAT (wield, WEAPON_VAMPIRIC) || (victim->contaminator != NULL && victim->contaminator == ch)))
{
//Iblis 5-11-03 In attempting to fix the fact that vampiric does nothing
//when activated on a reaver weapon, it was determined that was because
//reaver weapons are level 0. Iverath and I decided extra flags should
//do damage based on the damage your attack does.
dam = number_range (1, dam / 5 + 1);
act ("$p draws life from $n.", victim, wield, NULL, TO_ROOM);
act ("You feel $p drawing your life away.", victim, wield,
NULL, TO_CHAR);
damage_old (ch, victim, dam, 0, DAM_NEGATIVE, FALSE);
// Minax 1-17-03 Reavers do not get alignment lowered by vampiric use
if (!IS_CLASS (ch, PC_CLASS_REAVER))
change_alignment(ch,-1);
ch->hit += dam / 2;
}
if (ch->fighting == victim && IS_OBJ_STAT (wield, ITEM_BLESS))
change_alignment(ch,1);
if (ch->fighting == victim && IS_WEAPON_STAT (wield, WEAPON_FLAMING))
{
//5-11-03 Iblis - Change the damage due to depend on the damage of the weapon
//attack instead of the weapon's level
dam = number_range (1, dam / 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))
{
//5-11-03 Iblis - Change the damage due to depend on the damage of the weapon
//attack instead of the weapon's level
dam = number_range (1, dam / 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))
{
//5-11-03 Iblis - Change the damage due to depend on the damage of the weapon
//attack instead of the weapon's level
dam = number_range (1, dam / 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);
}
if (ch->fighting == victim && IS_WEAPON_STAT (wield, WEAPON_LARVA) && number_percent() <= 10)
{
act("As $p hits you, a larva burrows into your skin.",victim,wield,NULL,TO_CHAR);
act("As $p hits $n, a larva burrows into $s skin.",victim,wield,NULL,TO_ROOM);
larva_hit(ch,victim);
}
crit_strike_possible = TRUE;
}
trip_triggers(ch, OBJ_TRIG_CHANCE_ON_HIT, NULL, victim, OT_SPEC_NONE);
return;
}
//Iblis 1/09/04 - Intercept function for the soul link spell
bool damage (CHAR_DATA * ch, CHAR_DATA * victim, int dam, int dt, int dam_type, bool show)
{
if (victim->race == PC_RACE_SWARM)
{
if (victim->level > ch->level+50)
dam = dice(1,2);
else dam = dice(5,3);
if (dam_type == DAM_FIRE)
{
dam *= 2;
dam_type = DAM_UNIQUE; //So that vuln fire won't come into affect
}
}
return damage2(ch,victim,dam,dt,dam_type,show);
}
/*
* Inflict damage from a hit.
*/
bool
damage2 (CHAR_DATA * ch, CHAR_DATA * victim, int dam, int dt, int dam_type,
bool show)
{
bool mirror_attack = FALSE;
OBJ_DATA *corpse;
bool immune;
CHAR_DATA *tch=NULL, *anothertch=NULL;
missed_attack = FALSE;
if (victim->position == POS_DEAD)
return FALSE;
if (ch != victim && ch != NULL && victim != NULL)
{
if (!IS_NPC (ch))
ch->pcdata->last_fight = time (NULL);
if (!IS_NPC (victim))
victim->pcdata->last_fight = time (NULL);
}
if (dam > 12000000 && dt >= TYPE_HIT)
{
dam = 12000000;
if (!IS_IMMORTAL (ch))
{
OBJ_DATA *obj;
obj = get_eq_char (ch, WEAR_WIELD_R);
send_to_char ("You really shouldn't cheat.\n\r", ch);
if (obj != NULL)
extract_obj (obj);
obj = get_eq_char (ch, WEAR_WIELD_L);
if (obj != NULL)
extract_obj (obj);
}
}
//Iblis 1/13/04 Paladins do 2x damage to all undead
if (dt != gsn_soul_link)
{
if (ch->class == 6 && IS_SET(victim->act,ACT_UNDEAD))
dam *= 2;
if ((dam_type == DAM_NEGATIVE || dam_type == DAM_DISEASE || dam_type == DAM_POISON)
&& is_affected(victim,gsn_death_shroud))
{
dam *= 2;
}
//Iblis 9/29/04 - Dwarves do more and take less damage underground
if (ch->race == PC_RACE_DWARF && ch->in_room && ch->in_room->sector_type == SECT_UNDERGROUND)
{
dam += .2*dam;
}
if (victim->race == PC_RACE_DWARF && victim->in_room && victim->in_room->sector_type == SECT_UNDERGROUND)
{
dam -= .2*dam;
}
//Iblis 10/26/04 - Vuln Cold mobs/players take 10% more damage in snow/ice rooms
if (IS_SET(ch->vuln_flags,VULN_COLD) && (IS_SET(victim->in_room->room_flags,ROOM_SNOW)
|| IS_SET(victim->in_room->room_flags,ROOM_ICE)))
dam += .1*dam;
//Iblis 9/28/04 - Wind damage does 3x to flying people
// if (dam_type == DAM_WIND && IS_SET(victim->affected_by,AFF_FLYING))
// dam *= 3;
//Iblis 9/28/04 - Chaos Jesters take 1/3 less damage from ACT_WARPED mobs
if (IS_SET(ch->act2,ACT_WARPED) && !IS_NPC(victim) && victim->class == PC_CLASS_CHAOS_JESTER)
dam = (dam / 3.0) * 2;
//Iblis 9/29/04 - Not act warped mobs/players get 2 times damage in warped rooms
if (victim->in_room && IS_SET(victim->in_room->room_flags2,ROOM_WARPED) && !IS_SET(victim->act2,ACT_WARPED))
dam *= 2;
//Iblis 1/17/04 Litans get 2x damage if in water
if (victim->race == PC_RACE_LITAN && victim->in_room &&
(victim->in_room->sector_type == SECT_WATER_SWIM
|| victim->in_room->sector_type == SECT_WATER_NOSWIM
|| victim->in_room->sector_type == SECT_WATER_OCEAN
|| victim->in_room->sector_type == SECT_SWAMP
|| victim->in_room->sector_type == SECT_UNDERWATER))
dam *= 2;
if ((dt != gsn_exorcism) && (dt != gsn_hellscape) && !(ch->class == PC_CLASS_REAVER && dt==1000+DAM_SLASH))
{
if (dam > 35)
dam = (dam - 35) / 2 + 35;
if (dam > 80)
dam = (dam - 80) / 2 + Showing the first 100 KB of 386.9 KB. Download the archive for the full file.