--- deliantra/server/server/spell_util.C 2008/09/29 06:32:09 1.79 +++ deliantra/server/server/spell_util.C 2008/09/29 08:25:02 1.80 @@ -87,6 +87,16 @@ map->insert (arch_to_object (spob->other_arch), x, y, originator); } +static int +attuned_bonus (object *caster, object *spell, int level) +{ + // compute the attuned/repelled bonus + // attuned only increases up to 2 times the original level (i.e. bonus <= level) */ + // repell has no such quarrels + return (caster->path_attuned & spell->path_attuned ? min (level, +ATTUNE_REPELL) : 0) + + (caster->path_repelled & spell->path_attuned ? -ATTUNE_REPELL : 0); +} + /* * This function takes a caster and spell and presents the * effective level the caster needs to be to cast the spell. @@ -101,13 +111,9 @@ min_casting_level (object *caster, object *spell) { if (caster->path_denied & spell->path_attuned) - return 1; - - int new_level = spell->level - + (caster->path_repelled & spell->path_attuned ? +ATTUNE_REPELL : 0) - + (caster->path_attuned & spell->path_attuned ? -ATTUNE_REPELL : 0); + return 500; - return max (1, new_level); + return max (1, spell->level + attuned_bonus (caster, spell, spell->level)); } /* This function returns the effective level the spell @@ -130,19 +136,14 @@ if (object *skill = caster->contr->find_skill (spell->skill)) level = skill->level; + int bonus = attuned_bonus (caster, spell, level); + + level += bonus; + // now scale the effective level from the startinglevel..100 range to 1..100 if (level < 100) level = lerp (level, (int)spell->level, 100, 1, 100); - /* Got valid caster level. Now adjust for attunement */ - // attuned only increases up to 2 times the original level */ - if (caster->path_attuned & spell->path_attuned) - level = min (level * 2, level + ATTUNE_REPELL); - - // repell has no such quarrels - if (caster->path_repelled & spell->path_attuned) - level -= ATTUNE_REPELL; - /* Always make this at least 1. If this is zero, we get divide by zero * errors in various places. */ @@ -279,7 +280,6 @@ return 0; } - /* * Look at object 'op' and see if they know the spell * spname. This is pretty close to check_spell_known @@ -288,7 +288,6 @@ * If we match multiple spells but don't get an * exact match, we also return NULL. */ - object * lookup_spell_by_name (object *op, const char *spname) { @@ -998,7 +997,7 @@ if (op->path_attuned & spell_ob->path_attuned) { - caster_level += ATTUNE_REPELL; + caster_level += min (cast_level * 2, ATTUNE_REPELL); msg = " (attuned)"; } @@ -1008,13 +1007,11 @@ msg = " (repelled)"; } - int casting_level = min_casting_level (op, spell_ob); - - if (casting_level > caster_level) + if (spell_ob->level > caster_level) { op->failmsg (format ("You lack enough skill to cast that spell! " "H", - caster_level, msg, casting_level)); + caster_level, msg, spell_ob->level)); if (!op->is_wiz ()) return 0; }