… | |
… | |
212 | LOG (llevError, "SP_level_spellpoint_cost: Unknown flags passed: %d\n", flags); |
212 | LOG (llevError, "SP_level_spellpoint_cost: Unknown flags passed: %d\n", flags); |
213 | return 0; |
213 | return 0; |
214 | } |
214 | } |
215 | } |
215 | } |
216 | |
216 | |
|
|
217 | /* |
|
|
218 | * Return the effective casting level of the spell. |
|
|
219 | */ |
|
|
220 | static int |
|
|
221 | SP_casting_level (object *caster, object *spell) |
|
|
222 | { |
|
|
223 | int level = caster_level (caster, spell); |
|
|
224 | return max (0, level - min_casting_level (caster, spell)); |
|
|
225 | } |
|
|
226 | |
217 | /* SP_level_dam_adjust: Returns adjusted damage based on the caster. |
227 | /* SP_level_dam_adjust: Returns adjusted damage based on the caster. |
218 | * spob is the spell we are adjusting. |
228 | * spob is the spell we are adjusting. |
219 | */ |
229 | */ |
220 | int |
230 | int |
221 | SP_level_dam_adjust (object *caster, object *spob) |
231 | SP_level_dam_adjust (object *caster, object *spob) |
222 | { |
232 | { |
223 | if (!spob->dam_modifier) |
233 | if (!spob->dam_modifier) |
224 | return 0; |
234 | return 0; |
225 | |
235 | |
226 | int level = caster_level (caster, spob); |
|
|
227 | return max (0, level - min_casting_level (caster, spob)) / spob->dam_modifier; |
236 | return SP_casting_level (caster, spob) / spob->dam_modifier; |
228 | } |
237 | } |
229 | |
238 | |
230 | /* Adjust the strength of the spell based on level. |
239 | /* Adjust the strength of the spell based on level. |
231 | * This is basically the same as SP_level_dam_adjust above, |
240 | * This is basically the same as SP_level_dam_adjust above, |
232 | * but instead looks at the level_modifier value. |
241 | * but instead looks at the level_modifier value. |
… | |
… | |
235 | SP_level_duration_adjust (object *caster, object *spob) |
244 | SP_level_duration_adjust (object *caster, object *spob) |
236 | { |
245 | { |
237 | if (!spob->duration_modifier) |
246 | if (!spob->duration_modifier) |
238 | return 0; |
247 | return 0; |
239 | |
248 | |
240 | int level = caster_level (caster, spob); |
|
|
241 | return max (0, level - min_casting_level (caster, spob)) / spob->duration_modifier; |
249 | return SP_casting_level (caster, spob) / spob->duration_modifier; |
242 | } |
250 | } |
243 | |
251 | |
244 | /* Adjust the strength of the spell based on level. |
252 | /* Adjust the strength of the spell based on level. |
245 | * This is basically the same as SP_level_dam_adjust above, |
253 | * This is basically the same as SP_level_dam_adjust above, |
246 | * but instead looks at the level_modifier value. |
254 | * but instead looks at the level_modifier value. |
… | |
… | |
250 | { |
258 | { |
251 | if (!spob->range_modifier) |
259 | if (!spob->range_modifier) |
252 | return 0; |
260 | return 0; |
253 | |
261 | |
254 | int level = caster_level (caster, spob); |
262 | int level = caster_level (caster, spob); |
255 | return (level - min_casting_level (caster, spob)) / spob->range_modifier; |
263 | return SP_casting_level (caster, spob) / spob->range_modifier; |
256 | } |
264 | } |
257 | |
265 | |
258 | /* Checks to see if player knows the spell. If the name is the same |
266 | /* Checks to see if player knows the spell. If the name is the same |
259 | * as an existing spell, we presume they know it. |
267 | * as an existing spell, we presume they know it. |
260 | * returns 1 if they know the spell, 0 if they don't. |
268 | * returns 1 if they know the spell, 0 if they don't. |
… | |
… | |
394 | { |
402 | { |
395 | if (!xy_normalise (m, x, y)) |
403 | if (!xy_normalise (m, x, y)) |
396 | return 0; |
404 | return 0; |
397 | |
405 | |
398 | mapspace &ms = m->at (x, y); |
406 | mapspace &ms = m->at (x, y); |
|
|
407 | ms.update (); |
399 | |
408 | |
400 | if (OB_TYPE_MOVE_BLOCK (op, ms.move_block)) |
409 | if (OB_TYPE_MOVE_BLOCK (op, ms.move_block)) |
401 | return 0; |
410 | return 0; |
402 | |
411 | |
403 | for (object *tmp = ms.bot; tmp; tmp = tmp->above) |
412 | for (object *tmp = ms.bot; tmp; tmp = tmp->above) |
… | |
… | |
476 | fire_arch_from_position (object *op, object *caster, sint16 x, sint16 y, int dir, object *spell) |
485 | fire_arch_from_position (object *op, object *caster, sint16 x, sint16 y, int dir, object *spell) |
477 | { |
486 | { |
478 | if (!spell->other_arch) |
487 | if (!spell->other_arch) |
479 | return 0; |
488 | return 0; |
480 | |
489 | |
481 | mapxy pos (op->map, x, y);//TODO, should not pass x, y |
|
|
482 | |
|
|
483 | pos.move (dir ? dir : rndm (1, 8)); |
|
|
484 | |
|
|
485 | if (!pos.normalise ()) |
|
|
486 | return 0; |
|
|
487 | |
|
|
488 | object *tmp = spell->other_arch->instance (); |
490 | object *tmp = spell->other_arch->instance (); |
489 | |
491 | |
490 | if (!tmp) |
492 | if (!tmp) |
491 | return 0; |
493 | return 0; |
492 | |
|
|
493 | if (pos.ms ().blocks (tmp)) |
|
|
494 | { |
|
|
495 | new_draw_info (NDI_UNIQUE, 0, op, "You can't cast this spell on top of a wall!\n"); |
|
|
496 | tmp->destroy (); |
|
|
497 | return 0; |
|
|
498 | } |
|
|
499 | |
494 | |
500 | tmp->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
495 | tmp->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
501 | tmp->duration = spell->duration + SP_level_duration_adjust (caster, spell); |
496 | tmp->duration = spell->duration + SP_level_duration_adjust (caster, spell); |
502 | /* code in time.c uses food for some things, duration for others */ |
497 | /* code in time.c uses food for some things, duration for others */ |
503 | tmp->stats.food = tmp->duration; |
498 | tmp->stats.food = tmp->duration; |
504 | tmp->range = spell->range + SP_level_range_adjust (caster, spell); |
499 | tmp->range = spell->range + SP_level_range_adjust (caster, spell); |
505 | tmp->attacktype = spell->attacktype; |
500 | tmp->attacktype = spell->attacktype; |
506 | tmp->x = x; |
|
|
507 | tmp->y = y; |
|
|
508 | tmp->direction = dir; |
501 | tmp->direction = dir; |
509 | tmp->set_owner (op); |
502 | tmp->set_owner (op); |
510 | tmp->level = caster_level (caster, spell); |
503 | tmp->level = caster_level (caster, spell); |
511 | set_spell_skill (op, caster, spell, tmp); |
504 | set_spell_skill (op, caster, spell, tmp); |
512 | |
505 | |
… | |
… | |
1450 | check_bullet (op); |
1443 | check_bullet (op); |
1451 | return; |
1444 | return; |
1452 | } |
1445 | } |
1453 | } |
1446 | } |
1454 | |
1447 | |
1455 | /* This is called by move_apply. Basically, if someone |
1448 | /* This is called by move_apply. Basically, if someone |
1456 | * moves onto a spell effect and the walk_on or fly_on flags |
1449 | * moves onto a spell effect and the walk_on or fly_on flags |
1457 | * are set, this is called. This should only be called for |
1450 | * are set, this is called. This should only be called for |
1458 | * objects of the appropraite type. |
1451 | * objects of the appropriate type. |
1459 | */ |
1452 | */ |
1460 | void |
1453 | void |
1461 | apply_spell_effect (object *spell, object *victim) |
1454 | apply_spell_effect (object *spell, object *victim) |
1462 | { |
1455 | { |
1463 | switch (spell->subtype) |
1456 | switch (spell->subtype) |