version 1.52 | | version 1.53 |
---|
| | |
/* | | /* |
* static char *rcsid_spell_util_c = | | * static char *rcsid_spell_util_c = |
* "$Id: spell_util.c,v 1.52 2001/05/24 20:42:52 mwedel Exp $"; | | * "$Id: spell_util.c,v 1.53 2001/05/29 04:41:54 mwedel Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
| | |
char *range_name[range_size] = { | | char *range_name[range_size] = { |
"none", "bow", "magic", "wand", "rod", "scroll", "horn" | | "none", "bow", "magic", "wand", "rod", "scroll", "horn" |
#ifdef ALLOW_SKILLS | | |
,"steal" | | ,"steal" |
#endif | | |
}; | | }; |
| | |
archetype *spellarch[NROFREALSPELLS]; | | archetype *spellarch[NROFREALSPELLS]; |
| | |
/* Oct 95 - added cosmetic touches for MULTIPLE_GODS hack -b.t. */ | | /* Oct 95 - added cosmetic touches for MULTIPLE_GODS hack -b.t. */ |
| | |
int cast_spell(object *op,object *caster,int dir,int type,int ability,SpellTypeFrom item,char *stringarg) { | | int cast_spell(object *op,object *caster,int dir,int type,int ability,SpellTypeFrom item,char *stringarg) { |
#ifdef MULTIPLE_GODS | | |
char *godname; | | char *godname; |
#endif | | |
spell *s=find_spell(type); | | spell *s=find_spell(type); |
int success=0,bonus; | | int success=0,bonus; |
int duration=SP_PARAMETERS[type].bdur; /* get the base duration */ | | int duration=SP_PARAMETERS[type].bdur; /* get the base duration */ |
| | |
#ifdef MULTIPLE_GODS | | |
if(!strcmp((godname=determine_god(op)),"none")) godname="A random spirit"; | | if(!strcmp((godname=determine_god(op)),"none")) godname="A random spirit"; |
#endif | | |
| | |
/* It looks like the only properties we ever care about from the casting | | /* It looks like the only properties we ever care about from the casting |
* object (caster) is spell paths and level. | | * object (caster) is spell paths and level. |
| | |
*/ | | */ |
if( (RANDOM()%op->stats.Wis) +op->stats.grace - | | if( (RANDOM()%op->stats.Wis) +op->stats.grace - |
10*SP_level_spellpoint_cost(op,caster,type)/op->stats.maxgrace >0) { | | 10*SP_level_spellpoint_cost(op,caster,type)/op->stats.maxgrace >0) { |
#ifdef MULTIPLE_GODS | | |
new_draw_info_format(NDI_UNIQUE, 0,op, | | new_draw_info_format(NDI_UNIQUE, 0,op, |
"%s grants your prayer, though you are unworthy.",godname); | | "%s grants your prayer, though you are unworthy.",godname); |
#else | | |
new_draw_info(NDI_UNIQUE, 0,op, | | |
"God grants your prayer, though you are unworthy."); | | |
#endif | | |
} | | } |
else | | else |
{ | | { |
prayer_failure(op,op->stats.grace,SP_level_spellpoint_cost(op,caster,type)); | | prayer_failure(op,op->stats.grace,SP_level_spellpoint_cost(op,caster,type)); |
#ifdef MULTIPLE_GODS | | |
new_draw_info_format(NDI_UNIQUE, 0,op,"%s ignores your prayer.",godname); | | new_draw_info_format(NDI_UNIQUE, 0,op,"%s ignores your prayer.",godname); |
#else | | |
new_draw_info(NDI_UNIQUE, 0,op,"God ignores your prayer."); | | |
#endif | | |
op->contr->count_left=0; | | op->contr->count_left=0; |
return 0; | | return 0; |
} | | } |
| | |
if (op->type!=PLAYER) | | if (op->type!=PLAYER) |
return 0; | | return 0; |
if(s->cleric) | | if(s->cleric) |
#ifdef MULTIPLE_GODS | | |
new_draw_info_format(NDI_UNIQUE, 0,op,"This ground is unholy! %s ignores you.",godname); | | new_draw_info_format(NDI_UNIQUE, 0,op,"This ground is unholy! %s ignores you.",godname); |
#else | | |
new_draw_info(NDI_UNIQUE, 0,op,"This ground is unholy! God ignores you."); | | |
#endif | | |
else | | else |
switch(op->contr->shoottype) { | | switch(op->contr->shoottype) { |
case range_magic: | | case range_magic: |
| | |
success = cast_consecrate(op); | | success = cast_consecrate(op); |
break; | | break; |
case SP_SUMMON_CULT: | | case SP_SUMMON_CULT: |
#ifdef MULTIPLE_GODS | | |
success = summon_cult_monsters(op,dir); | | success = summon_cult_monsters(op,dir); |
#else | | |
success = summon_pet(op,dir,item); | | |
#endif | | |
break; | | break; |
case SP_PET: | | case SP_PET: |
success = summon_pet(op,dir, item); | | success = summon_pet(op,dir, item); |
| | |
else | | else |
set_owner (tmp, op); | | set_owner (tmp, op); |
tmp->level = casting_level (caster, type); | | tmp->level = casting_level (caster, type); |
#ifdef MULTIPLE_GODS /* needed for AT_HOLYWORD,AT_GODPOWER stuff */ | | |
| | /* needed for AT_HOLYWORD,AT_GODPOWER stuff */ |
if(tmp->attacktype&AT_HOLYWORD||tmp->attacktype&AT_GODPOWER) { | | if(tmp->attacktype&AT_HOLYWORD||tmp->attacktype&AT_GODPOWER) { |
if(!tailor_god_spell(tmp,op)) return 0; | | if(!tailor_god_spell(tmp,op)) return 0; |
} else /* Ugly else going across endif */ | | } else { |
#endif | | |
if(magic) | | if(magic) |
tmp->attacktype|=AT_MAGIC; | | tmp->attacktype|=AT_MAGIC; |
| | } |
if(QUERY_FLAG(tmp, FLAG_IS_TURNABLE)) | | if(QUERY_FLAG(tmp, FLAG_IS_TURNABLE)) |
SET_ANIMATION(tmp, dir); | | SET_ANIMATION(tmp, dir); |
| | |
| | |
copy_owner(tmp,op); | | copy_owner(tmp,op); |
tmp->level = casting_level (caster, spell_type); | | tmp->level = casting_level (caster, spell_type); |
tmp->x=x,tmp->y=y; | | tmp->x=x,tmp->y=y; |
#ifdef MULTIPLE_GODS /* holy word stuff */ | | |
| | /* holy word stuff */ |
if((tmp->attacktype&AT_HOLYWORD)||(tmp->attacktype&AT_GODPOWER)) { | | if((tmp->attacktype&AT_HOLYWORD)||(tmp->attacktype&AT_GODPOWER)) { |
if(!tailor_god_spell(tmp,op)) return 0; | | if(!tailor_god_spell(tmp,op)) return 0; |
} else /* god/holy word isnt really 'magic' */ | | } else /* god/holy word isnt really 'magic' */ |
#endif | | |
if(magic) | | if(magic) |
tmp->attacktype|=AT_MAGIC; /* JWI cone attacks should be considered | | tmp->attacktype|=AT_MAGIC; /* JWI cone attacks should be considered |
magical in nature ;) */ | | magical in nature ;) */ |
| | |
/* added to make face of death work,and counterspell */ | | /* added to make face of death work,and counterspell */ |
tmp->level = op->level; | | tmp->level = op->level; |
| | |
#ifdef MULTIPLE_GODS /* holy word stuff */ | | /* holy word stuff */ |
if(tmp->attacktype&AT_HOLYWORD||tmp->attacktype&AT_GODPOWER) | | if(tmp->attacktype&AT_HOLYWORD||tmp->attacktype&AT_GODPOWER) |
if(!tailor_god_spell(tmp,op)) return; | | if(!tailor_god_spell(tmp,op)) return; |
#endif | | |
tmp->stats.sp=op->stats.sp,tmp->stats.hp=op->stats.hp+1; | | tmp->stats.sp=op->stats.sp,tmp->stats.hp=op->stats.hp+1; |
tmp->stats.maxhp=op->stats.maxhp; | | tmp->stats.maxhp=op->stats.maxhp; |
tmp->stats.dam = op->stats.dam; | | tmp->stats.dam = op->stats.dam; |
| | |
tmp->x = op->x; | | tmp->x = op->x; |
tmp->y = op->y; | | tmp->y = op->y; |
| | |
#ifdef MULTIPLE_GODS /* needed for AT_HOLYWORD stuff -b.t. */ | | /* needed for AT_HOLYWORD stuff -b.t. */ |
if(tmp->attacktype&AT_HOLYWORD||tmp->attacktype&AT_GODPOWER) | | if(tmp->attacktype&AT_HOLYWORD||tmp->attacktype&AT_GODPOWER) |
if ( ! tailor_god_spell (tmp, op)) { | | if ( ! tailor_god_spell (tmp, op)) { |
remove_ob (op); | | remove_ob (op); |
free_object (op); | | free_object (op); |
return; | | return; |
} | | } |
#endif | | |
| | |
/* Prevent recursion */ | | /* Prevent recursion */ |
CLEAR_FLAG (op, FLAG_WALK_ON); | | CLEAR_FLAG (op, FLAG_WALK_ON); |
| | |
set_owner(tmp,op); /* needed so that if swarm elements kill, caster gets xp.*/ | | set_owner(tmp,op); /* needed so that if swarm elements kill, caster gets xp.*/ |
tmp->level=casting_level(caster, spell_type); /*needed later, to get level dep. right.*/ | | tmp->level=casting_level(caster, spell_type); /*needed later, to get level dep. right.*/ |
tmp->stats.sp=spell_type; /* needed later, see move_swarm_spell */ | | tmp->stats.sp=spell_type; /* needed later, see move_swarm_spell */ |
#ifdef MULTIPLE_GODS | | |
tmp->attacktype = swarm_type->clone.attacktype; | | tmp->attacktype = swarm_type->clone.attacktype; |
if (tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER) { | | if (tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER) { |
if ( ! tailor_god_spell (tmp, op)) | | if ( ! tailor_god_spell (tmp, op)) |
return; | | return; |
} | | } |
#endif | | |
tmp->magic = magic; | | tmp->magic = magic; |
tmp->stats.hp=n; /* n in swarm*/ | | tmp->stats.hp=n; /* n in swarm*/ |
tmp->other_arch=swarm_type; /* the archetype of the things to be fired*/ | | tmp->other_arch=swarm_type; /* the archetype of the things to be fired*/ |
| | |
| | |
int cast_smite_spell (object *op, object *caster,int dir, int type) { | | int cast_smite_spell (object *op, object *caster,int dir, int type) { |
object *effect, *target = get_pointed_target(op,dir); | | object *effect, *target = get_pointed_target(op,dir); |
#ifdef MULTIPLE_GODS | | |
object *god = find_god(determine_god(op)); | | object *god = find_god(determine_god(op)); |
#endif | | |
| | |
| | /* if we don't worship a god, or target a creature |
| | * of our god, the spell will fail. |
| | */ |
if(!target || QUERY_FLAG(target,FLAG_REFL_SPELL) | | if(!target || QUERY_FLAG(target,FLAG_REFL_SPELL) |
#ifdef MULTIPLE_GODS /* if we don't worship a god, or target a creature | | |
* of our god, the spell will fail. */ | | |
||!god | | ||!god |
||(target->title&&!strcmp(target->title,god->name)) | | ||(target->title&&!strcmp(target->title,god->name)) |
||(target->race&&strstr(target->race,god->race)) | | ||(target->race&&strstr(target->race,god->race)) |
#endif | | |
) { | | ) { |
new_draw_info(NDI_UNIQUE,0,op,"Your request is unheeded."); | | new_draw_info(NDI_UNIQUE,0,op,"Your request is unheeded."); |
return 0; | | return 0; |
| | |
| | |
/* tailor the effect by priest level and worshipped God */ | | /* tailor the effect by priest level and worshipped God */ |
effect->level = casting_level (caster, type); | | effect->level = casting_level (caster, type); |
#ifdef MULTIPLE_GODS | | |
if(effect->attacktype&AT_HOLYWORD||effect->attacktype&AT_GODPOWER) { | | if(effect->attacktype&AT_HOLYWORD||effect->attacktype&AT_GODPOWER) { |
if(tailor_god_spell(effect,op)) | | if(tailor_god_spell(effect,op)) |
new_draw_info_format(NDI_UNIQUE,0,op, | | new_draw_info_format(NDI_UNIQUE,0,op, |
| | |
return 0; | | return 0; |
} | | } |
} | | } |
#endif | | |
| | |
/* size of the area of destruction */ | | /* size of the area of destruction */ |
effect->stats.hp=SP_PARAMETERS[type].bdur + | | effect->stats.hp=SP_PARAMETERS[type].bdur + |