1 | |
|
|
2 | /* |
|
|
3 | * static char *rcsid_spell_attack_c = |
|
|
4 | * "$Id: spell_attack.C,v 1.9 2006/09/10 15:59:57 root Exp $"; |
|
|
5 | */ |
|
|
6 | |
|
|
7 | |
|
|
8 | /* |
1 | /* |
9 | CrossFire, A Multiplayer game for X-windows |
2 | CrossFire, A Multiplayer game for X-windows |
10 | |
3 | |
11 | Copyright (C) 2002-2003 Mark Wedel & Crossfire Development Team |
4 | Copyright (C) 2002-2003 Mark Wedel & Crossfire Development Team |
12 | Copyright (C) 1992 Frank Tore Johansen |
5 | Copyright (C) 1992 Frank Tore Johansen |
… | |
… | |
23 | |
16 | |
24 | You should have received a copy of the GNU General Public License |
17 | You should have received a copy of the GNU General Public License |
25 | along with this program; if not, write to the Free Software |
18 | along with this program; if not, write to the Free Software |
26 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
27 | |
20 | |
28 | The authors can be reached via e-mail at crossfire-devel@real-time.com |
21 | The authors can be reached via e-mail at <crossfire@schmorp.de> |
29 | */ |
22 | */ |
30 | |
23 | |
31 | /* This file contains all the spell attack code. Grouping this code |
24 | /* This file contains all the spell attack code. Grouping this code |
32 | * together should hopefully make it easier to find the relevent bits |
25 | * together should hopefully make it easier to find the relevent bits |
33 | * of code |
26 | * of code |
… | |
… | |
124 | void |
117 | void |
125 | forklightning (object *op, object *tmp) |
118 | forklightning (object *op, object *tmp) |
126 | { |
119 | { |
127 | int new_dir = 1; /* direction or -1 for left, +1 for right 0 if no new bolt */ |
120 | int new_dir = 1; /* direction or -1 for left, +1 for right 0 if no new bolt */ |
128 | int t_dir; /* stores temporary dir calculation */ |
121 | int t_dir; /* stores temporary dir calculation */ |
129 | mapstruct *m; |
122 | maptile *m; |
130 | sint16 sx, sy; |
123 | sint16 sx, sy; |
131 | object *new_bolt; |
124 | object *new_bolt; |
132 | |
125 | |
133 | /* pick a fork direction. tmp->stats.Con is the left bias |
126 | /* pick a fork direction. tmp->stats.Con is the left bias |
134 | * i.e., the chance in 100 of forking LEFT |
127 | * i.e., the chance in 100 of forking LEFT |
… | |
… | |
147 | |
140 | |
148 | if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (m, sx, sy))) |
141 | if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (m, sx, sy))) |
149 | return; |
142 | return; |
150 | |
143 | |
151 | /* OK, we made a fork */ |
144 | /* OK, we made a fork */ |
152 | new_bolt = get_object (); |
145 | new_bolt = object::create (); |
153 | copy_object (tmp, new_bolt); |
146 | tmp->copy_to (new_bolt); |
154 | |
147 | |
155 | /* reduce chances of subsequent forking */ |
148 | /* reduce chances of subsequent forking */ |
156 | new_bolt->stats.Dex -= 10; |
149 | new_bolt->stats.Dex -= 10; |
157 | tmp->stats.Dex -= 10; /* less forks from main bolt too */ |
150 | tmp->stats.Dex -= 10; /* less forks from main bolt too */ |
158 | new_bolt->stats.Con += 25 * new_dir; /* adjust the left bias */ |
151 | new_bolt->stats.Con += 25 * new_dir; /* adjust the left bias */ |
… | |
… | |
177 | move_bolt (object *op) |
170 | move_bolt (object *op) |
178 | { |
171 | { |
179 | object *tmp; |
172 | object *tmp; |
180 | int mflags; |
173 | int mflags; |
181 | sint16 x, y; |
174 | sint16 x, y; |
182 | mapstruct *m; |
175 | maptile *m; |
183 | |
176 | |
184 | if (--(op->duration) < 0) |
177 | if (--(op->duration) < 0) |
185 | { |
178 | { |
186 | remove_ob (op); |
179 | op->destroy (); |
187 | free_object (op); |
|
|
188 | return; |
180 | return; |
189 | } |
181 | } |
|
|
182 | |
190 | hit_map (op, 0, op->attacktype, 1); |
183 | hit_map (op, 0, op->attacktype, 1); |
191 | |
184 | |
192 | if (!op->direction) |
185 | if (!op->direction) |
193 | return; |
186 | return; |
194 | |
187 | |
… | |
… | |
256 | update_turn_face (op); /* A bolt *must* be IS_TURNABLE */ |
249 | update_turn_face (op); /* A bolt *must* be IS_TURNABLE */ |
257 | return; |
250 | return; |
258 | } |
251 | } |
259 | else |
252 | else |
260 | { /* Create a copy of this object and put it ahead */ |
253 | { /* Create a copy of this object and put it ahead */ |
261 | tmp = get_object (); |
254 | tmp = object::create (); |
262 | copy_object (op, tmp); |
255 | op->copy_to (tmp); |
263 | tmp->speed_left = -0.1; |
256 | tmp->speed_left = -0.1; |
264 | tmp->x += DIRX (tmp), tmp->y += DIRY (tmp); |
257 | tmp->x += DIRX (tmp), tmp->y += DIRY (tmp); |
265 | tmp = insert_ob_in_map (tmp, op->map, op, 0); |
258 | tmp = insert_ob_in_map (tmp, op->map, op, 0); |
266 | /* To make up for the decrease at the top of the function */ |
259 | /* To make up for the decrease at the top of the function */ |
267 | tmp->duration++; |
260 | tmp->duration++; |
… | |
… | |
326 | tmp->map = op->map; |
319 | tmp->map = op->map; |
327 | |
320 | |
328 | mflags = get_map_flags (tmp->map, &tmp->map, tmp->x, tmp->y, &tmp->x, &tmp->y); |
321 | mflags = get_map_flags (tmp->map, &tmp->map, tmp->x, tmp->y, &tmp->x, &tmp->y); |
329 | if (mflags & P_OUT_OF_MAP) |
322 | if (mflags & P_OUT_OF_MAP) |
330 | { |
323 | { |
331 | free_object (tmp); |
324 | tmp->destroy (); |
332 | return 0; |
325 | return 0; |
333 | } |
326 | } |
|
|
327 | |
334 | if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y))) |
328 | if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y))) |
335 | { |
329 | { |
336 | if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) |
330 | if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) |
337 | { |
331 | { |
338 | free_object (tmp); |
332 | tmp->destroy (); |
339 | return 0; |
333 | return 0; |
340 | } |
334 | } |
|
|
335 | |
341 | tmp->x = op->x; |
336 | tmp->x = op->x; |
342 | tmp->y = op->y; |
337 | tmp->y = op->y; |
343 | tmp->direction = absdir (tmp->direction + 4); |
338 | tmp->direction = absdir (tmp->direction + 4); |
344 | tmp->map = op->map; |
339 | tmp->map = op->map; |
345 | } |
340 | } |
|
|
341 | |
346 | if ((tmp = insert_ob_in_map (tmp, tmp->map, op, 0)) != NULL) |
342 | if ((tmp = insert_ob_in_map (tmp, tmp->map, op, 0)) != NULL) |
347 | move_bolt (tmp); |
343 | move_bolt (tmp); |
|
|
344 | |
348 | return 1; |
345 | return 1; |
349 | } |
346 | } |
350 | |
347 | |
351 | |
348 | |
352 | |
349 | |
… | |
… | |
362 | */ |
359 | */ |
363 | void |
360 | void |
364 | explosion (object *op) |
361 | explosion (object *op) |
365 | { |
362 | { |
366 | object *tmp; |
363 | object *tmp; |
367 | mapstruct *m = op->map; |
364 | maptile *m = op->map; |
368 | int i; |
365 | int i; |
369 | |
366 | |
370 | if (--(op->duration) < 0) |
367 | if (--(op->duration) < 0) |
371 | { |
368 | { |
372 | remove_ob (op); |
369 | op->destroy (); |
373 | free_object (op); |
|
|
374 | return; |
370 | return; |
375 | } |
371 | } |
|
|
372 | |
376 | hit_map (op, 0, op->attacktype, 0); |
373 | hit_map (op, 0, op->attacktype, 0); |
377 | |
374 | |
378 | if (op->range > 0) |
375 | if (op->range > 0) |
379 | { |
376 | { |
380 | for (i = 1; i < 9; i++) |
377 | for (i = 1; i < 9; i++) |
… | |
… | |
386 | /* ok_to_put_more already does things like checks for walls, |
383 | /* ok_to_put_more already does things like checks for walls, |
387 | * out of map, etc. |
384 | * out of map, etc. |
388 | */ |
385 | */ |
389 | if (ok_to_put_more (op->map, dx, dy, op, op->attacktype)) |
386 | if (ok_to_put_more (op->map, dx, dy, op, op->attacktype)) |
390 | { |
387 | { |
391 | tmp = get_object (); |
388 | tmp = object::create (); |
392 | copy_object (op, tmp); |
389 | op->copy_to (tmp); |
393 | tmp->state = 0; |
390 | tmp->state = 0; |
394 | tmp->speed_left = -0.21; |
391 | tmp->speed_left = -0.21; |
395 | tmp->range--; |
392 | tmp->range--; |
396 | tmp->value = 0; |
393 | tmp->value = 0; |
397 | tmp->x = dx; |
394 | tmp->x = dx; |
… | |
… | |
408 | * explode. |
405 | * explode. |
409 | */ |
406 | */ |
410 | void |
407 | void |
411 | explode_bullet (object *op) |
408 | explode_bullet (object *op) |
412 | { |
409 | { |
413 | tag_t op_tag = op->count; |
|
|
414 | object *tmp, *owner; |
410 | object *tmp, *owner; |
415 | |
411 | |
416 | if (op->other_arch == NULL) |
412 | if (op->other_arch == NULL) |
417 | { |
413 | { |
418 | LOG (llevError, "BUG: explode_bullet(): op without other_arch\n"); |
414 | LOG (llevError, "BUG: explode_bullet(): op without other_arch\n"); |
419 | remove_ob (op); |
415 | op->destroy (); |
420 | free_object (op); |
|
|
421 | return; |
416 | return; |
422 | } |
417 | } |
423 | |
418 | |
424 | if (op->env) |
419 | if (op->env) |
425 | { |
420 | { |
… | |
… | |
427 | |
422 | |
428 | env = object_get_env_recursive (op); |
423 | env = object_get_env_recursive (op); |
429 | if (env->map == NULL || out_of_map (env->map, env->x, env->y)) |
424 | if (env->map == NULL || out_of_map (env->map, env->x, env->y)) |
430 | { |
425 | { |
431 | LOG (llevError, "BUG: explode_bullet(): env out of map\n"); |
426 | LOG (llevError, "BUG: explode_bullet(): env out of map\n"); |
432 | remove_ob (op); |
427 | op->destroy (); |
433 | free_object (op); |
|
|
434 | return; |
428 | return; |
435 | } |
429 | } |
|
|
430 | |
436 | remove_ob (op); |
431 | op->remove (); |
437 | op->x = env->x; |
432 | op->x = env->x; |
438 | op->y = env->y; |
433 | op->y = env->y; |
439 | insert_ob_in_map (op, env->map, op, INS_NO_MERGE | INS_NO_WALK_ON); |
434 | insert_ob_in_map (op, env->map, op, INS_NO_MERGE | INS_NO_WALK_ON); |
440 | } |
435 | } |
441 | else if (out_of_map (op->map, op->x, op->y)) |
436 | else if (out_of_map (op->map, op->x, op->y)) |
442 | { |
437 | { |
443 | LOG (llevError, "BUG: explode_bullet(): op out of map\n"); |
438 | LOG (llevError, "BUG: explode_bullet(): op out of map\n"); |
444 | remove_ob (op); |
439 | op->destroy (); |
445 | free_object (op); |
|
|
446 | return; |
440 | return; |
447 | } |
441 | } |
448 | |
442 | |
449 | // elmex Tue Aug 15 17:46:51 CEST 2006: Prevent explosions of any kind on safe maps |
443 | // elmex Tue Aug 15 17:46:51 CEST 2006: Prevent explosions of any kind on safe maps |
450 | // NOTE: If this breaks something important: remove this. I can't think of anything |
444 | // NOTE: If this breaks something important: remove this. I can't think of anything |
451 | // bad at the moment that might happen from this. |
445 | // bad at the moment that might happen from this. |
452 | if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) |
446 | if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) |
453 | { |
447 | { |
454 | remove_ob (op); |
448 | op->destroy (); |
455 | free_object (op); |
|
|
456 | return; |
449 | return; |
457 | } |
450 | } |
458 | |
451 | |
459 | if (op->attacktype) |
452 | if (op->attacktype) |
460 | { |
453 | { |
461 | hit_map (op, 0, op->attacktype, 1); |
454 | hit_map (op, 0, op->attacktype, 1); |
462 | if (was_destroyed (op, op_tag)) |
455 | if (op->destroyed ()) |
463 | return; |
456 | return; |
464 | } |
457 | } |
465 | |
458 | |
466 | /* other_arch contains what this explodes into */ |
459 | /* other_arch contains what this explodes into */ |
467 | tmp = arch_to_object (op->other_arch); |
460 | tmp = arch_to_object (op->other_arch); |
468 | |
461 | |
469 | copy_owner (tmp, op); |
462 | copy_owner (tmp, op); |
470 | tmp->skill = op->skill; |
463 | tmp->skill = op->skill; |
471 | |
464 | |
472 | owner = get_owner (op); |
465 | owner = get_owner (op); |
|
|
466 | |
473 | if ((tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER) && owner && !tailor_god_spell (tmp, owner)) |
467 | if ((tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER) && owner && !tailor_god_spell (tmp, owner)) |
474 | { |
468 | { |
475 | remove_ob (op); |
469 | op->destroy (); |
476 | free_object (op); |
|
|
477 | return; |
470 | return; |
478 | } |
471 | } |
|
|
472 | |
479 | tmp->x = op->x; |
473 | tmp->x = op->x; |
480 | tmp->y = op->y; |
474 | tmp->y = op->y; |
481 | |
475 | |
482 | /* special for bombs - it actually has sane values for these */ |
476 | /* special for bombs - it actually has sane values for these */ |
483 | if (op->type == SPELL_EFFECT && op->subtype == SP_BOMB) |
477 | if (op->type == SPELL_EFFECT && op->subtype == SP_BOMB) |
… | |
… | |
508 | /* Prevent recursion */ |
502 | /* Prevent recursion */ |
509 | op->move_on = 0; |
503 | op->move_on = 0; |
510 | |
504 | |
511 | insert_ob_in_map (tmp, op->map, op, 0); |
505 | insert_ob_in_map (tmp, op->map, op, 0); |
512 | /* remove the firebullet */ |
506 | /* remove the firebullet */ |
513 | if (!was_destroyed (op, op_tag)) |
507 | if (!op->destroyed ()) |
514 | { |
508 | { |
515 | remove_ob (op); |
509 | op->destroy (); |
516 | free_object (op); |
|
|
517 | } |
510 | } |
518 | } |
511 | } |
519 | |
512 | |
520 | |
513 | |
521 | |
514 | |
… | |
… | |
524 | */ |
517 | */ |
525 | |
518 | |
526 | void |
519 | void |
527 | check_bullet (object *op) |
520 | check_bullet (object *op) |
528 | { |
521 | { |
529 | tag_t op_tag = op->count, tmp_tag; |
|
|
530 | object *tmp; |
522 | object *tmp; |
531 | int dam, mflags; |
523 | int dam, mflags; |
532 | mapstruct *m; |
524 | maptile *m; |
533 | sint16 sx, sy; |
525 | sint16 sx, sy; |
534 | |
526 | |
535 | mflags = get_map_flags (op->map, &m, op->x, op->y, &sx, &sy); |
527 | mflags = get_map_flags (op->map, &m, op->x, op->y, &sx, &sy); |
536 | |
528 | |
537 | if (!(mflags & P_IS_ALIVE) && !OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy))) |
529 | if (!(mflags & P_IS_ALIVE) && !OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy))) |
… | |
… | |
550 | |
542 | |
551 | for (tmp = get_map_ob (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) |
543 | for (tmp = get_map_ob (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) |
552 | { |
544 | { |
553 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
545 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
554 | { |
546 | { |
555 | tmp_tag = tmp->count; |
|
|
556 | dam = hit_player (tmp, op->stats.dam, op, op->attacktype, 1); |
547 | dam = hit_player (tmp, op->stats.dam, op, op->attacktype, 1); |
557 | if (was_destroyed (op, op_tag) || !was_destroyed (tmp, tmp_tag) || (op->stats.dam -= dam) < 0) |
548 | if (op->destroyed () || !tmp->destroyed () || (op->stats.dam -= dam) < 0) |
558 | { |
549 | { |
559 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
550 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
560 | { |
551 | { |
561 | remove_ob (op); |
552 | op->destroy (); |
562 | free_object (op); |
|
|
563 | return; |
553 | return; |
564 | } |
554 | } |
565 | } |
555 | } |
566 | } |
556 | } |
567 | } |
557 | } |
… | |
… | |
577 | void |
567 | void |
578 | move_bullet (object *op) |
568 | move_bullet (object *op) |
579 | { |
569 | { |
580 | sint16 new_x, new_y; |
570 | sint16 new_x, new_y; |
581 | int mflags; |
571 | int mflags; |
582 | mapstruct *m; |
572 | maptile *m; |
583 | |
573 | |
584 | #if 0 |
574 | #if 0 |
585 | /* We need a better general purpose way to do this */ |
575 | /* We need a better general purpose way to do this */ |
586 | |
576 | |
587 | /* peterm: added to make comet leave a trail of burnouts |
577 | /* peterm: added to make comet leave a trail of burnouts |
588 | it's an unadulterated hack, but the effect is cool. */ |
578 | it's an unadulterated hack, but the effect is cool. */ |
589 | if (op->stats.sp == SP_METEOR) |
579 | if (op->stats.sp == SP_METEOR) |
590 | { |
580 | { |
591 | replace_insert_ob_in_map ("fire_trail", op); |
581 | replace_insert_ob_in_map ("fire_trail", op); |
592 | if (was_destroyed (op, op_tag)) |
582 | if (op->destroyed ()) |
593 | return; |
583 | return; |
594 | } /* end addition. */ |
584 | } /* end addition. */ |
595 | #endif |
585 | #endif |
596 | |
586 | |
597 | /* Reached the end of its life - remove it */ |
587 | /* Reached the end of its life - remove it */ |
598 | if (--op->range <= 0) |
588 | if (--op->range <= 0) |
599 | { |
589 | { |
600 | if (op->other_arch) |
590 | if (op->other_arch) |
601 | { |
|
|
602 | explode_bullet (op); |
591 | explode_bullet (op); |
603 | } |
|
|
604 | else |
592 | else |
605 | { |
593 | op->destroy (); |
606 | remove_ob (op); |
594 | |
607 | free_object (op); |
|
|
608 | } |
|
|
609 | return; |
595 | return; |
610 | } |
596 | } |
611 | |
597 | |
612 | new_x = op->x + DIRX (op); |
598 | new_x = op->x + DIRX (op); |
613 | new_y = op->y + DIRY (op); |
599 | new_y = op->y + DIRY (op); |
614 | m = op->map; |
600 | m = op->map; |
615 | mflags = get_map_flags (m, &m, new_x, new_y, &new_x, &new_y); |
601 | mflags = get_map_flags (m, &m, new_x, new_y, &new_x, &new_y); |
616 | |
602 | |
617 | if (mflags & P_OUT_OF_MAP) |
603 | if (mflags & P_OUT_OF_MAP) |
618 | { |
604 | { |
619 | remove_ob (op); |
605 | op->destroy (); |
620 | free_object (op); |
|
|
621 | return; |
606 | return; |
622 | } |
607 | } |
623 | |
608 | |
624 | if (!op->direction || OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, new_x, new_y))) |
609 | if (!op->direction || OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, new_x, new_y))) |
625 | { |
610 | { |
626 | if (op->other_arch) |
611 | if (op->other_arch) |
627 | { |
|
|
628 | explode_bullet (op); |
612 | explode_bullet (op); |
629 | } |
|
|
630 | else |
613 | else |
631 | { |
614 | op->destroy (); |
632 | remove_ob (op); |
615 | |
633 | free_object (op); |
|
|
634 | } |
|
|
635 | return; |
616 | return; |
636 | } |
617 | } |
637 | |
618 | |
638 | remove_ob (op); |
619 | op->remove (); |
639 | op->x = new_x; |
620 | op->x = new_x; |
640 | op->y = new_y; |
621 | op->y = new_y; |
641 | if ((op = insert_ob_in_map (op, m, op, 0)) == NULL) |
622 | if ((op = insert_ob_in_map (op, m, op, 0)) == NULL) |
642 | return; |
623 | return; |
643 | |
624 | |
… | |
… | |
702 | tmp->map = op->map; |
683 | tmp->map = op->map; |
703 | |
684 | |
704 | mflags = get_map_flags (tmp->map, &tmp->map, tmp->x, tmp->y, &tmp->x, &tmp->y); |
685 | mflags = get_map_flags (tmp->map, &tmp->map, tmp->x, tmp->y, &tmp->x, &tmp->y); |
705 | if (mflags & P_OUT_OF_MAP) |
686 | if (mflags & P_OUT_OF_MAP) |
706 | { |
687 | { |
707 | free_object (tmp); |
688 | tmp->destroy (); |
708 | return 0; |
689 | return 0; |
709 | } |
690 | } |
|
|
691 | |
710 | if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y))) |
692 | if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y))) |
711 | { |
693 | { |
712 | if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) |
694 | if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) |
713 | { |
695 | { |
714 | free_object (tmp); |
696 | tmp->destroy (); |
715 | return 0; |
697 | return 0; |
716 | } |
698 | } |
|
|
699 | |
717 | tmp->x = op->x; |
700 | tmp->x = op->x; |
718 | tmp->y = op->y; |
701 | tmp->y = op->y; |
719 | tmp->direction = absdir (tmp->direction + 4); |
702 | tmp->direction = absdir (tmp->direction + 4); |
720 | tmp->map = op->map; |
703 | tmp->map = op->map; |
721 | } |
704 | } |
|
|
705 | |
722 | if ((tmp = insert_ob_in_map (tmp, tmp->map, op, 0)) != NULL) |
706 | if ((tmp = insert_ob_in_map (tmp, tmp->map, op, 0)) != NULL) |
723 | { |
|
|
724 | check_bullet (tmp); |
707 | check_bullet (tmp); |
725 | } |
708 | |
726 | return 1; |
709 | return 1; |
727 | } |
710 | } |
728 | |
711 | |
729 | |
712 | |
730 | |
713 | |
… | |
… | |
760 | |
743 | |
761 | void |
744 | void |
762 | move_cone (object *op) |
745 | move_cone (object *op) |
763 | { |
746 | { |
764 | int i; |
747 | int i; |
765 | tag_t tag; |
|
|
766 | |
748 | |
767 | /* if no map then hit_map will crash so just ignore object */ |
749 | /* if no map then hit_map will crash so just ignore object */ |
768 | if (!op->map) |
750 | if (!op->map) |
769 | { |
751 | { |
770 | LOG (llevError, "Tried to move_cone object %s without a map.\n", op->name ? &op->name : "unknown"); |
752 | LOG (llevError, "Tried to move_cone object %s without a map.\n", op->name ? &op->name : "unknown"); |
… | |
… | |
785 | * when their cone dies when they die. |
767 | * when their cone dies when they die. |
786 | */ |
768 | */ |
787 | /* If no owner left, the spell dies out. */ |
769 | /* If no owner left, the spell dies out. */ |
788 | if (get_owner (op) == NULL) |
770 | if (get_owner (op) == NULL) |
789 | { |
771 | { |
790 | remove_ob (op); |
772 | op->destroy (); |
791 | free_object (op); |
|
|
792 | return; |
773 | return; |
793 | } |
774 | } |
794 | #endif |
775 | #endif |
795 | |
776 | |
796 | tag = op->count; |
|
|
797 | hit_map (op, 0, op->attacktype, 0); |
777 | hit_map (op, 0, op->attacktype, 0); |
798 | |
778 | |
799 | /* Check to see if we should push anything. |
779 | /* Check to see if we should push anything. |
800 | * Spell objects with weight push whatever they encounter to some |
780 | * Spell objects with weight push whatever they encounter to some |
801 | * degree. |
781 | * degree. |
802 | */ |
782 | */ |
803 | if (op->weight) |
783 | if (op->weight) |
804 | check_spell_knockback (op); |
784 | check_spell_knockback (op); |
805 | |
785 | |
806 | if (was_destroyed (op, tag)) |
786 | if (op->destroyed ()) |
807 | return; |
787 | return; |
808 | |
788 | |
809 | if ((op->duration--) < 0) |
789 | if ((op->duration--) < 0) |
810 | { |
790 | { |
811 | remove_ob (op); |
791 | op->destroy (); |
812 | free_object (op); |
|
|
813 | return; |
792 | return; |
814 | } |
793 | } |
815 | /* Object has hit maximum range, so don't have it move |
794 | /* Object has hit maximum range, so don't have it move |
816 | * any further. When the duration above expires, |
795 | * any further. When the duration above expires, |
817 | * then the object will get removed. |
796 | * then the object will get removed. |
… | |
… | |
826 | { |
805 | { |
827 | sint16 x = op->x + freearr_x[absdir (op->stats.sp + i)], y = op->y + freearr_y[absdir (op->stats.sp + i)]; |
806 | sint16 x = op->x + freearr_x[absdir (op->stats.sp + i)], y = op->y + freearr_y[absdir (op->stats.sp + i)]; |
828 | |
807 | |
829 | if (ok_to_put_more (op->map, x, y, op, op->attacktype)) |
808 | if (ok_to_put_more (op->map, x, y, op, op->attacktype)) |
830 | { |
809 | { |
831 | object *tmp = get_object (); |
810 | object *tmp = object::create (); |
832 | |
811 | |
833 | copy_object (op, tmp); |
812 | op->copy_to (tmp); |
834 | tmp->x = x; |
813 | tmp->x = x; |
835 | tmp->y = y; |
814 | tmp->y = y; |
836 | |
815 | |
837 | tmp->duration = op->duration + 1; |
816 | tmp->duration = op->duration + 1; |
838 | |
817 | |
… | |
… | |
856 | int |
835 | int |
857 | cast_cone (object *op, object *caster, int dir, object *spell) |
836 | cast_cone (object *op, object *caster, int dir, object *spell) |
858 | { |
837 | { |
859 | object *tmp; |
838 | object *tmp; |
860 | int i, success = 0, range_min = -1, range_max = 1; |
839 | int i, success = 0, range_min = -1, range_max = 1; |
861 | mapstruct *m; |
840 | maptile *m; |
862 | sint16 sx, sy; |
841 | sint16 sx, sy; |
863 | MoveType movetype; |
842 | MoveType movetype; |
864 | |
843 | |
865 | if (!spell->other_arch) |
844 | if (!spell->other_arch) |
866 | return 0; |
845 | return 0; |
… | |
… | |
931 | tmp->y = sy; |
910 | tmp->y = sy; |
932 | tmp->attacktype = spell->attacktype; |
911 | tmp->attacktype = spell->attacktype; |
933 | |
912 | |
934 | /* holy word stuff */ |
913 | /* holy word stuff */ |
935 | if ((tmp->attacktype & AT_HOLYWORD) || (tmp->attacktype & AT_GODPOWER)) |
914 | if ((tmp->attacktype & AT_HOLYWORD) || (tmp->attacktype & AT_GODPOWER)) |
936 | { |
|
|
937 | if (!tailor_god_spell (tmp, op)) |
915 | if (!tailor_god_spell (tmp, op)) |
938 | return 0; |
916 | return 0; |
939 | } |
|
|
940 | |
917 | |
941 | if (dir) |
918 | if (dir) |
942 | tmp->stats.sp = dir; |
919 | tmp->stats.sp = dir; |
943 | else |
920 | else |
944 | tmp->stats.sp = i; |
921 | tmp->stats.sp = i; |
… | |
… | |
950 | { |
927 | { |
951 | tmp->range /= 4; |
928 | tmp->range /= 4; |
952 | if (tmp->range < 2 && spell->range >= 2) |
929 | if (tmp->range < 2 && spell->range >= 2) |
953 | tmp->range = 2; |
930 | tmp->range = 2; |
954 | } |
931 | } |
|
|
932 | |
955 | tmp->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
933 | tmp->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
956 | tmp->duration = spell->duration + SP_level_duration_adjust (caster, spell); |
934 | tmp->duration = spell->duration + SP_level_duration_adjust (caster, spell); |
957 | |
935 | |
958 | /* Special bonus for fear attacks */ |
936 | /* Special bonus for fear attacks */ |
959 | if (tmp->attacktype & AT_FEAR) |
937 | if (tmp->attacktype & AT_FEAR) |
… | |
… | |
961 | if (caster->type == PLAYER) |
939 | if (caster->type == PLAYER) |
962 | tmp->duration += fear_bonus[caster->stats.Cha]; |
940 | tmp->duration += fear_bonus[caster->stats.Cha]; |
963 | else |
941 | else |
964 | tmp->duration += caster->level / 3; |
942 | tmp->duration += caster->level / 3; |
965 | } |
943 | } |
|
|
944 | |
966 | if (tmp->attacktype & (AT_HOLYWORD | AT_TURN_UNDEAD)) |
945 | if (tmp->attacktype & (AT_HOLYWORD | AT_TURN_UNDEAD)) |
967 | { |
946 | { |
968 | if (caster->type == PLAYER) |
947 | if (caster->type == PLAYER) |
969 | tmp->duration += turn_bonus[caster->stats.Wis] / 5; |
948 | tmp->duration += turn_bonus[caster->stats.Wis] / 5; |
970 | else |
949 | else |
971 | tmp->duration += caster->level / 3; |
950 | tmp->duration += caster->level / 3; |
972 | } |
951 | } |
973 | |
952 | |
974 | |
|
|
975 | if (!(tmp->move_type & MOVE_FLY_LOW)) |
953 | if (!(tmp->move_type & MOVE_FLY_LOW)) |
976 | LOG (llevDebug, "cast_cone(): arch %s doesn't have flying 1\n", &spell->other_arch->name); |
954 | LOG (llevDebug, "cast_cone(): arch %s doesn't have flying 1\n", &spell->other_arch->name); |
977 | |
955 | |
978 | if (!tmp->move_on && tmp->stats.dam) |
956 | if (!tmp->move_on && tmp->stats.dam) |
979 | { |
957 | { |
980 | LOG (llevDebug, "cast_cone(): arch %s doesn't have move_on set\n", &spell->other_arch->name); |
958 | LOG (llevDebug, "cast_cone(): arch %s doesn't have move_on set\n", &spell->other_arch->name); |
981 | } |
959 | } |
|
|
960 | |
982 | insert_ob_in_map (tmp, m, op, 0); |
961 | insert_ob_in_map (tmp, m, op, 0); |
983 | |
962 | |
984 | /* This is used for tracking spells so that one effect doesn't hit |
963 | /* This is used for tracking spells so that one effect doesn't hit |
985 | * a single space too many times. |
964 | * a single space too many times. |
986 | */ |
965 | */ |
987 | tmp->stats.maxhp = tmp->count; |
966 | tmp->stats.maxhp = tmp->count; |
988 | |
967 | |
989 | if (tmp->other_arch) |
968 | if (tmp->other_arch) |
990 | cone_drop (tmp); |
969 | cone_drop (tmp); |
991 | } |
970 | } |
|
|
971 | |
992 | return success; |
972 | return success; |
993 | } |
973 | } |
994 | |
974 | |
995 | /**************************************************************************** |
975 | /**************************************************************************** |
996 | * |
976 | * |
… | |
… | |
1010 | archetype *at; |
990 | archetype *at; |
1011 | |
991 | |
1012 | if (op->state != NUM_ANIMATIONS (op) - 1) |
992 | if (op->state != NUM_ANIMATIONS (op) - 1) |
1013 | return; |
993 | return; |
1014 | |
994 | |
1015 | |
|
|
1016 | env = object_get_env_recursive (op); |
995 | env = object_get_env_recursive (op); |
1017 | |
996 | |
1018 | if (op->env) |
997 | if (op->env) |
1019 | { |
998 | { |
1020 | if (env->map == NULL) |
999 | if (env->map == NULL) |
1021 | return; |
1000 | return; |
1022 | |
1001 | |
1023 | if (env->type == PLAYER) |
1002 | if (env->type == PLAYER) |
1024 | esrv_del_item (env->contr, op->count); |
1003 | esrv_del_item (env->contr, op->count); |
1025 | |
1004 | |
1026 | remove_ob (op); |
1005 | op->remove (); |
1027 | op->x = env->x; |
1006 | op->x = env->x; |
1028 | op->y = env->y; |
1007 | op->y = env->y; |
1029 | if ((op = insert_ob_in_map (op, env->map, op, 0)) == NULL) |
1008 | if ((op = insert_ob_in_map (op, env->map, op, 0)) == NULL) |
1030 | return; |
1009 | return; |
1031 | } |
1010 | } |
… | |
… | |
1033 | // elmex Tue Aug 15 17:46:51 CEST 2006: Prevent bomb from exploding |
1012 | // elmex Tue Aug 15 17:46:51 CEST 2006: Prevent bomb from exploding |
1034 | // on a safe map. I don't like this special casing, but it seems to be neccessary |
1013 | // on a safe map. I don't like this special casing, but it seems to be neccessary |
1035 | // as bombs can be carried. |
1014 | // as bombs can be carried. |
1036 | if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) |
1015 | if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) |
1037 | { |
1016 | { |
1038 | remove_ob (op); |
1017 | op->destroy (); |
1039 | free_object (op); |
|
|
1040 | return; |
1018 | return; |
1041 | } |
1019 | } |
1042 | |
1020 | |
1043 | /* This copies a lot of the code from the fire bullet, |
1021 | /* This copies a lot of the code from the fire bullet, |
1044 | * but using the cast_bullet isn't really feasible, |
1022 | * but using the cast_bullet isn't really feasible, |
1045 | * so just set up the appropriate values. |
1023 | * so just set up the appropriate values. |
1046 | */ |
1024 | */ |
1047 | at = find_archetype (SPLINT); |
1025 | at = archetype::find (SPLINT); |
1048 | if (at) |
1026 | if (at) |
1049 | { |
1027 | { |
1050 | for (i = 1; i < 9; i++) |
1028 | for (i = 1; i < 9; i++) |
1051 | { |
1029 | { |
1052 | if (out_of_map (op->map, op->x + freearr_x[i], op->y + freearr_x[i])) |
1030 | if (out_of_map (op->map, op->x + freearr_x[i], op->y + freearr_x[i])) |
… | |
… | |
1079 | { |
1057 | { |
1080 | |
1058 | |
1081 | object *tmp; |
1059 | object *tmp; |
1082 | int mflags; |
1060 | int mflags; |
1083 | sint16 dx = op->x + freearr_x[dir], dy = op->y + freearr_y[dir]; |
1061 | sint16 dx = op->x + freearr_x[dir], dy = op->y + freearr_y[dir]; |
1084 | mapstruct *m; |
1062 | maptile *m; |
1085 | |
1063 | |
1086 | mflags = get_map_flags (op->map, &m, dx, dy, &dx, &dy); |
1064 | mflags = get_map_flags (op->map, &m, dx, dy, &dx, &dy); |
1087 | if ((mflags & P_OUT_OF_MAP) || (GET_MAP_MOVE_BLOCK (m, dx, dy) & MOVE_WALK)) |
1065 | if ((mflags & P_OUT_OF_MAP) || (GET_MAP_MOVE_BLOCK (m, dx, dy) & MOVE_WALK)) |
1088 | { |
1066 | { |
1089 | new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way."); |
1067 | new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way."); |
… | |
… | |
1125 | get_pointed_target (object *op, int dir, int range, int type) |
1103 | get_pointed_target (object *op, int dir, int range, int type) |
1126 | { |
1104 | { |
1127 | object *target; |
1105 | object *target; |
1128 | sint16 x, y; |
1106 | sint16 x, y; |
1129 | int dist, mflags; |
1107 | int dist, mflags; |
1130 | mapstruct *mp; |
1108 | maptile *mp; |
1131 | |
1109 | |
1132 | if (dir == 0) |
1110 | if (dir == 0) |
1133 | return NULL; |
1111 | return NULL; |
1134 | |
1112 | |
1135 | for (dist = 1; dist < range; dist++) |
1113 | for (dist = 1; dist < range; dist++) |
… | |
… | |
1238 | } |
1216 | } |
1239 | else |
1217 | else |
1240 | { |
1218 | { |
1241 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s looks stronger!", query_name (target)); |
1219 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s looks stronger!", query_name (target)); |
1242 | target->stats.hp = target->stats.maxhp * 2; |
1220 | target->stats.hp = target->stats.maxhp * 2; |
1243 | free_object (effect); |
1221 | effect->destroy (); |
1244 | return 0; |
1222 | return 0; |
1245 | } |
1223 | } |
1246 | } |
1224 | } |
1247 | } |
1225 | } |
1248 | else |
1226 | else |
… | |
… | |
1275 | move_missile (object *op) |
1253 | move_missile (object *op) |
1276 | { |
1254 | { |
1277 | int i, mflags; |
1255 | int i, mflags; |
1278 | object *owner; |
1256 | object *owner; |
1279 | sint16 new_x, new_y; |
1257 | sint16 new_x, new_y; |
1280 | mapstruct *m; |
1258 | maptile *m; |
1281 | |
1259 | |
1282 | if (op->range-- <= 0) |
1260 | if (op->range-- <= 0) |
1283 | { |
1261 | { |
1284 | remove_ob (op); |
1262 | op->destroy (); |
1285 | free_object (op); |
|
|
1286 | return; |
1263 | return; |
1287 | } |
1264 | } |
1288 | |
1265 | |
1289 | owner = get_owner (op); |
1266 | owner = get_owner (op); |
1290 | #if 0 |
1267 | #if 0 |
1291 | /* It'd make things nastier if this wasn't here - spells cast by |
1268 | /* It'd make things nastier if this wasn't here - spells cast by |
1292 | * monster that are then killed would continue to survive |
1269 | * monster that are then killed would continue to survive |
1293 | */ |
1270 | */ |
1294 | if (owner == NULL) |
1271 | if (owner == NULL) |
1295 | { |
1272 | { |
1296 | remove_ob (op); |
1273 | op->destroy (); |
1297 | free_object (op); |
|
|
1298 | return; |
1274 | return; |
1299 | } |
1275 | } |
1300 | #endif |
1276 | #endif |
1301 | |
1277 | |
1302 | new_x = op->x + DIRX (op); |
1278 | new_x = op->x + DIRX (op); |
… | |
… | |
1304 | |
1280 | |
1305 | mflags = get_map_flags (op->map, &m, new_x, new_y, &new_x, &new_y); |
1281 | mflags = get_map_flags (op->map, &m, new_x, new_y, &new_x, &new_y); |
1306 | |
1282 | |
1307 | if (!(mflags & P_OUT_OF_MAP) && ((mflags & P_IS_ALIVE) || OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, new_x, new_y)))) |
1283 | if (!(mflags & P_OUT_OF_MAP) && ((mflags & P_IS_ALIVE) || OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, new_x, new_y)))) |
1308 | { |
1284 | { |
1309 | tag_t tag = op->count; |
|
|
1310 | |
|
|
1311 | hit_map (op, op->direction, AT_MAGIC, 1); |
1285 | hit_map (op, op->direction, AT_MAGIC, 1); |
1312 | /* Basically, missile only hits one thing then goes away. |
1286 | /* Basically, missile only hits one thing then goes away. |
1313 | * we need to remove it if someone hasn't already done so. |
1287 | * we need to remove it if someone hasn't already done so. |
1314 | */ |
1288 | */ |
1315 | if (!was_destroyed (op, tag)) |
1289 | if (!op->destroyed ()) |
1316 | { |
1290 | op->destroy (); |
1317 | remove_ob (op); |
1291 | |
1318 | free_object (op); |
|
|
1319 | } |
|
|
1320 | return; |
1292 | return; |
1321 | } |
1293 | } |
1322 | |
1294 | |
1323 | remove_ob (op); |
1295 | op->remove (); |
|
|
1296 | |
1324 | if (!op->direction || (mflags & P_OUT_OF_MAP)) |
1297 | if (!op->direction || (mflags & P_OUT_OF_MAP)) |
1325 | { |
1298 | { |
1326 | free_object (op); |
1299 | op->destroy (); |
1327 | return; |
1300 | return; |
1328 | } |
1301 | } |
|
|
1302 | |
1329 | op->x = new_x; |
1303 | op->x = new_x; |
1330 | op->y = new_y; |
1304 | op->y = new_y; |
1331 | op->map = m; |
1305 | op->map = m; |
1332 | i = spell_find_dir (op->map, op->x, op->y, get_owner (op)); |
1306 | i = spell_find_dir (op->map, op->x, op->y, get_owner (op)); |
1333 | if (i > 0 && i != op->direction) |
1307 | if (i > 0 && i != op->direction) |
1334 | { |
1308 | { |
1335 | op->direction = i; |
1309 | op->direction = i; |
1336 | SET_ANIMATION (op, op->direction); |
1310 | SET_ANIMATION (op, op->direction); |
1337 | } |
1311 | } |
|
|
1312 | |
1338 | insert_ob_in_map (op, op->map, op, 0); |
1313 | insert_ob_in_map (op, op->map, op, 0); |
1339 | } |
1314 | } |
1340 | |
1315 | |
1341 | /**************************************************************************** |
1316 | /**************************************************************************** |
1342 | * Destruction |
1317 | * Destruction |
… | |
… | |
1388 | int |
1363 | int |
1389 | cast_destruction (object *op, object *caster, object *spell_ob) |
1364 | cast_destruction (object *op, object *caster, object *spell_ob) |
1390 | { |
1365 | { |
1391 | int i, j, range, mflags, friendly = 0, dam, dur; |
1366 | int i, j, range, mflags, friendly = 0, dam, dur; |
1392 | sint16 sx, sy; |
1367 | sint16 sx, sy; |
1393 | mapstruct *m; |
1368 | maptile *m; |
1394 | object *tmp; |
1369 | object *tmp; |
1395 | const char *skill; |
1370 | const char *skill; |
1396 | |
1371 | |
1397 | range = spell_ob->range + SP_level_range_adjust (caster, spell_ob); |
1372 | range = spell_ob->range + SP_level_range_adjust (caster, spell_ob); |
1398 | dam = spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob); |
1373 | dam = spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob); |
… | |
… | |
1580 | mood_change (object *op, object *caster, object *spell) |
1555 | mood_change (object *op, object *caster, object *spell) |
1581 | { |
1556 | { |
1582 | object *tmp, *god, *head; |
1557 | object *tmp, *god, *head; |
1583 | int done_one, range, mflags, level, at, best_at; |
1558 | int done_one, range, mflags, level, at, best_at; |
1584 | sint16 x, y, nx, ny; |
1559 | sint16 x, y, nx, ny; |
1585 | mapstruct *m; |
1560 | maptile *m; |
1586 | const char *race; |
1561 | const char *race; |
1587 | |
1562 | |
1588 | /* We precompute some values here so that we don't have to keep |
1563 | /* We precompute some values here so that we don't have to keep |
1589 | * doing it over and over again. |
1564 | * doing it over and over again. |
1590 | */ |
1565 | */ |
… | |
… | |
1754 | move_ball_spell (object *op) |
1729 | move_ball_spell (object *op) |
1755 | { |
1730 | { |
1756 | int i, j, dam_save, dir, mflags; |
1731 | int i, j, dam_save, dir, mflags; |
1757 | sint16 nx, ny, hx, hy; |
1732 | sint16 nx, ny, hx, hy; |
1758 | object *owner; |
1733 | object *owner; |
1759 | mapstruct *m; |
1734 | maptile *m; |
1760 | |
1735 | |
1761 | owner = get_owner (op); |
1736 | owner = get_owner (op); |
1762 | |
1737 | |
1763 | /* the following logic makes sure that the ball doesn't move into a wall, |
1738 | /* the following logic makes sure that the ball doesn't move into a wall, |
1764 | * and makes sure that it will move along a wall to try and get at it's |
1739 | * and makes sure that it will move along a wall to try and get at it's |
… | |
… | |
1795 | nx = op->x; |
1770 | nx = op->x; |
1796 | ny = op->y; |
1771 | ny = op->y; |
1797 | m = op->map; |
1772 | m = op->map; |
1798 | } |
1773 | } |
1799 | |
1774 | |
1800 | remove_ob (op); |
1775 | op->remove (); |
1801 | op->y = ny; |
1776 | op->y = ny; |
1802 | op->x = nx; |
1777 | op->x = nx; |
1803 | insert_ob_in_map (op, m, op, 0); |
1778 | insert_ob_in_map (op, m, op, 0); |
1804 | |
1779 | |
1805 | dam_save = op->stats.dam; /* save the original dam: we do halfdam on |
1780 | dam_save = op->stats.dam; /* save the original dam: we do halfdam on |
… | |
… | |
1876 | #if 0 |
1851 | #if 0 |
1877 | static int cardinal_adjust[9] = { -3, -2, -1, 0, 0, 0, 1, 2, 3 }; |
1852 | static int cardinal_adjust[9] = { -3, -2, -1, 0, 0, 0, 1, 2, 3 }; |
1878 | static int diagonal_adjust[10] = { -3, -2, -2, -1, 0, 0, 1, 2, 2, 3 }; |
1853 | static int diagonal_adjust[10] = { -3, -2, -2, -1, 0, 0, 1, 2, 2, 3 }; |
1879 | sint16 target_x, target_y, origin_x, origin_y; |
1854 | sint16 target_x, target_y, origin_x, origin_y; |
1880 | int adjustdir; |
1855 | int adjustdir; |
1881 | mapstruct *m; |
1856 | maptile *m; |
1882 | #endif |
1857 | #endif |
1883 | int basedir; |
1858 | int basedir; |
1884 | object *owner; |
1859 | object *owner; |
1885 | |
1860 | |
1886 | owner = get_owner (op); |
1861 | owner = get_owner (op); |
1887 | if (op->duration == 0 || owner == NULL) |
1862 | if (op->duration == 0 || owner == NULL) |
1888 | { |
1863 | { |
1889 | remove_ob (op); |
1864 | op->destroy (); |
1890 | free_object (op); |
|
|
1891 | return; |
1865 | return; |
1892 | } |
1866 | } |
|
|
1867 | |
1893 | op->duration--; |
1868 | op->duration--; |
1894 | |
1869 | |
1895 | basedir = op->direction; |
1870 | basedir = op->direction; |
1896 | if (basedir == 0) |
1871 | if (basedir == 0) |
1897 | { |
1872 | { |
… | |
… | |
2029 | cast_light (object *op, object *caster, object *spell, int dir) |
2004 | cast_light (object *op, object *caster, object *spell, int dir) |
2030 | { |
2005 | { |
2031 | object *target = NULL, *tmp = NULL; |
2006 | object *target = NULL, *tmp = NULL; |
2032 | sint16 x, y; |
2007 | sint16 x, y; |
2033 | int dam, mflags; |
2008 | int dam, mflags; |
2034 | mapstruct *m; |
2009 | maptile *m; |
2035 | |
2010 | |
2036 | dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
2011 | dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
2037 | |
2012 | |
2038 | if (!dir) |
2013 | if (!dir) |
2039 | { |
2014 | { |
… | |
… | |
2107 | cast_cause_disease (object *op, object *caster, object *spell, int dir) |
2082 | cast_cause_disease (object *op, object *caster, object *spell, int dir) |
2108 | { |
2083 | { |
2109 | sint16 x, y; |
2084 | sint16 x, y; |
2110 | int i, mflags, range, dam_mod, dur_mod; |
2085 | int i, mflags, range, dam_mod, dur_mod; |
2111 | object *walk; |
2086 | object *walk; |
2112 | mapstruct *m; |
2087 | maptile *m; |
2113 | |
2088 | |
2114 | x = op->x; |
2089 | x = op->x; |
2115 | y = op->y; |
2090 | y = op->y; |
2116 | |
2091 | |
2117 | /* If casting from a scroll, no direction will be available, so refer to the |
2092 | /* If casting from a scroll, no direction will be available, so refer to the |
… | |
… | |
2209 | { |
2184 | { |
2210 | object *flash; /* visual effect for inflicting disease */ |
2185 | object *flash; /* visual effect for inflicting disease */ |
2211 | |
2186 | |
2212 | new_draw_info_format (NDI_UNIQUE, 0, op, "You inflict %s on %s!", &disease->name, &walk->name); |
2187 | new_draw_info_format (NDI_UNIQUE, 0, op, "You inflict %s on %s!", &disease->name, &walk->name); |
2213 | |
2188 | |
2214 | free_object (disease); /* don't need this one anymore */ |
2189 | disease->destroy (); /* don't need this one anymore */ |
2215 | flash = get_archetype (ARCH_DETECT_MAGIC); |
2190 | flash = get_archetype (ARCH_DETECT_MAGIC); |
2216 | flash->x = x; |
2191 | flash->x = x; |
2217 | flash->y = y; |
2192 | flash->y = y; |
2218 | flash->map = walk->map; |
2193 | flash->map = walk->map; |
2219 | insert_ob_in_map (flash, walk->map, op, 0); |
2194 | insert_ob_in_map (flash, walk->map, op, 0); |
2220 | return 1; |
2195 | return 1; |
2221 | } |
2196 | } |
2222 | free_object (disease); |
2197 | |
|
|
2198 | disease->destroy (); |
2223 | } |
2199 | } |
2224 | } /* if living creature */ |
2200 | } /* if living creature */ |
2225 | } /* for range of spaces */ |
2201 | } /* for range of spaces */ |
2226 | new_draw_info (NDI_UNIQUE, 0, op, "No one caught anything!"); |
2202 | new_draw_info (NDI_UNIQUE, 0, op, "No one caught anything!"); |
2227 | return 1; |
2203 | return 1; |