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 |
… | |
… | |
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->remove (); |
187 | free_object (op); |
180 | op->destroy (0); |
188 | return; |
181 | return; |
189 | } |
182 | } |
|
|
183 | |
190 | hit_map (op, 0, op->attacktype, 1); |
184 | hit_map (op, 0, op->attacktype, 1); |
191 | |
185 | |
192 | if (!op->direction) |
186 | if (!op->direction) |
193 | return; |
187 | return; |
194 | |
188 | |
… | |
… | |
326 | tmp->map = op->map; |
320 | tmp->map = op->map; |
327 | |
321 | |
328 | mflags = get_map_flags (tmp->map, &tmp->map, tmp->x, tmp->y, &tmp->x, &tmp->y); |
322 | mflags = get_map_flags (tmp->map, &tmp->map, tmp->x, tmp->y, &tmp->x, &tmp->y); |
329 | if (mflags & P_OUT_OF_MAP) |
323 | if (mflags & P_OUT_OF_MAP) |
330 | { |
324 | { |
331 | free_object (tmp); |
325 | tmp->destroy (0); |
332 | return 0; |
326 | return 0; |
333 | } |
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 (0); |
339 | return 0; |
333 | return 0; |
340 | } |
334 | } |
341 | tmp->x = op->x; |
335 | tmp->x = op->x; |
342 | tmp->y = op->y; |
336 | tmp->y = op->y; |
343 | tmp->direction = absdir (tmp->direction + 4); |
337 | tmp->direction = absdir (tmp->direction + 4); |
… | |
… | |
362 | */ |
356 | */ |
363 | void |
357 | void |
364 | explosion (object *op) |
358 | explosion (object *op) |
365 | { |
359 | { |
366 | object *tmp; |
360 | object *tmp; |
367 | mapstruct *m = op->map; |
361 | maptile *m = op->map; |
368 | int i; |
362 | int i; |
369 | |
363 | |
370 | if (--(op->duration) < 0) |
364 | if (--(op->duration) < 0) |
371 | { |
365 | { |
372 | remove_ob (op); |
366 | op->remove (); |
373 | free_object (op); |
367 | op->destroy (0); |
374 | return; |
368 | return; |
375 | } |
369 | } |
376 | hit_map (op, 0, op->attacktype, 0); |
370 | hit_map (op, 0, op->attacktype, 0); |
377 | |
371 | |
378 | if (op->range > 0) |
372 | if (op->range > 0) |
… | |
… | |
408 | * explode. |
402 | * explode. |
409 | */ |
403 | */ |
410 | void |
404 | void |
411 | explode_bullet (object *op) |
405 | explode_bullet (object *op) |
412 | { |
406 | { |
413 | tag_t op_tag = op->count; |
|
|
414 | object *tmp, *owner; |
407 | object *tmp, *owner; |
415 | |
408 | |
416 | if (op->other_arch == NULL) |
409 | if (op->other_arch == NULL) |
417 | { |
410 | { |
418 | LOG (llevError, "BUG: explode_bullet(): op without other_arch\n"); |
411 | LOG (llevError, "BUG: explode_bullet(): op without other_arch\n"); |
419 | remove_ob (op); |
412 | op->remove (); |
420 | free_object (op); |
413 | op->destroy (0); |
421 | return; |
414 | return; |
422 | } |
415 | } |
423 | |
416 | |
424 | if (op->env) |
417 | if (op->env) |
425 | { |
418 | { |
… | |
… | |
427 | |
420 | |
428 | env = object_get_env_recursive (op); |
421 | env = object_get_env_recursive (op); |
429 | if (env->map == NULL || out_of_map (env->map, env->x, env->y)) |
422 | if (env->map == NULL || out_of_map (env->map, env->x, env->y)) |
430 | { |
423 | { |
431 | LOG (llevError, "BUG: explode_bullet(): env out of map\n"); |
424 | LOG (llevError, "BUG: explode_bullet(): env out of map\n"); |
432 | remove_ob (op); |
425 | op->remove (); |
433 | free_object (op); |
426 | op->destroy (0); |
434 | return; |
427 | return; |
435 | } |
428 | } |
436 | remove_ob (op); |
429 | op->remove (); |
437 | op->x = env->x; |
430 | op->x = env->x; |
438 | op->y = env->y; |
431 | op->y = env->y; |
439 | insert_ob_in_map (op, env->map, op, INS_NO_MERGE | INS_NO_WALK_ON); |
432 | insert_ob_in_map (op, env->map, op, INS_NO_MERGE | INS_NO_WALK_ON); |
440 | } |
433 | } |
441 | else if (out_of_map (op->map, op->x, op->y)) |
434 | else if (out_of_map (op->map, op->x, op->y)) |
442 | { |
435 | { |
443 | LOG (llevError, "BUG: explode_bullet(): op out of map\n"); |
436 | LOG (llevError, "BUG: explode_bullet(): op out of map\n"); |
444 | remove_ob (op); |
437 | op->remove (); |
445 | free_object (op); |
438 | op->destroy (0); |
446 | return; |
439 | return; |
447 | } |
440 | } |
448 | |
441 | |
449 | // elmex Tue Aug 15 17:46:51 CEST 2006: Prevent explosions of any kind on safe maps |
442 | // 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 |
443 | // NOTE: If this breaks something important: remove this. I can't think of anything |
451 | // bad at the moment that might happen from this. |
444 | // 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) |
445 | if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) |
453 | { |
446 | { |
454 | remove_ob (op); |
447 | op->remove (); |
455 | free_object (op); |
448 | op->destroy (0); |
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->remove (); |
476 | free_object (op); |
470 | op->destroy (0); |
477 | return; |
471 | return; |
478 | } |
472 | } |
|
|
473 | |
479 | tmp->x = op->x; |
474 | tmp->x = op->x; |
480 | tmp->y = op->y; |
475 | tmp->y = op->y; |
481 | |
476 | |
482 | /* special for bombs - it actually has sane values for these */ |
477 | /* special for bombs - it actually has sane values for these */ |
483 | if (op->type == SPELL_EFFECT && op->subtype == SP_BOMB) |
478 | if (op->type == SPELL_EFFECT && op->subtype == SP_BOMB) |
… | |
… | |
508 | /* Prevent recursion */ |
503 | /* Prevent recursion */ |
509 | op->move_on = 0; |
504 | op->move_on = 0; |
510 | |
505 | |
511 | insert_ob_in_map (tmp, op->map, op, 0); |
506 | insert_ob_in_map (tmp, op->map, op, 0); |
512 | /* remove the firebullet */ |
507 | /* remove the firebullet */ |
513 | if (!was_destroyed (op, op_tag)) |
508 | if (!op->destroyed ()) |
514 | { |
509 | { |
515 | remove_ob (op); |
510 | op->remove (); |
516 | free_object (op); |
511 | op->destroy (0); |
517 | } |
512 | } |
518 | } |
513 | } |
519 | |
514 | |
520 | |
515 | |
521 | |
516 | |
… | |
… | |
524 | */ |
519 | */ |
525 | |
520 | |
526 | void |
521 | void |
527 | check_bullet (object *op) |
522 | check_bullet (object *op) |
528 | { |
523 | { |
529 | tag_t op_tag = op->count, tmp_tag; |
|
|
530 | object *tmp; |
524 | object *tmp; |
531 | int dam, mflags; |
525 | int dam, mflags; |
532 | mapstruct *m; |
526 | maptile *m; |
533 | sint16 sx, sy; |
527 | sint16 sx, sy; |
534 | |
528 | |
535 | mflags = get_map_flags (op->map, &m, op->x, op->y, &sx, &sy); |
529 | mflags = get_map_flags (op->map, &m, op->x, op->y, &sx, &sy); |
536 | |
530 | |
537 | if (!(mflags & P_IS_ALIVE) && !OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy))) |
531 | if (!(mflags & P_IS_ALIVE) && !OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy))) |
… | |
… | |
550 | |
544 | |
551 | for (tmp = get_map_ob (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) |
545 | for (tmp = get_map_ob (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) |
552 | { |
546 | { |
553 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
547 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
554 | { |
548 | { |
555 | tmp_tag = tmp->count; |
|
|
556 | dam = hit_player (tmp, op->stats.dam, op, op->attacktype, 1); |
549 | 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) |
550 | if (op->destroyed () || !tmp->destroyed () || (op->stats.dam -= dam) < 0) |
558 | { |
551 | { |
559 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
552 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
560 | { |
553 | { |
561 | remove_ob (op); |
554 | op->remove (); |
562 | free_object (op); |
555 | op->destroy (0); |
563 | return; |
556 | return; |
564 | } |
557 | } |
565 | } |
558 | } |
566 | } |
559 | } |
567 | } |
560 | } |
… | |
… | |
577 | void |
570 | void |
578 | move_bullet (object *op) |
571 | move_bullet (object *op) |
579 | { |
572 | { |
580 | sint16 new_x, new_y; |
573 | sint16 new_x, new_y; |
581 | int mflags; |
574 | int mflags; |
582 | mapstruct *m; |
575 | maptile *m; |
583 | |
576 | |
584 | #if 0 |
577 | #if 0 |
585 | /* We need a better general purpose way to do this */ |
578 | /* We need a better general purpose way to do this */ |
586 | |
579 | |
587 | /* peterm: added to make comet leave a trail of burnouts |
580 | /* peterm: added to make comet leave a trail of burnouts |
588 | it's an unadulterated hack, but the effect is cool. */ |
581 | it's an unadulterated hack, but the effect is cool. */ |
589 | if (op->stats.sp == SP_METEOR) |
582 | if (op->stats.sp == SP_METEOR) |
590 | { |
583 | { |
591 | replace_insert_ob_in_map ("fire_trail", op); |
584 | replace_insert_ob_in_map ("fire_trail", op); |
592 | if (was_destroyed (op, op_tag)) |
585 | if (op->destroyed ()) |
593 | return; |
586 | return; |
594 | } /* end addition. */ |
587 | } /* end addition. */ |
595 | #endif |
588 | #endif |
596 | |
589 | |
597 | /* Reached the end of its life - remove it */ |
590 | /* Reached the end of its life - remove it */ |
… | |
… | |
601 | { |
594 | { |
602 | explode_bullet (op); |
595 | explode_bullet (op); |
603 | } |
596 | } |
604 | else |
597 | else |
605 | { |
598 | { |
606 | remove_ob (op); |
599 | op->remove (); |
607 | free_object (op); |
600 | op->destroy (0); |
608 | } |
601 | } |
609 | return; |
602 | return; |
610 | } |
603 | } |
611 | |
604 | |
612 | new_x = op->x + DIRX (op); |
605 | new_x = op->x + DIRX (op); |
… | |
… | |
614 | m = op->map; |
607 | m = op->map; |
615 | mflags = get_map_flags (m, &m, new_x, new_y, &new_x, &new_y); |
608 | mflags = get_map_flags (m, &m, new_x, new_y, &new_x, &new_y); |
616 | |
609 | |
617 | if (mflags & P_OUT_OF_MAP) |
610 | if (mflags & P_OUT_OF_MAP) |
618 | { |
611 | { |
619 | remove_ob (op); |
612 | op->remove (); |
620 | free_object (op); |
613 | op->destroy (0); |
621 | return; |
614 | return; |
622 | } |
615 | } |
623 | |
616 | |
624 | if (!op->direction || OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, new_x, new_y))) |
617 | if (!op->direction || OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, new_x, new_y))) |
625 | { |
618 | { |
… | |
… | |
627 | { |
620 | { |
628 | explode_bullet (op); |
621 | explode_bullet (op); |
629 | } |
622 | } |
630 | else |
623 | else |
631 | { |
624 | { |
632 | remove_ob (op); |
625 | op->remove (); |
633 | free_object (op); |
626 | op->destroy (0); |
634 | } |
627 | } |
635 | return; |
628 | return; |
636 | } |
629 | } |
637 | |
630 | |
638 | remove_ob (op); |
631 | op->remove (); |
639 | op->x = new_x; |
632 | op->x = new_x; |
640 | op->y = new_y; |
633 | op->y = new_y; |
641 | if ((op = insert_ob_in_map (op, m, op, 0)) == NULL) |
634 | if ((op = insert_ob_in_map (op, m, op, 0)) == NULL) |
642 | return; |
635 | return; |
643 | |
636 | |
… | |
… | |
702 | tmp->map = op->map; |
695 | tmp->map = op->map; |
703 | |
696 | |
704 | mflags = get_map_flags (tmp->map, &tmp->map, tmp->x, tmp->y, &tmp->x, &tmp->y); |
697 | mflags = get_map_flags (tmp->map, &tmp->map, tmp->x, tmp->y, &tmp->x, &tmp->y); |
705 | if (mflags & P_OUT_OF_MAP) |
698 | if (mflags & P_OUT_OF_MAP) |
706 | { |
699 | { |
707 | free_object (tmp); |
700 | tmp->destroy (0); |
708 | return 0; |
701 | return 0; |
709 | } |
702 | } |
710 | if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y))) |
703 | if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y))) |
711 | { |
704 | { |
712 | if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) |
705 | if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) |
713 | { |
706 | { |
714 | free_object (tmp); |
707 | tmp->destroy (0); |
715 | return 0; |
708 | return 0; |
716 | } |
709 | } |
717 | tmp->x = op->x; |
710 | tmp->x = op->x; |
718 | tmp->y = op->y; |
711 | tmp->y = op->y; |
719 | tmp->direction = absdir (tmp->direction + 4); |
712 | tmp->direction = absdir (tmp->direction + 4); |
… | |
… | |
760 | |
753 | |
761 | void |
754 | void |
762 | move_cone (object *op) |
755 | move_cone (object *op) |
763 | { |
756 | { |
764 | int i; |
757 | int i; |
765 | tag_t tag; |
|
|
766 | |
758 | |
767 | /* if no map then hit_map will crash so just ignore object */ |
759 | /* if no map then hit_map will crash so just ignore object */ |
768 | if (!op->map) |
760 | if (!op->map) |
769 | { |
761 | { |
770 | LOG (llevError, "Tried to move_cone object %s without a map.\n", op->name ? &op->name : "unknown"); |
762 | 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. |
777 | * when their cone dies when they die. |
786 | */ |
778 | */ |
787 | /* If no owner left, the spell dies out. */ |
779 | /* If no owner left, the spell dies out. */ |
788 | if (get_owner (op) == NULL) |
780 | if (get_owner (op) == NULL) |
789 | { |
781 | { |
790 | remove_ob (op); |
782 | op->remove (); |
791 | free_object (op); |
783 | op->destroy (0); |
792 | return; |
784 | return; |
793 | } |
785 | } |
794 | #endif |
786 | #endif |
795 | |
787 | |
796 | tag = op->count; |
|
|
797 | hit_map (op, 0, op->attacktype, 0); |
788 | hit_map (op, 0, op->attacktype, 0); |
798 | |
789 | |
799 | /* Check to see if we should push anything. |
790 | /* Check to see if we should push anything. |
800 | * Spell objects with weight push whatever they encounter to some |
791 | * Spell objects with weight push whatever they encounter to some |
801 | * degree. |
792 | * degree. |
802 | */ |
793 | */ |
803 | if (op->weight) |
794 | if (op->weight) |
804 | check_spell_knockback (op); |
795 | check_spell_knockback (op); |
805 | |
796 | |
806 | if (was_destroyed (op, tag)) |
797 | if (op->destroyed ()) |
807 | return; |
798 | return; |
808 | |
799 | |
809 | if ((op->duration--) < 0) |
800 | if ((op->duration--) < 0) |
810 | { |
801 | { |
811 | remove_ob (op); |
802 | op->remove (); |
812 | free_object (op); |
803 | op->destroy (0); |
813 | return; |
804 | return; |
814 | } |
805 | } |
815 | /* Object has hit maximum range, so don't have it move |
806 | /* Object has hit maximum range, so don't have it move |
816 | * any further. When the duration above expires, |
807 | * any further. When the duration above expires, |
817 | * then the object will get removed. |
808 | * then the object will get removed. |
… | |
… | |
856 | int |
847 | int |
857 | cast_cone (object *op, object *caster, int dir, object *spell) |
848 | cast_cone (object *op, object *caster, int dir, object *spell) |
858 | { |
849 | { |
859 | object *tmp; |
850 | object *tmp; |
860 | int i, success = 0, range_min = -1, range_max = 1; |
851 | int i, success = 0, range_min = -1, range_max = 1; |
861 | mapstruct *m; |
852 | maptile *m; |
862 | sint16 sx, sy; |
853 | sint16 sx, sy; |
863 | MoveType movetype; |
854 | MoveType movetype; |
864 | |
855 | |
865 | if (!spell->other_arch) |
856 | if (!spell->other_arch) |
866 | return 0; |
857 | return 0; |
… | |
… | |
931 | tmp->y = sy; |
922 | tmp->y = sy; |
932 | tmp->attacktype = spell->attacktype; |
923 | tmp->attacktype = spell->attacktype; |
933 | |
924 | |
934 | /* holy word stuff */ |
925 | /* holy word stuff */ |
935 | if ((tmp->attacktype & AT_HOLYWORD) || (tmp->attacktype & AT_GODPOWER)) |
926 | if ((tmp->attacktype & AT_HOLYWORD) || (tmp->attacktype & AT_GODPOWER)) |
936 | { |
|
|
937 | if (!tailor_god_spell (tmp, op)) |
927 | if (!tailor_god_spell (tmp, op)) |
938 | return 0; |
928 | return 0; |
939 | } |
|
|
940 | |
929 | |
941 | if (dir) |
930 | if (dir) |
942 | tmp->stats.sp = dir; |
931 | tmp->stats.sp = dir; |
943 | else |
932 | else |
944 | tmp->stats.sp = i; |
933 | tmp->stats.sp = i; |
… | |
… | |
950 | { |
939 | { |
951 | tmp->range /= 4; |
940 | tmp->range /= 4; |
952 | if (tmp->range < 2 && spell->range >= 2) |
941 | if (tmp->range < 2 && spell->range >= 2) |
953 | tmp->range = 2; |
942 | tmp->range = 2; |
954 | } |
943 | } |
|
|
944 | |
955 | tmp->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
945 | tmp->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
956 | tmp->duration = spell->duration + SP_level_duration_adjust (caster, spell); |
946 | tmp->duration = spell->duration + SP_level_duration_adjust (caster, spell); |
957 | |
947 | |
958 | /* Special bonus for fear attacks */ |
948 | /* Special bonus for fear attacks */ |
959 | if (tmp->attacktype & AT_FEAR) |
949 | if (tmp->attacktype & AT_FEAR) |
… | |
… | |
961 | if (caster->type == PLAYER) |
951 | if (caster->type == PLAYER) |
962 | tmp->duration += fear_bonus[caster->stats.Cha]; |
952 | tmp->duration += fear_bonus[caster->stats.Cha]; |
963 | else |
953 | else |
964 | tmp->duration += caster->level / 3; |
954 | tmp->duration += caster->level / 3; |
965 | } |
955 | } |
|
|
956 | |
966 | if (tmp->attacktype & (AT_HOLYWORD | AT_TURN_UNDEAD)) |
957 | if (tmp->attacktype & (AT_HOLYWORD | AT_TURN_UNDEAD)) |
967 | { |
958 | { |
968 | if (caster->type == PLAYER) |
959 | if (caster->type == PLAYER) |
969 | tmp->duration += turn_bonus[caster->stats.Wis] / 5; |
960 | tmp->duration += turn_bonus[caster->stats.Wis] / 5; |
970 | else |
961 | else |
971 | tmp->duration += caster->level / 3; |
962 | tmp->duration += caster->level / 3; |
972 | } |
963 | } |
973 | |
964 | |
974 | |
|
|
975 | if (!(tmp->move_type & MOVE_FLY_LOW)) |
965 | if (!(tmp->move_type & MOVE_FLY_LOW)) |
976 | LOG (llevDebug, "cast_cone(): arch %s doesn't have flying 1\n", &spell->other_arch->name); |
966 | LOG (llevDebug, "cast_cone(): arch %s doesn't have flying 1\n", &spell->other_arch->name); |
977 | |
967 | |
978 | if (!tmp->move_on && tmp->stats.dam) |
968 | if (!tmp->move_on && tmp->stats.dam) |
979 | { |
969 | { |
980 | LOG (llevDebug, "cast_cone(): arch %s doesn't have move_on set\n", &spell->other_arch->name); |
970 | LOG (llevDebug, "cast_cone(): arch %s doesn't have move_on set\n", &spell->other_arch->name); |
981 | } |
971 | } |
|
|
972 | |
982 | insert_ob_in_map (tmp, m, op, 0); |
973 | insert_ob_in_map (tmp, m, op, 0); |
983 | |
974 | |
984 | /* This is used for tracking spells so that one effect doesn't hit |
975 | /* This is used for tracking spells so that one effect doesn't hit |
985 | * a single space too many times. |
976 | * a single space too many times. |
986 | */ |
977 | */ |
987 | tmp->stats.maxhp = tmp->count; |
978 | tmp->stats.maxhp = tmp->count; |
988 | |
979 | |
989 | if (tmp->other_arch) |
980 | if (tmp->other_arch) |
990 | cone_drop (tmp); |
981 | cone_drop (tmp); |
991 | } |
982 | } |
|
|
983 | |
992 | return success; |
984 | return success; |
993 | } |
985 | } |
994 | |
986 | |
995 | /**************************************************************************** |
987 | /**************************************************************************** |
996 | * |
988 | * |
… | |
… | |
1010 | archetype *at; |
1002 | archetype *at; |
1011 | |
1003 | |
1012 | if (op->state != NUM_ANIMATIONS (op) - 1) |
1004 | if (op->state != NUM_ANIMATIONS (op) - 1) |
1013 | return; |
1005 | return; |
1014 | |
1006 | |
1015 | |
|
|
1016 | env = object_get_env_recursive (op); |
1007 | env = object_get_env_recursive (op); |
1017 | |
1008 | |
1018 | if (op->env) |
1009 | if (op->env) |
1019 | { |
1010 | { |
1020 | if (env->map == NULL) |
1011 | if (env->map == NULL) |
1021 | return; |
1012 | return; |
1022 | |
1013 | |
1023 | if (env->type == PLAYER) |
1014 | if (env->type == PLAYER) |
1024 | esrv_del_item (env->contr, op->count); |
1015 | esrv_del_item (env->contr, op->count); |
1025 | |
1016 | |
1026 | remove_ob (op); |
1017 | op->remove (); |
1027 | op->x = env->x; |
1018 | op->x = env->x; |
1028 | op->y = env->y; |
1019 | op->y = env->y; |
1029 | if ((op = insert_ob_in_map (op, env->map, op, 0)) == NULL) |
1020 | if ((op = insert_ob_in_map (op, env->map, op, 0)) == NULL) |
1030 | return; |
1021 | return; |
1031 | } |
1022 | } |
… | |
… | |
1033 | // elmex Tue Aug 15 17:46:51 CEST 2006: Prevent bomb from exploding |
1024 | // 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 |
1025 | // on a safe map. I don't like this special casing, but it seems to be neccessary |
1035 | // as bombs can be carried. |
1026 | // as bombs can be carried. |
1036 | if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) |
1027 | if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) |
1037 | { |
1028 | { |
1038 | remove_ob (op); |
1029 | op->remove (); |
1039 | free_object (op); |
1030 | op->destroy (0); |
1040 | return; |
1031 | return; |
1041 | } |
1032 | } |
1042 | |
1033 | |
1043 | /* This copies a lot of the code from the fire bullet, |
1034 | /* This copies a lot of the code from the fire bullet, |
1044 | * but using the cast_bullet isn't really feasible, |
1035 | * but using the cast_bullet isn't really feasible, |
1045 | * so just set up the appropriate values. |
1036 | * so just set up the appropriate values. |
1046 | */ |
1037 | */ |
1047 | at = find_archetype (SPLINT); |
1038 | at = archetype::find (SPLINT); |
1048 | if (at) |
1039 | if (at) |
1049 | { |
1040 | { |
1050 | for (i = 1; i < 9; i++) |
1041 | for (i = 1; i < 9; i++) |
1051 | { |
1042 | { |
1052 | if (out_of_map (op->map, op->x + freearr_x[i], op->y + freearr_x[i])) |
1043 | if (out_of_map (op->map, op->x + freearr_x[i], op->y + freearr_x[i])) |
… | |
… | |
1079 | { |
1070 | { |
1080 | |
1071 | |
1081 | object *tmp; |
1072 | object *tmp; |
1082 | int mflags; |
1073 | int mflags; |
1083 | sint16 dx = op->x + freearr_x[dir], dy = op->y + freearr_y[dir]; |
1074 | sint16 dx = op->x + freearr_x[dir], dy = op->y + freearr_y[dir]; |
1084 | mapstruct *m; |
1075 | maptile *m; |
1085 | |
1076 | |
1086 | mflags = get_map_flags (op->map, &m, dx, dy, &dx, &dy); |
1077 | 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)) |
1078 | if ((mflags & P_OUT_OF_MAP) || (GET_MAP_MOVE_BLOCK (m, dx, dy) & MOVE_WALK)) |
1088 | { |
1079 | { |
1089 | new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way."); |
1080 | 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) |
1116 | get_pointed_target (object *op, int dir, int range, int type) |
1126 | { |
1117 | { |
1127 | object *target; |
1118 | object *target; |
1128 | sint16 x, y; |
1119 | sint16 x, y; |
1129 | int dist, mflags; |
1120 | int dist, mflags; |
1130 | mapstruct *mp; |
1121 | maptile *mp; |
1131 | |
1122 | |
1132 | if (dir == 0) |
1123 | if (dir == 0) |
1133 | return NULL; |
1124 | return NULL; |
1134 | |
1125 | |
1135 | for (dist = 1; dist < range; dist++) |
1126 | for (dist = 1; dist < range; dist++) |
… | |
… | |
1238 | } |
1229 | } |
1239 | else |
1230 | else |
1240 | { |
1231 | { |
1241 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s looks stronger!", query_name (target)); |
1232 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s looks stronger!", query_name (target)); |
1242 | target->stats.hp = target->stats.maxhp * 2; |
1233 | target->stats.hp = target->stats.maxhp * 2; |
1243 | free_object (effect); |
1234 | effect->destroy (0); |
1244 | return 0; |
1235 | return 0; |
1245 | } |
1236 | } |
1246 | } |
1237 | } |
1247 | } |
1238 | } |
1248 | else |
1239 | else |
… | |
… | |
1275 | move_missile (object *op) |
1266 | move_missile (object *op) |
1276 | { |
1267 | { |
1277 | int i, mflags; |
1268 | int i, mflags; |
1278 | object *owner; |
1269 | object *owner; |
1279 | sint16 new_x, new_y; |
1270 | sint16 new_x, new_y; |
1280 | mapstruct *m; |
1271 | maptile *m; |
1281 | |
1272 | |
1282 | if (op->range-- <= 0) |
1273 | if (op->range-- <= 0) |
1283 | { |
1274 | { |
1284 | remove_ob (op); |
1275 | op->remove (); |
1285 | free_object (op); |
1276 | op->destroy (0); |
1286 | return; |
1277 | return; |
1287 | } |
1278 | } |
1288 | |
1279 | |
1289 | owner = get_owner (op); |
1280 | owner = get_owner (op); |
1290 | #if 0 |
1281 | #if 0 |
1291 | /* It'd make things nastier if this wasn't here - spells cast by |
1282 | /* It'd make things nastier if this wasn't here - spells cast by |
1292 | * monster that are then killed would continue to survive |
1283 | * monster that are then killed would continue to survive |
1293 | */ |
1284 | */ |
1294 | if (owner == NULL) |
1285 | if (owner == NULL) |
1295 | { |
1286 | { |
1296 | remove_ob (op); |
1287 | op->remove (); |
1297 | free_object (op); |
1288 | op->destroy (0); |
1298 | return; |
1289 | return; |
1299 | } |
1290 | } |
1300 | #endif |
1291 | #endif |
1301 | |
1292 | |
1302 | new_x = op->x + DIRX (op); |
1293 | new_x = op->x + DIRX (op); |
… | |
… | |
1304 | |
1295 | |
1305 | mflags = get_map_flags (op->map, &m, new_x, new_y, &new_x, &new_y); |
1296 | mflags = get_map_flags (op->map, &m, new_x, new_y, &new_x, &new_y); |
1306 | |
1297 | |
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)))) |
1298 | 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 | { |
1299 | { |
1309 | tag_t tag = op->count; |
|
|
1310 | |
|
|
1311 | hit_map (op, op->direction, AT_MAGIC, 1); |
1300 | hit_map (op, op->direction, AT_MAGIC, 1); |
1312 | /* Basically, missile only hits one thing then goes away. |
1301 | /* Basically, missile only hits one thing then goes away. |
1313 | * we need to remove it if someone hasn't already done so. |
1302 | * we need to remove it if someone hasn't already done so. |
1314 | */ |
1303 | */ |
1315 | if (!was_destroyed (op, tag)) |
1304 | if (!op->destroyed ()) |
1316 | { |
1305 | op->destroy (0); |
1317 | remove_ob (op); |
1306 | |
1318 | free_object (op); |
|
|
1319 | } |
|
|
1320 | return; |
1307 | return; |
1321 | } |
1308 | } |
1322 | |
1309 | |
1323 | remove_ob (op); |
1310 | op->remove (); |
|
|
1311 | |
1324 | if (!op->direction || (mflags & P_OUT_OF_MAP)) |
1312 | if (!op->direction || (mflags & P_OUT_OF_MAP)) |
1325 | { |
1313 | { |
1326 | free_object (op); |
1314 | op->destroy (0); |
1327 | return; |
1315 | return; |
1328 | } |
1316 | } |
|
|
1317 | |
1329 | op->x = new_x; |
1318 | op->x = new_x; |
1330 | op->y = new_y; |
1319 | op->y = new_y; |
1331 | op->map = m; |
1320 | op->map = m; |
1332 | i = spell_find_dir (op->map, op->x, op->y, get_owner (op)); |
1321 | i = spell_find_dir (op->map, op->x, op->y, get_owner (op)); |
1333 | if (i > 0 && i != op->direction) |
1322 | if (i > 0 && i != op->direction) |
1334 | { |
1323 | { |
1335 | op->direction = i; |
1324 | op->direction = i; |
1336 | SET_ANIMATION (op, op->direction); |
1325 | SET_ANIMATION (op, op->direction); |
1337 | } |
1326 | } |
|
|
1327 | |
1338 | insert_ob_in_map (op, op->map, op, 0); |
1328 | insert_ob_in_map (op, op->map, op, 0); |
1339 | } |
1329 | } |
1340 | |
1330 | |
1341 | /**************************************************************************** |
1331 | /**************************************************************************** |
1342 | * Destruction |
1332 | * Destruction |
… | |
… | |
1388 | int |
1378 | int |
1389 | cast_destruction (object *op, object *caster, object *spell_ob) |
1379 | cast_destruction (object *op, object *caster, object *spell_ob) |
1390 | { |
1380 | { |
1391 | int i, j, range, mflags, friendly = 0, dam, dur; |
1381 | int i, j, range, mflags, friendly = 0, dam, dur; |
1392 | sint16 sx, sy; |
1382 | sint16 sx, sy; |
1393 | mapstruct *m; |
1383 | maptile *m; |
1394 | object *tmp; |
1384 | object *tmp; |
1395 | const char *skill; |
1385 | const char *skill; |
1396 | |
1386 | |
1397 | range = spell_ob->range + SP_level_range_adjust (caster, spell_ob); |
1387 | range = spell_ob->range + SP_level_range_adjust (caster, spell_ob); |
1398 | dam = spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob); |
1388 | dam = spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob); |
… | |
… | |
1580 | mood_change (object *op, object *caster, object *spell) |
1570 | mood_change (object *op, object *caster, object *spell) |
1581 | { |
1571 | { |
1582 | object *tmp, *god, *head; |
1572 | object *tmp, *god, *head; |
1583 | int done_one, range, mflags, level, at, best_at; |
1573 | int done_one, range, mflags, level, at, best_at; |
1584 | sint16 x, y, nx, ny; |
1574 | sint16 x, y, nx, ny; |
1585 | mapstruct *m; |
1575 | maptile *m; |
1586 | const char *race; |
1576 | const char *race; |
1587 | |
1577 | |
1588 | /* We precompute some values here so that we don't have to keep |
1578 | /* We precompute some values here so that we don't have to keep |
1589 | * doing it over and over again. |
1579 | * doing it over and over again. |
1590 | */ |
1580 | */ |
… | |
… | |
1754 | move_ball_spell (object *op) |
1744 | move_ball_spell (object *op) |
1755 | { |
1745 | { |
1756 | int i, j, dam_save, dir, mflags; |
1746 | int i, j, dam_save, dir, mflags; |
1757 | sint16 nx, ny, hx, hy; |
1747 | sint16 nx, ny, hx, hy; |
1758 | object *owner; |
1748 | object *owner; |
1759 | mapstruct *m; |
1749 | maptile *m; |
1760 | |
1750 | |
1761 | owner = get_owner (op); |
1751 | owner = get_owner (op); |
1762 | |
1752 | |
1763 | /* the following logic makes sure that the ball doesn't move into a wall, |
1753 | /* 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 |
1754 | * and makes sure that it will move along a wall to try and get at it's |
… | |
… | |
1795 | nx = op->x; |
1785 | nx = op->x; |
1796 | ny = op->y; |
1786 | ny = op->y; |
1797 | m = op->map; |
1787 | m = op->map; |
1798 | } |
1788 | } |
1799 | |
1789 | |
1800 | remove_ob (op); |
1790 | op->remove (); |
1801 | op->y = ny; |
1791 | op->y = ny; |
1802 | op->x = nx; |
1792 | op->x = nx; |
1803 | insert_ob_in_map (op, m, op, 0); |
1793 | insert_ob_in_map (op, m, op, 0); |
1804 | |
1794 | |
1805 | dam_save = op->stats.dam; /* save the original dam: we do halfdam on |
1795 | dam_save = op->stats.dam; /* save the original dam: we do halfdam on |
… | |
… | |
1876 | #if 0 |
1866 | #if 0 |
1877 | static int cardinal_adjust[9] = { -3, -2, -1, 0, 0, 0, 1, 2, 3 }; |
1867 | 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 }; |
1868 | 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; |
1869 | sint16 target_x, target_y, origin_x, origin_y; |
1880 | int adjustdir; |
1870 | int adjustdir; |
1881 | mapstruct *m; |
1871 | maptile *m; |
1882 | #endif |
1872 | #endif |
1883 | int basedir; |
1873 | int basedir; |
1884 | object *owner; |
1874 | object *owner; |
1885 | |
1875 | |
1886 | owner = get_owner (op); |
1876 | owner = get_owner (op); |
1887 | if (op->duration == 0 || owner == NULL) |
1877 | if (op->duration == 0 || owner == NULL) |
1888 | { |
1878 | { |
1889 | remove_ob (op); |
1879 | op->remove (); |
1890 | free_object (op); |
1880 | op->destroy (0); |
1891 | return; |
1881 | return; |
1892 | } |
1882 | } |
1893 | op->duration--; |
1883 | op->duration--; |
1894 | |
1884 | |
1895 | basedir = op->direction; |
1885 | basedir = op->direction; |
… | |
… | |
2029 | cast_light (object *op, object *caster, object *spell, int dir) |
2019 | cast_light (object *op, object *caster, object *spell, int dir) |
2030 | { |
2020 | { |
2031 | object *target = NULL, *tmp = NULL; |
2021 | object *target = NULL, *tmp = NULL; |
2032 | sint16 x, y; |
2022 | sint16 x, y; |
2033 | int dam, mflags; |
2023 | int dam, mflags; |
2034 | mapstruct *m; |
2024 | maptile *m; |
2035 | |
2025 | |
2036 | dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
2026 | dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
2037 | |
2027 | |
2038 | if (!dir) |
2028 | if (!dir) |
2039 | { |
2029 | { |
… | |
… | |
2107 | cast_cause_disease (object *op, object *caster, object *spell, int dir) |
2097 | cast_cause_disease (object *op, object *caster, object *spell, int dir) |
2108 | { |
2098 | { |
2109 | sint16 x, y; |
2099 | sint16 x, y; |
2110 | int i, mflags, range, dam_mod, dur_mod; |
2100 | int i, mflags, range, dam_mod, dur_mod; |
2111 | object *walk; |
2101 | object *walk; |
2112 | mapstruct *m; |
2102 | maptile *m; |
2113 | |
2103 | |
2114 | x = op->x; |
2104 | x = op->x; |
2115 | y = op->y; |
2105 | y = op->y; |
2116 | |
2106 | |
2117 | /* If casting from a scroll, no direction will be available, so refer to the |
2107 | /* If casting from a scroll, no direction will be available, so refer to the |
… | |
… | |
2209 | { |
2199 | { |
2210 | object *flash; /* visual effect for inflicting disease */ |
2200 | object *flash; /* visual effect for inflicting disease */ |
2211 | |
2201 | |
2212 | new_draw_info_format (NDI_UNIQUE, 0, op, "You inflict %s on %s!", &disease->name, &walk->name); |
2202 | new_draw_info_format (NDI_UNIQUE, 0, op, "You inflict %s on %s!", &disease->name, &walk->name); |
2213 | |
2203 | |
2214 | free_object (disease); /* don't need this one anymore */ |
2204 | disease->destroy (0); /* don't need this one anymore */ |
2215 | flash = get_archetype (ARCH_DETECT_MAGIC); |
2205 | flash = get_archetype (ARCH_DETECT_MAGIC); |
2216 | flash->x = x; |
2206 | flash->x = x; |
2217 | flash->y = y; |
2207 | flash->y = y; |
2218 | flash->map = walk->map; |
2208 | flash->map = walk->map; |
2219 | insert_ob_in_map (flash, walk->map, op, 0); |
2209 | insert_ob_in_map (flash, walk->map, op, 0); |
2220 | return 1; |
2210 | return 1; |
2221 | } |
2211 | } |
2222 | free_object (disease); |
2212 | disease->destroy (0); |
2223 | } |
2213 | } |
2224 | } /* if living creature */ |
2214 | } /* if living creature */ |
2225 | } /* for range of spaces */ |
2215 | } /* for range of spaces */ |
2226 | new_draw_info (NDI_UNIQUE, 0, op, "No one caught anything!"); |
2216 | new_draw_info (NDI_UNIQUE, 0, op, "No one caught anything!"); |
2227 | return 1; |
2217 | return 1; |