fight.cpp
src/fight.cpp · 181.5 KB
From the archive athens.tar.gz
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 "msp.h"
#define MAX_DAMAGE_MESSAGE 43
/* 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 );
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);
void arena_broadcast(char_data *ch, char * fmt, ...); //Arena handle
char * const death_cry_dir_name[]=
{
"`cthe north`x", "`cthe east`x", "`cthe south`x", "`cthe west`x", "`cabove`x", "`cbelow`x",
"`cthe northeast`x", "`cthe southeast`x", "`cthe southwest`x", "`cthe northwest`x"
};
/*
* Local functions.
*/
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 ));
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 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 ));
/**************************************************************************/
// 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;
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->bleeding)
{
damage( ch, ch, ch->bleeding, TYPE_UNDEFINED, DAM_NONE,false);
act("`c$n's deteriorating condition is very apparent.`x",
ch,NULL,NULL,TO_ROOM);
ch->println("You lose even more blood.");
}
if(ch->is_stunned)
{
ch->is_stunned-=1;
if(ch->is_stunned<=0)
{
ch->position=POS_RESTING;
ch->is_stunned=0;
ch->println("`cYou are no longer stunned.`x");
}
}
if(ch->will_die)
{
ch->will_die-=20;
if(ch->will_die<=0)
{
ch->will_die=0;
// we know victim exists and is in the same room
kill_char(ch, victim);
continue;
}
}
if ( IS_AWAKE(ch) && ch->in_room == victim->in_room ){
multi_hit( ch, victim, TYPE_UNDEFINED );
}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 );
}
}
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 (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 slain by %s.", victim->name, ch->short_descr);
// 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);
}
//Arena-use
}else if(IS_SET(ch->act2, ACT2_PLR_ARENA)
|| IS_SET(victim->act2, ACT2_PLR_ARENA)){
char buf[MIL];
sprintf( buf, "%s has been defeated by %s", victim->name, ch->name );
arena_broadcast( ch, buf );
ch->win += 1;
victim->lost += 1; //arena stats
char_data *wch;
//Arena betting system, pays the winners
for( wch = player_list; wch; wch = wch->next_player )
{
if(can_see(wch, ch))
{
int value;
if (IS_SET(wch->act2,ACT2_PLR_BET) && IS_SET(victim->act2, ACT2_PLR_ARENA) )
{
if (!IS_NPC(wch) && !str_cmp(wch->pcdata->bet,ch->name))
{
value = wch->pot * 2;
wch->gold += value;
wch->pot = 0;
wch->printlnf("`R[ARENA]:`x You won the bet! You receive %d `Ygold.\n\r", value);
wch->pcdata->bet = NULL;
REMOVE_BIT(wch->act2, ACT2_PLR_BET);
}
if (!IS_NPC(wch) && !str_cmp(wch->pcdata->bet,victim->name))
{
wch->printlnf("`R[ARENA]:`x You lost the %d `Ygold you bet!\n\r", wch->pot);
wch->pot = 0;
wch->pcdata->bet = NULL;
REMOVE_BIT(wch->act2, ACT2_PLR_BET);
}
}
}
}
}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 slain by %s!", victim->name, ch->name);
}
log_string( log_buf );
if(ch->pkool>0 && victim->level<5
&& !IS_SET(ch->act2, ACT2_PLR_ARENA) && !IS_SET(victim->act2, ACT2_PLR_ARENA)
// && !IS_SET(ch->act2, ACT2_PLR_EVENT) && !IS_SET(victim->act2, ACT2_PLR_EVENT)
){
// ch didn't start the fight so they dont get the pkills on them
// reducing their max karns
ch->pkkills--;
}
if(victim->level<11 && !IS_LETGAINED(victim) && GAMESETTING_LETGAINING_IS_REQUIRED
&& !IS_SET(ch->act2, ACT2_PLR_ARENA) && !IS_SET(victim->act2, ACT2_PLR_ARENA)
// && !IS_SET(ch->act2, ACT2_PLR_EVENT) && !IS_SET(victim->act2, ACT2_PLR_EVENT)
){
if(!GAMESETTING5(GAMESET5_DEDICATED_PKILL_STYLE_MUD)){
ch->pkool+=4000;
}
}
if(ch->pkool>0 && victim->level<5){
// ch didn't start the fight so they dont get the pkills on them
// reducing their max karns
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){
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
}
//Arena- players PK independent
if( ch->pknorecall==0 && !IS_SET(ch->act2, ACT2_PLR_ARENA)
// && !IS_SET(ch->act2, ACT2_PLR_EVENT)
){
ch->pknorecall=5;
}
//Arena- players PK independent
if(!IS_SET(ch->act2, ACT2_PLR_ARENA)
// && !IS_SET(ch->act2, ACT2_PLR_EVENT)
){
ch->pknoquit=UMAX(ch->pknorecall,ch->pknoquit);
}
//Arena- players PK independent
if(GAMESETTING5(GAMESET5_DEDICATED_PKILL_STYLE_MUD)
&& !IS_SET(ch->act2, ACT2_PLR_ARENA)
// && !IS_SET(ch->act2, ACT2_PLR_EVENT)
){
ch->pknoquit=UMIN(ch->pknoquit,2);
}
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
//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) && !IS_SET(victim->act2, ACT2_PLR_ARENA)
// && !IS_SET(victim->act2, ACT2_PLR_EVENT)
){
if(GAMESETTING5(GAMESET5_HEROS_DONT_LOSE_XP_FOR_DYING)){
victim->printlnf("`cYou would have lost %d xp if you weren't a hero.`x", xp_amount);
}else{
victim->printlnf("`cYou have lost %d xp.`x", xp_amount);
gain_exp( victim, -xp_amount);
}
//Arena- players don't lose xp
}else if(IS_SET(victim->act2, ACT2_PLR_ARENA)
// && !IS_SET(victim->act2, ACT2_PLR_EVENT)
){
victim->printlnf("`cYou have lost in the arena but not xp points.`x");
}else{
victim->printlnf("`cYou have lost %d xp.`x", xp_amount);
gain_exp( victim, -xp_amount);
}
if ( IS_HERO( victim )){
do_heroxp( victim, -xp_amount);
}
//Arena- players perm damage independent
if(victim->exp<exp_per_level(victim,victim->pcdata->points)* victim->level
&& !IS_SET(victim->act2, ACT2_PLR_ARENA)
// && !IS_SET(victim->act2, ACT2_PLR_EVENT)
)
{
drop_level(victim);
check_perm_damage(victim);
}else{
if(number_range(1,get_sublevels_for_level( victim->level+5))<2
&& !IS_SET(victim->act2, ACT2_PLR_ARENA)
// && !IS_SET(victim->act2, ACT2_PLR_EVENT)
){
check_perm_damage(victim);
}else{
victim->println("`cLuckily you the gods have spared you serious injury.`x");
}
}
}
}
}
sprintf( log_buf, "%s [lvl %d] was slain 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;
//ARENA - raw_kill calls make_corpse
//avoid raw_kill, send him to a room fully dressed but defeated
if(!IS_SET(victim->act2, ACT2_PLR_ARENA)
// && !IS_SET(ch->act2, ACT2_PLR_EVENT)
){
raw_kill( victim, ch );
}
act( "$n APPEARS FROM THE LAND OF THE LIVING.", victim, NULL, NULL, TO_ROOM );
//ARENA VICTIM (LOSER)
//Send the defeated to the 'locker rooms'
if(IS_SET(victim->act2, ACT2_PLR_ARENA)
// || IS_SET(ch->act2, ACT2_PLR_EVENT)
){
//char buf[MIL];
//borrow the essential help from raw_kill
//without it PC'll go to position dead
//and 'see stars' and require assistance.
if(victim->position == POS_FIGHTING){
stop_fighting( victim, true );
}
victim->position = POS_RESTING;
victim->hit = UMAX( 1, victim->hit );
victim->mana = UMAX( 1, victim->mana );
victim->move = UMAX( 1, victim->move );
reset_char(victim); // easiest way to fix problems with death bugs
landchar(victim); // make sure they die on the ground
save_char_obj(victim);
//reset PC to arena noncombatant
//frees arena for others to play
REMOVE_BIT(victim->act2, ACT2_PLR_ARENA);
REMOVE_BIT(victim->act2, ACT2_PLR_ARENA);
//If you use mobmemory, players will auto
//initiate a pkill upon leaving the arena
//so must remove it!!! Prob not the victim.
if(victim->mobmemory){
victim->mobmemory = NULL;
}
if(victim->challenged != NULL){
ch->challenged = NULL;
}
if(victim->challenger != NULL){
ch->challenger = NULL;
}
if(victim->pcdata->bet){
ch->pcdata->bet = NULL;
}
//special room for arena defeated.
ROOM_INDEX_DATA *room;
room = get_room_index(701);
char_from_room(victim);
char_to_room(victim, room);
//Move the winner out of the arena
if(SET_BIT( ch->act2, ACT2_PLR_ARENA )){
if(ch->position == POS_FIGHTING){
stop_fighting( ch, true );
}
ch->position = POS_STANDING;
//If you use mobmemory, players will auto
//initiate a pkill upon leaving the arena
//so must remove it!!!
if(ch->mobmemory){
ch->mobmemory = NULL;
}
//remove bit so he'll clear recall filters
REMOVE_BIT(ch->act2, ACT2_PLR_ARENA );
if(ch->challenged != NULL){
ch->challenged = NULL;
}
if(ch->challenger != NULL){
ch->challenger = NULL;
}
if(ch->pcdata->bet){
ch->pcdata->bet = NULL;
}
if (IS_AFFECTED(ch, AFF_CURSE)){
REMOVE_BIT( ch->affected_by, AFF_CURSE );
}
do_recall( ch, "" );
ch->printlnf( "`R[ARENA]:`Y GRATZ Victorious %s!.`x\n\r", ch->name );
//reward?
int goldreward = number_range(20, 40);
ch->gold += goldreward;
ch->printlnf( "`R[ARENA]: `WYou win %d `Ygold!\n\r", goldreward);
//more? my dot gives qp reward
}
// 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( "`c$p holds:`x", 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,"`cscreams and attacks!`x");
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)
{
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
&& !IS_SET(ch->act2, ACT2_PLR_ARENA)
&& !IS_SET(victim->act2, ACT2_PLR_ARENA)
// && !IS_SET(ch->act2, ACT2_PLR_EVENT)
// && !IS_SET(ch->act2, ACT2_PLR_EVENT)
)
{
// 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( "`c$n disappears into the void.`x", victim, NULL, NULL, TO_ROOM );
victim->println("`cYou disappear into the void.`x");
if (victim->level > 1)
save_char_obj( victim);
char_from_room( victim);
char_to_room( victim, get_room_index( ROOM_VNUM_LIMBO ) );
return;
}
if(!IS_SET(ch->act2, ACT2_PLR_ARENA) || !IS_SET(victim->act2, ACT2_PLR_ARENA)
// || !IS_SET(victim->act2, ACT2_PLR_EVENT) || !IS_SET(victim->act2, ACT2_PLR_EVENT)
){
ch->pknorecall=15;
victim->pknorecall=15;
}
if(GAMESETTING5(GAMESET5_DEDICATED_PKILL_STYLE_MUD)){
ch->pknoquit =2;
victim->pknoquit=2;
}else if(!IS_SET(ch->act2, ACT2_PLR_ARENA) && !IS_SET(ch->act2, ACT2_PLR_ARENA)){
ch->pknoquit =20;
victim->pknoquit=20;
}
/* else if(!IS_SET(ch->act2, ACT2_PLR_EVENT) && !IS_SET(ch->act2, ACT2_PLR_EVENT)){
ch->pknoquit =20;
victim->pknoquit=20;
}
*/
}
// decrement the wait
if (ch->desc == NULL)
ch->wait = UMAX(0,ch->wait - PULSE_VIOLENCE);
if (ch->desc == NULL)
ch->daze = UMAX(0,ch->daze - PULSE_VIOLENCE);
// no attacks for stunnies -- just a check
if (ch->position < POS_RESTING)
return;
if (IS_NPC(ch))
{
mob_hit(ch,victim,dt);
return;
}
one_hit( ch, victim, dt, false );
if (ch->fighting != victim)
return;
if (IS_AFFECTED(ch,AFF_HASTE))
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 ( 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;
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,9);
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;
}
}
/**************************************************************************/
// 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 (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(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;
/*
* 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 (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 && 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("`cYou feel poison coursing through your veins.`x");
act("`c$n is poisoned by the venom on $p.`x",
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("`cThe poison on $p has worn off.`x",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("`c$p draws life from $N.`x",ch,wield,victim,TO_NOTVICT);
act_with_autodam_to_char("`c$p draws life from $N.`x",ch,wield,victim,dr);
dr=temp_hps-victim->hit;
act_with_autodam_to_char("`cYou feel $p drawing your life away.`x",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("`c$N is burned by $p.`x",ch,wield,victim,TO_NOTVICT);
act_with_autodam_to_char("`c$N is burned by $p.`x",ch,wield,victim,dr);
act_with_autodam_to_char("`c$p sears your flesh.`x",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("`c$p freezes $N.`x",ch,wield,victim,TO_NOTVICT);
act_with_autodam_to_char("`c$p freezes $N.`x",ch,wield,victim,dr);
act_with_autodam_to_char("`cThe cold touch of $p surrounds you with ice.`x",
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("`c$p draws mystical energy from $n.`x",victim,wield,NULL,TO_ROOM);
act("`cYou feel $p drawing your mystical energy away.`x",
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("`c$p saps the strength from $n.`x",victim,wield,NULL,TO_ROOM);
act("`cYou feel $p sapping your strength away.`x",
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("`cYou see stars as your head `Crings`x!%s",
autodamtext(victim, dr));
ch->printlnf("`cYour opponent looks `Bstunned`x!%s",
autodamtext(ch, dr));
DAZE_STATE(victim,UMAX(12,wield->level/4 + dam/20));
}
}
// 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("`c$N is struck by lightning from $p.`x",ch,wield,victim,TO_NOTVICT);
act_with_autodam_to_char("`c$N is struck by lightning from $p.`x",ch,wield,victim,dr);
act_with_autodam_to_char("`cYou are shocked by $p`x",victim,wield,NULL,dr);
shock_effect(victim,wield->level/2,dam,TARGET_CHAR);
}
}
tail_chain( );
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;
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 )
{
SET_BIT(ch->dyn,DYN_DOING_DAMAGE);
}
// 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{
// 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( "`cA tree suddenly transforms into $n.`x", ch, NULL, NULL, TO_ROOM );
ch->println( "`cYou assume your normal form.`x" );
}
if ( IS_SET( ch->affected_by2, AFF2_VANISH ))
{
REMOVE_BIT( ch->affected_by2, AFF2_VANISH );
affect_strip ( ch, gsn_vanish );
act( "`cA swirl of dust reveals $n.`x", ch, NULL, NULL, TO_ROOM );
ch->println( "`cYou shake the `#`Bfaerie-dust`^ from your body.`x" );
}
if ( IS_AFFECTED(ch, AFF_INVISIBLE) )
{
affect_strip( ch, gsn_invisibility );
affect_strip( ch, gsn_mass_invis );
REMOVE_BIT( ch->affected_by, AFF_INVISIBLE );
act( "`c$n fades into existence.`x", ch, NULL, NULL, TO_ROOM );
}
if ( IS_SET( ch->affected_by, AFF_HIDE)
|| IS_SET( ch->affected_by, AFF_INVISIBLE)
|| IS_SET( ch->affected_by, AFF_SNEAK))
{
REMOVE_BIT( ch->affected_by, AFF_HIDE );
REMOVE_BIT( ch->affected_by, AFF_INVISIBLE );
REMOVE_BIT( ch->affected_by, AFF_SNEAK );
act( "`c$n is revealed from the shadows.`x", 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;
// 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;
}
}
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);
}
// 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("`cYou are knocked from your mount!`x\r\n", victim, NULL, NULL, TO_CHAR);
act("`c$n is knocked from $s mount!`x\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("`cYou are knocked from your mount!`x\r\n", victim, NULL, NULL, TO_CHAR);
act("`c$n is knocked from %s mount!`x\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/2),gsn_fire_shield,DAM_FIRE,true);
}
if(is_affected(victim,gsn_chill_shield) && dt!=gsn_chill_shield){
damage(victim,ch,UMIN(ch->max_hit,dam/2),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/2),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/2),gsn_icy_armour,DAM_COLD,true);
}
}
if(100 * dam / victim->max_hit > (i = number_percent())){
bash_eq(victim,i);
}
update_pos(ch);
// Subdue System - Kalahn June 97, updated October 98
if (IS_SET(ch->dyn,DYN_CURRENT_SUBDUE) && !IS_AWAKE(victim)
&& ( IS_IMMORTAL(ch)
|| (number_percent()< UMAX(15,101-(GET_HITROLL(ch)/2)))
)
)
{
act( "`c$n appears to be subdued.`x", victim, NULL, NULL, TO_ROOM );
victim->println("`cYou have been subdued.`x");
if(!IS_NPC(victim) && !IS_SET(victim->act2, ACT2_PLR_ARENA)
// && !IS_SET(victim->act2, ACT2_PLR_EVENT)
){
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;
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( "`c$n is mortally wounded, and will die soon, if not aided.`x",
victim, NULL, NULL, TO_ROOM );
victim->println("`cYou are mortally wounded, and will die soon, if not aided.`x");
break;
case POS_INCAP:
act( "`c$n is incapacitated and will slowly die, if not aided.`x",
victim, NULL, NULL, TO_ROOM );
victim->println("`cYou are incapacitated and will slowly die, if not aided.`x");
break;
case POS_STUNNED:
act( "`c$n is stunned, but will probably recover.`x",
victim, NULL, NULL, TO_ROOM );
victim->println("You are stunned, but will probably recover.`x");
break;
case POS_DEAD:
act( "`c$n is DEAD!!`x", victim, 0, 0, TO_ROOM );
victim->println("You have been killed.`x");
/*Military Points gains & losses*/
if(!IS_NPC(ch) && !IS_NPC(victim))
{
int tempmps = 0;
if(victim->pcdata->military_points >= 10)
{
tempmps = victim->pcdata->military_points/4; /*used to store the military points lost when a player loses*/
victim->pcdata->military_points = victim->pcdata->military_points - tempmps;
ch->pcdata->military_points = ch->pcdata->military_points + tempmps;
victim->printlnf("`#`RYou have been defeated in combat!\n\r This has caused you to lose %d Military Points`^.", tempmps);
ch->printlnf("`#`RYou have defeated %s in combat!\n\r This has caused you to gain %d Military Points`^.", victim->name, tempmps);
}
else
{
tempmps = victim->pcdata->military_points;
victim->pcdata->military_points = 0;
ch->pcdata->military_points = ch->pcdata->military_points + tempmps;
victim->printlnf("`#`RYou have been defeated in combat!\n\r This has caused you to lose %d Military Points`^.", tempmps);
ch->printlnf("`#`RYou have defeated %s in combat!\n\r This has caused you to gain %d Military Points`^.", victim->name, tempmps);
}
if(victim->bounty > 0)
{
ch->gold += victim->bounty;
ch->printlnf("`cYou have collected a bounty of %d gold from %s.`x", victim->bounty, victim->name);
info_broadcast(ch,"%s has slain %s collecting a bounty of %d.", ch->name, victim->name, victim->bounty);
victim->bounty = 0;
}
}
break;
default:
if ( dam > victim->max_hit / 4 )
{
victim->println("`cThat caused you a lot of pain.`x");
}
if ( victim->hit < victim->max_hit / 4 )
{
victim->println("`RYou are bleeding a lot.`x");
}
break;
}
// Sleep spells and extremely wounded folks.
if ( !IS_AWAKE(victim) ){
stop_fighting( victim, false ); // Damage - not awake victim
}
// 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 ){
REMOVE_BIT(ch->dyn,DYN_DOING_DAMAGE);
return dam;
}
// Take care of link dead people.
if ( !IS_NPC(victim) && victim->desc == NULL )
{
if ( number_range( 0, victim->wait ) == 0
&& HAS_CONFIG(victim, CONFIG_AUTORECALL))
{
do_recall( victim, "" );
REMOVE_BIT(ch->dyn,DYN_DOING_DAMAGE);
return dam;
}
}
// Wimp out?
if ( IS_NPC(victim) && dam > 0 && victim->wait < PULSE_VIOLENCE / 2)
{
if ( ( IS_SET(victim->act, ACT_WIMPY) && number_bits( 2 ) == 0
&& victim->hit < victim->max_hit / 5)
|| ( IS_AFFECTED(victim, AFF_CHARM) && victim->master != NULL
&& victim->master->in_room != victim->in_room ) )
do_flee( victim, "" );
}
if ( !IS_NPC(victim)
&& victim->hit > 0
&& victim->hit <= victim->wimpy
&& victim->wait < PULSE_VIOLENCE / 2 )
do_flee( victim, "" );
if ( !IS_NPC(victim)
&& victim->hit > 0
&& victim->hit <= victim->pcdata->panic
&& victim->wait < PULSE_VIOLENCE / 2 )
{
victim->println("P A N I C ! ! !");
do_recall( victim, "" );
}
} // end of subdue else
REMOVE_BIT(ch->dyn,DYN_DOING_DAMAGE);
tail_chain( );
return dam;
}
/**************************************************************************/
// spells call this to inflict damage
// (dt = sn)
int damage_spell( char_data *ch, char_data *victim, int dam, int dt,
int dam_type, bool show )
{
// char buf[MSL];
int damount=damage( ch, victim, dam, dt, dam_type, show );
// code below in for monitoring reasons to fix up the AC system
/* sprintf(buf,"%3d, %3d, %3d, \"%s\", \"%s\", %3d, \"%s\", %3d, %d",
dt, dam, dam_type, skill_table[dt].name, ch->name, ch->level,
victim->name, victim->level, damount);
append_string_to_file( SPELL_DAMAGE_LOG,buf);
*/
return (damount);
}
/**************************************************************************/
bool is_safe(char_data *ch, char_data *victim)
{
char log_buf[MSL];
if (victim->in_room == NULL || ch->in_room == NULL)
return true;
if (victim->fighting == ch || victim == ch)
return false;
if (IS_IMMORTAL(ch) && ch->level > LEVEL_IMMORTAL)
return false;
if(!IS_NPC(ch) && !IS_NPC(victim) && GAMESETTING(GAMESET_PEACEFUL_MUD)){
ch->println("This is a peaceful mud... pkilling is not permitted.");
return true;
}
// unseen mobs
if ( !IS_IMMORTAL(ch) &&
IS_NPC(victim) && IS_SET(victim->act, ACT_IS_UNSEEN))
{
return true;
}
if( IS_NPC(victim) && IS_SET(victim->act2,ACT2_AVOIDS_ALL_ATTACKS) ){
ch->printlnf("`c%s cowers away from your attack.`x", PERS(victim, ch));
return true;
}
if( IS_KEEPER(victim) && !GAMESETTING2(GAMESET2_CAN_ATTACK_SHOPKEEPERS)){
ch->printlnf("`c%s cowers away from your attack.`x", PERS(victim, ch));
return true;
}
// safe rooms
if (IS_SET(victim->in_room->room_flags,ROOM_SAFE))
{
ch->println("`cNot in this room.`x");
return true;
}
// ooc rooms
if (IS_SET(victim->in_room->room_flags,ROOM_OOC))
{
ch->println("`cNot in an `BOOC `croom.`x");
return true;
}
// killing mobiles
if (IS_NPC(victim))
{
if( ch->level<6 || (!IS_LETGAINED(ch) && GAMESETTING_LETGAINING_IS_REQUIRED) ){
if ( IS_SET(victim->act, ACT_PET)
&& victim->leader
&& !IS_NPC(victim->leader)
&& (victim->leader->pet == victim)
&& IS_SET(victim->affected_by, AFF_CHARM))
{
ch->wrapln("`cThat is a players pet, which could start a pkill fight,`x "
"`csince you are either below level 6 or not letgained you can't`x "
"`cstart pkill combat.`x");
return true;
}
}
if (HAS_CONFIG(ch, CONFIG_DISALLOWED_PKILL))
{
if ( IS_SET(victim->act, ACT_PET)
&& victim->leader
&& !IS_NPC(victim->leader)
&& (victim->leader->pet == victim)
&& IS_SET(victim->affected_by, AFF_CHARM))
{
ch->wrapln("`cThat is a players pet, which could start a pkill fight,`x "
"`csince you are pkill restricted you can't start pkill combat.`x");
return true;
}
}
/* killing shopkeepers is now allowed */
/*if (victim->pIndexData->pShop != NULL)
*{
* ch->println("`cThe shopkeeper wouldn't like that.`x");
* return true;
*}
*/
/* killing healers, trainers, etc is now allowed */
/*
* if (IS_SET(victim->act,ACT_TRAIN)
* || IS_SET(victim->act,ACT_PRACTICE)
* || IS_SET(victim->act,ACT_IS_HEALER)
* || IS_SET(victim->act,ACT_IS_CHANGER))
* {
* ch->println("`cThe gods would not approve.`x");
* return true;
* }
*/
/* checks that players can't kill certain types of mobs */
if (!IS_NPC(ch))
{
/* no pets */
/* if (IS_SET(victim->act,ACT_PET))
* {
* act("`cThere is no point to killing someone's pet...`x",
* ch,NULL,victim,TO_CHAR);
* return true;
* }
*/
/* no charmed creatures unless owner */
/* if (IS_AFFECTED(victim,AFF_CHARM) && ch != victim->master)
{
ch->println("`cYou don't own that animal.`x");
return true;
}
*/
}
}
else // killing players
{
// being ordered to, and the master isn't letgained
if(IS_SET( ch->dyn, DYN_IS_BEING_ORDERED ) && ch->master)
{
if((ch->master->level<6) || (!IS_LETGAINED(ch->master) && GAMESETTING_LETGAINING_IS_REQUIRED) ){
// tell charmie
ch->println("`cYour master isn't letgained or above level 6.`x");
// tell master
ch->master->println("`cYou can not order a pet to pkill, steal from players etc,`x");
ch->master->println("`ctill level 6 and you have been letgained.`x");
ch->master->println("`c(See HELP DEATH and HELP LETGAIN)`x");
return true;
}
}
// NPC doing the killing
if (IS_NPC(ch))
{
// safe room check
if (IS_SET(victim->in_room->room_flags,ROOM_SAFE))
{
ch->println("`cNot in this room.`x");
return true;
}
// charmed mobs and pets cannot attack players while owned
if (IS_AFFECTED(ch,AFF_CHARM) && ch->master != NULL
&& ch->master->fighting != victim)
{
ch->println("`cPeople are your friends!`x");
return true;
}
}
else // player killing another player
{
if ((ch->level<6) || (!IS_LETGAINED(ch) && GAMESETTING_LETGAINING_IS_REQUIRED) ){
ch->println("`cYou can not player kill, steal from players etc,`x");
ch->println("`ctill level 6 and you have been letgained.`x");
ch->println("`c(See HELP DEATH and HELP LETGAIN)`x");
return true;
}
if(HAS_CONFIG(ch, CONFIG_DISALLOWED_PKILL))
{
ch->println("`cYou can not player kill, steal from players etc,`x");
ch->println("`cdue to a pkill restriction sorry.`x");
return true;
}
if(HAS_CONFIG2(ch,CONFIG2_NOPKILL)){
ch->println("You can't pkill others");
return true;
}
if(HAS_CONFIG2(victim,CONFIG2_NOPKILL)){
ch->println("`cA mysterious force prevents you from doing that.`x");
return true;
}
if(((victim->level<11))&&(ch->pkool>0))
{
ch->println("`cYou cannot kill the weak so soon after doing so.`x");
return true;
}
if(victim->pksafe>0)
{
//More arena allowance
if(IS_SET(victim->act2, ACT2_PLR_ARENA)){
victim->pksafe = 0;
return false;
}else{
ch->println("`cHe has died too recently, leave him alone.`x");
return true;
}
}
//added to stop non-clanned from killing or being killed
if(!victim->clan && !IS_SET(victim->in_room->room_flags, ROOM_ARENA))
{
ch->printlnf("`cYou cannot pkill someone that is not enlisted.`x");
return true;
}
if (!ch->clan && !IS_SET(ch->in_room->room_flags, ROOM_ARENA))
{
ch->printlnf("`cYou are not enlisted, therefore, you cannot pkill.`x");
return true;
}
if (!IS_NPC(ch) && !IS_NPC(victim)
&& !IS_SET(ch->act2, ACT2_PLR_ARENA)
&& !IS_SET(victim->act2, ACT2_PLR_ARENA)
// && !IS_SET(ch->act2, ACT2_PLR_EVENT)
// && !IS_SET(victim->act2, ACT2_PLR_EVENT)
)
{
sprintf( log_buf, "is_safe: %s might be starting a pkill fight with %s at %d!!!",
ch->name,
victim->name,
ch->in_room->vnum );
log_string( log_buf );
wiznet(log_buf,NULL,NULL,WIZ_BETA,0,0);
}
}
}
return false;
}
/**************************************************************************/
bool is_safe_spell(char_data *ch, char_data *victim, bool area )
{
if (victim->in_room == NULL || ch->in_room == NULL)
return true;
if (victim == ch && area){
return true;
}
if ( !IS_ICIMMORTAL(ch) &&
IS_NPC(victim) && IS_SET(victim->act, ACT_IS_UNSEEN))
{
return true;
}
if (victim->fighting == ch || victim == ch){
return false;
}
if(area)
{
if (ch->fighting!=victim && victim->fighting!=ch
&& !can_initiate_combat( ch, victim, CIT_GENERAL | CIT_SILENT))
{
return true;
}
}else{
if (ch->fighting!=victim && victim->fighting!=ch
&& !can_initiate_combat( ch, victim, CIT_GENERAL))
{
return true;
}
}
if (IS_ICIMMORTAL(ch) && !area){
return false;
}
// safe room?
if (IS_SET(victim->in_room->room_flags,ROOM_SAFE)){
return true;
}
if (HAS_CONFIG(ch, CONFIG_DISALLOWED_PKILL))
{
return true;
}
// killing mobiles
if (IS_NPC(victim))
{
if (victim->pIndexData->pShop != NULL)
return true;
// no killing healers, trainers, etc
if (IS_SET(victim->act,ACT_TRAIN)
|| IS_SET(victim->act,ACT_PRACTICE)
|| IS_SET(victim->act,ACT_IS_HEALER)
|| IS_SET(victim->act,ACT_IS_CHANGER))
return true;
if (!IS_NPC(ch))
{
// no pets
if (IS_SET(victim->act,ACT_PET))
return true;
// no charmed creatures unless owner
if (IS_AFFECTED(victim,AFF_CHARM) && (area || ch != victim->master))
return true;
// legal kill? -- cannot hit mob fighting non-group member
if (victim->fighting != NULL && !is_same_group(ch,victim->fighting))
return true;
}
else
{
// area effect spells do not hit other mobs
if (area && !is_same_group(victim,ch->fighting))
return true;
}
}
// killing players
else
{
if (area && IS_ICIMMORTAL(victim)){
return true;
}
if(HAS_CONFIG2(ch,CONFIG2_NOPKILL)){
return true;
}
if(HAS_CONFIG2(victim,CONFIG2_NOPKILL)){
return true;
}
// NPC doing the killing
if (IS_NPC(ch))
{
// charmed mobs and pets cannot attack players while owned
if (IS_AFFECTED(ch,AFF_CHARM) && ch->master != NULL
&& ch->master->fighting != victim)
return true;
// safe room?
if (IS_SET(victim->in_room->room_flags,ROOM_SAFE))
return true;
// legal kill? -- mobs only hit players grouped with opponent
if (ch->fighting != NULL && !is_same_group(ch->fighting,victim))
return true;
}
// player doing the killing
else
{
if(ch->level<11)
return true;
if(victim->pksafe>0)
return true;
if ((victim->level<11)&&(ch->pkool>0))
return true;
}
}
if (!IS_NPC(ch) && !IS_NPC(victim))
{
sprintf( log_buf, "is_safe_spell: %s might be starting a pkill fight with %s at %d!!!",
ch->name,
victim->name,
ch->in_room->vnum );
log_string( log_buf );
wiznet(log_buf,NULL,NULL,WIZ_BETA,0,0);
}
return false;
}
/**************************************************************************/
// Check for parry.
bool check_parry( char_data *ch, char_data *victim )
{
int chance;
if ( !IS_AWAKE(victim) )
return false;
chance = get_skill(victim,gsn_parry) / 2;
if ( get_eq_char( victim, WEAR_WIELD ) == NULL )
{
if (IS_NPC(victim))
chance /= 2;
else
return false;
}
if (!can_see(ch,victim))
chance /= 2;
if ( number_percent( ) >= chance + victim->level - ch->level )
return false;
act( "`cYou parry $n's attack.`x", ch, NULL, victim, TO_VICT );
act( "`c$n parries your attack.`x", victim, NULL, ch, TO_VICT );
check_improve(victim,gsn_parry,true,6);
return true;
}
/**************************************************************************/
// Check for shield block.
bool check_shield_block( char_data *ch, char_data *victim )
{
int chance;
if ( !IS_AWAKE(victim) )
return false;
chance = get_skill(victim,gsn_shield_block) / 5 + 3;
if ( get_eq_char( victim, WEAR_SHIELD ) == NULL )
return false;
if ( number_percent( ) >= chance + victim->level - ch->level )
return false;
act( "`cYou block $n's attack with your shield.`x",
ch, NULL, victim, TO_VICT );
act( "`c$n blocks your attack with a shield.`x",
victim, NULL, ch, TO_VICT );
check_improve(victim,gsn_shield_block,true,6);
return true;
}
/**************************************************************************/
// Check for dodge.
bool check_dodge( char_data *ch, char_data *victim )
{
int chance;
if ( !IS_AWAKE(victim) )
return false;
chance = get_skill(victim,gsn_dodge) / 2;
if (!can_see(victim,ch))
chance /= 2;
if ( number_percent( ) >= chance + victim->level - ch->level )
return false;
act( "`cYou dodge $n's attack.`x", ch, NULL, victim, TO_VICT);
act( "`c$n dodges your attack.`x", victim, NULL, ch, TO_VICT);
check_improve(victim,gsn_dodge,true,6);
return true;
}
/**************************************************************************/
// Set position of a victim based on their current hp
void update_pos( char_data *victim )
{
if ( !IS_NPC(victim)
&& victim->level >= LEVEL_IMMORTAL
&& victim->hit < 1 )
{
victim->hit = 1;
}
// GAMESET2_SHOPKEEPERS_CAN_BE_KILLED flag turned off
if(IS_KEEPER(victim)
&& !GAMESETTING2(GAMESET2_SHOPKEEPERS_CAN_BE_KILLED)
&& victim->hit < 1 )
{
victim->hit=20;
victim->max_hit+=20;
victim->level+=number_range(2,20);
victim->highest_level_to_do_damage+=10;
}
if ( victim->hit > 0 )
{
if ( victim->position <= POS_STUNNED )
victim->position = POS_STANDING;
return;
}
if ( IS_NPC(victim) && victim->hit < 1 )
{
victim->position = POS_DEAD;
return;
}
if ( victim->hit <= -11 )
{
victim->position = POS_DEAD;
return;
}
if ( victim->hit <= -6 ) victim->position = POS_MORTAL;
else if ( victim->hit <= -3 ) victim->position = POS_INCAP;
else victim->position = POS_STUNNED;
return;
}
/**************************************************************************/
// Start fights.
void set_fighting( char_data *ch, char_data *victim )
{
char buf[MSL];
OBJ_DATA *obj;
if(ch->fighting)
{
bug("Set_fighting: ch already fighting");
return;
}
if(!IS_NPC(ch))
{
// wizi imms wont start fighting on area attacks by PC's
if (!IS_SET(ch->dyn,DYN_DOING_DAMAGE) && INVIS_LEVEL(victim)> ch->level)
{
victim->println("`cYou dont return the attack, your wizi above them.`x");
return;
}
// unseen mobs wont attack the ch
if (IS_NPC(victim) && !IS_SET(ch->dyn,DYN_DOING_DAMAGE)
&& IS_SET(victim->act, ACT_IS_UNSEEN)
&& !HAS_HOLYLIGHT(ch))
{
victim->println("`cYou dont return the attack, your UNSEEN to them.`x");
return;
}
}
if( is_affected( ch, gsn_sneak )){
affect_strip( ch, gsn_sneak );
}
if( is_affected( victim, gsn_sneak )){
affect_strip( victim, gsn_sneak );
}
if( IS_AFFECTED(ch, AFF_SLEEP) ){
affect_strip( ch, gsn_sleep );
}
ch->fighting = victim;
ch->position = POS_FIGHTING;
// Auto draw weapons from sheathed to wield
if ( get_eq_char( ch, WEAR_WIELD ) == NULL
&& get_eq_char( ch, WEAR_SHEATHED ) != NULL )
{
obj = get_eq_char( ch, WEAR_SHEATHED );
equip_char( ch, obj, WEAR_WIELD );
act( "`cYou hastily draw $p.`x", ch, obj, NULL, TO_CHAR );
act( "`c$n hastily draws $p.`x", ch, obj, NULL, TO_ROOM );
WAIT_STATE( ch, PULSE_VIOLENCE );
}
if ( get_eq_char( victim, WEAR_WIELD ) == NULL
&& get_eq_char( victim, WEAR_SHEATHED ) != NULL )
{
obj = get_eq_char( victim, WEAR_SHEATHED );
equip_char( victim, obj, WEAR_WIELD );
act( "`cYou hastily draw $p.`x", victim, obj, NULL, TO_CHAR );
act( "`c$n hastily draws $p.`x", victim, obj, NULL, TO_ROOM );
WAIT_STATE( victim, PULSE_VIOLENCE );
}
if (TRUE_CH(ch)->pcdata && IS_SET(TRUE_CH(ch)->act,PLR_AUTOSUBDUE)){
SET_BIT(ch->dyn,DYN_CURRENT_SUBDUE);
ch->println("`cYou are subduing in this fight.`x");
}else{
REMOVE_BIT(ch->dyn,DYN_CURRENT_SUBDUE);
ch->println("`cYou are fighting to kill in this fight.`x");
}
// who started the fight and pksafeness stuff
if(IS_SET(ch->dyn,DYN_DOING_DAMAGE)
==IS_SET(victim->dyn,DYN_DOING_DAMAGE))
{
// check for mobprogs that trigger when someone starts combat
// with a spell, and the mobprog triggers a spell in return
// (this is only in the first round of combat)
if(IS_SET(ch->dyn,DYN_RUNNING_MOBPROG_CMD)){
// victim started the fight, ch is mobprog in return
logf("set_fighting(): ch->dyn,DYN_RUNNING_MOBPROG_CMD is true.");
logf("set_fighting(): victim (%s) started fight with %s, ch=%s",
victim->name,
victim->fighting?victim->fighting->name:"victim->fighting==NULL",
ch->name);
victim->pksafe=0;
}else if(IS_SET(victim->dyn,DYN_RUNNING_MOBPROG_CMD)){
// ch started the fight, victim is mobprog in return
logf("set_fighting(): victim->dyn,DYN_RUNNING_MOBPROG_CMD is true.");
logf("set_fighting(): ch (%s) started fight with %s, vict=%s",
ch->name,
ch->fighting?ch->fighting->name:"ch->fighting==NULL",
victim->name);
ch->pksafe=0;
}else{
bugf("set_fighting(): ch->dyn,DYN_DOING_DAMAGE "
"equals victim->dyn,DYN_DOING_DAMAGE)!");
if(!IS_NPC(ch) && !IS_NPC(victim)){
do_abort();
}
}
}else if(IS_SET(ch->dyn,DYN_DOING_DAMAGE)){
// ch started the fight
if(!IS_NPC(victim) || !IS_NPC(ch->fighting)){
logf("set_fighting(): ch (%s) started fight with %s, vict=%s",
ch->name, ch->fighting->name, victim->name);
SET_BIT(ch->dyn, DYN_STARTED_FIGHT);
REMOVE_BIT(victim->dyn, DYN_STARTED_FIGHT);
}
ch->pksafe=0;
}else{
// victim started the fight
if(!IS_NPC(ch) || (victim->fighting && !IS_NPC(victim->fighting))){
logf("set_fighting(): victim (%s) started fight with %s, ch=%s",
victim->name,
victim->fighting?victim->fighting->name:"victim->fighting==NULL",
ch->name);
SET_BIT(victim->dyn, DYN_STARTED_FIGHT);
REMOVE_BIT(ch->dyn, DYN_STARTED_FIGHT);
}
victim->pksafe=0;
}
// faults with mobs caused by bad use of olc checks only below here
// - WILL BE MOVED INTO ASAVE LATER PROBABLY
// check the level on both parties
if (victim->level==0)
{
sprintf( buf, "`1Victim = [%5d] %s (%s) `1Room = [%5d] %s"
"`1Attacker = %s`1"
"Note - victims level has been set to 90 after the fight",
IS_NPC(victim) ? victim->pIndexData->vnum : 0,
victim->short_descr, victim->name,
victim->in_room->vnum,
victim->in_room->name, ch->name);
victim->level=1;
if (IS_NPC(victim) && victim->pIndexData->level==0)
{
victim->pIndexData->level=90;
}
autonote(NOTE_SNOTE, "set_fighting()",
"victim->level==0", "olc" , buf, true);
SET_BIT( victim->pIndexData->area->olc_flags, OLCAREA_CHANGED );
}
if (ch->level==0)
{
sprintf( buf, "`1ch = [%5d] %s (%s) `1Room = [%5d] %s"
"`1Attacker = %s`1"
"Note - ch level has been set to 90 after the fight",
IS_NPC(ch) ? ch->pIndexData->vnum : 0,
ch->short_descr, ch->name,
ch->in_room->vnum,
ch->in_room->name, victim->name);
ch->level=1;
if (IS_NPC(ch) && ch->pIndexData->level==0)
{
ch->pIndexData->level=90;
}
autonote(NOTE_SNOTE, "set_fighting()",
"ch->level==0", "olc" , buf, true);
SET_BIT( ch->pIndexData->area->olc_flags, OLCAREA_CHANGED );
}
// check the max hp on both parties - note olc if there is a problem
if (victim->max_hit==0)
{
sprintf( buf, "`1Victim = [%5d] %s (%s) `1Room = [%5d] %s"
"`1Attacker = %s`1"
"Note - victims hitdice has been set to 1+1+(level*4) after the fight",
IS_NPC(victim) ? victim->pIndexData->vnum : 0,
victim->short_descr, victim->name,
victim->in_room->vnum,
victim->in_room->name, ch->name);
victim->max_hit=1;
if(IS_NPC(victim))
{
victim->pIndexData->hit[DICE_NUMBER] = 1;
victim->pIndexData->hit[DICE_TYPE] = 1;
victim->pIndexData->hit[DICE_BONUS] = victim->level*4;
}
autonote(NOTE_SNOTE, "set_fighting()",
"victim->max_hit==0", "olc" , buf, true);
SET_BIT( victim->pIndexData->area->olc_flags, OLCAREA_CHANGED );
}
if (ch->max_hit==0)
{
sprintf( buf, "`1Ch= [%5d] %s (%s) `1Room = [%5d] %s"
"`1Attacker = %s`1"
"Note - ch's hitdice has been set to 1+1+(level*4) after the fight",
IS_NPC(ch) ? ch->pIndexData->vnum : 0,
ch->short_descr, ch->name,
ch->in_room->vnum,
ch->in_room->name, victim->name);
ch->max_hit=1;
if(IS_NPC(ch))
{
ch->pIndexData->hit[DICE_NUMBER] = 1;
ch->pIndexData->hit[DICE_TYPE] = 1;
ch->pIndexData->hit[DICE_BONUS] = ch->level*4;
}
autonote(NOTE_SNOTE, "set_fighting()",
"ch->max_hit==0", "olc" , buf, true);
SET_BIT( ch->pIndexData->area->olc_flags, OLCAREA_CHANGED );
}
return;
}
/**************************************************************************/
// Stop fights.
void stop_fighting( char_data *ch, bool fBoth )
{
char_data *fch;
for ( fch = char_list; fch != NULL; fch = fch->next )
{
if ( fch == ch || ( fBoth && fch->fighting == ch ) )
{
fch->fighting = NULL;
//REMOVE_BIT(fch->dyn,DYN_CURRENT_SUBDUE);
REMOVE_BIT(fch->dyn,DYN_IS_CUTTING_OFF);
fch->position = IS_NPC(fch) ? fch->default_pos : POS_STANDING;
update_pos( fch );
}
}
return;
}
/**************************************************************************/
// Instantly decay a corpse - eg wraith called from make_corpse
void instant_decay_corpse(char_data *ch)
{
OBJ_DATA *obj;
OBJ_DATA *obj_next;
act( "`c$n disappears into thin air right before your eyes!`x", ch, NULL, NULL, TO_ROOM );
if ( IS_NPC(ch) )
{
if ( ch->gold > 0 )
{
obj_to_room( create_money( ch->gold, ch->silver ), ch->in_room );
act( "`cA pile of coins falls to the ground from the space\r\nonce occupied by $n.`x", ch, NULL, NULL, TO_ROOM );
ch->gold = 0;
ch->silver = 0;
}
}
else /* a player corpse */
{
if (ch->gold > 1 || ch->silver > 1)
{
obj_to_room( create_money( ch->gold/2, ch->silver/2 ), ch->in_room );
ch->gold -= ch->gold/2;
ch->silver -= ch->silver/2;
}
}
for ( obj = ch->carrying; obj != NULL; obj = obj_next )
{
bool floating = false;
obj_next = obj->next_content;
if (obj->wear_loc == WEAR_FLOAT)
floating = true;
obj_from_char( obj );
if (obj->item_type == ITEM_POTION)
obj->timer = number_range(500,1000);
if (obj->item_type == ITEM_SCROLL)
obj->timer = number_range(1000,2500);
if (IS_SET(obj->extra_flags,OBJEXTRA_ROT_DEATH) && !floating)
{
obj->timer = number_range(5,10);
REMOVE_BIT(obj->extra_flags,OBJEXTRA_ROT_DEATH);
}
REMOVE_BIT(obj->extra_flags,OBJEXTRA_VIS_DEATH);
if ( IS_SET( obj->extra_flags, OBJEXTRA_INVENTORY ) )
extract_obj( obj );
else if (floating)
{
if (IS_OBJ_STAT(obj,OBJEXTRA_ROT_DEATH)) /* get rid of it! */
{
if (obj->contains != NULL)
{
OBJ_DATA *in, *in_next;
act("`c$p evaporates,scattering its contents.`x",
ch,obj,NULL,TO_ROOM);
for (in = obj->contains; in != NULL; in = in_next)
{
in_next = in->next_content;
obj_from_obj(in);
obj_to_room(in,ch->in_room);
}
}
else
act("`c$p evaporates.`x", ch,obj,NULL,TO_ROOM);
extract_obj(obj);
}
else
{
act("`c$p falls to the floor.`x",ch,obj,NULL,TO_ROOM);
obj_to_room(obj,ch->in_room);
}
}
else
{
act("`c$p falls to the floor from the space\r\nonce occupied by $n.`x",ch,obj,NULL,TO_ROOM);
obj_to_room( obj, ch->in_room );
}
}
return;
}
/**************************************************************************/
// find the players morgue vnum in order of priority
// 1st - a manually set vnum *
// 2nd - clan morgue *
// 3rd - class morgue point*
// 4th - default racial morgue*
// 5th - gamewide default morgue
// * not yet implemented
int get_morguevnum(char_data *ch)
{
int vnum=game_settings->roomvnum_morgue;
if(get_room_index(class_table[ch->clss].morgue)){
vnum=class_table[ch->clss].morgue;
} else if(get_room_index(race_table[ch->race]->morgue)){
vnum=race_table[ch->race]->morgue;
}
return vnum;
};
/**************************************************************************/
void do_save_corpses(char_data *ch, char *);
/**************************************************************************/
// Make a corpse out of a character.
void make_corpse( char_data *ch, char_data *killer )
{
char *killed_by;
if ( ch == killer ){
killed_by = "someone";
}else{
killed_by = killer->short_descr;
}
char buf[MSL];
OBJ_DATA *corpse;
OBJ_DATA *obj;
OBJ_DATA *obj_next;
char *name;
bool keeper;
ROOM_INDEX_DATA *target_room=NULL;
if(GAMESETTING(GAMESET_MORGUE_ENABLED) && !IS_NPC(ch)
&& (!killer || (killer!=ch && IS_NPC(killer) && !killer->master)) )
{
target_room=get_room_index(get_morguevnum(ch));
if(!target_room){
// if you dont specify the morgue room,
// the corpse goes to the room they appear in after death.
target_room=get_room_index(race_table[ch->race]->death_room);
}
}
if(!target_room){
target_room=ch->in_room;
}
// reduce money on shopkeeper corpses to stop
// people killing the shopkeepers for money
keeper = IS_KEEPER(ch);
if (keeper)
{
if (ch->gold>5 || ch->silver>500 )
{
if (ch->gold>5)
{
ch->gold= number_range(1,5);
}
else
{
ch->gold= number_range(1,ch->gold);
}
if (ch->silver>500)
{
ch->silver=number_range(1,500);
}
else
{
ch->silver=number_range(1,ch->silver);
}
}
}
if (IS_SET(ch->form, FORM_INSTANT_DECAY))
{
instant_decay_corpse(ch);
return;
}
if ( IS_NPC(ch) )
{
name = ch->short_descr;
corpse = create_object(get_obj_index(OBJ_VNUM_CORPSE_NPC));
corpse->timer = number_range( 3, 6 );
if ( ch->gold > 0 || ch->silver > 0 )
{
obj_to_obj( create_money( ch->gold, ch->silver ), corpse );
ch->gold = 0;
ch->silver = 0;
}
//corpse->cost = 0;
corpse->cost = ch->level * number_range(3,4);
replace_string(corpse->killer, killed_by );
}
else // a player corpse
{
name = ch->short_descr;
if (ch->master){
stop_follower(ch);
}
corpse = create_object(get_obj_index(OBJ_VNUM_CORPSE_PC));
corpse->timer = number_range( 35, 50 );
corpse->killer = str_dup( killed_by );
if (!is_clan(ch)){
replace_string(corpse->owner, ch->name);
}else{
corpse->owner = NULL;
if (ch->gold > 1 || ch->silver > 1){
obj_to_obj(create_money(ch->gold / 2, ch->silver/2), corpse);
ch->gold -= ch->gold/2;
ch->silver -= ch->silver/2;
}
}
corpse->cost = 0;
}
corpse->level = 0;
sprintf( buf, corpse->short_descr, name );
replace_string( corpse->short_descr, buf );
sprintf( buf, corpse->description, name );
replace_string( corpse->description, buf);
for ( obj = ch->carrying; obj != NULL; obj = obj_next )
{
bool floating = false;
obj_next = obj->next_content;
// dont take tokens out of the players inventory
// extract_char() handles the destruction of
// dropdeath tokens (obj->value[0], TOKEN_DROPDEATH)
if (obj->item_type == ITEM_TOKEN){
continue;
}
if (obj->wear_loc == WEAR_FLOAT){
floating = true;
}
obj_from_char( obj );
if (obj->item_type == ITEM_POTION){
obj->timer = number_range(500,1000);
}
if (obj->item_type == ITEM_SCROLL){
obj->timer = number_range(1000,2500);
}
if (IS_SET(obj->extra_flags,OBJEXTRA_ROT_DEATH) && !floating){
obj->timer = number_range(5,10);
REMOVE_BIT(obj->extra_flags,OBJEXTRA_ROT_DEATH);
}
REMOVE_BIT(obj->extra_flags,OBJEXTRA_VIS_DEATH);
// shop keepers
if (keeper){
if (number_range(1,10)<2){
obj->timer = number_range(2,5);
}else{
extract_obj(obj);
continue;
}
}
if( IS_SET( obj->extra_flags, OBJEXTRA_INVENTORY )){
extract_obj( obj );
}else{
if (floating)
{
if (IS_OBJ_STAT(obj,OBJEXTRA_ROT_DEATH)) // get rid of it!
{
if (obj->contains != NULL)
{
OBJ_DATA *in, *in_next;
act("`c$p evaporates,scattering its contents.`x", ch,obj,NULL,TO_ROOM);
for (in = obj->contains; in != NULL; in = in_next)
{
in_next = in->next_content;
obj_from_obj(in);
obj_to_room(in,target_room);
}
}
else
{
act("`c$p evaporates.`x", ch,obj,NULL,TO_ROOM);
}
extract_obj(obj);
}
else
{
act("`c$p falls to the floor.`x",ch,obj,NULL,TO_ROOM);
obj_to_room(obj,target_room);
}
}
else
{
obj_to_obj( obj, corpse );
}
}
}
obj_to_room( corpse, target_room );
// if it is a player, resave the corpses
if(!IS_NPC(ch)){
do_save_corpses(NULL, "");
}
return;
}
/**************************************************************************/
// Improved Death_cry contributed by Diavolo.
void death_cry( char_data *ch, char_data *killer )
{
ROOM_INDEX_DATA *was_in_room;
char *msg;
int door;
int vnum;
// no death cry at this stage for a vanishing body
if (IS_SET(ch->form, FORM_INSTANT_DECAY))
{
return;
}
vnum = 0;
msg = "`cYou hear $n's death cry.`x";
switch ( number_bits(4))
{
case 0: msg = "`c$n hits the ground ... DEAD.`x";
break;
case 1:
if (ch->material == 0)
{
msg = "`c$n splatters blood on your armor.`x";
break;
}
case 2:
if (IS_SET(ch->parts,PART_GUTS))
{
msg = "`c$n spills $s guts all over the floor.`x";
vnum = OBJ_VNUM_GUTS;
}
break;
case 3:
if (IS_SET(ch->parts,PART_HEAD))
{
msg = "`c$n's severed head plops on the ground.`x";
vnum = OBJ_VNUM_SEVERED_HEAD;
}
break;
case 4:
if (IS_SET(ch->parts,PART_HEART))
{
msg = "`c$n's heart is torn from $s chest.`x";
vnum = OBJ_VNUM_TORN_HEART;
}
break;
case 5:
if (IS_SET(ch->parts,PART_ARMS))
{
msg = "`c$n's arm is sliced from $s dead body.`x";
vnum = OBJ_VNUM_SLICED_ARM;
}
break;
case 6:
if (IS_SET(ch->parts,PART_LEGS))
{
msg = "`c$n's leg is sliced from $s dead body.`x";
vnum = OBJ_VNUM_SLICED_LEG;
}
break;
case 7:
if (IS_SET(ch->parts,PART_BRAINS))
{
msg = "`c$n's head is shattered, and $s brains splash all over you.`x";
vnum = OBJ_VNUM_BRAINS;
}
}
if ( vnum != 0 )
{
char buf[MSL];
OBJ_DATA *obj;
char *name;
name = ch->short_descr;
obj = create_object( get_obj_index( vnum ));
obj->timer = number_range( 4, 7 );
sprintf( buf, obj->short_descr, name );
free_string( obj->short_descr );
obj->short_descr = str_dup( buf );
sprintf( buf, obj->description, name );
free_string( obj->description );
obj->description = str_dup( buf );
if (obj->item_type == ITEM_FOOD)
{
if (IS_SET(ch->form,FORM_POISON))
obj->value[3] = 1;
else if (!IS_SET(ch->form,FORM_EDIBLE))
obj->item_type = ITEM_TRASH;
}
obj_to_room( obj, ch->in_room );
}
if ( number_range(1,100) <= get_skill(killer, gsn_stifle ))
{
act( "`cYou managed to kill $N before they could let out a final cry.`x", killer, NULL, ch, TO_CHAR );
check_improve(ch,gsn_stifle,true,3);
return;
}
act( msg, ch, NULL, NULL, TO_ROOM );
// if ( IS_NPC(ch) )
if ( IS_SET( ch->form, FORM_SENTIENT )
|| !IS_NPC(ch))
msg = "`cYou hear someone's death cry`x";
else
msg = "`cYou hear something's death cry`x";
was_in_room = ch->in_room;
if (was_in_room==NULL){
return;
}
for ( door = 0; door < MAX_DIR; door++ )
{
EXIT_DATA *pexit;
char tempmsg[MIL];
sprintf( tempmsg, "%s from %s.", msg, death_cry_dir_name[rev_dir[door]]);
if ( ( pexit = was_in_room->exit[door] ) != NULL
&& pexit->u1.to_room != NULL
&& pexit->u1.to_room != was_in_room )
{
ch->in_room = pexit->u1.to_room;
act( tempmsg, ch, NULL, NULL, TO_ROOM );
}
}
ch->in_room = was_in_room;
return;
}
/**************************************************************************/
void raw_kill( char_data *victim, char_data *killer )
{
int i;
stop_fighting( victim, true ); //Raw_kill
death_cry( victim, killer );
if (victim->mounted_on)
dismount(victim);
if (victim->ridden_by)
{
victim->ridden_by->println("`cYour mount has been killed, you fall to the ground!`x");
dismount(victim->ridden_by);
}
make_corpse( victim, killer );
victim->pksafe=30;
if(GAMESETTING5(GAMESET5_DEDICATED_PKILL_STYLE_MUD)){
victim->pksafe=3;
if(victim->gold<400){
victim->gold+=number_range(40,400);
victim->println("`GYOUR GOLD HAS BEEN BOOSTED UP.`x");
}
victim->pknoquit=2;
victim->println("`YYOU ARE PK SAFE FOR 3 MINUTES!!!. PKNOQUIT AT 2MINS :)`x");
}else{
victim->pknoquit=0;
}
victim->pknorecall=0;
if ( IS_NPC(victim) )
{
victim->pIndexData->killed++;
kill_table[URANGE(0, victim->level, MAX_LEVEL-1)].killed++;
extract_char( victim, true );
return;
}
extract_char( victim, false );
while ( victim->affected ){
affect_remove( victim, victim->affected );
}
victim->affected_by = race_table[victim->race]->aff;
victim->subdued = false;
for (i = 0; i < 4; i++){
victim->armor[i]= 100;
}
victim->position = POS_RESTING;
victim->hit = UMAX( 1, victim->hit );
victim->mana = UMAX( 1, victim->mana );
victim->move = UMAX( 1, victim->move );
reset_char(victim); // easiest way to fix problems with death bugs
landchar(victim); // make sure they die on the ground
save_char_obj(victim);
return;
}
/**************************************************************************/
void group_bypass_killer_penatly(char_data *killer, char_data *victim, bool death)
{
assert(!IS_NPC(victim));
bool bypass_duel_used=false;
char_data *gch;
if(GAMESETTING2(GAMESET2_BYPASSDUEL_REDUCES_KARNS)){
for ( gch = killer->in_room->people; gch; gch = gch->next_in_room )
{
if ( !IS_NPC(gch) && gch->fighting==victim && is_same_group( gch, killer))
{
if(gch->duels){
if(gch->duels->is_bypassingduel(victim)){
bool lose_karn=false;
bypass_duel_used=true;
if(death){ // lose a karn
lose_karn=true;
}else{ // lose a karn some of the time
gch->duel_subdues_before_karn_loss--;
if(gch->duel_subdues_before_karn_loss<0){
lose_karn=true;
gch->duel_subdues_before_karn_loss=4;
}
}
if(lose_karn){
gch->pcdata->karns--;
if(GAMESETTING(GAMESET_NOPERMDEATH) && victim->pcdata->karns<0){
victim->pcdata->karns=0;
}
if(gch->pcdata->karns<0) // if they had a karn to lose
{
gch->println(
"`xFrom within your body you feel a `Rburning sensation`x from within,\r\n"
"a ball of light departs from your body and disappears!");
}else{
gch->println(
"`xFrom within your body you feel a `Rburning sensation`x from within,\r\n"
"you collapse to the ground, and pass out.");
}
save_char_obj(gch);
}
}
}
}
}
}
// tell all those who are required to write a pknote to do so
/*pkill_note_required_message(victim, victim, bypass_duel_used);
for ( gch = killer->in_room->people; gch; gch = gch->next_in_room )
{
if ( !IS_NPC(gch) && gch->fighting==victim && is_same_group( gch, killer))
{
pkill_note_required_message(gch, victim, bypass_duel_used);
}
}*/
}
/**************************************************************************/
// calculate the maximum level in a group attacking a victim
int group_max_level_attacking_victim(char_data *killer, char_data *victim )
{
int max_level = 0;
char_data *gch;
for ( gch = killer->in_room->people; gch; gch = gch->next_in_room )
{
if ( is_same_group( gch, killer)
&& gch->fighting==victim
&& max_level<gch->level)
{
max_level=gch->level;
}
}
return max_level;
}
/**************************************************************************/
void group_gain( char_data *ch, char_data *victim )
{
char_data *gch;
char_data *lch;
int xp;
int members;
int group_levels;
int max_group_level;
/*
* Monsters don't get kill xp's or alignment changes.
* P-killing doesn't help either.
* Dying of mortal wounds or poison doesn't give xp to anyone!
*/
if ( victim == ch )
return;
// no xp gained for pkilling
if(!IS_NPC(victim)){
return;
}
if ( !ch || !ch->in_room || !victim)
{
if (!ch){
bug("group_gain(): ch == NULL!");
}else{
if (!ch->in_room){
bug("group_gain(): ch->in_room == NULL!");
}else{
bug("group_gain(): victim == NULL!");
}
}
return;
}
members = 0;
group_levels = 0;
max_group_level= 0; // max level in killer group
for ( gch = ch->in_room->people; gch; gch = gch->next_in_room )
{
if ( is_same_group( gch, ch ) )
{
if( victim->level<11 && !IS_NPC(ch) && !IS_NPC(victim)
&& !IS_LETGAINED(victim) && GAMESETTING_LETGAINING_IS_REQUIRED )
{
if(!GAMESETTING5(GAMESET5_DEDICATED_PKILL_STYLE_MUD)){
gch->pkool+=4000;
}
}
// if it isn't a mount being ridden then include it
if(!IS_MOUNTED(gch)){
members++;
group_levels += IS_NPC(gch) ? gch->level / 2 : gch->level;
max_group_level=UMAX(max_group_level, gch->level);
}
}
}
if ( members == 0 ){
bug("Group_gain: members=0.");
members=1;
group_levels=ch->level;
max_group_level=ch->level;
}
lch = (ch->leader != NULL) ? ch->leader : ch;
for ( gch = ch->in_room->people; gch != NULL; gch = gch->next_in_room )
{
OBJ_DATA *obj;
OBJ_DATA *obj_next;
if ( !is_same_group( gch, ch ) || IS_NPC(gch)){
continue;
}
/* Taken out, add it back if you want it
if ( gch->level - lch->level >= 5 )
{
gch->println("`cYour level is too high for this group.`x");
continue;
}
if ( gch->level - lch->level <= -5 )
{
gch->println("`cYour level is too low for this group.`x");
continue;
}
*/
xp = xp_compute( gch, victim, group_levels);
// Kal Jan 2004, based on Ixliam's code
if(GAMESETTING5(GAMESET5_ADDICT_XP_BONUS)){
char_data *tempch, *addict=NULL;
for ( tempch= player_list; tempch; tempch= tempch->next_player)
{
if ( !IS_IMMORTAL(tempch)
&& tempch->level>10
&& !IS_OOC(tempch)
&& tempch->idle<2)
{
addict=tempch;
}
}
if(xp && addict && gch && addict== gch && dice(1,4)==1)
{
gch->println("`cYou gain an addict bonus.`x");
// give xp in range (xp+1) and (xp+1)*150%
// to the player who has been on the longest
xp = number_range(xp+1, (xp+1)*3/2);
}
}
if(IS_SET(gch->comm, COMM_BUILDING)){
gch->printlnf("`=\xa6If you weren't in building mode "
"you would receive %d xp.`x", xp );
}else{
gch->printlnf("`cYou receive %d experience points.`x", xp );
int bonus;
bonus = xp;
if (double_exp)
{
xp += bonus;
ch->printlnf("`cExpierence gains are doubled, you get %d bonus expienece points.`x", bonus );
}
gain_exp(gch, xp);
}
if (!IS_IMMORTAL( ch )) {
for ( obj = ch->carrying; obj != NULL; obj = obj_next )
{
obj_next = obj->next_content;
if ( obj->wear_loc == WEAR_NONE )
continue;
if ( ( IS_OBJ_STAT(obj, OBJEXTRA_ANTI_EVIL) && IS_EVIL(ch) )
|| ( IS_OBJ_STAT(obj, OBJEXTRA_ANTI_GOOD) && IS_GOOD(ch) )
|| ( IS_OBJ_STAT(obj, OBJEXTRA_ANTI_NEUTRAL) && IS_NEUTRAL(ch))
|| ( IS_OBJ2_STAT(obj, OBJEXTRA2_ANTI_CHAOS) && IS_TEND_CHAOTIC(ch))
|| ( IS_OBJ2_STAT(obj, OBJEXTRA2_ANTI_LAW) && IS_TEND_LAWFUL(ch))
|| ( IS_OBJ2_STAT(obj, OBJEXTRA2_ANTI_BALANCE) && IS_TEND_NEUTRAL(ch)))
{
act( "`cYou are zapped by $p.`x", ch, obj, NULL, TO_CHAR );
act( "`c$n is zapped by $p.`x", ch, obj, NULL, TO_ROOM );
obj_from_char( obj );
obj_to_room( obj, ch->in_room );
}
}
}
}
return;
}
/**************************************************************************/
/*
* Compute xp for a kill.
* Also adjust alignment of killer.
* Edit this function to change xp computations.
*/
int xp_compute( char_data *gch, char_data *victim, int total_levels)
{
char buf[MSL];
int xp,base_exp;
int level_range;
int level;
int lower_xp_level;
// abort the whole process if we can
if( victim->no_xp // mob previously subdued
|| IS_NPC(gch) // mobs dont get xp
|| gch->pcdata->xp_penalty>0 // player still has an outstanding xp penalty
|| IS_AFFECTED(gch, AFF_CHARM)){ // charmed player
return 0;
}
level=gch->level;
lower_xp_level=victim->highest_level_to_do_damage-8;
if(level<lower_xp_level){
level= lower_xp_level + (lower_xp_level - level);
}
level_range = victim->level - level;
// compute the base exp
switch (level_range)
{
default : base_exp = 0; break;
case -9 : base_exp = 1; break;
case -8 : base_exp = 2; break;
case -7 : base_exp = 5; break;
case -6 : base_exp = 10; break;
case -5 : base_exp = 12; break;
case -4 : base_exp = 13; break;
case -3 : base_exp = 15; break;
case -2 : base_exp = 17; break;
case -1 : base_exp = 19; break;
case 0 : base_exp = 20; break;
case 1 : base_exp = 25; break;
case 2 : base_exp = 55; break;
case 3 : base_exp = 75; break;
case 4 : base_exp = 80; break;
}
if (level_range > 4){
base_exp = 80 + 7 * (level_range - 4);
}
xp = base_exp;
// calculate exp multiplier
if(IS_NPC(victim)){
xp = xp * victim->pIndexData->xp_mod / 100;
}
// do alignment computations
if (IS_GOOD(gch)){
if (IS_EVIL(victim))
xp*=14/10;
else if (IS_NEUTRAL(victim))
xp*=12/10;
}else if (IS_NEUTRAL(gch)){
if (IS_EVIL(victim))
xp*=12/10;
else if (IS_GOOD(victim))
xp*=12/10;
}else if (IS_EVIL(gch)){
if (IS_NEUTRAL(victim))
xp*=115/100;
else
if (IS_GOOD(victim))
xp*=13/10;
}
// more exp at the low levels
if (level < 6){
xp = 10 * xp / (level + 2);
}
// reduced xp percent system
iShowing the first 100 KB of 181.5 KB. Download the archive for the full file.