handler.c
exodus2/src/handler.c · 191.3 KB
From the archive exodus2.tar.gz
Download the archive « Back to the archive contents
#include <sys/types.h>
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include "merc.h"
#include "magic.h"
#include <stdlib.h>
#include "recycle.h"
#include "tables.h"
#include "interp.h"
#include "clans/new_clans.h"
#include "clans/new_clans_comm.h"
#include "clans/new_clans_io.h"
#include "clans/new_clans_util.h"
#include "obj_trig.h"
#include "olc.h"
DECLARE_DO_FUN (do_return);
extern bool ch_is_quitting;
extern bool paddling;
void falcon_alert args ((CHAR_DATA * ch));
int flag_value args ((const struct flag_type * flag_table, char *argument));
inline bool IS_CLASS args((CHAR_DATA * ch, short class));
inline bool is_affected args((CHAR_DATA * ch, int sn));
short level_for_skill_2 (CHAR_DATA * ch, short sn);
void save_player_corpse args((OBJ_DATA* corpse));
bool cardgame_surrender args((CHAR_DATA *ch, bool premature));
void check_gravity_room_obj args((CHAR_DATA *people,OBJ_DATA *obj));
void switched_return args((CHAR_DATA *ch, ROOM_INDEX_DATA *location));
void friend_poof args((CHAR_DATA *ch));
int hands_used args((CHAR_DATA *ch));
int hands_required args((CHAR_DATA *ch, OBJ_DATA *obj));
bool equip_char_slot_new args((CHAR_DATA * ch, OBJ_DATA * obj, long slot));
/*
* Local functions.
*/
void affect_modify args ((CHAR_DATA * ch, AFFECT_DATA * paf, bool fAdd));
inline char *one_argument (char *argument, char *arg_first)
{
char cEnd;
while (isspace (*argument))
argument++;
cEnd = ' ';
if (*argument == '\'' || *argument == '"')
cEnd = *argument++;
while (*argument != '\0')
{
if (*argument == cEnd)
{
argument++;
break;
}
*arg_first = LOWER (*argument);
arg_first++;
argument++;
}
*arg_first = '\0';
while (isspace (*argument))
argument++;
return argument;
}
inline char *one_argument_nl (char *argument, char *arg_first)
{
char cEnd;
while (isspace (*argument))
argument++;
cEnd = ' ';
if (*argument == '\'' || *argument == '"')
cEnd = *argument++;
while (*argument != '\0')
{
if (*argument == cEnd)
{
argument++;
break;
}
*arg_first = *argument;
arg_first++;
argument++;
}
*arg_first = '\0';
while (isspace (*argument))
argument++;
return argument;
}
/* friend stuff -- for NPC's mostly */
bool is_friend (CHAR_DATA * ch, CHAR_DATA * victim)
{
if (is_same_group (ch, victim))
return TRUE;
if (!IS_NPC (ch))
return FALSE;
if (!IS_NPC (victim))
{
if (IS_SET (ch->off_flags, ASSIST_PLAYERS))
return TRUE;
else
return FALSE;
}
if (IS_AFFECTED (ch, AFF_CHARM))
return FALSE;
if (IS_SET (ch->off_flags, ASSIST_ALL))
return TRUE;
if (ch->group && ch->group == victim->group)
return TRUE;
if (IS_SET (ch->off_flags, ASSIST_VNUM)
&& ch->pIndexData == victim->pIndexData)
return TRUE;
if (IS_SET (ch->off_flags, ASSIST_RACE) && ch->race == victim->race)
return TRUE;
if (IS_SET (ch->off_flags, ASSIST_ALIGN)
&& ((IS_GOOD (ch) && IS_GOOD (victim))
|| (IS_EVIL (ch) && IS_EVIL (victim))
|| (IS_NEUTRAL (ch) && IS_NEUTRAL (victim))))
return TRUE;
return FALSE;
}
/* returns number of people on an object */
int count_users (OBJ_DATA * obj)
{
CHAR_DATA *fch;
int count = 0;
if (obj->in_room == NULL)
return 0;
for (fch = obj->in_room->people; fch != NULL; fch = fch->next_in_room)
if (fch->on == obj)
count++;
return count;
}
/* returns race number */
int race_lookup (const char *name)
{
int race;
for (race = 0; race_table[race].name != NULL; race++)
{
if (LOWER (name[0]) == LOWER (race_table[race].name[0])
&& !str_prefix (name, race_table[race].name))
return race;
}
return 0;
}
int orace_lookup (const char *name)
{
int race;
for (race = 1; race_table[race].name != NULL; race++)
{
if (LOWER (name[0]) == LOWER (race_table[race].name[0])
&& !str_prefix (name, race_table[race].name))
return race;
}
return 0;
}
int liq_lookup (const char *name)
{
int liq;
for (liq = 0; liq_table[liq].liq_name != NULL; liq++)
{
if (LOWER (name[0]) == LOWER (liq_table[liq].liq_name[0])
&& !str_prefix (name, liq_table[liq].liq_name))
return liq;
}
return -1;
}
int weapon_lookup (const char *name)
{
int type;
for (type = 0; weapon_table[type].name != NULL; type++)
{
if (LOWER (name[0]) == LOWER (weapon_table[type].name[0])
&& !str_prefix (name, weapon_table[type].name))
return type;
}
return -1;
}
int weapon_type (const char *name)
{
int type;
for (type = 0; weapon_table[type].name != NULL; type++)
{
if (LOWER (name[0]) == LOWER (weapon_table[type].name[0])
&& !str_prefix (name, weapon_table[type].name))
return weapon_table[type].type;
}
return WEAPON_EXOTIC;
}
int item_lookup (const char *name)
{
int type;
for (type = 0; item_table[type].name != NULL; type++)
{
if (LOWER (name[0]) == LOWER (item_table[type].name[0])
&& !str_prefix (name, item_table[type].name))
return item_table[type].type;
}
return -1;
}
char *item_name (int item_type)
{
int type;
for (type = 0; item_table[type].name != NULL; type++)
if (item_type == item_table[type].type)
return item_table[type].name;
return "none";
}
char *weapon_name (int weapon_type)
{
int type;
for (type = 0; weapon_table[type].name != NULL; type++)
if (weapon_type == weapon_table[type].type)
return weapon_table[type].name;
return "exotic";
}
int attack_lookup (const char *name)
{
int att;
for (att = 0; attack_table[att].name != NULL; att++)
{
if (LOWER (name[0]) == LOWER (attack_table[att].name[0])
&& !str_prefix (name, attack_table[att].name))
return att;
}
return 0;
}
/* returns a flag for wiznet */
long wiznet_lookup (const char *name)
{
int flag;
for (flag = 0; wiznet_table[flag].name != NULL; flag++)
{
if (LOWER (name[0]) == LOWER (wiznet_table[flag].name[0])
&& !str_prefix (name, wiznet_table[flag].name))
return flag;
}
return -1;
}
/* returns class number */
int class_lookup (const char *name)
{
int class;
for (class = 0; class < MAX_CLASS; class++)
{
if (LOWER (name[0]) == LOWER (class_table[class].name[0])
&& !str_prefix (name, class_table[class].name))
return class;
}
return -1;
}
int hand_lookup (const char *name)
{
int hand;
for (hand = 0; hand < 3; hand++)
{
if (!str_cmp (name, "left"))
return (HAND_LEFT);
if (!str_cmp (name, "right"))
return (HAND_RIGHT);
if (!str_cmp (name, "ambidextrous"))
return (HAND_AMBIDEXTROUS);
}
return -1;
}
/* for immunity, vulnerabiltiy, and resistant
the 'globals' (magic and weapons) may be overriden
three other cases -- wood, silver, and iron -- are checked in fight.c */
int check_immune (CHAR_DATA * ch, int dam_type)
{
int immune, def;
int bit;
immune = -1;
def = IS_NORMAL;
if (dam_type == DAM_NONE)
return immune;
if (dam_type == DAM_UNIQUE)
return 0;
if (dam_type <= 3)
{
if (IS_SET (ch->imm_flags, IMM_WEAPON))
def = IS_IMMUNE;
else if (IS_SET (ch->res_flags, RES_WEAPON))
def = IS_RESISTANT;
else if (IS_SET (ch->vuln_flags, VULN_WEAPON))
def = IS_VULNERABLE;
}
else if (dam_type != DAM_VAMPIRIC)
/* magical attack */
{
if (IS_SET (ch->imm_flags, IMM_MAGIC))
def = IS_IMMUNE;
else if (IS_SET (ch->res_flags, RES_MAGIC))
def = IS_RESISTANT;
else if (IS_SET (ch->vuln_flags, VULN_MAGIC))
def = IS_VULNERABLE;
}
/* set bits to check -- VULN etc. must ALL be the same or this will fail */
switch (dam_type)
{
case (DAM_BASH):
bit = IMM_BASH;
break;
case (DAM_PIERCE):
bit = IMM_PIERCE;
break;
case (DAM_SLASH):
bit = IMM_SLASH;
break;
case (DAM_FIRE):
bit = IMM_FIRE;
break;
case (DAM_COLD):
bit = IMM_COLD;
break;
case (DAM_LIGHTNING):
bit = IMM_LIGHTNING;
break;
case (DAM_ACID):
bit = IMM_ACID;
break;
case (DAM_POISON):
bit = IMM_POISON;
break;
case (DAM_NEGATIVE):
bit = IMM_NEGATIVE;
break;
case (DAM_HOLY):
bit = IMM_HOLY;
break;
case (DAM_ENERGY):
bit = IMM_ENERGY;
break;
case (DAM_MENTAL):
bit = IMM_MENTAL;
break;
case (DAM_DISEASE):
bit = IMM_DISEASE;
break;
case (DAM_DROWNING):
bit = IMM_DROWNING;
break;
case (DAM_LIGHT):
bit = IMM_LIGHT;
break;
case (DAM_CHARM):
bit = IMM_CHARM;
break;
case (DAM_SOUND):
bit = IMM_SOUND;
break;
default:
return def;
}
if (IS_SET (ch->imm_flags, bit))
immune = IS_IMMUNE;
else if (IS_SET (ch->res_flags, bit) && immune != IS_IMMUNE)
immune = IS_RESISTANT;
else if (IS_SET (ch->vuln_flags, bit))
{
if (immune == IS_IMMUNE)
immune = IS_RESISTANT;
else if (immune == IS_RESISTANT)
immune = IS_NORMAL;
else
immune = IS_VULNERABLE;
}
if (immune == -1)
return def;
else return immune;
}
int get_char_weight (CHAR_DATA * ch)
{
int weight;
switch (ch->size)
{
case SIZE_TINY:
weight = 500;
break;
case SIZE_SMALL:
weight = 800;
break;
default:
case SIZE_MEDIUM:
weight = 1400;
break;
case SIZE_LARGE:
weight = 1750;
break;
case SIZE_HUGE:
weight = 2500;
break;
case SIZE_GIANT:
weight = 4000;
break;
}
weight += get_carry_weight (ch);
return (weight);
}
/* for returning skill information */
int get_skill (CHAR_DATA * ch, int sn)
{
int skill=0;
// char buf[30];
if (ch->stunned)
return 0;
if (sn == -1)
{ /* shorthand for level based skills */
skill = ch->level * 5 / 2;
}
else if (sn < -1 || sn > MAX_SKILL)
{
bug ("Bad sn %d in get_skill.", sn);
skill = 0;
}
else if (!IS_NPC (ch))
{
if (ch->level < level_for_skill (ch, sn))
skill = 0;
else if (sn == gsn_swim)
{
if ((get_carry_weight (ch) / 10) > (can_carry_w (ch) / 10))
skill = 0;
else if (ch->race == PC_RACE_CANTHI || ch->race == PC_RACE_NIDAE)
skill = 100;
else if (ch->race == PC_RACE_DWARF)
skill = 0;
else skill = ch->pcdata->learned[sn];
}
else
skill = ch->pcdata->learned[sn];
skill += ch->pcdata->mod_learned[sn];
if (sn == gsn_dual_wield && skill > 0 && ch->race == PC_RACE_NERIX)
skill = 100;
if (sn == gsn_steal && ch->class == PC_CLASS_CHAOS_JESTER)
skill = 50;
}
else
/* mobiles */
{
//Iblis - if mob is an obj trigger mob, they have 100% in ALL skills
if (ch->pIndexData->vnum == MOB_VNUM_FAKIE)
return 100;
if (IS_SET(ch->act2,ACT_ALL_SKILLS))
{
if (!(sn == gsn_dodge || sn == gsn_flicker || sn == gsn_parry || sn == gsn_conceal
|| sn == gsn_prevent_escape || sn == gsn_awareness || sn == gsn_hear_the_wind
|| sn == gsn_dirty_tactics || sn == gsn_counter || sn == gsn_feed_death))
return 100;
}
//Iblis - if mob is a CJ created mob, they only have the hardcoded skills below
if (IS_SET(ch->act2,ACT_PUPPET))
{
if (ch->pIndexData->vnum == MOB_VNUM_FROG)
{
if (sn == skill_lookup("ice beam"))
return 100;
else return 0;
}
if (ch->pIndexData->vnum == MOB_VNUM_WARPED_CAT)
{
if (sn == gsn_dodge)
return 100;
else if (sn == gsn_avoid_traps)
return 100;
else return 0;
}
if (ch->pIndexData->vnum == MOB_VNUM_WARPED_OWL)
{
if (sn == gsn_swoop)
return 100;
else return 0;
}
}
//Iblis - if mob is a necromancer familiar, they only have the hardcoded skills below
//at 100 (if they are high enough level), otherwise they have the skill at 0%
if (IS_SET(ch->act2,ACT_FAMILIAR))
{
if (ch->pIndexData->vnum == MOB_VNUM_FAM_ZOMBIE)
{
if (sn == gsn_kick && ch->level >= 10)
return 100;
else if (sn == gsn_dagger)
return 100;
else if (sn == gsn_dodge && ch->level >= 30)
return 100;
else if (sn == gsn_parry && ch->level >= 39)
return 100;
else if (sn == gsn_backstab && ch->level >= 40)
return 100;
else if (sn == gsn_sneak && ch->level >= 50)
return 100;
else if (sn == gsn_second_attack && ch->level >= 50)
return 100;
else if (sn == gsn_enhanced_damage && ch->level >= 62)
return 100;
else if (sn == gsn_circle && ch->level >= 55)
return 100;
else if (sn == gsn_plague && ch->level >= 60)
return 100;
else if (sn == gsn_fear && ch->level >= 80)
return 100;
else return 0;
}
if (ch->pIndexData->vnum == MOB_VNUM_FAM_SKELETON)
{
if (sn == gsn_bash && ch->level >= 30)
return 100;
else if (sn == gsn_sword || sn == gsn_axe || sn == gsn_dagger
|| sn == gsn_polearm || sn == gsn_mace || sn == gsn_flail
|| sn == gsn_staff || sn == gsn_hand_to_hand)
return 100;
else if (sn == gsn_dual_wield && ch->level >= 35)
return 100;
else if (sn == gsn_berserk && ch->level >= 40)
return 100;
else if (sn == gsn_rescue && ch->level >= 50)
return 100;
else if (sn == gsn_second_attack && ch->level >= 50)
return 100;
else if (sn == gsn_third_attack && ch->level >= 55)
return 100;
else if (sn == gsn_enhanced_damage && ch->level >= 62)
return 100;
else if (sn == gsn_critical_strike && ch->level >= 70)
return 100;
else if (sn == gsn_hellbreath && ch->level >= 80)
return 100;
else return 0;
}
if (ch->pIndexData->vnum == MOB_VNUM_FAM_BANSHEE)
{
if (sn == gsn_hand_to_hand)
return 100;
else if (sn == gsn_fisticuffery && ch->level >= 30)
return 100;
else if (sn == gsn_second_attack && ch->level >= 50)
return 100;
else if (sn == gsn_enhanced_damage && ch->level >= 62)
return 100;
else if (sn == gsn_kai && ch->level >= 40)
return 100;
else if (sn == skill_lookup("Ballad of the Cantankerous Woodsman") && ch->level >= 28)
return 100;
else if (sn == skill_lookup("Falkentynes Fury") && ch->level >= 13)
return 100;
else return 0;
}
if (ch->pIndexData->vnum == MOB_VNUM_IMAGINARY_FRIEND)
{
if (sn == gsn_sword && ch->level >= 10)
return 100;
else if (sn == gsn_flail && ch->level >= 25)
return 100;
else if (sn == gsn_enhanced_damage && ch->level >= 30)
return 100;
else if (sn == gsn_dagger && ch->level >= 45)
return 100;
else if (sn == gsn_redirect && ch->level >= 50)
return 100;
else if (sn == gsn_dirty_tactics && ch->level >= 75)
return 100;
else if (sn == gsn_pick_lock && ch->level >= 90)
return 100;
else return 0;
}
return 0;
}
if (skill_table[sn].spell_fun != spell_null)
skill = 40 + 2 * ch->level;
else if (sn == gsn_sneak || sn == gsn_hide)
skill = ch->level * 2 + 20;
else if ((sn == gsn_dodge && IS_SET (ch->off_flags, OFF_DODGE))
|| (sn == gsn_parry && IS_SET (ch->off_flags, OFF_PARRY)))
skill = ch->level * 2;
else if (sn == gsn_shield_block)
skill = 10 + 2 * ch->level;
else if (sn == gsn_second_attack && (IS_SET (ch->act, ACT_WARRIOR)
|| IS_SET (ch->act, ACT_THIEF)))
skill = 10 + 3 * ch->level;
else if (sn == gsn_third_attack && IS_SET (ch->act, ACT_WARRIOR))
skill = 4 * ch->level - 40;
else if (sn == gsn_hand_to_hand)
skill = 40 + 2 * ch->level;
else if (sn == gsn_trip && IS_SET (ch->off_flags, OFF_TRIP))
skill = 10 + 3 * ch->level;
else if (sn == gsn_bash && IS_SET (ch->off_flags, OFF_BASH))
skill = 10 + 3 * ch->level;
else if (sn == gsn_counter && IS_SET (ch->off_flags, OFF_COUNTER))
skill = 10 + 3 * ch->level;
else if (sn == gsn_disarm && (IS_SET (ch->off_flags, OFF_DISARM)
|| IS_SET (ch->act, ACT_WARRIOR)
|| IS_SET (ch->act, ACT_THIEF)))
skill = 20 + 3 * ch->level;
else if (sn == gsn_berserk && IS_SET (ch->off_flags, OFF_BERSERK))
skill = 3 * ch->level;
else if (sn == gsn_kick)
skill = 10 + 3 * ch->level;
else if (sn == gsn_backstab && IS_SET (ch->act, ACT_THIEF))
skill = 20 + 2 * ch->level;
else if (sn == gsn_rescue)
skill = 40 + ch->level;
else if (sn == gsn_sword
|| sn == gsn_dagger
|| sn == gsn_staff
|| sn == gsn_dice
|| sn == gsn_mace
|| sn == gsn_axe || sn == gsn_flail || sn == gsn_polearm)
skill = 40 + 5 * ch->level / 2;
//Iblis - hardcoded skill %'s for mobs set ACT_MONK
else if (sn == gsn_critical_strike && IS_SET (ch->act2, ACT_MONK))
skill = 40 + ch->level;
else if (sn == gsn_counter && IS_SET (ch->act2, ACT_MONK))
skill = 40 + ch->level;
else if (sn == gsn_dive && IS_SET (ch->act2, ACT_MONK))
skill = 40 + ch->level;
else if (sn == gsn_prevent_escape && IS_SET (ch->act2, ACT_MONK))
skill = 40 + ch->level;
else if (sn == gsn_hear_the_wind && IS_SET (ch->act2, ACT_MONK))
skill = 40 + ch->level;
else if (sn == gsn_strike && IS_SET (ch->act2, ACT_MONK))
skill = 40 + ch->level;
else if (sn == gsn_awareness && IS_SET (ch->act2, ACT_MONK))
skill = 40 + ch->level;
else if (sn == gsn_dirty_tactics && (IS_SET (ch->act2, ACT_MONK) || IS_SET (ch->act2, ACT_THIEF)))
skill = 40 + ch->level;
else if (sn == gsn_whirlwind && IS_SET (ch->act2, ACT_MONK))
skill = 40 + ch->level;
else if (sn == gsn_fists_of_fury && IS_SET (ch->act2, ACT_MONK))
skill = 40 + ch->level;
//Iblis - hardcoded skill %'s for mobs set ACT_MAGE
else if (IS_SET (ch->act, ACT_MAGE) && (sn == skill_lookup("dispel magic")
|| sn == skill_lookup("blindness")
|| sn == skill_lookup("weaken")
|| sn == skill_lookup("curse")
|| sn == skill_lookup("colour spray")
|| sn == skill_lookup("magic missle")
|| sn == skill_lookup("acid blast")
|| sn == skill_lookup("energy drain")
|| sn == skill_lookup("heat metal")
|| sn == skill_lookup("web")
|| sn == skill_lookup("firestorm")
|| sn == skill_lookup("fireball")))
skill = 40 + ch->level;
else if (IS_SET (ch->act2, ACT_NECROMANCER) && (sn >= skill_lookup("death palm"))
&& (sn <= skill_lookup("unsummon")))
skill = 40 + ch->level;
else if (IS_SET (ch->act2, ACT_MAGE_SKILLS) && (sn == gsn_staves
|| sn == gsn_brew || sn == gsn_scrolls
|| sn == gsn_wands || sn == gsn_scribe))
skill = 40 + ch->level;
else if (sn == gsn_charge && IS_SET (ch->off_flags,OFF_CHARGE))
skill = 40 + ch->level;
else if (sn == gsn_sweep && IS_SET (ch->off_flags,OFF_SWEEP))
skill = 40 + ch->level;
else if (sn == gsn_stun && IS_SET (ch->off_flags,OFF_STUN))
skill = 40 + ch->level;
else if (sn == gsn_kai && IS_SET (ch->off_flags,OFF_KAI))
skill = 40 + ch->level;
else if (sn == gsn_hellbreath && IS_SET (ch->off_flags,OFF_HELLBREATH))
skill = 10 + 3 * ch->level;
else
skill = 0; //Shinowlan 03/26/2002 -- added to support mob scripts.
//this way mobs can use all skills as needed.
//Shinowlan 06/25/2002 - set back to the standard level of zero, was causing crash bugs (kai)
}
if (ch->daze > 0)
{
if (skill_table[sn].spell_fun != spell_null)
skill /= 2;
else
skill = 2 * skill / 3;
}
if (!IS_NPC (ch) && ch->pcdata->condition[COND_DRUNK] > 10)
skill = 9 * skill / 10;
return URANGE (0, skill, 100);
}
/* for returning weapon information */
int get_weapon_sn (CHAR_DATA * ch, int wield_type)
{
OBJ_DATA *wield;
int sn;
wield = get_eq_char (ch, wield_type);
if (wield == NULL || wield->item_type != ITEM_WEAPON)
sn = gsn_hand_to_hand;
else
switch (wield->value[0])
{
default:
sn = -1;
break;
case (WEAPON_SWORD):
sn = gsn_sword;
break;
case (WEAPON_DAGGER):
sn = gsn_dagger;
break;
case (WEAPON_STAFF):
sn = gsn_staff;
break;
case (WEAPON_MACE):
sn = gsn_mace;
break;
case (WEAPON_AXE):
sn = gsn_axe;
break;
case (WEAPON_FLAIL):
sn = gsn_flail;
break;
case (WEAPON_POLEARM):
sn = gsn_polearm;
break;
case (WEAPON_DICE):
sn = gsn_dice;
break;
}
return sn;
}
int get_weapon_skill (CHAR_DATA * ch, int sn)
{
int skill;
/* -1 is exotic */
if (IS_NPC (ch))
{
if (sn == -1)
skill = 3 * ch->level;
/* Using get_skill so familiar work properly
else if (sn == gsn_hand_to_hand)
skill = 40 + 2 * ch->level;
else
skill = 40 + 5 * ch->level / 2;
*/
else skill = get_skill(ch,sn);
}
else
{
if (sn == -1)
skill = 3 * ch->level;
else
skill = ch->pcdata->learned[sn];
}
return URANGE (0, skill, 100);
}
/* used to de-screw characters */
void reset_char (CHAR_DATA * ch)
{
int loc, mod, stat;
OBJ_DATA *obj;
AFFECT_DATA *af;
int i,k;
long wear_flags_left=0;
if (IS_NPC (ch))
return;
if (ch->pcdata->perm_hit == 0
|| ch->pcdata->perm_mana == 0
|| ch->pcdata->perm_move == 0 || ch->pcdata->last_level == 0)
{
/* do a FULL reset */
// for (loc = 0; loc < MAX_WEAR; loc++)
// {
for (k = 0;wear_conversion_table[k].wear_loc != -2;++k)
{
if (wear_conversion_table[k].wear_flag == ITEM_TAKE || wear_conversion_table[k].wear_flag == ITEM_NO_SAC)
continue;
if (!IS_SET(wear_flags_left,wear_conversion_table[k].wear_flag))
continue;
loc = wear_conversion_table[k].wear_loc;
obj = get_eq_char (ch, loc);
if (obj == NULL)
continue;
REMOVE_BIT(wear_flags_left,obj->wear_loc);
// obj = get_eq_char (ch, loc);
// if (obj == NULL)
// continue;
if (!obj->enchanted)
for (af = obj->pIndexData->affected; af != NULL; af = af->next)
{
mod = af->modifier;
switch (af->location)
{
case APPLY_SEX:
ch->sex -= mod;
if (ch->sex < 0 || ch->sex > 2)
ch->sex = IS_NPC (ch) ? 0 : ch->pcdata->true_sex;
break;
case APPLY_MANA:
ch->max_mana -= mod;
break;
case APPLY_HIT:
ch->max_hit -= mod;
break;
case APPLY_MOVE:
ch->max_move -= mod;
break;
}
}
for (af = obj->affected; af != NULL; af = af->next)
{
mod = af->modifier;
switch (af->location)
{
case APPLY_SEX:
ch->sex -= mod;
break;
case APPLY_MANA:
ch->max_mana -= mod;
break;
case APPLY_HIT:
ch->max_hit -= mod;
break;
case APPLY_MOVE:
ch->max_move -= mod;
break;
}
}
}
/* now reset the permanent stats */
ch->pcdata->perm_hit = ch->max_hit;
ch->pcdata->perm_mana = ch->max_mana;
ch->pcdata->perm_move = ch->max_move;
ch->pcdata->last_level = ch->played / 3600;
if (ch->pcdata->true_sex < 0 || ch->pcdata->true_sex > 2)
{
if (ch->sex > 0 && ch->sex < 3)
ch->pcdata->true_sex = ch->sex;
else
ch->pcdata->true_sex = 0;
}
}
/* now restore the character to his/her true condition */
for (stat = 0; stat < MAX_STATS; stat++)
ch->mod_stat[stat] = 0;
if (ch->pcdata->true_sex < 0 || ch->pcdata->true_sex > 2)
ch->pcdata->true_sex = 0;
ch->sex = ch->pcdata->true_sex;
if (!is_affected(ch,gsn_scramble))
{
ch->max_hit = ch->pcdata->perm_hit;
ch->max_mana = ch->pcdata->perm_mana;
ch->max_move = ch->pcdata->perm_move;
}
for (i = 0; i < 4; i++)
ch->armor[i] = 100;
ch->hitroll = 0;
ch->damroll = 0;
ch->saving_throw = 0;
for (i = 1; wear_conversion_table[i].wear_loc != -2;++i)
wear_flags_left |= wear_conversion_table[i].wear_flag;
/* now start adding back the effects */
// for (loc = 0; loc < MAX_WEAR; loc++)
for (k = 0;wear_conversion_table[k].wear_loc != -2;++k)
{
if (wear_conversion_table[k].wear_flag == ITEM_TAKE || wear_conversion_table[k].wear_flag == ITEM_NO_SAC)
continue;
if (!IS_SET(wear_flags_left,wear_conversion_table[k].wear_flag))
continue;
loc = wear_conversion_table[k].wear_loc;
obj = get_eq_char (ch, loc);
if (obj == NULL)
continue;
REMOVE_BIT(wear_flags_left,obj->wear_loc);
for (i = 0; i < 4; i++)
ch->armor[i] -= apply_ac_new (obj, i);
if (!obj->enchanted)
for (af = obj->pIndexData->affected; af != NULL; af = af->next)
{
mod = af->modifier;
switch (af->location)
{
case APPLY_STR:
ch->mod_stat[STAT_STR] += mod;
break;
case APPLY_DEX:
ch->mod_stat[STAT_DEX] += mod;
break;
case APPLY_INT:
ch->mod_stat[STAT_INT] += mod;
break;
case APPLY_WIS:
ch->mod_stat[STAT_WIS] += mod;
break;
case APPLY_CON:
ch->mod_stat[STAT_CON] += mod;
break;
case APPLY_CHA:
ch->mod_stat[STAT_CHA] += mod;
break;
case APPLY_SEX:
ch->sex += mod;
break;
case APPLY_MANA:
ch->max_mana += mod;
break;
case APPLY_HIT:
ch->max_hit += mod;
break;
case APPLY_MOVE:
ch->max_move += mod;
break;
case APPLY_AC:
for (i = 0; i < 4; i++)
ch->armor[i] += mod;
break;
case APPLY_HITROLL:
ch->hitroll += mod;
break;
case APPLY_DAMROLL:
ch->damroll += mod;
break;
case APPLY_SAVES:
ch->saving_throw += mod;
break;
case APPLY_SAVING_ROD:
ch->saving_throw += mod;
break;
case APPLY_SAVING_PETRI:
ch->saving_throw += mod;
break;
case APPLY_SAVING_BREATH:
ch->saving_throw += mod;
break;
case APPLY_SAVING_SPELL:
ch->saving_throw += mod;
break;
}
}
for (af = obj->affected; af != NULL; af = af->next)
{
mod = af->modifier;
switch (af->location)
{
case APPLY_STR:
ch->mod_stat[STAT_STR] += mod;
break;
case APPLY_DEX:
ch->mod_stat[STAT_DEX] += mod;
break;
case APPLY_INT:
ch->mod_stat[STAT_INT] += mod;
break;
case APPLY_WIS:
ch->mod_stat[STAT_WIS] += mod;
break;
case APPLY_CON:
ch->mod_stat[STAT_CON] += mod;
break;
case APPLY_CHA:
ch->mod_stat[STAT_CHA] += mod;
break;
case APPLY_SEX:
ch->sex += mod;
break;
case APPLY_MANA:
ch->max_mana += mod;
break;
case APPLY_HIT:
ch->max_hit += mod;
break;
case APPLY_MOVE:
ch->max_move += mod;
break;
case APPLY_AC:
for (i = 0; i < 4; i++)
ch->armor[i] += mod;
break;
case APPLY_HITROLL:
ch->hitroll += mod;
break;
case APPLY_DAMROLL:
ch->damroll += mod;
break;
case APPLY_SAVES:
ch->saving_throw += mod;
break;
case APPLY_SAVING_ROD:
ch->saving_throw += mod;
break;
case APPLY_SAVING_PETRI:
ch->saving_throw += mod;
break;
case APPLY_SAVING_BREATH:
ch->saving_throw += mod;
break;
case APPLY_SAVING_SPELL:
ch->saving_throw += mod;
break;
}
}
}
/* now add back spell effects */
for (af = ch->affected; af != NULL; af = af->next)
{
mod = af->modifier;
switch (af->location)
{
case APPLY_STR:
ch->mod_stat[STAT_STR] += mod;
break;
case APPLY_DEX:
ch->mod_stat[STAT_DEX] += mod;
break;
case APPLY_INT:
ch->mod_stat[STAT_INT] += mod;
break;
case APPLY_WIS:
ch->mod_stat[STAT_WIS] += mod;
break;
case APPLY_CON:
ch->mod_stat[STAT_CON] += mod;
break;
case APPLY_CHA:
ch->mod_stat[STAT_CHA] += mod;
break;
case APPLY_SEX:
ch->sex += mod;
break;
case APPLY_MANA:
ch->max_mana += mod;
break;
case APPLY_HIT:
ch->max_hit += mod;
break;
case APPLY_MOVE:
ch->max_move += mod;
break;
case APPLY_AC:
for (i = 0; i < 4; i++)
ch->armor[i] += mod;
break;
case APPLY_HITROLL:
ch->hitroll += mod;
break;
case APPLY_DAMROLL:
ch->damroll += mod;
break;
case APPLY_SAVES:
ch->saving_throw += mod;
break;
case APPLY_SAVING_ROD:
ch->saving_throw += mod;
break;
case APPLY_SAVING_PETRI:
ch->saving_throw += mod;
break;
case APPLY_SAVING_BREATH:
ch->saving_throw += mod;
break;
case APPLY_SAVING_SPELL:
ch->saving_throw += mod;
break;
}
}
/* make sure sex is RIGHT!!!! */
if (ch->sex < 0 || ch->sex > 2)
ch->sex = ch->pcdata->true_sex;
}
/*
* Retrieve a character's trusted level for permission checking.
*/
int get_trust (CHAR_DATA * ch)
{
if (ch == NULL)
{
// bug ("NULL ch in get_trust", 0);
return 0;
}
if (ch->desc != NULL && ch->desc->original != NULL)
ch = ch->desc->original;
if (ch == NULL)
{
bug ("NULL ch in get_trust (2)", 0);
return 0;
}
if (ch->trust != 0 && IS_SET (ch->comm, COMM_TRUE_TRUST))
return ch->trust;
if (IS_NPC (ch) && ch->level >= LEVEL_HERO)
return LEVEL_HERO - 1;
else
return ch->level;
}
/*
* Retrieve a character's age.
*/
int get_age (CHAR_DATA * ch)
{
if (!IS_NPC(ch) && ch->race == PC_RACE_NERIX)
{
return 1 + ((ch->played + (int) (current_time - ch->logon)) - ch->pcdata->nplayed)/36000;
}
else return 17 + (ch->played + (int) (current_time - ch->logon)) / 72000;
}
/* command for retrieving stats */
int get_curr_stat (CHAR_DATA * ch, int stat)
{
int max;
if (IS_NPC (ch) || ch->level > LEVEL_IMMORTAL)
max = 25;
else
{
//IBLIS 5/19/03 - Changed so the max is the max trainable,
//or 3 + natural stat, whichever is greater
if (ch->race == race_lookup ("avatar"))
max = 25;
max = pc_race_table[ch->race].max_stats[stat]; // + 4;
if (class_table[ch->class].attr_prime == stat)
max += 2;
//if (ch->race == race_lookup ("human"))
//max += 1;
max = UMAX (max, ch->perm_stat[stat] + 3);
max = UMIN (max, 25);
}
return URANGE (3, ch->perm_stat[stat] + ch->mod_stat[stat], max);
}
/* command for returning max training score */
int get_max_train (CHAR_DATA * ch, int stat)
{
int max;
if (IS_NPC (ch) || ch->level > LEVEL_IMMORTAL)
return 25;
if (ch->race == race_lookup ("avatar"))
max = 25;
max = pc_race_table[ch->race].max_stats[stat];
if (class_table[ch->class].attr_prime == stat)
{
if (ch->race == race_lookup ("human"))
max += 3;
else
max += 2;
}
return UMIN (max, 25);
}
/*
* Retrieve a character's carry capacity.
*/
int can_carry_n (CHAR_DATA * ch)
{
if (!IS_NPC (ch) && ch->level >= LEVEL_IMMORTAL)
return 1000;
/* if (IS_NPC(ch) && IS_SET(ch->act, ACT_PET))
return 0; */
return MAX_WEAR + 2 * get_curr_stat (ch, STAT_DEX) + ch->level;
}
/*
* Retrieve a character's carry capacity.
*/
int can_carry_w (CHAR_DATA * ch)
{
if (!IS_NPC (ch) && ch->level >= LEVEL_IMMORTAL)
return 10000000;
/* if (IS_NPC(ch) && IS_SET(ch->act, ACT_PET))
return 0; */
return str_app[get_curr_stat (ch, STAT_STR)].carry * 10 + ch->level * 25;
}
/*
* See if a string is one of the names of an object.
*/
bool is_name (char *str, char *namelist)
{
char name[MAX_INPUT_LENGTH], part[MAX_INPUT_LENGTH];
char *list, *string;
/* fix crash on NULL namelist */
if (namelist == NULL || namelist[0] == '\0')
return FALSE;
/* fixed to prevent is_name on "" returning TRUE */
/* if (str[0] == '\0')
return FALSE; */
string = str;
/* we need ALL parts of string to match part of namelist */
for (;;)
{ /* start parsing string */
str = one_argument (str, part);
if (part[0] == '\0')
return TRUE;
/* check to see if this is part of namelist */
list = namelist;
for (;;)
{ /* start parsing namelist */
list = one_argument (list, name);
if (name[0] == '\0') /* this name was not found */
return FALSE;
if (!str_prefix (string, name))
return TRUE; /* full pattern match */
if (!str_prefix (part, name))
break;
}
}
}
bool is_name_no_abbrev (char *str, char *namelist)
{
char name[MAX_INPUT_LENGTH], part[MAX_INPUT_LENGTH];
char buf[MAX_STRING_LENGTH], arg[MAX_INPUT_LENGTH];
char *list, *string;
strcpy (buf, str);
one_argument (buf, arg);
if (arg[0] == '\0')
return (FALSE);
string = str;
/* we need ALL parts of string to match part of namelist */
for (;;)
{ /* start parsing string */
str = one_argument (str, part);
if (part[0] == '\0')
return TRUE;
/* check to see if this is part of namelist */
list = namelist;
for (;;)
{ /* start parsing namelist */
list = one_argument (list, name);
if (name[0] == '\0') /* this name was not found */
return FALSE;
if (!str_cmp (string, name))
return TRUE; /* full pattern match */
if (!str_cmp (part, name))
break;
}
}
}
/* enchanted stuff for eq */
void affect_enchant (OBJ_DATA * obj)
{
/* okay, move all the old flags into new vectors if we have to */
if (!obj->enchanted)
{
AFFECT_DATA *paf, *af_new;
obj->enchanted = TRUE;
for (paf = obj->pIndexData->affected; paf != NULL; paf = paf->next)
{
af_new = new_affect ();
af_new->next = obj->affected;
obj->affected = af_new;
af_new->where = paf->where;
af_new->type = UMAX (0, paf->type);
af_new->level = paf->level;
af_new->duration = paf->duration;
af_new->location = paf->location;
af_new->modifier = paf->modifier;
af_new->bitvector = paf->bitvector;
af_new->composition = paf->composition;
af_new->comp_name = str_dup (paf->comp_name);
}
}
}
/*
* Apply or remove an affect to a character.
*/
void affect_modify (CHAR_DATA * ch, AFFECT_DATA * paf, bool fAdd)
{
OBJ_DATA *wield;
int mod, i,sn;
mod = paf->modifier;
if (fAdd)
{
switch (paf->where)
{
case TO_AFFECTS:
SET_BIT (ch->affected_by, paf->bitvector);
break;
case TO_IMMUNE:
SET_BIT (ch->imm_flags, paf->bitvector);
break;
case TO_RESIST:
SET_BIT (ch->res_flags, paf->bitvector);
break;
case TO_VULN:
SET_BIT (ch->vuln_flags, paf->bitvector);
break;
case TO_ACT2:
SET_BIT (ch->act2, paf->bitvector);
break;
//Iblis - below added for skill and equipment affects that modify a character's skill %
case TO_SKILL:
if (!IS_NPC(ch))
{
if (paf->location != 0 && skill_table[paf->location].name != NULL)
{
ch->pcdata->mod_learned[paf->location] += paf->modifier;
}
else if (paf->location == 0)
{
for (sn = 0; sn < MAX_SKILL; sn++)
{
if (skill_table[sn].name != NULL)
{
ch->pcdata->mod_learned[sn] += paf->modifier;
}
}
}
}
return;
}
}
else
{
switch (paf->where)
{
case TO_AFFECTS:
REMOVE_BIT (ch->affected_by, paf->bitvector);
break;
case TO_IMMUNE:
REMOVE_BIT (ch->imm_flags, paf->bitvector);
break;
case TO_RESIST:
REMOVE_BIT (ch->res_flags, paf->bitvector);
break;
case TO_VULN:
REMOVE_BIT (ch->vuln_flags, paf->bitvector);
break;
case TO_ACT2:
REMOVE_BIT (ch->act2, paf->bitvector);
if (!IS_NPC(ch) && paf->bitvector == ACT_WARPED)
ch->res_flags = race_table[ch->race].res;
break;
//Iblis - below added for skill and equipment affects that modify a character's skill %
case TO_SKILL:
if (!IS_NPC(ch))
{
if (paf->location != 0 && skill_table[paf->location].name != NULL)
{
ch->pcdata->mod_learned[paf->location] -= paf->modifier;
}
else if (paf->location == 0)
{
for (sn = 0; sn < MAX_SKILL; sn++)
{
if (skill_table[sn].name != NULL)
{
ch->pcdata->mod_learned[sn] -= paf->modifier;
}
}
}
}
return;
}
mod = 0 - mod;
}
switch (paf->location)
{
default:
bug ("Affect_modify: unknown location %d.", paf->location);
return;
case APPLY_NONE:
break;
case APPLY_STR:
ch->mod_stat[STAT_STR] += mod;
break;
case APPLY_DEX:
ch->mod_stat[STAT_DEX] += mod;
break;
case APPLY_INT:
ch->mod_stat[STAT_INT] += mod;
break;
case APPLY_WIS:
ch->mod_stat[STAT_WIS] += mod;
break;
case APPLY_CON:
ch->mod_stat[STAT_CON] += mod;
break;
case APPLY_CHA:
ch->mod_stat[STAT_CHA] += mod;
break;
case APPLY_SEX:
ch->sex += mod;
break;
case APPLY_CLASS:
break;
case APPLY_LEVEL:
break;
case APPLY_AGE:
break;
case APPLY_HEIGHT:
break;
case APPLY_WEIGHT:
break;
case APPLY_MANA:
ch->max_mana += mod;
break;
case APPLY_HIT:
ch->max_hit += mod;
break;
case APPLY_MOVE:
ch->max_move += mod;
break;
case APPLY_GOLD:
break;
case APPLY_EXP:
break;
case APPLY_AC:
for (i = 0; i < 4; i++)
ch->armor[i] += mod;
break;
case APPLY_HITROLL:
ch->hitroll += mod;
break;
case APPLY_DAMROLL:
ch->damroll += mod;
break;
case APPLY_SAVES:
ch->saving_throw += mod;
break;
case APPLY_SAVING_ROD:
ch->saving_throw += mod;
break;
case APPLY_SAVING_PETRI:
ch->saving_throw += mod;
break;
case APPLY_SAVING_BREATH:
ch->saving_throw += mod;
break;
case APPLY_SAVING_SPELL:
ch->saving_throw += mod;
break;
case APPLY_SPELL_AFFECT:
break;
}
/*
* Check for weapon wielding.
* Guard against recursion (for weapons with affects).
*/
if (!IS_NPC (ch)
&& (wield =
get_eq_char (ch,
WEAR_WIELD_R)) !=
NULL && get_obj_weight (wield) >
(str_app[get_curr_stat (ch, STAT_STR)].wield * 10))
{
static int depth;
if (depth == 0)
{
depth++;
obj_from_char (wield);
obj_to_room (wield, ch->in_room);
//Iblis - 3/11/04 - Antiduping Code
if (ch && !IS_NPC(ch))
save_char_obj (ch);
if (!ch_is_quitting)
{
act ("You drop $p.", ch, wield, NULL, TO_CHAR);
act ("$n drops $p.", ch, wield, NULL, TO_ROOM);
}
depth--;
}
}
if (!IS_NPC (ch) && (wield = get_eq_char (ch, WEAR_WIELD_L)) != NULL
&& get_obj_weight (wield) >
(str_app[get_curr_stat (ch, STAT_STR)].wield * 10))
{
static int depth;
if (depth == 0)
{
depth++;
obj_from_char (wield);
obj_to_room (wield, ch->in_room);
if (!ch_is_quitting)
{
//Iblis - 3/11/04 - Antiduping Code
if (ch && !IS_NPC(ch))
save_char_obj (ch);
act ("You drop $p.", ch, wield, NULL, TO_CHAR);
act ("$n drops $p.", ch, wield, NULL, TO_ROOM);
}
depth--;
}
}
return;
}
/* find an effect in an affect list */
AFFECT_DATA *affect_find (AFFECT_DATA * paf, int sn)
{
AFFECT_DATA *paf_find;
for (paf_find = paf; paf_find != NULL; paf_find = paf_find->next)
{
if (paf_find->type == sn)
return paf_find;
}
return NULL;
}
/* fix object affects when removing one */
void affect_check (CHAR_DATA * ch, int where, int vector)
{
AFFECT_DATA *paf;
OBJ_DATA *obj;
if (where == TO_OBJECT || where == TO_WEAPON || vector == 0 || where == TO_OBJECT2)
return;
for (paf = ch->affected; paf != NULL; paf = paf->next)
if (paf->where == where && paf->bitvector == vector)
{
switch (where)
{
case TO_AFFECTS:
SET_BIT (ch->affected_by, vector);
break;
case TO_IMMUNE:
SET_BIT (ch->imm_flags, vector);
break;
case TO_RESIST:
SET_BIT (ch->res_flags, vector);
break;
case TO_VULN:
SET_BIT (ch->vuln_flags, vector);
break;
case TO_ACT2:
SET_BIT (ch->act2,vector);
break;
}
return;
}
for (obj = ch->carrying; obj != NULL; obj = obj->next_content)
{
if (obj->wear_loc == -1)
continue;
for (paf = obj->affected; paf != NULL; paf = paf->next)
if (paf->where == where && paf->bitvector == vector)
{
switch (where)
{
case TO_AFFECTS:
SET_BIT (ch->affected_by, vector);
break;
case TO_IMMUNE:
SET_BIT (ch->imm_flags, vector);
break;
case TO_RESIST:
SET_BIT (ch->res_flags, vector);
break;
case TO_VULN:
SET_BIT (ch->vuln_flags, vector);
break;
case TO_ACT2:
SET_BIT (ch->act2, vector);
break;
}
return;
}
if (obj->enchanted)
continue;
for (paf = obj->pIndexData->affected; paf != NULL; paf = paf->next)
if (paf->where == where && paf->bitvector == vector)
{
switch (where)
{
case TO_AFFECTS:
SET_BIT (ch->affected_by, vector);
break;
case TO_IMMUNE:
SET_BIT (ch->imm_flags, vector);
break;
case TO_RESIST:
SET_BIT (ch->res_flags, vector);
break;
case TO_VULN:
SET_BIT (ch->vuln_flags, vector);
break;
case TO_ACT2:
SET_BIT (ch->act2, vector);
}
return;
}
}
}
void affect_to_char (CHAR_DATA * ch, AFFECT_DATA * paf)
{
AFFECT_DATA *paf_new;
if (IS_SET (ch->affected_by, paf->bitvector))
return;
paf_new = new_affect ();
paf_new->where = paf->where;
paf_new->type = paf->type;
paf_new->level = paf->level;
paf_new->duration = paf->duration;
paf_new->location = paf->location;
paf_new->modifier = paf->modifier;
paf_new->bitvector = paf->bitvector;
paf_new->permaff = paf->permaff;
paf_new->composition = paf->composition;
paf_new->comp_name = str_dup (paf->comp_name);
/* *paf_new = *paf; */
paf_new->next = ch->affected;
ch->affected = paf_new;
affect_modify (ch, paf_new, TRUE);
return;
}
/* give an affect to an object */
void affect_to_obj (OBJ_DATA * obj, AFFECT_DATA * paf)
{
AFFECT_DATA *paf_new;
paf_new = new_affect ();
paf_new->where = paf->where;
paf_new->type = paf->type;
paf_new->level = paf->level;
paf_new->duration = paf->duration;
paf_new->location = paf->location;
paf_new->modifier = paf->modifier;
paf_new->bitvector = paf->bitvector;
paf_new->permaff = paf->permaff;
paf_new->composition = paf->composition;
paf_new->comp_name = str_dup (paf->comp_name);
/* *paf_new = *paf; */
paf_new->next = obj->affected;
obj->affected = paf_new;
/* apply any affect vectors to the object's extra_flags */
if (paf->bitvector)
switch (paf->where)
{
case TO_OBJECT:
SET_BIT (obj->extra_flags[0], paf->bitvector);
break;
case TO_OBJECT2:
SET_BIT (obj->extra_flags[1], paf->bitvector);
break;
case TO_WEAPON:
if (obj->item_type == ITEM_WEAPON)
SET_BIT (obj->value[4], paf->bitvector);
break;
}
return;
}
/*
* Remove an affect from a char.
*/
void affect_remove (CHAR_DATA * ch, AFFECT_DATA * paf)
{
int where;
int vector;
if (ch->affected == NULL)
{
bug ("Affect_remove: no affect.", 0);
return;
}
affect_modify (ch, paf, FALSE);
where = paf->where;
vector = paf->bitvector;
if (paf == ch->affected)
{
ch->affected = paf->next;
}
else
{
AFFECT_DATA *prev;
for (prev = ch->affected; prev != NULL; prev = prev->next)
{
if (prev->next == paf)
{
prev->next = paf->next;
break;
}
}
if (prev == NULL)
{
bug ("Affect_remove: cannot find paf.", 0);
return;
}
}
if (paf->bitvector == AFF_CHARM && ch->race != PC_RACE_SIDHE
&& ch->leader != NULL && ch->leader->race == PC_RACE_SIDHE)
{
act ("Repulsed by $n's very presence, you push $m away in disgust.",
ch, NULL, ch->leader, TO_VICT);
act
("Your mind pulls free of the grasp of $N's magic, and $E pushes you away with a look of utter disgust.",
ch, NULL, ch->leader, TO_CHAR);
if (ch->master->pet == ch)
ch->master->pet = NULL;
ch->master = NULL;
ch->leader = NULL;
}
else if (paf->bitvector == AFF_CHARM && ch->race == PC_RACE_SIDHE
&& ch->leader != NULL && ch->leader->race != PC_RACE_SIDHE)
{
act ("You regain control of your mind and push $N away in contempt.",
ch, NULL, ch->leader, TO_CHAR);
act
("$n snaps his head to glare balefully at you a second before he escapes your magical grasp and slinks away.",
ch, NULL, ch->leader, TO_VICT);
if (ch->master->pet == ch)
ch->master->pet = NULL;
ch->master = NULL;
ch->leader = NULL;
}
if (paf->type == gsn_contaminate && ch->contaminator)
{
send_to_char("Someone somewhere has broken free of your contamination.\n\r",ch->contaminator);
/* ch->contaminator->mana -= 100;
ch->contaminator->move -= 100;
damage (ch->contaminator,ch->contaminator,100,gsn_contaminate,DAM_UNIQUE,FALSE);*/
ch->contaminator = NULL;
}
if (paf->type == gsn_dehydration && ch->race == PC_RACE_NIDAE)
{
ch->perm_stat[STAT_CHA] += 9;
ch->perm_stat[STAT_DEX] += 5;
}
if (paf->type == gsn_transform && !IS_NPC(ch))
{
REMOVE_BIT(ch->act2,ACT_TRANSFORMER);
free_string(ch->long_descr);
ch->long_descr = str_dup("");
free_string(ch->short_descr);
ch->short_descr = str_dup("");
}
if (paf->type == gsn_spider_vine)
{
OBJ_DATA* obj;
obj = get_eq_char (ch, WEAR_WRIST_L);
if (obj != NULL)
unequip_char(ch,obj);
obj_from_char(obj);
extract_obj(obj);
obj = get_eq_char (ch, WEAR_WRIST_R);
if (obj != NULL)
unequip_char(ch,obj);
obj_from_char(obj);
extract_obj(obj);
obj = get_eq_char (ch, WEAR_ARMS);
if (obj != NULL)
unequip_char(ch,obj);
obj_from_char(obj);
extract_obj(obj);
}
if (paf->type == gsn_soul_link)
{
if (!IS_NPC(ch))
if (ch->pcdata->soul_link)
{
ch->pcdata->soul_link->pcdata->soul_link = NULL;
affect_strip(ch->pcdata->soul_link,gsn_soul_link);
ch->pcdata->soul_link = NULL;
}
}
/*
if (paf->type == gsn_intoxicate)
{
if (!IS_NPC(ch))
ch->pcdata->condition[COND_DRUNK] = 0;
}
*/
if (paf->type == gsn_bark_skin)
affect_strip (ch, gsn_spider_vine);
if (paf->type == gsn_scramble && !IS_NPC(ch))
{
OBJ_DATA *obj, *obj_next;
long wear_long;
int hit_difference = 0, mana_difference = 0, move_difference = 0;
ch->max_hit = 1000;
ch->max_move = 1000;
ch->max_mana = 1000;
for (obj = ch->carrying; obj != NULL; obj = obj_next)
{
obj_next = obj->next_content;
if (obj->wear_loc == WEAR_NONE)
continue;
wear_long = obj->wear_loc;
// if (obj->affected)
// {
unequip_char (ch, obj);
hit_difference += (1000-ch->max_hit);
mana_difference += (1000-ch->max_mana);
move_difference += (1000-ch->max_move);
equip_char_slot_new (ch, obj, wear_long);
// }
}
/* ch->max_hit = ch->pcdata->perm_hit;
ch->max_move = ch->pcdata->perm_move;
ch->max_mana = ch->pcdata->perm_mana;*/
ch->max_hit = ch->pcdata->perm_hit + hit_difference;
ch->max_move = ch->pcdata->perm_move + move_difference;
ch->max_mana = ch->pcdata->perm_mana + mana_difference;
}
free_affect (paf);
affect_check (ch, where, vector);
return;
}
void affect_remove_obj (OBJ_DATA * obj, AFFECT_DATA * paf)
{
int where, vector;
if (obj->affected == NULL)
{
bug ("Affect_remove_object: no affect.", 0);
return;
}
if (obj->carried_by != NULL && obj->wear_loc != -1)
affect_modify (obj->carried_by, paf, FALSE);
where = paf->where;
vector = paf->bitvector;
/* remove flags from the object if needed */
if (paf->bitvector)
switch (paf->where)
{
case TO_OBJECT:
REMOVE_BIT (obj->extra_flags[0], paf->bitvector);
break;
case TO_OBJECT2:
REMOVE_BIT (obj->extra_flags[1], paf->bitvector);
break;
case TO_WEAPON:
if (obj->item_type == ITEM_WEAPON)
REMOVE_BIT (obj->value[4], paf->bitvector);
break;
}
if (paf == obj->affected)
{
obj->affected = paf->next;
}
else
{
AFFECT_DATA *prev;
for (prev = obj->affected; prev != NULL; prev = prev->next)
{
if (prev->next == paf)
{
prev->next = paf->next;
break;
}
}
if (prev == NULL)
{
bug ("Affect_remove_object: cannot find paf.", 0);
return;
}
}
free_affect (paf);
if (obj->carried_by != NULL && obj->wear_loc != -1)
affect_check (obj->carried_by, where, vector);
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->affected; paf != NULL; 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.
*/
inline bool is_affected (CHAR_DATA * ch, int sn)
{
AFFECT_DATA *paf;
if (ch == NULL)
return FALSE;
//Iblis 10/30/04 - Bad hack, but saves changing of a LOT of code
if (sn == gsn_mirror && IS_SET(ch->act2,ACT_ALWAYS_MIRRORED))
return TRUE;
for (paf = ch->affected; paf != NULL; paf = paf->next)
{
if (paf->type == sn && paf->composition == FALSE)
return TRUE;
}
return FALSE;
}
/*
* Strip all affects that modify skills.
*/
void affect_strip_skills (CHAR_DATA * ch)
{
AFFECT_DATA *paf;
AFFECT_DATA *paf_next;
for (paf = ch->affected; paf != NULL; paf = paf_next)
{
paf_next = paf->next;
if (paf->where == TO_SKILL)
affect_remove (ch, paf);
}
return;
}
/*
* Add or enhance an affect.
*/
void affect_join (CHAR_DATA * ch, AFFECT_DATA * paf)
{
AFFECT_DATA *paf_old;
bool found;
found = FALSE;
for (paf_old = ch->affected; paf_old != NULL; paf_old = paf_old->next)
{
if (paf_old->type == paf->type)
{
paf->level = (paf->level += paf_old->level) / 2;
paf->duration += paf_old->duration;
paf->modifier += paf_old->modifier;
affect_remove (ch, paf_old);
break;
}
}
affect_to_char (ch, paf);
return;
}
/*
* Move a char out of a room.
*/
void char_from_room (CHAR_DATA * ch)
{
OBJ_DATA *obj;
CHAR_DATA *fch, *fch_next;
//char buf[MAX_STRING_LENGTH];
if (ch->in_room == NULL)
{
return;
}
if (!IS_NPC (ch) && ch->pcdata && (ch->pcdata->cg_state != 0 || ch->pcdata->cg_ticks != 0))
{
if (ch->pcdata->cg_state > CG_ANTE_ACCEPTED)
cardgame_surrender(ch,TRUE);
else if (ch->pcdata->cg_state == 0)
do_cardduel(ch,"quit");
else do_ante(ch,"quit");
}
if (!IS_NPC (ch))
{
--ch->in_room->area->nplayer;
//do_echo(ch,"num_players--");
}
/* if (ch->in_room->area->nplayer < 0)
{
ch->in_room->area->nplayer = 0;
// do_echo(ch,"num_players < 0 so set to 0");
}*/
if ((((obj = get_eq_char (ch, WEAR_LIGHT)) != NULL
&& obj->item_type == ITEM_LIGHT
&& obj->value[2] != 0) || (!IS_NPC(ch) && ch->pcdata->flaming))
&& ch->in_room->light > 0)
--ch->in_room->light;
if (ch == ch->in_room->people)
{
/* If top of the people list in the room, set top of
* list to the next_in_room. Mathew 4/14/99
*/
ch->in_room->people = ch->next_in_room;
}
else
{
/* Otherwise, remove ch from the people in room list. Mathew 4/14/99
*/
CHAR_DATA *prev;
for (prev = ch->in_room->people; prev; prev = prev->next_in_room)
{
if (prev->next_in_room == ch)
{
prev->next_in_room = ch->next_in_room;
break;
}
}
// sprintf(buf,"char_from_room:ch found. (%s)",ch->name);
// bug (buf,0);
if (prev == NULL)
{
// sprintf (buf, "Char_from_room:ch not found. (%s)", ch->name);
// bug (buf, 0);
}
}
for (fch = ch->in_room->people; fch != NULL; fch = fch_next)
{
TRIGGER_DATA *pTrig;
fch_next = fch->next_in_room;
if (!IS_NPC (fch))
continue;
if (!can_see (fch, ch) || !IS_AWAKE (fch))
continue;
if (ch == fch)
continue;
if (HAS_SCRIPT (fch))
for (pTrig = fch->triggers; pTrig != NULL; pTrig = pTrig->next)
if (pTrig->trigger_type == TRIG_EXIT && pTrig->current ==
NULL && !IS_SET (fch->act, ACT_HALT))
{
act_trigger (fch, pTrig->name, NULL, NAME (ch), NAME (fch));
pTrig->current = pTrig->script;
pTrig->bits = SCRIPT_ADVANCE;
}
}
ch->in_room = NULL;
ch->next_in_room = NULL;
ch->on = NULL; /* sanity check! */
return;
}
void add_scent (CHAR_DATA * ch, ROOM_INDEX_DATA * pRoomIndex)
{
SCENT_DATA *sc;
if (IS_SET (ch->act, ACT_NO_SCENT) || ch->level >= LEVEL_IMMORTAL)
return;
switch (pRoomIndex->sector_type)
{
case SECT_UNDERWATER:
case SECT_WATER_SWIM:
case SECT_WATER_NOSWIM:
case SECT_WATER_OCEAN:
return;
}
for (sc = pRoomIndex->scents; sc; sc = sc->next_in_room)
{
if (sc->player == ch)
{
switch (pRoomIndex->sector_type)
{
default:
sc->scent_level = SCENT_STRONG;
break;
case SECT_SWAMP:
case SECT_HILLS:
case SECT_MOUNTAIN:
case SECT_SHORE:
sc->scent_level = SCENT_NOTICEABLE;
break;
}
return;
}
}
sc = new_scent ();
switch (pRoomIndex->sector_type)
{
default:
sc->scent_level = SCENT_STRONG;
break;
case SECT_SWAMP:
case SECT_HILLS:
case SECT_MOUNTAIN:
case SECT_SHORE:
sc->scent_level = SCENT_NOTICEABLE;
break;
}
sc->in_room = pRoomIndex;
sc->player = ch;
sc->next_in_room = pRoomIndex->scents;
pRoomIndex->scents = sc;
sc->next = scents;
scents = sc;
if (get_skill (ch, gsn_conceal) > 0)
do_conceal (ch, NULL);
}
bool is_hunting (CHAR_DATA * hunter, CHAR_DATA * hunted)
{
MEMORY_DATA *hunts;
if (get_position(hunter) <= POS_SLEEPING)
return (FALSE);
for (hunts = hunter->hunt_memory; hunts; hunts = hunts->next_memory)
if (hunts->player == hunted)
return (TRUE);
return (FALSE);
}
/*
* Move a char into a room.
*/
void char_to_room (CHAR_DATA * ch, ROOM_INDEX_DATA * pRoomIndex)
{
OBJ_DATA *obj;
CHAR_DATA *fch, *fch_next;
bool stop_follow = FALSE;
long bigasscounter=0;
char buf[MAX_STRING_LENGTH];
if (pRoomIndex == NULL)
{
ROOM_INDEX_DATA *room;
bug ("Char_to_room: NULL.", 0);
if ((room = get_room_index (ROOM_VNUM_ALTAR)) != NULL)
char_to_room (ch, room);
return;
}
ch->in_room = pRoomIndex;
ch->next_in_room = pRoomIndex->people;
pRoomIndex->people = ch;
add_scent (ch, pRoomIndex);
// Adeon 6/30/03
if (IS_SET (pRoomIndex->room_flags2, ROOM_SINKING))
if (!IS_SET (ch->act2, ACT_NOSINK))
ch->sink_timer = pRoomIndex->sink_timer;
else
ch->sink_timer = -1;
else
ch->sink_timer = -1;
if ((ch->in_room->sector_type == SECT_UNDERWATER
|| ch->in_room->sector_type == SECT_WATER_SWIM
|| ch->in_room->sector_type == SECT_WATER_OCEAN
|| ch->in_room->sector_type == SECT_SWAMP
|| ch->in_room->sector_type == SECT_WATER_NOSWIM
|| (IS_OUTSIDE(ch) && (weather_info.sky == SKY_RAINING || weather_info.sky == SKY_LIGHTNING)))
&& ch->race == PC_RACE_LITAN)
{
if (!IS_NPC(ch) && ch->pcdata->flaming)
{
ch->pcdata->flaming = 0;
if (!((obj = get_eq_char (ch, WEAR_LIGHT)) != NULL
&& obj->item_type == ITEM_LIGHT
&& obj->value[2] != 0 && ch->in_room != NULL))
ch->in_room->light--;
if (is_affected(ch,gsn_fireshield))
affect_strip(ch,gsn_fireshield);
send_to_char("The flame surrounding you is fizzles out by the water.\n\r",ch);
}
}
if ((ch->in_room->sector_type == SECT_UNDERWATER
|| ch->in_room->sector_type == SECT_WATER_SWIM
|| ch->in_room->sector_type == SECT_WATER_OCEAN)
&& is_affected (ch, gsn_fireshield))
{
send_to_char
("Your shield of fire quickly evaporates into a useless steam.\n\r",
ch);
act ("$n's shield of fire quickly evaporates into a useless steam.",
ch, NULL, NULL, TO_ROOM);
affect_strip (ch, gsn_fireshield);
}
if ((ch->in_room->sector_type != SECT_UNDERWATER
&& ch->in_room->sector_type != SECT_WATER_SWIM
&& ch->in_room->sector_type != SECT_WATER_NOSWIM
&& ch->in_room->sector_type != SECT_WATER_OCEAN)
|| IS_AFFECTED (ch, AFF_AQUA_BREATHE)
|| IS_SET(ch->imm_flags,IMM_DROWNING))
ch->drown_damage = 1;
if (pRoomIndex->tp_exp > 0 && ch->level <= pRoomIndex->tp_level
&& !IS_NPC (ch) && !IS_IMMORTAL (ch))
check_travel_point (ch);
bigasscounter = 0;
for (fch = pRoomIndex->people; fch != NULL; fch = fch_next)
{
TRIGGER_DATA *pTrig;
if (bigasscounter++ > 1000000)
{
sprintf(buf,"Bigasscounter in char_to_room person -> %s bug name -> %s bug room -> %d",ch->name, pRoomIndex->people->name,pRoomIndex->vnum);
bug(buf,0);
if (IS_NPC(ch))
{
bug("ITS AN NPC",0);
sprintf(buf,"Vnum = %d",ch->pIndexData->vnum);
bug(buf,0);
}
else
{
bug("ITS A PC",0);
exit(1);
}
return;
}
fch_next = fch->next_in_room;
if (ch == fch)
continue;
if (!can_see (fch, ch) || !IS_AWAKE (fch))
continue;
if (!IS_NPC (fch))
continue;
if (IS_AFFECTED (ch, AFF_SNEAK)
&& !IS_AFFECTED (fch, AFF_DETECT_HIDDEN))
continue;
if (ch->group != 0 && !stop_follow && ch->group == fch->group)
{
int numgr;
if (!is_same_group (ch, fch))
{
numgr = number_in_group (ch) - 1;
numgr = 100 - (numgr * 40);
if (numgr >= number_percent () && fch->master == NULL)
{
add_follower (fch, ch);
group_gr (ch, fch);
}
}
stop_follow = TRUE;
}
if (HAS_SCRIPT (fch))
for (pTrig = fch->triggers; pTrig != NULL; pTrig = pTrig->next)
if (pTrig->trigger_type ==
TRIG_ENTER && pTrig->current == NULL
&& !IS_SET (fch->act, ACT_HALT))
{
act_trigger (fch, pTrig->name, NULL, NAME (ch), NAME (fch));
pTrig->current = pTrig->script;
pTrig->bits = SCRIPT_ADVANCE;
}
}
/* if(IS_NPC(ch))
{
if(ch->riders != NULL)
{
if(ch->in_room != ch->riders->in_room)
{
ch->riders->mount = NULL;
ch->riders->position = POS_STANDING;
ch->riders = NULL;
}
}
} */
if (!IS_NPC (ch))
{
if (ch->mount != NULL)
{
if (ch->in_room != ch->mount->in_room)
{
ch->mount->riders = NULL;
ch->mount = NULL;
ch->position = POS_STANDING;
}
}
if (ch->in_room->area->empty)
{
ch->in_room->area->empty = FALSE;
ch->in_room->area->age = 0;
}
++ch->in_room->area->nplayer;
//do_echo(ch,"num_players++");
/*{
char buf[10];
sprintf(buf,"NPLAYER - %d\n\r",ch->in_room->area->nplayer);
send_to_char(buf,ch);
}*/
//Iblis 10/04/04 - SCAN TO SEE IF IMAGINARY FRIENDS SHOULD POOF
if (ch->in_room->area->nplayer > 1 && !IS_IMMORTAL(ch))
{
CHAR_DATA *mch;
for (mch = char_list;mch != NULL;mch = mch->next)
{
if (IS_NPC(mch))
continue;
if (!mch->in_room)
continue;
if (mch->class == PC_CLASS_CHAOS_JESTER && mch->in_room->area == ch->in_room->area
&& mch->pcdata->familiar)
{
act("$N vanishes into thin air.",mch,NULL,mch->pcdata->familiar,TO_ALL);
familiar_poof(mch);
}
}
}
}
if (((obj = get_eq_char (ch, WEAR_LIGHT)) != NULL
&& obj->item_type == ITEM_LIGHT && obj->value[2] != 0)
|| (!IS_NPC(ch) && ch->pcdata->flaming))
++ch->in_room->light;
if (IS_AFFECTED (ch, AFF_PLAGUE))
{
AFFECT_DATA *af, plague;
CHAR_DATA *vch;
for (af = ch->affected; af != NULL; af = af->next)
{
if (af->type == gsn_plague)
break;
}
if (af == NULL)
{
REMOVE_BIT (ch->affected_by, AFF_PLAGUE);
//Iblis 6/22/03 - Falcon skill
falcon_alert (ch);
return;
}
if (af->level == 1)
{
//Iblis 6/22/03 - Falcon skill
falcon_alert (ch);
return;
}
plague.where = TO_AFFECTS;
plague.type = gsn_plague;
plague.level = af->level - 1;
plague.duration = number_range (1, 2 * plague.level);
plague.location = APPLY_STR;
plague.modifier = -5;
plague.bitvector = AFF_PLAGUE;
plague.composition = FALSE;
plague.comp_name = str_dup ("");
for (vch = ch->in_room->people; vch != NULL; vch = vch->next_in_room)
{
if (!saves_spell (plague.level - 2, vch, DAM_DISEASE)
&& !IS_IMMORTAL (vch) && !IS_AFFECTED (vch, AFF_PLAGUE)
&& IS_NPC(vch)
&& number_bits (6) == 0)
{
send_to_char ("You feel hot and feverish.\n\r", vch);
act ("$n shivers and looks very ill.", vch, NULL, NULL,
TO_ROOM);
affect_join (vch, &plague);
}
}
}
//Iblis 6/22/03 - Falcon skill
falcon_alert (ch);
//Iblis 1/02/04 - Fixed enters room and char enters room
/* trip_triggers(ch, OBJ_TRIG_ENTER_ROOM, NULL, NULL, OT_SPEC_NONE);
sprintf(tcbuf,"%d",ch->in_room->vnum);
trip_triggers_arg(ch, OBJ_TRIG_CHAR_TO_ROOM, NULL, NULL, OT_SPEC_NONE,tcbuf);*/
return;
}
/*
* Give an obj to a char.
*/
void obj_to_char (OBJ_DATA * obj, CHAR_DATA * ch)
{
if (!IS_NPC (ch) && obj->item_type == ITEM_FOOD && obj->timer == 0 && obj->value[5] != -1)
obj->timer = obj->pIndexData->value[2];
obj->next_content = ch->carrying;
ch->carrying = obj;
obj->carried_by = ch;
obj->in_room = NULL;
obj->in_obj = NULL;
ch->carry_number += get_obj_number (obj);
ch->carry_weight += get_obj_weight (obj);
}
/*
* Take an obj from its character.
*/
void obj_from_char (OBJ_DATA * obj)
{
CHAR_DATA *ch;
if (!obj)
return;
if ((ch = obj->carried_by) == NULL)
{
bug ("Obj_from_char: null ch.", 0);
return;
}
if (obj->wear_loc != WEAR_NONE)
unequip_char (ch, obj);
if (ch->carrying == obj)
{
ch->carrying = obj->next_content;
}
else
{
OBJ_DATA *prev;
for (prev = ch->carrying; prev != NULL; prev = prev->next_content)
{
if (prev->next_content == obj)
{
prev->next_content = obj->next_content;
break;
}
}
if (prev == NULL)
bug ("Obj_from_char: obj not in list.", 0);
}
obj->carried_by = NULL;
obj->next_content = NULL;
ch->carry_number -= get_obj_number (obj);
ch->carry_weight -= get_obj_weight (obj);
return;
}
/*
* Find the ac value of an obj, including position effect.
*/
int apply_ac_new (OBJ_DATA * obj, int type)
{
if (obj->item_type != ITEM_ARMOR)
return 0;
if (IS_SET(obj->wear_flags,ITEM_WEAR_BODY))
return 3 * obj->value[type];
if (IS_SET(obj->wear_flags,ITEM_WEAR_ABOUT) || IS_SET(obj->wear_flags,ITEM_WEAR_HEAD)
|| IS_SET(obj->wear_flags,ITEM_WEAR_LEGS))
return 2 * obj->value[type];
if (IS_SET(obj->wear_flags,ITEM_WEAR_FEET) || IS_SET(obj->wear_flags,ITEM_WEAR_HANDS)
|| IS_SET(obj->wear_flags,ITEM_WEAR_ARMS) || IS_SET(obj->wear_flags,ITEM_WEAR_SHIELD)
|| IS_SET(obj->wear_flags,ITEM_WEAR_NECK) || IS_SET(obj->wear_flags,ITEM_WEAR_ANOTHER_NECK)
|| IS_SET(obj->wear_flags,ITEM_WEAR_WRIST) || IS_SET(obj->wear_flags,ITEM_WEAR_ANOTHER_WRIST)
|| IS_SET(obj->wear_flags,ITEM_WEAR_WAIST) || IS_SET(obj->wear_flags,ITEM_HOLD)
|| IS_SET(obj->wear_flags,ITEM_WEAR_FACE))
return obj->value[type];
return 0;
}
/*
* Find the ac value of an obj, including position effect.
*/
int apply_ac (OBJ_DATA * obj, int iWear, int type)
{
if (obj->item_type != ITEM_ARMOR)
return 0;
switch (iWear)
{
case WEAR_BODY:
return 3 * obj->value[type];
case WEAR_HEAD:
return 2 * obj->value[type];
case WEAR_LEGS:
return 2 * obj->value[type];
case WEAR_FEET:
return obj->value[type];
case WEAR_HANDS:
return obj->value[type];
case WEAR_ARMS:
return obj->value[type];
case WEAR_SHIELD:
return obj->value[type];
case WEAR_FINGER_L:
return 0;
case WEAR_FINGER_R:
return 0;
case WEAR_NECK_1:
return obj->value[type];
case WEAR_NECK_2:
return obj->value[type];
case WEAR_ABOUT:
return 2 * obj->value[type];
case WEAR_WAIST:
return obj->value[type];
case WEAR_WRIST_L:
return obj->value[type];
case WEAR_WRIST_R:
return obj->value[type];
case WEAR_HOLD:
return obj->value[type];
}
return 0;
}
/*
* Find a piece of eq on a character.
*/
OBJ_DATA *get_eq_char_new (CHAR_DATA * ch, long iWear)
{
OBJ_DATA *obj;
long bugcounter = 0;
if (ch == NULL)
return NULL;
for (obj = ch->carrying; obj != NULL; obj = obj->next_content)
{
if (bugcounter++ > 9999999)
{
bug ("ERROR ERROR in get_eq_char for CHARNAME then OBJNAME", 0);
bug (ch->name, 0);
bug (obj->short_descr, 0);
bug (obj->name, 0);
return NULL;
}
if (obj->wear_loc == -1)
continue;
if (IS_SET(obj->wear_loc,iWear))
return obj;
}
return NULL;
}
/*
* Find a piece of eq on a character.
*/
OBJ_DATA *get_eq_char (CHAR_DATA * ch, int iWear)
{
OBJ_DATA *obj;
int i=0;
long bugcounter = 0, wear_flag=-1;
if (ch == NULL)
return NULL;
for (i=0; wear_conversion_table[i].wear_loc != -2; ++i)
{
if (wear_conversion_table[i].wear_loc == iWear)
{
wear_flag = wear_conversion_table[i].wear_flag;
break;
}
}
if (wear_flag == -1)
return NULL;
for (obj = ch->carrying; obj != NULL; obj = obj->next_content)
{
if (bugcounter++ > 9999999)
{
bug ("ERROR ERROR in get_eq_char for CHARNAME then OBJNAME", 0);
bug (ch->name, 0);
bug (obj->short_descr, 0);
bug (obj->name, 0);
return NULL;
}
if (obj->wear_loc == -1)
continue;
if (IS_SET(obj->wear_loc,wear_flag))
return obj;
}
return NULL;
}
// Iblis 1/04/04 - Gets an object from the room with a specific vnum
// Created for use in necromancer's draw skill
OBJ_DATA *get_obj_vnum_room(ROOM_INDEX_DATA* rid, int vnum)
{
OBJ_DATA* obj;
for (obj = rid->contents;obj != NULL;obj = obj->next_content)
{
if (obj->pIndexData->vnum == vnum)
return obj;
}
return NULL;
}
// Iblis 1/04/04 - Gets an object from a char with a specific vnum
// Created for use in necromancer's draw skill
OBJ_DATA *get_obj_vnum_char(CHAR_DATA* ch, int vnum)
{
OBJ_DATA* obj;
for (obj = ch->carrying;obj != NULL;obj = obj->next_content)
{
if (obj->pIndexData->vnum == vnum)
return obj;
}
return NULL;
}
// Iblis 1/07/04 - Gets an object from the room with a specific vnum
// Created for use in necromancer's bone craft skill
OBJ_DATA *get_obj_vnum_container(OBJ_DATA* rid, int vnum)
{
OBJ_DATA* obj;
for (obj = rid->contains;obj != NULL;obj = obj->next_content)
{
if (obj->pIndexData->vnum == vnum)
return obj;
}
return NULL;
}
//
// Akamai 4/30/99 -- Support race and class specific objects
// Checks to see if a character can actually hold/wear the piece of
// equipment. If the char can not hold it, then it is forcibly dropped
//
int char_can_wear (CHAR_DATA * ch, OBJ_DATA * obj)
{
long fval = 0;
if (!obj)
return FALSE;
// Immortals can wear anything
if (IS_IMMORTAL (ch))
return (TRUE);
// NPCs can wear anything too - they're special
if (IS_NPC (ch))
return (TRUE);
// Validate good/neutral/evil
if ((IS_OBJ_STAT (obj, ITEM_ANTI_EVIL) && IS_EVIL (ch)) ||
(IS_OBJ_STAT (obj, ITEM_ANTI_GOOD) && IS_GOOD (ch)) ||
(IS_OBJ_STAT (obj, ITEM_ANTI_NEUTRAL) && IS_NEUTRAL (ch)))
{
return (FALSE);
}
// Iblis - (11/09/03)Validate Clan
if (!IS_SET(obj->clan_flags,flag_value(clan_flags, capitalize(get_clan_name_ch (ch)))))
{
if (obj->clan_flags != 0)
return (FALSE);
}
if (flag_value(clan_flags, capitalize(get_clan_name_ch (ch))) == -99 && ch->pcdata->loner == FALSE
&& !IS_SET(obj->clan_flags,CLAN_NONE))
{
if (obj->clan_flags != 0)
return (FALSE);
}
if (flag_value(clan_flags, capitalize(get_clan_name_ch (ch))) == -99 && ch->pcdata->loner == TRUE
&& !IS_SET(obj->clan_flags,CLAN_LONER))
{
if (obj->clan_flags != 0)
return (FALSE);
}
// Validate race
// if no flags are set then it is valid for all races
if (obj->race_flags != 0)
{
switch (ch->race)
{
case PC_RACE_HUMAN:
if (!IS_SET (obj->race_flags, RACE_HUMAN))
return (FALSE);
break;
case PC_RACE_ELF:
if (!IS_SET (obj->race_flags, RACE_ELF))
return (FALSE);
break;
case PC_RACE_DWARF:
if (!IS_SET (obj->race_flags, RACE_DWARF))
return (FALSE);
break;
case PC_RACE_CANTHI:
if (!IS_SET (obj->race_flags, RACE_CANTHI))
return (FALSE);
break;
case PC_RACE_VROATH:
if (!IS_SET (obj->race_flags, RACE_VROATH))
return (FALSE);
break;
case PC_RACE_SYVIN:
if (!IS_SET (obj->race_flags, RACE_SYVIN))
return (FALSE);
break;
case PC_RACE_SIDHE:
if (!IS_SET (obj->race_flags, RACE_SIDHE))
return (FALSE);
break;
case PC_RACE_LITAN:
if (!IS_SET (obj->race_flags, RACE_LITAN))
return (FALSE);
break;
case PC_RACE_KALIAN:
return (TRUE);
break;
case PC_RACE_LICH:
if (!IS_SET (obj->race_flags, RACE_LICH))
return (FALSE);
break;
case PC_RACE_NERIX:
if (!IS_SET (obj->race_flags, RACE_NERIX))
return (FALSE);
case PC_RACE_SWARM:
if (!IS_SET (obj->race_flags, RACE_SWARM))
return (FALSE);
default:
bug ("char_can_wear() - unrecognized PC race %d", ch->race);
return (FALSE);
break;
}
}
// Validate class
// if no flags are set then it is valid for all classes
if (obj->class_flags != 0)
{
// Hero status is a variation of the class flags
if (IS_SET (obj->class_flags, CLASS_HERO) && !(ch->pcdata->hero))
{
return (FALSE);
}
// get the flag value from the class_flags table for this class
fval = flag_value (class_flags, class_table[ch->class].name);
if (fval < 0)
{
bug ("char_can_wear() - unrecognized class/class flag", 0);
return (FALSE);
}
else
{
if (!class_flagged_obj (obj, ch))
return (FALSE);
}
}
return (TRUE);
}
bool char_can_remove_to_wear(CHAR_DATA *ch, OBJ_DATA *obj_to_wear, bool show_messages)
{
return char_can_remove_to_wear_hand(ch,obj_to_wear,show_messages,0);
}
//Iblis - new function to deal with multislot eq
bool char_can_remove_to_wear_hand(CHAR_DATA *ch, OBJ_DATA *obj_to_wear, bool show_messages, int hand)
{
long i, hands_needed=0;
OBJ_DATA *obj=NULL;
for (i = 2; i <= MAX_WEAR_FLAG;i = i<<1)
{
if (!IS_SET(obj_to_wear->wear_flags,i) && !(obj_to_wear->item_type == ITEM_LIGHT && i == ITEM_WEAR_LIGHT))
continue;
if (i == ITEM_NO_SAC || i == ITEM_TWO_HANDS || i == ITEM_TAKE)
continue;
if ((i == ITEM_WEAR_BODY || i == ITEM_WEAR_LEGS) && is_affected(ch,skill_lookup("swell")))
{
if (show_messages)
send_to_char("You're too swollen to wear that.\n\r",ch);
return FALSE;
}
if ((obj = get_eq_char_new (ch, i)) == NULL)
continue;
if (i == ITEM_WIELD)
{
if (get_skill(ch,gsn_dual_wield) == 0 && hand != HAND_AMBIDEXTROUS)
{
if (hand != HAND_LEFT)
obj = get_eq_char_new (ch,ITEM_WIELD);
else obj = get_eq_char_new (ch,ITEM_TWO_HANDS);
if (obj == NULL)
continue;
//handle the noremove with the code below
}
else
{
if (hand != HAND_LEFT)
{
obj = get_eq_char_new (ch,ITEM_WIELD);
if (IS_SET (obj->extra_flags[0], ITEM_NOREMOVE) && !IS_IMMORTAL (ch))
{
if (show_messages && get_eq_char_new (ch,ITEM_TWO_HANDS) != NULL)
act ("You can't remove $p.", ch, obj, NULL, TO_CHAR);
obj = get_eq_char_new(ch,ITEM_TWO_HANDS);
}
}
else
{
obj = get_eq_char_new (ch,ITEM_TWO_HANDS);
if (obj == NULL)
continue;
if (IS_SET (obj->extra_flags[0], ITEM_NOREMOVE) && !IS_IMMORTAL (ch))
{
if (show_messages && get_eq_char_new (ch,ITEM_WIELD) != NULL)
act ("You can't remove $p.", ch, obj, NULL, TO_CHAR);
obj = get_eq_char_new(ch,ITEM_WIELD);
}
}
if (obj == NULL)
continue;
}
}
if (IS_SET (obj->extra_flags[0], ITEM_NOREMOVE) && !IS_IMMORTAL (ch))
{
//The following three checks deal with objects that could be in two locations, that do not
//take up both of those locations.
if (i == ITEM_WEAR_NECK && !IS_SET(obj->wear_flags,ITEM_WEAR_ANOTHER_NECK))
{
if (show_messages && get_eq_char_new (ch,ITEM_WEAR_ANOTHER_NECK) != NULL)
act ("You can't remove $p.", ch, obj, NULL, TO_CHAR);
obj = get_eq_char_new (ch,ITEM_WEAR_ANOTHER_NECK);
}
else if (i == ITEM_WEAR_FINGER && !IS_SET(obj->wear_flags,ITEM_WEAR_ANOTHER_FINGER))
{
if (show_messages && get_eq_char_new (ch,ITEM_WEAR_ANOTHER_FINGER) != NULL)
act ("You can't remove $p.", ch, obj, NULL, TO_CHAR);
obj = get_eq_char_new (ch,ITEM_WEAR_ANOTHER_FINGER);
}
else if (i == ITEM_WEAR_WRIST && !IS_SET(obj->wear_flags, ITEM_WEAR_ANOTHER_WRIST))
{
if (show_messages && get_eq_char_new (ch,ITEM_WEAR_ANOTHER_WRIST) != NULL)
act ("You can't remove $p.", ch, obj, NULL, TO_CHAR);
obj = get_eq_char_new (ch, ITEM_WEAR_ANOTHER_WRIST);
}
if (obj == NULL)
continue;
if (IS_SET (obj->extra_flags[0], ITEM_NOREMOVE) && !IS_IMMORTAL (ch))
{
if (show_messages)
act ("You can't remove $p.", ch, obj, NULL, TO_CHAR);
return FALSE;
}
}
}
//Perform the hands check crap
if ((hands_needed = hands_required(ch,obj_to_wear)) + hands_used(ch) <= 2
|| (!IS_SET(obj_to_wear->wear_flags,ITEM_WIELD) && hands_needed < 2))
return TRUE;
hands_needed = hands_required(ch,obj_to_wear) - (2-hands_used(ch));
if (hands_needed > 2)
return FALSE;
//If this is not a weapon, hands_needed =2 ,and we already know we can remove the slot the item
// goes in, so we need to be able to clear one more hand
//If this is a weapon, they have a weapon slot free they can legally wear it
if (hands_needed && (obj = get_eq_char_new(ch,ITEM_WEAR_SHIELD)))
{
if (IS_SET (obj->extra_flags[0], ITEM_NOREMOVE) && !IS_IMMORTAL (ch))
{
if (show_messages)
act ("You can't remove $p.", ch, obj, NULL, TO_CHAR);
return FALSE;
}
--hands_needed;
}
if (hands_needed && (obj = get_eq_char_new(ch,ITEM_HOLD)))
{
if (IS_SET (obj->extra_flags[0], ITEM_NOREMOVE) && !IS_IMMORTAL (ch))
{
if (show_messages)
act ("You can't remove $p.", ch, obj, NULL, TO_CHAR);
return FALSE;
}
--hands_needed;
if (obj->item_type == ITEM_INSTRUMENT && IS_SET (obj->value[0], A) && ch->size < SIZE_LARGE)
--hands_needed;
}
if (hands_needed && (obj = get_eq_char_new(ch,ITEM_WIELD)))
{
if (IS_SET (obj->extra_flags[0], ITEM_NOREMOVE) && !IS_IMMORTAL (ch))
{
if (show_messages)
act ("You can't remove $p.", ch, obj, NULL, TO_CHAR);
return FALSE;
}
--hands_needed;
if (!IS_NPC (ch) && ch->size < SIZE_LARGE && IS_WEAPON_STAT (obj, WEAPON_TWO_HANDS))
--hands_needed;
}
if (hands_needed && (obj = get_eq_char_new(ch,ITEM_WIELD)))
{
if (IS_SET (obj->extra_flags[0], ITEM_NOREMOVE) && !IS_IMMORTAL (ch))
{
if (show_messages)
act ("You can't remove $p.", ch, obj, NULL, TO_CHAR);
return FALSE;
}
--hands_needed;
if (!IS_NPC (ch) && ch->size < SIZE_LARGE && IS_WEAPON_STAT (obj, WEAPON_TWO_HANDS))
--hands_needed;
}
//if somehow, beyond my understanding, hands_needed != 0, you can't wear it so return false here
if (hands_needed > 0)
return FALSE;
return TRUE;
}
//Iblis - new function to deal with multislot eq
bool all_slots_free(CHAR_DATA *ch, OBJ_DATA *obj_to_wear,int hand)
{
long i;
OBJ_DATA *obj;
for (i = 2; i <= MAX_WEAR_FLAG;i = i<<1)
{
if (!(obj_to_wear->item_type == ITEM_LIGHT && i == ITEM_WEAR_LIGHT))
{
if (!IS_SET(obj_to_wear->wear_flags,i))
continue;
}
if (i == ITEM_NO_SAC || i == ITEM_TWO_HANDS || i == ITEM_TAKE)
continue;
if ((i == ITEM_WEAR_BODY || i == ITEM_WEAR_LEGS) && is_affected(ch,skill_lookup("swell")))
{
return FALSE;
}
if (i == ITEM_WIELD && get_skill(ch,gsn_dual_wield) > 0)
{
if (!get_eq_char_new(ch,ITEM_WIELD) || !get_eq_char_new(ch,ITEM_TWO_HANDS))
continue;
}
if (i == ITEM_WIELD && hand == HAND_LEFT)
i = ITEM_TWO_HANDS;
if ((obj = get_eq_char_new (ch, i)) != NULL)
{
if (i == ITEM_WEAR_NECK && !IS_SET(obj->wear_flags,ITEM_WEAR_ANOTHER_NECK))
obj = get_eq_char_new (ch,ITEM_WEAR_ANOTHER_NECK);
else if (i == ITEM_WEAR_FINGER && !IS_SET(obj->wear_flags,ITEM_WEAR_ANOTHER_FINGER))
obj = get_eq_char_new (ch,ITEM_WEAR_ANOTHER_FINGER);
else if (i == ITEM_WEAR_WRIST && !IS_SET(obj->wear_flags, ITEM_WEAR_ANOTHER_WRIST))
obj = get_eq_char_new (ch, ITEM_WEAR_ANOTHER_WRIST);
else if (i == ITEM_WIELD && !IS_NPC(ch) && obj_to_wear->item_type == ITEM_WEAPON && ch->size < SIZE_LARGE && IS_WEAPON_STAT (obj_to_wear, WEAPON_TWO_HANDS))
obj = get_eq_char_new (ch, ITEM_TWO_HANDS);
if (obj != NULL)
return FALSE;
}
/* if (IS_SET (obj->extra_flags[0], ITEM_NOREMOVE) && !IS_IMMORTAL (ch))
{
//The following three checks deal with objects that could be in two locations, that do not
//take up both of those locations.
if (i == ITEM_WEAR_NECK && !IS_SET(obj->wear_flags,ITEM_WEAR_ANOTHER_NECK))
obj = get_eq_char_new (ch,ITEM_WEAR_ANOTHER_NECK);
else if (i == ITEM_WEAR_FINGER && !IS_SET(obj->wear_flags,ITEM_WEAR_ANOTHER_FINGER))
obj = get_eq_char_new (ch,ITEM_WEAR_ANOTHER_FINGER);
else if (i == ITEM_WEAR_WRIST && !IS_SET(obj->wear_flags, ITEM_WEAR_ANOTHER_WRIST))
obj = get_eq_char_new (ch, ITEM_WEAR_ANOTHER_WRIST);
if (IS_SET (obj->extra_flags[0], ITEM_NOREMOVE) && !IS_IMMORTAL (ch))
{
if (show_messages)
act ("You can't remove $p.", ch, obj, NULL, TO_CHAR);
return FALSE;
}
}*/
}
return TRUE;
}
/*bool remove_and_equip_char(CHAR_DATA *ch, OBJ_DATA *obj_to_wear, bool show_messages)
{
remove_and_equip_char_hand(ch,obj_to_wear,show_messages,0);
}*/
bool remove_and_equip_char_hand(CHAR_DATA *ch, OBJ_DATA *obj_to_wear, bool show_messages, int hand)
{
long i=0,newslot=0;
OBJ_DATA *obj = NULL;
int hands_needed=0;
obj_to_wear->wear_loc = 0;
for (i = 2; i <= MAX_WEAR_FLAG;i = i<<1)
{
if ((i == ITEM_WEAR_BODY || i == ITEM_WEAR_LEGS) && is_affected(ch,skill_lookup("swell")))
{
if (show_messages)
send_to_char("You're too swollen to wear that.\n\r",ch);
return FALSE;
}
if (!IS_SET(obj_to_wear->wear_flags,i) && !(obj_to_wear->item_type == ITEM_LIGHT && i == ITEM_WEAR_LIGHT))
continue;
if (i == ITEM_NO_SAC || i == ITEM_TWO_HANDS || i == ITEM_TAKE)
continue;
if (i == ITEM_WIELD && hand == HAND_LEFT)
i = ITEM_TWO_HANDS;
if ((obj = get_eq_char_new (ch, i)) == NULL)
{
obj_to_wear->wear_loc |= i;
if (i == ITEM_WIELD && !IS_NPC(ch) && obj_to_wear->item_type == ITEM_WEAPON && ch->size < SIZE_LARGE && IS_WEAPON_STAT (obj_to_wear, WEAPON_TWO_HANDS))
obj_to_wear->wear_loc |= ITEM_TWO_HANDS;
if (i == ITEM_TWO_HANDS && !IS_NPC(ch) && obj_to_wear->item_type == ITEM_WEAPON && ch->size < SIZE_LARGE && IS_WEAPON_STAT (obj_to_wear, WEAPON_TWO_HANDS))
obj_to_wear->wear_loc |= ITEM_WIELD;
continue;
}
newslot = -1;
if (i == ITEM_WEAR_NECK && (get_eq_char_new (ch,ITEM_WEAR_ANOTHER_NECK) == NULL))
{
obj_to_wear->wear_loc |= ITEM_WEAR_ANOTHER_NECK;
continue;
}
if (i == ITEM_WEAR_FINGER && (get_eq_char_new (ch,ITEM_WEAR_ANOTHER_FINGER) == NULL))
{
obj_to_wear->wear_loc |= ITEM_WEAR_ANOTHER_FINGER;
continue;
}
if (i == ITEM_WEAR_WRIST && (get_eq_char_new (ch,ITEM_WEAR_ANOTHER_WRIST) == NULL))
{
obj_to_wear->wear_loc |= ITEM_WEAR_ANOTHER_WRIST;
continue;
}
if ((i == ITEM_WIELD || i == ITEM_TWO_HANDS) && !(!IS_NPC(ch) && obj_to_wear->item_type == ITEM_WEAPON && ch->size < SIZE_LARGE && IS_WEAPON_STAT (obj_to_wear, WEAPON_TWO_HANDS)))
{
if (get_skill(ch,gsn_dual_wield) == 0 && hand != HAND_AMBIDEXTROUS)
{
// if (hand == HAND_LEFT)
// obj = get_eq_char_new (ch,ITEM_WIELD);
// else obj = get_eq_char_new (ch,ITEM_TWO_HANDS);
//handle the noremove with the code below
}
else
{
if (hand != HAND_LEFT)
{
//The if below deals with putting it in the other hand if this one is full
if (get_eq_char_new(ch,ITEM_TWO_HANDS) == NULL && hands_used(ch) <= 1)
{
obj_to_wear->wear_loc |= ITEM_TWO_HANDS;
continue;
}
/*obj = get_eq_char_new (ch,ITEM_WIELD);
if (IS_SET (obj->extra_flags[0], ITEM_NOREMOVE) && !IS_IMMORTAL (ch))
{
if (show_messages && get_eq_char_new (ch,ITEM_TWO_HANDS) != NULL)
act ("You can't remove $p.", ch, obj, NULL, TO_CHAR);
obj = get_eq_char_new(ch,ITEM_TWO_HANDS);
}*/
}
else
{
//The if below deals with putting it in the other hand if this one is full
if (get_eq_char_new(ch,ITEM_WIELD) == NULL && hands_used(ch) <= 1)
{
obj_to_wear->wear_loc |= ITEM_WIELD;
continue;
}
/* obj = get_eq_char_new (ch,ITEM_TWO_HANDS);
if (IS_SET (obj->extra_flags[0], ITEM_NOREMOVE) && !IS_IMMORTAL (ch))
{
if (show_messages && get_eq_char_new (ch,ITEM_WIELD) != NULL)
act ("You can't remove $p.", ch, obj, NULL, TO_CHAR);
obj = get_eq_char_new(ch,ITEM_WIELD);
}*/
}
}
}
if (IS_SET (obj->extra_flags[0], ITEM_NOREMOVE) && !IS_IMMORTAL (ch))
{
//The following three checks deal with objects that could be in two locations, that do not
//take up both of those locations.
// if (show_messages)
// act ("You can't remove $p.", ch, obj, NULL, TO_CHAR);
if (i == ITEM_WEAR_NECK && !IS_SET(obj->wear_flags,ITEM_WEAR_ANOTHER_NECK))
newslot = ITEM_WEAR_ANOTHER_NECK;
else if (i == ITEM_WEAR_FINGER && !IS_SET(obj->wear_flags,ITEM_WEAR_ANOTHER_FINGER))
newslot = ITEM_WEAR_ANOTHER_FINGER;
else if (i == ITEM_WEAR_WRIST && !IS_SET(obj->wear_flags, ITEM_WEAR_ANOTHER_WRIST))
newslot = ITEM_WEAR_ANOTHER_WRIST;
//else newslot = -1;
if (newslot != -1)
obj = get_eq_char_new(ch,newslot);
else
{
if (show_messages)
act ("You can't remove $p.", ch, obj, NULL, TO_CHAR);
return FALSE;
}
if (IS_SET (obj->extra_flags[0], ITEM_NOREMOVE) && !IS_IMMORTAL (ch))
{
if (show_messages)
act ("You can't remove $p.", ch, obj, NULL, TO_CHAR);
return FALSE;
}
}
unequip_char(ch,obj);
if (obj->item_type == ITEM_WEAPON && IS_WEAPON_STAT(obj,WEAPON_HOLY_ACTIVATED))
REMOVE_BIT(obj->value[4],WEAPON_HOLY_ACTIVATED);
if (obj->item_type == ITEM_POLE)
obj->value[1] = 0;
act ("$n stops using $p.", ch, obj, NULL, TO_ROOM);
act ("You stop using $p.", ch, obj, NULL, TO_CHAR);
if (i == ITEM_WIELD &&!IS_NPC(ch) && obj->item_type == ITEM_WEAPON && ch->size < SIZE_LARGE
&& IS_WEAPON_STAT (obj,WEAPON_TWO_HANDS))
obj_to_wear->wear_loc |= ITEM_TWO_HANDS;
if (i == ITEM_TWO_HANDS && !IS_NPC(ch) && obj->item_type == ITEM_WEAPON && ch->size < SIZE_LARGE
&& IS_WEAPON_STAT (obj, WEAPON_TWO_HANDS))
obj_to_wear->wear_loc |= ITEM_WIELD;
if (newslot == -1)
obj_to_wear->wear_loc |= i;
else obj_to_wear->wear_loc |= newslot;
}
if (hands_used(ch) <= 2)
return TRUE;
hands_needed = hands_used(ch)-2;
if (hands_needed && (obj = get_eq_char_new(ch,ITEM_WEAR_SHIELD)) && obj != obj_to_wear)
{
if (IS_SET (obj->extra_flags[0], ITEM_NOREMOVE) && !IS_IMMORTAL (ch))
{
if (show_messages)
act ("You can't remove $p.", ch, obj, NULL, TO_CHAR);
return FALSE;
}
--hands_needed;
}
if (hands_needed && (obj = get_eq_char_new(ch,ITEM_HOLD)) && obj != obj_to_wear)
{
if (IS_SET (obj->extra_flags[0], ITEM_NOREMOVE) && !IS_IMMORTAL (ch))
{
if (show_messages)
act ("You can't remove $p.", ch, obj, NULL, TO_CHAR);
return FALSE;
}
--hands_needed;
if (obj->item_type == ITEM_INSTRUMENT && IS_SET (obj->value[0], A) && ch->size < SIZE_LARGE)
--hands_needed;
}
if (hands_needed && (obj = get_eq_char_new(ch,ITEM_WIELD)) && obj != obj_to_wear)
{
if (IS_SET (obj->extra_flags[0], ITEM_NOREMOVE) && !IS_IMMORTAL (ch))
{
if (show_messages)
act ("You can't remove $p.", ch, obj, NULL, TO_CHAR);
return FALSE;
}
--hands_needed;
if (!IS_NPC (ch) && ch->size < SIZE_LARGE && IS_WEAPON_STAT (obj, WEAPON_TWO_HANDS))
--hands_needed;
}
if (hands_needed && (obj = get_eq_char_new(ch,ITEM_WIELD)) && obj != obj_to_wear)
{
if (IS_SET (obj->extra_flags[0], ITEM_NOREMOVE) && !IS_IMMORTAL (ch))
{
if (show_messages)
act ("You can't remove $p.", ch, obj, NULL, TO_CHAR);
return FALSE;
}
--hands_needed;
if (!IS_NPC (ch) && ch->size < SIZE_LARGE && IS_WEAPON_STAT (obj, WEAPON_TWO_HANDS))
--hands_needed;
}
//if somehow, beyond my understanding, hands_needed != 0, you can't wear it so return false here
if (hands_needed > 0)
return FALSE;
return TRUE;
}
//
// Equip a char with an obj.
//
void equip_char (CHAR_DATA * ch, OBJ_DATA * obj, long iWear)
{
AFFECT_DATA *paf;
int i;
if (get_eq_char (ch, iWear) != NULL)
return;
// support alignment/class/race specific equipment
if ((!char_can_wear (ch, obj) && (ch->race != PC_RACE_AVATAR))
|| ((IS_SET(obj->extra_flags[1],ITEM_NOAVATAR)) && ch->race == PC_RACE_AVATAR)
|| ((IS_SET(obj->extra_flags[1],ITEM_NOKALIAN)) && ch->race == PC_RACE_KALIAN))
{
act ("You are zapped by $p and drop it.", ch, obj, NULL, TO_CHAR);
act ("$n is zapped by $p and drops it.", ch, obj, NULL, TO_ROOM);
obj_from_char (obj);
obj_to_room (obj, ch->in_room);
obj->wear_loc = -1;
//Iblis - 3/11/04 - Antiduping Code
if (ch && !IS_NPC(ch))
save_char_obj (ch);
return;
}
//DEAL WITH AC PROPERLY!! PICK THE
for (i = 0; i < 4; i++)
ch->armor[i] -= apply_ac (obj, iWear, i);
for (i = 0; wear_conversion_table[i].wear_loc != -2; ++i)
{
if (wear_conversion_table[i].wear_loc == iWear)
{
obj->wear_loc = wear_conversion_table[i].wear_flag;
break;
}
}
// obj->wear_loc = iWear;
if (!obj->enchanted)
for (paf = obj->pIndexData->affected; paf != NULL; paf = paf->next)
if (paf->location != APPLY_SPELL_AFFECT)
{
affect_modify (ch, paf, TRUE);
}
for (paf = obj->affected; paf != NULL; paf = paf->next)
if (paf->location == APPLY_SPELL_AFFECT)
{
paf->permaff = TRUE;
switch (paf->bitvector)
{
case A:
send_to_char ("You are blinded!\n\r", ch);
act ("$n appears to be blinded.", ch, NULL, NULL, TO_ROOM);
break;
case B:
send_to_char ("You fade out of existence.\n\r", ch);
act ("$n fades out of existence.", ch, NULL, NULL, TO_ROOM);
break;
case C:
case D:
case E:
case G:
send_to_char ("Your eyes tingle.\n\r", ch);
break;
case F:
send_to_char ("Your awareness improves.\n\r", ch);
break;
case H:
act ("$n is surrounded by a white aura.", ch, NULL, NULL,
TO_ROOM);
send_to_char ("You are surrounded by a white aura.\n\r", ch);
break;
case I:
send_to_char ("You are surrounded by a pink outline.\n\r", ch);
act ("$n is surrounded by a pink outline.", ch, NULL,
NULL, TO_ROOM);
break;
case J:
send_to_char ("Your eyes glow red.\n\r", ch);
act ("$n's eyes glow red.\n\r", ch, NULL, NULL, TO_ROOM);
break;
case K:
send_to_char ("You feel unclean.\n\r", ch);
break;
case M:
send_to_char ("You feel very sick.\n\r", ch);
act ("$n looks very ill.", ch, NULL, NULL, TO_ROOM);
break;
case N:
send_to_char ("You feel holy and pure.\n\r", ch);
break;
case O:
send_to_char ("You feel aligned with darkness.\n\r", ch);
break;
case P:
send_to_char ("You begin to move silently.\n\r", ch);
break;
case Q:
send_to_char ("You hide in the shadows.\n\r", ch);
break;
case R:
send_to_char ("You feel very sleepy ..... zzzzzz.\n\r", ch);
act ("$n goes to sleep.", ch, NULL, NULL, TO_ROOM);
ch->position = POS_SLEEPING;
break;
case T:
send_to_char ("Your feet rise off the ground.\n\r", ch);
act ("$n's feet rise off the ground.", ch, NULL, NULL, TO_ROOM);
break;
case U:
act ("$n turns translucent.", ch, NULL, NULL, TO_ROOM);
send_to_char ("You turn translucent.\n\r", ch);
break;
case V:
send_to_char ("You feel yourself moving more quickly.\n\r", ch);
act ("$n is moving more quickly.", ch, NULL, NULL, TO_ROOM);
break;
case X:
send_to_char
("You scream in agony as plague sores erupt from your skin.\n\r",
ch);
act ("$n screams in agony as plague sores erupt from $s skin.",
ch, NULL, NULL, TO_ROOM);
break;
case Y:
send_to_char ("You feel your strength slip away.\n\r", ch);
act ("$n looks tired and weak.", ch, NULL, NULL, TO_ROOM);
break;
case bb:
send_to_char ("Your lungs take the form of gills.\n\r", ch);
act ("$n turns into a fish.", ch, NULL, NULL, TO_ROOM);
break;
case dd:
send_to_char ("You feel yourself slowing d o w n...\n\r", ch);
act ("$n starts to move in slow motion.", ch, NULL, NULL,
TO_ROOM);
break;
case ee:
send_to_char ("Your lungs take the form of gills.\n\r", ch);
act ("$n turns into a fish.", ch, NULL, NULL, TO_ROOM);
break;
}
if (ch->affected != NULL)
affect_strip (ch, paf->type);
REMOVE_BIT (ch->affected_by, paf->bitvector);
affect_to_char (ch, paf);
}
else
affect_modify (ch, paf, TRUE);
if ((obj->item_type == ITEM_LIGHT
&& obj->value[2] != 0 && ch->in_room != NULL)
&& !(!IS_NPC(ch) && ch->pcdata->flaming))
++ch->in_room->light;
trip_triggers(ch, OBJ_TRIG_WEAR, obj, NULL, OT_SPEC_NONE);
return;
}
//
// Equip a char with an obj.
//
bool equip_char_new (CHAR_DATA * ch, OBJ_DATA * obj)
{
return equip_char_new_hand(ch,obj,0);
}
bool equip_char_new_hand (CHAR_DATA * ch, OBJ_DATA * obj, int hand)
{
AFFECT_DATA *paf;
int i;
// if (get_eq_char_new (ch, iWear) != NULL)
// return;
// support alignment/class/race specific equipment
if ((!char_can_wear (ch, obj) && (ch->race != PC_RACE_AVATAR))
|| ((IS_SET(obj->extra_flags[1],ITEM_NOAVATAR)) && ch->race == PC_RACE_AVATAR)
|| ((IS_SET(obj->extra_flags[1],ITEM_NOKALIAN)) && ch->race == PC_RACE_KALIAN))
{
act ("You are zapped by $p and drop it.", ch, obj, NULL, TO_CHAR);
act ("$n is zapped by $p and drops it.", ch, obj, NULL, TO_ROOM);
obj_from_char (obj);
obj_to_room (obj, ch->in_room);
obj->wear_loc = -1;
//Iblis - 3/11/04 - Antiduping Code
if (ch && !IS_NPC(ch))
save_char_obj (ch);
return FALSE;
}
remove_and_equip_char_hand(ch,obj,TRUE,hand);
// obj->wear_loc = 0;
// obj->wear_loc = iWear;
//THIS DOES NOT DEAL PROPERLY WITH RINGS/NECK/WRIST
/* obj->wear_loc = obj->wear_flags;
if (IS_SET(obj->wear_loc,ITEM_TAKE))
obj->wear_loc -= ITEM_TAKE;
if (IS_SET(obj->wear_loc,ITEM_NO_SAC))
obj->wear_loc -= ITEM_NO_SAC;
if (IS_SET(obj->wear_loc,ITEM_TWO_HANDS))
obj->wear_loc -= ITEM_TWO_HANDS;*/
//DEAL WITH AC PROPERLY!! PICK THE
for (i = 0; i < 4; i++)
ch->armor[i] -= apply_ac_new (obj, i);
//obj->wear_loc = iWear;
if (!obj->enchanted)
for (paf = obj->pIndexData->affected; paf != NULL; paf = paf->next)
if (paf->location != APPLY_SPELL_AFFECT)
{
affect_modify (ch, paf, TRUE);
}
for (paf = obj->affected; paf != NULL; paf = paf->next)
if (paf->location == APPLY_SPELL_AFFECT)
{
paf->permaff = TRUE;
switch (paf->bitvector)
{
case A:
send_to_char ("You are blinded!\n\r", ch);
act ("$n appears to be blinded.", ch, NULL, NULL, TO_ROOM);
break;
case B:
send_to_char ("You fade out of existence.\n\r", ch);
act ("$n fades out of existence.", ch, NULL, NULL, TO_ROOM);
break;
case C:
case D:
case E:
case G:
send_to_char ("Your eyes tingle.\n\r", ch);
break;
case F:
send_to_char ("Your awareness improves.\n\r", ch);
break;
case H:
act ("$n is surrounded by a white aura.", ch, NULL, NULL,
TO_ROOM);
send_to_char ("You are surrounded by a white aura.\n\r", ch);
break;
case I:
send_to_char ("You are surrounded by a pink outline.\n\r", ch);
act ("$n is surrounded by a pink outline.", ch, NULL,
NULL, TO_ROOM);
break;
case J:
send_to_char ("Your eyes glow red.\n\r", ch);
act ("$n's eyes glow red.\n\r", ch, NULL, NULL, TO_ROOM);
break;
case K:
send_to_char ("You feel unclean.\n\r", ch);
break;
case M:
send_to_char ("You feel very sick.\n\r", ch);
act ("$n looks very ill.", ch, NULL, NULL, TO_ROOM);
break;
case N:
send_to_char ("You feel holy and pure.\n\r", ch);
break;
case O:
send_to_char ("You feel aligned with darkness.\n\r", ch);
break;
case P:
send_to_char ("You begin to move silently.\n\r", ch);
break;
case Q:
send_to_char ("You hide in the shadows.\n\r", ch);
break;
case R:
send_to_char ("You feel very sleepy ..... zzzzzz.\n\r", ch);
act ("$n goes to sleep.", ch, NULL, NULL, TO_ROOM);
ch->position = POS_SLEEPING;
break;
case T:
send_to_char ("Your feet rise off the ground.\n\r", ch);
act ("$n's feet rise off the ground.", ch, NULL, NULL, TO_ROOM);
break;
case U:
act ("$n turns translucent.", ch, NULL, NULL, TO_ROOM);
send_to_char ("You turn translucent.\n\r", ch);
break;
case V:
send_to_char ("You feel yourself moving more quickly.\n\r", ch);
act ("$n is moving more quickly.", ch, NULL, NULL, TO_ROOM);
break;
case X:
send_to_char
("You scream in agony as plague sores erupt from your skin.\n\r",
ch);
act ("$n screams in agony as plague sores erupt from $s skin.",
ch, NULL, NULL, TO_ROOM);
break;
case Y:
send_to_char ("You feel your strength slip away.\n\r", ch);
act ("$n looks tired and weak.", ch, NULL, NULL, TO_ROOM);
break;
case bb:
send_to_char ("Your lungs take the form of gills.\n\r", ch);
act ("$n turns into a fish.", ch, NULL, NULL, TO_ROOM);
break;
case dd:
send_to_char ("You feel yourself slowing d o w n...\n\r", ch);
act ("$n starts to move in slow motion.", ch, NULL, NULL,
TO_ROOM);
break;
case ee:
send_to_char ("Your lungs take the form of gills.\n\r", ch);
act ("$n turns into a fish.", ch, NULL, NULL, TO_ROOM);
break;
}
if (ch->affected != NULL)
affect_strip (ch, paf->type);
REMOVE_BIT (ch->affected_by, paf->bitvector);
affect_to_char (ch, paf);
}
else
affect_modify (ch, paf, TRUE);
if ((obj->item_type == ITEM_LIGHT
&& obj->value[2] != 0 && ch->in_room != NULL)
&& !(!IS_NPC(ch) && ch->pcdata->flaming))
++ch->in_room->light;
trip_triggers(ch, OBJ_TRIG_WEAR, obj, NULL, OT_SPEC_NONE);
return TRUE;
}
bool equip_char_slot_new (CHAR_DATA * ch, OBJ_DATA * obj, long slot)
{
AFFECT_DATA *paf;
int i;
if (slot == WEAR_NONE)
return FALSE;
// if (get_eq_char_new (ch, iWear) != NULL)
// return;
// support alignment/class/race specific equipment
if ((!char_can_wear (ch, obj) && (ch->race != PC_RACE_AVATAR))
|| ((IS_SET(obj->extra_flags[1],ITEM_NOAVATAR)) && ch->race == PC_RACE_AVATAR)
|| ((IS_SET(obj->extra_flags[1],ITEM_NOKALIAN)) && ch->race == PC_RACE_KALIAN))
{
act ("You are zapped by $p and drop it.", ch, obj, NULL, TO_CHAR);
act ("$n is zapped by $p and drops it.", ch, obj, NULL, TO_ROOM);
obj_from_char (obj);
obj_to_room (obj, ch->in_room);
obj->wear_loc = -1;
//Iblis - 3/11/04 - Antiduping Code
if (ch && !IS_NPC(ch))
save_char_obj (ch);
return FALSE;
}
// remove_and_equip_char_hand(ch,obj,TRUE,hand);
obj->wear_loc = slot;
// obj->wear_loc = 0;
// obj->wear_loc = iWear;
//THIS DOES NOT DEAL PROPERLY WITH RINGS/NECK/WRIST
/* obj->wear_loc = obj->wear_flags;
if (IS_SET(obj->wear_loc,ITEM_TAKE))
obj->wear_loc -= ITEM_TAKE;
if (IS_SET(obj->wear_loc,ITEM_NO_SAC))
obj->wear_loc -= ITEM_NO_SAC;
if (IS_SET(obj->wear_loc,ITEM_TWO_HANDS))
obj->wear_loc -= ITEM_TWO_HANDS;*/
//DEAL WITH AC PROPERLY!! PICK THE
for (i = 0; i < 4; i++)
ch->armor[i] -= apply_ac_new (obj, i);
//obj->wear_loc = iWear;
if (!obj->enchanted)
for (paf = obj->pIndexData->affected; paf != NULL; paf = paf->next)
if (paf->location != APPLY_SPELL_AFFECT)
{
affect_modify (ch, paf, TRUE);
}
for (paf = obj->affected; paf != NULL; paf = paf->next)
if (paf->location == APPLY_SPELL_AFFECT)
{
paf->permaff = TRUE;
switch (paf->bitvector)
{
case A:
send_to_char ("You are blinded!\n\r", ch);
act ("$n appears to be blinded.", ch, NULL, NULL, TO_ROOM);
break;
case B:
send_to_char ("You fade out of existence.\n\r", ch);
act ("$n fades out of existence.", ch, NULL, NULL, TO_ROOM);
break;
case C:
case D:
case E:
case G:
send_to_char ("Your eyes tingle.\n\r", ch);
break;
case F:
send_to_char ("Your awareness improves.\n\r", ch);
break;
case H:
act ("$n is surrounded by a white aura.", ch, NULL, NULL,
TO_ROOM);
send_to_char ("You are surrounded by a white aura.\n\r", ch);
break;
case I:
send_to_char ("You are surrounded by a pink outline.\n\r", ch);
act ("$n is surrounded by a pink outline.", ch, NULL,
NULL, TO_ROOM);
break;
case J:
send_to_char ("Your eyes glow red.\n\r", ch);
act ("$n's eyes glow red.\n\r", ch, NULL, NULL, TO_ROOM);
break;
case K:
send_to_char ("You feel unclean.\n\r", ch);
break;
case M:
send_to_char ("You feel very sick.\n\r", ch);
act ("$n looks very ill.", ch, NULL, NULL, TO_ROOM);
break;
case N:
send_to_char ("You feel holy and pure.\n\r", ch);
break;
case O:
send_to_char ("You feel aligned with darkness.\n\r", ch);
break;
case P:
send_to_char ("You begin to move silently.\n\r", ch);
break;
case Q:
send_to_char ("You hide in the shadows.\n\r", ch);
break;
case R:
send_to_char ("You feel very sleepy ..... zzzzzz.\n\r", ch);
act ("$n goes to sleep.", ch, NULL, NULL, TO_ROOM);
ch->position = POS_SLEEPING;
break;
case T:
send_to_char ("Your feet rise off the ground.\n\r", ch);
act ("$n's feet rise off the ground.", ch, NULL, NULL, TO_ROOM);
break;
case U:
act ("$n turns translucent.", ch, NULL, NULL, TO_ROOM);
send_to_char ("You turn translucent.\n\r", ch);
break;
case V:
send_to_char ("You feel yourself moving more quickly.\n\r", ch);
act ("$n is moving more quickly.", ch, NULL, NULL, TO_ROOM);
break;
case X:
send_to_char
("You scream in agony as plague sores erupt from your skin.\n\r",
ch);
act ("$n screams in agony as plague sores erupt from $s skin.",
ch, NULL, NULL, TO_ROOM);
break;
case Y:
send_to_char ("You feel your strength slip away.\n\r", ch);
act ("$n looks tired and weak.", ch, NULL, NULL, TO_ROOM);
break;
case bb:
send_to_char ("Your lungs take the form of gills.\n\r", ch);
act ("$n turns into a fish.", ch, NULL, NULL, TO_ROOM);
break;
case dd:
send_to_char ("You feel yourself slowing d o w n...\n\r", ch);
act ("$n starts to move in slow motion.", ch, NULL, NULL,
TO_ROOM);
break;
case ee:
send_to_char ("Your lungs take the form of gills.\n\r", ch);
act ("$n turns into a fish.", ch, NULL, NULL, TO_ROOM);
break;
}
if (ch->affected != NULL)
affect_strip (ch, paf->type);
REMOVE_BIT (ch->affected_by, paf->bitvector);
affect_to_char (ch, paf);
}
else
affect_modify (ch, paf, TRUE);
if ((obj->item_type == ITEM_LIGHT
&& obj->value[2] != 0 && ch->in_room != NULL)
&& !(!IS_NPC(ch) && ch->pcdata->flaming))
++ch->in_room->light;
//this is getting worn silently to fix something, so don't do obj triggers
//trip_triggers(ch, OBJ_TRIG_WEAR, obj, NULL, OT_SPEC_NONE);
return TRUE;
}
/*
* Unequip a char with an obj.
*/
void unequip_char (CHAR_DATA * ch, OBJ_DATA * obj)
{
AFFECT_DATA *paf = NULL;
AFFECT_DATA *lpaf = NULL;
AFFECT_DATA *lpaf_next = NULL;
int i;
if (!obj || obj->wear_loc == WEAR_NONE)
return;
for (i = 0; i < 4; i++)
ch->armor[i] += apply_ac_new (obj, i);
obj->wear_loc = -1;
if (!obj->enchanted)
{
for (paf = obj->pIndexData->affected; paf != NULL; paf = paf->next)
{
if (paf->location == APPLY_SPELL_AFFECT)
{
for Showing the first 100 KB of 191.3 KB. Download the archive for the full file.