fight.cpp
fight.cpp · 271.4 KB
From the archive wotl-src.zip
Download the archive « Back to the archive contents
/**************************************************************************/
// fight.cpp -
/***************************************************************************
* The Dawn of Time v1.69r (c)1997-2004 Michael Garratt *
* >> A number of people have contributed to the Dawn codebase, with the *
* majority of code written by Michael Garratt - www.dawnoftime.org *
* >> To use this source code, you must fully comply with all the licenses *
* in licenses.txt... In particular, you may not remove this copyright *
* notice. *
***************************************************************************
* >> Original Diku Mud copyright (c)1990, 1991 by Sebastian Hammer, *
* Michael Seifert, Hans Henrik St{rfeldt, Tom Madsen, & Katja Nyboe. *
* >> Merc Diku Mud improvements copyright (C) 1992, 1993 by Michael *
* Chastain, Michael Quan, and Mitchell Tse. *
* >> ROM 2.4 is copyright 1993-1995 Russ Taylor and 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) *
* >> Oblivion 1.2 is copyright 1996 Wes Wagner *
**************************************************************************/
#include "include.h" // dawn standard includes
#include "clan.h"
#include "duel.h"
#include "ictime.h"
#include "msp.h"
#define MAX_DAMAGE_MESSAGE 48
DECLARE_OSPEC_FUN( ospec_chameleon_mark );
void hunt_victim args( (char_data *ch)); // Ixliam
void weapon_effects( char_data *ch, char_data *victim, obj_data *wield);
/* command procedures needed */
DECLARE_DO_FUN(do_backstab );
DECLARE_DO_FUN(do_pbackstab );
DECLARE_DO_FUN(do_circle );
DECLARE_DO_FUN(do_emote );
DECLARE_DO_FUN(do_berserk );
DECLARE_DO_FUN(do_bash );
DECLARE_DO_FUN(do_trip );
DECLARE_DO_FUN(do_dirt );
DECLARE_DO_FUN(do_flee );
DECLARE_DO_FUN(do_kick );
DECLARE_DO_FUN(do_disarm );
DECLARE_DO_FUN(do_get );
DECLARE_DO_FUN(do_recall );
DECLARE_DO_FUN(do_yell );
DECLARE_DO_FUN(do_gore ); // Kerenos
DECLARE_DO_FUN(do_disarm_trap );
DECLARE_DO_FUN(do_visible );
DECLARE_SPEC_FUN( spec_cast_mage );
DECLARE_SPEC_FUN( spec_cast_cleric );
DECLARE_DO_FUN(do_wolfreturn ); // Ixliam
DECLARE_DO_FUN(do_look);
DECLARE_DO_FUN(do_startprison ); // Ixliam
DECLARE_DO_FUN(do_gaze ); // Ixliam
DECLARE_DO_FUN(do_crush ); // Ixliam
DECLARE_OSPEC_FUN( ospec_quicksilver_orb );
DECLARE_OSPEC_FUN( ospec_soulscream_shield );
OBJ_DATA *random_object args(( int level )); // Random Objects
char *get_weapontype(OBJ_DATA *obj);
void landchar( char_data *ch);
int group_max_level_attacking_victim(char_data *killer, char_data *victim );
void group_bypass_killer_penatly(char_data *killer, char_data *victim, bool death);
void pkill_note_required_message(char_data *ch, char_data *victim, bool bypass_duel_used);
bool can_join_combat( char_data *attacker, char_data *victim);
int switch_update(char_data *ch);
int get_age(char_data *ch);
bool race_can_wear (char_data *ch, OBJ_DATA *obj);
char * const death_cry_dir_name[]=
{
"the north", "the east", "the south", "the west", "above", "below",
"the northeast", "the southeast", "the southwest", "the northwest"
};
const struct flag_type corpse_dam_renames[] =
{
{"pristine", DAM_NONE, true},
{"battered ", DAM_BASH, true},
{"gouged ", DAM_PIERCE, true},
{"tattered ", DAM_SLASH, true},
{"burnt ", DAM_FIRE, true},
{"frozen ", DAM_COLD, true},
{"blackened ", DAM_LIGHTNING, true},
{"liquified ", DAM_ACID, true},
{"sickly ", DAM_POISON, true},
{"twisted ", DAM_NEGATIVE, true},
{"pristine ", DAM_HOLY, true},
{"charred ", DAM_ENERGY, true},
{"clenched", DAM_MENTAL, true},
{"pox-ridden ", DAM_DISEASE, true},
{"bloated ", DAM_DROWNING, true},
{"charred ", DAM_LIGHT, true},
{"pristine", DAM_OTHER, true},
{"rigid ", DAM_HARM, true},
{"pristine", DAM_CHARM, true},
{"battered ", DAM_SOUND, true},
{"pristine", DAM_ILLUSION, true},
{ NULL, 0, 0}
};
/*
* Local functions.
*/
OBJ_DATA *shape_corpse args((char_data *ch, obj_data *obj));
void pkill_autonote args(( char_data *ch, char_data *victim ));
void check_assist args(( char_data *ch, char_data *victim ));
bool check_dodge args(( char_data *ch, char_data *victim ));
bool check_parry args(( char_data *ch, char_data *victim ));
bool check_shield_block args(( char_data *ch, char_data *victim ));
bool check_spinblock 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 is_safe args(( char_data *ch, char_data *victim ));
void make_corpse args(( char_data *ch, char *killer ));
void one_hit args(( char_data *ch, char_data *victim, int dt, bool second ));
void two_hit args(( char_data *ch, char_data *victim, int dt, bool second ));
void mob_hit args(( char_data *ch, char_data *victim, int dt ));
void set_fighting args(( char_data *ch, char_data *victim ));
void disarm args(( char_data *ch, char_data *victim ));
void entangle args(( char_data *ch, char_data *victim ));
void mount args(( char_data *, char_data * ));
void dismount args(( char_data * ));
void show_list_to_char args(( OBJ_DATA *list, char_data *ch, char * filter,
bool fShort, bool fShowNothing ));
void make_blood args(( char_data *ch ));
/**************************************************************************/
// lame way to do this, but it was in the oblivion code and I
// can't be bothered changing it cause the code is only called
// when a pkill happens - it was originally put in update_handler() with
// ran everytime violence_update() was called!!!
void check_death_update(void)
{
char buf[MSL];
char_data *victim;
char_data *next_player;
for ( victim = player_list; victim; victim = next_player )
{
next_player=victim->next_player;
if(victim->pcdata->karns<0)
{
flush_char_outbuffer(victim);
victim->printf(
"You have been pkilled when you had no karns. The system is if you\r\n"
"are pkilled you lose a karn, if you are pkilled when you have no karns\r\n"
"the death is considered permanent.\r\n"
"Please keep in mind that it is bad RP to discuss this unless you think\r\n"
"it was a OOC pkill. If you consider it ooc please note it to admin\r\n"
"we will see what we can do about it.\r\n");
flush_char_outbuffer(victim);
logf( "PERMDEATH: Closing link to %s.", victim->name);
char subject[MIL];
sprintf(subject,"`RPERMDEATH:`W %s!`x", victim->name);
autonote(NOTE_INOTE, "Your friendly neighbourhood pkill system",
subject, "imm", "Subject says it all.", true);
flush_char_outbuffer(victim);
autonote(NOTE_PKNOTE, "Your friendly neighbourhood pkill system",
subject, "imm", "Subject says it all.", true);
char filenamebuf[MIL];
strcpy(filenamebuf, pfilename(victim->name, victim->pcdata->pfiletype));
// disconnect them
extract_char(victim,true);
connection_close(victim->desc);
// move them to the dead directory
sprintf(buf,"mv %s %s &", filenamebuf, DEAD_DIR);
logf("Systeming: '%s'", buf);
system(buf);
}
}
}
/**************************************************************************/
/*
* 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; ch = ch_next )
{
ch_next = ch->next;
/*
* Hunting mobs.
*/
if ( IS_NPC(ch) && ch->fighting == NULL
&& !IS_SET(ch->act, ACT_NO_HUNT)
&& IS_AWAKE(ch) && ch->mobmemory != NULL )
{
hunt_victim(ch);
continue;
}
if ( ( victim = ch->fighting ) == NULL || ch->in_room == NULL )
continue;
// do a room check
if( ch->in_room!=ch->fighting->in_room){
bug("violence_update(): ch->in_room != ch->fighting->in_room");
stop_fighting(ch,false);
continue;
}
if(ch->is_stunned)
{
ch->is_stunned-=1;
if(ch->is_stunned<=0)
{
ch->position=POS_RESTING;
ch->is_stunned=0;
ch->println("You are no longer stunned.");
}
}
obj_data *wpn;
if((wpn = get_eq_char(ch, WEAR_WIELD)) != NULL
&& wpn->ospec_fun == ospec_lookup("ospec_quicksilver_orb"))
ospec_quicksilver_orb(wpn, ch);
if ( IS_AWAKE(ch) && ch->in_room == victim->in_room ){
multi_hit( ch, victim, TYPE_UNDEFINED );
REMOVE_BIT(victim->dyn2, DYN2_DOING_ORBIT);
}else{
stop_fighting( ch, false ); // Violence_update - not awake/diff room
}
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 );
if ((number_percent() >= 85) && (IS_NPC(ch)) && (!is_affected(ch,AFF_CHARM)))
switch_update(ch);
}
}
return;
}
/**************************************************************************/
int get_sublevels_for_level(int level);
// Called when a player/mob victim is killed:
// - victim position should be POS_DEAD when called
// - handles the loss of karns, and reseting of karn countdowns
// loss of xp when dieing
// - records mobkills, pkills, pkdefeat, pkools
// - does NOT handle pknorecall, pksafe
// - autolooting
// - autonoting pkills
// - mob death trigger
void kill_char(char_data *victim, char_data *ch)
{
if(victim->position != POS_DEAD ){
bug("kill_char(): victim->position != POS_DEAD ");
return;
}
if(!IS_VALID(ch)){
bugf("kill_char(): ch (%d) is not valid!", ch->vnum());
}
ROOM_INDEX_DATA *deathroom;
if(ch->in_room){
deathroom=ch->in_room;
}else if(victim->in_room){
deathroom=victim->in_room;
bug("kill_char(): ch->in_room==NULL, setting it to victim->in_room");
ch->in_room=victim->in_room;
}else{
bugf("kill_char(): Couldn't find DEATHROOM!!!... setting it to limbo.");
deathroom=get_room_index(ROOM_VNUM_LIMBO);
assertp(deathroom);
}
group_gain( ch, victim );
// record mob kill values
if (!IS_NPC(ch) && IS_NPC(victim)){
ch->pcdata->mkills++;
}else if (IS_NPC(ch) && !IS_NPC(victim)){
victim->pcdata->mdefeats++;
}
if ( !IS_NPC(victim) )
{
if ( class_table[ch->clss].class_cast_type == CCT_BARD )
{
ch->songp = 0;
ch->songn = 0;
}
OBJ_DATA *token;
if ( ( ( token = get_obj_token( victim, "10395")) != NULL) && victim->pcdata->karns>=0)
{
obj_from_char (token);
extract_obj (token);
victim->println("You avoid your own death and suddenly vanish!");
ch->printlnf("%s avoids death at your hands and vanishes!", victim->name);
victim->position = POS_RESTING;
char_from_room(victim);
char_to_room(victim, get_room_index(3));
victim->hit = victim->max_hit;
do_look(victim, "auto");
return;
}
/************** ARREST **************************************************/
if (IS_SET(victim->act2, ACT2_UNDERARREST)
&& IS_AFFECTED2(ch, AFF2_BOUNTYHUNTER)
&& !IS_AWAKE(victim) && IS_NPC(ch))
{
victim->pknorecall = 0;
victim->pknoquit = 0;
act( "$n is placed in shackles and has been arrested.", victim, NULL, NULL, TO_ROOM );
victim->println("You have been arrested and taken to prison.");
stop_fighting( victim, true); // Damage - subdued
victim->position=POS_RESTING;
victim->hit=1;
if(victim->pcdata->theft > 0 && victim->pcdata->murder == 0)
info_broadcast(ch, "%s has been arrested by the guards for ROBBERY.", victim->name);
if(victim->pcdata->theft == 0 && victim->pcdata->murder > 0)
info_broadcast(ch, "%s has been arrested by the guards for MURDER.", victim->name);
if(victim->pcdata->theft > 0 && victim->pcdata->murder > 0)
info_broadcast(ch, "%s has been arrested by the guards for ROBBERY & MURDER.", victim->name);
REMOVE_BIT(victim->act2, ACT2_UNDERARREST);
sprintf( log_buf, "%s arrested by %s at %d", victim->name,
(IS_NPC(ch) ? ch->short_descr : ch->name),
ch->in_room->vnum );
log_string( log_buf );
wiznet(log_buf,NULL,NULL,WIZ_BETA,0,0);
if(victim->pcdata->murder > 3 && victim->pcdata->murder < 50)
victim->pcdata->murder = victim->pcdata->murder / 3;
if(victim->pcdata->theft > 3)
victim->pcdata->theft = victim->pcdata->theft / 3;
if (victim->pcdata->theft == 0 && victim->pcdata->murder == 0
&& IS_WEREBEAST(victim))
{
info_broadcast(ch, "%s has been arrested by the guards for LYCANTHROPY.", victim->name);
victim->pcdata->murder = 1;
}
do_startprison(victim, "");
return;
}
if (IS_SET(victim->act2, ACT2_UNDERARREST)
&& IS_AFFECTED2(ch, AFF2_BOUNTYHUNTER)
&& !IS_AWAKE(victim))
{
ch->pknorecall = 5;
ch->pknoquit = 5;
victim->pknorecall = 0;
victim->pknoquit = 0;
act( "$n is placed in shackles and has been arrested.", victim, NULL, NULL, TO_ROOM );
victim->println("You have been arrested and taken to prison.");
stop_fighting( victim, true); // Damage - subdued
stop_fighting( ch, true); // Damage - subdued
group_gain( ch, victim );
victim->subdued= true;
victim->subdued_timer = number_range(5,10);
victim->position=POS_RESTING;
victim->hit=1;
int bounty;
bounty= (victim->pcdata->theft + victim->pcdata->murder) * 50;
if(bounty > 500)
bounty = 500;
ch->printlnf("`#`YYou receive a bounty of %d gold.`^", bounty);
ch->gold += bounty;
if(victim->pcdata->theft > 0 && victim->pcdata->murder == 0)
info_broadcast(ch, "%s has been arrested for ROBBERY.", victim->name);
if(victim->pcdata->theft == 0 && victim->pcdata->murder > 0)
info_broadcast(ch, "%s has been arrested for MURDER.", victim->name);
if(victim->pcdata->theft > 0 && victim->pcdata->murder > 0)
info_broadcast(ch, "%s has been arrested for ROBBERY & MURDER.", victim->name);
REMOVE_BIT(victim->act2, ACT2_UNDERARREST);
sprintf( log_buf, "%s arrested by %s at %d",
victim->name,
(IS_NPC(ch) ? ch->short_descr : ch->name),
ch->in_room->vnum );
log_string( log_buf );
wiznet(log_buf,NULL,NULL,WIZ_BETA,0,0);
do_startprison(victim, "");
return;
}
/****************************************************************/
if (IS_NPC(ch)){ // mob killed player
sprintf( log_buf, "%s mkilled by %s at %d (kill_char())",
victim->name,
ch->short_descr,
deathroom->vnum);
// send the info
info_broadcast(victim, "%s has been toasted by %s.", victim->name, ch->short_descr);
if(ch->race == race_lookup("vampire")
&& !IS_VAMPIRE(victim) && victim->clan<0
&& !IS_WEREBEAST(victim)
&& victim->race != race_lookup("kender")
&& victim->race != race_lookup("avian")
&& victim->race != race_lookup("dragon")
&& victim->race != race_lookup("cambion")
&& victim->race != race_lookup("changeling")
&& victim->race != race_lookup("cyclops")
&& victim->race != race_lookup("goblin")
&& victim->race != race_lookup("gnoll")
&& victim->race != race_lookup("faerie")
&& victim->race != race_lookup("troll")
&& victim->race != race_lookup("centaur")
&& victim->race != race_lookup("draconian")
&& victim->race != race_lookup("minotaur")
&& victim->race != race_lookup("thri-kreen")
&& victim->race != race_lookup("demon")
&& victim->race != race_lookup("lich")
&& victim->race != race_lookup("angel")
&& class_table[victim->clss].class_cast_type != CCT_BARD
&& victim->race != race_lookup("golem"))
{
SET_BIT(victim->affected_by2, AFF2_VAMP_BITE);
victim->alliance = -3;
victim->println("`RYou will arise from your death as a vampire.`x");
int vclan = number_range(0,7);
switch(vclan)
{
case (0) :
SET_BIT(victim->vampire, VAM_BRUJAH);
break;
case (1) :
SET_BIT(victim->vampire, VAM_ASSAMITE);
break;
case (2) :
SET_BIT(victim->vampire, VAM_CAPPADOCIAN);
break;
case (3) :
SET_BIT(victim->vampire, VAM_GANGREL);
break;
case (4) :
SET_BIT(victim->vampire, VAM_MALKAVIAN);
break;
case (5) :
SET_BIT(victim->vampire, VAM_TOREADOR);
break;
case (6) :
SET_BIT(victim->vampire, VAM_TREMERE);
break;
case (7) :
SET_BIT(victim->vampire, VAM_VENTRUE);
break;
}
victim->vampgen = 13;
victim->bloodpool = 2;
}
// Log mobkills
{
char mklogbuf[MSL];
sprintf( mklogbuf, "%s mkilled by %s at %d (kill_char())",
victim->name,
ch->short_descr,
deathroom->vnum);
append_datetime_ch_to_file( ch, MKILL_LOGFILE, mklogbuf);
}
}else{ // player killed player
sprintf( log_buf, "%s pkilled by %s at %d (kill_char())",
victim->name,
ch->name,
deathroom->vnum);
// send the info
info_broadcast(victim, "%s has been toasted by %s!", victim->name, ch->name);
}
log_string( log_buf );
// ch didn't start the fight so they dont get the pkills on them
// reducing their max karns
if(ch->pkool>0 && victim->level<5)
{
ch->pkkills--;
}
if(victim->level<11 && !IS_LETGAINED(victim) && GAMESETTING_LETGAINING_IS_REQUIRED){
if(!GAMESETTING5(GAMESET5_DEDICATED_PKILL_STYLE_MUD)){
ch->pkool+=4000;
}
}
// pk system
if(ch!=victim && !IS_NPC(ch) && !IS_NPC(victim))
{
ch->pkkills+=1;
victim->pkdefeats+=1;
if(!GAMESETTING5(GAMESET5_DEDICATED_PKILL_STYLE_MUD)){
// new pk karn system
if(group_max_level_attacking_victim(ch, victim)<=victim->level+10)
{
OBJ_DATA *wrist1 = get_eq_char(victim, WEAR_WRIST_L);
OBJ_DATA *wrist2 = get_eq_char(victim, WEAR_WRIST_R);
if (wrist1!=NULL && wrist1->pIndexData->vnum==5097)
{
act( "$n's $p dissolves as it absorbs a violent death.", victim, wrist1, NULL, TO_ROOM );
act( "Your $p dissolves as it absorbs a violent death. You keep a karn!", victim, wrist1, NULL, TO_CHAR );
extract_obj(wrist1);
}
else
if (wrist2!=NULL && wrist2->pIndexData->vnum==5097)
{
act( "$n's $p dissolves as it absorbs a violent death.", victim, wrist2, NULL, TO_ROOM );
act( "Your $p dissolves as it absorbs a violent death. You keep a karn!", victim, wrist2, NULL, TO_CHAR );
extract_obj(wrist2);
}else
{
victim->pcdata->karns--;
if(GAMESETTING(GAMESET_NOPERMDEATH) && victim->pcdata->karns<0){
victim->pcdata->karns=0;
}
if(victim->pcdata->karns) // if they actually lost a karn
{
victim->println(
"From within your body you feel a surge of energy,\r\n"
"a ball of light departs from your body and disappears!");
}
}
}
group_bypass_killer_penatly(ch, victim, true);
if(GAMESETTING3(GAMESET3_KILLER_SYSTEM_ENABLED)
&& !IS_SET(victim->dyn, DYN_STARTED_FIGHT))
{
// mark the attackers as killers if the victim didn't start the fight
char_data *gch;
for ( gch = ch->in_room->people; gch; gch = gch->next_in_room )
{
if ( !IS_NPC(gch) && gch->fighting==victim && is_same_group( gch, ch))
{
if(!IS_KILLER(gch)){
ch->println( "*** You are now tagged as a KILLER!! ***");
}
gch->pcdata->killer_until=current_time+ (60*game_settings->killer_system_tagged_duration);
save_char_obj( gch );
}
}
}
// reduce the victims killer timer
if(IS_KILLER(victim)){
victim->pcdata->killer_until-=
(60*game_settings->killer_system_death_reduction_duration);
if(!IS_KILLER(victim)){
victim->pcdata->killer_until=0;
}
}
// update duels to protect victim
duel_protect_victim(victim);
// karn checking is done at the end of this function
}
if( ch->pknorecall==0){
ch->pknorecall=5;
}
ch->pknoquit=UMAX(ch->pknorecall,ch->pknoquit);
if(GAMESETTING5(GAMESET5_DEDICATED_PKILL_STYLE_MUD)){
ch->pknoquit=UMIN(ch->pknoquit,2);
}
victim->pcdata->next_karn_countdown=
UMIN(victim->pcdata->next_karn_countdown,GET_NEW_KARN_COUNTER(victim));
// autonote the pkill
if(!IS_SET(victim->in_room->room2_flags,ROOM2_ARENA) &&
!IS_SET(victim->in_room->room2_flags,ROOM2_WAR) )
{
pkill_autonote(ch, victim);
}
// deactivate autopkassist
if (IS_SET(victim->dyn,DYN_AUTOPKASSIST))
{
victim->println("`YYour autopkassist setting has been deactivated.`x");
REMOVE_BIT(victim->dyn,DYN_AUTOPKASSIST);
}
// remove thief status on death
if(IS_THIEF(victim)){
victim->println("You are no longer marked as a thief");
victim->pcdata->thief_until=0;
}
}
// Dying penalty: 2/3 way back to previous level for those level 20 or lower
{
if(victim->level<21)
{
if ( victim->exp > exp_per_level(victim,victim->pcdata->points)
* victim->level )
{
gain_exp( victim, (2 * (exp_per_level(victim,victim->pcdata->points)
* victim->level - victim->exp)/3) + 50 );
}
}
else
{
int xp_amount;
if(victim->level>50){
xp_amount=500+(get_sublevels_for_level( victim->level) *150);
}else{
xp_amount=500;
}
if(IS_HERO(victim)){
if(GAMESETTING5(GAMESET5_HEROS_DONT_LOSE_XP_FOR_DYING)){
victim->printlnf("You would have lost %d xp if you weren't a hero.", xp_amount);
}else{
victim->printlnf("You have lost %d xp.", xp_amount);
gain_exp( victim, -xp_amount);
}
}else{
victim->printlnf("You have lost %d xp.", xp_amount);
gain_exp( victim, -xp_amount);
}
if ( IS_HERO( victim )){
do_heroxp( victim, -xp_amount);
}
if(victim->exp<exp_per_level(victim,victim->pcdata->points)* victim->level )
{
drop_level(victim);
check_perm_damage(victim);
}else{
if(number_range(1,get_sublevels_for_level( victim->level+5))<2){
check_perm_damage(victim);
}else{
victim->println("Luckily you have not suffered serious injury.");
}
}
}
}
}
sprintf( log_buf, "%s [lvl %d] got toasted by %s at %s [lvl %d] [room %d] (%s)",
(IS_NPC(victim) ? victim->short_descr : victim->name),
victim->level,
(IS_NPC(ch) ? ch->short_descr : ch->name),
deathroom->name, ch->level, deathroom->vnum,
deathroom->area->name);
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 mobprog trigger
if ( IS_NPC( victim ) && HAS_TRIGGER( victim, TRIG_DEATH) )
{
victim->position = POS_STANDING;
mp_percent_trigger( victim, ch, NULL, NULL, TRIG_DEATH );
}
ch->mobmemory = NULL;
victim->mobmemory = NULL;
raw_kill( victim, ch );
// handle players autolooting and autogold mob corpses
if ( !IS_NPC(ch) && IS_NPC(victim) )
{
OBJ_DATA *corpse;
corpse = get_obj_list( ch, "corpse", deathroom->contents );
if(corpse && corpse->contains) // a corpse exists and isnt empty
{
if (IS_SET(ch->act, PLR_AUTOLOOT))
{
do_get( ch, "all corpse" );
}
else
{
if(IS_SET(ch->act,PLR_AUTOGOLD) )
{
OBJ_DATA *coins=get_obj_list(ch,"gcash",corpse->contains);
if (coins)
{
do_get(ch, "all.gcash corpse");
}
}
}
}
if ( corpse
&& HAS_CONFIG(ch, CONFIG_AUTOEXAMINE)
&& !IS_SET( ch->act,PLR_AUTOLOOT ))
{
act( "$p holds:", ch, corpse, NULL, TO_CHAR );
show_list_to_char( corpse->contains, ch, "", true, true );
}
}
if(!IS_NPC(victim)){
check_death_update();
}
}
/**************************************************************************/
// for auto assisting
// victim is being attacked by ch... will rch join in
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,"screams and attacks!");
multi_hit(rch,victim,TYPE_UNDEFINED);
continue;
}
// PCs next
if (!IS_NPC(ch) || IS_AFFECTED(ch,AFF_CHARM))
{
if( !is_same_group(ch,rch)
|| !can_join_combat(rch, victim)
|| is_safe(rch, victim)){
continue;
}
if(IS_NPC(victim)){
if(!IS_AFFECTED(rch,AFF_CHARM)
&& !(!IS_NPC(rch) && IS_SET(rch->act,PLR_AUTOASSIST))){
continue;
}
}else{
if(IS_NPC(rch)){
if(!IS_AFFECTED(rch,AFF_CHARM)){
continue;
}
}else{
if(!IS_SET(rch->dyn,DYN_AUTOPKASSIST)){
rch->println("`YYou dont automatically assist because you dont have autopkassist is off.`x");
continue;
}
}
}
// player attacking another player
if (!IS_NPC(rch) && !IS_NPC(victim))
{
logf( "%s attacking %s at %d (check_assist()(charm) might start pkill)",
rch->name,
victim->name,
rch->in_room->vnum );
}
multi_hit (rch,victim,TYPE_UNDEFINED);
continue;
}
//for horse attacking characters
if (victim->fighting && victim->fighting==rch->mounted_on)
{
// player attacking another player
if (!IS_NPC(rch) && !IS_NPC(victim))
{
logf( "%s attacking %s at %d (check_assist() might start pkill)",
rch->name,
victim->name,
rch->in_room->vnum );
}
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->helpgroup && rch->helpgroup == 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_in_room)
{
if (can_see(rch,vch)
&& is_same_group(vch,victim)
&& number_range(0,number) == 0)
{
target = vch;
number++;
}
}
if (target != NULL)
{
do_emote(rch,"screams and attacks!");
multi_hit(rch,target,TYPE_UNDEFINED);
}
}
}
}
}
}
/**************************************************************************/
// Do one group of attacks.
void multi_hit( char_data *ch, char_data *victim, int dt )
{
int chance;
if(IS_MOUNTED(ch))
{
ch->println("Cant do that.");
return;
}
if(!IS_NPC(ch) && !IS_NPC(victim) && ch!=victim)
{
if ( class_table[ch->clss].class_cast_type == CCT_BARD )
{
ch->songp = 0;
ch->songn = 0;
}
// transfer those to the void that are attacked
// while linkdead and dont have a pkill timer
if ( victim->pknorecall ==0
&& IS_LINKDEAD(victim)
&& victim->was_in_room == NULL
&& victim->in_room != NULL )
{
victim->was_in_room = victim->in_room;
if ( victim->fighting != NULL ){
stop_fighting( victim, true ); // Multi_hit linkdead transfer to void
}
act( "$n disappears into the void.", victim, NULL, NULL, TO_ROOM );
victim->println("You disappear into the void.");
if (victim->level > 1)
save_char_obj( victim);
char_from_room( victim);
char_to_room( victim, get_room_index( ROOM_VNUM_LIMBO ) );
return;
}
ch->pknorecall=15;
victim->pknorecall=15;
if(GAMESETTING5(GAMESET5_DEDICATED_PKILL_STYLE_MUD)){
ch->pknoquit =2;
victim->pknoquit=2;
}else{
ch->pknoquit =20;
victim->pknoquit=20;
}
if (IS_SET(victim->act2, ACT2_UNDERARREST) &&
IS_AFFECTED2(ch, AFF2_BOUNTYHUNTER))
{
ch->pknorecall = 5;
ch->pknoquit = 5;
victim->pknorecall = 5;
victim->pknoquit = 5;
}
}
// 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_affected( ch, gsn_hold_person))
return;
if (IS_NPC(ch))
{
mob_hit(ch,victim,dt);
return;
}
if(!IS_SET(ch->dyn2, DYN2_DOING_ORBIT))
one_hit( ch, victim, dt, false );
if (ch->fighting != victim)
return;
if (IS_AFFECTED(ch,AFF_HASTE))
one_hit(ch,victim,dt,false);
/* VAMPIRE ATTACKS - Ixliam - March 2004*/
if (IS_VAMPAFF(ch, VAM_FANGS) && (dt != gsn_backstab))
one_hit(ch,victim,dt,false);
/* IF CHARACTER HAS CELERITY, DO EXTRA ATTACKS */
if ( !IS_NPC(ch) && IS_VAMPAFF(ch, VAM_CELERITY) && (dt != gsn_backstab) )
{
int celatt = 1;
if ( get_age(ch) > 199 )
celatt = 2;
if ( get_age(ch) > 399 )
celatt = 3;
if ( get_age(ch) > 599 )
celatt = 4;
if (get_age(ch)>199
&& number_percent() < ((13-ch->vampgen)* 5))
celatt += 1;
if ( celatt > 4 )
celatt = 4;
int l = 0;
for (l=0; l < celatt; ++l)
{
one_hit(ch,victim,dt,false);
}
}
/* WISH EXTRA ATTACKS */
if ( !IS_NPC(ch) && IS_SET(ch->wish, WISH_ATTACK_1) && (dt != gsn_backstab) )
{
one_hit(ch,victim,dt,false);
}
if ( !IS_NPC(ch) && IS_SET(ch->wish, WISH_ATTACK_2) && (dt != gsn_backstab) )
{
one_hit(ch,victim,dt,false);
}
if ( !IS_NPC(ch) && IS_SET(ch->wish, WISH_ATTACK_3) && (dt != gsn_backstab) )
{
one_hit(ch,victim,dt,false);
}
// extra attack if defending your mount
if (victim->fighting==ch->mounted_on)
one_hit(ch,victim,dt,false);
if (get_eq_char (ch, WEAR_SECONDARY))
{
if(GAMESETTING2(GAMESET2_NO_SECOND_SKILL_REQUIRED)){
one_hit( ch, victim, dt, true );
if ( ch->fighting != victim ){
return;
}
}else{
if(number_range(ch->get_skill(gsn_second), 100)>90){
check_improve(ch,gsn_second,true,5);
one_hit( ch, victim, dt, true );
if ( ch->fighting != victim ){
return;
}
}else{
check_improve(ch,gsn_second,false,1);
}
}
}
if (get_eq_char (ch, WEAR_2WIELD))
{
if(number_range(ch->get_skill(gsn_triwield), 100)>90){
check_improve(ch,gsn_triwield,true,5);
two_hit( ch, victim, dt, false );
if ( ch->fighting != victim ){
return;
}
}else{
check_improve(ch,gsn_triwield,false,1);
}
}
if (get_eq_char (ch, WEAR_2SECONDARY))
{
if(number_range(ch->get_skill(gsn_quadwield), 100)>90){
check_improve(ch,gsn_quadwield,true,5);
two_hit( ch, victim, dt, true );
if ( ch->fighting != victim ){
return;
}
}else{
check_improve(ch,gsn_quadwield,false,1);
}
}
if ( ch->fighting != victim || dt == gsn_backstab )
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;
}
chance = get_skill(ch,gsn_third_attack)/3;
if (IS_AFFECTED(ch,AFF_SLOW))
chance = 0;
if ( number_percent( ) < chance )
{
one_hit( ch, victim, dt, false );
check_improve(ch,gsn_third_attack,true,6);
if ( ch->fighting != victim )
return;
}
chance = get_skill(ch,gsn_quad_attack)/2;
if (IS_AFFECTED(ch,AFF_SLOW))
chance = 0;
if ( number_percent( ) < chance )
{
one_hit( ch, victim, dt, false );
check_improve(ch,gsn_quad_attack,true,7);
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;
// Area attack -- BALLS nasty!
// mobs get the extra attack too if defending mount
if (victim->fighting==ch->mounted_on)
one_hit(ch,victim,dt,false);
if (IS_SET(ch->off_flags,OFF_AREA_ATTACK))
{
for (vch = ch->in_room->people; vch != NULL; vch = vch_next)
{
vch_next = vch->next_in_room;
if ((vch != victim && vch->fighting == ch))
one_hit(ch,vch,dt,false);
}
}
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)
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)/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,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)){
spec_cast_mage(ch);
return;
}
if (number == 2 && IS_SET(ch->act,ACT_CLERIC)){
spec_cast_cleric(ch);
return;
}
// now for the skills
number = number_range(0,10);
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_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_CIRCLE))
{
do_circle(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_pbackstab(ch,"");
}
case (9) :
if ( IS_SET( ch->off_flags, OFF_GORE ))
{
do_gore( ch, "" );
break;
}
case (10) :
if (IS_SET(ch->off_flags,OFF_GAZE))
{
do_gaze(ch,"");
}
break;
}
}
/**************************************************************************/
// Hit one guy once.
void one_hit( char_data *ch, char_data *victim, int dt, bool second )
{
OBJ_DATA *wield;
int victim_ac;
int thac0;
int thac0_00;
int thac0_32;
int dam;
int diceroll;
int sn,skill;
int dam_type;
int result;
int temp_hps;
sn = -1;
// just in case
if (victim == ch
|| ch == NULL || !IS_VALID(ch)
|| victim == NULL || !IS_VALID(victim))
{
return;
}
// Can't beat a dead char! and guard against weird room-leavings.
if ( victim->position == POS_DEAD || ch->in_room != victim->in_room )
return;
OBJ_DATA *primary_weapon= get_eq_char( ch, WEAR_WIELD );
OBJ_DATA *secondary_weapon= get_eq_char( ch, WEAR_SECONDARY);
// Figure out the type of damage message, first find the weapon
wield = second?secondary_weapon:primary_weapon;
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 ( class_table[ch->clss].class_cast_type == CCT_BARD )
{
ch->songp = 0;
ch->songn = 0;
}
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
if(second){ // swap over the secondary and primary to get sn
if(primary_weapon){
primary_weapon->wear_loc = WEAR_SECONDARY;
}
secondary_weapon->wear_loc = WEAR_WIELD;
sn = get_weapon_sn(ch);
if(primary_weapon){
primary_weapon->wear_loc = WEAR_WIELD;
}
secondary_weapon->wear_loc = WEAR_SECONDARY;
}else{
sn = get_weapon_sn(ch);
}
skill = 20 + get_weapon_skill(ch,sn);
if(second){
if(!GAMESETTING2(GAMESET2_NO_SECOND_SKILL_REQUIRED)){
skill*=(ch->get_skill(gsn_second)/100);
}
}
if ( get_eq_char( ch, WEAR_LODGED_ARM )){
skill -= 20;
}
if ( class_table[victim->clss].class_cast_type != CCT_BARD )
{
victim->songp = 0;
victim->songn = 0;
}
if(HAS_CONFIG(ch,CONFIG_PRACSYS_TESTER)){
skill+=20;
}
/*
* Calculate to-hit-armor-clss-0 versus armor.
*/
if ( IS_NPC(ch) )
{
thac0_00 = 20;
thac0_32 = -4; /* as good as a thief */
if (IS_SET(ch->act,ACT_WARRIOR))
thac0_32 = -10;
else if (IS_SET(ch->act,ACT_THIEF))
thac0_32 = -4;
else if (IS_SET(ch->act,ACT_CLERIC))
thac0_32 = 2;
else if (IS_SET(ch->act,ACT_MAGE))
thac0_32 = 6;
}
else
{
thac0_00 = class_table[ch->clss].thac0_00;
thac0_32 = class_table[ch->clss].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;
if(!IS_NPC(ch)){
// increase affect to hitroll for low pc newbies
if(ch->level<6){
thac0-= (6-ch->level)*2;
}
}else{
// decrease hitroll on low mobs when fighting newbies
if(ch->level<6 && victim->level<6){
thac0+= (6-victim->level)*2;
}
}
// make faerie fire do something
if(count_affected_by_base_spell( victim, gsn_faerie_fire )>0){
thac0-=number_range(1,3);
}
thac0 += 5 * (100 - skill) / 100;
if (dt == gsn_backstab)
thac0 -= 10 * (100 - get_skill(ch,gsn_backstab));
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(victim->position==POS_FIGHTING)
victim_ac -= victim->modifiers[STAT_QU]/5;
if ( !can_see( ch, victim ) )
victim_ac -= 4;
if ( victim->position < POS_FIGHTING)
victim_ac += 4;
if (victim->position < POS_RESTING)
victim_ac += 6;
if(is_affected( victim, gsn_hold_person))
victim_ac += 10;
// Fighting Styles AC Modifiers
if( victim->style == STYLE_AGGRESSIVE )
victim_ac += 3;
else if( victim->style == STYLE_DEFENSIVE )
victim_ac -= 2;
else if( victim->style == STYLE_EVASIVE )
victim_ac -= 3;
/*
* The moment of excitement!
*/
while ( ( diceroll = number_bits( 5 ) ) >= 20 )
;
if ( diceroll == 0
|| ( diceroll != 19 && diceroll < thac0 - victim_ac + num_enemies(ch) -
num_enemies(victim)))
{
/* Miss. */
damage( ch, victim, 0, dt, dam_type, true );
tail_chain( );
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;
// Send MSP sound message
{
char weapon_sound[MIL];
sprintf(weapon_sound,"%s6.wav", get_weapontype( wield ));
msp_to_room(MSPT_COMBAT, weapon_sound,
0,
ch,
false,
true);
}
// if weapon is above their level reduce the damage accordingly
if (wield->level>ch->level)
{
dam=dam * ch->level / wield->level;
}
// if defending a mount get bunch of extra damage
if (victim->fighting==ch->mounted_on)
{
dam=dam * 11/7;
}
// add damage bonus/penalty for mountedness:
// - if riding <80 you get from 1 to 100 percent of original damage
// - if riding >=80 you get 100 to 120 percent
// - based on riding skill and random factors
// - if defending your mount, these bonuses/penalties do not apply
if ((ch->mounted_on!=NULL)&&(!IS_NPC(ch))
&&(victim->fighting!=ch->mounted_on))
{
if (get_skill(ch, gsn_riding)<80)
{
dam *=(((get_skill(ch, gsn_riding)+20) * number_range(10,100))
/10000);
}
else
{
dam+=dam*((number_range(1,100))*(get_skill(ch, gsn_riding)-80))/10000;
check_improve(ch, gsn_riding, true, 10);
}
}
// no shield or second weapon = more damage
if (!get_eq_char(ch, WEAR_SECONDARY)
&& !get_eq_char(ch,WEAR_SHIELD))
dam = dam * 6/5;
// 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 (IS_WEAPON_STAT(wield,WEAPON_VORPAL)) // can't have both effects
{
int percent;
if((percent=number_percent()) <=(skill/33))
dam = 6 * dam + (dam*4*percent/100);
}
if ( IS_GOOD(victim)
&& IS_WEAPON_STAT(wield,WEAPON_HOLY)
&& IS_OBJ_STAT(wield,OBJEXTRA_ANTI_GOOD)
&& HAS_CLASSFLAG(ch, CLASSFLAG_DAMMODS_WITH_HOLYWEAPONS))
{
dam = dam + (victim->alliance/3)* (dam*5/4);
}
if ( IS_EVIL(victim)
&& IS_WEAPON_STAT(wield,WEAPON_HOLY)
&& IS_OBJ_STAT(wield,OBJEXTRA_ANTI_EVIL)
&& HAS_CLASSFLAG(ch, CLASSFLAG_DAMMODS_WITH_HOLYWEAPONS))
{
dam = (sh_int) dam + (abs(victim->alliance)/3)*(dam*5/4);
}
}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 ( wield != NULL && wield->item_type == ITEM_FIREARM )
{
if ( wield->value[1] <= 0 )
{
act( "`#`Y*CLICK* `cThe $p seems to be out of ammo.`^", ch, wield, NULL, TO_CHAR );
wield->value[1] = 0;
tail_chain( );
return;
}
wield->value[1] -= 1;
if (number_percent() <= get_skill(ch,gsn_firearms))
{
act( "$n shoots $N with $p.", ch, wield, victim, TO_NOTVICT );
act( "You shoot $N with $p.", ch, wield, victim, TO_CHAR );
act( "$n shoots at you with $p.",ch, wield, victim, TO_VICT );
obj_cast_spell( wield->value[2], wield->level, ch, victim, NULL );
}
else
{
act( "You miss the target.", ch,wield,NULL,TO_CHAR);
act( "$n misses with a shot from $p.", ch,wield,NULL,TO_ROOM);
check_improve(ch,gsn_firearms,false,2);
}
int recoil = 0;
if (IS_SET(wield->value[4], FIREARM_RECOIL_NONE) && ch->perm_stats[STAT_ST] < 25)
recoil = 1;
if (IS_SET(wield->value[4], FIREARM_RECOIL_LIGHT) && ch->perm_stats[STAT_ST] < 25)
recoil = 2;
if (IS_SET(wield->value[4], FIREARM_RECOIL_HEAVY) && ch->perm_stats[STAT_ST] < 25)
recoil = 3;
if (IS_SET(wield->value[4], FIREARM_RECOIL_EXTREME) && ch->perm_stats[STAT_ST] < 25)
recoil = 4;
if (IS_SET(wield->value[4], FIREARM_RECOIL_LIGHT) && ch->perm_stats[STAT_ST] < 45)
recoil = 1;
if (IS_SET(wield->value[4], FIREARM_RECOIL_HEAVY) && ch->perm_stats[STAT_ST] < 45)
recoil = 2;
if (IS_SET(wield->value[4], FIREARM_RECOIL_EXTREME) && ch->perm_stats[STAT_ST] < 45)
recoil = 3;
if (IS_SET(wield->value[4], FIREARM_RECOIL_HEAVY) && ch->perm_stats[STAT_ST] < 75)
recoil = 1;
if (IS_SET(wield->value[4], FIREARM_RECOIL_EXTREME) && ch->perm_stats[STAT_ST] < 75)
recoil = 2;
if (IS_SET(wield->value[4], FIREARM_RECOIL_EXTREME) && ch->perm_stats[STAT_ST] < 100)
recoil = 1;
if (recoil == 1)
{
ch->println ("The recoil slows you down a bit.");
WAIT_STATE(ch,1 * PULSE_VIOLENCE);
}
if (recoil == 2)
{
ch->println ("The recoil sends throws you off balance.");
WAIT_STATE(ch,2 * PULSE_VIOLENCE);
}
if (recoil == 3)
{
ch->println ("The strong recoil almost numbs your arm.");
WAIT_STATE(ch,3 * PULSE_VIOLENCE);
}
if (recoil == 4)
{
ch->println ("The recoil almost shatters your hand.");
WAIT_STATE(ch,4 * PULSE_VIOLENCE);
}
tail_chain( );
return;
}
if ( wield != NULL && wield->item_type == ITEM_WEAPON )
{
if ( strstr(wield->material, "iron") && IS_SET(victim->vuln_flags, VULN_IRON))
{
diceroll = number_percent();
if (diceroll <= 75)
{
dam += 2 * ( dam * diceroll/300);
}
}
if ( strstr(wield->material, "wood") && IS_SET(victim->vuln_flags, VULN_WOOD))
{
diceroll = number_percent();
if (diceroll <= 75)
{
dam += 2 * ( dam * diceroll/300);
}
}
if ( strstr(wield->material, "silver") && IS_SET(victim->vuln_flags, VULN_SILVER))
{
diceroll = number_percent();
if (diceroll <= 75)
{
dam += 2 * ( dam * diceroll/300);
}
}
}
if (IS_AFFECTED2(ch, AFF2_POSSESSION))
{
diceroll = number_percent();
if (diceroll <= 50){
dam += 2 * (dam * diceroll / 300);
}
}
if ( !IS_NPC(ch) && IS_VAMPAFF(ch, VAM_POTENCE) )
{
int ammount = (get_age(ch)/100);
if ( IS_VAMPAFF(ch, VAM_POTENCE) && ammount >= 7 )
ammount = 6;
else if ( ammount >= 6 )
ammount = 5;
ammount += ( 13 - ch->vampgen);
dam += ammount;
}
/* Vampires should be tougher at night and weaker during the day. */
if ( IS_VAMPIRE(ch) )
{
if (time_info.hour > 6 && time_info.hour < 19) /* 6 19 */
switch ( ch->in_room->sector_type )
{
case (SECT_FIELD):
case (SECT_CITY):
case (SECT_FOREST):
case (SECT_HILLS):
case (SECT_MOUNTAIN):
case (SECT_WATER_SWIM):
case (SECT_DESERT):
case (SECT_UNDERWATER):
case (SECT_WATER_NOSWIM):
case (SECT_SWAMP):
case (SECT_AIR):
case (SECT_ICE):
case (SECT_SNOW):
case (SECT_LAVA):
case (SECT_TRAIL):
if( !IS_SET(ch->in_room->room_flags, ROOM_DARK) ||
!IS_SET(ch->in_room->room_flags, ROOM_INDOORS))
{
dam /= 2;
}
}
}
if ( get_skill(ch,gsn_ultra_damage) > 0 )
{
diceroll = number_percent();
if (diceroll <= get_skill(ch,gsn_ultra_damage))
{
check_improve(ch,gsn_ultra_damage,true,7);
dam += 3/2 * ( dam * diceroll/300);
}
}
/*
* Calculate Damage Modifiers from Victim's Fighting Style
*/
if( victim->style == STYLE_AGGRESSIVE )
dam = dam * (4 / 1); // 1.1
else if( victim->style == STYLE_DEFENSIVE )
dam = dam * (6 / 7); // .85
else if( victim->style == STYLE_EVASIVE )
dam = dam * (4 / 5); // .8
/*
* Calculate Damage Modifiers from Attacker's Fighting Style
*/
if( ch->style == STYLE_AGGRESSIVE )
dam = dam * (4 / 1); // 1.1
else if( ch->style == STYLE_DEFENSIVE )
dam = dam * (6 / 7);
else if( ch->style == STYLE_EVASIVE )
dam = dam * (4 / 5);
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 *= 2 + (ch->level / 16);
}else{
dam *= 2 + (ch->level / 11);
}
}
dam += GET_DAMROLL(ch) * UMIN(100,skill) /100;
if ( dam <= 0 )
dam = 1;
result = damage( ch, victim, dam, dt, dam_type, true );
// but do we have a funky weapon?
if (result && wield != NULL)
{
int dam;
int dr; // damage result
if (ch->fighting == victim && IS_WEAPON_STAT(wield,WEAPON_POISON))
{
int level;
AFFECT_DATA *poison, af;
poison = affect_find(wield->affected,gsn_poison);
if(poison){
level = poison->level;
}else{
level = wield->level;
}
if (!saves_spell(level / 2,victim,DAM_POISON)
&& !HAS_CLASSFLAG(victim, CLASSFLAG_POISON_IMMUNITY))
{
victim->println("You feel poison coursing through your veins.");
act("$n is poisoned by the venom on $p.",
victim,wield,NULL,TO_ROOM);
af.where = WHERE_AFFECTS;
af.type = gsn_poison;
af.level = level * 3/4;
af.duration = level / 2;
af.location = APPLY_ST;
af.modifier = -1;
af.bitvector = AFF_POISON;
affect_join( victim, &af );
}
// weaken the poison if it's temporary
if(poison){
poison->level = UMAX(0,poison->level - 2);
poison->duration = UMAX(0,poison->duration - 1);
if (poison->level == 0 || poison->duration == 0){
act("The poison on $p has worn off.",ch,wield,NULL,TO_CHAR);
}
}
}
// vampiric weapon effect
if (ch->fighting == victim && IS_WEAPON_STAT(wield,WEAPON_VAMPIRIC))
{
dam = number_range(1, wield->level / 10 + 1);
temp_hps=victim->hit;
damage(ch,victim,dam,0,DAM_NEGATIVE,false);
if(victim->hit<-10){
victim->hit=-10;
}
dr=(temp_hps-victim->hit)/2;
ch->hit += dr;
act("$p draws life from $N.",ch,wield,victim,TO_NOTVICT);
act_with_autodam_to_char("$p draws life from $N.",ch,wield,victim,dr);
dr=temp_hps-victim->hit;
act_with_autodam_to_char("You feel $p drawing your life away.",victim,wield,NULL,dr);
}
// flaming weapon effect
if (ch->fighting == victim && IS_WEAPON_STAT(wield,WEAPON_FLAMING))
{
dam = number_range(1,wield->level / 4 + 1);
dr=damage(ch,victim,dam,0,DAM_FIRE,false);
act("$N is burned by $p.",ch,wield,victim,TO_NOTVICT);
act_with_autodam_to_char("$N is burned by $p.",ch,wield,victim,dr);
act_with_autodam_to_char("$p sears your flesh.",victim,wield,NULL,dr);
fire_effect( (void *) victim,wield->level/2,dam,TARGET_CHAR);
}
// frost weapon effect
if (ch->fighting == victim && IS_WEAPON_STAT(wield,WEAPON_FROST))
{
dam = number_range(1,wield->level / 6 + 2);
dr=damage(ch,victim,dam,0,DAM_COLD,false);
act("$p freezes $N.",ch,wield,victim,TO_NOTVICT);
act_with_autodam_to_char("$p freezes $N.",ch,wield,victim,dr);
act_with_autodam_to_char("The cold touch of $p surrounds you with ice.",
victim,wield,NULL,dr);
cold_effect(victim,wield->level/2,dam,TARGET_CHAR);
}
// suckle weapon effect - takes mana
if (ch->fighting == victim && IS_WEAPON_STAT(wield,WEAPON_SUCKLE))
{
dam = number_range(1, wield->level / 5 + 1);
act("$p draws mystical energy from $n.",victim,wield,NULL,TO_ROOM);
act("You feel $p drawing your mystical energy away.",
victim,wield,NULL,TO_CHAR);
victim->mana -= dam;
ch->mana += dam/2;
}
// enervated weapon effect - takes movements
if (ch->fighting == victim && IS_WEAPON_STAT(wield,WEAPON_ENERVATE))
{
dam = number_range(1, wield->level / 5 + 1);
act("$p saps the strength from $n.",victim,wield,NULL,TO_ROOM);
act("You feel $p sapping your strength away.",
victim,wield,NULL,TO_CHAR);
victim->move-= dam;
ch->move += dam/2;
}
if (ch->fighting == victim && (wield->pIndexData->vnum == 5093))
{
int rot_chance;
rot_chance = number_range(1,20);
if (rot_chance>=18 &&
!IS_SET(victim->act,ACT_UNDEAD) &&
!IS_SET(victim->imm_flags,IMM_DISEASE) &&
!HAS_CLASSFLAG(victim, CLASSFLAG_PLAGUE_IMMUNITY))
{
AFFECT_DATA af;
victim->printf( "You scream in `#`?a`?g`?o`?n`?y`^ as your skin begins to rot." );
act("$n screams in `#`?a`?g`?o`?n`?y`^ as $s skin begins to rot.",victim,NULL,NULL,TO_ROOM);
af.where = WHERE_AFFECTS;
af.type = gsn_plague;
af.level = 100;
af.duration = 75;
af.location = APPLY_ST;
af.modifier = -15;
af.bitvector = AFF_PLAGUE;
affect_join( victim, &af );
}
if (rot_chance == 20)
{
OBJ_DATA *decay, *decay_next;
int rotrandom = dice(2,10)-1;
for ( decay = victim->carrying; decay != NULL; decay = decay_next)
{
decay_next = decay->next_content;
if (decay->wear_loc == rotrandom)
break;
}
if (decay!=NULL && !IS_SET( decay->extra2_flags, OBJEXTRA2_NODECAY ))
{
decay->timer = 10+rotrandom;
act( "$p slowly starts to break apart.", victim, decay, NULL, TO_ROOM );
act( "$p slowly starts to break apart as decay sets in.", victim, decay, NULL, TO_CHAR );
}
}
}
if (ch->fighting == victim && (wield->pIndexData->vnum == 5094))
{
if(victim->clss == class_lookup("mage") ||
victim->clss == class_lookup("spellfilcher"))
{
if (!IS_NPC(victim))
{
act("$n is drained by the power of $p.",victim,wield,NULL,TO_ROOM);
act("You are drained by the power of $p.",victim,wield,NULL,TO_CHAR);
int mana_drain=0;
mana_drain = number_range(50,150);
victim->mana -= mana_drain;
if (victim->mana < 0)
{
victim->mana = 0;
}
}
int dispel_chance;
dispel_chance = number_range(1,20);
if(IS_NPC(victim) && !IS_SET(victim->act, ACT_MAGE))
{
dispel_chance = 0;
}
if (dispel_chance == 20)
{
act("$n is dispelled by $p.",victim,wield,NULL,TO_ROOM);
act("You are dispelled by $p.",victim,wield,NULL,TO_CHAR);
affect_parentspellfunc_strip(victim,gsn_regeneration);
affect_parentspellfunc_strip(victim,gsn_resist_poison);
affect_parentspellfunc_strip(victim,gsn_poison_immunity);
affect_parentspellfunc_strip(victim,gsn_illusions_grandeur);
affect_parentspellfunc_strip(victim,gsn_protection_fire);
affect_parentspellfunc_strip(victim,gsn_protection_cold);
affect_parentspellfunc_strip(victim,gsn_protection_acid);
affect_parentspellfunc_strip(victim,gsn_protection_lightning);
affect_parentspellfunc_strip(victim,gsn_holy_aura);
affect_parentspellfunc_strip(victim,gsn_unholy_aura);
affect_parentspellfunc_strip(victim,gsn_true_sight);
affect_parentspellfunc_strip(victim,gsn_barkskin);
affect_parentspellfunc_strip(victim,gsn_magic_resistance);
affect_parentspellfunc_strip(victim,gsn_fire_shield);
affect_parentspellfunc_strip(victim,gsn_chill_shield);
affect_parentspellfunc_strip(victim,gsn_animal_essence);
affect_parentspellfunc_strip(victim,gsn_armor);
affect_parentspellfunc_strip(victim,gsn_bless);
affect_parentspellfunc_strip(victim,gsn_detect_evil);
affect_parentspellfunc_strip(victim,gsn_detect_scry);
affect_parentspellfunc_strip(victim,gsn_detect_good);
affect_parentspellfunc_strip(victim,gsn_detect_hidden);
affect_parentspellfunc_strip(victim,gsn_detect_invis);
affect_parentspellfunc_strip(victim,gsn_fly);
affect_parentspellfunc_strip(victim,gsn_frenzy);
affect_parentspellfunc_strip(victim,gsn_giant_strength);
affect_parentspellfunc_strip(victim,gsn_haste);
affect_parentspellfunc_strip(victim,gsn_invisibility);
affect_parentspellfunc_strip(victim,gsn_mass_invis);
affect_parentspellfunc_strip(victim,gsn_rage);
affect_parentspellfunc_strip(victim,gsn_protection_good);
affect_parentspellfunc_strip(victim,gsn_protection_evil);
affect_parentspellfunc_strip(victim,gsn_pass_door);
if (IS_AFFECTED(victim,AFF_SANCTUARY) && !is_affected(victim, gsn_sanctuary ))
{
REMOVE_BIT(victim->affected_by,AFF_SANCTUARY);
act("The white aura around $n's body vanishes.",victim,NULL,NULL,TO_ROOM);
}
else
{
affect_parentspellfunc_strip(victim,gsn_sanctuary);
}
}
}
}
// annealed weapon effect
if (ch->fighting == victim && IS_WEAPON_STAT(wield,WEAPON_ANNEALED))
{
dam = number_range(1,wield->level/5 + 2);
dr=damage(ch,victim,dam,0,DAM_BASH,false);
if (!saves_spell(wield->level/4 + dam/20,victim,DAM_BASH))
{
DAZE_STATE(victim,UMAX(12,wield->level/4 + dam/20));
}
victim->printlnf("You see stars as your head `Crings`x!%s",
autodamtext(victim, dr));
ch->printlnf("Your opponent looks `Bstunned`x!%s",
autodamtext(ch, dr));
}
// shocking weapon effect
if (ch->fighting == victim && IS_WEAPON_STAT(wield,WEAPON_SHOCKING))
{
dam = number_range(1,wield->level/5 + 2);
dr=damage(ch,victim,dam,0,DAM_LIGHTNING,false);
act("$N is struck by lightning from $p.",ch,wield,victim,TO_NOTVICT);
act_with_autodam_to_char("$N is struck by lightning from $p.",ch,wield,victim,dr);
act_with_autodam_to_char("You are shocked by $p",victim,wield,NULL,dr);
shock_effect(victim,wield->level/2,dam,TARGET_CHAR);
}
}
tail_chain( );
return;
}
/**************************************************************************/
// Hit one guy once - two hit is for multi-limbed PC's
void two_hit( char_data *ch, char_data *victim, int dt, bool second )
{
OBJ_DATA *wield;
int victim_ac;
int thac0;
int thac0_00;
int thac0_32;
int dam;
int diceroll;
int sn,skill;
int dam_type;
int result;
sn = -1;
// just in case
if (victim == ch
|| ch == NULL || !IS_VALID(ch)
|| victim == NULL || !IS_VALID(victim))
{
return;
}
// Can't beat a dead char! and guard against weird room-leavings.
if ( victim->position == POS_DEAD || ch->in_room != victim->in_room )
return;
OBJ_DATA *primary_weapon= get_eq_char( ch, WEAR_2WIELD );
OBJ_DATA *secondary_weapon= get_eq_char( ch, WEAR_2SECONDARY);
// Figure out the type of damage message, first find the weapon
wield = second?secondary_weapon:primary_weapon;
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
if(second){ // swap over the secondary and primary to get sn
if(primary_weapon){
primary_weapon->wear_loc = WEAR_2SECONDARY;
}
secondary_weapon->wear_loc = WEAR_2WIELD;
sn = get_weapon_sn(ch);
if(primary_weapon){
primary_weapon->wear_loc = WEAR_2WIELD;
}
secondary_weapon->wear_loc = WEAR_2SECONDARY;
}else{
sn = get_weapon_sn(ch);
}
skill = 20 + get_weapon_skill(ch,sn);
if(second)
{
skill*=(ch->get_skill(gsn_quadwield)/100);
}
if ( get_eq_char( ch, WEAR_LODGED_ARM )){
skill -= 20;
}
/*
* Calculate to-hit-armor-clss-0 versus armor.
*/
if ( IS_NPC(ch) )
{
thac0_00 = 20;
thac0_32 = -4; /* as good as a thief */
if (IS_SET(ch->act,ACT_WARRIOR))
thac0_32 = -10;
else if (IS_SET(ch->act,ACT_THIEF))
thac0_32 = -4;
else if (IS_SET(ch->act,ACT_CLERIC))
thac0_32 = 2;
else if (IS_SET(ch->act,ACT_MAGE))
thac0_32 = 6;
}
else
{
thac0_00 = class_table[ch->clss].thac0_00;
thac0_32 = class_table[ch->clss].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;
if(!IS_NPC(ch)){
// increase affect to hitroll for low pc newbies
if(ch->level<6){
thac0-= (6-ch->level)*2;
}
}else{
// decrease hitroll on low mobs when fighting newbies
if(ch->level<6 && victim->level<6){
thac0+= (6-victim->level)*2;
}
}
// make faerie fire do something
if(count_affected_by_base_spell( victim, gsn_faerie_fire )>0){
thac0-=number_range(1,3);
}
thac0 += 5 * (100 - skill) / 100;
if (dt == gsn_backstab)
thac0 -= 10 * (100 - get_skill(ch,gsn_backstab));
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(victim->position==POS_FIGHTING)
victim_ac -= victim->modifiers[STAT_QU]/5;
if ( !can_see( ch, victim ) )
victim_ac -= 4;
if ( victim->position < POS_FIGHTING)
victim_ac += 4;
if (victim->position < POS_RESTING)
victim_ac += 6;
if(is_affected( victim, gsn_hold_person))
victim_ac += 10;
/*
* The moment of excitement!
*/
while ( ( diceroll = number_bits( 5 ) ) >= 20 )
;
if ( diceroll == 0
|| ( diceroll != 19 && diceroll < thac0 - victim_ac + num_enemies(ch) -
num_enemies(victim)))
{
/* Miss. */
damage( ch, victim, 0, dt, dam_type, true );
tail_chain( );
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;
// Send MSP sound message
{
char weapon_sound[MIL];
sprintf(weapon_sound,"%s6.wav", get_weapontype( wield ));
msp_to_room(MSPT_COMBAT, weapon_sound,
0,
ch,
false,
true);
}
// if weapon is above their level reduce the damage accordingly
if (wield->level>ch->level)
{
dam=dam * ch->level / wield->level;
}
// if defending a mount get bunch of extra damage
if (victim->fighting==ch->mounted_on)
{
dam=dam * 11/7;
}
// add damage bonus/penalty for mountedness:
// - if riding <80 you get from 1 to 100 percent of original damage
// - if riding >=80 you get 100 to 120 percent
// - based on riding skill and random factors
// - if defending your mount, these bonuses/penalties do not apply
if ((ch->mounted_on!=NULL)&&(!IS_NPC(ch))
&&(victim->fighting!=ch->mounted_on))
{
if (get_skill(ch, gsn_riding)<80)
{
dam *=(((get_skill(ch, gsn_riding)+20) * number_range(10,100))
/10000);
}
else
{
dam+=dam*((number_range(1,100))*(get_skill(ch, gsn_riding)-80))/10000;
check_improve(ch, gsn_riding, true, 10);
}
}
// no shield or second weapon = more damage
if (!get_eq_char(ch, WEAR_2SECONDARY)
&& !get_eq_char(ch,WEAR_SHIELD))
dam = dam * 6/5;
// 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 (IS_WEAPON_STAT(wield,WEAPON_VORPAL)) // can't have both effects
{
int percent;
if((percent=number_percent()) <=(skill/33))
dam = 6 * dam + (dam*4*percent/100);
}
if ( IS_GOOD(victim)
&& IS_WEAPON_STAT(wield,WEAPON_HOLY)
&& IS_OBJ_STAT(wield,OBJEXTRA_ANTI_GOOD)
&& HAS_CLASSFLAG(ch, CLASSFLAG_DAMMODS_WITH_HOLYWEAPONS))
{
dam = dam + (victim->alliance/3)* (dam*5/4);
}
if ( IS_EVIL(victim)
&& IS_WEAPON_STAT(wield,WEAPON_HOLY)
&& IS_OBJ_STAT(wield,OBJEXTRA_ANTI_EVIL)
&& HAS_CLASSFLAG(ch, CLASSFLAG_DAMMODS_WITH_HOLYWEAPONS))
{
dam = (sh_int) dam + (abs(victim->alliance)/3)*(dam*5/4);
}
}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 ( wield != NULL && wield->item_type == ITEM_WEAPON )
{
if ( strstr(wield->material, "iron") && IS_SET(victim->vuln_flags, VULN_IRON))
{
diceroll = number_percent();
if (diceroll <= 75)
{
dam += 2 * ( dam * diceroll/300);
}
}
if ( strstr(wield->material, "wood") && IS_SET(victim->vuln_flags, VULN_WOOD))
{
diceroll = number_percent();
if (diceroll <= 75)
{
dam += 2 * ( dam * diceroll/300);
}
}
if ( strstr(wield->material, "silver") && IS_SET(victim->vuln_flags, VULN_SILVER))
{
diceroll = number_percent();
if (diceroll <= 75)
{
dam += 2 * ( dam * diceroll/300);
}
}
}
if (IS_AFFECTED2(ch, AFF2_POSSESSION))
{
diceroll = number_percent();
if (diceroll <= 50){
dam += 2 * (dam * diceroll / 300);
}
}
if ( get_skill(ch,gsn_ultra_damage) > 0 )
{
diceroll = number_percent();
if (diceroll <= get_skill(ch,gsn_ultra_damage))
{
check_improve(ch,gsn_ultra_damage,true,7);
dam += 3/2 * ( dam * diceroll/300);
}
}
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 *= 2 + (ch->level / 16);
}else{
dam *= 2 + (ch->level / 11);
}
}
dam += GET_DAMROLL(ch) * UMIN(100,skill) /100;
if ( dam <= 0 )
dam = 1;
result = damage( ch, victim, dam, dt, dam_type, true );
// but do we have a funky weapon?
if (result < 0 && wield != NULL)
{
weapon_effects(ch, victim, wield);
if ( class_table[ch->clss].class_cast_type == CCT_BARD )
{
ch->songp = 0;
ch->songn = 0;
}
if ( class_table[victim->clss].class_cast_type == CCT_BARD )
{
victim->songp = 0;
victim->songn = 0;
}
if (ch->fighting == victim && (wield->pIndexData->vnum == 5094))
{
if(victim->clss == class_lookup("mage") ||
victim->clss == class_lookup("spellfilcher"))
{
if (!IS_NPC(victim))
{
act("$n is drained by the power of $p.",victim,wield,NULL,TO_ROOM);
act("You are drained by the power of $p.",victim,wield,NULL,TO_CHAR);
int mana_drain=0;
mana_drain = number_range(50,200);
victim->mana -= mana_drain;
if (victim->mana > 0)
{
victim->mana = 0;
}
}
int dispel_chance;
dispel_chance = number_range(1,20);
if(IS_NPC(victim) && !IS_SET(victim->act, ACT_MAGE))
{
dispel_chance = 0;
}
if (dispel_chance == 20)
{
act("$n is dispelled by $p.",victim,wield,NULL,TO_ROOM);
act("You are dispelled by $p.",victim,wield,NULL,TO_CHAR);
affect_parentspellfunc_strip(victim,gsn_regeneration);
affect_parentspellfunc_strip(victim,gsn_resist_poison);
affect_parentspellfunc_strip(victim,gsn_poison_immunity);
affect_parentspellfunc_strip(victim,gsn_illusions_grandeur);
affect_parentspellfunc_strip(victim,gsn_protection_fire);
affect_parentspellfunc_strip(victim,gsn_protection_cold);
affect_parentspellfunc_strip(victim,gsn_protection_acid);
affect_parentspellfunc_strip(victim,gsn_protection_lightning);
affect_parentspellfunc_strip(victim,gsn_holy_aura);
affect_parentspellfunc_strip(victim,gsn_unholy_aura);
affect_parentspellfunc_strip(victim,gsn_true_sight);
affect_parentspellfunc_strip(victim,gsn_barkskin);
affect_parentspellfunc_strip(victim,gsn_magic_resistance);
affect_parentspellfunc_strip(victim,gsn_fire_shield);
affect_parentspellfunc_strip(victim,gsn_chill_shield);
affect_parentspellfunc_strip(victim,gsn_animal_essence);
affect_parentspellfunc_strip(victim,gsn_armor);
affect_parentspellfunc_strip(victim,gsn_bless);
affect_parentspellfunc_strip(victim,gsn_detect_evil);
affect_parentspellfunc_strip(victim,gsn_detect_scry);
affect_parentspellfunc_strip(victim,gsn_detect_good);
affect_parentspellfunc_strip(victim,gsn_detect_hidden);
affect_parentspellfunc_strip(victim,gsn_detect_invis);
affect_parentspellfunc_strip(victim,gsn_fly);
affect_parentspellfunc_strip(victim,gsn_frenzy);
affect_parentspellfunc_strip(victim,gsn_giant_strength);
affect_parentspellfunc_strip(victim,gsn_haste);
affect_parentspellfunc_strip(victim,gsn_invisibility);
affect_parentspellfunc_strip(victim,gsn_mass_invis);
affect_parentspellfunc_strip(victim,gsn_rage);
affect_parentspellfunc_strip(victim,gsn_protection_good);
affect_parentspellfunc_strip(victim,gsn_protection_evil);
affect_parentspellfunc_strip(victim,gsn_pass_door);
if (IS_AFFECTED(victim,AFF_SANCTUARY) && !is_affected(victim, gsn_sanctuary ))
{
REMOVE_BIT(victim->affected_by,AFF_SANCTUARY);
act("The white aura around $n's body vanishes.",victim,NULL,NULL,TO_ROOM);
}
else
{
affect_parentspellfunc_strip(victim,gsn_sanctuary);
}
}
}
}
}
tail_chain( );
return;
}
void weapon_effects( char_data *ch, char_data *victim, obj_data *wield)
{
int dam;
int dr;
if (ch->fighting == victim && IS_WEAPON_STAT(wield,WEAPON_POISON))
{
int level;
AFFECT_DATA *poison, af;
poison = affect_find(wield->affected,gsn_poison);
if(poison){
level = poison->level;
}else{
level = wield->level;
}
if (!saves_spell(level / 2,victim,DAM_POISON)
&& !HAS_CLASSFLAG(victim, CLASSFLAG_POISON_IMMUNITY))
{
victim->println("You feel poison coursing through your veins.");
act("$n is poisoned by the venom on $p.",
victim,wield,NULL,TO_ROOM);
af.where = WHERE_AFFECTS;
af.type = gsn_poison;
af.level = level * 3/4;
af.duration = level / 2;
af.location = APPLY_ST;
af.modifier = -1;
af.bitvector = AFF_POISON;
affect_join( victim, &af );
}
// weaken the poison if it's temporary
if(poison){
poison->level = UMAX(0,poison->level - 2);
poison->duration = UMAX(0,poison->duration - 1);
if (poison->level == 0 || poison->duration == 0){
act("The poison on $p has worn off.",ch,wield,NULL,TO_CHAR);
}
}
}
// vampiric weapon effect
if (ch->fighting == victim && IS_WEAPON_STAT(wield,WEAPON_VAMPIRIC))
{
dam = number_range(1, wield->level / 10 + 1);
int temp_hps=victim->hit;
damage(ch,victim,dam,0,DAM_NEGATIVE,false);
if(victim->hit<-10){
victim->hit=-10;
}
dr=(temp_hps-victim->hit)/2;
ch->hit += dr;
act("$p draws life from $N.",ch,wield,victim,TO_NOTVICT);
act_with_autodam_to_char("$p draws life from $N.",ch,wield,victim,dr);
dr=temp_hps-victim->hit;
act_with_autodam_to_char("You feel $p drawing your life away.",victim,wield,NULL,dr);
}
// flaming weapon effect
if (ch->fighting == victim && IS_WEAPON_STAT(wield,WEAPON_FLAMING))
{
dam = number_range(1,wield->level / 4 + 1);
dr=damage(ch,victim,dam,0,DAM_FIRE,false);
act("$N is burned by $p.",ch,wield,victim,TO_NOTVICT);
act_with_autodam_to_char("$N is burned by $p.",ch,wield,victim,dr);
act_with_autodam_to_char("$p sears your flesh.",victim,wield,NULL,dr);
fire_effect( (void *) victim,wield->level/2,dam,TARGET_CHAR);
}
// frost weapon effect
if (ch->fighting == victim && IS_WEAPON_STAT(wield,WEAPON_FROST))
{
dam = number_range(1,wield->level / 6 + 2);
dr=damage(ch,victim,dam,0,DAM_COLD,false);
act("$p freezes $N.",ch,wield,victim,TO_NOTVICT);
act_with_autodam_to_char("$p freezes $N.",ch,wield,victim,dr);
act_with_autodam_to_char("The cold touch of $p surrounds you with ice.",
victim,wield,NULL,dr);
cold_effect(victim,wield->level/2,dam,TARGET_CHAR);
}
// suckle weapon effect - takes mana
if (ch->fighting == victim && IS_WEAPON_STAT(wield,WEAPON_SUCKLE))
{
dam = number_range(1, wield->level / 5 + 1);
act("$p draws mystical energy from $n.",victim,wield,NULL,TO_ROOM);
act("You feel $p drawing your mystical energy away.",
victim,wield,NULL,TO_CHAR);
victim->mana -= dam;
ch->mana += dam/2;
}
// enervated weapon effect - takes movements
if (ch->fighting == victim && IS_WEAPON_STAT(wield,WEAPON_ENERVATE))
{
dam = number_range(1, wield->level / 5 + 1);
act("$p saps the strength from $n.",victim,wield,NULL,TO_ROOM);
act("You feel $p sapping your strength away.",
victim,wield,NULL,TO_CHAR);
victim->move-= dam;
ch->move += dam/2;
}
// annealed weapon effect
if (ch->fighting == victim && IS_WEAPON_STAT(wield,WEAPON_ANNEALED))
{
dam = number_range(1,wield->level/5 + 2);
dr=damage(ch,victim,dam,0,DAM_BASH,false);
if (!saves_spell(wield->level/4 + dam/20,victim,DAM_BASH)){
victim->printlnf("You see stars as your head `Crings`x!%s",
autodamtext(victim, dr));
ch->printlnf("Your opponent looks `Bstunned`x!%s",
autodamtext(ch, dr));
DAZE_STATE(victim,UMAX(12,wield->level/4 + dam/20));
}
}
if (ch->fighting == victim && IS_WEAPON_STAT(wield,WEAPON_SHOCKING))
{
dam = number_range(1,wield->level/5 + 2);
dr=damage(ch,victim,dam,0,DAM_LIGHTNING,false);
act("$N is struck by lightning from $p.",ch,wield,victim,TO_NOTVICT);
act_with_autodam_to_char("$N is struck by lightning from $p.",ch,wield,victim,dr);
act_with_autodam_to_char("You are shocked by $p",victim,wield,NULL,dr);
shock_effect(victim,wield->level/2,dam,TARGET_CHAR);
}
return;
}
/**************************************************************************/
// Inflict damage from a hit.
// return the amount of hitpoints removed from the victim
int damage(char_data *ch,char_data *victim,int dam,int dt,int dam_type, bool show)
{
bool immune;
int i;
char_data *rch;
char_data *rch_next = NULL;
OBJ_DATA *loser;
if ( !IS_VALID(victim) || victim->position == POS_DEAD ){
return 0;
}
// doing damage system used to determine who starts fights
if( dt!=gsn_fire_shield
&& dt!=gsn_chill_shield
&& dt!=gsn_icy_armour
&& dt!=gsn_fiery_armour
&& dt!=gsn_orbit
&& dt!=gsn_blood_shield)
{
SET_BIT(ch->dyn,DYN_DOING_DAMAGE);
}
if(dt == gsn_orbit)
{
obj_data *wield;
if ( (wield = get_eq_char( ch, WEAR_WIELD )) != NULL
&& wield->item_type == ITEM_WEAPON ){
dt = TYPE_HIT + wield->value[3];
}
else {
REMOVE_BIT(ch->dyn2, DYN2_DOING_ORBIT);
return 0;
}
}
// Stop up any residual loopholes.
if ( dam > 2200 && dt >= TYPE_HIT)
{
bugf( "Damage: %d: more than 2200 points! by %s.", dam, PERS(ch, NULL));
dam = 2200;
if (!IS_IMMORTAL(ch))
{
OBJ_DATA *obj;
obj = get_eq_char( ch, WEAR_WIELD );
ch->println("You really shouldn't cheat.");
if (obj != NULL)
extract_obj(obj);
}
}
// scale the damage
if(!GAMESETTING3(GAMESET3_EXPERIMENTAL_DAMAGE_SCALING)){
// old damage scaling system originating from oblivion
// too complicated for its own good.
dam=dam*3/2;
switch(UMIN(number_range(1,20),number_range(1,20)))
{
default :
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7: dam = dam / (victim->level*2/5+1) ; break ;
case 8:
case 9:
case 10:
case 11:
case 12:
case 13:
if(ch->level>victim->level){
dam=dam * (ch->level-victim->level+5)/5;
}
dam = dam / (victim->level*2/5+1);
break;
case 14:
case 15:
case 16:
case 17:
if(ch->level*11/10>victim->level){
dam=dam * (ch->level*11/10-victim->level+5)/5;
}
dam = dam / (victim->level*2/5+1);
break;
case 18:
case 19:
if(ch->level*12/10>victim->level){
dam=dam * (ch->level*12/10-victim->level+5)/5;
}
dam = dam / (victim->level*2/5+1);
break;
case 20:
if(ch->level*15/10>victim->level){
dam=dam * (ch->level*15/10-victim->level+5)/5;
}
dam = dam / (victim->level*2/5+1);
break;
}
}else{
if (HAS_CONFIG2(ch, CONFIG2_FISHING))
dam=dam*2;
// increase/decrease the damage_scale_value
// we will use by upto 50%
int scale=game_settings->damage_scale_value;
if(number_range(1,2)==1){
scale+=number_range(1,number_range(1,scale/2));
}else{
scale-=number_range(1,number_range(1,scale/2));
}
scale=URANGE(100, scale, 4000);
// apply the damage scale value
scale=(victim->level * scale / 10000);
if(scale){
dam/=scale;
}
}
if ( victim != ch )
{
// Certain attacks are forbidden.
// Most other attacks are returned - set victim to fighting
if ( is_safe( ch, victim ) ){
REMOVE_BIT(ch->dyn,DYN_DOING_DAMAGE);
return 0;
}
if ( victim->position > POS_STUNNED )
{
if ( ch->fighting == NULL ){
set_fighting( ch, victim );
}
if ( victim->fighting == NULL ){ // moved from above
set_fighting( victim, ch );
if ( IS_NPC( victim ) && HAS_TRIGGER( victim, TRIG_KILL )){
mp_percent_trigger( victim, ch, NULL, NULL, TRIG_KILL );
if(!IS_VALID(victim)){ // if the mob purged itself
REMOVE_BIT(ch->dyn,DYN_DOING_DAMAGE);
return 0;
}
}
}
if (victim->timer <= 4){ // moved from above
victim->position = POS_FIGHTING;
}
if ( IS_NPC(ch)
&& IS_NPC(victim)
&& IS_AFFECTED(victim, AFF_CHARM)
&& victim->master != NULL
&& victim->master->in_room == ch->in_room
&& number_bits( 3 ) == 0 )
{
stop_fighting( ch, false ); // Damage
multi_hit( ch, victim->master, TYPE_UNDEFINED );
REMOVE_BIT(ch->dyn,DYN_DOING_DAMAGE);
return 0;
}
}
// More charm stuff.
if ( victim->master == ch ){
stop_follower( victim );
}
}
// Inviso attacks ... not.
if ( IS_SET( ch->affected_by2, AFF2_TREEFORM ))
{
REMOVE_BIT( ch->affected_by2, AFF2_TREEFORM );
affect_strip( ch, gsn_treeform );
act( "A tree suddenly transforms into $n.", ch, NULL, NULL, TO_ROOM );
ch->println( "You assume your normal form." );
}
if ( IS_SET( ch->affected_by2, AFF2_VANISH ))
{
REMOVE_BIT( ch->affected_by2, AFF2_VANISH );
affect_strip ( ch, gsn_vanish );
act( "A swirl of dust reveals $n.", ch, NULL, NULL, TO_ROOM );
ch->println( "You shake the `#`Bfaerie-dust`^ from your body." );
}
if ( IS_AFFECTED(ch, AFF_INVISIBLE) )
{
affect_parentspellfunc_strip( ch, gsn_invisibility );
affect_parentspellfunc_strip( ch, gsn_mass_invis );
REMOVE_BIT( ch->affected_by, AFF_INVISIBLE );
ch->println( "You fade into existence.");
act( "$n fades into existence.", ch, NULL, NULL, TO_ROOM );
}
if ( IS_SET( ch->affected_by, AFF_HIDE)
|| IS_SET( ch->affected_by, AFF_SNEAK))
{
REMOVE_BIT( ch->affected_by, AFF_HIDE );
REMOVE_BIT( ch->affected_by, AFF_SNEAK );
act( "$n is revealed from the shadows.", ch, NULL, NULL, TO_ROOM );
}
// Set Mob Remember
if ( victim->mobmemory ) {
victim->mobmemory = ch;
}
else
mobRememberSet( victim, ch );
// Damage modifiers.
if ( dam > 1 && !IS_NPC(victim)
&& victim->pcdata->condition[COND_DRUNK] > 10 )
dam = 9 * dam / 10;
if ( dam > 1 && IS_AFFECTED(victim, AFF_SANCTUARY) )
dam /= 2;
if ( !IS_NPC(victim) && IS_VAMPAFF(victim, VAM_FORTITUDE) )
{
int ammount = (get_age(victim)/100);
if ( IS_VAMPAFF(victim, VAM_FORTITUDE) && ammount >= 7 )
ammount = 6;
else if ( ammount >= 6 )
ammount = 5;
ammount += ( 13 - ch->vampgen);
dam = dam * number_range(95-ammount,95) /100;
}
// subdue modifications - make damage 60-90% of what it would have been
if (IS_SET(ch->dyn,DYN_CURRENT_SUBDUE))
{
dam = dam * number_range(60,90) /100;
}
if ( dam > 1 && ((IS_AFFECTED(victim, AFF_PROTECT_EVIL) && IS_EVIL(ch) )
|| (IS_AFFECTED(victim, AFF_PROTECT_GOOD) && IS_GOOD(ch) )))
dam -= dam / 4;
if(num_enemies(victim)>num_enemies(ch))
dam = dam + dam * (num_enemies(victim) - num_enemies(ch))/2;
immune = false;
// Check for parry, and dodge.
if ( dt >= TYPE_HIT && ch != victim)
{
if ( check_parry( ch, victim ) ){
REMOVE_BIT(ch->dyn,DYN_DOING_DAMAGE);
return 0;
}
if ( check_dodge( ch, victim ) ){
REMOVE_BIT(ch->dyn,DYN_DOING_DAMAGE);
return 0;
}
if ( check_shield_block(ch,victim)){
REMOVE_BIT(ch->dyn,DYN_DOING_DAMAGE);
return 0;
}
if ( (IS_SET(victim->dyn2, DYN2_DOING_SPINBLOCK)
|| (IS_NPC(victim) && IS_SET(victim->off_flags, OFF_SPINBLOCK)))
&& check_spinblock(ch,victim)){
REMOVE_BIT(ch->dyn,DYN_DOING_DAMAGE);
return 0;
}
}
// Let's check for Jinn affinities (kinda messy) clean up later
if( ch != victim
&& (( (dt == DAM_LIGHT || dt == DAM_FIRE)
&& get_skill(ch, gsn_fire_affinity) >= number_percent())
|| ( (dt == DAM_POISON || dt == DAM_ACID)
&& get_skill(ch, gsn_earth_affinity) >= number_percent())
|| ( (dt == DAM_DROWNING || dt == DAM_COLD)
&& get_skill(ch, gsn_water_affinity) >= number_percent())
|| ( (dt == DAM_LIGHTNING || dt == DAM_SOUND)
&& get_skill(ch, gsn_air_affinity) >= number_percent())))
{
REMOVE_BIT(ch->dyn,DYN_DOING_DAMAGE);
victim->mana = UMAX(50, victim->mana + dam);
act("Your attack flows into $N!", ch, NULL, victim, TO_CHAR);
act("$n's attack flows into $N!", ch, NULL, victim, TO_NOTVICT);
act("$n's attack flows into you.", ch, NULL, victim, TO_VICT);
return 0;
}
switch(check_immune(victim,dam_type))
{
case(IS_IMMUNE):
immune = true;
dam = 0;
break;
case(IS_RESISTANT):
dam -= dam/2;
break;
case(IS_VULNERABLE):
dam += dam;
break;
}
if(show){
dam_message( ch, victim, dam, dt, immune );
}
if(dam == 0){
REMOVE_BIT(ch->dyn,DYN_DOING_DAMAGE);
return 0;
}
// hurt the victim.
victim->hit -= dam;
// if we did damage, record if the level of the attacker is higher than
// the previously highest recorded attacker. This information is used
// when allocating group xp, the amount of XP awarded reduces based on
// if you are more than 8 levels below the highest attacker's level
// (the lower you are from that level, the less you get)
if(dam>0){
victim->highest_level_to_do_damage=
UMAX(victim->highest_level_to_do_damage, ch->level);
}
//Storing damage types and precedence
if(dam > 0)
{
if(victim->last_damage[1] >= 2000)
victim->last_damage[1] = 1000+dam_type;
else
{
if(victim->last_damage[1] >= 1000)
victim->last_damage[1]-=1000;
victim->last_damage[0] = 1000+dam_type;
}
}
else if(victim->last_damage[1] >= 2000)
victim->last_damage[1]-=2000;
// inform the victim of their new state.
update_pos( victim );
// if the victim is riding a mount, check if they are knocked off it
if(victim->mounted_on){
long percent_of_max_hits;
percent_of_max_hits=dam*100;
percent_of_max_hits/=victim->max_hit;
if(percent_of_max_hits>=10){
if(!IS_NPC(victim)) // player
{
if ((number_range(1, 100)) <
(105-get_skill(victim, gsn_riding)) *
(percent_of_max_hits-9))
{
act("You are knocked from your mount!\r\n", victim, NULL, NULL, TO_CHAR);
act("$n is knocked from $s mount!\r\n", victim, NULL, NULL, TO_ROOM);
dismount(victim);
check_improve(victim, gsn_riding, false, 1);
}
}else{ // mob
if (number_range(1, 100)+((percent_of_max_hits-10)*3)>80){
act("You are knocked from your mount!\r\n", victim, NULL, NULL, TO_CHAR);
act("$n is knocked from %s mount!\r\n", victim, NULL, NULL, TO_ROOM);
dismount(victim);
}
}
}
}
if(dam>1)
{
if(is_affected(victim,gsn_fire_shield) && dt!=gsn_fire_shield){
damage(victim,ch,UMIN(ch->max_hit,dam*3/4),gsn_fire_shield,DAM_FIRE,true);
}
if(is_affected(victim,gsn_blood_shield) && dt!=gsn_blood_shield){
int blood_dam = damage(victim,ch,UMIN(ch->max_hit,dam*3/2),gsn_blood_shield,DAM_NEGATIVE,true);
if(blood_dam > 0)
ch->hit+=blood_dam;
}
if(is_affected(victim,gsn_chill_shield) && dt!=gsn_chill_shield){
damage(victim,ch,UMIN(ch->max_hit,dam*3/4),gsn_chill_shield,DAM_COLD,true);
}
if(is_affected(victim,gsn_fiery_armour) && dt!=gsn_fiery_armour){
damage(victim,ch,UMIN(ch->max_hit,dam*3/4),gsn_fiery_armour,DAM_FIRE,true);
}
if(is_affected(victim,gsn_icy_armour) && dt!=gsn_icy_armour){
damage(victim,ch,UMIN(ch->max_hit,dam*3/4),gsn_icy_armour,DAM_COLD,true);
}
if(IS_SET(victim->dyn2, DYN2_DOING_ORBIT) && dt!=gsn_orbit){
int orbit_damage = damage(victim,ch,UMIN(ch->max_hit,dam*3/2),gsn_orbit,DAM_NONE,true);
if(orbit_damage > 0)
weapon_effects(ch, victim, get_eq_char( ch, WEAR_WIELD ));
}
}
if(100 * dam / victim->max_hit > (i = number_percent())){
bash_eq(victim,i);
}
update_pos(ch);
/************** ARREST **************************************************/
if (IS_SET(victim->act2, ACT2_UNDERARREST)
&& IS_AFFECTED2(ch, AFF2_BOUNTYHUNTER)
&& !IS_AWAKE(victim) && IS_NPC(ch))
{
victim->pknorecall = 0;
victim->pknoquit = 0;
act( "$n is placed in shackles and has been arrested.", victim, NULL, NULL, TO_ROOM );
victim->println("You have been arrested and taken to prison.");
stop_fighting( victim, true); // Damage - subdued
stop_fighting( ch, true); // Damage - subdued
victim->position=POS_RESTING;
victim->hit=1;
if(victim->pcdata->theft > 0 && victim->pcdata->murder == 0)
info_broadcast(ch, "%s has been arrested by the guards for ROBBERY.", victim->name);
if(victim->pcdata->theft == 0 && victim->pcdata->murder > 0)
info_broadcast(ch, "%s has been arrested by the guards for MURDER.", victim->name);
if(victim->pcdata->theft > 0 && victim->pcdata->murder > 0)
info_broadcast(ch, "%s has been arrested by the guards for ROBBERY & MURDER.", victim->name);
REMOVE_BIT(victim->act2, ACT2_UNDERARREST);
sprintf( log_buf, "%s arrested by %s at %d", victim->name,
(IS_NPC(ch) ? ch->short_descr : ch->name),
ch->in_room->vnum );
log_string( log_buf );
wiznet(log_buf,NULL,NULL,WIZ_BETA,0,0);
if(victim->pcdata->murder > 3 && victim->pcdata->murder < 50)
victim->pcdata->murder = victim->pcdata->murder / 3;
if(victim->pcdata->theft > 3)
victim->pcdata->theft = victim->pcdata->theft / 3;
if (victim->pcdata->theft == 0 && victim->pcdata->murder == 0
&& IS_WEREBEAST(victim))
{
info_broadcast(ch, "%s has been arrested by the guards for being a WEREWOLF.", victim->name);
victim->pcdata->murder = 1;
}
do_startprison(victim, "");
return 0;
}
if (IS_SET(victim->act2, ACT2_UNDERARREST)
&& IS_AFFECTED2(ch, AFF2_BOUNTYHUNTER)
&& !IS_AWAKE(victim))
{
ch->pknorecall = 5;
ch->pknoquit = 5;
victim->pknorecall = 0;
victim->pknoquit = 0;
act( "$n is placed in shackles and has been arrested.", victim, NULL, NULL, TO_ROOM );
victim->println("You have been arrested and taken to prison.");
stop_fighting( victim, true); // Damage - subdued
stop_fighting(ch, true); // Damage - subdued
group_gain( ch, victim );
victim->subdued= true;
victim->subdued_timer = number_range(5,10);
victim->position=POS_RESTING;
victim->hit=1;
int bounty;
bounty= (victim->pcdata->theft + victim->pcdata->murder) * 50;
if(bounty > 500)
bounty = 500;
ch->printlnf("`#`YYou receive a bounty of %d gold.`^", bounty);
ch->gold += bounty;
if(victim->pcdata->theft > 0 && victim->pcdata->murder == 0)
info_broadcast(ch, "%s has been arrested for ROBBERY.", victim->name);
if(victim->pcdata->theft == 0 && victim->pcdata->murder > 0)
info_broadcast(ch, "%s has been arrested for MURDER.", victim->name);
if(victim->pcdata->theft > 0 && victim->pcdata->murder > 0)
info_broadcast(ch, "%s has been arrested for ROBBERY & MURDER.", victim->name);
REMOVE_BIT(victim->act2, ACT2_UNDERARREST);
sprintf( log_buf, "%s arrested by %s at %d",
victim->name,
(IS_NPC(ch) ? ch->short_descr : ch->name),
ch->in_room->vnum );
log_string( log_buf );
wiznet(log_buf,NULL,NULL,WIZ_BETA,0,0);
do_startprison(victim, "");
return 0;
}
/****************************************************************/
// Subdue System - Kalahn June 97, updated October 98
if (IS_SET(ch->dyn,DYN_CURRENT_SUBDUE)
&& !IS_AWAKE(victim) && !IS_SET(ch->in_room->room2_flags,ROOM2_ARENA)
&& !IS_SET(ch->in_room->room2_flags,ROOM2_WAR)
&& ( IS_IMMORTAL(ch)
|| (number_percent()< UMAX(15,101-(GET_HITROLL(ch)/2)))
)
)
{
act( "$n appears to be subdued.", victim, NULL, NULL, TO_ROOM );
victim->println("You have been subdued.");
if(!IS_NPC(victim)){
group_bypass_killer_penatly(ch, victim, false);
// update duels to protect victim
duel_protect_victim(victim);
}
stop_fighting( victim, true); // Damage - subdued
group_gain( ch, victim );
victim->subdued= true;
victim->subdued_timer = number_range(10,20);
victim->is_stunned = ch->level;
victim->position=POS_STUNNED;
/************* VAMPIRE SUBDUAL *************/
if ( !IS_NPC(victim) && IS_VAMPIRE(victim))
{
victim->subdued=true;
victim->subdued_timer = 5;
victim->position = POS_MORTAL;
victim->hit = -10;
update_pos(victim);
}
/************* VAMPIRE SUBDUAL *************/
if (IS_NPC(victim))
{
victim->no_xp = true;
victim->pIndexData->count--;
// no more exchanging money with a weak money changer and then
// subduing the mob and getting your silver back.
if (IS_SET(victim->act,ACT_IS_CHANGER)){
victim->gold= number_range(1,UMIN(3,victim->gold));
victim->silver= number_range(1,UMIN(350,victim->silver));
}
}
sprintf( log_buf, "%s subdued by %s at %d",
victim->name,
(IS_NPC(ch) ? ch->short_descr : ch->name),
ch->in_room->vnum );
log_string( log_buf );
wiznet(log_buf,NULL,NULL,WIZ_BETA,0,0);
if(GAMESETTING5(GAMESET5_DEDICATED_PKILL_STYLE_MUD)){
pkill_broadcast(log_buf);
}else{
if (!IS_NPC(victim))
{
sprintf( log_buf, "%s[%d] subdued by %s[%d] at %d",
victim->name, victim->level,
ch->name, ch->level,
ch->in_room->vnum );
wiznet(log_buf,NULL,NULL,WIZ_DEATHS,0,0);
}
}
}
else
{
switch( victim->position )
{
case POS_MORTAL:
act( "$n is mortally wounded, and will die soon, if not aided.",
victim, NULL, NULL, TO_ROOM );
victim->println("You are mortally wounded, and will die soon, if not aided.");
break;
case POS_INCAP:
act( "$n is incapacitated and will slowly die, if not aided.",
victim, NULL, NULL, TO_ROOM );
victim->println("You are incapacitated and will slowly die, if not aided.");
break;
case POS_STUNNED:
act( "$n is stunned, but will probably recover.",
victim, NULL, NULL, TO_ROOM );
victim->println("You are stunned, but will probably recover.");
break;
case POS_DEAD:
act( "$n is DEAD!!", victim, 0, 0, TO_ROOM );
victim->println("You have been `rKILLED!!`x");
break;
default:
if ( victim->hit < victim->max_hit / 4 )
{
victim->println("`YYou sure are `rBLEEDING!`x");
}
break;
}
// Sleep spells and extremely wounded folks.
if ( !IS_AWAKE(victim) ){
stop_fighting( victim, false ); // Damage - not awake victim
}
/* JAIL DEATH FIX */
if ( !IS_NPC(victim) &&
is_name( victim->in_room->area->file_name, "jailarea.are" )&&
victim->in_room->vnum != 10398)
{
victim->position = POS_RESTING;
victim->printlnf("`#`YDoctors rush in and revive you from certain death.`^");
victim->subdued = false;
victim->subdued_timer=0;
victim->pcdata->tired=UMIN(0, victim->pcdata->tired);
victim->pcdata->condition[COND_THIRST]=
UMAX(30, victim->pcdata->condition[COND_THIRST]);
victim->pcdata->condition[COND_HUNGER]=
UMAX(30,victim->pcdata->condition[COND_HUNGER]);
victim->pcdata->condition[COND_FULL]=
UMIN(0,victim->pcdata->condition[COND_FULL]);
victim->pcdata->condition[COND_DRUNK]=
UMIN(0,victim->pcdata->condition[COND_DRUNK]);
victim->hit = victim->max_hit;
victim->mana = victim->max_mana;
victim->move = victim->max_move;
victim->bleeding = 0;
victim->will_die = 0;
update_pos( victim);
do_look(victim, "auto");
return 0;
}
// Arena Code by IXLIAM
if (victim->position == POS_DEAD && !IS_NPC(victim) && !IS_NPC(ch)
&& (IS_SET(victim->in_room->room2_flags,ROOM2_ARENA)))
{
ch->pcdata->akills += 1;
victim->pcdata->adeaths += 1;
ch->pknorecall=0;
ch->pknoquit =0;
victim->pknorecall=0;
victim->pknoquit =0;
/* the dead man */
stop_fighting(victim,true);
char_from_room(victim);
char_to_room(victim,get_room_index(50019));
victim->println("`#`RYou have `YLOST!!!`^");
affect_strip(ch,gsn_plague);
affect_strip(ch,gsn_despair);
affect_strip(ch,gsn_poison);
affect_strip(ch,gsn_blindness);
affect_strip(ch,gsn_sleep);
affect_strip(ch,gsn_curse);
affect_strip(ch,gsn_cause_fear);
affect_strip(ch,gsn_fear_magic);
affect_strip(ch,gsn_vanish);
affect_strip(ch,gsn_neck_thrust);
affect_strip(ch,gsn_charm_person);
affect_strip(ch,gsn_pine_needles);
affect_strip(ch,gsn_wrath);
victim->move = victim->max_move;
victim->hit = victim->max_hit;
victim->mana = victim->max_mana;
update_pos( victim );
do_look(victim, "auto");
/* the winner :) */
stop_fighting(ch,true);
char_from_room(ch);
char_to_room(ch,get_room_index(50000));
ch->println("`#`RYou have `YWON!!!!`^");
info_broadcast(victim, "%s defeated %s in the Arena.", ch->name, victim->name);
affect_strip(ch,gsn_wrath);
affect_strip(ch,gsn_despair);
affect_strip(ch,gsn_plague);
affect_strip(ch,gsn_poison);
affect_strip(ch,gsn_blindness);
affect_strip(ch,gsn_sleep);
affect_strip(ch,gsn_curse);
affect_strip(ch,gsn_cause_fear);
affect_strip(ch,gsn_fear_magic);
affect_strip(ch,gsn_vanish);
affect_strip(ch,gsn_neck_thrust);
affect_strip(ch,gsn_charm_person);
affect_strip(ch,gsn_pine_needles);
ch->hit = ch->max_hit;
ch->mana = ch->max_mana;
ch->move = ch->max_move;
update_pos( ch );
do_look(ch, "auto");
if (IS_SET(ch->act2,ACT2_PLR_CHALLENGER))
REMOVE_BIT(ch->act2,ACT2_PLR_CHALLENGER);
if (IS_SET(victim->act2,ACT2_PLR_CHALLENGER))
REMOVE_BIT(victim->act2,ACT2_PLR_CHALLENGER);
if (IS_SET(victim->act2,ACT2_PLR_CHALLENGED))
REMOVE_BIT(victim->act2,ACT2_PLR_CHALLENGED);
if (IS_SET(ch->act2,ACT2_PLR_CHALLENGED))
REMOVE_BIT(ch->act2,ACT2_PLR_CHALLENGED);
arena_is_busy = false;
REMOVE_BIT(ch->dyn,DYN_DOING_DAMAGE);
tail_chain( );
return 0;
}
// End of Arena Code
// War Battlefield Code by IXLIAM
if (victim->position == POS_DEAD && !IS_NPC(victim) && !IS_NPC(ch)
&& (IS_SET(victim->in_room->room2_flags,ROOM2_WAR)))
{
/* the dead man */
stop_fighting(victim,true);
char_from_room(victim);
char_to_room(victim,get_room_index(50020));
victim->println("`#`YYou have been `RKILLED `Yand removed from battle !`^");
loser = create_object(get_obj_index(50097)); // Loser timed token
loser->timer = 8; // Number of ticks they cannot battle
obj_to_char( loser, victim ); // Send token to loser
if (( loser = get_obj_token( ch, "50098")) != NULL)
{
obj_from_char (loser);
extract_obj (loser);
}
if (( loser = get_obj_token( ch, "50099")) != NULL)
{
obj_from_char (loser);
extract_obj (loser);
}
affect_strip(ch,gsn_wrath);
affect_strip(ch,gsn_plague);
affect_strip(ch,gsn_despair);
affect_strip(ch,gsn_poison);
affect_strip(ch,gsn_blindness);
affect_strip(ch,gsn_sleep);
affect_strip(ch,gsn_curse);
affect_strip(ch,gsn_cause_fear);
affect_strip(ch,gsn_fear_magic);
affect_strip(ch,gsn_vanish);
affect_strip(ch,gsn_neck_thrust);
affect_strip(ch,gsn_charm_person);
affect_strip(ch,gsn_pine_needles);
victim->hit = victim->max_hit;
victim->mana = victim->max_mana;
victim->move = victim->max_move;
ch->pknorecall=0;
ch->pknoquit =0;
victim->pknorecall=0;
victim->pknoquit =0;
victim->bleeding = 0;
victim->will_die = 0;
update_pos( victim );
do_look(victim, "auto");
if (IS_SET(victim->act2,ACT2_WAR_BLUE))
{
info_broadcast(victim, "`#`Y[`BBLUE TEAM`Y]`W %s has been killed in the Battlefield.", victim->name);
REMOVE_BIT(victim->act2,ACT2_WAR_BLUE);
}
if (IS_SET(victim->act2,ACT2_WAR_RED))
{
info_broadcast(victim, "`#`Y[`RRED TEAM`Y]`W %s has been killed in the Battlefield.", victim->name);
REMOVE_BIT(victim->act2,ACT2_WAR_RED);
}
REMOVE_BIT(ch->dyn,DYN_DOING_DAMAGE);
tail_chain( );
return 0;
}
// End of War Battlefield Code
// Payoff for killing things.
if ( victim->position == POS_DEAD )
{
int number_in_room=0;
// ** get rch the safe way
// This code is necessary because a mob (ch) can trigger on
// on position acts ("is DEAD!!" etc)... and purge itself
rch= NULL;
if(IS_VALID(ch) && ch->in_room){
rch = ch->in_room->people;
number_in_room=ch->in_room->number_in_room;
}else if(IS_VALID(victim) && victim->in_room){
rch = victim->in_room->people;
number_in_room=victim->in_room->number_in_room;
}
if(!rch){
logf("Not testing for roomdeath trigger cause victim room and ch room couldn't be found.");
}
// ** Check for the roomdeath triggers
// note: number_in_room is used to prevent a mobprog on two mobs in
// a room creating an endless loop by removing themself from
// the room and putting themselves back in the room - Kal, June 01
for ( ; rch && --number_in_room>=0; rch = rch_next )
{
rch_next = rch->next_in_room;
if ( IS_NPC( rch ))
{
if ( HAS_TRIGGER( rch, TRIG_ROOMDEATH )
&& can_see( rch, ch )
&& rch!=victim)
{
logf("Running roomdeath trigger prog on mob '%s' %d",
PERS(rch, NULL), rch->pIndexData?rch->pIndexData->vnum:0);
mp_percent_trigger( rch, ch, NULL, NULL, TRIG_ROOMDEATH );
}
}
}
kill_char(victim, ch);
REMOVE_BIT(ch->dyn,DYN_DOING_DAMAGE);
return dam;
}
if ( victim == ch Showing the first 100 KB of 271.4 KB. Download the archive for the full file.