fight.c
toc/code/fight.c · 337.6 KB
From the archive fear2.1.3.tar.gz
Download the archive « Back to the archive contents
/****************************************************************************
* [S]imulated [M]edieval [A]dventure multi[U]ser [G]ame | \\._.// *
* -----------------------------------------------------------| (0...0) *
* SMAUG 1.4 (C) 1994, 1995, 1996, 1998 by Derek Snider | ).:.( *
* -----------------------------------------------------------| {o o} *
* SMAUG code team: Thoric, Altrag, Blodkai, Narn, Haus, | / ' ' \ *
* Scryn, Rennard, Swordbearer, Gorog, Grishnakh, Nivek, |~'~.VxvxV.~'~*
* Tricops and Fireblade | *
* ------------------------------------------------------------------------ *
* Merc 2.1 Diku Mud improvments copyright (C) 1992, 1993 by Michael *
* Chastain, Michael Quan, and Mitchell Tse. *
* Original Diku Mud copyright (C) 1990, 1991 by Sebastian Hammer, *
* Michael Seifert, Hans Henrik St{rfeldt, Tom Madsen, and Katja Nyboe. *
* ------------------------------------------------------------------------ *
* Battle & death module *
****************************************************************************/
#include <sys/types.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include "mud.h"
extern char lastplayercmd[MIL];
extern CHAR_DATA *gch_prev;
extern int barena;
int blockdam;
int g_tohit;
int g_roll;
int g_lowtohit;
int g_hitohit;
/*
* Local functions.
*/
void new_dam_message args((CHAR_DATA * ch, CHAR_DATA * victim, int dam, int dt, OBJ_DATA * obj, int spec, int limb));
void death_cry args((CHAR_DATA * ch));
void group_gain args((CHAR_DATA * ch, CHAR_DATA * victim));
int xp_compute args((CHAR_DATA * gch, CHAR_DATA * victim));
int align_compute args((CHAR_DATA * gch, CHAR_DATA * victim));
ch_ret one_hit args((CHAR_DATA * ch, CHAR_DATA * victim, int dt, int limb));
int obj_hitroll args((OBJ_DATA * obj));
void show_condition args((CHAR_DATA * ch, CHAR_DATA * victim));
/*
* Check to see if player's attacks are (still?) suppressed
* #ifdef TRI
*/
bool is_attack_supressed(CHAR_DATA * ch)
{
TIMER *timer;
if (IS_NPC(ch))
return FALSE;
timer = get_timerptr(ch, TIMER_ASUPRESSED);
if (!timer)
return FALSE;
/* perma-supression -- bard? (can be reset at end of fight, or spell, etc) */
if (timer->value == -1)
return TRUE;
/* this is for timed supressions */
if (timer->count >= 1)
return TRUE;
return FALSE;
}
int get_empty_limb(CHAR_DATA *victim)
{
int limb;
if(get_eq_char(victim, WEAR_NECK) == NULL)
{
limb = LM_NECK;
return limb;
}
if(get_eq_char(victim, WEAR_HEAD) == NULL)
{
limb = LM_HEAD;
return limb;
}
if(get_eq_char(victim, WEAR_BODY) == NULL)
{
limb = LM_BODY;
return limb;
}
if(get_eq_char(victim, WEAR_ARM_R) == NULL)
{
limb = LM_RARM;
return limb;
}
if(get_eq_char(victim, WEAR_ARM_L) == NULL)
{
limb = LM_LARM;
return limb;
}
if(get_eq_char(victim, WEAR_LEG_R) == NULL)
{
limb = LM_RLEG;
return limb;
}
if(get_eq_char(victim, WEAR_LEG_L) == NULL)
{
limb = LM_LLEG;
return limb;
}
return -1;
}
int get_random_limb(CHAR_DATA *victim, int rnum)
{
int limb = LM_BODY;
if(rnum == 1)
limb = LM_RARM;
if(rnum == 2)
limb = LM_LARM;
if(rnum == 3)
limb = LM_RLEG;
if(rnum == 4)
limb = LM_LLEG;
if(rnum == 5)
limb = LM_BODY;
if(rnum == 6)
limb = LM_HEAD;
if(rnum == 7)
limb = LM_NECK;
return limb;
}
int get_weapon_limb(CHAR_DATA *victim)
{
int limb;
if (IS_NPC(victim))
return -1;
if (get_eq_char(victim, WEAR_WIELD) != NULL)
{
if (victim->pcdata->righthanded == 1)
limb = LM_RARM;
else
limb = LM_LARM;
return limb;
}
else
return -1;
}
int get_tohit_diff(CHAR_DATA *ch, CHAR_DATA *victim, int wear, int type)
{
OBJ_DATA *weapon;
OBJ_DATA *armor;
int bashmod = 0;
int slashmod = 0;
int stabmod = 0;
weapon = get_eq_char(ch, WEAR_WIELD);
if (!weapon)
{
bashmod += ch->tohitbash;
stabmod += ch->tohitstab;
slashmod += ch->tohitslash;
}
else
{
bashmod += weapon->value[7];
stabmod += weapon->value[9];
slashmod += weapon->value[8];
}
armor = get_eq_char(victim, wear);
if (!armor && IS_NPC(victim))
{
bashmod -= victim->armor;
stabmod -= victim->armor;
slashmod -= victim->armor;
}
else if (armor)
{
bashmod -= armor->value[0];
stabmod -= armor->value[2];
slashmod -= armor->value[1];
}
if (bashmod > stabmod && bashmod > slashmod)
{
if (type == 1)
return bashmod;
else
return GRIP_BASH;
}
if (stabmod > bashmod && stabmod > slashmod)
{
if (type == 1)
return stabmod;
else
return GRIP_STAB;
}
if (slashmod > stabmod && slashmod > bashmod)
{
if (type == 1)
return slashmod;
else
return GRIP_SLASH;
}
if (bashmod == slashmod || bashmod == stabmod)
{
if (type == 1)
return bashmod;
else
return GRIP_BASH;
}
if (stabmod == slashmod)
{
if (type == 1)
return slashmod;
else
return GRIP_SLASH;
}
if (type == 1)
return -30;
else
return GRIP_BASH;
}
int get_best_grip(CHAR_DATA *ch, CHAR_DATA *victim)
{
int grip = GRIP_BASH;
int diff = -30;
grip = get_tohit_diff(ch, victim, WEAR_NECK, 2);
diff = get_tohit_diff(ch, victim, WEAR_NECK, 1);
if (get_tohit_diff(ch, victim, WEAR_HEAD, 1) > diff)
{
diff = get_tohit_diff(ch, victim, WEAR_HEAD, 1);
grip = get_tohit_diff(ch, victim, WEAR_HEAD, 2);
}
if (get_tohit_diff(ch, victim, WEAR_ARM_R, 1) > diff)
{
diff = get_tohit_diff(ch, victim, WEAR_ARM_R, 1);
grip = get_tohit_diff(ch, victim, WEAR_ARM_R, 2);
}
if (get_tohit_diff(ch, victim, WEAR_ARM_L, 1) > diff)
{
diff = get_tohit_diff(ch, victim, WEAR_ARM_L, 1);
grip = get_tohit_diff(ch, victim, WEAR_ARM_L, 2);
}
if (get_tohit_diff(ch, victim, WEAR_LEG_R, 1) > diff)
{
diff = get_tohit_diff(ch, victim, WEAR_LEG_R, 1);
grip = get_tohit_diff(ch, victim, WEAR_LEG_R, 2);
}
if (get_tohit_diff(ch, victim, WEAR_LEG_L, 1) > diff)
{
diff = get_tohit_diff(ch, victim, WEAR_LEG_L, 1);
grip = get_tohit_diff(ch, victim, WEAR_LEG_L, 2);
}
if (get_tohit_diff(ch, victim, WEAR_BODY, 1) > diff)
{
diff = get_tohit_diff(ch, victim, WEAR_BODY, 1);
grip = get_tohit_diff(ch, victim, WEAR_BODY, 2);
}
return grip;
}
int get_best_diff(CHAR_DATA *ch, CHAR_DATA *victim, int type)
{
int diff = -30;
int limb = LM_BODY;
diff = get_tohit_diff(ch, victim, WEAR_NECK, 1);
limb = LM_NECK;
if (get_tohit_diff(ch, victim, WEAR_HEAD, 1) > diff)
{
diff = get_tohit_diff(ch, victim, WEAR_HEAD, 1);
limb = LM_HEAD;
}
if (get_tohit_diff(ch, victim, WEAR_ARM_R, 1) > diff)
{
diff = get_tohit_diff(ch, victim, WEAR_ARM_R, 1);
limb = LM_RARM;
}
if (get_tohit_diff(ch, victim, WEAR_ARM_L, 1) > diff)
{
diff = get_tohit_diff(ch, victim, WEAR_ARM_L, 1);
limb = LM_LARM;
}
if (get_tohit_diff(ch, victim, WEAR_LEG_R, 1) > diff)
{
diff = get_tohit_diff(ch, victim, WEAR_LEG_R, 1);
limb = LM_RLEG;
}
if (get_tohit_diff(ch, victim, WEAR_LEG_L, 1) > diff)
{
diff = get_tohit_diff(ch, victim, WEAR_LEG_L, 1);
limb = LM_LLEG;
}
if (get_tohit_diff(ch, victim, WEAR_BODY, 1) > diff)
{
diff = get_tohit_diff(ch, victim, WEAR_BODY, 1);
limb = LM_BODY;
}
if (type == 1)
return diff;
else
return limb;
}
void do_emptycorpses(CHAR_DATA *ch, char *argument)
{
OBJ_DATA *corpse;
OBJ_DATA *contents;
OBJ_DATA *next_content;
for (corpse = ch->in_room->first_content; corpse; corpse = corpse->next_content)
{
if (IN_SAME_ROOM_OBJ(ch, corpse))
{
if (corpse->item_type == ITEM_CORPSE_NPC)
{
for (contents = corpse->first_content; contents; contents = next_content)
{
next_content = contents->next_content;
obj_from_obj(contents);
obj_to_room(contents, ch->in_room, ch);
}
}
}
}
send_to_char("All NPC corpses in this room are now empty.\n\r", ch);
return;
}
/* Target Limb choosing function */
int target_chooser(CHAR_DATA * ch, CHAR_DATA * victim )
{
int mobint, mobwis, rnum, limb;
OBJ_DATA *weapon;
int diff;
/*
LM_RARM
LM_LARM
LM_RLEG
LM_LLEG
LM_BODY
LM_HEAD
LM_NECK
*/
mobint = get_curr_int(ch);
mobwis = get_curr_wis(ch);
if ((ch->pIndexData->vnum >= OVERLAND_LOW_MOB && ch->pIndexData->vnum <= OVERLAND_HI_MOB) && ch->m1 == 1) //can just set the stats low, but incase
{
limb = LM_BODY;
return limb;
}
if(mobint < 8) //target body
{
limb = LM_BODY;
return limb;
}
if(mobint >= 8 && mobint <= 11) //target random part
{
rnum = number_range(1,7);
limb = get_random_limb(victim, rnum);
return limb;
}
if ((weapon = get_eq_char(ch, WEAR_WIELD)) != NULL)
{
if (weapon->value[7] > weapon->value[8] && weapon->value[7] > weapon->value[9])
ch->grip = GRIP_BASH;
if (weapon->value[8] > weapon->value[7] && weapon->value[8] > weapon->value[9])
ch->grip = GRIP_SLASH;
if (weapon->value[9] > weapon->value[7] && weapon->value[9] > weapon->value[8])
ch->grip = GRIP_STAB;
if (weapon->value[7] == weapon->value[8] || weapon->value[7] == weapon->value[9])
ch->grip = GRIP_BASH;
if (weapon->value[8] == weapon->value[9])
ch->grip = GRIP_SLASH;
}
if(mobint >= 12 && mobint <= 14) //target empty limb or random part
{
limb = get_empty_limb(victim);
if (limb < 0)
{
rnum = number_range(1,7);
limb = get_random_limb(victim, rnum);
}
return limb;
}
if (mobint >= 15 && mobint <= 17) //target empty slots, weapon hand, or random part
{
if (mobwis < 15)
{
limb = get_empty_limb(victim);
if (limb < 0)
limb = get_weapon_limb(victim);
if (limb < 0)
{
rnum = number_range(1,7);
limb = get_random_limb(victim, rnum);
}
return limb;
}
else //target arms or legs instead of rest of target (if no weapon/empty slots)
{
limb = get_empty_limb(victim);
if (limb < 0)
{
if (number_range(1, 5) <= 2)
{
limb = get_weapon_limb(victim);
}
}
if (limb < 0)
{
rnum = number_range(1,4);
limb = get_random_limb(victim, rnum);
}
}
return limb;
}
if (mobint >= 18 && mobint <= 21) //target limb based on equipment matchups, higher the wisdom, the better it can matchup
{
if (mobwis < 18)
{
limb = get_empty_limb(victim);
if (limb < 0)
{
diff = get_best_diff(ch, victim, 1);
if (diff >= 3)
{
limb = get_best_diff(ch, victim, 2);
ch->grip = get_best_grip(ch, victim);
}
}
if (limb < 0)
{
if (number_range(1, 5) >= 3)
limb = get_weapon_limb(victim);
}
if (limb < 0)
{
rnum = number_range(1,4);
limb = get_random_limb(victim, rnum);
}
return limb;
}
else
{
limb = get_empty_limb(victim);
if (limb < 0)
{
diff = get_best_diff(ch, victim, 1);
if (diff >= 1)
{
limb = get_best_diff(ch, victim, 2);
ch->grip = get_best_grip(ch, victim);
}
}
if (limb < 0)
limb = get_weapon_limb(victim);
if (limb < 0)
{
rnum = number_range(1,4);
limb = get_random_limb(victim, rnum);
}
return limb;
}
}
if (mobint > 21) //Target best possible limb, high wisdom mobs will make BEST decision possible
{
if (mobwis < 22)
{
limb = get_empty_limb(victim);
if (limb < 0)
{
diff = get_best_diff(ch, victim, 1);
limb = get_best_diff(ch, victim, 2);
ch->grip = get_best_grip(ch, victim);
}
return limb;
}
else
{
limb = get_empty_limb(victim); //empty slot?
if (limb < 0) //Good armor target?
{
diff = get_best_diff(ch, victim, 1);
if (diff >= 1)
{
limb = get_best_diff(ch, victim, 2);
ch->grip = get_best_grip(ch, victim);
}
}
if (limb < 0) //Hurt limb?
{
if (victim->con_larm < 400 || victim->con_rarm < 400 || victim->con_rleg < 400 || victim->con_rleg < 400) //target hurt limbs
{
if (victim->con_rleg < 400 && victim->con_rleg <= victim->con_lleg && victim->con_rleg <= victim->con_rarm
&& victim->con_rleg <= victim->con_larm)
return LM_RLEG;
if (victim->con_lleg < 400 && victim->con_lleg <= victim->con_rleg && victim->con_lleg <= victim->con_rarm
&& victim->con_lleg <= victim->con_larm)
return LM_LLEG;
if (!IS_NPC(victim) && victim->pcdata->righthanded == 0) //in case of a tie target the wielding limb
{
if (victim->con_rarm < 400 && victim->con_rarm <= victim->con_larm && victim->con_rarm <= victim->con_rleg
&& victim->con_rarm <= victim->con_lleg)
return LM_RARM;
if (victim->con_larm < 400 && victim->con_larm <= victim->con_rarm && victim->con_larm <= victim->con_rleg
&& victim->con_larm <= victim->con_lleg)
return LM_LARM;
}
else
{
if (victim->con_larm < 400 && victim->con_larm <= victim->con_rarm && victim->con_larm <= victim->con_rleg
&& victim->con_larm <= victim->con_lleg)
return LM_LARM;
if (victim->con_rarm < 400 && victim->con_rarm <= victim->con_larm && victim->con_rarm <= victim->con_rleg
&& victim->con_rarm <= victim->con_lleg)
return LM_RARM;
}
}
}
if (limb < 0) //damaged eq?
{
OBJ_DATA *eq;
if (((eq = get_eq_char(victim, WEAR_NECK)) != NULL) && eq->value[3] < 300)
return LM_NECK;
if (((eq = get_eq_char(victim, WEAR_HEAD)) != NULL) && eq->value[3] < 300)
return LM_HEAD;
if (!IS_NPC(victim) && victim->pcdata->righthanded == 0)
{
if (((eq = get_eq_char(victim, WEAR_ARM_R)) != NULL) && eq->value[3] < 300)
return LM_RARM;
}
else
{
if (((eq = get_eq_char(victim, WEAR_ARM_L)) != NULL) && eq->value[3] < 300)
return LM_LARM;
}
if (((eq = get_eq_char(victim, WEAR_LEG_R)) != NULL) && eq->value[3] < 300)
return LM_RLEG;
if (((eq = get_eq_char(victim, WEAR_LEG_L)) != NULL) && eq->value[3] < 300)
return LM_LLEG;
if (((eq = get_eq_char(victim, WEAR_BODY)) != NULL) && eq->value[3] < 300)
return LM_BODY;
}
if (limb < 0) //all else fails just find the best
{
limb = get_best_diff(ch, victim, 2);
ch->grip = get_best_grip(ch, victim);
return limb;
}
return limb;
}
}
return LM_BODY;
}
/*
* Check to see if weapon is poisoned.
*/
bool is_wielding_poisoned(CHAR_DATA * ch)
{
OBJ_DATA *obj;
if ((obj = get_eq_char(ch, WEAR_WIELD)) != NULL && IS_OBJ_STAT(obj, ITEM_POISONED))
return TRUE;
return FALSE;
}
/*
* hunting, hating and fearing code -Thoric
*/
bool is_hunting(CHAR_DATA * ch, CHAR_DATA * victim)
{
if (!ch->hunting || ch->hunting->who != victim)
return FALSE;
return TRUE;
}
bool is_hating(CHAR_DATA * ch, CHAR_DATA * victim)
{
if (!ch->hating || ch->hating->who != victim)
return FALSE;
return TRUE;
}
bool is_fearing(CHAR_DATA * ch, CHAR_DATA * victim)
{
if (!ch->fearing || ch->fearing->who != victim)
return FALSE;
return TRUE;
}
void stop_hunting(CHAR_DATA * ch)
{
if (ch->hunting)
{
STRFREE(ch->hunting->name);
DISPOSE(ch->hunting);
ch->hunting = NULL;
}
return;
}
void stop_hating(CHAR_DATA * ch)
{
if (ch->hating)
{
STRFREE(ch->hating->name);
DISPOSE(ch->hating);
ch->hating = NULL;
}
return;
}
void stop_fearing(CHAR_DATA * ch)
{
if (ch->fearing)
{
STRFREE(ch->fearing->name);
DISPOSE(ch->fearing);
ch->fearing = NULL;
}
return;
}
void start_hunting(CHAR_DATA * ch, CHAR_DATA * victim)
{
if (!IS_NPC(ch))
return;
if (ch->hunting)
stop_hunting(ch);
CREATE(ch->hunting, HHF_DATA, 1);
ch->hunting->name = QUICKLINK(victim->name);
ch->hunting->who = victim;
return;
}
void start_hating(CHAR_DATA * ch, CHAR_DATA * victim)
{
if (!IS_NPC(ch))
return;
if (ch->hating)
stop_hating(ch);
CREATE(ch->hating, HHF_DATA, 1);
ch->hating->name = QUICKLINK(victim->name);
ch->hating->who = victim;
return;
}
void start_fearing(CHAR_DATA * ch, CHAR_DATA * victim)
{
if (!IS_NPC(ch))
return;
if (ch->fearing)
stop_fearing(ch);
CREATE(ch->fearing, HHF_DATA, 1);
ch->fearing->name = QUICKLINK(victim->name);
ch->fearing->who = victim;
return;
}
/*
* Get the current armor class for a vampire based on time of day
*/
sh_int VAMP_AC(CHAR_DATA * ch)
{
if (IS_VAMPIRE(ch) && IS_OUTSIDE(ch))
{
switch (time_info.sunlight)
{
case SUN_DARK:
return -10;
case SUN_RISE:
return 5;
case SUN_LIGHT:
return 10;
case SUN_SET:
return 2;
default:
return 0;
}
}
else
return 0;
}
int max_fight(CHAR_DATA * ch)
{
return 20;
}
bool has_artifact(CHAR_DATA * ch)
{
OBJ_DATA *obj;
if (xIS_SET(ch->in_room->room_flags, ROOM_TSAFE))
return FALSE;
for (obj = ch->last_carrying; obj; obj = obj->prev_content)
{
if (IS_OBJ_STAT(obj, ITEM_ARTIFACT)) //Found the artifact
return TRUE;
}
return FALSE;
}
void do_stack(CHAR_DATA *ch, char *argument)
{
char buf[MSL];
if (check_npc(ch))
return;
if (strlen(argument) + strlen(ch->pcdata->stackbuf) >= MSL-5)
{
send_to_char("You can only have roughly 4000 characters in your command stack, clear it if there is a problem.\n\n", ch);
return;
}
if (argument[0] == '\0')
{
send_to_char("You must provide an argument.\n\r", ch);
return;
}
sprintf(buf, "/%s/", argument);;
strcat(ch->pcdata->stackbuf, buf);
return;
}
void do_clearstack(CHAR_DATA *ch, char *argument)
{
if (check_npc(ch))
return;
strcpy(ch->pcdata->stackbuf, "");
send_to_char("Cleared.\n\r", ch);
return;
}
void parse_attack_buffer(char *fullbuf, char *cbuf)
{
int x = 0;
int z = 0;
int cnt = 0;
char buf[MSL];
int y = 0;
for (;;)
{
if (fullbuf[x] == '\0')
{
strcpy(fullbuf, "");
strcpy(cbuf, "");
return;
}
if (fullbuf[x] == '/')
{
cnt++;
if (cnt == 2)
{
cbuf[z] = '\0';
x++;
for (;;)
{
if (fullbuf[x] != '\0')
buf[y++] = fullbuf[x++];
else
break;
}
buf[y] = '\0';
sprintf(fullbuf, buf);
return;
}
x++;
}
else
{
cbuf[z++] = fullbuf[x++];
}
}
}
/*
* Control the fights going on.
* Called periodically by update_handler.
* Many hours spent fixing bugs in here by Thoric, as noted by residual
* debugging checks. If you never get any of these error messages again
* in your logs... then you can comment out some of the checks without
* worry.
*
* Note: This function also handles some non-violence updates.
*/
void violence_update(void)
{
char buf[MSL];
CHAR_DATA *ch;
CHAR_DATA *lst_ch;
CHAR_DATA *ich;
CHAR_DATA *victim;
CHAR_DATA *rch, *rch_next;
TIMER *timer, *timer_next;
ch_ret retcode;
OBJ_DATA *shield;
int attacktype, cnt;
static int pulse = 0;
int range;
AGGRO_DATA *aggro;
AGGRO_DATA *naggro;
int haggro = -1;
char abuf[100];
char target[10];
char commandbuf[MSL];
lst_ch = NULL;
pulse = (pulse + 1) % 100;
for (ch = last_char; ch; lst_ch = ch, ch = gch_prev)
{
set_cur_char(ch);
if (ch == first_char && ch->prev)
{
bug("ERROR: first_char->prev != NULL, fixing...", 0);
ch->prev = NULL;
}
gch_prev = ch->prev;
if (gch_prev && gch_prev->next != ch)
{
if (!ch->name)
{
bug("short-cutting");
UNLINK(ch, first_char, last_char, next, prev);
continue;
}
sprintf(buf, "FATAL: violence_update: %s->prev->next doesn't point to ch.", ch->name);
bug(buf, 0);
bug("Short-cutting here", 0);
ch->prev = NULL;
gch_prev = NULL;
do_shout(ch, "Thoric says, 'Prepare for the worst!'");
}
/*
* See if we got a pointer to someone who recently died...
* if so, either the pointer is bad... or it's a player who
* "died", and is back at the healer...
* Since he/she's in the char_list, it's likely to be the later...
* and should not already be in another fight already
*/
if (char_died(ch))
continue;
/*
* See if we got a pointer to some bad looking data...
*/
if (!ch->in_room || !ch->name)
{
log_string("violence_update: bad ch record! (Shortcutting.)");
sprintf(buf, "ch: %d ch->in_room: %d ch->prev: %d ch->next: %d", (int) ch, (int) ch->in_room, (int) ch->prev, (int) ch->next);
log_string(buf);
log_string(lastplayercmd);
if (lst_ch)
sprintf(buf, "lst_ch: %d lst_ch->prev: %d lst_ch->next: %d", (int) lst_ch, (int) lst_ch->prev, (int) lst_ch->next);
else
strcpy(buf, "lst_ch: NULL");
log_string(buf);
gch_prev = NULL;
continue;
}
/*
* Experience gained during battle deceases as battle drags on
*/
if (ch->fighting)
if ((++ch->fighting->duration % 24) == 0)
ch->fighting->xp = ((ch->fighting->xp * 9) / 10);
if (ch->fighting && ch->fighting->who && ch->fighting->who->name)
{
int hking;
int iking;
if (IS_NPC(ch->fighting->who))
hking = ch->fighting->who->m4;
else
hking = ch->fighting->who->pcdata->hometown;
for (ich = ch->in_room->first_person; ich; ich = ich->next_in_room)
{
if (ich == ch)
continue;
range = ich->m5;
if (IS_NPC(ich))
iking = ich->m4;
else
iking = ich->pcdata->hometown;
if (IN_WILDERNESS(ch))
{
if (abs(ich->coord->x - ch->coord->x) <= range && abs(ich->coord->y - ch->coord->y) <= range && ich->map == ch->map)
{
if (IS_NPC(ich) && ch->fighting && !ich->hating && !ich->hunting && !ich->fighting && ch->fighting->who != ich
&& number_range(1, 100) <= 70 && xIS_SET(ich->act, ACT_MILITARY) && !xIS_SET(ich->miflags, KM_NOASSIST)
&& can_see_map(ich, ch->fighting->who) && hking != iking && !is_safe(ich, ch->fighting->who))
{
start_hating(ich, ch->fighting->who);
start_hunting(ich, ch->fighting->who);
break;
}
}
}
else
{
if (IS_NPC(ich) && ch->fighting && !ich->hating && !ich->hunting && !ich->fighting && ch->fighting->who != ich
&& number_range(1, 100) <= 70 && xIS_SET(ich->act, ACT_MILITARY) && !xIS_SET(ich->miflags, KM_NOASSIST)
&& can_see_map(ich, ch->fighting->who) && hking != iking && !is_safe(ich, ch->fighting->who))
{
start_hating(ich, ch->fighting->who);
start_hunting(ich, ch->fighting->who);
break;
}
}
}
}
for (timer = ch->first_timer; timer; timer = timer_next)
{
timer_next = timer->next;
if (--timer->count <= 0)
{
if (timer->type == TIMER_ASUPRESSED)
{
if (timer->value == -1)
{
timer->count = 1000;
continue;
}
}
if (timer->type == TIMER_NUISANCE)
{
DISPOSE(ch->pcdata->nuisance);
}
if (timer->type == TIMER_DO_FUN)
{
int tempsub;
tempsub = ch->substate;
ch->substate = timer->value;
(timer->do_fun) (ch, "");
if (char_died(ch))
break;
ch->substate = tempsub;
}
extract_timer(ch, timer);
}
}
if (char_died(ch))
continue;
/*
for (aggro = ch->first_aggro; aggro; aggro = aggro->next)
{
if (aggro->ch)
bug("%d > %s", aggro->value, aggro->ch->name);
}
*/
for (aggro = ch->first_aggro; aggro; aggro = naggro)
{
naggro = aggro->next;
if (number_range(1, 20) == 1) //10 seconds roughly
aggro->value-=1;
if (aggro->value <= 0)
{
UNLINK(aggro, ch->first_aggro, ch->last_aggro, next, prev);
UNLINK(aggro, first_global_aggro, last_global_aggro, next_global, prev_global);
DISPOSE(aggro);
}
}
//Do not attack this round if there is a fight timer
if (ch->fight_timer > 0)
{
ch->fight_timer--;
if (ch->fight_timer == 0)
ch->fight_state = 0;
continue;
}
if (IS_NPC(ch) && xIS_SET(ch->act, ACT_NOATTACK))
continue;
/* check for exits moving players around */
if ((retcode = pullcheck(ch, pulse)) == rCHAR_DIED || char_died(ch))
continue;
/* Let the battle begin! */
if ((victim = who_fighting(ch)) == NULL || IS_AFFECTED(ch, AFF_PARALYSIS))
continue;
if (!IN_SAME_ROOM(ch, victim))
{
stop_fighting(ch, FALSE);
continue;
}
if( IS_NPC(ch) )
{
retcode = rNONE;
if (is_safe(victim, ch) && !has_artifact(ch) && !has_artifact(victim))
{
sprintf(buf, "violence_update: %s fighting %s in a SAFE room.", ch->name, victim->name);
log_string(buf);
stop_fighting(ch, TRUE);
}
else if (IS_AWAKE(ch) && in_same_room(ch, victim))
{
int fired = 0;
/*
* Mob triggers
*/
rprog_rfight_trigger(ch);
if (char_died(ch))
continue;
mprog_hitprcnt_trigger(ch, victim);
if (char_died(ch))
continue;
mprog_fight_trigger(ch, victim);
if (char_died(ch))
continue;
/*
* NPC special attack flags -Thoric
*/
if (IS_NPC(ch))
{
if (!xIS_EMPTY(ch->attacks))
{
attacktype = -1;
if (15 >= number_percent())
{
cnt = 0;
for (;;)
{
if (cnt++ > 100)
{
attacktype = -1;
break;
}
attacktype = number_range(7, MAX_ATTACK_TYPE - 1);
if (xIS_SET(ch->attacks, attacktype))
{
fired = 1;
break;
}
}
switch (attacktype)
{
case ATCK_BASH:
break;
case ATCK_STUN:
do_stun(ch, "");
retcode = global_retcode;
break;
case ATCK_GOUGE:
do_gouge(ch, "");
retcode = global_retcode;
break;
case ATCK_FEED:
break;
case ATCK_DRAIN:
break;
case ATCK_FIREBREATH:
retcode = spell_fire_breath(skill_lookup("fire breath"), ch->level, ch, victim);
break;
case ATCK_FROSTBREATH:
retcode = spell_frost_breath(skill_lookup("frost breath"), ch->level, ch, victim);
break;
case ATCK_ACIDBREATH:
retcode = spell_acid_breath(skill_lookup("acid breath"), ch->level, ch, victim);
break;
case ATCK_LIGHTNBREATH:
retcode = spell_lightning_breath(skill_lookup("lightning breath"), ch->level, ch, victim);
break;
case ATCK_GASBREATH:
retcode = spell_gas_breath(skill_lookup("gas breath"), ch->level, ch, victim);
break;
case ATCK_SPIRALBLAST:
break;
case ATCK_POISON:
retcode = spell_poison(gsn_poison, ch->level, ch, victim);
break;
case ATCK_NASTYPOISON:
/*
retcode = spell_nasty_poison( skill_lookup( "nasty poison" ), ch->level, ch, victim );
*/
break;
case ATCK_GAZE:
/*
retcode = spell_gaze( skill_lookup( "gaze" ), ch->level, ch, victim );
*/
break;
case ATCK_BLINDNESS:
retcode = spell_blindness(gsn_blindness, ch->level, ch, victim);
break;
case ATCK_CAUSESERIOUS:
retcode = spell_cause_serious(skill_lookup("cause serious"), ch->level, ch, victim);
break;
case ATCK_EARTHQUAKE:
retcode = spell_earthquake(skill_lookup("earthquake"), ch->level, ch, victim);
break;
case ATCK_CAUSECRITICAL:
retcode = spell_cause_critical(skill_lookup("cause critical"), ch->level, ch, victim);
break;
case ATCK_CURSE:
retcode = spell_curse(skill_lookup("curse"), ch->level, ch, victim);
break;
case ATCK_FLAMESTRIKE:;
break;
case ATCK_HARM:
retcode = spell_harm(skill_lookup("harm"), ch->level, ch, victim);
break;
case ATCK_FIREBALL:
break;
case ATCK_COLORSPRAY:
break;
case ATCK_WEAKEN:
retcode = spell_weaken(skill_lookup("weaken"), ch->level, ch, victim);
break;
}
ch->fight_timer = 0;
if (attacktype != -1 && (retcode == rCHAR_DIED || char_died(ch)))
continue;
}
}
/*
* NPC special defense flags -Thoric
*/
if (!xIS_EMPTY(ch->defenses))
{
attacktype = -1;
if (15 > number_percent())
{
cnt = 0;
for (;;)
{
if (cnt++ > 100)
{
attacktype = -1;
break;
}
attacktype = number_range(2, MAX_DEFENSE_TYPE - 1);
if (xIS_SET(ch->defenses, attacktype))
{
fired = 1;
break;
}
}
switch (attacktype)
{
case DFND_CURELIGHT:
act(AT_MAGIC, "$n mutters a few incantations...and looks a little better.", ch, NULL, NULL, TO_ROOM);
retcode = spell_smaug(skill_lookup("cure light"), ch->level, ch, ch);
break;
case DFND_CURESERIOUS:
act(AT_MAGIC, "$n mutters a few incantations...and looks a bit better.", ch, NULL, NULL, TO_ROOM);
retcode = spell_smaug(skill_lookup("cure serious"), ch->level, ch, ch);
break;
case DFND_CURECRITICAL:
act(AT_MAGIC, "$n mutters a few incantations...and looks healthier.", ch, NULL, NULL, TO_ROOM);
retcode = spell_smaug(skill_lookup("cure critical"), ch->level, ch, ch);
break;
case DFND_HEAL:
act(AT_MAGIC, "$n mutters a few incantations...and looks much healthier.", ch, NULL, NULL, TO_ROOM);
retcode = spell_smaug(skill_lookup("heal"), ch->level, ch, ch);
break;
case DFND_DISPELMAGIC:
act(AT_MAGIC, "$n utters an incantation...", ch, NULL, NULL, TO_ROOM);
retcode = spell_dispel_magic(skill_lookup("dispel magic"), ch->level, ch, victim);
break;
case DFND_DISPELEVIL:
break;
case DFND_SHOCKSHIELD:
if (!IS_AFFECTED(ch, AFF_SHOCKSHIELD))
{
act(AT_MAGIC, "$n utters a few incantations...", ch, NULL, NULL, TO_ROOM);
retcode = spell_smaug(skill_lookup("shockshield"), ch->level, ch, ch);
}
else
retcode = rNONE;
break;
case DFND_FIRESHIELD:
if (!IS_AFFECTED(ch, AFF_FIRESHIELD))
{
act(AT_MAGIC, "$n utters a few incantations...", ch, NULL, NULL, TO_ROOM);
retcode = spell_smaug(skill_lookup("fireshield"), ch->level, ch, ch);
}
else
retcode = rNONE;
break;
case DFND_ICESHIELD:
if (!IS_AFFECTED(ch, AFF_ICESHIELD))
{
act(AT_MAGIC, "$n utters a few incantations...", ch, NULL, NULL, TO_ROOM);
retcode = spell_smaug(skill_lookup("iceshield"), ch->level, ch, ch);
}
else
retcode = rNONE;
break;
case DFND_TRUESIGHT:
if (!IS_AFFECTED(ch, AFF_TRUESIGHT))
retcode = spell_smaug(skill_lookup("true"), ch->level, ch, ch);
else
retcode = rNONE;
break;
case DFND_SANCTUARY:
if (!IS_AFFECTED(ch, AFF_SANCTUARY))
{
act(AT_MAGIC, "$n utters a few incantations...", ch, NULL, NULL, TO_ROOM);
retcode = spell_smaug(skill_lookup("sanctuary"), ch->level, ch, ch);
}
else
retcode = rNONE;
break;
}
ch->fight_timer = 0;
if (attacktype != -1 && (retcode == rCHAR_DIED || char_died(ch)))
continue;
}
}
}
if (ch->fight_timer > 0)
continue;
//Still want it to fire roughly every 12 seconds per unit even if in battle, roughly comes out to about 16 or
//so seconds with the 65 percent chance. At 5 units that is roughly a heal every 3 seconds.
//Mage units will fire at a much faster rate since magic is their primary way of damage and survival
if (IS_NPC(ch) && xIS_SET(ch->act, ACT_MILITARY) && ch->m4 > 1 && ch->m4 < sysdata.max_kingdom
&& ch->fight_timer == 0 && ch->fighting && ch->fighting->who && number_range(1, 24) <= get_btimer(ch, -1, NULL))
{
int csn;
BUYKMOB_DATA *kmob;
char snbuf[MSL];
for (kmob = first_buykmob; kmob; kmob = kmob->next)
{
if (ch->pIndexData->vnum == kmob->vnum)
{
if (xIS_SET(kmob->flags, KMOB_MAGE))
{
if (xIS_SET(kmob->flags, KMOB_MAGEDAMAGE1) || xIS_SET(kmob->flags, KMOB_MAGEDAMAGE2)
|| xIS_SET(kmob->flags, KMOB_MAGEDAMAGE3) || xIS_SET(kmob->flags, KMOB_MAGEDAMAGE4))
{
int num;
for (;;)
{
num = number_range(1, 4);
if (num == 1 && xIS_SET(kmob->flags, KMOB_MAGEDAMAGE1))
{
num = number_range(1, 10);
if (num == 1)
csn = skill_lookup("jagged spike");
else if (num == 2)
csn = skill_lookup("jagged stone");
else if (num == 3)
csn = skill_lookup("fire arrow");
else if (num == 4)
csn = skill_lookup("fire blast");
else if (num == 5)
csn = skill_lookup("wind chill");
else if (num == 6)
csn = skill_lookup("wind gust");
else if (num == 7)
csn = skill_lookup("cold ball");
else if (num == 8)
csn = skill_lookup("frozen dart");
else if (num == 9)
csn = skill_lookup("energy blast");
else
csn = skill_lookup("power drain");
if (csn <= 0)
continue;
sprintf(snbuf, "$n waves $s hands and casts %s on $N", skill_table[csn]->name);
act(AT_ACTION, snbuf, ch, NULL, ch->fighting->who, TO_ROOM);
spell_smaug(csn, POINT_LEVEL(LEARNED(ch, csn), MASTERED(ch, csn)), ch, ch->fighting->who);
break;
}
if (num == 2 && xIS_SET(kmob->flags, KMOB_MAGEDAMAGE2))
{
num = number_range(1, 10);
if (num == 1)
csn = skill_lookup("acid blast");
else if (num == 2)
csn = skill_lookup("acidic ball");
else if (num == 3)
csn = skill_lookup("fire bolt");
else if (num == 4)
csn = skill_lookup("scolding blast");
else if (num == 5)
csn = skill_lookup("funnel");
else if (num == 6)
csn = skill_lookup("wind spike");
else if (num == 7)
csn = skill_lookup("frozen ball");
else if (num == 8)
csn = skill_lookup("frozen spike");
else if (num == 9)
csn = skill_lookup("electric blast");
else
csn = skill_lookup("energy drain");
if (csn <= 0)
continue;
sprintf(snbuf, "$n waves $s hands and casts %s on $N", skill_table[csn]->name);
act(AT_ACTION, snbuf, ch, NULL, ch->fighting->who, TO_ROOM);
spell_smaug(csn, POINT_LEVEL(LEARNED(ch, csn), MASTERED(ch, csn)), ch, ch->fighting->who);
break;
}
if (num == 3 && xIS_SET(kmob->flags, KMOB_MAGEDAMAGE3))
{
num = number_range(1, 10);
if (num == 1)
csn = skill_lookup("acidic blast");
else if (num == 2)
csn = skill_lookup("earth clamp");
else if (num == 3)
csn = skill_lookup("blazing burst");
else if (num == 4)
csn = skill_lookup("fireball");
else if (num == 5)
csn = skill_lookup("tornado");
else if (num == 6)
csn = skill_lookup("blitzing wave");
else if (num == 7)
csn = skill_lookup("frigid ball");
else if (num == 8)
csn = skill_lookup("frozen blast");
else if (num == 9)
csn = skill_lookup("deanimation");
else
csn = skill_lookup("jolting burst");
if (csn <= 0)
continue;
sprintf(snbuf, "$n waves $s hands and casts %s on $N", skill_table[csn]->name);
act(AT_ACTION, snbuf, ch, NULL, ch->fighting->who, TO_ROOM);
spell_smaug(csn, POINT_LEVEL(LEARNED(ch, csn), MASTERED(ch, csn)), ch, ch->fighting->who);
break;
}
if (num == 4 && xIS_SET(kmob->flags, KMOB_MAGEDAMAGE4))
{
num = number_range(1, 10);
if (num == 1)
csn = skill_lookup("acidic oblivion");
else if (num == 2)
csn = skill_lookup("demolic blast");
else if (num == 3)
csn = skill_lookup("dancing fire");
else if (num == 4)
csn = skill_lookup("eradication");
else if (num == 5)
csn = skill_lookup("heavenly blast");
else if (num == 6)
csn = skill_lookup("meteor");
else if (num == 7)
csn = skill_lookup("frigid death");
else if (num == 8)
csn = skill_lookup("tidal wave");
else if (num == 9)
csn = skill_lookup("molecular degeneration");
else
csn = skill_lookup("quantum spike");
if (csn <= 0)
continue;
sprintf(snbuf, "$n waves $s hands and casts %s on $N", skill_table[csn]->name);
act(AT_ACTION, snbuf, ch, NULL, ch->fighting->who, TO_ROOM);
spell_smaug(csn, POINT_LEVEL(LEARNED(ch, csn), MASTERED(ch, csn)), ch, ch->fighting->who);
break;
}
}
break;
}
}
if (xIS_SET(kmob->flags, KMOB_CLERIC))
{
CHAR_DATA *rch;
int num = number_range(1, 20);
if (num > 13 && (xIS_SET(kmob->flags, KMOB_HARM) || xIS_SET(kmob->flags, KMOB_CLERICDAMAGE)))
{
num = number_range(1, 2);
if (num == 1 && xIS_SET(kmob->flags, KMOB_HARM))
{
csn = skill_lookup("harm");
if (csn <= 0)
continue;
act(AT_ACTION, "$n waves $s hands and casts harm on $N.", ch, NULL, ch->fighting->who, TO_ROOM);
spell_harm(csn, POINT_LEVEL(LEARNED(ch, csn), MASTERED(ch, csn)), ch, ch->fighting->who);
break;
}
if (num == 2 && xIS_SET(kmob->flags, KMOB_CLERICDAMAGE))
{
num = number_range(1, 5);
if (num == 1)
csn = skill_lookup("gurori");
else if (num == 2)
csn = skill_lookup("furori");
else if (num == 3)
csn = skill_lookup("aurori");
else if (num == 4)
csn = skill_lookup("wurori");
else
csn = skill_lookup("eurori");
if (csn <= 0)
continue;
sprintf(snbuf, "$n waves $s hands and casts %s on $N", skill_table[csn]->name);
act(AT_ACTION, snbuf, ch, NULL, ch->fighting->who, TO_ROOM);
spell_smaug(csn, POINT_LEVEL(LEARNED(ch, csn), MASTERED(ch, csn)), ch, ch->fighting->who);
break;
}
}
if (num <= 13 && (xIS_SET(kmob->flags, KMOB_CURELIGHT) || xIS_SET(kmob->flags, KMOB_CURESERIOUS)
|| xIS_SET(kmob->flags, KMOB_CURECRITICAL) || xIS_SET(kmob->flags, KMOB_HEAL)
|| xIS_SET(kmob->flags, KMOB_DIVINITY) || xIS_SET(kmob->flags, KMOB_POWERHEAL)))
{
for (rch = ch->in_room->first_person; rch; rch = rch->next_in_room)
{
if (in_same_room(ch, rch) && IS_NPC(rch) && rch->m4 == ch->m4 && rch->hit < rch->max_hit)
{
for (;;)
{
num = number_range(1, 6);
if (num == 1 && xIS_SET(kmob->flags, KMOB_CURELIGHT))
{
csn = skill_lookup("cure light");
if (csn <= 0)
continue;
spell_smaug(csn, POINT_LEVEL(LEARNED(ch, csn), MASTERED(ch, csn)), ch, rch);
act(AT_ACTION, "$n waves $s hands and casts cure light on $N.", ch, NULL, rch, TO_ROOM);
break;
}
if (num == 2 && xIS_SET(kmob->flags, KMOB_CURESERIOUS))
{
csn = skill_lookup("cure serious");
if (csn <= 0)
continue;
spell_smaug(csn, POINT_LEVEL(LEARNED(ch, csn), MASTERED(ch, csn)), ch, rch);
act(AT_ACTION, "$n waves $s hands and casts cure serious on $N.", ch, NULL, rch, TO_ROOM);
break;
}
if (num == 3 && xIS_SET(kmob->flags, KMOB_CURECRITICAL))
{
csn = skill_lookup("cure critical");
if (csn <= 0)
continue;
spell_smaug(csn, POINT_LEVEL(LEARNED(ch, csn), MASTERED(ch, csn)), ch, rch);
act(AT_ACTION, "$n waves $s hands and casts cure critical on $N.", ch, NULL, rch, TO_ROOM);
break;
}
if (num == 4 && xIS_SET(kmob->flags, KMOB_HEAL))
{
csn = skill_lookup("heal");
if (csn <= 0)
continue;
spell_smaug(csn, POINT_LEVEL(LEARNED(ch, csn), MASTERED(ch, csn)), ch, rch);
act(AT_ACTION, "$n waves $s hands and casts heal on $N.", ch, NULL, rch, TO_ROOM);
break;
}
if (num == 5 && xIS_SET(kmob->flags, KMOB_DIVINITY))
{
csn = skill_lookup("divinity");
if (csn <= 0)
continue;
spell_smaug(csn, POINT_LEVEL(LEARNED(ch, csn), MASTERED(ch, csn)), ch, rch);
act(AT_ACTION, "$n waves $s hands and casts divinity on $N.", ch, NULL, rch, TO_ROOM);
break;
}
if (num == 6 && xIS_SET(kmob->flags, KMOB_POWERHEAL))
{
csn = skill_lookup("power heal");
if (csn <= 0)
continue;
spell_smaug(csn, POINT_LEVEL(LEARNED(ch, csn), MASTERED(ch, csn)), ch, rch);
act(AT_ACTION, "$n waves $s hands and casts power heal on $N.", ch, NULL, rch, TO_ROOM);
break;
}
}
break;
}
}
}
}
break;
}
}
continue;
}
else
{
retcode = one_hit(ch, victim, TYPE_HIT, LM_BODY);
if (fired == 1)
ch->fight_timer += 2;
}
}
else
stop_fighting(ch, FALSE);
if (char_died(ch))
continue;
if (retcode == rCHAR_DIED || (victim = who_fighting(ch)) == NULL)
continue;
//Don't want to target some bum with a giant shield all the time do we!!
if (ch->fighting && ch->fighting->who && (shield = get_eq_char(ch->fighting->who, WEAR_SHIELD)) != NULL && IS_NPC(ch) && !xIS_SET(ch->act, ACT_MILITARY))
{
if (shield->value[2] >= 30) //Lower aggression rate against this target
{
for (aggro = ch->first_aggro; aggro; aggro = aggro->next)
{
if (aggro->ch && aggro->ch == ch->fighting->who)
break;
}
if (aggro)
{
aggro->value -= UMAX(1, (shield->value[2]- 30) / 4);
}
}
}
//stop kingdom buffering, mobs will target unequiped foes first....
if (ch->fighting && ch->fighting->who && ch->fighting->who->name && xIS_SET(ch->act, ACT_MILITARY))
{
int eqlevel;
int fnd = 0;
int npeace;
int ht;
int bpercent = 100;
CHAR_DATA *newtarget = NULL;
if (!get_eq_char(ch->fighting->who, WEAR_NECK))
eqlevel = 1;
else if (!get_eq_char(ch->fighting->who, WEAR_HEAD))
eqlevel = 2;
else if (!get_eq_char(ch->fighting->who, WEAR_ARM_R))
eqlevel = 3;
else if (!get_eq_char(ch->fighting->who, WEAR_ARM_L))
eqlevel = 4;
else if (!get_eq_char(ch->fighting->who, WEAR_LEG_R))
eqlevel = 5;
else if (!get_eq_char(ch->fighting->who, WEAR_LEG_L))
eqlevel = 6;
else if (!get_eq_char(ch->fighting->who, WEAR_BODY))
eqlevel = 7;
else
eqlevel = 8;
if (eqlevel > 1)
{
if (xIS_SET(ch->miflags, KM_ATTACKN))
npeace = 1;
else if (xIS_SET(ch->miflags, KM_ATTACKE))
npeace = 0;
else
npeace = -1;
if (IS_NPC(ch->fighting->who))
ht = ch->fighting->who->m4;
else
ht = ch->fighting->who->pcdata->hometown;
for (ich = ch->in_room->first_person; ich; ich = ich->next_in_room)
{
if (ich == ch)
continue;
if (IN_WILDERNESS(ch))
{
if (ich->coord->x == ch->coord->x && ich->coord->y == ch->coord->y && ich->map == ch->map)
{
if (can_see_map(ch, ich) && !is_safe(ch, ich) && ch->m4 != ht && (npeace == -1 || kingdom_table[ch->m4]->peace[ht] <= npeace) && !IS_IMMORTAL(ich))
{
if (!get_eq_char(ich, WEAR_NECK))
{
for (aggro = ch->first_aggro; aggro; aggro = aggro->next)
if (aggro->ch && aggro->ch == ich)
aggro->value = 10000;
fnd = 1;
break;
}
if (!get_eq_char(ich, WEAR_HEAD) && eqlevel > 2)
{
for (aggro = ch->first_aggro; aggro; aggro = aggro->next)
if (aggro->ch && aggro->ch == ich)
aggro->value = 10000;
fnd = 1;
break;
}
if (!get_eq_char(ich, WEAR_ARM_R) && eqlevel > 3)
{
for (aggro = ch->first_aggro; aggro; aggro = aggro->next)
if (aggro->ch && aggro->ch == ich)
aggro->value = 10000;
fnd = 1;
break;
}
if (!get_eq_char(ich, WEAR_ARM_L) && eqlevel > 4)
{
for (aggro = ch->first_aggro; aggro; aggro = aggro->next)
if (aggro->ch && aggro->ch == ich)
aggro->value = 10000;
fnd = 1;
break;
}
if (!get_eq_char(ich, WEAR_LEG_R) && eqlevel > 5)
{
for (aggro = ch->first_aggro; aggro; aggro = aggro->next)
if (aggro->ch && aggro->ch == ich)
aggro->value = 10000;
fnd = 1;
break;
}
if (!get_eq_char(ich, WEAR_LEG_L) && eqlevel > 6)
{
for (aggro = ch->first_aggro; aggro; aggro = aggro->next)
if (aggro->ch && aggro->ch == ich)
aggro->value = 10000;
fnd = 1;
break;
}
if (!get_eq_char(ich, WEAR_BODY) && eqlevel > 7)
{
for (aggro = ch->first_aggro; aggro; aggro = aggro->next)
if (aggro->ch && aggro->ch == ich)
aggro->value = 10000;
fnd = 1;
break;
}
if (eqlevel == 8)
{
shield = get_eq_char(ich, WEAR_SHIELD);
if (shield && shield->value[2] >= 40) //switch targets on a decent block percent
{
if (bpercent == 100)
{
shield = get_eq_char(ch->fighting->who, WEAR_SHIELD);
if (shield)
bpercent = shield->value[2];
else
bpercent = 0;
}
shield = get_eq_char(ich, WEAR_SHIELD);
if (!shield && ich != ch && !IS_NPC(ich) && !IS_IMMORTAL(ich))
{
newtarget = ich;
bpercent = 0;
continue;
}
if (shield && shield->value[2] < bpercent && ich != ch && !IS_NPC(ich) && !IS_IMMORTAL(ich))
{
newtarget = ich;
bpercent = shield->value[2];
}
}
}
}
}
}
else
{
if (can_see_map(ch, ich) && !is_safe(ch, ich) && ch->m4 != ht && (npeace == -1 || kingdom_table[ch->m4]->peace[ht] <= npeace) && !IS_IMMORTAL(ich))
{
if (!get_eq_char(ich, WEAR_NECK))
{
for (aggro = ch->first_aggro; aggro; aggro = aggro->next)
if (aggro->ch && aggro->ch == ich)
aggro->value = 10000;
fnd = 1;
break;
}
if (!get_eq_char(ich, WEAR_HEAD) && eqlevel > 2)
{
for (aggro = ch->first_aggro; aggro; aggro = aggro->next)
if (aggro->ch && aggro->ch == ich)
aggro->value = 10000;
fnd = 1;
break;
}
if (!get_eq_char(ich, WEAR_ARM_R) && eqlevel > 3)
{
for (aggro = ch->first_aggro; aggro; aggro = aggro->next)
if (aggro->ch && aggro->ch == ich)
aggro->value = 10000;
fnd = 1;
break;
}
if (!get_eq_char(ich, WEAR_ARM_L) && eqlevel > 4)
{
for (aggro = ch->first_aggro; aggro; aggro = aggro->next)
if (aggro->ch && aggro->ch == ich)
aggro->value = 10000;
fnd = 1;
break;
}
if (!get_eq_char(ich, WEAR_LEG_R) && eqlevel > 5)
{
for (aggro = ch->first_aggro; aggro; aggro = aggro->next)
if (aggro->ch && aggro->ch == ich)
aggro->value = 10000;
fnd = 1;
break;
}
if (!get_eq_char(ich, WEAR_LEG_L) && eqlevel > 6)
{
for (aggro = ch->first_aggro; aggro; aggro = aggro->next)
if (aggro->ch && aggro->ch == ich)
aggro->value = 10000;
fnd = 1;
break;
}
if (!get_eq_char(ich, WEAR_BODY) && eqlevel > 7)
{
for (aggro = ch->first_aggro; aggro; aggro = aggro->next)
if (aggro->ch && aggro->ch == ich)
aggro->value = 10000;
fnd = 1;
break;
}
if (eqlevel == 8)
{
shield = get_eq_char(ich, WEAR_SHIELD);
if (shield && shield->value[2] >= 40) //switch targets on a decent block percent
{
if (bpercent == 100)
{
shield = get_eq_char(ch->fighting->who, WEAR_SHIELD);
if (shield)
bpercent = shield->value[2];
else
bpercent = 0;
}
shield = get_eq_char(ich, WEAR_SHIELD);
if (!shield && ich != ch && !IS_NPC(ich) && !IS_IMMORTAL(ich))
{
newtarget = ich;
bpercent = 0;
continue;
}
if (shield && shield->value[2] < bpercent && ich != ch && !IS_NPC(ich) && !IS_IMMORTAL(ich))
{
newtarget = ich;
bpercent = shield->value[2];
}
}
}
}
}
}
if (fnd == 0 && newtarget)
{
for (aggro = ch->first_aggro; aggro; aggro = aggro->next)
if (aggro->ch && aggro->ch == newtarget)
aggro->value = 10000;
}
}
}
}
/*
* Fun for the whole family!
*/
for (rch = ch->in_room->first_person; rch; rch = rch_next)
{
rch_next = rch->next_in_room;
if (rch->coord->x != ch->coord->x || rch->coord->y != ch->coord->y || rch->map != ch->map)
{
continue;
}
if (IS_AWAKE(rch) && !rch->fighting)
{
if (!IS_NPC(ch) && IS_NPC(rch) && !IS_SET(ch->pcdata->flags, PCFLAG_CNOASSIST))
{
if (IN_SAME_ROOM(rch, ch))
{
if (IS_NPC(rch) && IS_AFFECTED(rch, AFF_CHARM) && !IS_ACT_FLAG(rch, ACT_MOUNTSAVE) && rch->master == ch
&& !rch->fighting)
{
one_hit(rch, victim, TYPE_HIT, LM_BODY);
continue;
}
}
}
/*
* PC's auto-assist others in their group.
*/
if (!IS_NPC(ch) || IS_AFFECTED(ch, AFF_CHARM))
{
if ((!IS_NPC(rch) || IS_AFFECTED(rch, AFF_CHARM)) && is_same_group(ch, rch))
one_hit(rch, victim, TYPE_HIT, LM_BODY);
continue;
}
/*
* NPC's assist NPC's of same type or 12.5% chance regardless.
*/
if (IS_NPC(rch) && !IS_AFFECTED(rch, AFF_CHARM) && !xIS_SET(rch->act, ACT_NOASSIST))
{
if (char_died(ch))
break;
if (rch->pIndexData == ch->pIndexData || number_bits(3) == 0)
{
CHAR_DATA *vch;
CHAR_DATA *target;
int number;
int hking;
int iking;
target = NULL;
number = 0;
if (IS_NPC(rch))
hking = rch->m4;
else
hking = rch->pcdata->hometown;
for (vch = ch->in_room->first_person; vch; vch = vch->next)
{
if (IS_NPC(vch))
iking = vch->m4;
else
iking = vch->pcdata->hometown;
if (can_see_map(rch, vch) && is_same_group(vch, victim) && number_range(0, number) && !is_safe(rch, vch) && (!xIS_SET(vch->act, ACT_MILITARY) || (xIS_SET(vch->act, ACT_MILITARY) && iking != hking)))
{
if (vch->mount && vch->mount == rch)
target = NULL;
else
{
target = vch;
number++;
}
}
}
if (target)
one_hit(rch, target, TYPE_HIT, LM_BODY);
}
}
}
}
for (aggro = ch->first_aggro; aggro; aggro = aggro->next)
{
if (!aggro->ch)
continue;
if (haggro == -1)
{
if (IN_SAME_ROOM(ch, aggro->ch))
haggro = aggro->value;
}
if (aggro->value > haggro)
{
if (IN_SAME_ROOM(ch, aggro->ch))
haggro = aggro->value;
}
}
for (aggro = ch->first_aggro; aggro; aggro = aggro->next)
{
if (haggro == aggro->value)
break;
}
if (aggro && ch->fighting && ch->fighting->who && aggro->ch != ch->fighting->who)
{
ch->fighting->who = aggro->ch;
act(AT_WHITE, "$n turns $s head toward $N and focuses $s rage on $N!", ch, NULL, ch->fighting->who, TO_NOTVICT);
act(AT_WHITE, "$n turns $s head toward you and foruses $s rage on YOU!", ch, NULL, ch->fighting->who, TO_VICT);
}
if (!IS_NPC(ch) && ch->fight_timer == 0 && ch->fighting && ch->fighting->who)
{
if (xIS_SET(ch->act, PLR_TARGET) && !ch->pcdata->autocommand)
{
if (ch->pcdata->target_limb == LM_HEAD)
sprintf(target, "head");
else if (ch->pcdata->target_limb == LM_BODY)
sprintf(target, "body");
else if (ch->pcdata->target_limb == LM_NECK)
sprintf(target, "neck");
else if (ch->pcdata->target_limb == LM_RARM)
sprintf(target, "rarm");
else if (ch->pcdata->target_limb == LM_LARM)
sprintf(target, "larm");
else if (ch->pcdata->target_limb == LM_LLEG)
sprintf(target, "lleg");
else if (ch->pcdata->target_limb == LM_RLEG)
sprintf(target, "rleg");
else
sprintf(target, "body");
sprintf(abuf, "'%s' %s", ch->fighting->who->name, target);
if (ch->pcdata->target == GRIP_SLASH)
ch->grip = GRIP_SLASH;
else if (ch->pcdata->target == GRIP_STAB)
ch->grip = GRIP_STAB;
else
ch->grip = GRIP_BASH;
if (ch->position < POS_BERSERK)
;
else if (get_char_room_new(ch, ch->fighting->who->name, 1) == NULL)
;
else if (ch->pcdata->stackbuf[0] != '\0')
{
strcpy(commandbuf, "");
parse_attack_buffer(ch->pcdata->stackbuf, commandbuf);
if (commandbuf[0] == '\0' && ch->pcdata->stackbuf[0] == '\0')
do_attack(ch, abuf);
else
interpret(ch, commandbuf);
}
else
do_attack(ch, abuf);
}
}
if (xIS_SET(ch->act, PLR_TARGET) && ch->pcdata->autocommand)
{
if (ch->pcdata->stackbuf[0] != '\0')
{
strcpy(commandbuf, "");
parse_attack_buffer(ch->pcdata->stackbuf, commandbuf);
if (commandbuf[0] == '\0' && ch->pcdata->stackbuf[0] == '\0')
interpret(ch, ch->pcdata->autocommand);
else
interpret(ch, commandbuf);
}
else
interpret(ch, ch->pcdata->autocommand);
}
/*
for (d = first_descriptor; d; d = d->next)
{
if (d->connected == CON_PLAYING && d->character->in_room && d->newstate != 2)
{
if (d->character->fighting && can_see(d->character, d->character->fighting->who))
{
int percent;
ch = d->character;
victim = d->character->fighting->who;
percent = ((victim->hit * 100) / victim->max_hit);
if (ch->level >= 15)
sprintf(buf2, "(%2d%%)", percent);
else
sprintf(buf2, " ");
ch_printf(ch, "^x&R*&r~&R*&r~&R*&r~&R*&r~&R*&r~&R*&r~&R*&r~&R*&r~&R*&r~&R*&r~&R*&r~&R*&r~&R*&r~&R*&r~&R*\n\r");
if (victim->hit == victim->max_hit)
ch_printf(ch, "&R* &G&W(&r**&R***&Y***&G***&G&W) %s &R*\n\r", buf2);
else if (percent >= 90)
ch_printf(ch, "&R* &G&W(&r**&R***&Y***&G** &G&W) %s &R*\n\r", buf2);
else if (percent >= 80)
ch_printf(ch, "&R* &G&W(&r**&R***&Y***&G* &G&W) %s &R*\n\r", buf2);
else if (percent >= 70)
ch_printf(ch, "&R* &G&W(&r**&R***&Y*** &G&W) %s &R*\n\r", buf2);
else if (percent >= 60)
ch_printf(ch, "&R* &G&W(&r**&R***&Y** &G&W) %s &R*\n\r", buf2);
else if (percent >= 50)
ch_printf(ch, "&R* &G&W(&r**&R***&Y* &G&W) %s &R*\n\r", buf2);
else if (percent >= 40)
ch_printf(ch, "&R* &G&W(&r**&R*** &G&W) %s &R*\n\r", buf2);
else if (percent >= 30)
ch_printf(ch, "&R* &G&W(&r**&R** &G&W) %s &R*\n\r", buf2);
else if (percent >= 20)
ch_printf(ch, "&R* &G&W(&r**&R* &G&W) %s &R*\n\r", buf2);
else if (percent >= 10)
ch_printf(ch, "&R* &G&W(&r** &G&W) %s &R*\n\r", buf2);
else
ch_printf(ch, "&R* &G&W(&r* &G&W) %s &R*\n\r", buf2);
ch_printf(ch, "&R*&r~&R*&r~&R*&r~&R*&r~&R*&r~&R*&r~&R*&r~&R*&r~&R*&r~&R*&r~&R*&r~&R*&r~&R*&r~&R*&r~&R*\n\r");
}
}
}*/
}
return;
}
/*
* Weapon types, haus
*/
int weapon_prof_bonus_check(CHAR_DATA * ch, OBJ_DATA * wield, int *gsn_ptr)
{
return 0;
}
/*
* Calculate the tohit bonus on the object and return RIS values.
* -- Altrag
*/
int obj_hitroll(OBJ_DATA * obj)
{
return 0;
}
/*
* Offensive shield level modifier
*/
sh_int off_shld_lvl(CHAR_DATA * ch)
{
if (get_curr_int(ch) < 13) //1-12
return SPOWER_MIN;
if (get_curr_int(ch) < 17) //13-16
return SPOWER_MED;
if (get_curr_int(ch) < 21) //17-20
return SPOWER_HI;
if (get_curr_int(ch) < 24) //21-23
return SPOWER_GREATER;
else
return SPOWER_GREATEST; //24+
return URANGE(5, (get_curr_int(ch)-12)*5, 50);
}
void do_grip(CHAR_DATA * ch, char *argument)
{
if (!str_prefix(argument, "slash"))
{
ch->grip = GRIP_SLASH;
send_to_char("Grip changed to slash.\n\r", ch);
if (ch->fighting)
{
SET_BIT(ch->fight_state, FSTATE_GRIP);
ch->fight_timer = 2;
}
return;
}
else if (!str_prefix(argument, "bash"))
{
ch->grip = GRIP_BASH;
send_to_char("Grip changed to bash.\n\r", ch);
if (ch->fighting)
{
SET_BIT(ch->fight_state, FSTATE_GRIP);
ch->fight_timer = 2;
}
return;
}
else if (!str_prefix(argument, "stab"))
{
ch->grip = GRIP_STAB;
send_to_char("Grip changed to stab.\n\r", ch);
if (ch->fighting)
{
SET_BIT(ch->fight_state, FSTATE_GRIP);
ch->fight_timer = 2;
}
return;
}
else
{
send_to_char("Syntax: grip <argument> argument = slash, bash, stab\n\r", ch);
return;
}
}
//Adjusts strength/agility from attack, part of the stat increase/decrease with no levels
//More of a strength drop now for using lighter weapons
void adjust_agi_str(CHAR_DATA *ch, OBJ_DATA *weapon, CHAR_DATA *target)
{
//1000 for agility 10000 for strengh since it is base 25 and agi is base 100
int str, agi, mod, mstr, magi, bstr, astr, alow, apercent;
str = ch->perm_str;
agi = ch->perm_agi;
mstr = magi = 0;
if (get_eq_char(ch, WEAR_DUAL_WIELD) != NULL)
learn_from_success(ch, gsn_dual_wield, NULL);
if(weapon == NULL)
mod = 1;
else
mod = weapon->value[3] - race_table[ch->race]->weaponmin + 1;
if (mod == 7) //largest weapon
{
magi += number_range(-1, -2);
mstr += number_range(2, 3);
}
if (mod == 6) //2nd largest weapon
{
magi += number_range(0, -1);
mstr += number_range(1, 2);
}
if (mod == 5) //average weapon/heavy, light change in both areas
{
magi += number_range(-1, 2);
mstr += number_range(1, 0);
}
if (mod == 4) //average weapon/light, light change in both areas.
{
magi += number_range(1, 2);
mstr += number_range(-1, 1);
}
if (mod == 3) //Lighter weapon, increase agi
{
magi += number_range(2, 3);
mstr += number_range(0, -1);
}
if (mod == 2) //Lightest weapon, increases agi
{
magi += number_range(3, 5);
mstr += number_range(-2, -3);
}
if (mod == 1) //no weapon
{
magi += number_range(5, 7);
mstr += number_range(-3, -5);
}
//Increase agility if under 30 no matter what
if (agi <= 30)
{
if (mod == 7)
magi = 1;
if (mod == 6)
magi = number_range(1, 2);
if (mod == 5)
magi = number_range(1, 3);
if (mod == 4)
magi = number_range(1, 4);
if (mod == 3)
magi = number_range(2, 5);
if (mod == 2)
magi = number_range(4, 10);
if (mod == 1)
magi = number_range(12, 20);
}
if (sysdata.stat_gain <= 3)
{
if (magi > 0)
magi = number_range(150*magi/100, 180*magi/100);
if (mstr > 0)
mstr = number_range(150*mstr/100, 180*mstr/100);
}
else if (sysdata.stat_gain >= 5)
{
if (magi > 0)
magi = number_range(250*magi/100, 300*magi/100);
if (mstr > 0)
magi = number_range(250*mstr/100, 300*mstr/100);
}
//strength mods
if (mstr > 0)
{
bstr = 14 + race_table[ch->race]->str_plus;
if (str == bstr - 4)
mstr *= 2;
if (str == bstr - 3)
mstr *= 1.7;
if (str == bstr - 2)
mstr *= 1.5;
if (str == bstr - 1)
mstr *= 1.2;
if (str == bstr)
mstr *= 1;
if (str == bstr + 1)
mstr *= .85;
if (str == bstr + 2)
mstr *= .7;
if (str == bstr + 3)
mstr *= .6;
if (str == bstr + 4)
mstr *= .4;
if (str == bstr + 5)
mstr *= .3;
if (str == bstr + 6)
mstr *= .275;
if (str == bstr + 7)
mstr *= .25;
if (str == bstr + 8)
mstr *= .225;
if (str > bstr + 8) //Base + 8 should be the max unless you screwed it up
mstr = 0;
else
{
if (mstr == 0)
mstr = 1;
}
}
else
{
bstr = 14 + race_table[ch->race]->str_plus;
if (str == bstr - 4)
mstr = 0;
if (str == bstr - 3)
mstr *= .3;
if (str == bstr - 2)
mstr *= .4;
if (str == bstr - 1)
mstr *= .6;
if (str == bstr)
mstr *= 1;
if (str == bstr + 1)
mstr *= 1.2;
if (str == bstr + 2)
mstr *= 1.4;
if (str == bstr + 3)
mstr *= 1.6;
if (str == bstr + 4)
mstr *= 1.8;
if (str >= bstr + 5)
mstr *= 2;
}
//agility mods
if (magi > 0)
{
astr = race_table[ch->race]->agi_start;
alow = astr - race_table[ch->race]->agi_range;
apercent = (agi - alow) * 100 / (astr - alow);
magi = magi * (200 - apercent) / 100;
if (magi <= 0)
magi = 1;
}
else
{
astr = race_table[ch->race]->agi_start;
alow = astr - race_table[ch->race]->agi_range;
apercent = (agi - alow) * 100 / (astr - alow);
magi = magi * apercent / 100;
}
if (ch->perm_str >= (14 + race_table[ch->race]->str_plus + race_table[ch->race]->str_range + get_talent_increase(ch, 1)) && ch->pcdata->per_str >= 3000 && mstr > 0)
mstr = 0;
if (ch->perm_str <= (14 + race_table[ch->race]->str_plus - 5 + race_table[ch->race]->str_range) && ch->pcdata->per_str <= 3000 && mstr < 0)
mstr = 0;
if (ch->perm_agi >= (race_table[ch->race]->agi_start + race_table[ch->race]->agi_range + get_talent_increase(ch, 7)) && ch->pcdata->per_agi >= 300)
magi = 0;
if (ch->perm_agi <= (race_table[ch->race]->agi_start - race_table[ch->race]->agi_range) && ch->pcdata->per_agi <= 300 && magi < 0)
magi = 0;
if (target && IS_NPC(target) && xIS_SET(target->act, ACT_MOUNTSAVE))
{
if (mstr > 0)
mstr = 0;
if (magi > 0)
magi = 0;
}
if (magi > 1 && magi < -1)
magi = magi * race_table[ch->race]->agi_plus/100;
ch->pcdata->per_agi += magi;
ch->pcdata->per_str += mstr;
if (ch->pcdata->per_agi > 1000)
{
ch->perm_agi++;
if (ch->perm_agi < 16)
ch->perm_agi = 16;
send_to_char("&R*************************************\n\r", ch);
send_to_char("&R*****You Gain 1 Point of Agility*****\n\r", ch);
send_to_char("&R*************************************\n\r", ch);
ch->pcdata->per_agi = 0;
}
if (ch->pcdata->per_str > 10000)
{
ch->perm_str++;
send_to_char("&R**************************************\n\r", ch);
send_to_char("&R*****You Gain 1 Point of Strength*****\n\r", ch);
send_to_char("&R**************************************\n\r", ch);
ch->pcdata->per_str = 0;
}
if (ch->pcdata->per_agi < 0)
{
ch->perm_agi--;
send_to_char("&r*************************************\n\r", ch);
send_to_char("&r*****You Lose 1 Point of Agility*****\n\r", ch);
send_to_char("&r*************************************\n\r", ch);
ch->pcdata->per_agi = 999;
}
if (ch->pcdata->per_str < 0)
{
ch->perm_str--;
send_to_char("&r**************************************\n\r", ch);
send_to_char("&r*****You Lose 1 Point of Strength*****\n\r", ch);
send_to_char("&r**************************************\n\r", ch);
ch->pcdata->per_str = 9999;
}
}
int get_limb_location(int limb)
{
if (limb == LM_BODY)
return WEAR_BODY;
if (limb == LM_NECK)
return WEAR_NECK;
if (limb == LM_HEAD)
return WEAR_HEAD;
if (limb == LM_RARM)
return WEAR_ARM_R;
if (limb == LM_LARM)
return WEAR_ARM_L;
if (limb == LM_RLEG)
return WEAR_LEG_R;
if (limb == LM_LLEG)
return WEAR_LEG_L;
return WEAR_BODY;
}
//the routine for hit or miss check
//-ac (better tohit) +ac (better armor)
int get_hit_or_miss(CHAR_DATA *ch, CHAR_DATA *victim, int ac, int grip, int limb, int noarmor, OBJ_DATA *wield, int sn)
{
int crit = 0;
int spread = 0;
int value = 0;
int percent;
int points;
AFFECT_DATA *paf;
int roll;
int pslice = 0;
int perfect = 0;
int bracing;
int nodeath = 0;
int addspread = 0;
//critical skill check
if (!IS_NPC(ch) && ch->pcdata->learned[gsn_critical] > 0 && ch->pcdata->ranking[gsn_critical] > 0)
{
percent = number_range(1, 10000);
points = POINT_LEVEL(LEARNED(ch, gsn_critical), MASTERED(ch, gsn_critical));
points = number_range(points * 7, points * 10);
if (percent <= points)
{
crit = 1;
learn_from_success(ch, gsn_critical, victim);
}
else
learn_from_failure(ch, gsn_critical, victim);
}
if (sn == gsn_powerslice)
{
int level;
level = POINT_LEVEL(LEARNED(ch, gsn_powerslice), MASTERED(ch, gsn_powerslice))*2;
level += (get_curr_str(ch) - get_curr_str(victim)) * 2;
level += number_range(level*3, level*4);
level = UMAX(50, level);
if (number_range(1, 10000) <= level)
pslice = 1;
if (pslice == 1)
learn_from_success(ch, gsn_powerslice, victim);
else
learn_from_failure(ch, gsn_powerslice, victim);
}
if (sn == gsn_perfect_shot)
{
int level;
level = POINT_LEVEL(LEARNED(ch, gsn_perfect_shot), MASTERED(ch, gsn_perfect_shot))*3/2;
level += (get_curr_str(ch) - get_curr_str(victim)) * 2;
level += number_range(level*2, level*3);
level = UMAX(50, level);
if (number_range(1, 10000) <= level)
{
perfect = 1;
}
}
if (wield && IS_OBJ_STAT(wield, ITEM_TWOHANDED) && ch->race < MAX_PC_RACE)
{
int tpoints = POINT_LEVEL(LEARNED(ch, gsn_weapon_twohanded), MASTERED(ch, gsn_weapon_twohanded));
int mod = wield->value[3] - race_table[ch->race]->weaponmin + 1;
if (mod >= 5 && LEARNED(ch, gsn_weapon_twohanded))
{
if (tpoints >= 90)
ac-=3;
else if (tpoints >= 60)
ac-=2;
else if (tpoints >= 30)
ac-=1;
}
}
ac*=2; //this should make it more defined if you have a better weapon/armor
ac -= URANGE(-10, ch->apply_tohit, 10);
ac += URANGE(-10, victim->apply_armor, 10);
for (paf = victim->first_affect; paf; paf = paf->next)
{
if (paf->type == gsn_berserk);
{
ac -= UMIN(6, paf->modifier/12+1);
break;
}
}
if (!IS_NPC(victim) && victim->pcdata->learned[gsn_krundo_style] > 0)
{
int level;
level = POINT_LEVEL(LEARNED(victim, gsn_krundo_style), MASTERED(victim, gsn_krundo_style));
level = number_range(level*4, level*5);
level = URANGE(1, level, 400);
ac += level/100;
level = level % 100;
if (number_range(1, 100) <= level)
{
ac++;
}
learn_from_success(victim, gsn_krundo_style, ch);
}
if (!IS_NPC(ch) && ch->pcdata->learned[gsn_rwundo_style] > 0)
{
int level;
level = POINT_LEVEL(LEARNED(ch, gsn_rwundo_style), MASTERED(ch, gsn_rwundo_style));
level = number_range(level*4, level*5);
level = URANGE(1, level, 400);
ac -= level/100;
level = level % 100;
if (number_range(1, 100) <= level)
{
ac--;
}
learn_from_success(ch, gsn_rwundo_style, victim);
}
if (!IS_NPC(ch) && ch->pcdata->learned[gsn_concentration] > 0)
{
int level;
level = POINT_LEVEL(LEARNED(ch, gsn_concentration), MASTERED(ch, gsn_concentration));
level = number_range(level*3, level*4);
level = URANGE(1, level, 300);
ac -= level/100;
level = level % 100;
if (number_range(1, 100) <= level)
{
ac--;
}
}
g_tohit = ac;
if (grip == GRIP_BASH)
spread = 6;
else if (grip == GRIP_SLASH)
spread = 4;
else if (grip == GRIP_STAB)
spread = 2;
if (!IS_NPC(ch) && ch->pcdata->learned[gsn_rwundi_style] > 0)
{
int level;
level = POINT_LEVEL(LEARNED(ch, gsn_rwundi_style), MASTERED(ch, gsn_rwundi_style));
level = number_range(level*2, level*3);
level = URANGE(1, level, 200);
spread += level/100;
level = level % 100;
if (number_range(1, 100) <= level)
{
addspread++;
}
learn_from_success(ch, gsn_rwundi_style, victim);
}
roll = number_range(1, TOHIT_SYS);
if (victim->apply_bracing)
{
int sroll;
bracing = UMAX(1, TOHIT_SYS * victim->apply_bracing / 120);
sroll = number_range(1, TOHIT_SYS+bracing);
if (sroll == TOHIT_SYS+bracing || pslice || perfect)
crit = 1;
check_aff_learn(victim, "bracing", 0, ch, 1);
}
else
{
if (roll == TOHIT_SYS || pslice || perfect)
crit = 1;
}
if (limb == LM_HEAD && roll >= TOHIT_SYS-(UMAX(1,TOHIT_SYS/20)))
crit = 1;
else if (roll == 1 && !pslice && !perfect)
crit = -1;
if (roll > ((TOHIT_SYS/2)-(TOHIT_SYS/10) + ac + spread + (TOHIT_SYS/6)) && limb == LM_NECK)
{
if (crit == 0)
nodeath = 1;
crit = 1;
}
g_roll = roll;
g_lowtohit = UMAX(1, (TOHIT_SYS/2)-(TOHIT_SYS/10) + ac - spread - addspread);
g_hitohit = UMAX(1, (TOHIT_SYS/2)-(TOHIT_SYS/10) + ac + spread);
if (noarmor && crit == 0) //always land against no armor
return 200;
if (crit && sn == gsn_pincer) //Enough is enough on this one
return 200;
if (roll < ((TOHIT_SYS/2)-(TOHIT_SYS/10) + ac - spread - addspread) && crit != 1 && crit != -1)
return DM_MISS;
if (roll > ((TOHIT_SYS/2)-(TOHIT_SYS/10) + ac + spread) && crit != 1 && crit != -1)
return 200; //100 percent 200 - 100
if (crit != 1 && crit != -1)
{
value = (TOHIT_SYS/2)-(TOHIT_SYS/10) + ac + spread - roll;
spread += addspread;
if (spread == 2)
{
value -= addspread*2;
if (value <= 0)
return 183;
else if (value == 1)
return 166;
else if (value == 2)
return 150;
else if (value == 3)
return 133;
else if (value == 4)
return 116;
}
if (spread == 3)
{
value -= addspread*2;
if (value <= 0)
return 187;
else if (value == 1)
return 175;
else if (value == 2)
return 162;
else if (value == 3)
return 150;
else if (value == 4)
return 137;
else if (value == 5)
return 125;
else if (value == 6)
return 112;
}
if (spread == 4)
{
value -= addspread*2;
if (value <= 0)
return 190;
else if (value == 1)
return 180;
else if (value == 2)
return 170;
else if (value == 3)
return 160;
else if (value == 4)
return 150;
else if (value == 5)
return 140;
else if (value == 6)
return 130;
else if (value == 7)
return 120;
else if (value == 8)
return 110;
}
if (spread == 5) //8.33
{
value -= addspread*2;
if (value <= 0)
return 192;
else if (value == 1)
return 184;
else if (value == 2)
return 175;
else if (value == 3)
return 167;
else if (value == 4)
return 159;
else if (value == 5)
return 150;
else if (value == 6)
return 141;
else if (value == 7)
return 133;
else if (value == 8)
return 125;
else if (value == 9)
return 116;
else if (value == 10)
return 108;
}
if (spread == 6) //7.14
{
value -= addspread*2;
if (value <= 0)
return 192;
else if (value == 1)
return 185;
else if (value == 2)
return 178;
else if (value == 3)
return 171;
else if (value == 4)
return 164;
else if (value == 5)
return 157;
else if (value == 6)
return 150;
else if (value == 7)
return 142;
else if (value == 8)
return 135;
else if (value == 9)
return 128;
else if (value == 10)
return 121;
else if (value == 11)
return 114;
else if (value == 12)
return 107;
}
if (spread == 7) //6.25
{
value -= addspread*2;
if (value <= 0)
return 193;
else if (value == 1)
return 187;
else if (value == 2)
return 181;
else if (value == 3)
return 175;
else if (value == 4)
return 168;
else if (value == 5)
return 162;
else if (value == 6)
return 156;
else if (value == 7)
return 150;
else if (value == 8)
return 143;
else if (value == 9)
return 137;
else if (value == 10)
return 131;
else if (value == 11)
return 125;
else if (value == 12)
return 118;
else if (value == 13)
return 112;
else if (value == 14)
return 106;
}
if (spread == 8) //5.55
{
value -= addspread*2;
if (value <= 0)
return 194;
else if (value == 1)
return 188;
else if (value == 2)
return 183;
else if (value == 3)
return 177;
else if (value == 4)
return 172;
else if (value == 5)
return 166;
else if (value == 6)
return 161;
else if (value == 7)
return 155;
else if (value == 8)
return 150;
else if (value == 9)
return 144;
else if (value == 10)
return 138;
else if (value == 11)
return 133;
else if (value == 12)
return 127;
else if (value == 13)
return 122;
else if (value == 14)
return 116;
else if (value == 15)
return 111;
else if (value == 16)
return 105;
}
}
if (crit == -1) //crit miss
{
roll = number_range(1, TOHIT_SYS);
if (roll >= 8 && roll <= 10 && wield && !IS_OBJ_STAT(wield, ITEM_NOBREAK))
{
send_to_char("You damage your weapon with your lousy attack.\n\r", ch);
if (wield->item_type == ITEM_MISSILE_WEAPON)
wield->value[0] -= number_range(25, 60);
else
wield->value[0] -= number_range(50, 100);
if (wield->value[0] <= 0)
{
make_scraps(wield, ch);
}
}
else if (roll >= 14 && roll <= 19)
{
send_to_char("Your attack was so bad that you lose your balance and need to take some time to regain it.\n\r", ch);
ch->fight_timer += number_range(UMAX(3, ch->fight_timer*1), UMAX(6, ch->fight_timer*2));
}
}
if (crit == 1) //crit hit
{
int toinsta;
int blimb = 0;
roll = number_range(1,TOHIT_SYS);
if (ch->grip == GRIP_STAB)
{
if (roll < TOHIT_SYS-2)
roll+= 3;
else
roll = TOHIT_SYS;
}
if (perfect == 1)
roll = TOHIT_SYS;
if (roll == TOHIT_SYS && (limb == LM_HEAD || limb == LM_NECK || limb == LM_BODY) && !nodeath)
return DM_DEATH;
if (limb == LM_NECK && !nodeath)
{
toinsta = URANGE(TOHIT_SYS-14, TOHIT_SYS-10+ac, TOHIT_SYS-4);
if (roll > toinsta)
return DM_DEATH;
}
else if (limb == LM_HEAD)
{
toinsta = URANGE(TOHIT_SYS-10, TOHIT_SYS-6+ac, TOHIT_SYS-2);
if (roll > toinsta)
return DM_DEATH;
}
else
{
if (grip == GRIP_SLASH)
{
toinsta = number_range(1, 100)-ac;
if (toinsta > 95)
blimb = 1;
}
if (grip == GRIP_BASH)
{
toinsta = number_range(1, 100)-ac;
if (toinsta > 99)
blimb = 1;
}
if (pslice == 1)
blimb = 1;
}
if (blimb == 0)
return number_range(250, 350);
else
return number_range(-250, -350);
}
return DM_MISS;
}
int fight_unarmed(CHAR_DATA *ch)
{
BUYKMOB_DATA *kmob;
if (!IS_NPC(ch))
return 0;
if (!IN_WILDERNESS(ch))
return 0;
if (!xIS_SET(ch->act, ACT_MILITARY))
return 0;
for (kmob = first_buykmob; kmob; kmob = kmob->next)
{
if (kmob->vnum == ch->pIndexData->vnum)
{
if (xIS_SET(kmob->flags, KMOB_SOLDIERUNARMED))
return 1;
}
}
return 0;
}
int wielding_skill_weapon(CHAR_DATA *ch, int missile)
{
OBJ_DATA *weapon;
if ((weapon = get_eq_char(ch, WEAR_WIELD)) == NULL)
{
if (get_eq_char(ch, WEAR_MISSILE_WIELD) && missile)
return 6;
else
return 0;
}
if (get_eq_char(ch, WEAR_MISSILE_WIELD) && missile)
return 6;
if (weapon->pIndexData->vnum >= OBJ_FORGE_HAND_AXE && weapon->pIndexData->vnum <= OBJ_FORGE_BATTLE_AXE)
return 1;
if (weapon->pIndexData->vnum >= OBJ_FORGE_SHORT_SWORD && weapon->pIndexData->vnum <= OBJ_FORGE_FLAMBERGE)
return 2;
if (weapon->pIndexData->vnum >= OBJ_FORGE_KNIFE && weapon->pIndexData->vnum <= OBJ_FORGE_STILETTO )
return 7;
if (weapon->pIndexData->vnum >= OBJ_FORGE_PILUM && weapon->pIndexData->vnum <= OBJ_FORGE_TRIDENT)
return 3;
if (weapon->pIndexData->vnum >= OBJ_FORGE_CLUB && weapon->pIndexData->vnum <= OBJ_FORGE_MAUL)
return 4;
if (weapon->pIndexData->vnum >= OBJ_FORGE_SCEPTRE && weapon->pIndexData->vnum <= OBJ_FORGE_BLADED_STAFF)
return 5;
if (IS_OBJ_STAT(weapon, ITEM_TYPE_AXE))
return 1;
if (IS_OBJ_STAT(weapon, ITEM_TYPE_SWORD))
return 2;
if (IS_OBJ_STAT(weapon, ITEM_TYPE_DAGGER))
return 7;
if (IS_OBJ_STAT(weapon, ITEM_TYPE_POLEARM))
return 3;
if (IS_OBJ_STAT(weapon, ITEM_TYPE_BLUNT))
return 4;
if (IS_OBJ_STAT(weapon, ITEM_TYPE_STAVES))
return 5;
return 0;
}
//Type 0 - (ch is being hit) 1 - (ch is doing the hitting)
int get_fightingstyle_dam(CHAR_DATA *ch, int dam, CHAR_DATA *victim, int type, int learn)
{
int level;
int gsnstyle = gsn_style_standard;
int newdam = 0;
int dam1;
int dam2;
if (IS_NPC(ch))
return dam;
if (ch->style == STYLE_EVASIVE)
gsnstyle = gsn_style_evasive;
if (ch->style == STYLE_WIZARDRY)
gsnstyle = gsn_style_wizardry;
if (ch->style == STYLE_DIVINE)
gsnstyle = gsn_style_divine;
if (ch->position == POS_AGGRESSIVE)
gsnstyle = gsn_style_aggressive;
if (ch->position == POS_FIGHTING)
gsnstyle = gsn_style_standard;
if (ch->position == POS_BERSERK)
gsnstyle = gsn_style_berserk;
if (ch->position == POS_DEFENSIVE)
gsnstyle = gsn_style_defensive;
if (GET_MASTERY(ch, gsnstyle, 0, ch->level) <= 0)
learn = 0;
level = POINT_LEVEL(LEARNED(ch, gsnstyle), MASTERED(ch, gsnstyle));
if (ch->position == POS_BERSERK)
{
if (type == 0)
newdam = 5 - level/12;
else
newdam = 4 + level/12;
}
else if (ch->position == POS_AGGRESSIVE)
{
if (type == 0)
newdam = 2 - level/12;
else
newdam = 2 + level/12;
}
else if (ch->position == POS_FIGHTING)
{
if (type == 0)
newdam = 0 - level/12;
else
newdam = 0 + level/12;
}
else if (ch->position == POS_DEFENSIVE)
{
if (type == 0)
newdam = -2 - level/12;
else
newdam = -2 + level/12;
}
else if (ch->position == POS_EVASIVE)
{
if (type == 0)
newdam = -5 - level/12;
else
newdam = -4 + level/12;
}
dam1 = dam + newdam;
dam2 = dam * (100+(newdam*3)) / 100;
//If you are hitting choose the least amount of damage, if you are being hit choose the most
if ((type == 1 && dam1 < dam2) || (type == 0 && dam1 > dam2))
dam = dam1;
else
dam = dam2;
if (learn)
learn_from_success(ch, gsnstyle, victim);
return dam;
}
/*
* Hit one guy once.
*/
ch_ret one_hit(CHAR_DATA * ch, CHAR_DATA * victim, int dt, int limb)
{
OBJ_DATA *wield;
OBJ_DATA *dual;
OBJ_DATA *shield;
OBJ_DATA *eq;
int victim_ac = 0;
int armor_ac = 0;
int weapon_ac = 0;
int tohit;
int plusris;
int dam;
int level;
int miss = 0;
int spec = DM_HIT;
int holder = 1;
int percent = 1;
int counter = 0;
int attacktype, cnt;
int prof_bonus;
ch_ret retcode = rNONE;
sh_int mastery;
sh_int hnum;
int crit = 0;
int block = 0;
int suc = 0;
int slimb = 0;
int cond;
AFFECT_DATA *paf;
int noarmor = 0;
BUYKMOB_DATA *kmob;
dual = NULL;
blockdam = 0;
g_tohit = g_roll = g_lowtohit = g_hitohit = 0;
/*
* Can't beat a dead char!
* Guard against weird room-leavings.
*/
if (victim->position == POS_DEAD || ch->in_room != victim->in_room)
return rVICT_DIED;
if (get_eq_char(ch, WEAR_DUAL_WIELD) != NULL && dt != gsn_backstab)
{
if (number_range(1, 2) == 1)
wield = get_eq_char(ch, WEAR_WIELD);
else
wield = get_eq_char(ch, WEAR_DUAL_WIELD);
}
else
wield = get_eq_char(ch, WEAR_WIELD);
//moved this here so it can use the right weapon for finding values....was moved from violence_update
if (IS_NPC(ch))
{
if (xIS_SET(ch->act, ACT_NOATTACK))
return rNONE;
if (wield && wield == get_eq_char(ch, WEAR_DUAL_WIELD))
{
dual = get_eq_char(ch, WEAR_WIELD);
wield->wear_loc = WEAR_WIELD;
dual->wear_loc = WEAR_DUAL_WIELD;
limb = target_chooser(ch, victim); //sets limb and grip
dual->wear_loc = WEAR_WIELD;
wield->wear_loc = WEAR_DUAL_WIELD;
}
else
limb = target_chooser(ch, victim); //sets limb and grip
}
//remove this later, but for now they need to be reset;
if (wield)
{
if (xIS_SET(wield->pIndexData->extra_flags, ITEM_TWOHANDED))
xSET_BIT(wield->extra_flags, ITEM_TWOHANDED);
}
if (victim->position == POS_RIDING)
{
victim->position = POS_STANDING;
if (victim->riding)
{
victim->riding->rider = NULL;
victim->riding = NULL;
}
}
if (victim->rider)
{
victim->rider->riding = NULL;
victim->rider->position = POS_STANDING;
victim->rider = NULL;
}
prof_bonus = 0;
if (!IS_NPC(ch) && ch->pcdata->learned[gsn_combatart] > 0 && wield)
{
learn_from_success(ch, gsn_combatart, victim);
}
if (dt == gsn_backstab || dt == gsn_circle || dt == gsn_kick_back)
{
ch->fight_timer = get_btimer(ch, -1, victim);
}
else if (dt < TYPE_PROJECTILE)
{
ch->fight_timer = get_btimer(ch, dt, victim);
}
else
{
ch->fight_timer = get_btimer(ch, -1, victim);
}
if (ch->fighting /* make sure fight is already started */
&& dt == TYPE_UNDEFINED && IS_NPC(ch) && !xIS_EMPTY(ch->attacks))
{
cnt = 0;
for (;;)
{
attacktype = number_range(0, 6);
if (xIS_SET(ch->attacks, attacktype))
break;
if (cnt++ > 16)
{
attacktype = -1;
break;
}
}
if (attacShowing the first 100 KB of 337.6 KB. Download the archive for the full file.