1 | |
|
|
2 | /* |
|
|
3 | * static char *rcsid_spell_util_c = |
|
|
4 | * "$Id: spell_util.C,v 1.11 2006/09/10 15:59:58 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) 2001 Mark Wedel & Crossfire Development Team |
4 | Copyright (C) 2001 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 | |
24 | |
32 | #include <global.h> |
25 | #include <global.h> |
33 | #include <spells.h> |
26 | #include <spells.h> |
… | |
… | |
126 | } |
119 | } |
127 | |
120 | |
128 | i = 0; |
121 | i = 0; |
129 | while (spell_mapping[i]) |
122 | while (spell_mapping[i]) |
130 | { |
123 | { |
131 | if (!find_archetype (spell_mapping[i])) |
124 | if (!archetype::find (spell_mapping[i])) |
132 | { |
125 | { |
133 | LOG (llevError, "Unable to find spell mapping %s (%i)\n", spell_mapping[i], i); |
126 | LOG (llevError, "Unable to find spell mapping %s (%i)\n", spell_mapping[i], i); |
134 | } |
127 | } |
135 | i++; |
128 | i++; |
136 | } |
129 | } |
… | |
… | |
160 | /* pretty basic function - basically just takes |
153 | /* pretty basic function - basically just takes |
161 | * an object, sets the x,y, and calls insert_ob_in_map |
154 | * an object, sets the x,y, and calls insert_ob_in_map |
162 | */ |
155 | */ |
163 | |
156 | |
164 | void |
157 | void |
165 | spell_effect (object *spob, int x, int y, mapstruct *map, object *originator) |
158 | spell_effect (object *spob, int x, int y, maptile *map, object *originator) |
166 | { |
159 | { |
167 | |
160 | |
168 | if (spob->other_arch != NULL) |
161 | if (spob->other_arch != NULL) |
169 | { |
162 | { |
170 | object *effect = arch_to_object (spob->other_arch); |
163 | object *effect = arch_to_object (spob->other_arch); |
… | |
… | |
190 | min_casting_level (object *caster, object *spell) |
183 | min_casting_level (object *caster, object *spell) |
191 | { |
184 | { |
192 | int new_level; |
185 | int new_level; |
193 | |
186 | |
194 | if (caster->path_denied & spell->path_attuned) |
187 | if (caster->path_denied & spell->path_attuned) |
195 | { |
|
|
196 | /* This case is not a bug, just the fact that this function is |
|
|
197 | * usually called BEFORE checking for path_deny. -AV |
|
|
198 | */ |
|
|
199 | #if 0 |
|
|
200 | LOG (llevError, "BUG: path_level_mod (arch %s, name %s): casting denied " "spell\n", caster->arch->name, caster->name); |
|
|
201 | #endif |
|
|
202 | return 1; |
188 | return 1; |
203 | } |
189 | |
204 | new_level = spell->level |
190 | new_level = spell->level |
205 | + ((caster->path_repelled & spell->path_attuned) ? +2 : 0) + ((caster->path_attuned & spell->path_attuned) ? -2 : 0); |
191 | + ((caster->path_repelled & spell->path_attuned) ? +2 : 0) + ((caster->path_attuned & spell->path_attuned) ? -2 : 0); |
|
|
192 | |
206 | return (new_level < 1) ? 1 : new_level; |
193 | return (new_level < 1) ? 1 : new_level; |
207 | } |
194 | } |
208 | |
195 | |
209 | |
196 | |
210 | /* This function returns the effective level the spell |
197 | /* This function returns the effective level the spell |
… | |
… | |
219 | { |
206 | { |
220 | int level = caster->level; |
207 | int level = caster->level; |
221 | |
208 | |
222 | /* If this is a player, try to find the matching skill */ |
209 | /* If this is a player, try to find the matching skill */ |
223 | if (caster->type == PLAYER && spell->skill) |
210 | if (caster->type == PLAYER && spell->skill) |
224 | { |
|
|
225 | int i; |
|
|
226 | |
|
|
227 | for (i = 0; i < NUM_SKILLS; i++) |
211 | for (int i = 0; i < NUM_SKILLS; i++) |
228 | if (caster->contr->last_skill_ob[i] && caster->contr->last_skill_ob[i]->skill == spell->skill) |
212 | if (caster->contr->last_skill_ob[i] && caster->contr->last_skill_ob[i]->skill == spell->skill) |
229 | { |
213 | { |
230 | level = caster->contr->last_skill_ob[i]->level; |
214 | level = caster->contr->last_skill_ob[i]->level; |
231 | break; |
215 | break; |
232 | } |
216 | } |
233 | } |
|
|
234 | |
217 | |
235 | /* if a rod is fired by a player, take the use_magic_item skill in consideration. */ |
218 | /* if a rod is fired by a player, take the use_magic_item skill in consideration. */ |
236 | if (caster->type == ROD && caster->env && caster->env->type == PLAYER) |
219 | if (caster->type == ROD && caster->env && caster->env->type == PLAYER) |
237 | { |
220 | { |
238 | object *skill = find_skill_by_number (caster->env, SK_USE_MAGIC_ITEM); |
221 | object *skill = find_skill_by_number (caster->env, SK_USE_MAGIC_ITEM); |
… | |
… | |
247 | /* Always make this at least 1. If this is zero, we get divide by zero |
230 | /* Always make this at least 1. If this is zero, we get divide by zero |
248 | * errors in various places. |
231 | * errors in various places. |
249 | */ |
232 | */ |
250 | if (level < 1) |
233 | if (level < 1) |
251 | level = 1; |
234 | level = 1; |
|
|
235 | |
252 | return level; |
236 | return level; |
253 | } |
237 | } |
254 | |
238 | |
255 | /* The following function scales the spellpoint cost of |
239 | /* The following function scales the spellpoint cost of |
256 | * a spell by it's increased effectiveness. Some of the |
240 | * a spell by it's increased effectiveness. Some of the |
… | |
… | |
451 | * reflect_spell fails.) |
435 | * reflect_spell fails.) |
452 | * Caller should be sure it passes us valid map coordinates |
436 | * Caller should be sure it passes us valid map coordinates |
453 | * eg, updated for tiled maps. |
437 | * eg, updated for tiled maps. |
454 | */ |
438 | */ |
455 | int |
439 | int |
456 | reflwall (mapstruct *m, int x, int y, object *sp_op) |
440 | reflwall (maptile *m, int x, int y, object *sp_op) |
457 | { |
441 | { |
458 | object *op; |
442 | object *op; |
459 | |
443 | |
460 | if (OUT_OF_REAL_MAP (m, x, y)) |
444 | if (OUT_OF_REAL_MAP (m, x, y)) |
461 | return 0; |
445 | return 0; |
462 | for (op = get_map_ob (m, x, y); op != NULL; op = op->above) |
446 | for (op = GET_MAP_OB (m, x, y); op != NULL; op = op->above) |
463 | if (QUERY_FLAG (op, FLAG_REFL_SPELL) && (!QUERY_FLAG (op, FLAG_ALIVE) || |
447 | if (QUERY_FLAG (op, FLAG_REFL_SPELL) |
464 | sp_op->type == LIGHTNING || (rndm (0, 99)) < 90 - (sp_op->level / 10))) |
448 | && (!QUERY_FLAG (op, FLAG_ALIVE) |
|
|
449 | || (rndm (0, 99)) < 90 - (sp_op->level / 10))) |
465 | return 1; |
450 | return 1; |
466 | |
451 | |
467 | return 0; |
452 | return 0; |
468 | } |
453 | } |
469 | |
454 | |
… | |
… | |
475 | * in. |
460 | * in. |
476 | */ |
461 | */ |
477 | int |
462 | int |
478 | cast_create_obj (object *op, object *caster, object *new_op, int dir) |
463 | cast_create_obj (object *op, object *caster, object *new_op, int dir) |
479 | { |
464 | { |
480 | mapstruct *m; |
465 | maptile *m; |
481 | sint16 sx, sy; |
466 | sint16 sx, sy; |
482 | |
467 | |
483 | if (dir && |
468 | if (dir && |
484 | ((get_map_flags (op->map, &m, op->x + freearr_x[dir], op->y + freearr_y[dir], &sx, &sy) & P_OUT_OF_MAP) || |
469 | ((get_map_flags (op->map, &m, op->x + freearr_x[dir], op->y + freearr_y[dir], &sx, &sy) & P_OUT_OF_MAP) || |
485 | OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy)))) |
470 | OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy)))) |
… | |
… | |
505 | * does not have AT_MAGIC, then counterwalls do not effect the spell. |
490 | * does not have AT_MAGIC, then counterwalls do not effect the spell. |
506 | * |
491 | * |
507 | */ |
492 | */ |
508 | |
493 | |
509 | int |
494 | int |
510 | ok_to_put_more (mapstruct *m, sint16 x, sint16 y, object *op, int immune_stop) |
495 | ok_to_put_more (maptile *m, sint16 x, sint16 y, object *op, int immune_stop) |
511 | { |
496 | { |
512 | object *tmp; |
497 | object *tmp; |
513 | int mflags; |
498 | int mflags; |
514 | mapstruct *mp; |
499 | maptile *mp; |
515 | |
500 | |
516 | mp = m; |
501 | mp = m; |
517 | mflags = get_map_flags (m, &mp, x, y, &x, &y); |
502 | mflags = get_map_flags (m, &mp, x, y, &x, &y); |
518 | |
503 | |
519 | if (mflags & P_OUT_OF_MAP) |
504 | if (mflags & P_OUT_OF_MAP) |
520 | return 0; |
505 | return 0; |
521 | |
506 | |
522 | if (OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (mp, x, y))) |
507 | if (OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (mp, x, y))) |
523 | return 0; |
508 | return 0; |
524 | |
509 | |
525 | for (tmp = get_map_ob (mp, x, y); tmp != NULL; tmp = tmp->above) |
510 | for (tmp = GET_MAP_OB (mp, x, y); tmp != NULL; tmp = tmp->above) |
526 | { |
511 | { |
527 | /* If there is a counterspell on the space, and this |
512 | /* If there is a counterspell on the space, and this |
528 | * object is using magic, don't progress. I believe we could |
513 | * object is using magic, don't progress. I believe we could |
529 | * leave this out and let in progress, and other areas of the code |
514 | * leave this out and let in progress, and other areas of the code |
530 | * will then remove it, but that would seem to to use more |
515 | * will then remove it, but that would seem to to use more |
… | |
… | |
585 | int |
570 | int |
586 | fire_arch_from_position (object *op, object *caster, sint16 x, sint16 y, int dir, object *spell) |
571 | fire_arch_from_position (object *op, object *caster, sint16 x, sint16 y, int dir, object *spell) |
587 | { |
572 | { |
588 | object *tmp; |
573 | object *tmp; |
589 | int mflags; |
574 | int mflags; |
590 | mapstruct *m; |
575 | maptile *m; |
591 | |
576 | |
592 | if (spell->other_arch == NULL) |
577 | if (spell->other_arch == NULL) |
593 | return 0; |
578 | return 0; |
594 | |
579 | |
595 | m = op->map; |
580 | m = op->map; |
… | |
… | |
605 | return 0; |
590 | return 0; |
606 | |
591 | |
607 | if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (m, x, y))) |
592 | if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (m, x, y))) |
608 | { |
593 | { |
609 | new_draw_info (NDI_UNIQUE, 0, op, "You can't cast the spell on top of a wall!\n"); |
594 | new_draw_info (NDI_UNIQUE, 0, op, "You can't cast the spell on top of a wall!\n"); |
610 | free_object (tmp); |
595 | tmp->destroy (); |
611 | return 0; |
596 | return 0; |
612 | } |
597 | } |
613 | |
|
|
614 | |
|
|
615 | |
598 | |
616 | tmp->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
599 | tmp->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
617 | tmp->duration = spell->duration + SP_level_duration_adjust (caster, spell); |
600 | tmp->duration = spell->duration + SP_level_duration_adjust (caster, spell); |
618 | /* code in time.c uses food for some things, duration for others */ |
601 | /* code in time.c uses food for some things, duration for others */ |
619 | tmp->stats.food = tmp->duration; |
602 | tmp->stats.food = tmp->duration; |
620 | tmp->range = spell->range + SP_level_range_adjust (caster, spell); |
603 | tmp->range = spell->range + SP_level_range_adjust (caster, spell); |
621 | tmp->attacktype = spell->attacktype; |
604 | tmp->attacktype = spell->attacktype; |
622 | tmp->x = x; |
605 | tmp->x = x; |
623 | tmp->y = y; |
606 | tmp->y = y; |
624 | tmp->direction = dir; |
607 | tmp->direction = dir; |
625 | if (get_owner (op) != NULL) |
608 | if (op->owner != NULL) |
626 | copy_owner (tmp, op); |
609 | tmp->set_owner (op); |
627 | else |
610 | else |
628 | set_owner (tmp, op); |
611 | tmp->set_owner (op); |
629 | tmp->level = caster_level (caster, spell); |
612 | tmp->level = caster_level (caster, spell); |
630 | set_spell_skill (op, caster, spell, tmp); |
613 | set_spell_skill (op, caster, spell, tmp); |
631 | |
614 | |
632 | /* needed for AT_HOLYWORD,AT_GODPOWER stuff */ |
615 | /* needed for AT_HOLYWORD,AT_GODPOWER stuff */ |
633 | if (tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER) |
616 | if (tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER) |
… | |
… | |
685 | |
668 | |
686 | object * |
669 | object * |
687 | find_target_for_friendly_spell (object *op, int dir) |
670 | find_target_for_friendly_spell (object *op, int dir) |
688 | { |
671 | { |
689 | object *tmp; |
672 | object *tmp; |
690 | mapstruct *m; |
673 | maptile *m; |
691 | sint16 x, y; |
674 | sint16 x, y; |
692 | int mflags; |
675 | int mflags; |
693 | |
676 | |
694 | /* I don't really get this block - if op isn't a player or rune, |
677 | /* I don't really get this block - if op isn't a player or rune, |
695 | * we then make the owner of this object the target. |
678 | * we then make the owner of this object the target. |
696 | * The owner could very well be no where near op. |
679 | * The owner could very well be no where near op. |
697 | */ |
680 | */ |
698 | if (op->type != PLAYER && op->type != RUNE) |
681 | if (op->type != PLAYER && op->type != RUNE) |
699 | { |
682 | { |
700 | tmp = get_owner (op); |
683 | tmp = op->owner; |
701 | /* If the owner does not exist, or is not a monster, than apply the spell |
684 | /* If the owner does not exist, or is not a monster, than apply the spell |
702 | * to the caster. |
685 | * to the caster. |
703 | */ |
686 | */ |
704 | if (!tmp || !QUERY_FLAG (tmp, FLAG_MONSTER)) |
687 | if (!tmp || !QUERY_FLAG (tmp, FLAG_MONSTER)) |
705 | tmp = op; |
688 | tmp = op; |
… | |
… | |
711 | y = op->y + freearr_y[dir]; |
694 | y = op->y + freearr_y[dir]; |
712 | |
695 | |
713 | mflags = get_map_flags (m, &m, x, y, &x, &y); |
696 | mflags = get_map_flags (m, &m, x, y, &x, &y); |
714 | |
697 | |
715 | if (mflags & P_OUT_OF_MAP) |
698 | if (mflags & P_OUT_OF_MAP) |
716 | tmp = NULL; |
699 | tmp = 0; |
717 | else |
700 | else |
718 | { |
701 | tmp = m->at (x, y).player (); |
719 | for (tmp = get_map_ob (m, x, y); tmp != NULL; tmp = tmp->above) |
|
|
720 | if (tmp->type == PLAYER) |
|
|
721 | break; |
|
|
722 | } |
|
|
723 | } |
702 | } |
|
|
703 | |
724 | /* didn't find a player there, look in current square for a player */ |
704 | /* didn't find a player there, look in current square for a player */ |
725 | if (tmp == NULL) |
705 | if (!tmp) |
726 | for (tmp = get_map_ob (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) |
706 | tmp = op->ms ().player (); |
727 | { |
|
|
728 | if (tmp->type == PLAYER) |
|
|
729 | break; |
|
|
730 | } |
|
|
731 | |
707 | |
732 | return tmp; |
708 | return tmp; |
733 | } |
709 | } |
734 | |
710 | |
735 | |
711 | |
… | |
… | |
745 | * any, otherwise -1. |
721 | * any, otherwise -1. |
746 | * note that exclude can be NULL, in which case all bets are off. |
722 | * note that exclude can be NULL, in which case all bets are off. |
747 | */ |
723 | */ |
748 | |
724 | |
749 | int |
725 | int |
750 | spell_find_dir (mapstruct *m, int x, int y, object *exclude) |
726 | spell_find_dir (maptile *m, int x, int y, object *exclude) |
751 | { |
727 | { |
752 | int i, max = SIZEOFFREE; |
728 | int i, max = SIZEOFFREE; |
753 | sint16 nx, ny; |
729 | sint16 nx, ny; |
754 | int owner_type = 0, mflags; |
730 | int owner_type = 0, mflags; |
755 | object *tmp; |
731 | object *tmp; |
756 | mapstruct *mp; |
732 | maptile *mp; |
757 | |
733 | |
758 | if (exclude && exclude->head) |
734 | if (exclude && exclude->head) |
759 | exclude = exclude->head; |
735 | exclude = exclude->head; |
760 | if (exclude && exclude->type) |
736 | if (exclude && exclude->type) |
761 | owner_type = exclude->type; |
737 | owner_type = exclude->type; |
… | |
… | |
767 | mp = m; |
743 | mp = m; |
768 | mflags = get_map_flags (m, &mp, nx, ny, &nx, &ny); |
744 | mflags = get_map_flags (m, &mp, nx, ny, &nx, &ny); |
769 | if (mflags & (P_OUT_OF_MAP | P_BLOCKSVIEW)) |
745 | if (mflags & (P_OUT_OF_MAP | P_BLOCKSVIEW)) |
770 | continue; |
746 | continue; |
771 | |
747 | |
772 | tmp = get_map_ob (mp, nx, ny); |
748 | tmp = GET_MAP_OB (mp, nx, ny); |
773 | |
749 | |
774 | while (tmp != NULL && (((owner_type == PLAYER && |
750 | while (tmp != NULL && (((owner_type == PLAYER && |
775 | !QUERY_FLAG (tmp, FLAG_MONSTER) && !QUERY_FLAG (tmp, FLAG_GENERATOR)) || |
751 | !QUERY_FLAG (tmp, FLAG_MONSTER) && !QUERY_FLAG (tmp, FLAG_GENERATOR)) || |
776 | (owner_type != PLAYER && tmp->type != PLAYER)) || (tmp == exclude || (tmp->head && tmp->head == exclude)))) |
752 | (owner_type != PLAYER && tmp->type != PLAYER)) || (tmp == exclude || (tmp->head && tmp->head == exclude)))) |
777 | tmp = tmp->above; |
753 | tmp = tmp->above; |
… | |
… | |
796 | archetype *at; |
772 | archetype *at; |
797 | int dir; |
773 | int dir; |
798 | |
774 | |
799 | /* Handle cases where we are passed a bogus mosntername */ |
775 | /* Handle cases where we are passed a bogus mosntername */ |
800 | |
776 | |
801 | if ((at = find_archetype (monstername)) == NULL) |
777 | if ((at = archetype::find (monstername)) == NULL) |
802 | return; |
778 | return; |
803 | |
779 | |
804 | /* find a free square nearby |
780 | /* find a free square nearby |
805 | * first we check the closest square for free squares |
781 | * first we check the closest square for free squares |
806 | */ |
782 | */ |
… | |
… | |
973 | if (failure <= -20 && failure > -40) /* wonder */ |
949 | if (failure <= -20 && failure > -40) /* wonder */ |
974 | { |
950 | { |
975 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s gives a sign to renew your faith.", godname); |
951 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s gives a sign to renew your faith.", godname); |
976 | tmp = get_archetype (SPELL_WONDER); |
952 | tmp = get_archetype (SPELL_WONDER); |
977 | cast_cone (op, op, 0, tmp); |
953 | cast_cone (op, op, 0, tmp); |
978 | free_object (tmp); |
954 | tmp->destroy (); |
979 | } |
955 | } |
980 | |
956 | |
981 | else if (failure <= -40 && failure > -60) /* confusion */ |
957 | else if (failure <= -40 && failure > -60) /* confusion */ |
982 | { |
958 | { |
983 | new_draw_info (NDI_UNIQUE, 0, op, "Your diety touches your mind!"); |
959 | new_draw_info (NDI_UNIQUE, 0, op, "Your diety touches your mind!"); |
… | |
… | |
1017 | if (failure <= -20 && failure > -40) /* wonder */ |
993 | if (failure <= -20 && failure > -40) /* wonder */ |
1018 | { |
994 | { |
1019 | new_draw_info (NDI_UNIQUE, 0, op, "Your spell causes an unexpected effect."); |
995 | new_draw_info (NDI_UNIQUE, 0, op, "Your spell causes an unexpected effect."); |
1020 | tmp = get_archetype (SPELL_WONDER); |
996 | tmp = get_archetype (SPELL_WONDER); |
1021 | cast_cone (op, op, 0, tmp); |
997 | cast_cone (op, op, 0, tmp); |
1022 | free_object (tmp); |
998 | tmp->destroy (); |
1023 | } |
999 | } |
1024 | |
1000 | |
1025 | else if (failure <= -40 && failure > -60) /* confusion */ |
1001 | else if (failure <= -40 && failure > -60) /* confusion */ |
1026 | { |
1002 | { |
1027 | new_draw_info (NDI_UNIQUE, 0, op, "Your magic recoils on you, making you confused!"); |
1003 | new_draw_info (NDI_UNIQUE, 0, op, "Your magic recoils on you, making you confused!"); |
… | |
… | |
1082 | /* Always cast spell on caster */ |
1058 | /* Always cast spell on caster */ |
1083 | success = cast_spell (op, caster, dir, spell, stringarg); |
1059 | success = cast_spell (op, caster, dir, spell, stringarg); |
1084 | |
1060 | |
1085 | if (caster->contr->party == NULL) |
1061 | if (caster->contr->party == NULL) |
1086 | { |
1062 | { |
1087 | remove_ob (spell); |
1063 | spell->remove (); |
1088 | return success; |
1064 | return success; |
1089 | } |
1065 | } |
1090 | for (pl = first_player; pl != NULL; pl = pl->next) |
1066 | for_all_players (pl) |
1091 | if ((pl->ob->contr->party == caster->contr->party) && (on_same_map (pl->ob, caster))) |
1067 | if ((pl->ob->contr->party == caster->contr->party) && (on_same_map (pl->ob, caster))) |
1092 | { |
1068 | { |
1093 | cast_spell (pl->ob, caster, pl->ob->facing, spell, stringarg); |
1069 | cast_spell (pl->ob, caster, pl->ob->facing, spell, stringarg); |
1094 | } |
1070 | } |
1095 | remove_ob (spell); |
1071 | spell->remove (); |
1096 | return success; |
1072 | return success; |
1097 | } |
1073 | } |
1098 | |
1074 | |
1099 | /* This is where the main dispatch when someone casts a spell. |
1075 | /* This is where the main dispatch when someone casts a spell. |
1100 | * |
1076 | * |
… | |
… | |
1125 | */ |
1101 | */ |
1126 | |
1102 | |
1127 | int |
1103 | int |
1128 | cast_spell (object *op, object *caster, int dir, object *spell_ob, char *stringarg) |
1104 | cast_spell (object *op, object *caster, int dir, object *spell_ob, char *stringarg) |
1129 | { |
1105 | { |
1130 | |
|
|
1131 | const char *godname; |
1106 | const char *godname; |
1132 | int success = 0, mflags, cast_level = 0, old_shoottype; |
1107 | int success = 0, mflags, cast_level = 0, old_shoottype; |
1133 | object *skill = NULL; |
1108 | object *skill = NULL; |
1134 | |
1109 | |
1135 | old_shoottype = op->contr ? op->contr->shoottype : 0; |
1110 | old_shoottype = op->contr ? op->contr->shoottype : 0; |
… | |
… | |
1137 | if (!spell_ob) |
1112 | if (!spell_ob) |
1138 | { |
1113 | { |
1139 | LOG (llevError, "cast_spell: null spell object passed\n"); |
1114 | LOG (llevError, "cast_spell: null spell object passed\n"); |
1140 | return 0; |
1115 | return 0; |
1141 | } |
1116 | } |
|
|
1117 | |
1142 | if (!strcmp ((godname = determine_god (op)), "none")) |
1118 | if (!strcmp ((godname = determine_god (op)), "none")) |
1143 | godname = "A random spirit"; |
1119 | godname = "A random spirit"; |
1144 | |
1120 | |
1145 | /* the caller should set caster to op if appropriate */ |
1121 | /* the caller should set caster to op if appropriate */ |
1146 | if (!caster) |
1122 | if (!caster) |
… | |
… | |
1150 | } |
1126 | } |
1151 | |
1127 | |
1152 | /* if caster is a spell casting object, this normally shouldn't be |
1128 | /* if caster is a spell casting object, this normally shouldn't be |
1153 | * an issue, because they don't have any spellpaths set up. |
1129 | * an issue, because they don't have any spellpaths set up. |
1154 | */ |
1130 | */ |
1155 | if (caster->path_denied & spell_ob->path_attuned) |
1131 | if (caster->path_denied & spell_ob->path_attuned && !QUERY_FLAG (caster, FLAG_WIZCAST)) |
1156 | { |
1132 | { |
1157 | new_draw_info (NDI_UNIQUE, 0, op, "That spell path is denied to you."); |
1133 | new_draw_info (NDI_UNIQUE, 0, op, "That spell path is denied to you."); |
1158 | return 0; |
1134 | return 0; |
1159 | } |
1135 | } |
1160 | |
1136 | |
… | |
… | |
1268 | if ((mflags & P_NO_CLERIC) && spell_ob->stats.grace) |
1244 | if ((mflags & P_NO_CLERIC) && spell_ob->stats.grace) |
1269 | new_draw_info_format (NDI_UNIQUE, 0, op, "This ground is unholy! %s ignores you.", godname); |
1245 | new_draw_info_format (NDI_UNIQUE, 0, op, "This ground is unholy! %s ignores you.", godname); |
1270 | else |
1246 | else |
1271 | switch (op->contr->shoottype) |
1247 | switch (op->contr->shoottype) |
1272 | { |
1248 | { |
1273 | case range_magic: |
1249 | case range_magic: |
1274 | new_draw_info (NDI_UNIQUE, 0, op, "Something blocks your spellcasting."); |
1250 | new_draw_info (NDI_UNIQUE, 0, op, "Something blocks your spellcasting."); |
1275 | break; |
1251 | break; |
1276 | case range_misc: |
1252 | case range_misc: |
1277 | new_draw_info (NDI_UNIQUE, 0, op, "Something blocks the magic of your item."); |
1253 | new_draw_info (NDI_UNIQUE, 0, op, "Something blocks the magic of your item."); |
1278 | break; |
1254 | break; |
1279 | case range_golem: |
1255 | case range_golem: |
1280 | new_draw_info (NDI_UNIQUE, 0, op, "Something blocks the magic of your scroll."); |
1256 | new_draw_info (NDI_UNIQUE, 0, op, "Something blocks the magic of your scroll."); |
1281 | break; |
1257 | break; |
1282 | default: |
1258 | default: |
1283 | break; |
1259 | break; |
1284 | } |
1260 | } |
1285 | return 0; |
1261 | return 0; |
1286 | } |
1262 | } |
1287 | |
1263 | |
1288 | if (caster == op && settings.casting_time == TRUE && spell_ob->type == SPELL) |
1264 | if (caster == op && settings.casting_time == TRUE && spell_ob->type == SPELL) |
… | |
… | |
1295 | * spell is actually cast, it knows about the stringarg. |
1271 | * spell is actually cast, it knows about the stringarg. |
1296 | * necessary for the invoke command spells. |
1272 | * necessary for the invoke command spells. |
1297 | */ |
1273 | */ |
1298 | if (stringarg) |
1274 | if (stringarg) |
1299 | { |
1275 | { |
1300 | op->spellarg = strdup_local (stringarg); |
1276 | op->spellarg = strdup (stringarg); |
1301 | } |
1277 | } |
1302 | else |
1278 | else |
1303 | op->spellarg = NULL; |
1279 | op->spellarg = NULL; |
1304 | return 0; |
1280 | return 0; |
1305 | } |
1281 | } |
… | |
… | |
1362 | change_skill (op, skill, 0); /* needed for proper exp credit */ |
1338 | change_skill (op, skill, 0); /* needed for proper exp credit */ |
1363 | } |
1339 | } |
1364 | |
1340 | |
1365 | switch (spell_ob->subtype) |
1341 | switch (spell_ob->subtype) |
1366 | { |
1342 | { |
1367 | /* The order of case statements is same as the order they show up |
1343 | /* The order of case statements is same as the order they show up |
1368 | * in in spells.h. |
1344 | * in in spells.h. |
1369 | */ |
1345 | */ |
1370 | case SP_RAISE_DEAD: |
1346 | case SP_RAISE_DEAD: |
1371 | success = cast_raise_dead_spell (op, caster, spell_ob, dir, stringarg); |
1347 | success = cast_raise_dead_spell (op, caster, spell_ob, dir, stringarg); |
1372 | break; |
1348 | break; |
1373 | |
1349 | |
1374 | case SP_RUNE: |
1350 | case SP_RUNE: |
1375 | success = write_rune (op, caster, spell_ob, dir, stringarg); |
1351 | success = write_rune (op, caster, spell_ob, dir, stringarg); |
1376 | break; |
1352 | break; |
1377 | |
1353 | |
1378 | case SP_MAKE_MARK: |
1354 | case SP_MAKE_MARK: |
1379 | success = write_mark (op, spell_ob, stringarg); |
1355 | success = write_mark (op, spell_ob, stringarg); |
1380 | break; |
1356 | break; |
1381 | |
1357 | |
1382 | case SP_BOLT: |
1358 | case SP_BOLT: |
1383 | success = fire_bolt (op, caster, dir, spell_ob, skill); |
1359 | success = fire_bolt (op, caster, dir, spell_ob, skill); |
1384 | break; |
1360 | break; |
1385 | |
1361 | |
1386 | case SP_BULLET: |
1362 | case SP_BULLET: |
1387 | success = fire_bullet (op, caster, dir, spell_ob); |
1363 | success = fire_bullet (op, caster, dir, spell_ob); |
1388 | break; |
1364 | break; |
1389 | |
1365 | |
1390 | case SP_CONE: |
1366 | case SP_CONE: |
1391 | success = cast_cone (op, caster, dir, spell_ob); |
1367 | success = cast_cone (op, caster, dir, spell_ob); |
1392 | break; |
1368 | break; |
1393 | |
1369 | |
1394 | case SP_BOMB: |
1370 | case SP_BOMB: |
1395 | success = create_bomb (op, caster, dir, spell_ob); |
1371 | success = create_bomb (op, caster, dir, spell_ob); |
1396 | break; |
1372 | break; |
1397 | |
1373 | |
1398 | case SP_WONDER: |
1374 | case SP_WONDER: |
1399 | success = cast_wonder (op, caster, dir, spell_ob); |
1375 | success = cast_wonder (op, caster, dir, spell_ob); |
1400 | break; |
1376 | break; |
1401 | |
1377 | |
1402 | case SP_SMITE: |
1378 | case SP_SMITE: |
1403 | success = cast_smite_spell (op, caster, dir, spell_ob); |
1379 | success = cast_smite_spell (op, caster, dir, spell_ob); |
1404 | break; |
1380 | break; |
1405 | |
1381 | |
1406 | case SP_MAGIC_MISSILE: |
1382 | case SP_MAGIC_MISSILE: |
|
|
1383 | success = fire_arch_from_position (op, caster, op->x + freearr_x[dir], op->y + freearr_y[dir], dir, spell_ob); |
|
|
1384 | break; |
|
|
1385 | |
|
|
1386 | case SP_SUMMON_GOLEM: |
|
|
1387 | success = summon_golem (op, caster, dir, spell_ob); |
|
|
1388 | old_shoottype = range_golem; |
|
|
1389 | break; |
|
|
1390 | |
|
|
1391 | case SP_DIMENSION_DOOR: |
|
|
1392 | /* dimension door needs the actual caster, because that is what is |
|
|
1393 | * moved. |
|
|
1394 | */ |
|
|
1395 | success = dimension_door (op, caster, spell_ob, dir); |
|
|
1396 | break; |
|
|
1397 | |
|
|
1398 | case SP_MAGIC_MAPPING: |
|
|
1399 | if (op->type == PLAYER) |
|
|
1400 | { |
|
|
1401 | spell_effect (spell_ob, op->x, op->y, op->map, op); |
|
|
1402 | draw_magic_map (op); |
|
|
1403 | success = 1; |
|
|
1404 | } |
|
|
1405 | else |
|
|
1406 | success = 0; |
|
|
1407 | break; |
|
|
1408 | |
|
|
1409 | case SP_MAGIC_WALL: |
|
|
1410 | success = magic_wall (op, caster, dir, spell_ob); |
|
|
1411 | break; |
|
|
1412 | |
|
|
1413 | case SP_DESTRUCTION: |
|
|
1414 | success = cast_destruction (op, caster, spell_ob); |
|
|
1415 | break; |
|
|
1416 | |
|
|
1417 | case SP_PERCEIVE_SELF: |
|
|
1418 | success = perceive_self (op); |
|
|
1419 | break; |
|
|
1420 | |
|
|
1421 | case SP_WORD_OF_RECALL: |
|
|
1422 | success = cast_word_of_recall (op, caster, spell_ob); |
|
|
1423 | break; |
|
|
1424 | |
|
|
1425 | case SP_INVISIBLE: |
|
|
1426 | success = cast_invisible (op, caster, spell_ob); |
|
|
1427 | break; |
|
|
1428 | |
|
|
1429 | case SP_PROBE: |
|
|
1430 | success = probe (op, caster, spell_ob, dir); |
|
|
1431 | break; |
|
|
1432 | |
|
|
1433 | case SP_HEALING: |
|
|
1434 | success = cast_heal (op, caster, spell_ob, dir); |
|
|
1435 | break; |
|
|
1436 | |
|
|
1437 | case SP_CREATE_FOOD: |
|
|
1438 | success = cast_create_food (op, caster, spell_ob, dir, stringarg); |
|
|
1439 | break; |
|
|
1440 | |
|
|
1441 | case SP_EARTH_TO_DUST: |
|
|
1442 | success = cast_earth_to_dust (op, caster, spell_ob); |
|
|
1443 | break; |
|
|
1444 | |
|
|
1445 | case SP_CHANGE_ABILITY: |
|
|
1446 | success = cast_change_ability (op, caster, spell_ob, dir, 0); |
|
|
1447 | break; |
|
|
1448 | |
|
|
1449 | case SP_BLESS: |
|
|
1450 | success = cast_bless (op, caster, spell_ob, dir); |
|
|
1451 | break; |
|
|
1452 | |
|
|
1453 | case SP_CURSE: |
|
|
1454 | success = cast_curse (op, caster, spell_ob, dir); |
|
|
1455 | break; |
|
|
1456 | |
|
|
1457 | case SP_SUMMON_MONSTER: |
|
|
1458 | success = summon_object (op, caster, spell_ob, dir, stringarg); |
|
|
1459 | break; |
|
|
1460 | |
|
|
1461 | case SP_CHARGING: |
|
|
1462 | success = recharge (op, caster, spell_ob); |
|
|
1463 | break; |
|
|
1464 | |
|
|
1465 | case SP_POLYMORPH: |
|
|
1466 | #ifdef NO_POLYMORPH |
|
|
1467 | /* Not great, but at least provide feedback so if players do have |
|
|
1468 | * polymorph (ie, find it as a preset item or left over from before |
|
|
1469 | * it was disabled), they get some feedback. |
|
|
1470 | */ |
|
|
1471 | new_draw_info (NDI_UNIQUE, 0, op, "The spell fizzles"); |
|
|
1472 | success = 0; |
|
|
1473 | #else |
|
|
1474 | success = cast_polymorph (op, caster, spell_ob, dir); |
|
|
1475 | #endif |
|
|
1476 | break; |
|
|
1477 | |
|
|
1478 | case SP_ALCHEMY: |
|
|
1479 | success = alchemy (op, caster, spell_ob); |
|
|
1480 | break; |
|
|
1481 | |
|
|
1482 | case SP_REMOVE_CURSE: |
|
|
1483 | success = remove_curse (op, caster, spell_ob); |
|
|
1484 | break; |
|
|
1485 | |
|
|
1486 | case SP_IDENTIFY: |
|
|
1487 | success = cast_identify (op, caster, spell_ob); |
|
|
1488 | break; |
|
|
1489 | |
|
|
1490 | case SP_DETECTION: |
|
|
1491 | success = cast_detection (op, caster, spell_ob, skill); |
|
|
1492 | break; |
|
|
1493 | |
|
|
1494 | case SP_MOOD_CHANGE: |
|
|
1495 | success = mood_change (op, caster, spell_ob); |
|
|
1496 | break; |
|
|
1497 | |
|
|
1498 | case SP_MOVING_BALL: |
|
|
1499 | if (spell_ob->path_repelled && (spell_ob->path_repelled & caster->path_attuned) != spell_ob->path_repelled) |
|
|
1500 | { |
|
|
1501 | new_draw_info_format (NDI_UNIQUE, 0, op, "You lack the proper attunement to cast %s", &spell_ob->name); |
|
|
1502 | success = 0; |
|
|
1503 | } |
|
|
1504 | else |
1407 | success = fire_arch_from_position (op, caster, op->x + freearr_x[dir], op->y + freearr_y[dir], dir, spell_ob); |
1505 | success = fire_arch_from_position (op, caster, op->x + freearr_x[dir], op->y + freearr_y[dir], dir, spell_ob); |
1408 | break; |
1506 | break; |
1409 | |
1507 | |
1410 | case SP_SUMMON_GOLEM: |
|
|
1411 | success = summon_golem (op, caster, dir, spell_ob); |
|
|
1412 | old_shoottype = range_golem; |
|
|
1413 | break; |
|
|
1414 | |
|
|
1415 | case SP_DIMENSION_DOOR: |
|
|
1416 | /* dimension door needs the actual caster, because that is what is |
|
|
1417 | * moved. |
|
|
1418 | */ |
|
|
1419 | success = dimension_door (op, caster, spell_ob, dir); |
|
|
1420 | break; |
|
|
1421 | |
|
|
1422 | case SP_MAGIC_MAPPING: |
|
|
1423 | if (op->type == PLAYER) |
|
|
1424 | { |
|
|
1425 | spell_effect (spell_ob, op->x, op->y, op->map, op); |
|
|
1426 | draw_magic_map (op); |
|
|
1427 | success = 1; |
|
|
1428 | } |
|
|
1429 | else |
|
|
1430 | success = 0; |
|
|
1431 | break; |
|
|
1432 | |
|
|
1433 | case SP_MAGIC_WALL: |
|
|
1434 | success = magic_wall (op, caster, dir, spell_ob); |
|
|
1435 | break; |
|
|
1436 | |
|
|
1437 | case SP_DESTRUCTION: |
|
|
1438 | success = cast_destruction (op, caster, spell_ob); |
|
|
1439 | break; |
|
|
1440 | |
|
|
1441 | case SP_PERCEIVE_SELF: |
|
|
1442 | success = perceive_self (op); |
|
|
1443 | break; |
|
|
1444 | |
|
|
1445 | case SP_WORD_OF_RECALL: |
|
|
1446 | success = cast_word_of_recall (op, caster, spell_ob); |
|
|
1447 | break; |
|
|
1448 | |
|
|
1449 | case SP_INVISIBLE: |
|
|
1450 | success = cast_invisible (op, caster, spell_ob); |
|
|
1451 | break; |
|
|
1452 | |
|
|
1453 | case SP_PROBE: |
|
|
1454 | success = probe (op, caster, spell_ob, dir); |
|
|
1455 | break; |
|
|
1456 | |
|
|
1457 | case SP_HEALING: |
|
|
1458 | success = cast_heal (op, caster, spell_ob, dir); |
|
|
1459 | break; |
|
|
1460 | |
|
|
1461 | case SP_CREATE_FOOD: |
|
|
1462 | success = cast_create_food (op, caster, spell_ob, dir, stringarg); |
|
|
1463 | break; |
|
|
1464 | |
|
|
1465 | case SP_EARTH_TO_DUST: |
|
|
1466 | success = cast_earth_to_dust (op, caster, spell_ob); |
|
|
1467 | break; |
|
|
1468 | |
|
|
1469 | case SP_CHANGE_ABILITY: |
|
|
1470 | success = cast_change_ability (op, caster, spell_ob, dir, 0); |
|
|
1471 | break; |
|
|
1472 | |
|
|
1473 | case SP_BLESS: |
|
|
1474 | success = cast_bless (op, caster, spell_ob, dir); |
|
|
1475 | break; |
|
|
1476 | |
|
|
1477 | case SP_CURSE: |
|
|
1478 | success = cast_curse (op, caster, spell_ob, dir); |
|
|
1479 | break; |
|
|
1480 | |
|
|
1481 | case SP_SUMMON_MONSTER: |
|
|
1482 | success = summon_object (op, caster, spell_ob, dir, stringarg); |
|
|
1483 | break; |
|
|
1484 | |
|
|
1485 | case SP_CHARGING: |
|
|
1486 | success = recharge (op, caster, spell_ob); |
|
|
1487 | break; |
|
|
1488 | |
|
|
1489 | case SP_POLYMORPH: |
|
|
1490 | #ifdef NO_POLYMORPH |
|
|
1491 | /* Not great, but at least provide feedback so if players do have |
|
|
1492 | * polymorph (ie, find it as a preset item or left over from before |
|
|
1493 | * it was disabled), they get some feedback. |
|
|
1494 | */ |
|
|
1495 | new_draw_info (NDI_UNIQUE, 0, op, "The spell fizzles"); |
|
|
1496 | success = 0; |
|
|
1497 | #else |
|
|
1498 | success = cast_polymorph (op, caster, spell_ob, dir); |
|
|
1499 | #endif |
|
|
1500 | break; |
|
|
1501 | |
|
|
1502 | case SP_ALCHEMY: |
|
|
1503 | success = alchemy (op, caster, spell_ob); |
|
|
1504 | break; |
|
|
1505 | |
|
|
1506 | case SP_REMOVE_CURSE: |
|
|
1507 | success = remove_curse (op, caster, spell_ob); |
|
|
1508 | break; |
|
|
1509 | |
|
|
1510 | case SP_IDENTIFY: |
|
|
1511 | success = cast_identify (op, caster, spell_ob); |
|
|
1512 | break; |
|
|
1513 | |
|
|
1514 | case SP_DETECTION: |
|
|
1515 | success = cast_detection (op, caster, spell_ob, skill); |
|
|
1516 | break; |
|
|
1517 | |
|
|
1518 | case SP_MOOD_CHANGE: |
|
|
1519 | success = mood_change (op, caster, spell_ob); |
|
|
1520 | break; |
|
|
1521 | |
|
|
1522 | case SP_MOVING_BALL: |
|
|
1523 | if (spell_ob->path_repelled && (spell_ob->path_repelled & caster->path_attuned) != spell_ob->path_repelled) |
|
|
1524 | { |
|
|
1525 | new_draw_info_format (NDI_UNIQUE, 0, op, "You lack the proper attunement to cast %s", &spell_ob->name); |
|
|
1526 | success = 0; |
|
|
1527 | } |
|
|
1528 | else |
|
|
1529 | success = fire_arch_from_position (op, caster, op->x + freearr_x[dir], op->y + freearr_y[dir], dir, spell_ob); |
|
|
1530 | break; |
|
|
1531 | |
|
|
1532 | case SP_SWARM: |
1508 | case SP_SWARM: |
1533 | success = fire_swarm (op, caster, spell_ob, dir); |
1509 | success = fire_swarm (op, caster, spell_ob, dir); |
1534 | break; |
1510 | break; |
1535 | |
1511 | |
1536 | case SP_CHANGE_MANA: |
1512 | case SP_CHANGE_MANA: |
1537 | success = cast_transfer (op, caster, spell_ob, dir); |
1513 | success = cast_transfer (op, caster, spell_ob, dir); |
1538 | break; |
1514 | break; |
1539 | |
1515 | |
1540 | case SP_DISPEL_RUNE: |
1516 | case SP_DISPEL_RUNE: |
1541 | /* in rune.c */ |
1517 | /* in rune.c */ |
1542 | success = dispel_rune (op, caster, spell_ob, skill, dir); |
1518 | success = dispel_rune (op, caster, spell_ob, skill, dir); |
1543 | break; |
1519 | break; |
1544 | |
1520 | |
1545 | case SP_CREATE_MISSILE: |
1521 | case SP_CREATE_MISSILE: |
1546 | success = cast_create_missile (op, caster, spell_ob, dir, stringarg); |
1522 | success = cast_create_missile (op, caster, spell_ob, dir, stringarg); |
1547 | break; |
1523 | break; |
1548 | |
1524 | |
1549 | case SP_CONSECRATE: |
1525 | case SP_CONSECRATE: |
1550 | success = cast_consecrate (op, caster, spell_ob); |
1526 | success = cast_consecrate (op, caster, spell_ob); |
1551 | break; |
1527 | break; |
1552 | |
1528 | |
1553 | case SP_ANIMATE_WEAPON: |
1529 | case SP_ANIMATE_WEAPON: |
1554 | success = animate_weapon (op, caster, spell_ob, dir); |
1530 | success = animate_weapon (op, caster, spell_ob, dir); |
1555 | old_shoottype = range_golem; |
1531 | old_shoottype = range_golem; |
1556 | break; |
1532 | break; |
1557 | |
1533 | |
1558 | case SP_LIGHT: |
1534 | case SP_LIGHT: |
1559 | success = cast_light (op, caster, spell_ob, dir); |
1535 | success = cast_light (op, caster, spell_ob, dir); |
1560 | break; |
1536 | break; |
1561 | |
1537 | |
1562 | case SP_CHANGE_MAP_LIGHT: |
1538 | case SP_CHANGE_MAP_LIGHT: |
1563 | success = cast_change_map_lightlevel (op, caster, spell_ob); |
1539 | success = cast_change_map_lightlevel (op, caster, spell_ob); |
1564 | break; |
1540 | break; |
1565 | |
1541 | |
1566 | case SP_FAERY_FIRE: |
1542 | case SP_FAERY_FIRE: |
1567 | success = cast_destruction (op, caster, spell_ob); |
1543 | success = cast_destruction (op, caster, spell_ob); |
1568 | break; |
1544 | break; |
1569 | |
1545 | |
1570 | case SP_CAUSE_DISEASE: |
1546 | case SP_CAUSE_DISEASE: |
1571 | success = cast_cause_disease (op, caster, spell_ob, dir); |
1547 | success = cast_cause_disease (op, caster, spell_ob, dir); |
1572 | break; |
1548 | break; |
1573 | |
1549 | |
1574 | case SP_AURA: |
1550 | case SP_AURA: |
1575 | success = create_aura (op, caster, spell_ob); |
1551 | success = create_aura (op, caster, spell_ob); |
1576 | break; |
1552 | break; |
1577 | |
1553 | |
1578 | case SP_TOWN_PORTAL: |
1554 | case SP_TOWN_PORTAL: |
1579 | success = cast_create_town_portal (op, caster, spell_ob, dir); |
1555 | success = cast_create_town_portal (op, caster, spell_ob, dir); |
1580 | break; |
1556 | break; |
1581 | |
1557 | |
1582 | case SP_PARTY_SPELL: |
1558 | case SP_PARTY_SPELL: |
1583 | success = cast_party_spell (op, caster, dir, spell_ob, stringarg); |
1559 | success = cast_party_spell (op, caster, dir, spell_ob, stringarg); |
1584 | break; |
1560 | break; |
1585 | |
1561 | |
1586 | default: |
1562 | default: |
1587 | if (!INVOKE_OBJECT (CAST_SPELL, spell_ob, ARG_OBJECT (op), ARG_OBJECT (caster), ARG_INT (dir), ARG_STRING (stringarg))) |
1563 | if (!INVOKE_OBJECT (CAST_SPELL, spell_ob, ARG_OBJECT (op), ARG_OBJECT (caster), ARG_INT (dir), ARG_STRING (stringarg))) |
1588 | LOG (llevError, "cast_spell: Unhandled spell subtype %d\n", spell_ob->subtype); |
1564 | LOG (llevError, "cast_spell: Unhandled spell subtype %d\n", spell_ob->subtype); |
1589 | |
|
|
1590 | |
|
|
1591 | } |
1565 | } |
1592 | |
1566 | |
1593 | /* FIXME - we need some better sound suppport */ |
1567 | /* FIXME - we need some better sound suppport */ |
1594 | // yes, for example, augment map info with the spell effect |
1568 | // yes, for example, augment map info with the spell effect |
1595 | // so clients can calculate the sounds themselves |
1569 | // so clients can calculate the sounds themselves |
… | |
… | |
1617 | * then dispatches them to the appropriate specific routines. |
1591 | * then dispatches them to the appropriate specific routines. |
1618 | */ |
1592 | */ |
1619 | void |
1593 | void |
1620 | move_spell_effect (object *op) |
1594 | move_spell_effect (object *op) |
1621 | { |
1595 | { |
1622 | |
|
|
1623 | switch (op->subtype) |
1596 | switch (op->subtype) |
1624 | { |
1597 | { |
1625 | case SP_BOLT: |
1598 | case SP_BOLT: |
1626 | move_bolt (op); |
1599 | move_bolt (op); |
1627 | break; |
1600 | break; |
1628 | |
1601 | |
1629 | case SP_BULLET: |
1602 | case SP_BULLET: |
1630 | move_bullet (op); |
1603 | move_bullet (op); |
1631 | break; |
1604 | break; |
1632 | |
1605 | |
1633 | case SP_EXPLOSION: |
1606 | case SP_EXPLOSION: |
1634 | explosion (op); |
1607 | explosion (op); |
1635 | break; |
1608 | break; |
1636 | |
1609 | |
1637 | case SP_CONE: |
1610 | case SP_CONE: |
1638 | move_cone (op); |
1611 | move_cone (op); |
1639 | break; |
1612 | break; |
1640 | |
1613 | |
1641 | case SP_BOMB: |
1614 | case SP_BOMB: |
1642 | animate_bomb (op); |
1615 | animate_bomb (op); |
1643 | break; |
1616 | break; |
1644 | |
1617 | |
1645 | case SP_MAGIC_MISSILE: |
1618 | case SP_MAGIC_MISSILE: |
1646 | move_missile (op); |
1619 | move_missile (op); |
1647 | break; |
1620 | break; |
1648 | |
1621 | |
1649 | case SP_WORD_OF_RECALL: |
1622 | case SP_WORD_OF_RECALL: |
1650 | execute_word_of_recall (op); |
1623 | execute_word_of_recall (op); |
1651 | break; |
1624 | break; |
1652 | |
1625 | |
1653 | case SP_MOVING_BALL: |
1626 | case SP_MOVING_BALL: |
1654 | move_ball_spell (op); |
1627 | move_ball_spell (op); |
1655 | break; |
1628 | break; |
1656 | |
1629 | |
1657 | case SP_SWARM: |
1630 | case SP_SWARM: |
1658 | move_swarm_spell (op); |
1631 | move_swarm_spell (op); |
1659 | break; |
1632 | break; |
1660 | |
1633 | |
1661 | case SP_AURA: |
1634 | case SP_AURA: |
1662 | move_aura (op); |
1635 | move_aura (op); |
1663 | break; |
1636 | break; |
1664 | |
|
|
1665 | } |
1637 | } |
1666 | } |
1638 | } |
1667 | |
1639 | |
1668 | /* this checks to see if something special should happen if |
1640 | /* this checks to see if something special should happen if |
1669 | * something runs into the object. |
1641 | * something runs into the object. |
1670 | */ |
1642 | */ |
1671 | void |
1643 | void |
1672 | check_spell_effect (object *op) |
1644 | check_spell_effect (object *op) |
1673 | { |
1645 | { |
1674 | |
|
|
1675 | switch (op->subtype) |
1646 | switch (op->subtype) |
1676 | { |
1647 | { |
1677 | case SP_BOLT: |
1648 | case SP_BOLT: |
1678 | move_bolt (op); |
1649 | move_bolt (op); |
1679 | return; |
1650 | return; |
1680 | |
1651 | |
1681 | case SP_BULLET: |
1652 | case SP_BULLET: |
1682 | check_bullet (op); |
1653 | check_bullet (op); |
1683 | return; |
1654 | return; |
1684 | } |
1655 | } |
1685 | |
|
|
1686 | } |
1656 | } |
1687 | |
1657 | |
1688 | /* This is called by move_apply. Basically, if someone |
1658 | /* This is called by move_apply. Basically, if someone |
1689 | * moves onto a spell effect and the walk_on or fly_on flags |
1659 | * moves onto a spell effect and the walk_on or fly_on flags |
1690 | * are set, this is called. This should only be called for |
1660 | * are set, this is called. This should only be called for |
… | |
… | |
1693 | void |
1663 | void |
1694 | apply_spell_effect (object *spell, object *victim) |
1664 | apply_spell_effect (object *spell, object *victim) |
1695 | { |
1665 | { |
1696 | switch (spell->subtype) |
1666 | switch (spell->subtype) |
1697 | { |
1667 | { |
1698 | case SP_CONE: |
1668 | case SP_CONE: |
1699 | if (QUERY_FLAG (victim, FLAG_ALIVE) && spell->speed && spell->attacktype) |
1669 | if (QUERY_FLAG (victim, FLAG_ALIVE) && spell->speed && spell->attacktype) |
1700 | hit_player (victim, spell->stats.dam, spell, spell->attacktype, 0); |
1670 | hit_player (victim, spell->stats.dam, spell, spell->attacktype, 0); |
1701 | break; |
1671 | break; |
1702 | |
1672 | |
1703 | case SP_MAGIC_MISSILE: |
1673 | case SP_MAGIC_MISSILE: |
1704 | if (QUERY_FLAG (victim, FLAG_ALIVE)) |
1674 | if (QUERY_FLAG (victim, FLAG_ALIVE)) |
1705 | { |
1675 | { |
1706 | tag_t spell_tag = spell->count; |
|
|
1707 | |
|
|
1708 | hit_player (victim, spell->stats.dam, spell, spell->attacktype, 1); |
|
|
1709 | if (!was_destroyed (spell, spell_tag)) |
|
|
1710 | { |
|
|
1711 | remove_ob (spell); |
|
|
1712 | free_object (spell); |
|
|
1713 | } |
|
|
1714 | } |
|
|
1715 | break; |
|
|
1716 | |
|
|
1717 | case SP_MOVING_BALL: |
|
|
1718 | if (QUERY_FLAG (victim, FLAG_ALIVE)) |
|
|
1719 | hit_player (victim, spell->stats.dam, spell, spell->attacktype, 1); |
1676 | hit_player (victim, spell->stats.dam, spell, spell->attacktype, 1); |
|
|
1677 | |
|
|
1678 | if (!spell->destroyed ()) |
|
|
1679 | spell->destroy (); |
|
|
1680 | } |
|
|
1681 | break; |
|
|
1682 | |
|
|
1683 | case SP_MOVING_BALL: |
|
|
1684 | if (QUERY_FLAG (victim, FLAG_ALIVE)) |
|
|
1685 | hit_player (victim, spell->stats.dam, spell, spell->attacktype, 1); |
1720 | else if (victim->material || victim->materialname) |
1686 | else if (victim->material || victim->materialname) |
1721 | save_throw_object (victim, spell->attacktype, spell); |
1687 | save_throw_object (victim, spell->attacktype, spell); |
1722 | break; |
1688 | break; |
1723 | } |
1689 | } |
1724 | } |
1690 | } |