handler.c
toc/code/handler.c · 228.8 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. *
* ------------------------------------------------------------------------ *
* Main structure manipulation module *
****************************************************************************/
#include <sys/types.h>
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include "mud.h"
extern int top_exit;
extern int top_ed;
extern int top_affect;
extern int cur_qobjs;
extern int cur_qchars;
extern CHAR_DATA *gch_prev;
extern OBJ_DATA *gobj_prev;
CHAR_DATA *cur_char;
ROOM_INDEX_DATA *cur_room;
bool cur_char_died;
ch_ret global_retcode;
int saving_mount_on_quit;
int cur_obj;
int cur_obj_serial;
int top_map_mob;
bool cur_obj_extracted;
obj_ret global_objcode;
OBJ_DATA *group_object(OBJ_DATA * obj1, OBJ_DATA * obj2);
bool in_magic_container(OBJ_DATA * obj);
/* Strlen_color by Rusty, useful for skipping over colors */
int strlen_color(char *argument)
{
char *str;
int i, length;
str = argument;
if (argument == NULL)
return 0;
for (length = i = 0; i < strlen(argument); ++i)
{
if ((str[i] != '&') && (str[i] != '^'))
++length;
if ((str[i] == '&') || (str[i] == '^'))
{
if ((str[i] == '&') && (str[i + 1] == '&'))
length = 2 + length;
else if ((str[i] == '^') && (str[i + 1] == '^'))
length = 2 + length;
else
--length;
}
}
return length;
}
/*
* Retrieve a character's trusted level for permission checking.
*/
sh_int get_trust(CHAR_DATA * ch)
{
if (IS_NPC(ch))
return LEVEL_PC;
if (ch->desc && ch->desc->original)
ch = ch->desc->original;
if (ch->trust != 0)
return ch->trust;
if (ch->level >= LEVEL_IMMORTAL && IS_RETIRED(ch)) /* Tracker1 */
return LEVEL_IMMORTAL; /* Tracker1 */
return ch->level;
}
/*
* New FLevel trust return, for use of the flevel attribute. - Xerves 3-12-98
*/
sh_int get_ftrust(CHAR_DATA * ch)
{
if (ch->desc && ch->desc->original)
ch = ch->desc->original;
if (IS_NPC(ch))
return ch->level;
if (IS_RETIRED(ch))
return LEVEL_IMMORTAL; /* Tracker1 */
if (ch->level > ch->pcdata->flevel)
return ch->level;
return ch->pcdata->flevel;
}
/*
* Retrieve a character's age.
*/
sh_int get_age(CHAR_DATA * ch)
{
if (IS_NPC(ch))
return 17;
return 17 + (ch->played + (current_time - ch->pcdata->logon)) / 72000;
}
/*
* Retrieve character's current strength.
*/
sh_int get_curr_str(CHAR_DATA * ch)
{
sh_int max;
max = 25;
return URANGE(3, ch->perm_str + URANGE(-4, ch->mod_str, 4), max);
}
/*
* Retrieve character's current intelligence.
*/
sh_int get_curr_int(CHAR_DATA * ch)
{
sh_int max;
max = 25;
return URANGE(3, ch->perm_int + URANGE(-4, ch->mod_int, 4), max);
}
/*
* Retrieve character's current wisdom.
*/
sh_int get_curr_wis(CHAR_DATA * ch)
{
sh_int max;
max = 25;
return URANGE(3, ch->perm_wis + URANGE(-4, ch->mod_wis, 4), max);
}
/*
* Retrieve character's current dexterity.
*/
sh_int get_curr_dex(CHAR_DATA * ch)
{
sh_int max;
max = 25;
return URANGE(3, ch->perm_dex + URANGE(-4, ch->mod_dex, 4), max);
}
/*
* Retrieve character's current constitution.
*/
sh_int get_curr_con(CHAR_DATA * ch)
{
sh_int max;
max = 25;
return URANGE(3, ch->perm_con + URANGE(-4, ch->mod_con, 4), max);
}
/*
* Retrieve character's current charisma.
*/
sh_int get_curr_cha(CHAR_DATA * ch)
{
sh_int max;
max = 25;
return URANGE(3, ch->perm_cha + URANGE(-4, ch->mod_cha, 4), max);
}
/*
* Retrieve character's current luck.
*/
sh_int get_curr_lck(CHAR_DATA * ch)
{
sh_int max;
max = 25;
return URANGE(3, ch->perm_lck + URANGE(-4, ch->mod_lck, 4), max);
}
sh_int get_curr_agi(CHAR_DATA * ch)
{
sh_int max;
max = 100;
return URANGE(10, ch->perm_agi + URANGE(-15, ch->mod_agi, 15), max);
}
/* Below 2 functions are used to return points and masteries of spells. Mainly to
compute an estimated value for mobs -- Xerves 2/00 */
sh_int get_mastered_value(CHAR_DATA *ch, int sn)
{
if (!IS_NPC(ch))
{
return URANGE(0, ch->pcdata->ranking[sn], MAX_RANKING);
}
else
{
if (ch->max_hit <= 28)
return get_mastery_value(ch, sn, 0, SPOWER_MIN);
else if (ch->max_hit <= 77)
return get_mastery_value(ch, sn, 0, SPOWER_LOW);
else if (ch->max_hit <= 200)
return get_mastery_value(ch, sn, 0, SPOWER_MED);
else if (ch->max_hit <= 694)
return get_mastery_value(ch, sn, 0, SPOWER_HI);
else if (ch->max_hit <= 1022)
return get_mastery_value(ch, sn, 0, SPOWER_GREAT);
else if (ch->max_hit <= 3000)
return get_mastery_value(ch, sn, 0, SPOWER_GREATER);
else
return get_mastery_value(ch, sn, 0, SPOWER_GREATEST);
}
}
sh_int get_learned_value(CHAR_DATA *ch, int sn)
{
if (!IS_NPC(ch))
{
return URANGE(0, ch->pcdata->learned[sn], MAX_SKPOINTS);
}
else
{
if (ch->max_hit <= 28)
return get_point_value(ch, sn, 0, SPOWER_MIN);
else if (ch->max_hit <= 77)
return get_point_value(ch, sn, 0, SPOWER_LOW);
else if (ch->max_hit <= 200)
return get_point_value(ch, sn, 0, SPOWER_MED);
else if (ch->max_hit <= 694)
return get_point_value(ch, sn, 0, SPOWER_HI);
else if (ch->max_hit <= 1022)
return get_point_value(ch, sn, 0, SPOWER_GREAT);
else if (ch->max_hit <= 3000)
return get_point_value(ch, sn, 0, SPOWER_GREATER);
else
return get_point_value(ch, sn, 0, SPOWER_GREATEST);
}
}
/* Below 2 functions are used to return points and masteries of spells. Mainly to
compute an estimated value for mobs -- Xerves 2/00 */
sh_int get_point_value(CHAR_DATA * ch, int sn, int isobj, int lv)
{
if (!IS_NPC(ch) && isobj == 0 && ch->pcdata->learned[sn] > 1)
return ch->pcdata->learned[sn];
else if (lv >= SPOWER_MIN)
{
if (lv == SPOWER_MIN)
return number_range(1, 2);
if (lv == SPOWER_LOW)
return number_range(2, 4);
if (lv == SPOWER_MED)
return number_range(3, 6);
if (lv == SPOWER_HI)
return number_range(5, 8);
if (lv == SPOWER_GREAT)
return number_range(7, 10);
if (lv == SPOWER_GREATER)
return number_range(8, 12);
if (lv == SPOWER_GREATEST)
return number_range(10, 14);
}
else if (IS_NPC(ch) && isobj == 0)
{
if (ch->max_hit <= 28)
return get_point_value(ch, sn, 0, SPOWER_MIN);
else if (ch->max_hit <= 77)
return get_point_value(ch, sn, 0, SPOWER_LOW);
else if (ch->max_hit <= 200)
return get_point_value(ch, sn, 0, SPOWER_MED);
else if (ch->max_hit <= 694)
return get_point_value(ch, sn, 0, SPOWER_HI);
else if (ch->max_hit <= 1022)
return get_point_value(ch, sn, 0, SPOWER_GREAT);
else if (ch->max_hit <= 3000)
return get_point_value(ch, sn, 0, SPOWER_GREATER);
else
return get_point_value(ch, sn, 0, SPOWER_GREATEST);
}
return 1;
}
sh_int get_mastery_value(CHAR_DATA * ch, int sn, int isobj, int lv)
{
int di;
if (!IS_NPC(ch) && isobj == 0 && ch->pcdata->ranking[sn] > 1)
return ch->pcdata->ranking[sn];
else if (lv >= SPOWER_MIN)
{
//mob or obj
di = dice(1, 20);
if (lv == SPOWER_MIN)
return 1;
if (lv == SPOWER_LOW)
{
if (di >= 15)
return 2;
else
return 1;
}
if (lv == SPOWER_MED)
{
if (di >= 14)
return 2;
else
return 1;
}
if (lv == SPOWER_HI)
{
if (di >= 12)
return 3;
else
return 2;
}
if (lv == SPOWER_GREAT)
{
if (di >= 4)
return 4;
else
return 3;
}
if (lv == SPOWER_GREATER)
{
if (di <= 15)
return 4;
else
return 5;
}
if (lv == SPOWER_GREATEST)
{
if (di <= 5)
return 4;
else if (di >= 16)
return 6;
else
return 5;
}
}
else if (IS_NPC(ch) && isobj == 0)
{
if (ch->max_hit <= 28)
return get_mastery_value(ch, sn, 0, SPOWER_MIN);
else if (ch->max_hit <= 77)
return get_mastery_value(ch, sn, 0, SPOWER_LOW);
else if (ch->max_hit <= 200)
return get_mastery_value(ch, sn, 0, SPOWER_MED);
else if (ch->max_hit <= 694)
return get_mastery_value(ch, sn, 0, SPOWER_HI);
else if (ch->max_hit <= 1022)
return get_mastery_value(ch, sn, 0, SPOWER_GREAT);
else if (ch->max_hit <= 3000)
return get_mastery_value(ch, sn, 0, SPOWER_GREATER);
else
return get_mastery_value(ch, sn, 0, SPOWER_GREATEST);
}
return 1;
}
/* Below 6 handler functions are used in information obtaining in the new skill system.
There are other functions in act_info.c and in mud_comm.c -- Xerves 2/00 */
// Retreives a Mastery name from its Number.
char *get_mastery_name(int mastery)
{
switch (mastery)
{
default:
return "Unknown";
case 1:
return "Beginner";
case 2:
return "Novice";
case 3:
return "Expert";
case 4:
return "Master";
case 5:
return "Elite";
case 6:
return "Flawless";
}
}
char *get_tier_name(int mastery)
{
switch (mastery)
{
default:
return "Unknown";
case 1:
return "Tier 1";
case 2:
return "Tier 2";
case 3:
return "Tier 3";
case 4:
return "Tier 4";
}
}
char *get_wplevel(int power)
{
switch (power)
{
default:
return "None";
case SPOWER_MIN:
return "Minimum";
case SPOWER_LOW:
return "Low";
case SPOWER_MED:
return "Medium";
case SPOWER_HI:
return "High";
case SPOWER_GREAT:
return "Great";
case SPOWER_GREATER:
return "Greater";
case SPOWER_GREATEST:
return "Greatest";
}
}
char *get_sphere_name2(int sphere)
{
switch(sphere)
{
default:
return "Unknown";
case 1:
return "Combat";
case 2:
return "Agent";
case 3:
return "Wizardry";
case 4:
return "Divine";
case 5:
return "Spiritual";
}
}
char *get_sphere_name(int sphere)
{
switch(sphere)
{
default:
return " Unknown ";
case 1:
return " Combat ";
case 2:
return " Agent ";
case 3:
return " Wizardry ";
case 4:
return " Divine ";
case 5:
return " Spiritual ";
}
}
/*
* Retreives a Group name from its Number. -- Xerves 1/00
*/
char *get_group_name(int group)
{
switch (group)
{
default:
return "Unknown";
case 1:
return "Air";
case 2:
return "Earth";
case 3:
return "Energy";
case 4:
return "Fire";
case 5:
return "Water";
case 6:
return "Divine";
case 7:
return "Strikes";
case 8:
return "Body";
case 9:
return "Mind";
case 10:
return "-------";
case 11:
return "Survival";
case 12:
return "Stealth";
case 13:
return "Thieving";
case 14:
return "Battle Skills";
case 15:
return "-------";
case 16:
return "Tactical";
case 17:
return "Styles";
case 18:
return "-------";
}
}
/*
* Retreives a Group name from its Number. Should be used in do_skills only since it
* includes extra values to break up Fire for Cleric and Fire for Mage
*/
char *get_group_name2(int group)
{
switch (group)
{
default:
return "Unknown";
case 1:
return "Air";
case 2:
return "Earth";
case 3:
return "Energy";
case 4:
return "Fire";
case 5:
return "Water";
case 6:
return "Divine";
case 7:
return "Strikes";
case 8:
return "Body";
case 9:
return "Mind";
case 10:
return "-------";
case 11:
return "Survival";
case 12:
return "Stealth";
case 13:
return "Thieving";
case 14:
return "Battle Skills";
case 15:
return "--------";
case 16:
return "Tactical";
case 17:
return "Styles";
case 18:
return "-------";
case 19:
return "Air";
case 20:
return "Earth";
case 21:
return "Energy";
case 22:
return "Fire";
case 23:
return "Water";
}
}
//Used in do_skills to determine percents
int is_part_sphere(int sphere, int group)
{
if (sphere == 1) //Warrior
if (group == 14 || group == 16 || group == 17)
return 1;
if (sphere == 2) //Thief
if (group == 11 || group == 12 || group == 13)
return 1;
if (sphere == 3) //Mage
if (group == 1 || group == 2 || group == 3 || group == 4 || group == 5)
return 1;
if (sphere == 4) //Cleric
if (group == 6 || group == 19 || group == 20 || group == 21 || group == 22 || group == 23)
return 1;
if (sphere == 5) //Hand to Hand
if (group == 7 || group == 8 || group == 9)
return 1;
return 0;
}
// Returns Mastery number for the name
int get_mastery_num(char *mastery)
{
char buf[MSL];
sprintf(buf, mastery);
buf[0] = UPPER(buf[0]);
if (!str_cmp(buf, "Beginner"))
return 1;
if (!str_cmp(buf, "Novice") || !str_prefix(buf, "Apprentice"))
return 2;
if (!str_cmp(buf, "Expert"))
return 3;
if (!str_cmp(buf, "Master"))
return 4;
if (!str_cmp(buf, "Elite"))
return 5;
if (!str_cmp(buf, "Flawless"))
return 6;
return -1;
}
// Get sphere number from sphere name -- Xerves 7/04
sh_int issphere(char *argument)
{
sh_int sphere = -1;
if (!str_cmp(argument, "Combat"))
sphere = 1;
if (!str_cmp(argument, "Agent"))
sphere = 2;
if (!str_cmp(argument, "Wizardry"))
sphere = 3;
if (!str_cmp(argument, "Divine"))
sphere = 4;
if (!str_cmp(argument, "Spiritual"))
sphere = 5;
return sphere;
}
/* Get group number from group name -- Xerves 1/00 */
sh_int isgroup(char *argument)
{
sh_int group = -1;
if (!str_cmp(argument, "Air"))
group = 1;
if (!str_cmp(argument, "Earth"))
group = 2;
if (!str_cmp(argument, "Energy"))
group = 3;
if (!str_cmp(argument, "Fire"))
group = 4;
if (!str_cmp(argument, "Water"))
group = 5;
if (!str_cmp(argument, "Divine"))
group = 6;
if (!str_cmp(argument, "Strikes"))
group = 7;
if (!str_cmp(argument, "Body"))
group = 8;
if (!str_cmp(argument, "Mind"))
group = 9;
if (!str_cmp(argument, "-------"))
group = 10;
if (!str_cmp(argument, "Survival"))
group = 11;
if (!str_cmp(argument, "Stealth"))
group = 12;
if (!str_cmp(argument, "Thieving"))
group = 13;
if (!str_cmp(argument, "Battle Skills"))
group = 14;
if (!str_cmp(argument, "--------"))
group = 15;
if (!str_cmp(argument, "Tactical"))
group = 16;
if (!str_cmp(argument, "Styles"))
group = 17;
if (!str_cmp(argument, "-------"))
group = 18;
return group;
}
//Movement lag, more lag the more tired you get (adding in later running, etc)
int movement_lag(CHAR_DATA *ch, int beats)
{
int percent;
int level;
if (beats < 0)
beats = 1;
percent = ch->move * 100 / 1000;
if (IS_NPC(ch) || LEARNED(ch, gsn_shadowfoot) >= 1)
{
if (percent >= 70)
beats = 1;
else if (percent >= 60)
beats = beats * 3 / 10;
else if (percent >= 50)
beats = beats * 5 / 10;
else if (percent >= 40)
beats = beats * 8 / 10;
else if (percent >= 30)
beats = beats * 11 / 10;
else if (percent >= 15)
beats = beats * 15 / 10;
else if (percent < 15)
beats = beats * 20 / 10;
}
else
{
if (percent >= 80)
beats = 1;
else if (percent >= 70)
beats = beats * 5 / 10;
else if (percent >= 60)
beats = beats * 8 / 10;
else if (percent >= 50)
beats = beats * 12 / 10;
else if (percent >= 40)
beats = beats * 15 / 10;
else if (percent >= 15)
beats = beats * 20 / 10;
else if (percent < 15)
beats = beats * 30 / 10;
}
level = POINT_LEVEL(LEARNED(ch, gsn_featherfoot), MASTERED(ch, gsn_featherfoot));
if (level > 0 && !IS_NPC(ch))
{
beats = beats * (100-(level/2)) / 100;
}
if (beats < 1)
beats = 1;
if (!IS_NPC(ch) && LEARNED(ch, gsn_featherfoot) >= 1)
learn_from_success(ch, gsn_featherfoot, NULL);
if (!IS_NPC(ch) && LEARNED(ch, gsn_featherback) >= 1)
learn_from_success(ch, gsn_featherback, NULL);
return UMIN(20, beats); //5 seconds max, anything over is just evil
}
void update_movement_points(CHAR_DATA *ch, int move)
{
int mv;
if (IS_NPC(ch))
{
if (!xIS_SET(ch->act, ACT_MOUNTSAVE))
return;
}
if (!IS_NPC(ch))
{
mv = number_range(move*.15, move*.3);
if (sysdata.stat_gain <= 3)
mv = number_range(move*.25, move*.5);
else if (sysdata.stat_gain >= 5)
mv = number_range(move*.4, move*.8);
if (ch->mover >= 35 && ch->mover < 45)
mv *= .8;
else if (ch->mover < 55)
mv *= .6;
else if (ch->mover < 65)
mv *= .5;
else if (ch->mover <= 74)
mv *= .3;
else if (ch->mover < 94)
mv *= .25;
else
mv *= .2;
if (mv == 0)
mv = 1;
if (ch->mover >= (74+get_talent_increase(ch, 8)) && ch->pcdata->per_move >= 300)
mv = 0;
ch->pcdata->per_move += mv;
if (ch->pcdata->per_move > 1000)
{
ch->mover++;
send_to_char("&C*****************************************\n\r", ch);
send_to_char("&C******You Gain 1 Point in Endurance******\n\r", ch);
send_to_char("&C*****************************************\n\r", ch);
ch->pcdata->per_move = 0;
}
if (ch->pcdata->per_move < 0)
{
ch->mover--;
send_to_char("&c*****************************************\n\r", ch);
send_to_char("&c******You Lose 1 Point in Endurance******\n\r", ch);
send_to_char("&c*****************************************\n\r", ch);
ch->pcdata->per_move = 999;
}
}
else
{
mv = number_range(move*.1, move*.25);
if (sysdata.stat_gain <= 3)
mv = number_range(move*.2, move*.4);
else if (sysdata.stat_gain >= 5)
mv = number_range(move*.35, move*.7);
if (ch->mover >= 65 && ch->mover < 75)
mv *= .7;
else if (ch->mover < 85)
mv *= .5;
else if (ch->mover < 95)
mv *= .3;
else if (ch->mover < 105)
mv *= .2;
else if (ch->mover < 115)
mv *= .15;
else if (ch->mover < 125)
mv *= .1;
else if (ch->mover < 135)
mv *= .07;
if (mv == 0)
mv = 1;
if (ch->mover == 135 && ch->m1 >= 300)
mv = 0;
ch->m1 += mv;
if (ch->m1 > 1000)
{
ch->mover++;
send_to_char("&C*************************************************\n\r", ch);
send_to_char("&C******Your Mount Gains 1 Point in Endurance******\n\r", ch);
send_to_char("&C*************************************************\n\r", ch);
ch->m1 = 0;
}
}
}
void str_load_increase(CHAR_DATA *ch, int load)
{
int mstr = 0;
int str = ch->perm_str;
int bstr;
if (load >= 51 && load <= 55)
mstr += number_range(0, 2);
else if (load >= 56 && load <= 60)
mstr += number_range(1, 2);
else if (load >= 61 && load <= 65)
mstr += number_range(2, 3);
else if (load >= 66 && load <= 70)
mstr += number_range(2, 4);
else if (load >= 71 && load <= 75)
mstr += number_range(3, 4);
else if (load >= 76 && load <= 80)
mstr += number_range(3, 5);
else if (load >= 81 && load <= 85)
mstr += number_range(4, 5);
else if (load >= 86 && load <= 90)
mstr += number_range(4, 6);
else if (load >= 91 && load <= 96)
mstr += number_range(5, 6);
else
mstr += number_range(6, 7);
if (sysdata.stat_gain <= 3)
mstr = number_range(150*mstr/100, 180*mstr/100);
else if (sysdata.stat_gain >= 5)
mstr = number_range(250*mstr/100, 300*mstr/100);
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 + 5) //Base + 5 should be the max unless you screwed it up
mstr = 0;
else
{
if (mstr == 0)
mstr = 1;
}
if (ch->perm_str == (14 + race_table[ch->race]->str_plus + race_table[ch->race]->str_range) && ch->pcdata->per_str >= 3000)
mstr = 0;
ch->pcdata->per_str += mstr;
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;
}
}
int calculate_movement_cost(int move, CHAR_DATA *ch)
{
int load;
int weight;
int level;
int addmove = 0;
if (ch->con_lleg <= -1)
addmove += UMAX(1, number_range(move*1.5, move*2.3));
else if (ch->con_lleg <= 10)
addmove += UMAX(1, number_range(move*1.3, move*1.5));
else if (ch->con_lleg <= 30)
addmove += UMAX(1, number_range(move*1.15, move*1.3));
else if (ch->con_lleg <= 50)
addmove += UMAX(1, number_range(move*1.05, move*1.15));
if (ch->con_rleg <= -1)
addmove += UMAX(1, number_range(move*1.5, move*2.3));
else if (ch->con_rleg <= 10)
addmove += UMAX(1, number_range(move*1.3, move*1.5));
else if (ch->con_rleg <= 30)
addmove += UMAX(1, number_range(move*1.15, move*1.3));
else if (ch->con_rleg <= 50)
addmove += UMAX(1, number_range(move*1.05, move*1.15));
move+=addmove;
if ((IS_NPC(ch) && !xIS_SET(ch->act, ACT_MOUNTSAVE)) || IS_IMMORTAL(ch))
return 1; //for now
else
{
if (ch->mover < 15)
move = move * (5 - (.1 * (ch->mover-5)));
else if (ch->mover < 25)
move = move * (4 - (.1 * (ch->mover-15)));
else if (ch->mover < 35)
move = move * (3 - (.1 * (ch->mover-25)));
else if (ch->mover < 45)
move = move * (2 - (.1 * (ch->mover-35)));
else if (ch->mover < 55)
move = move * (1.3 - (.07 * (ch->mover-45)));
else if (ch->mover < 65)
move = move * (.95 - (.035 * (ch->mover-55)));
else if (ch->mover < 75)
move = move * (.8 - (.015 * (ch->mover-65)));
else if (ch->mover < 85)
move = move * (.7 - (.01 * (ch->mover-75)));
else if (ch->mover < 95)
move = move * (.6 - (.01 * (ch->mover-85)));
else if (ch->mover < 105)
move = move * (.5 - (.01 * (ch->mover-95)));
else if (ch->mover < 115)
move = move * (.4 - (.01 * (ch->mover-105)));
else if (ch->mover < 125)
move = move * (.3 - (.01 * (ch->mover-115)));
else if (ch->mover < 135)
move = move * (.2 - (.01 * (ch->mover-125)));
else if (ch->mover >= 135)
move = move * .1;
if (!IS_NPC(ch) && ch->pcdata->learned[gsn_shadowfoot] > 0)
{
level = POINT_LEVEL(GET_POINTS(ch, gsn_shadowfoot, 0, 1), GET_MASTERY(ch, gsn_shadowfoot, 0, 1));
move = move * (100 - (15+level/2)) / 100;
learn_from_success(ch, gsn_shadowfoot, NULL);
}
if (move < 1)
move = 1;
if (!IS_NPC(ch))
weight = get_ch_carry_weight(ch);
else
{
if (ch->master)
weight = get_ch_carry_weight(ch->master);
else
weight = 1;
}
load = 100 * weight / can_carry_w(ch);
if (load > 50)
{
if (!IS_NPC(ch))
str_load_increase(ch, load);
if (!IS_NPC(ch) && ch->pcdata->learned[gsn_strongfoot] > 0)
{
level = POINT_LEVEL(GET_POINTS(ch, gsn_strongfoot, 0, 1), GET_MASTERY(ch, gsn_strongfoot, 0, 1));
load = load - (level*2/5);
learn_from_success(ch, gsn_strongfoot, NULL);
}
if (load <= 50)
;
else if (load >= 51 && load <= 55)
move *= 1.1;
else if (load >= 56 && load <= 60)
move *= 1.3;
else if (load >= 61 && load <= 65)
move *= 1.5;
else if (load >= 66 && load <= 70)
move *= 1.7;
else if (load >= 71 && load <= 75)
move *= 2;
else if (load >= 76 && load <= 80)
move *= 2.3;
else if (load >= 81 && load <= 85)
move *= 2.6;
else if (load >= 86 && load <= 90)
move *= 3;
else if (load >= 91 && load <= 96)
move *= 4;
else
move *= 5;
}
}
if (ch->rider)
move *= 2;
return move;
}
/* Below are hitroll/damroll checks to get the hitroll normally plus bonuses based
on mastery */
int get_hit_roll(CHAR_DATA * ch)
{
int hitroll;
hitroll = ch->hitroll + str_app[get_curr_str(ch)].tohit + (2 - (abs(ch->mental_state) / 10));
return hitroll;
}
int get_dam_roll(CHAR_DATA * ch)
{
int damroll;
damroll = ch->damroll + ch->damplus + str_app[get_curr_str(ch)].todam;
if (ch->mental_state > 5 && ch->mental_state < 15)
damroll++;
return damroll;
}
//Defines what the room is, 1 is safe, 2 is noloot, 3 is anitem, 4 is freekill
//Default is noloot
int check_room_pk(CHAR_DATA * ch)
{
//Do the Wilderness first
//Wilderness checks, the room itself should ALWAYS be set to noloot
if (IN_WILDERNESS(ch))
{
int stx, sty, endx, endy, x, y;
if (sysdata.resetgame)
return 4;
stx = ch->coord->x - 5;
sty = ch->coord->y - 5;
endx = ch->coord->x + 5;
endy = ch->coord->y + 5;
if (stx < 1)
stx = 1;
if (sty < 1)
sty = 1;
if (endx > MAX_X)
endx = MAX_X;
if (endy > MAX_Y)
endy = MAX_Y;
for (y = sty; y < endy + 1; y += 1)
{
for (x = stx; x < endx + 1; x += 1)
{
if (map_sector[ch->map][x][y] == SECT_ROAD)
return 2;
if (map_sector[ch->map][x][y] == SECT_BRIDGE)
return 2;
if (map_sector[ch->map][x][y] == SECT_PATH)
{
if (abs(ch->coord->y - y) <= 3 && abs(ch->coord->x - x) <= 3)
return 2;
}
}
}
return 3;
}
//A safe room is a safe room no matter what.
if (xIS_SET(ch->in_room->room_flags, ROOM_TSAFE))
return 1;
if (xIS_SET(ch->in_room->room_flags, ROOM_SAFE))
return 1;
if (xIS_SET(ch->in_room->room_flags, ROOM_FREEKILL))
return 4;
if (xIS_SET(ch->in_room->room_flags, ROOM_ANITEM))
return 3;
if (xIS_SET(ch->in_room->room_flags, ROOM_NOLOOT))
return 2;
//Check areas next, room goes before area in priority
if (IS_SET(ch->in_room->area->flags, AFLAG_NOKILL))
return 1;
if (IS_SET(ch->in_room->area->flags, AFLAG_NOLOOT))
return 2;
if (IS_SET(ch->in_room->area->flags, AFLAG_ANITEM))
return 3;
if (IS_SET(ch->in_room->area->flags, AFLAG_FREEKILL))
return 4;
if (sysdata.resetgame)
return 4;
else
return 2;
}
bool in_same_room(CHAR_DATA * ch, CHAR_DATA * victim)
{
if (IN_WILDERNESS(ch))
{
if (ch->coord->x == victim->coord->x && ch->coord->y == victim->coord->y
&& ch->map == victim->map)
return TRUE;
}
else
{
if (ch->in_room == victim->in_room)
return TRUE;
}
return FALSE;
}
bool in_hellmaze(CHAR_DATA * ch)
{
return FALSE;
}
// Send out message, doesn't use a channel, don't want to spam poor players
void hunt_message(CHAR_DATA * ch, CHAR_DATA * victim, int range)
{
DESCRIPTOR_DATA *d;
CHAR_DATA *tochar;
int message = 1;
char buf[MSL];
char buf2[MSL];
for (d = first_descriptor; d; d = d->next)
{
if (d->connected == CON_PLAYING && d->character->in_room && d->newstate != 2)
tochar = d->character;
else
continue;
if (tochar->coord->x > -1 || tochar->coord->y > -1 || tochar->map > -1)
{
if (abs(ch->coord->x - tochar->coord->x) <= range && abs(ch->coord->y - tochar->coord->y) <= range)
{
message = number_range(1, 6);
if (message == 1)
sprintf(buf, "My first target has escaped, so &R[%s&R]%s will DIE instead.", victim->name, char_color_str(AT_GOSSIP, tochar));
else if (message == 2)
sprintf(buf, "I seek more battles, and &R[%s&R]%s looks like an easy target.", victim->name, char_color_str(AT_GOSSIP, tochar));
else if (message == 3)
sprintf(buf, "&R[%s&R]%s shall die today, I will take delight in my victory.", victim->name, char_color_str(AT_GOSSIP, tochar));
else if (message == 4)
sprintf(buf, "Come here &R[%s&R]%s, I wish to introduce you to your maker.", victim->name, char_color_str(AT_GOSSIP, tochar));
else if (message == 5)
sprintf(buf, "Poor &R[%s&R]%s, today was just not a good day to step outside.", victim->name, char_color_str(AT_GOSSIP, tochar));
else
sprintf(buf, "Life shall end for &R[%s&R]%s today, how sad.", victim->name, char_color_str(AT_GOSSIP, tochar));
sprintf(buf2, "&c&w%s [&cyells&c&w] %s'%s'", ch->short_descr, char_color_str(AT_GOSSIP, tochar), buf);
act(AT_GOSSIP, buf2, ch, NULL, tochar, TO_VICT);
}
}
}
return;
}
void find_next_target(CHAR_DATA * ch)
{
CHAR_DATA *victim;
int range, num, count, npeace, ht, x;
CHAR_DATA *pvictim = NULL;
int eqlevel = 8;
if (xIS_SET(ch->miflags, KM_ATTACKN) || xIS_SET(ch->miflags, KM_ATTACKE) || xIS_SET(ch->miflags, KM_ATTACKA))
{
count = x = 0;
range = ch->m6;
if (xIS_SET(ch->miflags, KM_ATTACKN))
npeace = 1;
else if (xIS_SET(ch->miflags, KM_ATTACKE))
npeace = 0;
else
npeace = -1;
for (victim = ch->in_room->first_person; victim; victim = victim->next_in_room)
{
if (victim->coord->x > -1 || victim->coord->y > -1 || victim->map > -1)
{
if (abs(ch->coord->x - victim->coord->x) <= range && abs(ch->coord->y - victim->coord->y) <= range)
{
if (IS_NPC(victim))
ht = victim->m4;
else
ht = victim->pcdata->hometown;
if (victim->map == ch->map && victim->level < LEVEL_IMMORTAL && can_see(ch, victim) && ch->m4 != ht
&& (npeace == -1 || kingdom_table[ch->m4]->peace[ht] <= npeace) && !xIS_SET(victim->act, ACT_PACIFIST))
{
if (!get_eq_char(victim, WEAR_NECK))
{
pvictim = victim;
eqlevel = 1;
}
if (!get_eq_char(victim, WEAR_HEAD) && eqlevel > 2)
{
pvictim = victim;
eqlevel = 2;
}
if (!get_eq_char(victim, WEAR_ARM_R) && eqlevel > 3)
{
pvictim = victim;
eqlevel = 3;
}
if (!get_eq_char(victim, WEAR_ARM_L) && eqlevel > 4)
{
pvictim = victim;
eqlevel = 4;
}
if (!get_eq_char(victim, WEAR_LEG_R) && eqlevel > 5)
{
pvictim = victim;
eqlevel = 5;
}
if (!get_eq_char(victim, WEAR_LEG_L) && eqlevel > 6)
{
pvictim = victim;
eqlevel = 6;
}
if (!get_eq_char(victim, WEAR_BODY) && eqlevel > 7)
{
pvictim = victim;
eqlevel = 7;
}
if (!pvictim)
pvictim = victim;
}
}
}
}
if (!pvictim)
{
stop_hating(ch);
stop_hunting(ch);
do_yell(ch, "Lost my target, no new ones sited, standing down.");
return;
}
else
{
hunt_message(ch, pvictim, range + 1);
start_hunting(ch, pvictim);
return;
}
}
if (xIS_SET(ch->miflags, KM_ATTACKC) || xIS_SET(ch->miflags, KM_ATTACKH))
{
count = x = 0;
for (victim = ch->in_room->first_person; victim; victim = victim->next_in_room)
{
if ((xIS_SET(ch->miflags, KM_ATTACKC) && get_wear_cloak(victim)) ||
(xIS_SET(ch->miflags, KM_ATTACKH) && get_wear_hidden_cloak(victim)))
{
if (IN_SAME_ROOM(ch, victim))
{
if (IS_NPC(victim))
ht = victim->m4;
else
ht = victim->pcdata->hometown;
if (can_see_map(ch, victim) && !is_safe(ch, victim) && ch->m4 != ht && !IS_IMMORTAL(victim))
{
count++;
}
}
}
}
if (count == 0)
{
stop_hating(ch);
stop_hunting(ch);
do_yell(ch, "Lost my target, no new ones sited, standing down.");
return;
}
num = number_range(1, count);
for (victim = ch->in_room->first_person; victim; victim = victim->next_in_room)
{
if ((xIS_SET(ch->miflags, KM_ATTACKC) && get_wear_cloak(victim)) ||
(xIS_SET(ch->miflags, KM_ATTACKH) && get_wear_hidden_cloak(victim)))
{
if (IN_SAME_ROOM(ch, victim))
{
if (IS_NPC(victim))
ht = victim->m4;
else
ht = victim->pcdata->hometown;
if (x == num && can_see_map(ch, victim) && !is_safe(ch, victim) && ch->m4 != ht && !IS_IMMORTAL(victim))
{
hunt_message(ch, victim, 3);
start_hunting(ch, victim);
return;
}
else
{
if (can_see_map(ch, victim) && !is_safe(ch, victim) && ch->m4 != ht && !IS_IMMORTAL(victim))
x++;
}
}
}
}
}
}
// 0 is out of Battle, 1 is while on map, range is different
void find_next_hunt(CHAR_DATA * ch, int type)
{
DESCRIPTOR_DATA *d;
CHAR_DATA *victim;
int count = 0;
int x = 1;
int num;
int range;
if (type == 0)
range = 10;
else
range = 10;
if (xIS_SET(ch->act, ACT_MILITARY)) //They hunt mobs too, different function
{
find_next_target(ch);
return;
}
for (d = first_descriptor; d; d = d->next)
{
if (d->connected == CON_PLAYING && d->character->in_room && d->newstate != 2)
victim = d->character;
else
continue;
if (victim->coord->x > -1 || victim->coord->y > -1 || victim->map > -1)
{
if (abs(ch->coord->x - victim->coord->x) <= range && abs(ch->coord->y - victim->coord->y) <= range)
{
if (victim->map == ch->map && can_see(ch, victim) && victim->level < LEVEL_IMMORTAL)
{
count++;
}
}
}
}
if (count == 0)
{
extract_char(ch, TRUE);
return;
}
num = number_range(1, count);
for (d = first_descriptor; d; d = d->next)
{
if (d->connected == CON_PLAYING && d->character->in_room && d->newstate != 2)
victim = d->character;
else
continue;
if (victim->coord->x > -1 || victim->coord->y > -1 || victim->map > -1)
{
if (abs(ch->coord->x - victim->coord->x) <= range && abs(ch->coord->y - victim->coord->y) <= range)
{
if (x == num && (ch->map == victim->map && victim->level < LEVEL_IMMORTAL && can_see(ch, victim)) )
{
hunt_message(ch, victim, range + 1);
start_hunting(ch, victim);
start_hating(ch, victim);
return;
}
else
{
if (ch->map == victim->map && victim->level < LEVEL_IMMORTAL && can_see(ch, victim))
x++;
}
}
}
}
}
bool find_sector(CHAR_DATA * ch, int sector)
{
if (IS_ONMAP_FLAG(ch))
{
if (map_sector[ch->map][ch->coord->x][ch->coord->y] == sector)
{
return TRUE;
}
}
else
{
if (ch->in_room->sector_type == sector)
{
return TRUE;
}
}
return FALSE;
}
/*
* Retrieve a character's carry capacity.
* Vastly reduced (finally) due to containers -Thoric
*/
int can_carry_n(CHAR_DATA * ch)
{
int penalty = 0;
if (!IS_NPC(ch) && ch->level >= LEVEL_IMMORTAL)
return 1000;
if (IS_NPC(ch) && (xIS_SET(ch->act, ACT_PET) || xIS_SET(ch->act, ACT_MOUNTSAVE)))
return 0;
if (IS_NPC(ch) && xIS_SET(ch->act, ACT_IMMORTAL))
return 1000;
if (get_eq_char(ch, WEAR_WIELD))
++penalty;
if (get_eq_char(ch, WEAR_DUAL_WIELD))
++penalty;
if (get_eq_char(ch, WEAR_MISSILE_WIELD))
++penalty;
if (get_eq_char(ch, WEAR_NOCKED))
++penalty;
if (get_eq_char(ch, WEAR_SHIELD))
++penalty;
return URANGE(8, 8 + get_curr_dex(ch) - 12 - penalty, 20);
}
/*
* Retrieve a character's carry capacity.
*/
int can_carry_w(CHAR_DATA * ch)
{
int level = POINT_LEVEL(LEARNED(ch, gsn_featherback), MASTERED(ch, gsn_featherback));
int weight;
if (!IS_NPC(ch) && ch->level >= LEVEL_IMMORTAL)
return 1000000;
if (IS_NPC(ch) && xIS_SET(ch->act, ACT_MOUNTSAVE))
return str_app[get_curr_str(ch)].carry*2;
if (IS_NPC(ch) && xIS_SET(ch->act, ACT_IMMORTAL))
return 1000000;
weight = str_app[get_curr_str(ch)].carry;
if (level > 0)
{
weight += weight * UMIN(40, level/2) / 100;
}
return weight;
}
/*
* See if a player/mob can take a piece of prototype eq -Thoric
*/
bool can_take_proto(CHAR_DATA * ch)
{
if (IS_IMMORTAL(ch))
return TRUE;
else if (IS_NPC(ch) && xIS_SET(ch->act, ACT_PROTOTYPE))
return TRUE;
else
return FALSE;
}
/*
* See if a string is one of the names of an object.
*/
bool is_name(const char *str, char *namelist)
{
char name[MIL];
for (;;)
{
namelist = one_argument(namelist, name);
if (name[0] == '\0')
return FALSE;
if (!str_cmp(str, name))
return TRUE;
}
}
/* Will count users on furniture -- Xerves */
int count_users(OBJ_DATA * obj)
{
CHAR_DATA *fch;
int count = 0;
if (obj->in_room == NULL)
return 0;
for (fch = obj->in_room->first_person; fch != NULL; fch = fch->next_in_room)
if (fch->on == obj)
count++;
return count;
}
int max_weight(OBJ_DATA * obj)
{
CHAR_DATA *fch;
int weight = 0;
if (obj->in_room == NULL)
return 200000;
for (fch = obj->in_room->first_person; fch != NULL; fch = fch->next_in_room)
if (fch->on == obj)
weight = weight + fch->weight;
return weight;
}
bool is_name_prefix(const char *str, char *namelist)
{
char name[MIL];
for (;;)
{
namelist = one_argument(namelist, name);
if (name[0] == '\0')
return FALSE;
if (!str_prefix(str, name))
return TRUE;
}
}
/*
* See if a string is one of the names of an object. -Thoric
* Treats a dash as a word delimiter as well as a space
*/
bool is_name2(const char *str, char *namelist)
{
char name[MIL];
for (;;)
{
namelist = one_argument2(namelist, name);
if (name[0] == '\0')
return FALSE;
if (!str_cmp(str, name))
return TRUE;
}
}
bool is_name2_prefix(const char *str, char *namelist)
{
char name[MIL];
for (;;)
{
namelist = one_argument2(namelist, name);
if (name[0] == '\0')
return FALSE;
if (!str_prefix(str, name))
return TRUE;
}
}
/* -Thoric
* Checks if str is a name in namelist supporting multiple keywords
*/
bool nifty_is_name(char *str, char *namelist)
{
char name[MIL];
if (!str || str[0] == '\0')
return FALSE;
for (;;)
{
str = one_argument2(str, name);
if (name[0] == '\0')
return TRUE;
if (!is_name2(name, namelist))
return FALSE;
}
}
bool nifty_is_name_prefix(char *str, char *namelist)
{
char name[MIL];
if (!str || str[0] == '\0')
return FALSE;
for (;;)
{
str = one_argument2(str, name);
if (name[0] == '\0')
return TRUE;
if (!is_name2_prefix(name, namelist))
return FALSE;
}
}
void room_affect(ROOM_INDEX_DATA * pRoomIndex, AFFECT_DATA * paf, bool fAdd)
{
if (fAdd)
{
switch (paf->location)
{
case APPLY_ROOMFLAG:
case APPLY_SECTORTYPE:
break;
case APPLY_ROOMLIGHT:
pRoomIndex->light += paf->modifier;
break;
case APPLY_TELEVNUM:
case APPLY_TELEDELAY:
break;
}
}
else
{
switch (paf->location)
{
case APPLY_ROOMFLAG:
case APPLY_SECTORTYPE:
break;
case APPLY_ROOMLIGHT:
pRoomIndex->light -= paf->modifier;
break;
case APPLY_TELEVNUM:
case APPLY_TELEDELAY:
break;
}
}
}
/*
* Modify a skill (hopefully) properly -Thoric
*
* On "adding" a skill modifying affect, the value set is unimportant
* upon removing the affect, the skill it enforced to a proper range.
*/
void modify_skill(CHAR_DATA * ch, int sn, int mod, bool fAdd)
{
if (!IS_NPC(ch))
{
if (fAdd)
ch->pcdata->learned[sn] += mod;
else
ch->pcdata->learned[sn] = URANGE(0, ch->pcdata->learned[sn] + mod, MAX_SKPOINTS);
}
}
int base_resis_values(CHAR_DATA *ch, int type)
{
int fire, water, air, earth, energy, holy, unholy, nonmagic, magic, poison, paralysis;
fire=water=air=earth=energy=holy=unholy=nonmagic=magic=poison=paralysis=100;
if (IS_SET(ch->elementb, ELEMENT_FIRE))
{
fire -=25;
water +=50;
}
if (IS_SET(ch->elementb, ELEMENT_WATER))
{
fire +=35;
water -=20;
}
if (IS_SET(ch->elementb, ELEMENT_AIR))
{
air -=35;
earth +=50;
}
if (IS_SET(ch->elementb, ELEMENT_EARTH))
{
air +=35;
earth -=25;
}
if (IS_SET(ch->elementb, ELEMENT_ENERGY))
{
energy -=40;
air +=15;
earth +=15;
fire +=15;
water +=15;
}
if (IS_SET(ch->elementb, ELEMENT_DIVINE))
{
holy -=60;
unholy +=200;
energy -= 10;
air -=10;
earth -=10;
fire -=10;
water -=10;
}
if (IS_SET(ch->elementb, ELEMENT_UNHOLY))
{
unholy -=60;
holy +=200;
energy -= 10;
air -=10;
earth -=10;
fire -=10;
water -=10;
}
if (ch->race == RACE_OGRE)
{
nonmagic -= 20;
fire -= 25;
water -= 30;
magic += 100;
poison -= 30;
paralysis -= 30;
}
if (ch->race == RACE_DWARF)
{
water -= 25;
}
if (ch->race == RACE_HOBBIT)
{
fire -= 25;
}
if (ch->race == RACE_FAIRY)
{
magic -= 35;
nonmagic += 50;
}
if (type == 1)
return fire;
if (type == 2)
return water;
if (type == 3)
return air;
if (type == 4)
return earth;
if (type == 5)
return energy;
if (type == 6)
return holy;
if (type == 7)
return unholy;
if (type == 8)
return nonmagic;
if (type == 9)
return magic;
if (type == 10)
return poison;
if (type == 11)
return paralysis;
return 100;
}
/*
* Apply or remove an affect to a character.
*/
void affect_modify(CHAR_DATA * ch, AFFECT_DATA * paf, sh_int fAdd)
{
OBJ_DATA *wield;
int mod;
sh_int eq = 0;
struct skill_type *skill;
ch_ret retcode;
int resist;
int susc;
int diff;
//AFFECT_DATA *saf;
mod = paf->modifier;
if (fAdd > 1)
{
fAdd -= 2;
eq = 1;
}
if (fAdd)
{
xSET_BITS(ch->affected_by, paf->bitvector);
if (paf->location % REVERSE_APPLY == APPLY_RECURRINGSPELL)
{
mod = abs(mod);
if (IS_VALID_SN(mod) && (skill = skill_table[mod]) != NULL && skill->type == SKILL_SPELL)
xSET_BIT(ch->affected_by, AFF_RECURRINGSPELL);
else
bug("affect_modify(%s) APPLY_RECURRINGSPELL with bad sn %d", ch->name, mod);
return;
}
}
else
{
xREMOVE_BITS(ch->affected_by, paf->bitvector);
/*
* might be an idea to have a duration removespell which returns
* the spell after the duration... but would have to store
* the removed spell's information somewhere... -Thoric
* (Though we could keep the affect, but disable it for a duration)
*/
if ((paf->location % REVERSE_APPLY) == APPLY_REMOVESPELL)
return;
if (paf->location % REVERSE_APPLY == APPLY_RECURRINGSPELL)
{
mod = abs(mod);
if (!IS_VALID_SN(mod) || (skill = skill_table[mod]) == NULL || skill->type != SKILL_SPELL)
bug("affect_modify(%s) APPLY_RECURRINGSPELL with bad sn %d", ch->name, mod);
xREMOVE_BIT(ch->affected_by, AFF_RECURRINGSPELL);
return;
}
switch (paf->location % REVERSE_APPLY)
{
case APPLY_AFFECT:
REMOVE_BIT(ch->affected_by.bits[0], mod);
return;
case APPLY_EXT_AFFECT:
xREMOVE_BIT(ch->affected_by, mod);
return;
case APPLY_RESISTANT:
REMOVE_BIT(ch->resistant, mod);
return;
case APPLY_IMMUNE:
REMOVE_BIT(ch->immune, mod);
return;
case APPLY_SUSCEPTIBLE:
REMOVE_BIT(ch->susceptible, mod);
return;
case APPLY_WEARSPELL: /* affect only on wear */
return;
case APPLY_REMOVE:
SET_BIT(ch->affected_by.bits[0], mod);
return;
}
mod = 0 - mod;
}
switch (paf->location % REVERSE_APPLY)
{
default:
bug("Affect_modify: unknown location %d.", paf->location);
return;
case APPLY_NONE:
break;
case APPLY_ARMOR:
ch->apply_armor += mod;
break;
case APPLY_SHIELD:
ch->apply_shield += mod;
break;
case APPLY_STONE:
ch->apply_stone += mod;
break;
case APPLY_SANCTIFY:
ch->apply_sanctify += mod;
break;
case APPLY_WMOD:
if (!fAdd)
{
if (mod == -ch->apply_wmod)
ch->apply_wmod += mod;
if (ch->apply_wmod < 0)
ch->apply_wmod = 0;
}
else
{
if (mod < ch->apply_wmod || ch->apply_wmod == 0)
{
ch->apply_wmod = mod;
}
}
break;
case APPLY_RENERGY:
resist = (ch->apply_res_energy[1] == 0 ? 100 : ch->apply_res_energy[1]);
susc = (ch->apply_res_energy[2] == 0 ? 100 : ch->apply_res_energy[2]);
//Getting the natural "susc/resist" to add back in later...
diff = (ch->apply_res_energy[0] + (100-resist) - (susc-100)) - 100;
if (!fAdd)
{
if (mod == 0 || mod == -1) //0 and 1 will not work
;
if (mod > -100) //Resist
{
if (mod == -ch->apply_res_energy[1])
ch->apply_res_energy[1] = 100;
}
if (mod < -100) //Susc
{
if (mod == -ch->apply_res_energy[2])
ch->apply_res_energy[2] = 100;
}
if (mod == 1) //Immune
{
ch->apply_res_energy[1] = 100;
diff = base_resis_values(ch, 5)-100;
}
}
else
{
if (mod > 100 && mod > ch->apply_res_energy[2]) //Susc
{
ch->apply_res_energy[2] = mod;
}
if (mod < 100 && mod > 1 && mod < ch->apply_res_energy[1]) //Resist
{
ch->apply_res_energy[1] = mod;
}
if (mod == -1) //Immune
ch->apply_res_energy[1] = -500;
}
resist = (ch->apply_res_energy[1] == 0 ? 100 : ch->apply_res_energy[1]);
susc = (ch->apply_res_energy[2] == 0 ? 100 : ch->apply_res_energy[2]);
if (ch->apply_res_energy[1] == -500)
ch->apply_res_energy[0] = -500;
else
ch->apply_res_energy[0] = 100 + diff - (100-resist) + (susc-100);
break;
case APPLY_RWATER:
resist = (ch->apply_res_water[1] == 0 ? 100 : ch->apply_res_water[1]);
susc = (ch->apply_res_water[2] == 0 ? 100 : ch->apply_res_water[2]);
//Getting the natural "susc/resist" to add back in later...
diff = (ch->apply_res_water[0] + (100-resist) - (susc-100)) - 100;
if (!fAdd)
{
if (mod == 0 || mod == -1) //0 and 1 will not work
;
if (mod > -100) //Resist
{
if (mod == -ch->apply_res_water[1])
ch->apply_res_water[1] = 100;
}
if (mod < -100) //Susc
{
if (mod == -ch->apply_res_water[2])
ch->apply_res_water[2] = 100;
}
if (mod == 1) //Immune
{
ch->apply_res_water[1] = 100;
diff = base_resis_values(ch, 2)-100;
}
}
else
{
if (mod > 100 && mod > ch->apply_res_water[2]) //Susc
{
ch->apply_res_water[2] = mod;
}
if (mod < 100 && mod > 1 && mod < ch->apply_res_water[1]) //Resist
{
ch->apply_res_water[1] = mod;
}
if (mod == -1) //Immune
ch->apply_res_water[1] = -500;
}
resist = (ch->apply_res_water[1] == 0 ? 100 : ch->apply_res_water[1]);
susc = (ch->apply_res_water[2] == 0 ? 100 : ch->apply_res_water[2]);
if (ch->apply_res_water[1] == -500)
ch->apply_res_water[0] = -500;
else
ch->apply_res_water[0] = 100 + diff - (100-resist) + (susc-100);
break;
case APPLY_REARTH:
resist = (ch->apply_res_earth[1] == 0 ? 100 : ch->apply_res_earth[1]);
susc = (ch->apply_res_earth[2] == 0 ? 100 : ch->apply_res_earth[2]);
//Getting the natural "susc/resist" to add back in later...
diff = (ch->apply_res_earth[0] + (100-resist) - (susc-100)) - 100;
if (!fAdd)
{
if (mod == 0 || mod == -1) //0 and 1 will not work
;
if (mod > -100) //Resist
{
if (mod == -ch->apply_res_earth[1])
ch->apply_res_earth[1] = 100;
}
if (mod < -100) //Susc
{
if (mod == -ch->apply_res_earth[2])
ch->apply_res_earth[2] = 100;
}
if (mod == 1) //Immune
{
ch->apply_res_earth[1] = 100;
diff = base_resis_values(ch, 4)-100;
}
}
else
{
if (mod > 100 && mod > ch->apply_res_earth[2]) //Susc
{
ch->apply_res_earth[2] = mod;
}
if (mod < 100 && mod > 1 && mod < ch->apply_res_earth[1]) //Resist
{
ch->apply_res_earth[1] = mod;
}
if (mod == -1) //Immune
ch->apply_res_earth[1] = -500;
}
resist = (ch->apply_res_earth[1] == 0 ? 100 : ch->apply_res_earth[1]);
susc = (ch->apply_res_earth[2] == 0 ? 100 : ch->apply_res_earth[2]);
if (ch->apply_res_earth[1] == -500)
ch->apply_res_earth[0] = -500;
else
ch->apply_res_earth[0] = 100 + diff - (100-resist) + (susc-100);
break;
case APPLY_RAIR:
resist = (ch->apply_res_air[1] == 0 ? 100 : ch->apply_res_air[1]);
susc = (ch->apply_res_air[2] == 0 ? 100 : ch->apply_res_air[2]);
//Getting the natural "susc/resist" to add back in later...
diff = (ch->apply_res_air[0] + (100-resist) - (susc-100)) - 100;
if (!fAdd)
{
if (mod == 0 || mod == -1) //0 and 1 will not work
;
if (mod > -100) //Resist
{
if (mod == -ch->apply_res_air[1])
ch->apply_res_air[1] = 100;
}
if (mod < -100) //Susc
{
if (mod == -ch->apply_res_air[2])
ch->apply_res_air[2] = 100;
}
if (mod == 1) //Immune
{
ch->apply_res_air[1] = 100;
diff = base_resis_values(ch, 3)-100;
}
}
else
{
if (mod > 100 && mod > ch->apply_res_air[2]) //Susc
{
ch->apply_res_air[2] = mod;
}
if (mod < 100 && mod > 1 && mod < ch->apply_res_air[1]) //Resist
{
ch->apply_res_air[1] = mod;
}
if (mod == -1) //Immune
ch->apply_res_air[1] = -500;
}
resist = (ch->apply_res_air[1] == 0 ? 100 : ch->apply_res_air[1]);
susc = (ch->apply_res_air[2] == 0 ? 100 : ch->apply_res_air[2]);
if (ch->apply_res_air[1] == -500)
ch->apply_res_air[0] = -500;
else
ch->apply_res_air[0] = 100 + diff - (100-resist) + (susc-100);
break;
case APPLY_RFIRE:
resist = (ch->apply_res_fire[1] == 0 ? 100 : ch->apply_res_fire[1]);
susc = (ch->apply_res_fire[2] == 0 ? 100 : ch->apply_res_fire[2]);
//Getting the natural "susc/resist" to add back in later...
diff = (ch->apply_res_fire[0] + (100-resist) - (susc-100)) - 100;
if (!fAdd)
{
if (mod == 0 || mod == -1) //0 and 1 will not work
;
if (mod > -100) //Resist
{
if (mod == -ch->apply_res_fire[1])
ch->apply_res_fire[1] = 100;
}
if (mod < -100) //Susc
{
if (mod == -ch->apply_res_fire[2])
ch->apply_res_fire[2] = 100;
}
if (mod == 1) //Immune
{
ch->apply_res_fire[1] = 100;
diff = base_resis_values(ch, 1)-100;
}
}
else
{
if (mod > 100 && mod > ch->apply_res_fire[2]) //Susc
{
ch->apply_res_fire[2] = mod;
}
if (mod < 100 && mod > 1 && mod < ch->apply_res_fire[1]) //Resist
{
ch->apply_res_fire[1] = mod;
}
if (mod == -1) //Immune
ch->apply_res_fire[1] = -500;
}
resist = (ch->apply_res_fire[1] == 0 ? 100 : ch->apply_res_fire[1]);
susc = (ch->apply_res_fire[2] == 0 ? 100 : ch->apply_res_fire[2]);
if (ch->apply_res_fire[1] == -500)
ch->apply_res_fire[0] = -500;
else
ch->apply_res_fire[0] = 100 + diff - (100-resist) + (susc-100);
break;
case APPLY_RMAGIC:
resist = (ch->apply_res_magic[1] == 0 ? 100 : ch->apply_res_magic[1]);
susc = (ch->apply_res_magic[2] == 0 ? 100 : ch->apply_res_magic[2]);
//Getting the natural "susc/resist" to add back in later...
diff = (ch->apply_res_magic[0] + (100-resist) - (susc-100)) - 100;
if (!fAdd)
{
if (mod == 0 || mod == -1) //0 and 1 will not work
;
if (mod > -100) //Resist
{
if (mod == -ch->apply_res_magic[1])
ch->apply_res_magic[1] = 100;
}
if (mod < -100) //Susc
{
if (mod == -ch->apply_res_magic[2])
ch->apply_res_magic[2] = 100;
}
if (mod == 1) //Immune
{
ch->apply_res_magic[1] = 100;
diff = base_resis_values(ch, 9)-100;
}
}
else
{
if (mod > 100 && mod > ch->apply_res_magic[2]) //Susc
{
ch->apply_res_magic[2] = mod;
}
if (mod < 100 && mod > 1 && mod < ch->apply_res_magic[1]) //Resist
{
ch->apply_res_magic[1] = mod;
}
if (mod == -1) //Immune
ch->apply_res_magic[1] = -500;
}
resist = (ch->apply_res_magic[1] == 0 ? 100 : ch->apply_res_magic[1]);
susc = (ch->apply_res_magic[2] == 0 ? 100 : ch->apply_res_magic[2]);
if (ch->apply_res_magic[1] == -500)
ch->apply_res_magic[0] = -500;
else
ch->apply_res_magic[0] = 100 + diff - (100-resist) + (susc-100);
break;
case APPLY_RNONMAGIC:
resist = (ch->apply_res_nonmagic[1] == 0 ? 100 : ch->apply_res_nonmagic[1]);
susc = (ch->apply_res_nonmagic[2] == 0 ? 100 : ch->apply_res_nonmagic[2]);
//Getting the natural "susc/resist" to add back in later...
diff = (ch->apply_res_nonmagic[0] + (100-resist) - (susc-100)) - 100;
if (!fAdd)
{
if (mod == 0 || mod == -1) //0 and 1 will not work
;
if (mod > -100) //Resist
{
if (mod == -ch->apply_res_nonmagic[1])
ch->apply_res_nonmagic[1] = 100;
}
if (mod < -100) //Susc
{
if (mod == -ch->apply_res_nonmagic[2])
ch->apply_res_nonmagic[2] = 100;
}
if (mod == 1) //Immune
{
ch->apply_res_nonmagic[1] = 100;
diff = base_resis_values(ch, 8)-100;
}
}
else
{
if (mod > 100 && mod > ch->apply_res_nonmagic[2]) //Susc
{
ch->apply_res_nonmagic[2] = mod;
}
if (mod < 100 && mod > 1 && mod < ch->apply_res_nonmagic[1]) //Resist
{
ch->apply_res_nonmagic[1] = mod;
}
if (mod == -1) //Immune
ch->apply_res_nonmagic[1] = -500;
}
resist = (ch->apply_res_nonmagic[1] == 0 ? 100 : ch->apply_res_nonmagic[1]);
susc = (ch->apply_res_nonmagic[2] == 0 ? 100 : ch->apply_res_nonmagic[2]);
if (ch->apply_res_nonmagic[1] == -500)
ch->apply_res_nonmagic[0] = -500;
else
ch->apply_res_nonmagic[0] = 100 + diff - (100-resist) + (susc-100);
break;
case APPLY_RBLUNT:
resist = (ch->apply_res_blunt[1] == 0 ? 100 : ch->apply_res_blunt[1]);
susc = (ch->apply_res_blunt[2] == 0 ? 100 : ch->apply_res_blunt[2]);
//Getting the natural "susc/resist" to add back in later...
diff = (ch->apply_res_blunt[0] + (100-resist) - (susc-100)) - 100;
if (!fAdd)
{
if (mod == 0 || mod == -1) //0 and 1 will not work
;
if (mod > -100) //Resist
{
if (mod == -ch->apply_res_blunt[1])
ch->apply_res_blunt[1] = 100;
}
if (mod < -100) //Susc
{
if (mod == -ch->apply_res_blunt[2])
ch->apply_res_blunt[2] = 100;
}
if (mod == 1) //Immune
{
ch->apply_res_blunt[1] = 100;
}
}
else
{
if (mod > 100 && mod > ch->apply_res_blunt[2]) //Susc
{
ch->apply_res_blunt[2] = mod;
}
if (mod < 100 && mod > 1 && mod < ch->apply_res_blunt[1]) //Resist
{
ch->apply_res_blunt[1] = mod;
}
if (mod == -1) //Immune
ch->apply_res_blunt[1] = -500;
}
resist = (ch->apply_res_blunt[1] == 0 ? 100 : ch->apply_res_blunt[1]);
susc = (ch->apply_res_blunt[2] == 0 ? 100 : ch->apply_res_blunt[2]);
if (ch->apply_res_blunt[1] == -500)
ch->apply_res_blunt[0] = -500;
else
ch->apply_res_blunt[0] = 100 + diff - (100-resist) + (susc-100);
break;
case APPLY_RPIERCE:
resist = (ch->apply_res_pierce[1] == 0 ? 100 : ch->apply_res_pierce[1]);
susc = (ch->apply_res_pierce[2] == 0 ? 100 : ch->apply_res_pierce[2]);
//Getting the natural "susc/resist" to add back in later...
diff = (ch->apply_res_pierce[0] + (100-resist) - (susc-100)) - 100;
if (!fAdd)
{
if (mod == 0 || mod == -1) //0 and 1 will not work
;
if (mod > -100) //Resist
{
if (mod == -ch->apply_res_pierce[1])
ch->apply_res_pierce[1] = 100;
}
if (mod < -100) //Susc
{
if (mod == -ch->apply_res_pierce[2])
ch->apply_res_pierce[2] = 100;
}
if (mod == 1) //Immune
{
ch->apply_res_pierce[1] = 100;
}
}
else
{
if (mod > 100 && mod > ch->apply_res_pierce[2]) //Susc
{
ch->apply_res_pierce[2] = mod;
}
if (mod < 100 && mod > 1 && mod < ch->apply_res_pierce[1]) //Resist
{
ch->apply_res_pierce[1] = mod;
}
if (mod == -1) //Immune
ch->apply_res_pierce[1] = -500;
}
resist = (ch->apply_res_pierce[1] == 0 ? 100 : ch->apply_res_pierce[1]);
susc = (ch->apply_res_pierce[2] == 0 ? 100 : ch->apply_res_pierce[2]);
if (ch->apply_res_pierce[1] == -500)
ch->apply_res_pierce[0] = -500;
else
ch->apply_res_pierce[0] = 100 + diff - (100-resist) + (susc-100);
break;
case APPLY_RSLASH:
resist = (ch->apply_res_slash[1] == 0 ? 100 : ch->apply_res_slash[1]);
susc = (ch->apply_res_slash[2] == 0 ? 100 : ch->apply_res_slash[2]);
//Getting the natural "susc/resist" to add back in later...
diff = (ch->apply_res_slash[0] + (100-resist) - (susc-100)) - 100;
if (!fAdd)
{
if (mod == 0 || mod == -1) //0 and 1 will not work
;
if (mod > -100) //Resist
{
if (mod == -ch->apply_res_slash[1])
ch->apply_res_slash[1] = 100;
}
if (mod < -100) //Susc
{
if (mod == -ch->apply_res_slash[2])
ch->apply_res_slash[2] = 100;
}
if (mod == 1) //Immune
{
ch->apply_res_slash[1] = 100;
}
}
else
{
if (mod > 100 && mod > ch->apply_res_slash[2]) //Susc
{
ch->apply_res_slash[2] = mod;
}
if (mod < 100 && mod > 1 && mod < ch->apply_res_slash[1]) //Resist
{
ch->apply_res_slash[1] = mod;
}
if (mod == -1) //Immune
ch->apply_res_slash[1] = -500;
}
resist = (ch->apply_res_slash[1] == 0 ? 100 : ch->apply_res_slash[1]);
susc = (ch->apply_res_slash[2] == 0 ? 100 : ch->apply_res_slash[2]);
if (ch->apply_res_slash[1] == -500)
ch->apply_res_slash[0] = -500;
else
ch->apply_res_slash[0] = 100 + diff - (100-resist) + (susc-100);
break;
case APPLY_RPOISON:
resist = (ch->apply_res_poison[1] == 0 ? 100 : ch->apply_res_poison[1]);
susc = (ch->apply_res_poison[2] == 0 ? 100 : ch->apply_res_poison[2]);
//Getting the natural "susc/resist" to add back in later...
diff = (ch->apply_res_poison[0] + (100-resist) - (susc-100)) - 100;
if (!fAdd)
{
if (mod == 0 || mod == -1) //0 and 1 will not work
;
if (mod > -100) //Resist
{
if (mod == -ch->apply_res_poison[1])
ch->apply_res_poison[1] = 100;
}
if (mod < -100) //Susc
{
if (mod == -ch->apply_res_poison[2])
ch->apply_res_poison[2] = 100;
}
if (mod == 1) //Immune
{
ch->apply_res_poison[1] = 100;
diff = base_resis_values(ch, 10)-100;
}
}
else
{
if (mod > 100 && mod > ch->apply_res_poison[2]) //Susc
{
ch->apply_res_poison[2] = mod;
}
if (mod < 100 && mod > 1 && mod < ch->apply_res_poison[1]) //Resist
{
ch->apply_res_poison[1] = mod;
}
if (mod == -1) //Immune
ch->apply_res_poison[1] = -500;
}
resist = (ch->apply_res_poison[1] == 0 ? 100 : ch->apply_res_poison[1]);
susc = (ch->apply_res_poison[2] == 0 ? 100 : ch->apply_res_poison[2]);
if (ch->apply_res_poison[1] == -500)
ch->apply_res_poison[0] = -500;
else
ch->apply_res_poison[0] = 100 + diff - (100-resist) + (susc-100);
break;
case APPLY_RPARALYSIS:
resist = (ch->apply_res_paralysis[1] == 0 ? 100 : ch->apply_res_paralysis[1]);
susc = (ch->apply_res_paralysis[2] == 0 ? 100 : ch->apply_res_paralysis[2]);
//Getting the natural "susc/resist" to add back in later...
diff = (ch->apply_res_paralysis[0] + (100-resist) - (susc-100)) - 100;
if (!fAdd)
{
if (mod == 0 || mod == -1) //0 and 1 will not work
;
if (mod > -100) //Resist
{
if (mod == -ch->apply_res_paralysis[1])
ch->apply_res_paralysis[1] = 100;
}
if (mod < -100) //Susc
{
if (mod == -ch->apply_res_paralysis[2])
ch->apply_res_paralysis[2] = 100;
}
if (mod == 1) //Immune
{
ch->apply_res_paralysis[1] = 100;
diff = base_resis_values(ch, 11)-100;
}
}
else
{
if (mod > 100 && mod > ch->apply_res_paralysis[2]) //Susc
{
ch->apply_res_poison[2] = mod;
}
if (mod < 100 && mod > 1 && mod < ch->apply_res_paralysis[1]) //Resist
{
ch->apply_res_paralysis[1] = mod;
}
if (mod == -1) //Immune
ch->apply_res_paralysis[1] = -500;
}
resist = (ch->apply_res_paralysis[1] == 0 ? 100 : ch->apply_res_paralysis[1]);
susc = (ch->apply_res_paralysis[2] == 0 ? 100 : ch->apply_res_paralysis[2]);
if (ch->apply_res_paralysis[1] == -500)
ch->apply_res_paralysis[0] = -500;
else
ch->apply_res_paralysis[0] = 100 + diff - (100-resist) + (susc-100);
break;
case APPLY_RHOLY:
resist = (ch->apply_res_holy[1] == 0 ? 100 : ch->apply_res_holy[1]);
susc = (ch->apply_res_holy[2] == 0 ? 100 : ch->apply_res_holy[2]);
//Getting the natural "susc/resist" to add back in later...
diff = (ch->apply_res_holy[0] + (100-resist) - (susc-100)) - 100;
if (!fAdd)
{
if (mod == 0 || mod == -1) //0 and 1 will not work
;
if (mod > -100) //Resist
{
if (mod == -ch->apply_res_holy[1])
ch->apply_res_holy[1] = 100;
}
if (mod < -100) //Susc
{
if (mod == -ch->apply_res_holy[2])
ch->apply_res_holy[2] = 100;
}
if (mod == 1) //Immune
{
ch->apply_res_holy[1] = 100;
diff = base_resis_values(ch, 6)-100;
}
}
else
{
if (mod > 100 && mod > ch->apply_res_holy[2]) //Susc
{
ch->apply_res_holy[2] = mod;
}
if (mod < 100 && mod > 1 && mod < ch->apply_res_holy[1]) //Resist
{
ch->apply_res_holy[1] = mod;
}
if (mod == -1) //Immune
ch->apply_res_holy[1] = -500;
}
resist = (ch->apply_res_holy[1] == 0 ? 100 : ch->apply_res_holy[1]);
susc = (ch->apply_res_holy[2] == 0 ? 100 : ch->apply_res_holy[2]);
if (ch->apply_res_holy[1] == -500)
ch->apply_res_holy[0] = -500;
else
ch->apply_res_holy[0] = 100 + diff - (100-resist) + (susc-100);
break;
case APPLY_RUNHOLY:
resist = (ch->apply_res_unholy[1] == 0 ? 100 : ch->apply_res_unholy[1]);
susc = (ch->apply_res_unholy[2] == 0 ? 100 : ch->apply_res_unholy[2]);
//Getting the natural "susc/resist" to add back in later...
diff = (ch->apply_res_unholy[0] + (100-resist) - (susc-100)) - 100;
if (!fAdd)
{
if (mod == 0 || mod == -1) //0 and 1 will not work
;
if (mod > -100) //Resist
{
if (mod == -ch->apply_res_unholy[1])
ch->apply_res_unholy[1] = 100;
}
if (mod < -100) //Susc
{
if (mod == -ch->apply_res_unholy[2])
ch->apply_res_unholy[2] = 100;
}
if (mod == 1) //Immune
{
ch->apply_res_unholy[1] = 100;
diff = base_resis_values(ch, 7)-100;
}
}
else
{
if (mod > 100 && mod > ch->apply_res_unholy[2]) //Susc
{
ch->apply_res_unholy[2] = mod;
}
if (mod < 100 && mod > 1 && mod < ch->apply_res_unholy[1]) //Resist
{
ch->apply_res_unholy[1] = mod;
}
if (mod == -1) //Immune
ch->apply_res_unholy[1] = -500;
}
resist = (ch->apply_res_unholy[1] == 0 ? 100 : ch->apply_res_unholy[1]);
susc = (ch->apply_res_unholy[2] == 0 ? 100 : ch->apply_res_unholy[2]);
if (ch->apply_res_unholy[1] == -500)
ch->apply_res_unholy[0] = -500;
else
ch->apply_res_unholy[0] = 100 + diff - (100-resist) + (susc-100);
break;
case APPLY_RUNDEAD:
resist = (ch->apply_res_undead[1] == 0 ? 100 : ch->apply_res_undead[1]);
susc = (ch->apply_res_undead[2] == 0 ? 100 : ch->apply_res_undead[2]);
//Getting the natural "susc/resist" to add back in later...
diff = (ch->apply_res_undead[0] + (100-resist) - (susc-100)) - 100;
if (!fAdd)
{
if (mod == 0 || mod == -1) //0 and 1 will not work
;
if (mod > -100) //Resist
{
if (mod == -ch->apply_res_undead[1])
ch->apply_res_undead[1] = 100;
}
if (mod < -100) //Susc
{
if (mod == -ch->apply_res_undead[2])
ch->apply_res_undead[2] = 100;
}
if (mod == 1) //Immune
{
ch->apply_res_undead[1] = 100;
}
}
else
{
if (mod > 100 && mod > ch->apply_res_undead[2]) //Susc
{
ch->apply_res_undead[2] = mod;
}
if (mod < 100 && mod > 1 && mod < ch->apply_res_undead[1]) //Resist
{
ch->apply_res_undead[1] = mod;
}
if (mod == -1) //Immune
ch->apply_res_undead[1] = -500;
}
resist = (ch->apply_res_undead[1] == 0 ? 100 : ch->apply_res_undead[1]);
susc = (ch->apply_res_undead[2] == 0 ? 100 : ch->apply_res_undead[2]);
if (ch->apply_res_undead[1] == -500)
ch->apply_res_undead[0] = -500;
else
ch->apply_res_undead[0] = 100 + diff - (100-resist) + (susc-100);
break;
case APPLY_MANAFUSE:
if (mod > ch->apply_manafuse)
{
ch->apply_manafuse = mod;
}
if (mod < 0 && mod + ch->apply_manafuse == 0)
ch->apply_manafuse = 0;
break;
case APPLY_FASTING:
if (mod > ch->apply_fasting)
{
ch->apply_fasting = mod;
}
if (mod < 0 && mod + ch->apply_fasting == 0)
ch->apply_fasting = 0;
break;
case APPLY_MANASHELL:
if (mod > ch->apply_manashell)
{
ch->apply_manashell = mod;
}
if (mod < 0 && mod + ch->apply_manashell == 0)
ch->apply_manashell = 0;
break;
case APPLY_MANASHIELD:
if (mod > ch->apply_manashield)
{
ch->apply_manashield = mod;
}
if (mod < 0 && mod + ch->apply_manashield == 0)
ch->apply_manashield = 0;
break;
case APPLY_MANAGUARD:
if (mod > ch->apply_managuard)
{
ch->apply_managuard = mod;
}
if (mod < 0 && mod + ch->apply_managuard == 0)
ch->apply_managuard = 0;
break;
case APPLY_MANABURN:
if (mod > ch->apply_manaburn)
{
ch->apply_manaburn = mod;
}
if (mod < 0 && mod + ch->apply_manaburn == 0)
ch->apply_manaburn = 0;
break;
case APPLY_WEAPONCLAMP:
if (mod > ch->apply_weaponclamp)
{
ch->apply_weaponclamp = mod;
}
if (mod < 0 && mod + ch->apply_weaponclamp == 0)
ch->apply_weaponclamp = 0;
break;
case APPLY_ARROWCATCH:
if (mod > ch->apply_arrowcatch)
{
ch->apply_arrowcatch = mod;
}
if (mod < 0 && mod + ch->apply_arrowcatch == 0)
ch->apply_arrowcatch = 0;
break;
case APPLY_BRACING:
if (mod > ch->apply_bracing)
{
ch->apply_bracing = mod;
}
if (mod < 0 && mod + ch->apply_bracing == 0)
ch->apply_bracing = 0;
break;
case APPLY_HARDENING:
if (mod > ch->apply_hardening)
{
ch->apply_hardening = mod;
}
if (mod < 0 && mod + ch->apply_hardening == 0)
ch->apply_hardening = 0;
break;
case APPLY_TOHIT:
ch->apply_tohit += mod;
break;
case APPLY_MANATICK:
if (mod > ch->managen)
{
ch->managen = mod;
}
if (mod < 0 && mod + ch->managen == 0)
ch->managen = 0;
break;
case APPLY_HPTICK:
if (mod > ch->hpgen)
{
ch->hpgen = mod;
}
if (mod < 0 && mod + ch->hpgen == 0)
ch->hpgen = 0;
break;
case APPLY_STR:
ch->mod_str += mod;
break;
case APPLY_DEX:
ch->mod_dex += mod;
break;
case APPLY_INT:
ch->mod_int += mod;
break;
case APPLY_WIS:
ch->mod_wis += mod;
break;
case APPLY_CON:
ch->mod_con += mod;
break;
case APPLY_CHA:
ch->mod_cha += mod;
break;
case APPLY_LCK:
ch->mod_lck += mod;
break;
case APPLY_AGI:
ch->mod_agi += mod;
break;
case APPLY_SEX:
ch->sex = (ch->sex + mod) % 3;
if (ch->sex < 0)
ch->sex += 2;
ch->sex = URANGE(0, ch->sex, 2);
break;
/*
* These are unused due to possible problems. Enable at your own risk.
*/
case APPLY_CLASS:
break;
case APPLY_LEVEL:
break;
case APPLY_AGE:
break;
case APPLY_GOLD:
break;
case APPLY_EXP:
break;
/*
* Regular apply types
*/
case APPLY_HEIGHT:
ch->height += mod;
break;
case APPLY_WEIGHT:
ch->weight += mod;
break;
case APPLY_MANA:
/*if (mod > ch->max_mana)
mod = paf->modifier = ch->max_mana;
for (saf = ch->first_affect; saf; saf = saf->next)
{
if ((saf->location % REVERSE_APPLY) == APPLY_MANA && saf != paf && fAdd)
paf->modifier = mod = 0;
}*/
ch->max_mana += mod;
break;
case APPLY_HIT:
/*if (mod > ch->max_hit)
mod = paf->modifier = ch->max_hit;
for (saf = ch->first_affect; saf; saf = saf->next)
{
if ((saf->location % REVERSE_APPLY) == APPLY_HIT && saf != paf && fAdd)
paf->modifier = mod = 0;
} */
ch->max_hit += mod;
break;
case APPLY_MOVE:
ch->max_move += mod;
break;
case APPLY_HITROLL:
ch->hitroll += mod;
break;
case APPLY_DAMROLL:
ch->damroll += mod;
break;
case APPLY_SAVING_POISON:
ch->saving_poison_death += mod;
break;
case APPLY_SAVING_ROD:
ch->saving_wand += mod;
break;
case APPLY_SAVING_PARA:
ch->saving_para_petri += mod;
break;
case APPLY_SAVING_BREATH:
ch->saving_breath += mod;
break;
case APPLY_SAVING_SPELL:
ch->saving_spell_staff += mod;
break;
/*
* Bitvector modifying apply types
*/
case APPLY_AFFECT:
SET_BIT(ch->affected_by.bits[0], mod);
break;
case APPLY_EXT_AFFECT:
xSET_BIT(ch->affected_by, mod);
break;
case APPLY_RESISTANT:
SET_BIT(ch->resistant, mod);
break;
case APPLY_IMMUNE:
SET_BIT(ch->immune, mod);
break;
case APPLY_SUSCEPTIBLE:
SET_BIT(ch->susceptible, mod);
break;
case APPLY_WEAPONSPELL: /* see fight.c */
break;
case APPLY_REMOVE:
REMOVE_BIT(ch->affected_by.bits[0], mod);
break;
/*
* Player condition modifiers
*/
case APPLY_FULL:
if (!IS_NPC(ch))
ch->pcdata->condition[COND_FULL] = URANGE(0, ch->pcdata->condition[COND_FULL] + mod, 48);
break;
case APPLY_THIRST:
if (!IS_NPC(ch))
ch->pcdata->condition[COND_THIRST] = URANGE(0, ch->pcdata->condition[COND_THIRST] + mod, 48);
break;
case APPLY_DRUNK:
if (!IS_NPC(ch))
ch->pcdata->condition[COND_DRUNK] = URANGE(0, ch->pcdata->condition[COND_DRUNK] + mod, 48);
break;
case APPLY_BLOOD:
if (!IS_NPC(ch))
ch->pcdata->condition[COND_BLOODTHIRST] = URANGE(0, ch->pcdata->condition[COND_BLOODTHIRST] + mod, ch->level + 10);
break;
case APPLY_MENTALSTATE:
ch->mental_state = URANGE(-100, ch->mental_state + mod, 100);
break;
case APPLY_EMOTION:
ch->emotional_state = URANGE(-100, ch->emotional_state + mod, 100);
break;
/*
* Specialty modfiers
*/
case APPLY_CONTAGIOUS:
break;
case APPLY_ODOR:
break;
case APPLY_STRIPSN:
if (IS_VALID_SN(mod))
affect_strip(ch, mod);
else
bug("affect_modify: APPLY_STRIPSN invalid sn %d", mod);
break;
/* spell cast upon wear/removal of an object -Thoric */
case APPLY_WEARSPELL:
case APPLY_REMOVESPELL:
if (xIS_SET(ch->in_room->room_flags, ROOM_NO_MAGIC) || wIS_SET(ch, ROOM_NO_MAGIC) || is_immune(ch, -1, RIS_MAGIC)
|| saving_char == ch /* so save/quit doesn't trigger */ || loading_char == ch) /* so loading doesn't trigger */
return;
mod = abs(mod);
if (IS_VALID_SN(mod) && (skill = skill_table[mod]) != NULL && skill->type == SKILL_SPELL)
{
if (skill->target == TAR_IGNORE || skill->target == TAR_OBJ_INV || skill->target == TAR_OBJ_ROOM)
{
bug("APPLY_WEARSPELL trying to apply bad target spell. SN is %d.", mod);
return;
}
if ((retcode = (*skill->spell_fun) (mod, ch->level, ch, ch)) == rCHAR_DIED || char_died(ch))
return;
}
break;
/*
* Skill apply types
*/
case APPLY_PALM: /* not implemented yet */
break;
case APPLY_TRACK:
modify_skill(ch, gsn_track, mod, fAdd);
break;
case APPLY_HIDE:
modify_skill(ch, gsn_hide, mod, fAdd);
break;
case APPLY_STEAL:
modify_skill(ch, gsn_steal, mod, fAdd);
break;
case APPLY_SNEAK:
modify_skill(ch, gsn_sneak, mod, fAdd);
break;
case APPLY_PICK:
modify_skill(ch, gsn_pick_lock, mod, fAdd);
break;
case APPLY_BACKSTAB:
modify_skill(ch, gsn_backstab, mod, fAdd);
break;
case APPLY_DETRAP:
modify_skill(ch, gsn_detrap, mod, fAdd);
break;
case APPLY_DODGE:
modify_skill(ch, gsn_dodge, mod, fAdd);
break;
case APPLY_PEEK:
modify_skill(ch, gsn_peek, mod, fAdd);
break;
case APPLY_SCAN:
modify_skill(ch, gsn_scan, mod, fAdd);
break;
case APPLY_GOUGE:
modify_skill(ch, gsn_gouge, mod, fAdd);
break;
case APPLY_SEARCH:
modify_skill(ch, gsn_search, mod, fAdd);
break;
case APPLY_DIG:
modify_skill(ch, gsn_dig, mod, fAdd);
break;
case APPLY_MOUNT:
break;
case APPLY_DISARM:
modify_skill(ch, gsn_disarm, mod, fAdd);
break;
case APPLY_KICK:
break;
case APPLY_PARRY:
modify_skill(ch, gsn_parry, mod, fAdd);
break;
case APPLY_BASH:
break;
case APPLY_STUN:
modify_skill(ch, gsn_stun, mod, fAdd);
break;
case APPLY_PUNCH:
break;
case APPLY_CLIMB:
modify_skill(ch, gsn_climb, mod, fAdd);
break;
case APPLY_GRIP:
modify_skill(ch, gsn_grip, mod, fAdd);
break;
case APPLY_SCRIBE:
modify_skill(ch, gsn_scribe, mod, fAdd);
break;
case APPLY_BREW:
modify_skill(ch, gsn_brew, mod, fAdd);
break;
case APPLY_COOK:
modify_skill(ch, gsn_cook, mod, fAdd);
break;
/*
* Room apply types
*/
case APPLY_ROOMFLAG:
case APPLY_SECTORTYPE:
case APPLY_ROOMLIGHT:
case APPLY_TELEVNUM:
break;
/*
* Object apply types
*/
}
/*
* Check for weapon wielding.
* Guard against recursion (for weapons with affects).
*/
if (!IS_NPC(ch) && saving_char != ch && (wield = get_eq_char(ch, WEAR_WIELD)) != NULL && get_obj_weight(wield) > str_app[get_curr_str(ch)].wield)
{
static int depth;
if (depth == 0)
{
depth++;
act(AT_ACTION, "You notice your strength decrease thus taking more time to swing your weapon!", ch, wield, NULL, TO_CHAR);
depth--;
}
}
return;
}
/*
* Give an affect to a char.
*/
void affect_to_char(CHAR_DATA * ch, AFFECT_DATA * paf)
{
AFFECT_DATA *paf_new;
if (!ch)
{
bug("Affect_to_char(NULL, %d)", paf ? paf->type : 0);
return;
}
if (!paf)
{
bug("Affect_to_char(%s, NULL)", ch->name);
return;
}
CREATE(paf_new, AFFECT_DATA, 1);
LINK(paf_new, ch->first_affect, ch->last_affect, next, prev);
paf_new->type = paf->type;
paf_new->duration = paf->duration;
paf_new->location = paf->location;
paf_new->modifier = paf->modifier;
paf_new->bitvector = paf->bitvector;
affect_modify(ch, paf_new, TRUE);
return;
}
/*
* Remove an affect from a char.
*/
void affect_remove(CHAR_DATA * ch, AFFECT_DATA * paf)
{
if (!ch->first_affect)
{
bug("Affect_remove(%s, %d): no affect.", ch->name, paf ? paf->type : 0);
return;
}
affect_modify(ch, paf, FALSE);
UNLINK(paf, ch->first_affect, ch->last_affect, next, prev);
DISPOSE(paf);
return;
}
/*
* Strip all affects of a given sn.
*/
void affect_strip(CHAR_DATA * ch, int sn)
{
AFFECT_DATA *paf;
AFFECT_DATA *paf_next;
for (paf = ch->first_affect; paf; paf = paf_next)
{
paf_next = paf->next;
if (paf->type == sn)
affect_remove(ch, paf);
}
return;
}
/*
* Return true if a char is affected by a spell.
*/
bool is_affected(CHAR_DATA * ch, int sn)
{
AFFECT_DATA *paf;
for (paf = ch->first_affect; paf; paf = paf->next)
if (paf->type == sn)
return TRUE;
return FALSE;
}
/*
* Add or enhance an affect.
* Limitations put in place by Thoric, they may be high... but at least
* they're there :)
*/
void affect_join(CHAR_DATA * ch, AFFECT_DATA * paf)
{
AFFECT_DATA *paf_old;
for (paf_old = ch->first_affect; paf_old; paf_old = paf_old->next)
if (paf_old->type == paf->type)
{
paf->duration = UMIN(1000000, paf->duration + paf_old->duration);
if (paf->modifier < 0)
{
if (paf_old->modifier < paf->modifier)
paf->modifier = paf_old->modifier;
}
else if (paf->modifier > 0)
{
if (paf_old->modifier > paf->modifier)
paf->modifier = paf_old->modifier;
}
affect_remove(ch, paf_old);
break;
}
affect_to_char(ch, paf);
return;
}
/*
* Apply only affected and RIS on a char
*/
void aris_affect(CHAR_DATA * ch, AFFECT_DATA * paf)
{
xSET_BITS(ch->affected_by, paf->bitvector);
switch (paf->location % REVERSE_APPLY)
{
case APPLY_AFFECT:
SET_BIT(ch->affected_by.bits[0], paf->modifier);
break;
case APPLY_EXT_AFFECT:
xSET_BIT(ch->affected_by, paf->modifier);
case APPLY_RESISTANT:
SET_BIT(ch->resistant, paf->modifier);
break;
case APPLY_IMMUNE:
SET_BIT(ch->immune, paf->modifier);
break;
case APPLY_SUSCEPTIBLE:
SET_BIT(ch->susceptible, paf->modifier);
break;
}
}
/*
* Update affecteds and RIS for a character in case things get messed.
* This should only really be used as a quick fix until the cause
* of the problem can be hunted down. - FB
* Last modified: June 30, 1997
*
* Quick fix? Looks like a good solution for a lot of problems.
*/
/* Temp mod to bypass immortals so they can keep their mset affects,
* just a band-aid until we get more time to look at it -- Blodkai */
void update_aris(CHAR_DATA * ch)
{
AFFECT_DATA *paf;
OBJ_DATA *obj;
int hiding;
if (IS_NPC(ch) || IS_IMMORTAL(ch))
return;
/* So chars using hide skill will continue to hide */
hiding = IS_AFFECTED(ch, AFF_HIDE);
xCLEAR_BITS(ch->affected_by);
ch->resistant = 0;
ch->immune = 0;
ch->susceptible = 0;
xCLEAR_BITS(ch->no_affected_by);
ch->no_resistant = 0;
ch->no_immune = 0;
ch->no_susceptible = 0;
/* Add in effects from race */
xSET_BITS(ch->affected_by, race_table[ch->race]->affected);
SET_BIT(ch->resistant, race_table[ch->race]->resist);
SET_BIT(ch->susceptible, race_table[ch->race]->suscept);
/* Add in effects from deities */
if (ch->pcdata->deity)
{
if (ch->pcdata->favor > ch->pcdata->deity->affectednum)
xSET_BITS(ch->affected_by, ch->pcdata->deity->affected);
if (ch->pcdata->favor > ch->pcdata->deity->elementnum)
SET_BIT(ch->resistant, ch->pcdata->deity->element);
if (ch->pcdata->favor < ch->pcdata->deity->susceptnum)
SET_BIT(ch->susceptible, ch->pcdata->deity->suscept);
}
/* Add in effect from spells */
for (paf = ch->first_affect; paf; paf = paf->next)
aris_affect(ch, paf);
/* Add in effects from equipment */
for (obj = ch->first_carrying; obj; obj = obj->next_content)
{
if (obj->wear_loc != WEAR_NONE)
{
for (paf = obj->first_affect; paf; paf = paf->next)
aris_affect(ch, paf);
for (paf = obj->pIndexData->first_affect; paf; paf = paf->next)
aris_affect(ch, paf);
}
}
/* Add in effects from the room */
if (ch->in_room) /* non-existant char booboo-fix --TRI */
for (paf = ch->in_room->first_affect; paf; paf = paf->next)
aris_affect(ch, paf);
/* Add in effects for polymorph */
if (ch->morph)
{
xSET_BITS(ch->affected_by, ch->morph->affected_by);
SET_BIT(ch->immune, ch->morph->immune);
SET_BIT(ch->resistant, ch->morph->resistant);
SET_BIT(ch->susceptible, ch->morph->suscept);
/* Right now only morphs have no_ things --Shaddai */
xSET_BITS(ch->no_affected_by, ch->morph->no_affected_by);
SET_BIT(ch->no_immune, ch->morph->no_immune);
SET_BIT(ch->no_resistant, ch->morph->no_resistant);
SET_BIT(ch->no_susceptible, ch->morph->no_suscept);
}
/* If they were hiding before, make them hiding again */
if (hiding)
xSET_BIT(ch->affected_by, AFF_HIDE);
return;
}
/*
* Move a char out of a room.
*/
void char_from_room(CHAR_DATA * ch)
{
OBJ_DATA *obj;
AFFECT_DATA *paf;
CMAP_DATA *mch;
if (!ch->in_room)
{
bug("Char_from_room: NULL.", 0);
return;
}
if (!IS_NPC(ch))
--ch->in_room->area->nplayer;
if ((obj = get_eq_char(ch, WEAR_LIGHT)) != NULL && obj->item_type == ITEM_LIGHT && obj->value[2] != 0 && ch->in_room->light > 0)
--ch->in_room->light;
/*
* Character's affect on the room
*/
for (paf = ch->first_affect; paf; paf = paf->next)
room_affect(ch->in_room, paf, FALSE);
if (!IS_NPC(ch) && xIS_SET(ch->act, PLR_MAPWINDOW) && ch->in_room->vnum == OVERLAND_SOLAN)
{
ch_printf(ch, "%s", MXPTAG("FRAME Map CLOSE"));
ch->pcdata->xsize = 0;
ch->pcdata->ysize = 0;
}
/*
* Room's affect on the character
*/
if (!char_died(ch))
{
for (paf = ch->in_room->first_affect; paf; paf = paf->next)
affect_modify(ch, paf, FALSE);
if (char_died(ch)) /* could die from removespell, etc */
return;
}
if (IS_NPC(ch))
{
for (mch = first_wilderchar; mch; mch = mch->next)
{
if (mch->mapch == ch && (mch->mapch->coord->x == ch->coord->x && mch->mapch->coord->y == ch->coord->y && mch->mapch->map == ch->map))
{
UNLINK(mch, first_wilderchar, last_wilderchar, next, prev);
top_map_mob--;
}
}
}
UNLINK(ch, ch->in_room->first_person, ch->in_room->last_person, next_in_room, prev_in_room);
ch->was_in_room = ch->in_room;
ch->in_room = NULL;
ch->next_in_room = NULL;
ch->prev_in_room = NULL;
if (!IS_NPC(ch) && get_timer(ch, TIMER_SHOVEDRAG) > 0)
remove_timer(ch, TIMER_SHOVEDRAG);
return;
}
/*
* Enough resources to build? Docks if needed -- Xerves 12/99
*/
bool enough_resources(CHAR_DATA * ch, int hometown, int needed, int ctype)
{
if (needed > ch->pcdata->town->lumber)
{
ch_printf(ch, "You need %d units, your hometown cannot afford that.\n\r", needed);
return FALSE;
}
if (ctype == 0)
ch->pcdata->town->lumber -= needed;
return TRUE;
}
/*
* Move a char into a room.
*/
void char_to_room(CHAR_DATA * ch, ROOM_INDEX_DATA * pRoomIndex)
{
OBJ_DATA *obj;
AFFECT_DATA *paf;
CMAP_DATA *mch;
if (!ch)
{
bug("Char_to_room: NULL ch!", 0);
return;
}
if (!pRoomIndex)
{
bug("Char_to_room: %s -> NULL room! Putting char in limbo (%d)", ch->name, ROOM_VNUM_LIMBO);
/*
* This used to just return, but there was a problem with crashing
* and I saw no reason not to just put the char in limbo. -Narn
*/
pRoomIndex = get_room_index(ROOM_VNUM_LIMBO);
}
ch->in_room = pRoomIndex;
LINK(ch, pRoomIndex->first_person, pRoomIndex->last_person, next_in_room, prev_in_room);
if (IS_NPC(ch) && ch->in_room->vnum == OVERLAND_SOLAN)
{
CREATE(mch, CMAP_DATA, 1);
mch->mapch = ch;
LINK(mch, first_wilderchar, last_wilderchar, next, prev);
top_map_mob++;
}
if (!IS_NPC(ch))
if (++pRoomIndex->area->nplayer > pRoomIndex->area->max_players)
pRoomIndex->area->max_players = pRoomIndex->area->nplayer;
if ((obj = get_eq_char(ch, WEAR_LIGHT)) != NULL && obj->item_type == ITEM_LIGHT && obj->value[2] != 0)
++pRoomIndex->light;
if (ch->pcdata && ch->pcdata->quest && ch->pcdata->quest->questarea == ch->in_room->area
&& ch->pcdata->quest->timeleft > 0 && ch->pcdata->quest->mission == 2)
{
int x;
CHAR_DATA *gch;
ch->pcdata->quest->killed++;
if (ch->pcdata->quest->traveltime > -1)
ch->pcdata->quest->traveltime = 0;
if (pRoomIndex->vnum == pRoomIndex->area->hi_r_vnum) //Win
{
for (x = 0; x <= 5; x++)
{
if (ch->pcdata->quest->player[x] == ch->pcdata->pid)
{
ch_printf(ch, "\n\r^r&CYou have completed your quest, your reward is %d QP^x\n\r\n\r", ch->pcdata->quest->qp[x]);
ch->pcdata->quest_curr += ch->pcdata->quest->qp[x];
ch->pcdata->quest_accum += ch->pcdata->quest->qp[x];
ch->pcdata->quest_wins++;
}
}
for (gch = first_char; gch; gch = gch->next)
{
if (IS_NPC(gch))
continue;
if (gch == ch)
continue;
if (!gch->pcdata->quest)
continue;
if (gch->pcdata->quest->questarea != ch->in_room->area)
continue;
if (gch->pcdata->quest != ch->pcdata->quest)
continue;
for (x = 0; x <= 5; x++)
{
if (gch->pcdata->quest->player[x] == gch->pcdata->pid)
{
ch_printf(gch, "\n\r^r&CYou have completed your quest, your reward is %d QP^x\n\r\n\r", gch->pcdata->quest->qp[x]);
gch->pcdata->quest_curr += gch->pcdata->quest->qp[x];
gch->pcdata->quest_accum += gch->pcdata->quest->qp[x];
gch->pcdata->quest_wins++;
gch->pcdata->quest->timeleft = -1;
gch->pcdata->quest->tillnew = 25;
}
}
}
ch->pcdata->quest->timeleft = -1;
ch->pcdata->quest->tillnew = 25;
}
}
/*
* Room's effect on the character
*/
if (!char_died(ch))
{
for (paf = pRoomIndex->first_affect; paf; paf = paf->next)
affect_modify(ch, paf, TRUE);
if (char_died(ch)) /* could die from a wearspell, etc */
return;
}
/*
* Character's effect on the room
*/
for (paf = ch->first_affect; paf; paf = paf->next)
room_affect(pRoomIndex, paf, TRUE);
if (!IS_NPC(ch) && (check_room_pk(ch) == 1))
{
if (get_timer(ch, TIMER_SHOVEDRAG) > 0)
remove_timer(ch, TIMER_SHOVEDRAG);
add_timer(ch, TIMER_SHOVEDRAG, 4, NULL, 0);/*-12 Seconds-*/
}
/*
* Delayed Teleport rooms -Thoric
* Should be the last thing checked in this function
*/
if (xIS_SET(pRoomIndex->room_flags, ROOM_TELEPORT) && pRoomIndex->tele_delay > 0)
{
TELEPORT_DATA *tele;
for (tele = first_teleport; tele; tele = tele->next)
if (tele->room == pRoomIndex)
return;
CREATE(tele, TELEPORT_DATA, 1);
LINK(tele, first_teleport, last_teleport, next, prev);
tele->room = pRoomIndex;
tele->timer = pRoomIndex->tele_delay;
}
if (ch->on)
{
ch->on = NULL;
ch->position = POS_STANDING;
}
if (ch->mount)
{
ch->mount->on = NULL;
ch->mount->position = POS_STANDING;
}
if (!ch->was_in_room)
ch->was_in_room = ch->in_room;
return;
}
//Checks carrying weight/number, replaced the integer due to it being inaccurate at times
float get_ch_carry_weight(CHAR_DATA *ch)
{
OBJ_DATA *obj;
float weight = 0;
for (obj = ch->first_carrying; obj; obj = obj->next_content)
{
weight += get_obj_weight(obj);
}
if (ch->rider)
{
weight += (float)ch->rider->weight;
weight += get_ch_carry_weight(ch->rider);
}
return weight;
}
int get_ch_carry_number(CHAR_DATA *ch)
{
OBJ_DATA *obj;
int weight = 0;
for (obj = ch->first_carrying; obj; obj = obj->next_content)
{
if (obj->wear_loc == WEAR_NONE)
weight += get_obj_number(obj);
}
return weight;
}
OBJ_DATA *bank_to_char(OBJ_DATA * obj, CHAR_DATA *ch)
{
if (ch != NULL)
{
if (IN_WILDERNESS(ch))
{
SET_OBJ_STAT(obj, ITEM_ONMAP);
obj->map = ch->map;
obj->coord->x = ch->coord->x;
obj->coord->y = ch->coord->y;
}
else
{
REMOVE_OBJ_STAT(obj, ITEM_ONMAP);
obj->map = -1;
obj->coord->x = -1;
obj->coord->y = -1;
}
}
else
{
REMOVE_OBJ_STAT(obj, ITEM_ONMAP);
obj->map = -1;
obj->coord->x = -1;
obj->coord->y = -1;
}
UNLINK(obj, ch->pcdata->first_bankobj, ch->pcdata->last_bankobj, next_content, prev_content);
obj->carried_by = NULL;
obj->in_room = NULL;
obj->in_obj = NULL;
return obj;
}
OBJ_DATA *townbank_to_char(OBJ_DATA * obj, TOWN_DATA *town, CHAR_DATA *ch)
{
if (ch != NULL)
{
if (IN_WILDERNESS(ch))
{
SET_OBJ_STAT(obj, ITEM_ONMAP);
obj->map = ch->map;
obj->coord->x = ch->coord->x;
obj->coord->y = ch->coord->y;
}
else
{
REMOVE_OBJ_STAT(obj, ITEM_ONMAP);
obj->map = -1;
obj->coord->x = -1;
obj->coord->y = -1;
}
}
else
{
REMOVE_OBJ_STAT(obj, ITEM_ONMAP);
obj->map = -1;
obj->coord->x = -1;
obj->coord->y = -1;
}
UNLINK(obj, town->first_bankobj, town->last_bankobj, next_content, prev_content);
obj->carried_by = NULL;
obj->in_room = NULL;
obj->in_obj = NULL;
return obj;
}
OBJ_DATA *obj_to_bank(OBJ_DATA * obj, CHAR_DATA *ch)
{
OBJ_DATA *otmp;
OBJ_DATA *oret = NULL;
int grouped = FALSE;
REMOVE_OBJ_STAT(obj, ITEM_ONMAP);
obj->map = -1;
obj->coord->x = -1;
obj->coord->y = -1;
for (otmp = ch->pcdata->first_bankobj; otmp; otmp = otmp->next_content)
{
if ((oret = group_object(otmp, obj)) == otmp)
{
grouped = TRUE;
break;
}
}
if (!grouped)
{
LINK(obj, ch->pcdata->first_bankobj, ch->pcdata->last_bankobj, next_content, prev_content);
obj->carried_by = NULL;
obj->in_room = NULL;
obj->in_obj = NULL;
return obj;
}
else
return oret;
}
OBJ_DATA *obj_to_townbank(OBJ_DATA * obj, TOWN_DATA *town)
{
OBJ_DATA *otmp;
OBJ_DATA *oret = NULL;
int grouped = FALSE;
REMOVE_OBJ_STAT(obj, ITEM_ONMAP);
obj->map = -1;
obj->coord->x = -1;
obj->coord->y = -1;
for (otmp = town->first_bankobShowing the first 100 KB of 228.8 KB. Download the archive for the full file.