1 | |
|
|
2 | /* |
|
|
3 | * static char *rcsid_spell_util_c = |
|
|
4 | * "$Id: spell_util.C,v 1.12 2006/09/11 20:26:41 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 | |
… | |
… | |
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 | } |
… | |
… | |
1695 | break; |
1671 | break; |
1696 | |
1672 | |
1697 | case SP_MAGIC_MISSILE: |
1673 | case SP_MAGIC_MISSILE: |
1698 | if (QUERY_FLAG (victim, FLAG_ALIVE)) |
1674 | if (QUERY_FLAG (victim, FLAG_ALIVE)) |
1699 | { |
1675 | { |
1700 | tag_t spell_tag = spell->count; |
|
|
1701 | |
|
|
1702 | hit_player (victim, spell->stats.dam, spell, spell->attacktype, 1); |
1676 | hit_player (victim, spell->stats.dam, spell, spell->attacktype, 1); |
1703 | if (!was_destroyed (spell, spell_tag)) |
1677 | |
1704 | { |
1678 | if (!spell->destroyed ()) |
1705 | remove_ob (spell); |
1679 | spell->destroy (); |
1706 | free_object (spell); |
|
|
1707 | } |
|
|
1708 | } |
1680 | } |
1709 | break; |
1681 | break; |
1710 | |
1682 | |
1711 | case SP_MOVING_BALL: |
1683 | case SP_MOVING_BALL: |
1712 | if (QUERY_FLAG (victim, FLAG_ALIVE)) |
1684 | if (QUERY_FLAG (victim, FLAG_ALIVE)) |