version 1.7 | | version 1.8 |
---|
| | |
/* | | /* |
* static char *rcsid_spell_util_c = | | * static char *rcsid_spell_util_c = |
* "$Id: spell_util.c,v 1.7 2000/04/14 04:48:19 cvs Exp $"; | | * "$Id: spell_util.c,v 1.8 2000/04/17 14:18:13 jec Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
return &spells[spelltype]; | | return &spells[spelltype]; |
} | | } |
| | |
int path_level_mod(object *op, int sp) { | | /* |
spell *s = find_spell(sp); | | * base_level: level before considering attuned/repelled paths |
int val; | | * Returns modified level. |
| | */ |
if (op->path_denied & s->path) | | int path_level_mod (object *caster, int base_level, int spell_type) |
return -100; /* shouldn't get here, but ... */ | | { |
val = (op->path_repelled & s->path) ? -5 : 0 | | spell *s = find_spell(spell_type); |
+ (op->path_attuned & s->path) ? 5 : 0; | | int new_level; |
if (op->level - val < 1) | | |
return op->level-1; | | if (caster->path_denied & s->path) |
else | | { |
return val; | | LOG (llevError, "BUG: path_level_mod (arch %s, name %s): casting denied " |
| | "spell\n", caster->arch->name, caster->name); |
| | return 1; |
| | } |
| | new_level = base_level |
| | + ((caster->path_repelled & s->path) ? -5 : 0) |
| | + ((caster->path_attuned & s->path) ? 5 : 0); |
| | return (new_level < 1) ? 1 : new_level; |
| | } |
| | |
| | int casting_level (object *caster, int spell_type) |
| | { |
| | return path_level_mod (caster, SK_level (caster), spell_type); |
} | | } |
| | |
int check_spell_known(object *op,int sp) { | | |
| | int check_spell_known (object *op, int spell_type) |
| | { |
int i; | | int i; |
for(i=0; i < (int)op->contr->nrofknownspells; i++) | | for(i=0; i < (int)op->contr->nrofknownspells; i++) |
if(op->contr->known_spells[i]==sp) | | if(op->contr->known_spells[i]==spell_type) |
return 1; | | return 1; |
return 0; | | return 0; |
} | | } |
| | |
n=RANDOM()%3 + RANDOM()%3 + RANDOM()%3 +3 + | | n=RANDOM()%3 + RANDOM()%3 + RANDOM()%3 +3 + |
SP_level_strength_adjust(op,caster, type); | | SP_level_strength_adjust(op,caster, type); |
success = 1; | | success = 1; |
fire_swarm(op,dir,spellarch[type],SP_METEOR,n,0); | | fire_swarm(op,caster,dir,spellarch[type],SP_METEOR,n,0); |
break; | | break; |
} | | } |
case SP_BULLET_SWARM: { | | case SP_BULLET_SWARM: { |
| | |
n=RANDOM()%3 + RANDOM()%3 + RANDOM()%3 +3 + | | n=RANDOM()%3 + RANDOM()%3 + RANDOM()%3 +3 + |
SP_level_strength_adjust(op,caster, type); | | SP_level_strength_adjust(op,caster, type); |
success = 1; | | success = 1; |
fire_swarm(op,dir,spellarch[type],SP_BULLET,n,1); | | fire_swarm(op,caster,dir,spellarch[type],SP_BULLET,n,1); |
break; | | break; |
} | | } |
case SP_BULLET_STORM: { | | case SP_BULLET_STORM: { |
| | |
n=RANDOM()%3 + RANDOM()%3 + RANDOM()%3 +3 + | | n=RANDOM()%3 + RANDOM()%3 + RANDOM()%3 +3 + |
SP_level_strength_adjust(op,caster, type); | | SP_level_strength_adjust(op,caster, type); |
success = 1; | | success = 1; |
fire_swarm(op,dir,spellarch[type],SP_LARGE_BULLET,n,1); | | fire_swarm(op,caster,dir,spellarch[type],SP_LARGE_BULLET,n,1); |
break; | | break; |
} | | } |
case SP_CAUSE_MANY: { | | case SP_CAUSE_MANY: { |
| | |
n=RANDOM()%3 + RANDOM()%3 + RANDOM()%3 +3 + | | n=RANDOM()%3 + RANDOM()%3 + RANDOM()%3 +3 + |
SP_level_strength_adjust(op,caster, type); | | SP_level_strength_adjust(op,caster, type); |
success = 1; | | success = 1; |
fire_swarm(op,dir,spellarch[type],SP_CAUSE_HEAVY,n,1); | | fire_swarm(op,caster,dir,spellarch[type],SP_CAUSE_HEAVY,n,1); |
break; | | break; |
} | | } |
case SP_METEOR: | | case SP_METEOR: |
| | |
tmp->x=x, tmp->y=y; | | tmp->x=x, tmp->y=y; |
tmp->direction=dir; | | tmp->direction=dir; |
set_owner(tmp,op); | | set_owner(tmp,op); |
| | tmp->level = casting_level (caster, type); |
#ifdef MULTIPLE_GODS /* needed for AT_HOLYWORD,AT_GODPOWER stuff */ | | #ifdef MULTIPLE_GODS /* 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; |
| | |
success=1; | | success=1; |
tmp=arch_to_object(spell_arch); | | tmp=arch_to_object(spell_arch); |
set_owner(tmp,op); | | set_owner(tmp,op); |
/* Make face of death work? */ | | tmp->level = casting_level (caster, spell_type); |
/* tmp->level=op->level; */ | | |
tmp->level=SK_level(op); /* need to use the cleric level, not overall value -b.t. */ | | |
tmp->x=x,tmp->y=y; | | tmp->x=x,tmp->y=y; |
#ifdef MULTIPLE_GODS /* holy word stuff */ | | #ifdef MULTIPLE_GODS /* holy word stuff */ |
if((tmp->attacktype&AT_HOLYWORD)||(tmp->attacktype&AT_GODPOWER)) { | | if((tmp->attacktype&AT_HOLYWORD)||(tmp->attacktype&AT_GODPOWER)) { |
| | |
tmp->x=x, tmp->y=y; | | tmp->x=x, tmp->y=y; |
| | |
/* added to make face of death work,and counterspell */ | | /* added to make face of death work,and counterspell */ |
tmp->level=SK_level(op); | | tmp->level = op->level; |
| | |
#ifdef MULTIPLE_GODS /* holy word stuff */ | | #ifdef MULTIPLE_GODS /* holy word stuff */ |
if(tmp->attacktype&AT_HOLYWORD||tmp->attacktype&AT_GODPOWER) | | if(tmp->attacktype&AT_HOLYWORD||tmp->attacktype&AT_GODPOWER) |
| | |
most of the following adjustments are for damage only, some are | | most of the following adjustments are for damage only, some are |
for turning undead and whatnot. | | for turning undead and whatnot. |
| | |
| | The following functions assume that casting the spell is not |
| | denied. Denied spells have an undefined path level modifier. |
| | There wouldn't be a meaningful result anyway. |
| | |
The arrays are defined in spells.h*/ | | The arrays are defined in spells.h*/ |
| | |
/* July 1995 - I changed the next 3 functions slightly by replacing | | /* July 1995 - I changed the next 3 functions slightly by replacing |
| | |
* path modifiers. --DAMN */ | | * path modifiers. --DAMN */ |
| | |
int SP_level_dam_adjust(object *op, object *caster, int spell_type) | | int SP_level_dam_adjust(object *op, object *caster, int spell_type) |
{ int adj; | | { |
#ifdef ALLOW_SKILLS | | int level = casting_level (caster, spell_type); |
int level=SK_level(caster)+path_level_mod(caster, spell_type); | | int adj = (level-spells[spell_type].level); |
#else | | |
int level=caster->level+path_level_mod(caster, spell_type); | | |
#endif | | |
| | |
adj=(level-spells[spell_type].level); | | |
if(adj < 0) adj=0; | | if(adj < 0) adj=0; |
if(SP_PARAMETERS[spell_type].ldam) | | if(SP_PARAMETERS[spell_type].ldam) |
adj/=SP_PARAMETERS[spell_type].ldam; | | adj/=SP_PARAMETERS[spell_type].ldam; |
| | |
/* now based on caster's level instead of on op's level and caster's * | | /* now based on caster's level instead of on op's level and caster's * |
* path modifiers. --DAMN */ | | * path modifiers. --DAMN */ |
int SP_level_strength_adjust(object *op, object *caster, int spell_type) | | int SP_level_strength_adjust(object *op, object *caster, int spell_type) |
{ int adj; | | { |
#ifdef ALLOW_SKILLS | | int level = casting_level (caster, spell_type); |
int level=SK_level(caster)+path_level_mod(caster, spell_type); | | int adj = (level-spells[spell_type].level); |
#else | | |
int level=caster->level+path_level_mod(caster, spell_type); | | |
#endif | | |
adj= (level-spells[spell_type].level); | | |
if(adj < 0) adj=0; | | if(adj < 0) adj=0; |
if(SP_PARAMETERS[spell_type].ldur) | | if(SP_PARAMETERS[spell_type].ldur) |
adj/=SP_PARAMETERS[spell_type].ldur; | | adj/=SP_PARAMETERS[spell_type].ldur; |
| | |
int SP_level_spellpoint_cost(object *op, object *caster, int spell_type) | | int SP_level_spellpoint_cost(object *op, object *caster, int spell_type) |
{ | | { |
spell *s=find_spell(spell_type); | | spell *s=find_spell(spell_type); |
# ifdef ALLOW_SKILLS | | int level = casting_level (caster, spell_type); |
int level=SK_level(op)+path_level_mod(caster, spell_type); | | |
#else | | |
int level=op->level+path_level_mod(caster, spell_type); | | |
#endif /* ALLOW_SKILLS */ | | |
#ifdef SPELLPOINT_LEVEL_DEPEND | | #ifdef SPELLPOINT_LEVEL_DEPEND |
int sp; | | int sp; |
if(SP_PARAMETERS[spell_type].spl) | | if(SP_PARAMETERS[spell_type].spl) |
| | |
the parts of the swarm. | | the parts of the swarm. |
| | |
Interface: | | Interface: |
op: the caster | | op: the owner |
| | caster: the caster (owner, wand, rod, scroll) |
dir: the direction everything will be fired in | | dir: the direction everything will be fired in |
swarm_type: the archetype that will be fired | | swarm_type: the archetype that will be fired |
spell_type: the spell type of the archetype that's fired | | spell_type: the spell type of the archetype that's fired |
| | |
*/ | | */ |
| | |
| | |
void fire_swarm (object *op, int dir, archetype *swarm_type, int spell_type, | | void fire_swarm (object *op, object *caster, int dir, archetype *swarm_type, |
int n, int magic) | | int spell_type, int n, int magic) |
{ | | { |
object *tmp; | | object *tmp; |
tmp=arch_to_object(find_archetype("swarm_spell")); | | tmp=get_archetype("swarm_spell"); |
tmp->x=op->x; | | tmp->x=op->x; |
tmp->y=op->y; | | tmp->y=op->y; |
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=op->level; /*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 */ |
tmp->magic = magic; | | tmp->magic = magic; |
tmp->stats.hp=n; /* n in swarm*/ | | tmp->stats.hp=n; /* n in swarm*/ |
| | |
return 0; | | return 0; |
| | |
/* tailor the effect by priest level and worshipped God */ | | /* tailor the effect by priest level and worshipped God */ |
effect->level=SK_level(op); | | effect->level = casting_level (caster, type); |
#ifdef MULTIPLE_GODS | | #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)) |