ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/spell_util.C
(Generate patch)

Comparing deliantra/server/server/spell_util.C (file contents):
Revision 1.79 by root, Mon Sep 29 06:32:09 2008 UTC vs.
Revision 1.83 by root, Mon Sep 29 11:52:34 2008 UTC

85{ 85{
86 if (spob->other_arch) 86 if (spob->other_arch)
87 map->insert (arch_to_object (spob->other_arch), x, y, originator); 87 map->insert (arch_to_object (spob->other_arch), x, y, originator);
88} 88}
89 89
90/* 90static int
91 * This function takes a caster and spell and presents the 91attuned_bonus (object *caster, object *spell, int level)
92 * effective level the caster needs to be to cast the spell.
93 * basically, it just adjusts the spell->level with attuned/repelled
94 * spellpaths. Was called path_level_mod.
95 *
96 * caster is person casting the spell.
97 * spell is the spell object.
98 * Returns modified level.
99 */
100int
101min_casting_level (object *caster, object *spell)
102{ 92{
103 if (caster->path_denied & spell->path_attuned) 93 // compute the attuned/repelled bonus
104 return 1; 94 // attuned only increases up to 2 times the original level (i.e. bonus <= level) */
105 95 // repell has no such quarrels
106 int new_level = spell->level 96 return (caster->path_attuned & spell->path_attuned ? min (level, +ATTUNE_REPELL) : 0)
107 + (caster->path_repelled & spell->path_attuned ? +ATTUNE_REPELL : 0) 97 + (caster->path_repelled & spell->path_attuned ? -ATTUNE_REPELL : 0);
108 + (caster->path_attuned & spell->path_attuned ? -ATTUNE_REPELL : 0);
109
110 return max (1, new_level);
111} 98}
112 99
113/* This function returns the effective level the spell 100/* This function returns the effective level the spell
114 * is being cast at. 101 * is being cast at.
115 */ 102 */
128 } 115 }
129 else if (caster->type == PLAYER) /* If this is a player, try to find the matching skill */ 116 else if (caster->type == PLAYER) /* If this is a player, try to find the matching skill */
130 if (object *skill = caster->contr->find_skill (spell->skill)) 117 if (object *skill = caster->contr->find_skill (spell->skill))
131 level = skill->level; 118 level = skill->level;
132 119
120 int bonus = attuned_bonus (caster, spell, level);
121
122 level += bonus;
123
133 // now scale the effective level from the startinglevel..100 range to 1..100 124 // now scale the effective level from the startinglevel..100 range to 1..100
134 if (level < 100) 125 if (level < 100)
135 level = lerp (level, (int)spell->level, 100, 1, 100); 126 level = lerp (level, (int)spell->level, 100, 1, 100);
136
137 /* Got valid caster level. Now adjust for attunement */
138 // attuned only increases up to 2 times the original level */
139 if (caster->path_attuned & spell->path_attuned)
140 level = min (level * 2, level + ATTUNE_REPELL);
141
142 // repell has no such quarrels
143 if (caster->path_repelled & spell->path_attuned)
144 level -= ATTUNE_REPELL;
145 127
146 /* Always make this at least 1. If this is zero, we get divide by zero 128 /* Always make this at least 1. If this is zero, we get divide by zero
147 * errors in various places. 129 * errors in various places.
148 */ 130 */
149 return max (level, 1); 131 return max (level, 1);
277 return spop; 259 return spop;
278 260
279 return 0; 261 return 0;
280} 262}
281 263
282
283/* 264/*
284 * Look at object 'op' and see if they know the spell 265 * Look at object 'op' and see if they know the spell
285 * spname. This is pretty close to check_spell_known 266 * spname. This is pretty close to check_spell_known
286 * above, but it uses a looser matching mechanism. 267 * above, but it uses a looser matching mechanism.
287 * returns the matching spell object, or NULL. 268 * returns the matching spell object, or NULL.
288 * If we match multiple spells but don't get an 269 * If we match multiple spells but don't get an
289 * exact match, we also return NULL. 270 * exact match, we also return NULL.
290 */ 271 */
291
292object * 272object *
293lookup_spell_by_name (object *op, const char *spname) 273lookup_spell_by_name (object *op, const char *spname)
294{ 274{
295 object *spob1 = NULL, *spob2 = NULL, *spob; 275 object *spob1 = NULL, *spob2 = NULL, *spob;
296 int nummatch = 0; 276 int nummatch = 0;
996 976
997 int caster_level = skill->level; 977 int caster_level = skill->level;
998 978
999 if (op->path_attuned & spell_ob->path_attuned) 979 if (op->path_attuned & spell_ob->path_attuned)
1000 { 980 {
1001 caster_level += ATTUNE_REPELL; 981 caster_level += min (cast_level * 2, ATTUNE_REPELL);
1002 msg = " (attuned)"; 982 msg = " (attuned)";
1003 } 983 }
1004 984
1005 if (op->path_repelled & spell_ob->path_attuned) 985 if (op->path_repelled & spell_ob->path_attuned)
1006 { 986 {
1007 caster_level = ATTUNE_REPELL; // negative is ok 987 caster_level = ATTUNE_REPELL; // negative is ok
1008 msg = " (repelled)"; 988 msg = " (repelled)";
1009 } 989 }
1010 990
1011 int casting_level = min_casting_level (op, spell_ob);
1012
1013 if (casting_level > caster_level) 991 if (spell_ob->level > caster_level)
1014 { 992 {
1015 op->failmsg (format ("You lack enough skill to cast that spell! " 993 op->failmsg (format ("You lack enough skill to cast that spell! "
1016 "H<Your effective cast level is %d%s, but level %d is required.>", 994 "H<Your effective cast level is %d%s, but level %d is required.>",
1017 caster_level, msg, casting_level)); 995 caster_level, msg, spell_ob->level));
1018 if (!op->is_wiz ()) 996 if (!op->is_wiz ())
1019 return 0; 997 return 0;
1020 } 998 }
1021 } 999 }
1022 1000
1475 1453
1476 case SP_MAGIC_MISSILE: 1454 case SP_MAGIC_MISSILE:
1477 if (QUERY_FLAG (victim, FLAG_ALIVE)) 1455 if (QUERY_FLAG (victim, FLAG_ALIVE))
1478 { 1456 {
1479 hit_player (victim, spell->stats.dam, spell, spell->attacktype, 1); 1457 hit_player (victim, spell->stats.dam, spell, spell->attacktype, 1);
1480
1481 if (!spell->destroyed ())
1482 spell->destroy (); 1458 spell->destroy ();
1483 } 1459 }
1484 break; 1460 break;
1485 1461
1486 case SP_MOVING_BALL: 1462 case SP_MOVING_BALL:
1487 if (QUERY_FLAG (victim, FLAG_ALIVE)) 1463 if (QUERY_FLAG (victim, FLAG_ALIVE))
1488 hit_player (victim, spell->stats.dam, spell, spell->attacktype, 1); 1464 hit_player (victim, spell->stats.dam, spell, spell->attacktype, 1);
1489 else if (victim->materialname) 1465 else if (victim->materialname)
1490 save_throw_object (victim, spell->attacktype, spell); 1466 save_throw_object (victim, spell->attacktype, spell);
1491 break;
1492 }
1493}
1494 1467
1468 break;
1469 }
1470}
1471

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines