magic.c
kbkmud/src/magic.c · 296.8 KB
From the archive kbkmud.tar.gz
Download the archive « Back to the archive contents
/***************************************************************************
* Original Diku Mud copyright (C) 1990, 1991 by Sebastian Hammer, *
* Michael Seifert, Hans Henrik St{rfeldt, Tom Madsen, and Katja Nyboe. *
* *
* Merc Diku Mud improvments copyright (C) 1992, 1993 by Michael *
* Chastain, Michael Quan, and Mitchell Tse. *
* *
* In order to use any part of this Merc Diku Mud, you must comply with *
* both the original Diku license in 'license.doc' as well the Merc *
* license in 'license.txt'. In particular, you may not remove either of *
* these copyright notices. *
* *
* Thanks to abaddon for proof-reading our comm.c and pointing out bugs. *
* Any remaining bugs are, of course, our work, not his. :) *
* *
* Much time and thought has gone into this software and you are *
* benefitting. We hope that you share your changes too. What goes *
* around, comes around. *
***************************************************************************/
/***************************************************************************
* ROM 2.4 is copyright 1993-1996 Russ Taylor *
* ROM has been brought to you by the ROM consortium *
* Russ Taylor (rtaylor@pacinfo.com) *
* Gabrielle Taylor (gtaylor@pacinfo.com) *
* Brian Moore (rom@rom.efn.org) *
* By using this code, you have agreed to follow the terms of the *
* ROM license, in the file Tartarus/doc/rom.license *
***************************************************************************/
/***************************************************************************
* Tartarus code is copyright (C) 1997-1998 by Daniel Graham *
* In using this code you agree to comply with the Tartarus license *
* found in the file /Tartarus/doc/tartarus.doc *
***************************************************************************/
#include "include.h"
/* command procedures needed */
DECLARE_DO_FUN(do_gtell );
DECLARE_DO_FUN(do_follow );
DECLARE_DO_FUN(do_look );
DECLARE_DO_FUN(do_laying_hands );
DECLARE_DO_FUN(do_barkskin );
DECLARE_DO_FUN(do_yell );
DECLARE_DO_FUN(do_myell );
DECLARE_DO_FUN(do_say );
DECLARE_DO_FUN(do_flee );
DECLARE_DO_FUN(do_murder );
/*
* Local functions.
*/
void say_spell args( ( CHAR_DATA *ch, int sn ) );
int spellcraft_dam args( ( int num, int dice) );
bool check_spellcraft args( (CHAR_DATA *ch, int sn) );
bool eye_of_beholder_nullify args((CHAR_DATA *ch));
bool cleansed args ((CHAR_DATA *ch, CHAR_DATA *victim,int diffmodifier, int sn));
bool check_counterspell args((CHAR_DATA *ch, CHAR_DATA *victim));
bool remove_obj args( ( CHAR_DATA *ch, int iWear, bool fReplace ) );
bool is_affected_obj args( ( OBJ_DATA *obj, int sn ) );
void wear_obj args( ( CHAR_DATA *ch, OBJ_DATA *obj, bool fReplace ) );
/*
* Lookup a skill by name.
*/
int skill_lookup( const char *name )
{
int sn;
for ( sn = 0; sn < MAX_SKILL; sn++ )
{
if ( skill_table[sn].name == NULL )
break;
if ( LOWER(name[0]) == LOWER(skill_table[sn].name[0])
&& !str_prefix( name, skill_table[sn].name ) )
return sn;
}
return -1;
}
int find_spell( CHAR_DATA *ch, const char *name )
{
/* finds a spell the character can cast if possible */
int sn, found = -1;
if (IS_NPC(ch))
return skill_lookup(name);
for ( sn = 0; sn < MAX_SKILL; sn++ )
{
if (skill_table[sn].name == NULL)
break;
if (LOWER(name[0]) == LOWER(skill_table[sn].name[0])
&& !str_prefix(name,skill_table[sn].name))
{
if ( found == -1)
found = sn;
if (ch->level >= skill_table[sn].skill_level[ch->class]
&& ch->pcdata->learned[sn] > 0)
return sn;
}
}
return found;
}
/*
* Lookup a skill by slot number.
* Used for object loading.
*/
int slot_lookup( int slot )
{
extern bool fBootDb;
int sn;
if ( slot <= 0 )
return -1;
for ( sn = 0; sn < MAX_SKILL; sn++ )
{
if ( slot == skill_table[sn].slot )
return sn;
}
if ( fBootDb )
{
bug( "Slot_lookup: bad slot %d.", slot );
abort( );
}
return -1;
}
/* Eye of beholder dispel code */
bool eye_of_beholder_nullify(CHAR_DATA *ch)
{
OBJ_DATA *eye;
eye = get_eq_char(ch,WEAR_LIGHT);
if (eye == NULL
|| eye->pIndexData->vnum != 14003)
return FALSE;
if (saves_spell(eye->level, ch,DAM_OTHER))
return FALSE;
send_to_char("The beholder eye in your hands nullifies your magic!\n\r",ch);
act("$n's spell fizzles.",ch,0,0,TO_ROOM);
return TRUE;
}
/*
* Utter mystical words for an sn.
*/
void say_spell( CHAR_DATA *ch, int sn )
{
char buf [MAX_STRING_LENGTH];
char buf2 [MAX_STRING_LENGTH];
CHAR_DATA *rch;
char *pName;
int iSyl;
int length;
struct syl_type
{
char * old;
char * new;
};
static const struct syl_type syl_table[] =
{
{ " ", " " },
{ "ar", "abra" },
{ "au", "kada" },
{ "bless", "fido" },
{ "blind", "nose" },
{ "bur", "mosa" },
{ "cu", "judi" },
{ "de", "oculo" },
{ "en", "unso" },
{ "light", "dies" },
{ "lo", "hi" },
{ "mor", "zak" },
{ "move", "sido" },
{ "ness", "lacri" },
{ "ning", "illa" },
{ "per", "duda" },
{ "ra", "gru" },
{ "fresh", "ima" },
{ "re", "candus" },
{ "son", "sabru" },
{ "tect", "infra" },
{ "tri", "cula" },
{ "ven", "nofo" },
{ "a", "a" }, { "b", "b" }, { "c", "q" }, { "d", "e" },
{ "e", "z" }, { "f", "y" }, { "g", "o" }, { "h", "p" },
{ "i", "u" }, { "j", "y" }, { "k", "t" }, { "l", "r" },
{ "m", "w" }, { "n", "i" }, { "o", "a" }, { "p", "s" },
{ "q", "d" }, { "r", "f" }, { "s", "g" }, { "t", "h" },
{ "u", "j" }, { "v", "z" }, { "w", "x" }, { "x", "n" },
{ "y", "l" }, { "z", "k" },
{ "", "" }
};
if ( (sn == skill_lookup("power word kill"))
|| (sn == skill_lookup("power word stun")) )
return;
buf[0] = '\0';
for ( pName = skill_table[sn].name; *pName != '\0'; pName += length )
{
for ( iSyl = 0; (length = strlen(syl_table[iSyl].old)) != 0; iSyl++ )
{
if ( !str_prefix( syl_table[iSyl].old, pName ) )
{
strcat( buf, syl_table[iSyl].new );
break;
}
}
if ( length == 0 )
length = 1;
}
sprintf( buf2, "$n utters the words, '%s'.", buf );
sprintf( buf, "$n utters the words, '%s'.", skill_table[sn].name );
for ( rch = ch->in_room->people; rch; rch = rch->next_in_room )
{
if ( rch != ch )
act((IS_IMMORTAL(rch) && IS_SET(rch->act,PLR_HOLYLIGHT)) || (!IS_NPC(rch) && ch->class==rch->class) ? buf : buf2,
ch, NULL, rch, TO_VICT );
/* act( ch->class==rch->class ? buf : buf2, ch, NULL, rch, TO_VICT );*/
}
return;
}
/*
* Compute a saving throw.
* Negative apply's make saving throw better.
*/
bool saves_spell( int level, CHAR_DATA *victim, int dam_type )
{
int save;
if(victim->fighting && get_trust(victim->fighting)==MAX_LEVEL)
return FALSE;
//Base 35% chance to save
//Subtract 5% for the difference between the spell's level and the victim's level
//Add 2/3 of the victim's saving throw in
//So for a 51 spell with -100 svs, 35 + 66 = 101 chance to save
save = 35 + ( victim->level - level) * 5 - (victim->saving_throw*.66);
if (IS_AFFECTED(victim,AFF_BERSERK))
save += (victim->drain_level + victim->level)/5;
if (IS_NPC(victim))
save += victim->level/3;
switch(check_immune(victim,dam_type))
{
case IS_IMMUNE: return TRUE;
case IS_RESISTANT: save *= 1.3; break;
case IS_VULNERABLE: save *= .7; break;
}
if(is_affected(victim,skill_lookup("strength of faith")) && (number_percent()<50 || dam_type==DAM_HOLY))
return TRUE;
if(get_skill(victim,skill_lookup("elemental affinity")) > 75 && dam_type > 3) {
int chance = number_percent();
save = (10 + (chance / 10)) * save / 10;
}
save = 9 * save / 10;
if (!IS_NPC(victim))
n_logf("Saves_spell: VICTIM=%s LEVEL=%d DAM=%d SAVE=%d", victim->name, level, dam_type, save);
save = URANGE( 5, save, 85 );
return number_percent( ) < save;
}
/* RT save for dispels */
bool saves_dispel( int dis_level, int spell_level, int duration)
{
int save;
save = 68 + (spell_level - dis_level) * 5;
if(duration==-1)
return TRUE;
save = URANGE( 20, save, 80 );
return number_percent( ) < save;
}
/* for finding mana costs -- temporary version */
int mana_cost (CHAR_DATA *ch, int min_mana, int level)
{
if (ch->level + 2 == level)
return 1000;
return UMAX(min_mana,(100/(2 + ch->level - level)));
}
void do_laying_hands( CHAR_DATA *ch, char *argument )
{
char arg[MAX_INPUT_LENGTH];
CHAR_DATA *victim;
int heal, sn;
AFFECT_DATA af;
if ( (get_skill(ch,gsn_laying_hands) == 0)
|| (ch->level < skill_table[gsn_laying_hands].skill_level[ch->class] ) )
{
send_to_char("You do not have the ability to divinely heal.\n\r",ch);
return;
}
one_argument(argument, arg);
if (arg[0] == '\0')
{
send_to_char("Give your divine touch to whom?\n\r", ch);
return;
}
if ( (victim = get_char_room(ch, arg)) == NULL )
{
send_to_char("They aren't here.\n\r",ch);
return;
}
if (victim == ch)
return send_to_char("That wouldn't be very selfless.\n\r", ch);
if (is_affected(ch, gsn_laying_hands) )
return send_to_char("The gods have not granted you divine touch yet.\n\r", ch);
if (IS_EVIL(victim))
return send_to_char("Your deity would not approve of that.\n\r",ch);
if (ch->mana < 80)
return send_to_char("You don't have the mana.\n\r",ch);
ch->mana -= skill_table[gsn_laying_hands].min_mana;
WAIT_STATE( ch, skill_table[gsn_laying_hands].beats );
init_affect(&af);
af.where = TO_AFFECTS;
af.aftype = AFT_SKILL;
af.type = gsn_laying_hands;
af.level = ch->level;
af.duration = 24;
af.modifier = 0;
af.location = 0;
af.bitvector = 0;
af.affect_list_msg = str_dup("prevents usage of laying hands");
affect_to_char( ch, &af);
sn=skill_lookup("poison");
if(is_affected(victim,sn) && cleansed(ch,victim,2,sn))
{
act("$n looks less ill.",victim,0,ch,TO_ROOM);
send_to_char(skill_table[sn].msg_off, victim );
send_to_char("\n\r", victim);
affect_strip(victim,sn);
}
sn=skill_lookup("blindness");
if(is_affected(victim,sn) && cleansed(ch,victim,2,sn))
{
act("$n looks less ill.",victim,0,ch,TO_ROOM);
send_to_char(skill_table[sn].msg_off, victim );
send_to_char("\n\r", victim);
affect_strip(victim,sn);
}
sn=skill_lookup("weaken");
if(is_affected(victim,sn) && cleansed(ch,victim,1,sn))
{
act("$n looks stronger.",victim,0,ch,TO_ROOM);
send_to_char(skill_table[sn].msg_off, victim );
send_to_char("\n\r", victim);
affect_strip(victim,sn);
}
sn=skill_lookup("plague");
if(is_affected(victim,sn) && cleansed(ch,victim,2,sn))
{
act("$n looks less diseased.",victim,0,ch,TO_ROOM);
send_to_char(skill_table[sn].msg_off, victim );
send_to_char("\n\r", victim);
affect_strip(victim,sn);
}
sn=skill_lookup("curse");
if(is_affected(victim,sn) && cleansed(ch,victim,2,sn))
{
act("$n's curse wears off.",victim,0,ch,TO_ROOM);
send_to_char(skill_table[sn].msg_off, victim );
send_to_char("\n\r", victim);
affect_strip(victim,sn);
}
heal = ch->level * 6;
victim->hit = UMIN(victim->hit + heal, victim->max_hit);
act("$n lays $s hands upon $N and $N's wounds seem to heal.",ch,NULL,victim, TO_NOTVICT);
act("You lay hands upon $N and $S wounds seem to heal.", ch, NULL, victim, TO_CHAR);
act("$n lays hands upon you in blessed communication and your wounds heal.",ch,NULL,victim,TO_VICT);
return;
}
/*
* The kludgy global is for spells who want more stuff from command line.
*/
char *target_name;
void do_cast( CHAR_DATA *ch, char *argument )
{
char buf[MAX_STRING_LENGTH];
char arg1[MAX_INPUT_LENGTH];
char arg2[MAX_INPUT_LENGTH];
CHAR_DATA *victim;
OBJ_DATA *obj;
void *vo;
int mana;
int sn;
bool runeDagger=FALSE;
int target;
bool absorbed = FALSE;
bool reflected = FALSE;
/*
* Switched NPC's can cast spells, but others can't.
*/
if ( IS_NPC(ch) && ch->desc == NULL)
return;
if(class_table[ch->class].ctype!=CLASS_CASTER && !IS_IMMORTAL(ch))
{
send_to_char("You must ask your deity for prayers instead of pulling it from the world.\n\r",ch);
return;
}
if (ch->cabal == CABAL_RAGER && !IS_IMMORTAL(ch))
{
send_to_char("You cannot cast spells as a Rager.\n\r",ch);
return;
}
if (is_affected(ch, gsn_deafen) && number_percent()<40)
{
send_to_char("You can't get the right intonations.\n\r", ch);
WAIT_STATE(ch,PULSE_VIOLENCE);
return;
}
if (is_affected(ch, gsn_garble) && number_percent()<40)
{
send_to_char("You can't get the right intonations.\n\r", ch);
WAIT_STATE(ch,PULSE_VIOLENCE);
return;
}
if(is_affected(ch,gsn_tigerclaw))
{
if (number_percent() > 65) // Fail, the command does NOT go through
{
send_to_char("Blood bubbles from your throat as you fail to make sound.\n\r",ch);
damage_old(ch,ch,number_range(50,200),gsn_tigerclaw,DAM_NONE,TRUE);
return;
WAIT_STATE(ch,PULSE_VIOLENCE);
} else { // It goes through, and less damage
send_to_char("Your throat throbs with pain but you overcome it and continue.\n\r",ch);
damage_old(ch,ch,number_range(20,80),gsn_tigerclaw,DAM_NONE,TRUE);
}
}
if (is_affected(ch, gsn_gag) && number_percent()<90)
{
send_to_char("You nearly choke as your try to speak with a gag in your mouth.\n\r",ch);
act("$n makes a muffled noise from behind a gag.",ch,NULL,NULL,TO_ROOM);
return;
}
target_name = one_argument( argument, arg1 );
one_argument( target_name, arg2 );
if ( arg1[0] == '\0' )
{
send_to_char( "Cast which what where?\n\r", ch );
return;
}
if ((sn = find_spell(ch,arg1)) < 1
|| skill_table[sn].spell_fun == spell_null
|| (ch->level < skill_table[sn].skill_level[ch->class] && !IS_IMMORTAL(ch))
|| (IS_NPC(ch))
|| ch->pcdata->learned[sn] == 0)
{
send_to_char( "You don't know any spells of that name.\n\r", ch );
return;
}
if ( ch->position < skill_table[sn].minimum_position )
{
send_to_char( "You can't concentrate enough.\n\r", ch );
return;
}
if(is_affected(ch,gsn_shadowstrike) && number_percent()<35) {
send_to_char("The shadowy arms restrict your movements.\n\r",ch);
act("$n tries to cast a spell but is held back by shadowy arms.",ch,0,0,TO_ROOM);
WAIT_STATE(ch,12);
return;
}
if (ch->level + 2 == skill_table[sn].skill_level[ch->class])
mana = 50;
else
mana = UMAX(
skill_table[sn].min_mana,
100 / ( 2 + ch->level - skill_table[sn].skill_level[ch->class] ) );
switch (get_curr_stat(ch,STAT_INT)) {
case 25: mana = 43 * mana / 50; break;
case 24: mana = 22 * mana / 25; break;
case 23: mana = 45 * mana / 50; break;
case 22: mana = 23 * mana / 25; break;
case 21: mana = 47 * mana / 50; break;
case 20: mana = 24 * mana / 25; break;
case 19: mana = 49 * mana / 50; break;
}
{
OBJ_DATA *ring;
ring = get_eq_char(ch,WEAR_FINGER_R);
if (ring != NULL && ring->pIndexData->vnum == OBJ_VNUM_WIZARDRY_1)
mana -= (7*mana/100);
else if (ring != NULL && ring->pIndexData->vnum == OBJ_VNUM_WIZARDRY_2)
mana -= (15*mana/100);
ring = get_eq_char(ch,WEAR_FINGER_L);
if (ring != NULL && ring->pIndexData->vnum == OBJ_VNUM_WIZARDRY_1)
mana -= (7*mana/100);
else if (ring != NULL && ring->pIndexData->vnum == OBJ_VNUM_WIZARDRY_2)
mana -= (15*mana/100);
}
/*
* Locate targets.
*/
victim = NULL;
obj = NULL;
vo = NULL;
target = TARGET_NONE;
switch ( skill_table[sn].target )
{
default:
bug( "Do_cast: bad target for sn %d.", sn );
return;
case TAR_IGNORE:
break;
case TAR_CHAR_OFFENSIVE:
if ( arg2[0] == '\0' )
{
if ( ( victim = ch->fighting ) == NULL )
{
send_to_char( "Cast the spell on whom?\n\r", ch );
return;
}
}
else
{
if ( ( victim = get_char_room( ch, target_name ) ) == NULL )
{
send_to_char( "They aren't here.\n\r", ch );
return;
}
}
if ( !IS_NPC(ch) )
{
check_killer(ch,victim);
}
if ( IS_AFFECTED(ch, AFF_CHARM) && ch->master == victim )
{
send_to_char( "You can't do that on your own master.\n\r",
ch );
return;
}
vo = (void *) victim;
target = TARGET_CHAR;
break;
case TAR_CHAR_DEFENSIVE:
if ( arg2[0] == '\0' )
{
victim = ch;
}
else
{
if ( ( victim = get_char_room( ch, target_name ) ) == NULL )
{
send_to_char( "They aren't here.\n\r", ch );
return;
}
}
vo = (void *) victim;
target = TARGET_CHAR;
break;
case TAR_CHAR_SELF:
if ( arg2[0] != '\0' && !is_name( target_name, ch->name ) )
{
send_to_char( "You cannot cast this spell on another.\n\r", ch );
return;
}
vo = (void *) ch;
target = TARGET_CHAR;
break;
case TAR_OBJ_INV:
if ( arg2[0] == '\0' )
{
send_to_char( "What should the spell be cast upon?\n\r", ch );
return;
}
if ( ( obj = get_obj_carry( ch, target_name, ch ) ) == NULL )
{
send_to_char( "You are not carrying that.\n\r", ch );
return;
}
vo = (void *) obj;
target = TARGET_OBJ;
break;
case TAR_OBJ_CHAR_OFF:
if (arg2[0] == '\0')
{
if ((victim = ch->fighting) == NULL)
{
send_to_char("Cast the spell on whom or what?\n\r",ch);
return;
}
target = TARGET_CHAR;
}
else if ((victim = get_char_room(ch,target_name)) != NULL)
{
target = TARGET_CHAR;
}
if (target == TARGET_CHAR) /* check the sanity of the attack */
{
if ( IS_AFFECTED(ch, AFF_CHARM) && ch->master == victim )
{
send_to_char( "You can't do that on your own follower.\n\r",
ch );
return;
}
if (!IS_NPC(ch))
check_killer(ch,victim);
vo = (void *) victim;
}
else if ((obj = get_obj_here(ch,target_name)) != NULL)
{
vo = (void *) obj;
target = TARGET_OBJ;
}
else
{
send_to_char("You don't see that here.\n\r",ch);
return;
}
break;
case TAR_OBJ_CHAR_DEF:
if (arg2[0] == '\0')
{
vo = (void *) ch;
target = TARGET_CHAR;
}
else if ((victim = get_char_room(ch,target_name)) != NULL)
{
vo = (void *) victim;
target = TARGET_CHAR;
}
else if ((obj = get_obj_carry(ch,target_name,ch)) != NULL)
{
vo = (void *) obj;
target = TARGET_OBJ;
}
else
{
send_to_char("You don't see that here.\n\r",ch);
return;
}
break;
}
if ( !IS_NPC(ch) && ch->mana < mana )
{
send_to_char( "You don't have enough mana.\n\r", ch );
return;
}
if ( str_cmp( skill_table[sn].name, "ventriloquate" ) )
say_spell( ch, sn );
WAIT_STATE( ch, skill_table[sn].beats );
if ( number_percent( ) > get_skill(ch,sn) )
{
send_to_char( "You lost your concentration.\n\r", ch );
check_improve(ch,sn,FALSE,1);
if (get_skill(ch,skill_lookup("mental clarity")) > 75)
ch->mana -= mana / 4;
else
ch->mana -= mana / 2;
}
else
{
if (get_skill(ch,skill_lookup("mental clarity")) > 75)
ch->mana -= mana / 2;
else
ch->mana -= mana;
if (IS_SET(ch->in_room->room_flags,ROOM_NO_MAGIC) && !(ch->level > LEVEL_HERO))
{
act("$n's spell fizzles.",ch,0,0,TO_ROOM);
send_to_char("Your spell fizzles and dies.\n\r",ch);
return;
}
if (eye_of_beholder_nullify(ch))
return;
if (skill_table[sn].target == TAR_CHAR_OFFENSIVE
&& is_safe(ch,victim))
return;
if (skill_table[sn].target == TAR_CHAR_DEFENSIVE && is_affected(victim,gsn_timestop))
{
act("$N is stuck in time and is unaffected by your spell.",ch,0,victim,TO_CHAR);
act("$N is untouched by $n's spell.",ch,0,victim,TO_NOTVICT);
act("$n tries to cast something on you but you are stuck in time and unaffected.",ch,0,victim,TO_VICT);
return;
}
if (skill_table[sn].target == TAR_CHAR_DEFENSIVE
|| skill_table[sn].target == TAR_CHAR_OFFENSIVE)
reflected = spellbaned(ch,victim,sn);
if (skill_table[sn].target == TAR_CHAR_OFFENSIVE)
{
if (!IS_NPC(ch) && !IS_NPC(victim)
&& (ch->fighting == NULL || victim->fighting == NULL) && str_cmp(skill_table[sn].name, "incinerate")!=1)
{
switch(number_range(0,2))
{
case (0):
case (1):
sprintf(buf,"Die, %s you sorcerous dog!",PERS(ch,victim));
break;
case (2):
sprintf(buf,"Help! %s is casting a spell on me!",PERS(ch,victim));
}
if (victim != ch && !IS_NPC(ch))
do_myell(victim,buf);
}
if(check_counterspell(ch,victim))
{
act("$N reflects your spell right back at you!",ch,0,victim,TO_CHAR);
act("You reflect $n's spell right back at $m!",ch,0,victim,TO_VICT);
act("$N reflects $n's spell right back at $m!",ch,0,victim,TO_NOTVICT);
(*skill_table[sn].spell_fun) ( sn, ch->level*2, victim, ch, target);
return;
}
if (is_affected(victim,skill_lookup("body of diamond"))) {
if (number_percent() < 25) {
act("Your spell is reflected off $N's diamond skin!",ch,0,victim,TO_CHAR);
act("Your diamond skin reflects $n's spell!",ch,0,victim,TO_VICT);
act("$N's diamond skin reflects $n's spell!",ch,0,victim,TO_NOTVICT);
(*skill_table[sn].spell_fun) ( sn, ch->level/4, victim, ch, target);
}
}
}
absorbed = check_absorb(ch,victim,sn);
if (reflected && skill_table[sn].target == TAR_CHAR_OFFENSIVE)
vo = (void *) ch;
OBJ_DATA *dagger;
dagger = get_eq_char(ch, WEAR_WIELD);
if (dagger != NULL && dagger->pIndexData->vnum == 27500)
runeDagger = TRUE;
if ((!absorbed) && (!reflected))
(*skill_table[sn].spell_fun) ( sn, runeDagger ? ch->level * 1.4 + GET_HITROLL(ch)/20 : ch->level + GET_HITROLL(ch)/20, ch, vo,target);
check_improve(ch,sn,TRUE,1);
}
if ((skill_table[sn].target == TAR_CHAR_OFFENSIVE
|| (skill_table[sn].target == TAR_OBJ_CHAR_OFF && target == TARGET_CHAR))
&& victim != ch
&& victim->master != ch)
{
CHAR_DATA *vch;
CHAR_DATA *vch_next;
for ( vch = ch->in_room->people; vch; vch = vch_next )
{
vch_next = vch->next_in_room;
if ( victim == vch && victim->fighting == NULL )
{ check_killer(victim,ch);
multi_hit( victim, ch, TYPE_UNDEFINED );
break;
}
}
}
return;
}
bool check_absorb(CHAR_DATA *ch,CHAR_DATA *victim,int dt)
{
int mana;
if (dt >= 0 && dt < MAX_SKILL)
{
if (skill_table[dt].target != TAR_CHAR_OFFENSIVE || !is_affected(victim,gsn_absorb))
return FALSE;
if (skill_table[dt].ctype == CMD_COMMUNE
|| (skill_table[dt].ctype == CMD_BOTH && class_table[ch->class].ctype == CLASS_COMMUNER))
return FALSE;
if (ch == victim)
return FALSE;
if (!IS_NPC(ch))
{
if (ch->level + 2 == skill_table[dt].skill_level[ch->class])
mana = 50;
else
mana = UMAX( skill_table[dt].min_mana, 100 / ( 2 + ch->level - skill_table[dt].skill_level[ch->class] ) );
}
else
mana = skill_table[dt].min_mana;
if (number_percent() < ((victim->level*2) + (victim->pcdata->learned[gsn_absorb]) / 2) && (number_percent() > 40))
{
act("The air about $N shimmers as it absorbs $n's spell.",ch,NULL,victim,TO_NOTVICT);
act("The air about you shimmers as it absorbs $n's spell.",ch,NULL,victim,TO_VICT);
act("The air about $N shimmers as it absorbs your spell.",ch,NULL,victim,TO_CHAR);
victim->mana += mana;
send_to_char("You feel mana surge through you!\n\r",victim);
return TRUE;
}
}
return FALSE;
}
/*
* Cast spells at targets using a magical object.
*/
void obj_cast_spell( int sn, int level, CHAR_DATA *ch, CHAR_DATA *victim, OBJ_DATA *obj )
{
void *vo;
int target = TARGET_NONE;
if ( sn <= 0 )
return;
if ( sn >= MAX_SKILL || skill_table[sn].spell_fun == 0 )
{
bug( "Obj_cast_spell: bad sn %d.", sn );
return;
}
if (IS_SET(ch->in_room->room_flags,ROOM_NO_MAGIC))
{
act("$n's spell fizzles.",ch,0,0,TO_ROOM);
send_to_char("Your spell fizzles and dies.\n\r",ch);
return;
}
switch ( skill_table[sn].target )
{
default:
bug( "Obj_cast_spell: bad target for sn %d.", sn );
return;
case TAR_IGNORE:
vo = NULL;
break;
case TAR_CHAR_OFFENSIVE:
if ( victim == NULL )
victim = ch->fighting;
if ( victim == NULL )
{
send_to_char( "You can't do that.\n\r", ch );
return;
}
if (is_safe(ch,victim) && ch != victim)
{
send_to_char("Something isn't right...\n\r",ch);
return;
}
vo = (void *) victim;
target = TARGET_CHAR;
break;
case TAR_CHAR_DEFENSIVE:
case TAR_CHAR_SELF:
if ( victim == NULL )
victim = ch;
vo = (void *) victim;
target = TARGET_CHAR;
break;
case TAR_OBJ_INV:
if ( obj == NULL )
{
send_to_char( "You can't do that.\n\r", ch );
return;
}
vo = (void *) obj;
target = TARGET_OBJ;
break;
case TAR_OBJ_CHAR_OFF:
if ( victim == NULL && obj == NULL)
{
if (ch->fighting != NULL)
victim = ch->fighting;
else
{
send_to_char("You can't do that.\n\r",ch);
return;
}
}
if (victim != NULL)
{
if (is_safe_spell(ch,victim,FALSE) && ch != victim)
{
send_to_char("Something isn't right...\n\r",ch);
return;
}
vo = (void *) victim;
target = TARGET_CHAR;
}
else
{
vo = (void *) obj;
target = TARGET_OBJ;
}
break;
case TAR_OBJ_CHAR_DEF:
if (victim == NULL && obj == NULL)
{
vo = (void *) ch;
target = TARGET_CHAR;
}
else if (victim != NULL)
{
vo = (void *) victim;
target = TARGET_CHAR;
}
else
{
vo = (void *) obj;
target = TARGET_OBJ;
}
break;
}
target_name = "";
(*skill_table[sn].spell_fun) ( sn, level, ch, vo,target);
if ( (skill_table[sn].target == TAR_CHAR_OFFENSIVE
|| (skill_table[sn].target == TAR_OBJ_CHAR_OFF && target == TARGET_CHAR))
&& victim != ch
&& victim->master != ch )
{
CHAR_DATA *vch;
CHAR_DATA *vch_next;
for ( vch = ch->in_room->people; vch; vch = vch_next )
{
vch_next = vch->next_in_room;
if ( victim == vch && victim->fighting == NULL )
{
check_killer(victim,ch);
multi_hit( victim, ch, TYPE_UNDEFINED );
break;
}
}
}
return;
}
/*
* Spell functions.
*/
void spell_absorb( int sn, int level, CHAR_DATA *ch, void *vo, int target )
{
CHAR_DATA *victim = (CHAR_DATA *) vo;
AFFECT_DATA af;
if (is_affected(victim,gsn_absorb) )
{
send_to_char("You are already absorbing spells.\n\r",victim);
return;
}
init_affect(&af);
af.aftype = AFT_SPELL;
af.where = TO_AFFECTS;
af.type = gsn_absorb;
af.level = level;
af.duration = 3 + level/5;
af.modifier = 0;
af.location = 0;
af.bitvector = 0;
af.affect_list_msg = str_dup("grants a chance to absorb spells");
affect_to_char(victim, &af);
send_to_char("A shimmering force field crackles around you.\n\r",victim);
act("A sizzling force field shimmers into existence around $n.",victim,NULL,NULL,TO_ROOM);
return;
}
void spell_acidneedles( int sn, int level, CHAR_DATA *ch, void *vo, int target )
{
CHAR_DATA *victim = (CHAR_DATA *) vo;
int dam;
int num;
if (check_spellcraft(ch,sn))
dam = spellcraft_dam(level/3,5);
else
dam = dice( level/3, 5 );
if (is_affected(victim,skill_lookup("plague"))) {
AFFECT_DATA *plague = affect_find(victim->affected,skill_lookup("plague"));
if (!plague) goto skip_acid_multiplier;
if (plague->modifier <= -4) {
act("You wince in agony as the acid needles penetrate your plague sores!",ch,0,victim,TO_VICT);
act("$N winces in agony as the acid needles penetrate $S plague sores!",ch,0,victim,TO_NOTVICT);
act("$N winces in agony as the acid needles penetrate $S plague sores!",ch,0,victim,TO_CHAR);
dam += 5 + dice(-1 * plague->modifier,1);
if (number_percent() < 30) {
act("The plague worsens!",0,0,victim,TO_VICT);
plague->modifier -= 1;
}
}
}
else if (is_affected(victim,skill_lookup("poison"))) {
AFFECT_DATA *poison = affect_find(victim->affected,skill_lookup("poison"));
if (!poison) goto skip_acid_multiplier;
if (poison->modifier <= -4) {
act("The acid needles exacerbate your poison as they sink into your flesh!",ch,0,victim,TO_VICT);
act("$N goes slightly pale as the acid needles sink into $S flesh!",ch,0,victim,TO_NOTVICT);
act("$N goes slightly pale as the acid needles sink into $S flesh!",ch,0,victim,TO_CHAR);
dam += 8 + dice(-1 * poison->modifier,3);
level += 2;
if (number_percent() < 50) {
act("The poison becomes more potent!",0,0,victim,TO_VICT);
poison->modifier -= 1;
}
}
}
else if (is_affected(victim,skill_lookup("weaken"))) {
AFFECT_DATA *weaken = affect_find(victim->affected,skill_lookup("weaken"));
if (!weaken) goto skip_acid_multiplier;
act("The acid needles sizzle and burn your weakened muscles as they pierce your flesh!",ch,0,victim,TO_VICT);
act("The acid needles sizzle and burn $N's weakened muscles as they pierce $S flesh!",ch,0,victim,TO_NOTVICT);
act("The acid needles sizzle and burn $N's weakened muscles as they pierce $S flesh!",ch,0,victim,TO_CHAR);
dam += 12 + dice(-1 * weaken->modifier,5);
level += 4;
if (number_percent() < 75) {
act("You feel weaker as the acid melts away your muscle tissue.",0,0,victim,TO_VICT);
weaken->modifier -= 1;
}
}
skip_acid_multiplier:
if ( saves_spell( level, victim, DAM_ACID ) )
dam = 2 * dam / 3;
for (num = 0; num < 4; num++)
{
if (number_percent() < 100 - num*5)
damage_old(ch,victim,dam,sn,DAM_ACID,TRUE);
dam = dam - dam/5;
}
WAIT_STATE(ch,PULSE_VIOLENCE*1);
return;
}
void spell_acid_blast( int sn, int level, CHAR_DATA *ch, void *vo, int target )
{
CHAR_DATA *victim = (CHAR_DATA *) vo;
int dam;
if (check_spellcraft(ch,sn))
dam = spellcraft_dam(level,9);
else
dam = dice( level, 8.5 );
if ( saves_spell( level, victim, DAM_ACID ) )
dam /= 2;
damage_old( ch, victim, dam, sn,DAM_ACID,TRUE);
return;
}
void spell_armor( int sn, int level, CHAR_DATA *ch, void *vo, int target )
{
CHAR_DATA *victim = (CHAR_DATA *) vo;
AFFECT_DATA af;
if ( is_affected( victim, sn ) )
{
if (victim == ch)
send_to_char("You are already armored.\n\r",ch);
else
act("$N is already armored.",ch,NULL,victim,TO_CHAR);
return;
}
init_affect(&af);
af.where = TO_AFFECTS;
af.aftype = get_spell_aftype(ch);
af.type = sn;
af.level = level;
af.duration = 24;
af.modifier = AC_PER_ONE_PERCENT_DECREASE_DAMAGE;
af.location = APPLY_AC;
af.bitvector = 0;
affect_to_char( victim, &af );
send_to_char( "You feel someone protecting you.\n\r", victim );
if ( ch != victim )
act("$N is protected by your magic.",ch,NULL,victim,TO_CHAR);
return;
}
void spell_bless( int sn, int level, CHAR_DATA *ch, void *vo, int target)
{
CHAR_DATA *victim;
AFFECT_DATA af;
if (target == TARGET_OBJ)
{
send_to_char("Uh, what are you thinking?\n\r", ch);
return;
}
/* character target */
victim = (CHAR_DATA *) vo;
if ( victim->position == POS_FIGHTING || is_affected( victim, sn ) )
{
if (victim == ch)
send_to_char("You are already blessed.\n\r",ch);
else
act("$N already has divine favor.",ch,NULL,victim,TO_CHAR);
return;
}
init_affect(&af);
af.aftype = AFT_COMMUNE;
af.where = TO_AFFECTS;
af.type = sn;
af.level = level;
af.duration = 6+level;
af.location = APPLY_HITROLL;
if ( level < 8 )
af.modifier = 1;
else
af.modifier = level / 8;
af.bitvector = 0;
affect_to_char( victim, &af );
af.location = APPLY_SAVING_SPELL;
if ( level < 8 )
af.modifier = -1;
else
af.modifier = 0 - level / 8;
affect_to_char( victim, &af );
send_to_char( "You feel righteous.\n\r", victim );
if ( ch != victim )
act("You grant $N the favor of your god.",ch,NULL,victim,TO_CHAR);
return;
}
void spell_blindness( int sn, int level, CHAR_DATA *ch, void *vo, int target)
{
CHAR_DATA *victim = (CHAR_DATA *) vo;
AFFECT_DATA af;
int dur;
if ( IS_AFFECTED(victim, AFF_BLIND)) {
act("But $E is already blind!",ch,0,victim,TO_CHAR);
return;
}
if (saves_spell(level,victim,DAM_OTHER) || (!(str_cmp(race_table[victim->race].name,"lich")))) {
act("You failed to blind $N.",ch,0,victim,TO_CHAR);
return;
}
init_affect(&af);
af.where = TO_AFFECTS;
af.aftype = get_spell_aftype(ch);
af.type = sn;
af.level = level;
af.location = APPLY_HITROLL;
af.modifier = -4;
dur = level/3;
if (dur > 9)
dur = 9;
af.duration = dur;
af.bitvector = AFF_BLIND;
affect_to_char( victim, &af );
send_to_char( "You are blinded!\n\r", victim );
act("$n appears to be blinded.",victim,NULL,NULL,TO_ROOM);
return;
}
void spell_burning_hands(int sn,int level, CHAR_DATA *ch, void *vo, int target)
{
CHAR_DATA *victim = (CHAR_DATA *) vo;
static const sh_int dam_each[] =
{
0,
0, 0, 0, 0, 14, 17, 20, 23, 26, 29,
29, 29, 30, 30, 31, 31, 32, 32, 33, 33,
34, 34, 35, 35, 36, 36, 37, 37, 38, 38,
39, 39, 40, 40, 41, 41, 42, 42, 43, 43,
44, 44, 45, 45, 46, 46, 47, 47, 48, 48
};
int dam;
level = UMIN(level, sizeof(dam_each)/sizeof(dam_each[0]) - 1);
level = UMAX(0, level);
dam = number_range( dam_each[level] / 2, dam_each[level] * 2 );
if ( saves_spell( level, victim,DAM_FIRE) )
dam /= 2;
damage_old( ch, victim, dam, sn, DAM_FIRE,TRUE);
return;
}
void spell_call_lightning( int sn, int level,CHAR_DATA *ch,void *vo,int target)
{
CHAR_DATA *vch;
CHAR_DATA *vch_next;
int dam;
if ( !IS_OUTSIDE(ch) )
{
send_to_char( "You must be out of doors.\n\r", ch );
return;
}
if ( weather_info.sky < SKY_RAINING )
{
send_to_char( "You need bad weather.\n\r", ch );
return;
}
dam = dice(level/2, 8);
send_to_char( "Lightning from above strikes your foes!\n\r", ch );
act( "$n calls lightning from above to strike $s foes!", ch, NULL, NULL, TO_ROOM );
for ( vch = char_list; vch != NULL; vch = vch_next )
{
vch_next = vch->next;
if ( vch->in_room == NULL )
continue;
if ( vch->in_room == ch->in_room )
{
if ( vch != ch && ( IS_NPC(ch) ? !IS_NPC(vch) : IS_NPC(vch) ) )
damage_old( ch, vch, saves_spell( level,vch,DAM_LIGHTNING) ? dam / 2 : dam, sn,DAM_LIGHTNING,TRUE);
continue;
}
if ( vch->in_room->area == ch->in_room->area
&& IS_OUTSIDE(vch)
&& IS_AWAKE(vch) )
send_to_char( "Lightning flashes in the sky.\n\r", vch );
}
return;
}
/* RT calm spell stops all fighting in the room */
void spell_calm( int sn, int level, CHAR_DATA *ch, void *vo,int target)
{
CHAR_DATA *vch;
int mlevel = 0;
int count = 0;
int high_level = 0;
int chance;
long vnum;
AFFECT_DATA af;
/* get sum of all mobile levels in the room */
for (vch = ch->in_room->people; vch != NULL; vch = vch->next_in_room)
{
if (vch->position == POS_FIGHTING)
{
count++;
/* if (IS_NPC(vch))*/
mlevel += vch->level;
/* else
mlevel += vch->level/2;*/
high_level = UMAX(high_level,vch->level);
}
}
/* compute chance of stopping combat */
chance = 4 * level - high_level + 2 * count;
if (IS_IMMORTAL(ch)) /* always works */
mlevel = 0;
if (number_range(0, chance) >= mlevel) /* hard to stop large fights */
{
for (vch = ch->in_room->people; vch != NULL; vch = vch->next_in_room)
{
if (IS_NPC(vch) && (IS_SET(vch->imm_flags,IMM_MAGIC) ||
IS_SET(vch->act,ACT_UNDEAD)))
continue;
if (IS_AFFECTED(vch,AFF_CALM) || IS_AFFECTED(vch,AFF_BERSERK)
|| is_affected(vch,skill_lookup("frenzy")))
continue;
if(IS_NPC(vch)) {
vnum=vch->pIndexData->vnum;
if(vnum==MOB_VNUM_RAGER||vnum==MOB_VNUM_ARCANA||
vnum==MOB_VNUM_KNIGHT||vnum==MOB_VNUM_ANCIENT||
vnum==MOB_VNUM_ENFORCER||vnum==MOB_VNUM_BOUNTY||
vnum==MOB_VNUM_OUTLAW)
continue;
}
send_to_char("A wave of calmness passes over you.\n\r",vch);
if (vch->fighting || vch->position == POS_FIGHTING)
vch->fighting=NULL;
stop_fighting(vch,FALSE);
init_affect(&af);
af.where = TO_AFFECTS;
af.aftype = get_spell_aftype(ch);
af.type = sn;
af.level = level;
af.duration = level/4;
af.location = APPLY_HITROLL;
if(IS_NPC(vch)) {
af.modifier=-5;
} else {
af.modifier=-1 * level/10;
af.duration=2;
}
af.bitvector = AFF_CALM;
affect_to_char(vch,&af);
af.location = APPLY_DAMROLL;
affect_to_char(vch,&af);
}
}
}
void spell_cancellation( int sn, int level, CHAR_DATA *ch, void *vo,int target )
{
CHAR_DATA *victim = (CHAR_DATA *) vo;
bool found = FALSE;
bool commune = FALSE;
if (class_table[ch->class].ctype==CLASS_COMMUNER) commune = TRUE;
if (victim != ch && victim->master != ch)
{
send_to_char("You can only cast cancel on followers.\n\r",ch);
return;
}
level += 2;
if ((!IS_NPC(ch) && IS_NPC(victim) &&
!(IS_AFFECTED(ch, AFF_CHARM) && ch->master == victim) ) ||
(IS_NPC(ch) && !IS_NPC(victim)) )
{
send_to_char("You failed, try dispel magic.\n\r",ch);
return;
}
if (check_dispel_cancellation(level,victim,ch,skill_lookup("armor"),commune))
found = TRUE;
if (check_dispel_cancellation(level,victim,ch,skill_lookup("bless"),commune))
found = TRUE;
if (check_dispel_cancellation(level,victim,ch,skill_lookup("blindness"),commune))
found = TRUE;
if (check_dispel_cancellation(level,victim,ch,skill_lookup("calm"),commune))
found = TRUE;
if (check_dispel_cancellation(level,victim,ch,skill_lookup("change sex"),commune))
found = TRUE;
if (check_dispel_cancellation(level,victim,ch,skill_lookup("charm person"),commune))
found = TRUE;
if (check_dispel_cancellation(level,victim,ch,skill_lookup("chill"),commune))
found = TRUE;
if (check_dispel_cancellation(level,victim,ch,skill_lookup("curse"),commune))
found = TRUE;
if (check_dispel_cancellation(level,victim,ch,skill_lookup("detect evil"),commune))
found = TRUE;
if (check_dispel_cancellation(level,victim,ch,skill_lookup("detect good"),commune))
found = TRUE;
if (check_dispel_cancellation(level,victim,ch,skill_lookup("detect invis"),commune))
found = TRUE;
if (check_dispel_cancellation(level,victim,ch,skill_lookup("detect magic"),commune))
found = TRUE;
if (check_dispel_cancellation(level,victim,ch,skill_lookup("faerie fire"),commune))
found = TRUE;
if (check_dispel_cancellation(level,victim,ch,skill_lookup("fly"),commune))
found = TRUE;
if (check_dispel_cancellation(level,victim,ch,skill_lookup("frenzy"),commune))
found = TRUE;
if (check_dispel_cancellation(level,victim,ch,skill_lookup("giant strength"),commune))
found = TRUE;
if (check_dispel_cancellation(level,victim,ch,skill_lookup("haste"),commune))
found = TRUE;
if (check_dispel_cancellation(level,victim,ch,skill_lookup("infravision"),commune))
found = TRUE;
if (check_dispel_cancellation(level,victim,ch,skill_lookup("invis"),commune))
found = TRUE;
if (check_dispel_cancellation(level,victim,ch,skill_lookup("mass invis"),commune))
found = TRUE;
if (check_dispel_cancellation(level,victim,ch,skill_lookup("pass door"),commune))
found = TRUE;
if (check_dispel_cancellation(level,victim,ch,skill_lookup("protection"),commune))
found = TRUE;
if (check_dispel_cancellation(level,victim,ch,skill_lookup("sanctuary"),commune))
found = TRUE;
if (check_dispel_cancellation(level,victim,ch,skill_lookup("shield"),commune))
found = TRUE;
if (check_dispel_cancellation(level,victim,ch,skill_lookup("sleep"),commune))
found = TRUE;
if (check_dispel_cancellation(level,victim,ch,skill_lookup("slow"),commune))
found = TRUE;
if (check_dispel_cancellation(level,victim,ch,skill_lookup("stone skin"),commune))
found = TRUE;
if (check_dispel_cancellation(level,victim,ch,skill_lookup("weaken"),commune))
found = TRUE;
if (found)
send_to_char("Ok.\n\r",ch);
else
send_to_char("Spell failed.\n\r",ch);
}
void spell_cause_light( int sn, int level, CHAR_DATA *ch, void *vo,int target )
{
damage_old( ch, (CHAR_DATA *) vo, dice(1, 8) + level / 3, sn,DAM_HARM,TRUE);
return;
}
void spell_cause_critical(int sn,int level,CHAR_DATA *ch,void *vo,int target)
{
damage_old( ch, (CHAR_DATA *) vo, dice(3, 8) + level - 6, sn,DAM_HARM,TRUE);
return;
}
void spell_cause_serious(int sn,int level,CHAR_DATA *ch,void *vo,int target)
{
damage_old( ch, (CHAR_DATA *) vo, dice(2, 8) + level / 2, sn,DAM_HARM,TRUE);
return;
}
void spell_chain_lightning(int sn,int level,CHAR_DATA *ch, void *vo,int target)
{
CHAR_DATA *victim = (CHAR_DATA *) vo;
CHAR_DATA *tmp_vict,*last_vict,*next_vict;
bool found;
int dam;
/* first strike */
if (is_affected(ch,gsn_grounding))
{
send_to_char("The electricity fizzles at your feet.\n\r",ch);
act("A lightning bolt leaps from $n's hand but fizzles into the ground.",ch,0,0,TO_ROOM);
return;
}
act("A lightning bolt leaps from $n's hand and arcs to $N.",
ch,NULL,victim,TO_ROOM);
act("A lightning bolt leaps from your hand and arcs to $N.",
ch,NULL,victim,TO_CHAR);
act("A lightning bolt leaps from $n's hand and hits you!",
ch,NULL,victim,TO_VICT);
WAIT_STATE(ch, PULSE_VIOLENCE * 2);
dam = dice(level,6);
if (saves_spell(level,victim,DAM_LIGHTNING))
dam /= 3;
damage_old(ch,victim,dam,sn,DAM_LIGHTNING,TRUE);
last_vict = victim;
level -= 4; /* decrement damage */
/* new targets */
while (level > 0)
{
found = FALSE;
for (tmp_vict = ch->in_room->people;
tmp_vict != NULL;
tmp_vict = next_vict)
{
next_vict = tmp_vict->next_in_room;
if (!is_safe_spell(ch,tmp_vict,TRUE) && tmp_vict != last_vict)
{
found = TRUE;
last_vict = tmp_vict;
if (last_vict == ch)
{
if (number_percent()>=ch->level)
{
act("The bolt arcs back to $n, and it stabilizes!",tmp_vict,NULL,NULL,TO_ROOM);
act("The bolt arcs back to you and you stabilize its energy!",tmp_vict,NULL,NULL,TO_ROOM);
level+=7;
}
else
{
act("The bolt arcs back to $n!",tmp_vict,NULL,NULL,TO_ROOM);
act("The bolt arcs back to you!",tmp_vict,NULL,NULL,TO_ROOM);
}
}
else
{
act("The bolt arcs to $n!",tmp_vict,NULL,NULL,TO_ROOM);
act("The bolt hits you!",tmp_vict,NULL,NULL,TO_CHAR);
dam = dice(level,6);
if (saves_spell(level,tmp_vict,DAM_LIGHTNING))
dam /= 3;
damage_old(ch,tmp_vict,dam,sn,DAM_LIGHTNING,TRUE);
level -= 4; /* decrement damage */
}
}
} /* end target searching loop */
if (!found) /* no target found, hit the caster */
{
if (ch == NULL)
return;
if (last_vict == ch) /* no double hits */
{
act("The bolt seems to have fizzled out.",ch,NULL,NULL,TO_ROOM);
act("The bolt grounds out harmlessly through your body.",
ch,NULL,NULL,TO_CHAR);
return;
}
last_vict = ch;
act("The bolt arcs back to $n!",ch,NULL,NULL,TO_ROOM);
send_to_char("The bolt arcs harmlessly back to you.\n\r",ch);
level -= 4; /* decrement damage */
if (ch == NULL)
return;
}
/* now go back and find more targets */
}
}
void spell_change_sex( int sn, int level, CHAR_DATA *ch, void *vo,int target )
{
CHAR_DATA *victim = (CHAR_DATA *) vo;
AFFECT_DATA af;
if ( is_affected( victim, sn ))
{
if (victim == ch)
send_to_char("You've already been changed.\n\r",ch);
else
act("$N has already had $s(?) sex changed.",ch,NULL,victim,TO_CHAR);
return;
}
if (saves_spell(level , victim,DAM_OTHER))
return;
init_affect(&af);
af.where = TO_AFFECTS;
af.aftype = AFT_SPELL;
af.type = sn;
af.level = level;
af.duration = 2 * level;
af.location = APPLY_SEX;
do
{
af.modifier = number_range( 0, 2 ) - victim->sex;
}
while ( af.modifier == 0 );
af.bitvector = 0;
af.affect_list_msg = str_dup("modifies anatomy");
affect_to_char( victim, &af );
send_to_char( "You feel different.\n\r", victim );
act("$n doesn't look like $mself anymore...",victim,NULL,NULL,TO_ROOM);
return;
}
void spell_charm_person( int sn, int level, CHAR_DATA *ch, void *vo,int target )
{
CHAR_DATA *victim = (CHAR_DATA *) vo;
AFFECT_DATA af;
CHAR_DATA *check;
int count;
count = 0;
if ((!IS_NPC(victim)) && (!IS_IMMORTAL(ch)))
{
send_to_char( "You can only charm mobiles.\n\r", ch );
return;
}
if (is_safe(ch,victim))
return;
if ( victim == ch )
{
send_to_char( "You like yourself even better!\n\r", ch );
return;
}
if (IS_NPC(victim) && (victim->pIndexData->pShop != NULL))
{
act("$N suddenly becomes very angry and destroys $n!",ch,0,victim,TO_ROOM);
act("$N suddenly becomes very angry and destroys you!",ch,0,victim,TO_CHAR);
raw_kill(victim,ch);
return;
}
if ( IS_AFFECTED(victim, AFF_CHARM)
|| IS_AFFECTED(ch, AFF_CHARM)
|| level < victim->level
|| IS_CABAL_GUARD(victim)
|| IS_SET(victim->imm_flags,IMM_CHARM)
|| (IS_NPC(victim) && victim->spec_fun != NULL)
|| (IS_NPC(victim) && IS_SET(victim->act,ACT_AGGRESSIVE))) {
act("$E completely ignores your charming spell.",ch,0,victim,TO_CHAR);
return;
}
if ( saves_spell( level-3, victim,DAM_CHARM) )
{
act("$E resists your charming magic.",ch,0,victim,TO_CHAR);
act("You resist $n's charming magic.",ch,0,victim,TO_VICT);
act("$N resists $n's charming magic.",ch,0,victim,TO_NOTVICT);
return;
}
for (check = char_list; check != NULL; check = check->next)
{
if (check->leader == ch && IS_AFFECTED(check,AFF_CHARM))
count++;
}
if (count > 0)
{
send_to_char("You already control as many charmies as you can.\n\r",ch);
return;
}
if (victim->level > ch->level)
{
send_to_char("They are too powerful for you to charm.\n\r", ch);
return;
}
if ( victim->master )
stop_follower( victim );
add_follower( victim, ch );
victim->leader = ch;
init_affect(&af);
af.where = TO_AFFECTS;
af.aftype = AFT_SPELL;
af.type = sn;
af.level = level;
af.duration = number_fuzzy( level / 4 );
af.location = 0;
af.modifier = 0;
af.bitvector = AFF_CHARM;
char msg_buf[MSL];
sprintf(msg_buf,"under %s's command", IS_NPC(ch) ? ch->short_descr : ch->name);
af.affect_list_msg = str_dup(msg_buf);
affect_to_char( victim, &af );
act( "Isn't $n just so nice?", ch, NULL, victim, TO_VICT );
if ( ch != victim )
act("$N looks at you with adoring eyes.",ch,NULL,victim,TO_CHAR);
return;
}
void spell_chill_touch( int sn, int level, CHAR_DATA *ch, void *vo,int target )
{
CHAR_DATA *victim = (CHAR_DATA *) vo;
static const sh_int dam_each[] =
{
0,
0, 0, 6, 7, 8, 9, 12, 13, 13, 13,
14, 14, 14, 15, 15, 15, 16, 16, 16, 17,
17, 17, 18, 18, 18, 19, 19, 19, 20, 20,
20, 21, 21, 21, 22, 22, 22, 23, 23, 23,
24, 24, 24, 25, 25, 25, 26, 26, 26, 27
};
AFFECT_DATA af;
int dam;
level = UMIN(level, sizeof(dam_each)/sizeof(dam_each[0]) - 1);
level = UMAX(0, level);
dam = number_range( dam_each[level] / 2, dam_each[level] * 2 );
dam *= 2;
if (check_spellcraft(ch,sn))
dam *= 2;
if ( !saves_spell( level, victim,DAM_COLD ) )
{
act("$n turns blue and shivers.",victim,NULL,NULL,TO_ROOM);
init_affect(&af);
af.where = TO_AFFECTS;
af.aftype = AFT_SPELL;
af.type = sn;
af.level = level;
af.duration = 6;
af.location = APPLY_STR;
af.modifier = -1;
af.bitvector = 0;
affect_join( victim, &af );
}
else
{
dam /= 2;
}
damage_old( ch, victim, dam, sn, DAM_COLD,TRUE );
return;
}
void spell_colour_spray( int sn, int level, CHAR_DATA *ch, void *vo,int target )
{
CHAR_DATA *victim = (CHAR_DATA *) vo;
static const sh_int dam_each[] =
{
0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
30, 35, 40, 45, 50, 55, 55, 55, 56, 57,
58, 58, 59, 60, 61, 61, 62, 63, 64, 64,
65, 66, 67, 67, 68, 69, 70, 70, 71, 72,
73, 73, 74, 75, 76, 76, 77, 78, 79, 79
};
int dam;
level = UMIN(level, sizeof(dam_each)/sizeof(dam_each[0]) - 1);
level = UMAX(0, level);
dam = number_range( dam_each[level] / 2, dam_each[level] * 2 );
if ( saves_spell( level, victim,DAM_LIGHT) )
dam /= 2;
else
spell_blindness(skill_lookup("blindness"),
level/2,ch,(void *) victim,TARGET_CHAR);
damage_old( ch, victim, dam, sn, DAM_LIGHT,TRUE );
return;
}
void spell_concatenate(int sn,int level,CHAR_DATA *ch,void *vo, int target)
{
CHAR_DATA *victim = (CHAR_DATA *) vo;
int dam;
act("$n points an arm at $N and releases a blast of pure energy.",ch,NULL,victim,TO_NOTVICT);
act("$n gestures at you and a blast of white light engulfs you!",ch,NULL,victim,TO_VICT);
act("You concatenate the magical energies around you and channel them at $N.",ch,NULL,victim,TO_CHAR);
if (level <= 35)
{
if (check_spellcraft(ch,sn))
dam = spellcraft_dam(level,11);
else
dam = dice(level,11);
}
else if (level <= 40)
{
if (check_spellcraft(ch,sn))
dam = spellcraft_dam(level,12);
else
dam = dice(level,12);
}
else if (level <= 48)
{
if (check_spellcraft(ch,sn))
dam = spellcraft_dam(level,13);
else
dam = dice(level,13);
}
else
{
if (check_spellcraft(ch,sn))
dam = spellcraft_dam(level, 13);
else
dam = dice(level,13);
dam += number_range(0,level);
}
if (IS_NPC(victim))
{
if (level <= 35)
dam += level;
else if (level <=40)
dam += (3*level);
else
dam += 4*level;
}
if (saves_spell(level,victim, DAM_ENERGY) );
dam /= 2;
damage_old( ch, victim, dam, sn, DAM_ENERGY, TRUE);
if (number_bits(2) == 0)
spell_blindness(skill_lookup("blindness"), level*3/4, ch, (void *) victim, TARGET_CHAR);
send_to_char("You stop channeling the energy and the beam of light dissipates.\n\r", ch);
act("$n's beam of light dissipates.",ch,NULL,NULL,TO_ROOM);
return;
}
/* Very messy group gate spell. I wanted players to 'feel' that their
entire group had transfered with them rather than just dumping them all in
the room and doing a look (then they'd just see whoever was transfered
before them but not following members).
-Ceran
*/
void spell_venueport(int sn, int level,CHAR_DATA *ch,void *vo, int target)
{
CHAR_DATA *victim;
CHAR_DATA *group;
CHAR_DATA *arrival;
CHAR_DATA *g_next;
ROOM_INDEX_DATA *VENUEPORT;
CHAR_DATA *last_to_venue;
int numb;
if (affect_find(ch->affected,gsn_insect_swarm) != NULL)
{
send_to_char( "You attempt to transport yourself to safety but loose your concentration as you are bitten by yet another insect.\n\r", ch);
return;
}
if (cabal_down(ch,CABAL_ARCANA))
return;
last_to_venue = ch;
victim = get_char_world( ch, target_name );
/* send_to_char("You utter the words, 'tesseract'.\n\r",ch);
act("$n utters the words, 'tesseract'.",ch,NULL,NULL,TO_ROOM); */
if ( victim == NULL
|| victim == ch
|| victim->in_room == NULL
|| IS_SET(ch->in_room->room_flags, ROOM_NO_RECALL)
|| !can_see_room(ch,victim->in_room)
|| (victim->in_room->cabal != 0 && victim->in_room->cabal != CABAL_ARCANA)
|| ch->in_room->guild != 0
|| victim->in_room->guild != 0
|| (IS_NPC(victim) && IS_SET(victim->imm_flags,IMM_SUMMON))
|| IS_SET(victim->in_room->room_flags, ROOM_SAFE)
|| IS_SET(victim->in_room->room_flags, ROOM_PRIVATE)
|| IS_SET(victim->in_room->room_flags, ROOM_SOLITARY)
|| IS_SET(victim->in_room->room_flags, ROOM_NO_RECALL)
|| victim->level >= level + 9
|| (saves_spell( level, victim,DAM_OTHER) )
|| (!IS_NPC(victim) && !can_pk(ch,victim) && IS_SET(victim->act,PLR_NOSUMMON)))
{
send_to_char( "You failed.\n\r", ch );
return;
}
if (victim->in_room == ch->in_room)
{
send_to_char("You are already at that venue.\n\r",ch);
return;
}
VENUEPORT = get_room_index(ROOM_VNUM_VENUEPORT);
numb = 1;
for (group = ch->in_room->people; group != NULL; group = g_next)
{
g_next = group->next_in_room;
if (!is_same_group(group,ch) || (group->fighting != NULL) )
continue;
if (group == ch )
continue;
numb++;
affect_strip(group,gsn_ambush);
send_to_char("You feel space and time rupture around you as everything shifts.\n\r",group);
send_to_char("With a blinding flash of light you find yourself somewhere else!\n\r",group);
send_to_char("\n\r",group);
char_from_room(group);
char_to_room(group,victim->in_room);
act("$n arrives suddenly!",group,NULL,NULL,TO_ROOM);
char_from_room(group);
char_to_room(group, VENUEPORT);
last_to_venue = group;
if (is_affected(group,gsn_earthfade))
{
affect_strip(group, gsn_earthfade);
}
}
act("With a brilliant flash of light $n and $s friends disappear!",ch,NULL,NULL,TO_ROOM);
send_to_char("You feel space and time rupture around you as everything shifts.\n\r",ch);
send_to_char("With a blinding flash of light you find yourself somewhere else!\n\r",ch);
send_to_char("\n\r",ch);
char_from_room(ch);
char_to_room(ch,victim->in_room);
act("$n arrives suddenly!",ch,NULL,NULL,TO_ROOM);
un_earthfade(ch,NULL);
if (last_to_venue == ch)
{
do_look(ch,"auto");
return;
}
for (arrival = last_to_venue->in_room->people; arrival != NULL; arrival = g_next)
{
g_next = arrival->next_in_room;
if (arrival == ch)
continue;
if ((is_same_group(arrival,ch)) && (arrival != ch) )
{
char_from_room(arrival);
char_to_room(arrival,ch->in_room);
}
}
for (arrival = ch->in_room->people; arrival != NULL; arrival = arrival->next_in_room)
{
do_look(arrival,"auto");
if (--numb == 0)
break;
}
return;
}
void spell_electric_storm(int sn, int level, CHAR_DATA *ch, void *vo, int
target)
{
AFFECT_DATA af;
ROOM_AFFECT_DATA raf;
if ( is_affected( ch, sn ) )
{
send_to_char
("Your unable to call upon the storm again so soon.\n\r", ch);
return;
}
if ( is_affected_room( ch->in_room, sn ))
{
send_to_char("The storm already obeys your will here.\n\r",ch);
return;
}
if (number_range(1,100) > ch->pcdata->learned[sn])
{
send_to_char("You call to the storm but it does not heed your summons.\n\r",ch);
WAIT_STATE(ch, PULSE_TICK / 2);
}
init_affect(&af);
af.where = TO_AFFECTS;
af.aftype = AFT_SPELL;
af.type = sn;
af.level = ch->level;
af.duration = 48;
af.modifier = 0;
af.location = APPLY_NONE;
af.affect_list_msg = str_dup("unable to summon an electrical storm");
af.bitvector = 0;
affect_to_char( ch, &af );
init_affect_room(&raf);
raf.where = TO_ROOM_AFFECTS;
raf.aftype = AFT_SPELL;
raf.type = sn;
raf.level = ch->level;
raf.duration = level / 10;
raf.location = APPLY_NONE;
raf.modifier = 0;
raf.bitvector = AFF_ROOM_ELECTRIC_STORM;
affect_to_room( ch->in_room, &raf );
send_to_char("The storm heads your summons as a massive electric storm begins to brew overhead!\n\r", ch);
act("$n raises their arms to the sky and a massive storm cloud begins to form overhead.",ch,NULL,NULL,TO_ROOM);
WAIT_STATE(ch, PULSE_TICK);
}
void spell_wrath(int sn,int level,CHAR_DATA *ch,void *vo, int target)
{
CHAR_DATA *victim = (CHAR_DATA *) vo;
int dam;
if (!IS_EVIL(victim))
{
act("$N is unaffected by $n's heavenly wrath.",ch,NULL,victim,TO_NOTVICT);
act("You are unaffected by $n's heavenly wrath.\n\r",ch,NULL,victim,TO_VICT);
send_to_char("The Gods do not enhance your wrath and frown on your actions\n\r",ch);
return;
}
dam = dice(level, 8);
dam += dice(level,5);
if (saves_spell(level,victim,DAM_HOLY) || saves_spell(level + 5, victim,DAM_HOLY))
dam /= 2;
act("You call down the wrath of god upon $N.",ch,0,victim,TO_CHAR);
act("$n calls down the wrath of god upon $N.",ch,0,victim,TO_NOTVICT);
act("$n calls down the wrath of god upon you.",ch,0,victim,TO_VICT);
damage_old(ch,victim,dam,sn,DAM_HOLY,TRUE);
if (number_range(0,3) != 0)
return;
spell_curse(gsn_curse,level,ch,(void *) victim, TARGET_CHAR);
return;
}
void spell_continual_light(int sn,int level,CHAR_DATA *ch,void *vo,int target)
{
OBJ_DATA *light;
if (target_name[0] != '\0') /* do a glow on some object */
{
light = get_obj_carry(ch,target_name,ch);
if (light == NULL)
{
send_to_char("You don't see that here.\n\r",ch);
return;
}
if (IS_OBJ_STAT(light,ITEM_GLOW))
{
act("$p is already glowing.",ch,light,NULL,TO_CHAR);
return;
}
set_bit(&light->extra_flags,ITEM_GLOW);
act("$p glows with a white light.",ch,light,NULL,TO_ALL);
return;
}
light = create_object( get_obj_index( OBJ_VNUM_LIGHT_BALL ), 0 );
obj_to_room( light, ch->in_room );
act( "$n twiddles $s thumbs and $p appears.", ch, light, NULL, TO_ROOM );
act( "You twiddle your thumbs and $p appears.", ch, light, NULL, TO_CHAR );
return;
}
void spell_control_weather(int sn,int level,CHAR_DATA *ch,void *vo,int target)
{
if ( !str_cmp( target_name, "better" ) )
weather_info.change += dice( level / 3, 4 );
else if ( !str_cmp( target_name, "worse" ) )
weather_info.change -= dice( level / 3, 4 );
else
send_to_char ("Do you want it to get better or worse?\n\r", ch );
send_to_char( "Ok.\n\r", ch );
return;
}
void spell_create_food( int sn, int level, CHAR_DATA *ch, void *vo,int target)
{
OBJ_DATA *mushroom;
mushroom = create_object( get_obj_index( OBJ_VNUM_MUSHROOM ), 0 );
mushroom->value[0] = level / 2;
mushroom->value[1] = level;
obj_to_room( mushroom, ch->in_room );
act( "$p suddenly appears.", ch, mushroom, NULL, TO_ROOM );
act( "$p suddenly appears.", ch, mushroom, NULL, TO_CHAR );
return;
}
void spell_create_rose( int sn, int level, CHAR_DATA *ch, void *vo,int target )
{
OBJ_DATA *rose;
rose = create_object(get_obj_index(OBJ_VNUM_ROSE), 0);
act("$n has created a beautiful red rose.",ch,rose,NULL,TO_ROOM);
send_to_char("You create a beautiful red rose.\n\r",ch);
obj_to_char(rose,ch);
return;
}
void spell_create_spring(int sn,int level,CHAR_DATA *ch,void *vo,int target)
{
OBJ_DATA *spring;
spring = create_object( get_obj_index( OBJ_VNUM_SPRING ), 0 );
spring->timer = level;
obj_to_room( spring, ch->in_room );
act( "$p flows from the ground.", ch, spring, NULL, TO_ROOM );
act( "$p flows from the ground.", ch, spring, NULL, TO_CHAR );
return;
}
void spell_create_water( int sn, int level, CHAR_DATA *ch, void *vo,int target)
{
OBJ_DATA *obj = (OBJ_DATA *) vo;
int water;
if ( obj->item_type != ITEM_DRINK_CON )
{
send_to_char( "It is unable to hold water.\n\r", ch );
return;
}
if ( obj->value[2] != LIQ_WATER && obj->value[1] != 0 )
{
send_to_char( "It contains some other liquid.\n\r", ch );
return;
}
water = UMIN(
level * (weather_info.sky >= SKY_RAINING ? 4 : 2),
obj->value[0] - obj->value[1]
);
if ( water > 0 )
{
obj->value[2] = LIQ_WATER;
obj->value[1] += water;
if ( !is_name( "water", obj->name ) )
{
char buf[MAX_STRING_LENGTH];
sprintf( buf, "%s water", obj->name );
free_string( obj->name );
obj->name = str_dup( buf );
}
act( "$p is filled.", ch, obj, NULL, TO_CHAR );
}
return;
}
void spell_cure_blindness(int sn,int level,CHAR_DATA *ch,void *vo,int target)
{
CHAR_DATA *victim = (CHAR_DATA *) vo;
if ( !is_affected( victim, gsn_blindness ))
{
if (victim == ch)
send_to_char("You aren't blind.\n\r",ch);
else
act("$N doesn't appear to be blinded.",ch,NULL,victim,TO_CHAR);
return;
}
if (check_dispel(level,victim,gsn_blindness))
{
send_to_char( "Your vision returns!\n\r", victim );
act("$n is no longer blinded.",victim,NULL,NULL,TO_ROOM);
}
else
send_to_char("Spell failed.\n\r",ch);
}
void spell_cure_critical( int sn, int level, CHAR_DATA *ch, void *vo,int target)
{
CHAR_DATA *victim = (CHAR_DATA *) vo;
int heal;
heal = dice(3, 8) + level - 6;
victim->hit = UMIN( victim->hit + heal, victim->max_hit );
update_pos( victim );
send_to_char( "You feel better!\n\r", victim );
if ( ch != victim )
send_to_char( "Ok.\n\r", ch );
return;
}
/* RT added to cure plague */
void spell_cure_disease( int sn, int level, CHAR_DATA *ch,void *vo,int target)
{
CHAR_DATA *victim = (CHAR_DATA *) vo;
if (!str_cmp(class_table[ch->class].name, "monk")
&& victim != ch)
{
send_to_char("You are only able to purge your own diseases.\n\r",ch);
return;
}
if ( !is_affected( victim, gsn_plague ) )
{
if (victim == ch)
send_to_char("You aren't ill.\n\r",ch);
else
act("$N doesn't appear to be diseased.",ch,NULL,victim,TO_CHAR);
return;
}
if (check_dispel(level,victim,gsn_plague))
{
send_to_char("Your sores vanish.\n\r",victim);
act("$n looks relieved as $s sores vanish.",victim,NULL,NULL,TO_ROOM);
}
else
send_to_char("Spell failed.\n\r",ch);
}
void spell_cure_light( int sn, int level, CHAR_DATA *ch, void *vo,int target)
{
CHAR_DATA *victim = (CHAR_DATA *) vo;
int heal;
heal = dice(1, 8) + level / 3;
victim->hit = UMIN( victim->hit + heal, victim->max_hit );
update_pos( victim );
send_to_char( "You feel better!\n\r", victim );
if ( ch != victim )
send_to_char( "Ok.\n\r", ch );
return;
}
void spell_cure_poison( int sn, int level, CHAR_DATA *ch, void *vo,int target )
{
CHAR_DATA *victim = (CHAR_DATA *) vo;
if (!str_cmp(class_table[ch->class].name, "monk")
&& victim != ch)
{
send_to_char("You are only able to purge toxins from your own body.\n\r",ch);
return;
}
if ( !is_affected( victim, gsn_poison )
&& !is_affected(victim, gsn_poison_dust))
{
if (victim == ch)
send_to_char("You aren't poisoned.\n\r",ch);
else
act("$N doesn't appear to be poisoned.",ch,NULL,victim,TO_CHAR);
return;
}
if (is_affected(victim,gsn_poison_dust))
{
if (check_dispel(level,victim,gsn_poison_dust))
send_to_char("A warm feelings runs through you as the poison dust vanishes.\n\r",victim);
act("$n looks much better.",victim,0,0,TO_ROOM);
if (!is_affected(victim,gsn_poison))
return;
}
if (check_dispel(level,victim,gsn_poison))
{
send_to_char("A warm feeling runs through your body.\n\r",victim);
act("$n looks much better.",victim,NULL,NULL,TO_ROOM);
}
else
send_to_char("Spell failed.\n\r",ch);
}
void spell_cure_serious( int sn, int level, CHAR_DATA *ch, void *vo,int target )
{
CHAR_DATA *victim = (CHAR_DATA *) vo;
int heal;
heal = dice(2, 8) + level /2 ;
victim->hit = UMIN( victim->hit + heal, victim->max_hit );
update_pos( victim );
send_to_char( "You feel better!\n\r", victim );
if ( ch != victim )
send_to_char( "Ok.\n\r", ch );
return;
}
void spell_curse( int sn, int level, CHAR_DATA *ch, void *vo,int target )
{
CHAR_DATA *victim;
OBJ_DATA *obj;
AFFECT_DATA af;
/* deal with the object case first */
if (target == TARGET_OBJ)
{
obj = (OBJ_DATA *) vo;
if (obj==NULL) return;
if (IS_OBJ_STAT(obj,ITEM_EVIL))
{
act("$p is already filled with evil.",ch,obj,NULL,TO_CHAR);
return;
}
if (IS_OBJ_STAT(obj,ITEM_BLESS))
{
AFFECT_DATA *paf;
paf = affect_find(obj->affected,skill_lookup("bless"));
if (!saves_dispel(level,paf != NULL ? paf->level : obj->level,0))
{
if (paf != NULL)
affect_remove_obj(obj,paf);
act("$p glows with a red aura.",ch,obj,NULL,TO_ALL);
remove_bit(&obj->extra_flags,ITEM_BLESS);
return;
}
else
{
act("The holy aura of $p is too powerful for you to overcome.",
ch,obj,NULL,TO_CHAR);
return;
}
}
init_affect(&af);
af.where = TO_OBJECT;
af.aftype = get_spell_aftype(ch);
af.type = sn;
af.level = level;
af.duration = 2 * level;
af.location = APPLY_SAVES;
af.modifier = +5;
af.bitvector = ITEM_EVIL;
affect_to_obj(obj,&af);
act("$p glows with a malevolent aura.",ch,obj,NULL,TO_ALL);
if (obj->wear_loc != WEAR_NONE)
ch->saving_throw += 1;
return;
}
/* character curses */
victim = (CHAR_DATA *) vo;
if ((obj = get_eq_char(victim,WEAR_BODY)) != NULL
&& obj->pIndexData->vnum == 14005)
level -= 20;
if (IS_AFFECTED(victim,AFF_CURSE))
{
send_to_char("You are already cursed.\n\r", victim );
if( ch != victim )
act("$N is already cursed.",ch,NULL,victim,TO_CHAR );
return;
}
if (saves_spell(level,victim,DAM_NEGATIVE))
{
if( ch == victim )
act("You resist your curse.",ch,NULL,0,TO_CHAR );
if( ch != victim )
{
act("$N resists your curse.",ch,NULL,victim,TO_CHAR );
act("You resist $n's curse.",ch,NULL,victim,TO_VICT );
act("$N resists $n's curse.",ch,NULL,victim,TO_ROOM );
}
return;
}
init_affect(&af);
af.where = TO_AFFECTS;
af.aftype = get_spell_aftype(ch);
af.type = sn;
af.level = level;
af.duration = ( 2 + level/5);
af.location = APPLY_HITROLL;
af.modifier = -1 * (level / 8);
af.bitvector = AFF_CURSE;
affect_to_char( victim, &af );
af.location = APPLY_SAVING_SPELL;
af.modifier = level / 8;
affect_to_char( victim, &af );
af.affect_list_msg = str_dup("unable to recall");
af.location = APPLY_NONE;
af.modifier = 0;
affect_to_char( victim, &af );
send_to_char( "You feel unclean.\n\r", victim );
if ( ch != victim )
act("$N looks very uncomfortable.",ch,NULL,victim,TO_CHAR);
return;
}
void spell_dark_wrath(int sn, int level, CHAR_DATA *ch, void *vo, int target)
{
CHAR_DATA *victim = (CHAR_DATA *) vo;
int dam;
if (!IS_GOOD(victim) )
{
act("$N is unaffected by $n's dark wrath.", ch, NULL,victim,TO_NOTVICT);
act("$N is unaffected by your dark wrath.",ch,NULL,victim,TO_CHAR);
act("You are unaffected by $n's dark wrath.",ch,NULL,victim,TO_VICT);
return;
}
dam = dice(level,9);
if (saves_spell(level,victim,DAM_NEGATIVE) )
dam /= 2;
damage_old(ch,victim,dam,sn, DAM_NEGATIVE, TRUE);
if (number_range(0,3) != 0)
return;
spell_curse(gsn_curse, level, ch, (void *) victim, TARGET_CHAR);
return;
}
/* RT replacement demonfire spell */
void spell_demonfire(int sn, int level, CHAR_DATA *ch, void *vo,int target)
{
CHAR_DATA *victim = (CHAR_DATA *) vo;
int dam;
/* Retarded alignment based stuff removed in favor of plain damage spell */
dam = dice(level, 7);
if (victim != ch)
{
act("$n calls forth the demons of Hell upon $N!",
ch,NULL,victim,TO_ROOM);
act("$n has assailed you with the demons of Hell!",
ch,NULL,victim,TO_VICT);
send_to_char("You conjure forth the demons of hell!\n\r",ch);
}
if ( saves_spell( level, victim,DAM_NEGATIVE) )
dam /= 2;
damage_old( ch, victim, dam, sn, DAM_NEGATIVE ,TRUE);
spell_curse(gsn_curse, 3 * level / 4, ch, (void *) victim,TARGET_CHAR);
}
void spell_detect_evil( int sn, int level, CHAR_DATA *ch, void *vo,int target )
{
CHAR_DATA *victim = (CHAR_DATA *) vo;
AFFECT_DATA af;
if ( IS_AFFECTED(victim, AFF_DETECT_EVIL) )
{
if (victim == ch)
send_to_char("You can already sense evil.\n\r",ch);
else
act("$N can already detect evil.",ch,NULL,victim,TO_CHAR);
return;
}
init_affect(&af);
af.aftype = AFT_COMMUNE;
af.where = TO_AFFECTS;
af.type = sn;
af.level = level;
af.duration = level;
af.modifier = 0;
af.location = APPLY_NONE;
af.bitvector = AFF_DETECT_EVIL;
af.affect_list_msg = str_dup("allows you to distinguish evil hearts");
affect_to_char( victim, &af );
send_to_char( "Your eyes tingle.\n\r", victim );
if ( ch != victim )
send_to_char( "Ok.\n\r", ch );
return;
}
void spell_detect_good( int sn, int level, CHAR_DATA *ch, void *vo,int target )
{
CHAR_DATA *victim = (CHAR_DATA *) vo;
AFFECT_DATA af;
if ( IS_AFFECTED(victim, AFF_DETECT_GOOD) )
{
if (victim == ch)
send_to_char("You can already sense good.\n\r",ch);
else
act("$N can already detect good.",ch,NULL,victim,TO_CHAR);
return;
}
init_affect(&af);
af.where = TO_AFFECTS;
af.aftype = get_spell_aftype(ch);
af.type = sn;
af.level = level;
af.duration = level;
af.modifier = 0;
af.location = APPLY_NONE;
af.bitvector = AFF_DETECT_GOOD;
af.affect_list_msg = str_dup("allows you to distinguish light-hearts");
affect_to_char( victim, &af );
send_to_char( "Your eyes tingle.\n\r", victim );
if ( ch != victim )
send_to_char( "Ok.\n\r", ch );
return;
}
void do_detect_hidden(CHAR_DATA *ch, char *argument)
{
AFFECT_DATA af;
int number;
if ( IS_AFFECTED(ch, AFF_DETECT_HIDDEN) )
{
send_to_char("You are already as alert as you can be. \n\r",ch);
return;
}
if ( (number = get_skill(ch,gsn_detect_hidden)) == 0 ||
ch->level < skill_table[gsn_detect_hidden].skill_level[ch->class] )
{
send_to_char("Huh?\n\r", ch);
return;
}
if ( (number = number_percent()) > get_skill(ch, gsn_detect_hidden) )
{
send_to_char("You peer into the shadows but your vision stays the same.\n\r", ch);
check_improve(ch,gsn_detect_hidden,FALSE, 2);
return;
}
init_affect(&af);
af.where = TO_AFFECTS;
af.aftype = AFT_SPELL;
af.type = gsn_detect_hidden;
af.level = ch->level;
af.duration = ch->level;
af.location = APPLY_NONE;
af.modifier = 0;
af.bitvector = AFF_DETECT_HIDDEN;
af.affect_list_msg = str_dup("grants the ability to detect the hidden");
affect_to_char( ch, &af );
send_to_char( "Your awareness improves.\n\r", ch );
check_improve( ch, gsn_detect_hidden, TRUE, 2 );
return;
}
void spell_detect_invis( int sn, int level, CHAR_DATA *ch, void *vo,int target)
{
CHAR_DATA *victim = (CHAR_DATA *) vo;
AFFECT_DATA af;
if ( IS_AFFECTED(victim, AFF_DETECT_INVIS) )
{
if (victim == ch)
send_to_char("You can already see invisible.\n\r",ch);
else
act("$N can already see invisible things.",ch,NULL,victim,TO_CHAR);
return;
}
init_affect(&af);
af.where = TO_AFFECTS;
af.aftype = get_spell_aftype(ch);
af.type = sn;
af.level = level;
af.duration = level;
af.modifier = 0;
af.location = APPLY_NONE;
af.bitvector = AFF_DETECT_INVIS;
af.affect_list_msg = str_dup("grants the ability to detect the invisible");
affect_to_char( victim, &af );
send_to_char( "Your eyes tingle.\n\r", victim );
if ( ch != victim )
send_to_char( "Ok.\n\r", ch );
return;
}
void spell_detect_magic( int sn, int level, CHAR_DATA *ch, void *vo,int target )
{
CHAR_DATA *victim = (CHAR_DATA *) vo;
AFFECT_DATA af;
if ( IS_AFFECTED(victim, AFF_DETECT_MAGIC) )
{
if (victim == ch)
send_to_char("You can already sense magical auras.\n\r",ch);
else
act("$N can already detect magic.",ch,NULL,victim,TO_CHAR);
return;
}
init_affect(&af);
af.where = TO_AFFECTS;
af.aftype = get_spell_aftype(ch);
af.type = sn;
af.level = level;
af.duration = level;
af.modifier = 0;
af.location = APPLY_NONE;
af.bitvector = AFF_DETECT_MAGIC;
af.affect_list_msg = str_dup("grants the ability to detect magical auras");
affect_to_char( victim, &af );
send_to_char( "Your eyes tingle.\n\r", victim );
if ( ch != victim )
send_to_char( "Ok.\n\r", ch );
return;
}
void spell_detect_poison( int sn, int level, CHAR_DATA *ch, void *vo,int target)
{
OBJ_DATA *obj = (OBJ_DATA *) vo;
if ( obj->item_type == ITEM_DRINK_CON || obj->item_type == ITEM_FOOD )
{
if ( obj->value[3] != 0 )
send_to_char( "You smell poisonous fumes.\n\r", ch );
else
send_to_char( "It looks delicious.\n\r", ch );
}
else
{
send_to_char( "It doesn't look poisoned.\n\r", ch );
}
return;
}
void spell_dispel_evil( int sn, int level, CHAR_DATA *ch, void *vo,int target)
{
CHAR_DATA *victim = (CHAR_DATA *) vo;
int dam;
if ( !IS_NPC(ch) && IS_EVIL(ch) )
victim = ch;
if ( IS_GOOD(victim) )
{
act( "$N is protected.", ch, NULL, victim, TO_ROOM );
return;
}
if ( IS_NEUTRAL(victim) )
{
act( "$N does not seem to be affected.", ch, NULL, victim, TO_CHAR );
return;
}
if (victim->hit > (ch->level * 4))
dam = dice( level, 4 );
else
dam = UMAX(victim->hit, dice(level,4));
if ( saves_spell( level, victim,DAM_HOLY) )
dam /= 2;
damage_old( ch, victim, dam, sn, DAM_HOLY ,TRUE);
return;
}
void spell_dispel_good( int sn, int level, CHAR_DATA *ch, void *vo,int target )
{
CHAR_DATA *victim = (CHAR_DATA *) vo;
int dam;
if ( !IS_NPC(ch) && IS_GOOD(ch) )
victim = ch;
if ( IS_EVIL(victim) )
{
act( "$N is protected by $S evil.", ch, NULL, victim, TO_ROOM );
return;
}
if ( IS_NEUTRAL(victim) )
{
act( "$N does not seem to be affected.", ch, NULL, victim, TO_CHAR );
return;
}
if (victim->hit > (ch->level * 4))
dam = dice( level, 4 );
else
dam = UMAX(victim->hit, dice(level,4));
if ( saves_spell( level, victim,DAM_NEGATIVE) )
dam /= 2;
damage_old( ch, victim, dam, sn, DAM_NEGATIVE ,TRUE);
return;
}
void spell_earthquake( int sn, int level, CHAR_DATA *ch, void *vo,int target )
{
CHAR_DATA *vch;
CHAR_DATA *vch_next;
char buf[MAX_STRING_LENGTH];
send_to_char( "The earth trembles beneath your feet!\n\r", ch );
act( "$n makes the earth tremble and shiver.", ch, NULL, NULL, TO_ROOM );
for ( vch = char_list; vch != NULL; vch = vch_next )
{
vch_next = vch->next;
if ( vch->in_room == NULL )
continue;
if ( vch->in_room == ch->in_room )
{
if ( vch != ch && !is_safe_spell(ch,vch,TRUE))
{
if (!IS_NPC(ch) && !IS_NPC(vch)
&& (ch->fighting == NULL || vch->fighting == NULL))
{
switch(number_range(0,2))
{
case (0):
case (1):
sprintf(buf,"Die, %s you sorcerous dog!",PERS(ch,vch));
break;
case (2):
sprintf(buf,"Help! %s is casting a spell on me!",PERS(ch,vch));
}
if (vch != ch)
do_myell(vch,buf);
}
if (IS_AFFECTED(vch,AFF_FLYING))
damage_old(ch,vch,0,sn,DAM_EARTH,TRUE);
else
damage_old( ch,vch,level + dice(2, 8), sn, DAM_EARTH,TRUE);
}
continue;
}
if ( vch->in_room->area == ch->in_room->area )
send_to_char( "The earth trembles and shivers.\n\r", vch );
}
return;
}
void spell_enchant_armor( int sn, int level, CHAR_DATA *ch, void *vo,int target)
{
OBJ_DATA *obj = (OBJ_DATA *) vo;
AFFECT_DATA *paf;
int result, fail;
int ac_bonus, added;
bool ac_found = FALSE;
if (obj->item_type != ITEM_ARMOR)
{
send_to_char("That isn't an armor.\n\r",ch);
return;
}
if (obj->wear_loc != -1)
{
send_to_char("The item must be carried to be enchanted.\n\r",ch);
return;
}
/* this means they have no bonus */
ac_bonus = 0;
fail = 25; /* base 25% chance of failure */
/* find the bonuses */
if (!obj->enchanted)
for ( paf = obj->pIndexData->affected; paf != NULL; paf = paf->next )
{
if ( paf->location == APPLY_AC )
{
ac_bonus = paf->modifier;
ac_found = TRUE;
fail += 5 * (ac_bonus * ac_bonus);
}
else /* things get a little harder */
fail += 20;
}
for ( paf = obj->affected; paf != NULL; paf = paf->next )
{
if ( paf->location == APPLY_AC )
{
ac_bonus = paf->modifier;
ac_found = TRUE;
fail += 5 * (ac_bonus * ac_bonus);
}
else /* things get a little harder */
fail += 20;
}
/* apply other modifiers */
fail -= level;
if (IS_OBJ_STAT(obj,ITEM_BLESS))
fail -= 15;
if (IS_OBJ_STAT(obj,ITEM_GLOW))
fail -= 5;
fail = URANGE(5,fail,85);
result = number_percent();
/* the moment of truth */
if (result < (fail / 5)) /* item destroyed */
{
act("$p flares blindingly... and evaporates!",ch,obj,NULL,TO_CHAR);
act("$p flares blindingly... and evaporates!",ch,obj,NULL,TO_ROOM);
extract_obj(obj);
return;
}
if (result < (fail / 3)) /* item disenchanted */
{
AFFECT_DATA *paf_next;
act("$p glows brightly, then fades...oops.",ch,obj,NULL,TO_CHAR);
act("$p glows brightly, then fades.",ch,obj,NULL,TO_ROOM);
obj->enchanted = TRUE;
/* remove all affects */
for (paf = obj->affected; paf != NULL; paf = paf_next)
{
paf_next = paf->next;
free_affect(paf);
}
obj->affected = NULL;
remove_bit(&obj->extra_flags, ITEM_GLOW);
remove_bit(&obj->extra_flags, ITEM_HUM);
remove_bit(&obj->extra_flags, ITEM_MAGIC);
remove_bit(&obj->extra_flags, ITEM_INVIS);
remove_bit(&obj->extra_flags, ITEM_NODROP);
remove_bit(&obj->extra_flags, ITEM_NOREMOVE);
return;
}
if ( result <= fail ) /* failed, no bad result */
{
send_to_char("Nothing seemed to happen.\n\r",ch);
return;
}
/* okay, move all the old flags into new vectors if we have to */
if (!obj->enchanted)
{
AFFECT_DATA *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;
}
}
if (result <= (90 - level/5)) /* success! */
{
act("$p shimmers with a gold aura.",ch,obj,NULL,TO_CHAR);
act("$p shimmers with a gold aura.",ch,obj,NULL,TO_ROOM);
set_bit(&obj->extra_flags, ITEM_MAGIC);
added = -1;
}
else /* exceptional enchant */
{
act("$p glows a brillant gold!",ch,obj,NULL,TO_CHAR);
act("$p glows a brillant gold!",ch,obj,NULL,TO_ROOM);
set_bit(&obj->extra_flags,ITEM_MAGIC);
added = AC_PER_ONE_PERCENT_DECREASE_DAMAGE/3;
}
if ( (result = number_percent()) <= 25 && !is_set(&obj->extra_flags,ITEM_HUM) )
{
set_bit(&obj->extra_flags,ITEM_HUM);
remove_bit(&obj->extra_flags,ITEM_GLOW);
}
if ( (result = number_percent()) <= 25 && !is_set(&obj->extra_flags,ITEM_GLOW) )
set_bit(&obj->extra_flags,ITEM_GLOW);
/* now add the enchantments */
if (obj->level < LEVEL_HERO)
obj->level = UMIN(LEVEL_HERO - 1,obj->level + 1);
if (ac_found)
{
for ( paf = obj->affected; paf != NULL; paf = paf->next)
{
if ( paf->location == APPLY_AC)
{
paf->type = sn;
paf->modifier += added;
paf->level = UMAX(paf->level,level);
}
}
}
else /* add a new affect */
{
paf = new_affect();
paf->where = TO_OBJECT;
paf->type = sn;
paf->level = level;
paf->duration = -1;
paf->location = APPLY_AC;
paf->modifier = added;
paf->bitvector = 0;
paf->next = obj->affected;
obj->affected = paf;
}
}
void spell_enchant_weapon(int sn,int level,CHAR_DATA *ch, void *vo,int target)
{
OBJ_DATA *obj = (OBJ_DATA *) vo;
AFFECT_DATA *paf;
int result, fail;
int hit_bonus, dam_bonus, added;
bool hit_found = FALSE, dam_found = FALSE;
if (obj->item_type != ITEM_WEAPON)
{
send_to_char("That isn't a weapon.\n\r",ch);
return;
}
if (obj->wear_loc != -1)
{
send_to_char("The item must be carried to be enchanted.\n\r",ch);
return;
}
if (is_affected_obj(obj,skill_lookup("unholy bless")))
return send_to_char("The unholy aura surrounding that prevents you.\n\r",ch);
/* this means they have no bonus */
hit_bonus = 0;
dam_bonus = 0;
fail = 25; /* base 25% chance of failure */
/* find the bonuses */
if (!obj->enchanted)
for ( paf = obj->pIndexData->affected; paf != NULL; paf = paf->next )
{
if ( paf->location == APPLY_HITROLL )
{
hit_bonus = paf->modifier;
hit_found = TRUE;
fail += 2 * (hit_bonus * hit_bonus);
}
else if (paf->location == APPLY_DAMROLL )
{
dam_bonus = paf->modifier;
dam_found = TRUE;
fail += 2 * (dam_bonus * dam_bonus);
}
else /* things get a little harder */
fail += 25;
}
for ( paf = obj->affected; paf != NULL; paf = paf->next )
{
if ( paf->location == APPLY_HITROLL )
{
hit_bonus = paf->modifier;
hit_found = TRUE;
fail += 2 * (hit_bonus * hit_bonus);
}
else if (paf->location == APPLY_DAMROLL )
{
dam_bonus = paf->modifier;
dam_found = TRUE;
fail += 2 * (dam_bonus * dam_bonus);
}
else /* things get a little harder */
fail += 25;
}
/* apply other modifiers */
fail -= 3 * level/2;
if (IS_OBJ_STAT(obj,ITEM_BLESS))
fail -= 15;
if (IS_OBJ_STAT(obj,ITEM_GLOW))
fail -= 5;
fail = URANGE(5,fail,95);
result = number_percent();
/* the moment of truth */
if (result < (fail / 5)) /* item destroyed */
{
act("$p shivers violently and explodes!",ch,obj,NULL,TO_CHAR);
act("$p shivers violently and explodeds!",ch,obj,NULL,TO_ROOM);
extract_obj(obj);
return;
}
if (result < (fail / 2)) /* item disenchanted */
{
AFFECT_DATA *paf_next;
act("$p glows brightly, then fades...oops.",ch,obj,NULL,TO_CHAR);
act("$p glows brightly, then fades.",ch,obj,NULL,TO_ROOM);
obj->enchanted = TRUE;
/* remove all affects */
for (paf = obj->affected; paf != NULL; paf = paf_next)
{
paf_next = paf->next;
free_affect(paf);
}
obj->affected = NULL;
remove_bit(&obj->extra_flags, ITEM_GLOW);
remove_bit(&obj->extra_flags, ITEM_HUM);
remove_bit(&obj->extra_flags, ITEM_MAGIC);
remove_bit(&obj->extra_flags, ITEM_INVIS);
remove_bit(&obj->extra_flags, ITEM_NODROP);
remove_bit(&obj->extra_flags, ITEM_NOREMOVE);
return;
}
if ( result <= fail ) /* failed, no bad result */
{
send_to_char("Nothing seemed to happen.\n\r",ch);
return;
}
/* okay, move all the old flags into new vectors if we have to */
if (!obj->enchanted)
{
AFFECT_DATA *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;
}
}
if (result <= (100 - level/5)) /* success! */
{
act("$p glows blue.",ch,obj,NULL,TO_CHAR);
act("$p glows blue.",ch,obj,NULL,TO_ROOM);
set_bit(&obj->extra_flags, ITEM_MAGIC);
added = 1;
}
else /* exceptional enchant */
{
act("$p glows a brillant blue!",ch,obj,NULL,TO_CHAR);
act("$p glows a brillant blue!",ch,obj,NULL,TO_ROOM);
set_bit(&obj->extra_flags,ITEM_MAGIC);
added = 2;
}
if ( (result = number_percent()) <= 25 && !is_set(&obj->extra_flags,ITEM_HUM) )
{
set_bit(&obj->extra_flags,ITEM_HUM);
remove_bit(&obj->extra_flags,ITEM_GLOW);
}
if ( (result = number_percent()) <= 25 && !is_set(&obj->extra_flags,ITEM_GLOW) )
set_bit(&obj->extra_flags,ITEM_GLOW);
if (level >= 100)
set_bit(&obj->extra_flags,ITEM_ROT_DEATH);
/* now add the enchantments */
if (obj->level < LEVEL_HERO - 1)
obj->level = UMIN(LEVEL_HERO - 1,obj->level + 1);
if (dam_found)
{
for ( paf = obj->affected; paf != NULL; paf = paf->next)
{
if ( paf->location == APPLY_DAMROLL)
{
paf->type = sn;
paf->modifier += added;
paf->level = UMAX(paf->level,level);
}
}
}
else /* add a new affect */
{
paf = new_affect();
paf->where = TO_OBJECT;
paf->type = sn;
paf->level = level;
paf->duration = -1;
paf->location = APPLY_DAMROLL;
paf->modifier = added;
paf->bitvector = 0;
paf->next = obj->affected;
obj->affected = paf;
}
if (hit_found)
{
for ( paf = obj->affected; paf != NULL; paf = paf->next)
{
if ( paf->location == APPLY_HITROLL)
{
paf->type = sn;
paf->modifier += added;
paf->level = UMAX(paf->level,level);
}
}
}
else /* add a new affect */
{
paf = new_affect();
paf->type = sn;
paf->level = level;
paf->duration = -1;
paf->location = APPLY_HITROLL;
paf->modifier = added;
paf->bitvector = 0;
paf->next = obj->affected;
obj->affected = paf;
}
return;
}
void spell_fireball( int sn, int level, CHAR_DATA *ch, void *vo,int target )
{
CHAR_DATA *vch;
char buf[MSL];
int dam = number_range(125,135);
if (check_spellcraft(ch,sn))
dam += spellcraft_dam(level,3);
else
dam += dice(level,3);
act("$n conjures a fireball into the room!",ch,0,0,TO_ROOM);
act("You conjure a fireball into the room!",ch,0,0,TO_CHAR);
for (vch = ch->in_room->people; vch != NULL; vch = vch->next_in_room)
{
if ((is_same_group(vch,ch) || IS_IMMORTAL(vch)) && ch->fighting != vch) {
continue;
}
if (ch->cabal != 0 && is_same_cabal(vch,ch )) {
continue;
}
act("You are engulfed by $n's fireball!",ch,0,vch,TO_VICT);
switch(number_range(0,2))
{
case (0):
case (1):
sprintf(buf,"Die, %s you sorcerous dog!",PERS(ch,vch));
break;
case (2):
sprintf(buf,"Help! %s is casting a spell on me!",PERS(ch,vch));
}
if ( saves_spell( level, vch, DAM_FIRE) )
dam /= 2;
damage_old( ch, vch, dam, sn, DAM_FIRE ,TRUE);
}
return;
}
void spell_fireproof(int sn, int level, CHAR_DATA *ch, void *vo,int target)
{
OBJ_DATA *obj = (OBJ_DATA *) vo;
AFFECT_DATA af;
if (IS_OBJ_STAT(obj,ITEM_BURN_PROOF))
{
act("$p is already protected from burning.",ch,obj,NULL,TO_CHAR);
return;
}
init_affect(&af);
af.where = TO_OBJECT;
af.type = sn;
af.aftype = AFT_SPELL;
af.level = level;
af.duration = number_fuzzy(level / 4);
af.location = APPLY_NONE;
af.modifier = 0;
af.bitvector = ITEM_BURN_PROOF;
affect_to_obj(obj,&af);
act("You protect $p from fire.",ch,obj,NULL,TO_CHAR);
act("$p is surrounded by a protective aura.",ch,obj,NULL,TO_ROOM);
}
void spell_flamestrike( int sn, int level, CHAR_DATA *ch, void *vo,int target )
{
CHAR_DATA *victim = (CHAR_DATA *) vo;
int dam;
if (check_spellcraft(ch,sn))
dam = spellcraft_dam(6 + level / 2,8);
else
dam = dice(6 + level / 2, 8);
if ( saves_spell( level, victim,DAM_FIRE) )
dam /= 2;
damage_old( ch, victim, dam, sn, DAM_FIRE ,TRUE);
return;
}
void spell_faerie_fire( int sn, int level, CHAR_DATA *ch, void *vo,int target )
{
CHAR_DATA *victim = (CHAR_DATA *) vo;
AFFECT_DATA af;
if ( IS_AFFECTED(victim, AFF_FAERIE_FIRE) )
{
send_to_char("You are already glowing.\n\r", victim );
if( ch != victim )
{
act("$N is already glowing.",ch,NULL,victim,TO_CHAR );
act("$N is already glowing.",ch,NULL,victim,TO_ROOM );
}
return;
}
if (saves_spell(level+15, victim,DAM_OTHER))
{
if( ch == victim )
send_to_char("You resist your faerie fire.\n\r",victim);
if( ch != victim )
{
act("$N resists your faerie fire.",ch,NULL,victim,TO_CHAR );
act("$N resists $n's faerie fire.",ch,NULL,victim,TO_ROOM );
act("You resist $n's faerie fire.",ch,NULL,victim,TO_VICT );
}
return;
}
affect_strip ( victim,gsn_camouflage );
affect_strip ( victim, gsn_invis );
affect_strip ( victim, gsn_mass_invis );
affect_strip ( victim, gsn_sneak );
affect_strip ( victim, gsn_earthfade );
affect_strip ( victim, gsn_duo );
REMOVE_BIT ( victim->affected_by, AFF_HIDE );
REMOVE_BIT ( victim->affected_by, AFF_INVISIBLE );
REMOVE_BIT ( victim->affected_by, AFF_SNEAK );
REMOVE_BIT ( victim->affected_by, AFF_CAMOUFLAGE );
init_affect(&af);
af.where = TO_AFFECTS;
af.aftype = get_spell_aftype(ch);
af.type = sn;
af.level = level;
af.duration = 5;
af.location = APPLY_AC;
af.modifier = -5 * AC_PER_ONE_PERCENT_DECREASE_DAMAGE;
af.bitvector = AFF_FAERIE_FIRE;
affect_to_char( victim, &af );
send_to_char( "You are surrounded by a pink outline.\n\r", victim );
act( "$n is surrounded by a pink outline.", victim, NULL, NULL, TO_ROOM );
return;
}
void spell_faerie_fog( int sn, int level, CHAR_DATA *ch, void *vo,int target )
{
CHAR_DATA *ich;
AFFECT_DATA af;
act( "$n conjures a cloud of purple smoke.", ch, NULL, NULL, TO_ROOM );
send_to_char( "You conjure a cloud of purple smoke.\n\r", ch );
init_affect(&af);
af.where = TO_AFFECTS;
af.aftype = get_spell_aftype(ch);
af.type = sn;
af.level = level;
af.duration = 4 + (level/8);
af.bitvector = 0;
af.modifier = 0;
for ( ich = ch->in_room->people; ich != NULL; ich = ich->next_in_room )
{
if (ich->invis_level > 0)
continue;
if (ich->trust > 51 )
continue;
if ( ich == ch || saves_spell( level, ich,DAM_OTHER) )
continue;
af.affect_list_msg = str_dup("unable to conceal yourself");
affect_to_char( ich,&af);
affect_strip ( ich,gsn_camouflage );
affect_strip ( ich, gsn_invis );
affect_strip ( ich, gsn_mass_invis );
affect_strip ( ich, gsn_sneak );
affect_strip ( ich, gsn_earthfade );
affect_strip ( ich, gsn_duo );
REMOVE_BIT ( ich->affected_by, AFF_HIDE );
REMOVE_BIT ( ich->affected_by, AFF_INVISIBLE );
REMOVE_BIT ( ich->affected_by, AFF_SNEAK );
REMOVE_BIT ( ich->affected_by, AFF_CAMOUFLAGE );
act( "$n is revealed!", ich, NULL, NULL, TO_ROOM );
send_to_char( "You are revealed!\n\r", ich );
}
return;
}
void spell_fly( int sn, int level, CHAR_DATA *ch, void *vo,int target )
{
CHAR_DATA *victim = (CHAR_DATA *) vo;
AFFECT_DATA af;
if ( IS_AFFECTED(victim, AFF_FLYING) )
{
if (victim == ch)
send_to_char("You are already airborne.\n\r",ch);
else
act("$N doesn't need your help to fly.",ch,NULL,victim,TO_CHAR);
return;
}
if (is_affected(ch,skill_lookup("bolo toss"))) {
return send_to_char("Your magic cannot overcome the weight of the bolo twisted around your torso.\n\r",ch);
}
init_affect(&af);
af.where = TO_AFFECTS;
af.aftype = get_spell_aftype(ch);
af.type = sn;
af.level = level;
af.duration = level + 3;
af.location = 0;
af.modifier = 0;
af.affect_list_msg = str_dup("grants flight");
af.bitvector = AFF_FLYING;
affect_to_char( victim, &af );
send_to_char( "Your feet rise off the ground.\n\r", victim );
act( "$n's feet rise off the ground.", victim, NULL, NULL, TO_ROOM );
return;
}
/* RT clerical berserking spell */
void spell_frenzy(int sn, int level, CHAR_DATA *ch, void *vo,int target)
{
CHAR_DATA *victim = (CHAR_DATA *) vo;
AFFECT_DATA af;
if (is_affected(victim,sn) || IS_AFFECTED(victim,AFF_BERSERK))
{
if (victim == ch)
send_to_char("You are already in a frenzy.\n\r",ch);
else
act("$N is already in a frenzy.",ch,NULL,victim,TO_CHAR);
return;
}
if (is_affected(victim,skill_lookup("calm")))
{
if (victim == ch)
send_to_char("Why don't you just relax for a while?\n\r",ch);
else
act("$N doesn't look like $e wants to fight anymore.", ch,NULL,victim,TO_CHAR);
return;
}
if ((IS_GOOD(ch) && !IS_GOOD(victim)) ||
(IS_NEUTRAL(ch) && !IS_NEUTRAL(victim)) ||
(IS_EVIL(ch) && !IS_EVIL(victim)) )
{
act("Your god doesn't seem to like $N",ch,NULL,victim,TO_CHAR);
return;
}
init_affect(&af);
af.aftype = AFT_COMMUNE;
af.where = TO_AFFECTS;
af.type = sn;
af.level = level;
af.duration = level / 3;
af.modifier = level / 6;
af.bitvector = 0;
af.location = APPLY_HITROLL;
affect_to_char(victim,&af);
af.location = APPLY_DAMROLL;
affect_to_char(victim,&af);
af.modifier = -2 * AC_PER_ONE_PERCENT_DECREASE_DAMAGE;
af.location = APPLY_AC;
affect_to_char(victim,&af);
send_to_char("You are filled with holy wrath!\n\r",victim);
act("$n gets a wild look in $s eyes!",victim,NULL,NULL,TO_ROOM);
}
/* RT ROM-style gate */
void spell_gate( int sn, int level, CHAR_DATA *ch, void *vo,int target )
{
CHAR_DATA *victim;
if (ch->fighting != NULL)
{
send_to_char("You can't concentrate enough.\n\r",ch);
return;
}
victim = get_char_world( ch, target_name );
if (!(victim==NULL))
{
if ((IS_NPC(victim)) && ( IS_SET(victim->res_flags,RES_SUMMON) ))
level -= 5;
if ((IS_NPC(victim)) && ( IS_SET(victim->vuln_flags,VULN_SUMMON) ))
level += 5;
}
if ( victim == NULL
|| victim == ch
|| victim->in_room == NULL
|| !can_see_room(ch,victim->in_room)
|| IS_SET(victim->in_room->room_flags, ROOM_NO_GATE)
|| IS_SET(victim->in_room->room_flags, ROOM_PRIVATE)
|| (victim->in_room->cabal != 0 && victim->in_room->cabal != ch->cabal)
|| IS_SET(victim->in_room->room_flags, ROOM_SOLITARY)
|| IS_SET(ch->in_room->room_flags, ROOM_NO_RECALL)
|| victim->level >= level + 4
|| (!IS_NPC(victim) && !can_pk(ch,victim) && IS_SET(victim->act,PLR_NOSUMMON))
|| (!IS_NPC(victim) && saves_spell(level,victim,DAM_OTHER))
|| (!IS_NPC(victim) && victim->level > LEVEL_HERO)
|| (IS_NPC(victim) && IS_SET(victim->imm_flags,IMM_SUMMON))
|| (IS_NPC(victim) && saves_spell( level, victim,DAM_OTHER) ) )
{
send_to_char( "You failed.\n\r", ch );
return;
}
if (victim->in_room->cabal != 0 && victim->in_room->cabal != victim->cabal)
{
send_to_char("You failed.\n\r",victim);
return;
}
act("$n steps through a gate and vanishes.",ch,NULL,NULL,TO_ROOM);
send_to_char("You step through a gate and vanish.\n\r",ch);
char_from_room(ch);
char_to_room(ch,victim->in_room);
act("$n has arrived through a gate.",ch,NULL,NULL,TO_ROOM);
do_look(ch,"auto");
un_camouflage( ch, NULL);
un_earthfade(ch, NULL);
un_hide(ch, NULL);
un_sneak(ch, NULL);
}
void spell_giant_strength(int sn,int level,CHAR_DATA *ch,void *vo,int target)
{
CHAR_DATA *victim = (CHAR_DATA *) vo;
AFFECT_DATA af;
if ( is_affected( victim, sn ) )
{
if (victim == ch)
send_to_char("You are already as strong as you can get!\n\r",ch);
else
act("$N can't get any stronger.",ch,NULL,victim,TO_CHAR);
return;
}
init_affect(&af);
af.where = TO_AFFECTS;
af.aftype = get_spell_aftype(ch);
af.type = sn;
af.level = level;
af.duration = level;
af.location = APPLY_STR;
af.modifier = 1 + (level >= 18) + (level >= 25) + (level >= 32);
af.bitvector = 0;
affect_to_char( victim, &af );
af.location = APPLY_ENHANCED_MOD;
af.modifier = 2;
affect_to_char( victim, &af );
send_to_char( "Your muscles surge with heightened power!\n\r", victim );
act("$n's muscles surge with heightened power.",victim,NULL,NULL,TO_ROOM);
return;
}
void spell_harm( int sn, int level, CHAR_DATA *ch, void *vo,int target)
{
CHAR_DATA *victim = (CHAR_DATA *) vo;
int dam;
dam = UMAX( 20, victim->hit - dice(1,4) );
if ( saves_spell( level, victim,DAM_HARM) )
dam = UMIN( 50, dam / 2 );
dam = UMIN( 100, dam );
damage_old( ch, victim, dam, sn, DAM_HARM ,TRUE);
return;
}
/* RT haste spell */
void spell_haste( int sn, int level, CHAR_DATA *ch, void *vo,int target )
{
CHAR_DATA *victim = (CHAR_DATA *) vo;
AFFECT_DATA af;
if (!str_cmp(class_table[ch->class].name, "monk")
&& victim != ch)
{
send_to_char("You are only able to enhance your own physical abilities.\n\r",ch);
return;
}
if ( is_affected( victim, sn ) || IS_AFFECTED(victim,AFF_HASTE)
|| IS_SET(victim->off_flags,OFF_FAST))
{
if (victim == ch)
send_to_char("You can't move any faster!\n\r",ch);
else
act("$N is already moving as fast as $E can.",
ch,NULL,victim,TO_CHAR);
return;
}
if (IS_AFFECTED(victim,AFF_SLOW))
{
send_to_char("You start moving at normal speed again.\n\r",victim);
act("$n starts moving at normal speed again.",victim,NULL,NULL,TO_ROOM);
affect_strip(victim,skill_lookup("slow"));
return;
}
init_affect(&af);
af.where = TO_AFFECTS;
af.aftype = AFT_SPELL;
af.type = sn;
af.level = level;
if (victim == ch)
af.duration = level/2;
else
af.duration = level/2;
af.location = APPLY_DEX;
af.modifier = 1 + (level >= 18) + (level >= 25) + (level >= 32);
af.bitvector = AFF_HASTE;
char msg_buf[MSL];
sprintf(msg_buf,"increases likelihood of attacks and dexterity by %d",af.modifier);
af.affect_list_msg = str_dup(msg_buf);
affect_to_char( victim, &af );
send_to_char( "You feel yourself moving more quickly.\n\r", victim );
act("$n is moving more quickly.",victim,NULL,NULL,TO_ROOM);
if ( ch != victim )
send_to_char( "Ok.\n\r", ch );
return;
}
void spell_heal( int sn, int level, CHAR_DATA *ch, void *vo,int target )
{
CHAR_DATA *victim = (CHAR_DATA *) vo;
victim->hit = UMIN( victim->hit + 100, victim->max_hit );
update_pos( victim );
send_to_char( "A warm feeling fills your body.\n\r", victim );
if ( ch != victim )
send_to_char( "Ok.\n\r", ch );
return;
}
void spell_heat_metal( int sn, int level, CHAR_DATA *ch, void *vo,int target )
{
CHAR_DATA *victim = (CHAR_DATA *) vo;
OBJ_DATA *obj_lose, *obj_next;
int dam = 0;
bool fail = TRUE;
return;
if (!saves_spell(level + 2,victim,DAM_FIRE)
&& !IS_SET(victim->imm_flags,IMM_FIRE))
{
for ( obj_lose = victim->carrying;
obj_lose != NULL;
obj_lose = obj_next)
{
obj_next = obj_lose->next_content;
if ( number_range(1,2 * level) > obj_lose->level
&& !saves_spell(level,victim,DAM_FIRE)
&& IS_OBJ_STAT(obj_lose,ITEM_METAL))
{
switch ( obj_lose->item_type )
{
case ITEM_ARMOR:
if (obj_lose->wear_loc != -1) /* remove the item */
{
if (can_drop_obj(victim,obj_lose)
&& (obj_lose->weight / 10) <
number_range(1,2 * get_curr_stat(victim,STAT_DEX))
&& remove_obj( victim, obj_lose->wear_loc, TRUE ))
{
act("$n yelps and throws $p to the ground!",
victim,obj_lose,NULL,TO_ROOM);
act("You remove and drop $p before it burns you.",
victim,obj_lose,NULL,TO_CHAR);
dam += (number_range(1,obj_lose->level) / 3);
obj_from_char(obj_lose);
obj_to_room(obj_lose, victim->in_room);
fail = FALSE;
}
else /* stuck on the body! ouch! */
{
act("Your skin is seared by $p!",
victim,obj_lose,NULL,TO_CHAR);
dam += (number_range(1,obj_lose->level));
fail = FALSE;
}
}
else /* drop it if we can */
{
if (can_drop_obj(victim,obj_lose))
{
act("$n yelps and throws $p to the ground!",
victim,obj_lose,NULL,TO_ROOM);
act("You and drop $p before it burns you.",
victim,obj_lose,NULL,TO_CHAR);
dam += (number_range(1,obj_lose->level) / 6);
obj_from_char(obj_lose);
obj_to_room(obj_lose, victim->in_room);
fail = FALSE;
}
else /* cannot drop */
{
act("Your skin is seared by $p!",
Showing the first 100 KB of 296.8 KB. Download the archive for the full file.