… | |
… | |
24 | |
24 | |
25 | #include <global.h> |
25 | #include <global.h> |
26 | #include <spells.h> |
26 | #include <spells.h> |
27 | #include <object.h> |
27 | #include <object.h> |
28 | #include <errno.h> |
28 | #include <errno.h> |
29 | #ifndef __CEXTRACT__ |
|
|
30 | # include <sproto.h> |
29 | #include <sproto.h> |
31 | #endif |
|
|
32 | #include <sounds.h> |
30 | #include <sounds.h> |
33 | |
31 | |
34 | extern char *spell_mapping[]; |
32 | extern char *spell_mapping[]; |
35 | |
33 | |
36 | /* This returns a random spell from 'ob'. If skill is set, then |
34 | /* This returns a random spell from 'ob'. If skill is set, then |
… | |
… | |
151 | } |
149 | } |
152 | |
150 | |
153 | /* pretty basic function - basically just takes |
151 | /* pretty basic function - basically just takes |
154 | * an object, sets the x,y, and calls insert_ob_in_map |
152 | * an object, sets the x,y, and calls insert_ob_in_map |
155 | */ |
153 | */ |
156 | |
|
|
157 | void |
154 | void |
158 | spell_effect (object *spob, int x, int y, maptile *map, object *originator) |
155 | spell_effect (object *spob, int x, int y, maptile *map, object *originator) |
159 | { |
156 | { |
160 | |
|
|
161 | if (spob->other_arch != NULL) |
157 | if (spob->other_arch) |
162 | { |
158 | map->insert (arch_to_object (spob->other_arch), x, y, originator); |
163 | object *effect = arch_to_object (spob->other_arch); |
|
|
164 | |
|
|
165 | effect->x = x; |
|
|
166 | effect->y = y; |
|
|
167 | |
|
|
168 | insert_ob_in_map (effect, map, originator, 0); |
|
|
169 | } |
|
|
170 | } |
159 | } |
171 | |
160 | |
172 | /* |
161 | /* |
173 | * This function takes a caster and spell and presents the |
162 | * This function takes a caster and spell and presents the |
174 | * effective level the caster needs to be to cast the spell. |
163 | * effective level the caster needs to be to cast the spell. |
175 | * basically, it just adjusts the spell->level with attuned/repelled |
164 | * basically, it just adjusts the spell->level with attuned/repelled |
176 | * spellpaths. Was called path_level_mod |
165 | * spellpaths. Was called path_level_mod. |
177 | * |
166 | * |
178 | * caster is person casting hte spell. |
167 | * caster is person casting the spell. |
179 | * spell is the spell object. |
168 | * spell is the spell object. |
180 | * Returns modified level. |
169 | * Returns modified level. |
181 | */ |
170 | */ |
182 | int |
171 | int |
183 | min_casting_level (object *caster, object *spell) |
172 | min_casting_level (object *caster, object *spell) |
184 | { |
173 | { |
185 | int new_level; |
174 | int new_level; |
186 | |
175 | |
187 | if (caster->path_denied & spell->path_attuned) |
176 | if (caster->path_denied & spell->path_attuned) |
188 | { |
|
|
189 | /* This case is not a bug, just the fact that this function is |
|
|
190 | * usually called BEFORE checking for path_deny. -AV |
|
|
191 | */ |
|
|
192 | #if 0 |
|
|
193 | LOG (llevError, "BUG: path_level_mod (arch %s, name %s): casting denied " "spell\n", caster->arch->name, caster->name); |
|
|
194 | #endif |
|
|
195 | return 1; |
177 | return 1; |
196 | } |
178 | |
197 | new_level = spell->level |
179 | new_level = spell->level |
198 | + ((caster->path_repelled & spell->path_attuned) ? +2 : 0) + ((caster->path_attuned & spell->path_attuned) ? -2 : 0); |
180 | + (caster->path_repelled & spell->path_attuned ? +2 : 0) |
199 | return (new_level < 1) ? 1 : new_level; |
181 | + (caster->path_attuned & spell->path_attuned ? -2 : 0); |
200 | } |
|
|
201 | |
182 | |
|
|
183 | return max (1, new_level); |
|
|
184 | } |
202 | |
185 | |
203 | /* This function returns the effective level the spell |
186 | /* This function returns the effective level the spell |
204 | * is being cast at. |
187 | * is being cast at. |
205 | * Note that I changed the repelled/attuned bonus to 2 from 5. |
188 | * Note that I changed the repelled/attuned bonus to 2 from 5. |
206 | * This is because the new code compares casting_level against |
189 | * This is because the new code compares casting_level against |
… | |
… | |
212 | { |
195 | { |
213 | int level = caster->level; |
196 | int level = caster->level; |
214 | |
197 | |
215 | /* If this is a player, try to find the matching skill */ |
198 | /* If this is a player, try to find the matching skill */ |
216 | if (caster->type == PLAYER && spell->skill) |
199 | if (caster->type == PLAYER && spell->skill) |
217 | { |
|
|
218 | int i; |
|
|
219 | |
|
|
220 | for (i = 0; i < NUM_SKILLS; i++) |
200 | for (int i = 0; i < NUM_SKILLS; i++) |
221 | if (caster->contr->last_skill_ob[i] && caster->contr->last_skill_ob[i]->skill == spell->skill) |
201 | if (caster->contr->last_skill_ob[i] && caster->contr->last_skill_ob[i]->skill == spell->skill) |
222 | { |
202 | { |
223 | level = caster->contr->last_skill_ob[i]->level; |
203 | level = caster->contr->last_skill_ob[i]->level; |
224 | break; |
204 | break; |
225 | } |
205 | } |
226 | } |
|
|
227 | |
206 | |
228 | /* if a rod is fired by a player, take the use_magic_item skill in consideration. */ |
207 | /* if a rod is fired by a player, take the use_magic_item skill in consideration. */ |
229 | if (caster->type == ROD && caster->env && caster->env->type == PLAYER) |
208 | if (caster->type == ROD && caster->env && caster->env->type == PLAYER) |
230 | { |
209 | { |
231 | object *skill = find_skill_by_number (caster->env, SK_USE_MAGIC_ITEM); |
210 | object *skill = find_skill_by_number (caster->env, SK_USE_MAGIC_ITEM); |
… | |
… | |
240 | /* Always make this at least 1. If this is zero, we get divide by zero |
219 | /* Always make this at least 1. If this is zero, we get divide by zero |
241 | * errors in various places. |
220 | * errors in various places. |
242 | */ |
221 | */ |
243 | if (level < 1) |
222 | if (level < 1) |
244 | level = 1; |
223 | level = 1; |
|
|
224 | |
245 | return level; |
225 | return level; |
246 | } |
226 | } |
247 | |
227 | |
248 | /* The following function scales the spellpoint cost of |
228 | /* The following function scales the spellpoint cost of |
249 | * a spell by it's increased effectiveness. Some of the |
229 | * a spell by it's increased effectiveness. Some of the |
… | |
… | |
450 | { |
430 | { |
451 | object *op; |
431 | object *op; |
452 | |
432 | |
453 | if (OUT_OF_REAL_MAP (m, x, y)) |
433 | if (OUT_OF_REAL_MAP (m, x, y)) |
454 | return 0; |
434 | return 0; |
455 | for (op = get_map_ob (m, x, y); op != NULL; op = op->above) |
435 | for (op = GET_MAP_OB (m, x, y); op != NULL; op = op->above) |
456 | if (QUERY_FLAG (op, FLAG_REFL_SPELL) && (!QUERY_FLAG (op, FLAG_ALIVE) || |
436 | if (QUERY_FLAG (op, FLAG_REFL_SPELL) |
457 | sp_op->type == LIGHTNING || (rndm (0, 99)) < 90 - (sp_op->level / 10))) |
437 | && (!QUERY_FLAG (op, FLAG_ALIVE) |
|
|
438 | || (rndm (0, 99)) < 90 - (sp_op->level / 10))) |
458 | return 1; |
439 | return 1; |
459 | |
440 | |
460 | return 0; |
441 | return 0; |
461 | } |
442 | } |
462 | |
443 | |
… | |
… | |
479 | { |
460 | { |
480 | new_draw_info (NDI_UNIQUE, 0, op, "Something is in the way."); |
461 | new_draw_info (NDI_UNIQUE, 0, op, "Something is in the way."); |
481 | new_draw_info (NDI_UNIQUE, 0, op, "You cast it at your feet."); |
462 | new_draw_info (NDI_UNIQUE, 0, op, "You cast it at your feet."); |
482 | dir = 0; |
463 | dir = 0; |
483 | } |
464 | } |
484 | new_op->x = op->x + freearr_x[dir]; |
465 | |
485 | new_op->y = op->y + freearr_y[dir]; |
466 | op->map->insert (new_op, |
486 | if (dir == 0) |
467 | op->x + freearr_x[dir], op->y + freearr_y[dir], |
487 | insert_ob_in_map (new_op, op->map, op, INS_BELOW_ORIGINATOR); |
468 | op, |
488 | else |
469 | dir ? 0 : INS_BELOW_ORIGINATOR); |
489 | insert_ob_in_map (new_op, op->map, op, 0); |
470 | |
490 | return dir; |
471 | return dir; |
491 | } |
472 | } |
492 | |
473 | |
493 | /* Returns true if it is ok to put spell *op on the space/may provided. |
474 | /* Returns true if it is ok to put spell *op on the space/may provided. |
494 | * immune_stop is basically the attacktype of the spell (why |
475 | * immune_stop is basically the attacktype of the spell (why |
… | |
… | |
513 | return 0; |
494 | return 0; |
514 | |
495 | |
515 | if (OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (mp, x, y))) |
496 | if (OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (mp, x, y))) |
516 | return 0; |
497 | return 0; |
517 | |
498 | |
518 | for (tmp = get_map_ob (mp, x, y); tmp != NULL; tmp = tmp->above) |
499 | for (tmp = GET_MAP_OB (mp, x, y); tmp != NULL; tmp = tmp->above) |
519 | { |
500 | { |
520 | /* If there is a counterspell on the space, and this |
501 | /* If there is a counterspell on the space, and this |
521 | * object is using magic, don't progress. I believe we could |
502 | * object is using magic, don't progress. I believe we could |
522 | * leave this out and let in progress, and other areas of the code |
503 | * leave this out and let in progress, and other areas of the code |
523 | * will then remove it, but that would seem to to use more |
504 | * will then remove it, but that would seem to to use more |
… | |
… | |
598 | return 0; |
579 | return 0; |
599 | |
580 | |
600 | if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (m, x, y))) |
581 | if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (m, x, y))) |
601 | { |
582 | { |
602 | new_draw_info (NDI_UNIQUE, 0, op, "You can't cast the spell on top of a wall!\n"); |
583 | new_draw_info (NDI_UNIQUE, 0, op, "You can't cast the spell on top of a wall!\n"); |
603 | free_object (tmp); |
584 | tmp->destroy (); |
604 | return 0; |
585 | return 0; |
605 | } |
586 | } |
606 | |
|
|
607 | |
|
|
608 | |
587 | |
609 | tmp->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
588 | tmp->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
610 | tmp->duration = spell->duration + SP_level_duration_adjust (caster, spell); |
589 | tmp->duration = spell->duration + SP_level_duration_adjust (caster, spell); |
611 | /* code in time.c uses food for some things, duration for others */ |
590 | /* code in time.c uses food for some things, duration for others */ |
612 | tmp->stats.food = tmp->duration; |
591 | tmp->stats.food = tmp->duration; |
613 | tmp->range = spell->range + SP_level_range_adjust (caster, spell); |
592 | tmp->range = spell->range + SP_level_range_adjust (caster, spell); |
614 | tmp->attacktype = spell->attacktype; |
593 | tmp->attacktype = spell->attacktype; |
615 | tmp->x = x; |
594 | tmp->x = x; |
616 | tmp->y = y; |
595 | tmp->y = y; |
617 | tmp->direction = dir; |
596 | tmp->direction = dir; |
618 | if (get_owner (op) != NULL) |
597 | if (op->owner != NULL) |
619 | copy_owner (tmp, op); |
598 | tmp->set_owner (op); |
620 | else |
599 | else |
621 | set_owner (tmp, op); |
600 | tmp->set_owner (op); |
622 | tmp->level = caster_level (caster, spell); |
601 | tmp->level = caster_level (caster, spell); |
623 | set_spell_skill (op, caster, spell, tmp); |
602 | set_spell_skill (op, caster, spell, tmp); |
624 | |
603 | |
625 | /* needed for AT_HOLYWORD,AT_GODPOWER stuff */ |
604 | /* needed for AT_HOLYWORD,AT_GODPOWER stuff */ |
626 | if (tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER) |
605 | if (tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER) |
… | |
… | |
629 | return 0; |
608 | return 0; |
630 | } |
609 | } |
631 | if (QUERY_FLAG (tmp, FLAG_IS_TURNABLE)) |
610 | if (QUERY_FLAG (tmp, FLAG_IS_TURNABLE)) |
632 | SET_ANIMATION (tmp, dir); |
611 | SET_ANIMATION (tmp, dir); |
633 | |
612 | |
634 | if ((tmp = insert_ob_in_map (tmp, m, op, 0)) == NULL) |
613 | if ((tmp = insert_ob_in_map (tmp, m, op, 0))) |
635 | return 1; |
|
|
636 | |
|
|
637 | move_spell_effect (tmp); |
614 | move_spell_effect (tmp); |
638 | |
615 | |
639 | return 1; |
616 | return 1; |
640 | } |
617 | } |
641 | |
|
|
642 | |
|
|
643 | |
618 | |
644 | /***************************************************************************** |
619 | /***************************************************************************** |
645 | * |
620 | * |
646 | * Code related to rods - perhaps better located in another file? |
621 | * Code related to rods - perhaps better located in another file? |
647 | * |
622 | * |
648 | ****************************************************************************/ |
623 | ****************************************************************************/ |
649 | |
|
|
650 | void |
624 | void |
651 | regenerate_rod (object *rod) |
625 | regenerate_rod (object *rod) |
652 | { |
626 | { |
653 | if (rod->stats.hp < rod->stats.maxhp) |
627 | if (rod->stats.hp < rod->stats.maxhp) |
654 | { |
628 | { |
… | |
… | |
688 | * we then make the owner of this object the target. |
662 | * we then make the owner of this object the target. |
689 | * The owner could very well be no where near op. |
663 | * The owner could very well be no where near op. |
690 | */ |
664 | */ |
691 | if (op->type != PLAYER && op->type != RUNE) |
665 | if (op->type != PLAYER && op->type != RUNE) |
692 | { |
666 | { |
693 | tmp = get_owner (op); |
667 | tmp = op->owner; |
694 | /* If the owner does not exist, or is not a monster, than apply the spell |
668 | /* If the owner does not exist, or is not a monster, than apply the spell |
695 | * to the caster. |
669 | * to the caster. |
696 | */ |
670 | */ |
697 | if (!tmp || !QUERY_FLAG (tmp, FLAG_MONSTER)) |
671 | if (!tmp || !QUERY_FLAG (tmp, FLAG_MONSTER)) |
698 | tmp = op; |
672 | tmp = op; |
… | |
… | |
704 | y = op->y + freearr_y[dir]; |
678 | y = op->y + freearr_y[dir]; |
705 | |
679 | |
706 | mflags = get_map_flags (m, &m, x, y, &x, &y); |
680 | mflags = get_map_flags (m, &m, x, y, &x, &y); |
707 | |
681 | |
708 | if (mflags & P_OUT_OF_MAP) |
682 | if (mflags & P_OUT_OF_MAP) |
709 | tmp = NULL; |
683 | tmp = 0; |
710 | else |
684 | else |
711 | { |
685 | tmp = m->at (x, y).player (); |
712 | for (tmp = get_map_ob (m, x, y); tmp != NULL; tmp = tmp->above) |
|
|
713 | if (tmp->type == PLAYER) |
|
|
714 | break; |
|
|
715 | } |
|
|
716 | } |
686 | } |
|
|
687 | |
717 | /* didn't find a player there, look in current square for a player */ |
688 | /* didn't find a player there, look in current square for a player */ |
718 | if (tmp == NULL) |
689 | if (!tmp) |
719 | for (tmp = get_map_ob (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) |
690 | tmp = op->ms ().player (); |
720 | { |
|
|
721 | if (tmp->type == PLAYER) |
|
|
722 | break; |
|
|
723 | } |
|
|
724 | |
691 | |
725 | return tmp; |
692 | return tmp; |
726 | } |
693 | } |
727 | |
694 | |
728 | |
695 | |
… | |
… | |
760 | mp = m; |
727 | mp = m; |
761 | mflags = get_map_flags (m, &mp, nx, ny, &nx, &ny); |
728 | mflags = get_map_flags (m, &mp, nx, ny, &nx, &ny); |
762 | if (mflags & (P_OUT_OF_MAP | P_BLOCKSVIEW)) |
729 | if (mflags & (P_OUT_OF_MAP | P_BLOCKSVIEW)) |
763 | continue; |
730 | continue; |
764 | |
731 | |
765 | tmp = get_map_ob (mp, nx, ny); |
732 | tmp = GET_MAP_OB (mp, nx, ny); |
766 | |
733 | |
767 | while (tmp != NULL && (((owner_type == PLAYER && |
734 | while (tmp != NULL && (((owner_type == PLAYER && |
768 | !QUERY_FLAG (tmp, FLAG_MONSTER) && !QUERY_FLAG (tmp, FLAG_GENERATOR)) || |
735 | !QUERY_FLAG (tmp, FLAG_MONSTER) && !QUERY_FLAG (tmp, FLAG_GENERATOR)) || |
769 | (owner_type != PLAYER && tmp->type != PLAYER)) || (tmp == exclude || (tmp->head && tmp->head == exclude)))) |
736 | (owner_type != PLAYER && tmp->type != PLAYER)) || (tmp == exclude || (tmp->head && tmp->head == exclude)))) |
770 | tmp = tmp->above; |
737 | tmp = tmp->above; |
… | |
… | |
825 | create_treasure (head->randomitems, head, GT_INVISIBLE, op->map->difficulty, 0); |
792 | create_treasure (head->randomitems, head, GT_INVISIBLE, op->map->difficulty, 0); |
826 | |
793 | |
827 | insert_ob_in_map (head, op->map, op, 0); |
794 | insert_ob_in_map (head, op->map, op, 0); |
828 | |
795 | |
829 | /* thought it'd be cool to insert a burnout, too. */ |
796 | /* thought it'd be cool to insert a burnout, too. */ |
830 | tmp = get_archetype ("burnout"); |
797 | op->map->insert (get_archetype ("burnout"), op->x + freearr_x[dir], op->y + freearr_y[dir], op); |
831 | tmp->map = op->map; |
|
|
832 | tmp->x = op->x + freearr_x[dir]; |
|
|
833 | tmp->y = op->y + freearr_y[dir]; |
|
|
834 | insert_ob_in_map (tmp, op->map, op, 0); |
|
|
835 | } |
798 | } |
836 | } |
799 | } |
837 | |
800 | |
838 | /* peterm: function which summons hostile monsters and |
801 | /* peterm: function which summons hostile monsters and |
839 | * places them in nearby squares. |
802 | * places them in nearby squares. |
… | |
… | |
966 | if (failure <= -20 && failure > -40) /* wonder */ |
929 | if (failure <= -20 && failure > -40) /* wonder */ |
967 | { |
930 | { |
968 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s gives a sign to renew your faith.", godname); |
931 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s gives a sign to renew your faith.", godname); |
969 | tmp = get_archetype (SPELL_WONDER); |
932 | tmp = get_archetype (SPELL_WONDER); |
970 | cast_cone (op, op, 0, tmp); |
933 | cast_cone (op, op, 0, tmp); |
971 | free_object (tmp); |
934 | tmp->destroy (); |
972 | } |
935 | } |
973 | |
936 | |
974 | else if (failure <= -40 && failure > -60) /* confusion */ |
937 | else if (failure <= -40 && failure > -60) /* confusion */ |
975 | { |
938 | { |
976 | new_draw_info (NDI_UNIQUE, 0, op, "Your diety touches your mind!"); |
939 | new_draw_info (NDI_UNIQUE, 0, op, "Your diety touches your mind!"); |
… | |
… | |
1010 | if (failure <= -20 && failure > -40) /* wonder */ |
973 | if (failure <= -20 && failure > -40) /* wonder */ |
1011 | { |
974 | { |
1012 | new_draw_info (NDI_UNIQUE, 0, op, "Your spell causes an unexpected effect."); |
975 | new_draw_info (NDI_UNIQUE, 0, op, "Your spell causes an unexpected effect."); |
1013 | tmp = get_archetype (SPELL_WONDER); |
976 | tmp = get_archetype (SPELL_WONDER); |
1014 | cast_cone (op, op, 0, tmp); |
977 | cast_cone (op, op, 0, tmp); |
1015 | free_object (tmp); |
978 | tmp->destroy (); |
1016 | } |
979 | } |
1017 | |
980 | |
1018 | else if (failure <= -40 && failure > -60) /* confusion */ |
981 | else if (failure <= -40 && failure > -60) /* confusion */ |
1019 | { |
982 | { |
1020 | new_draw_info (NDI_UNIQUE, 0, op, "Your magic recoils on you, making you confused!"); |
983 | new_draw_info (NDI_UNIQUE, 0, op, "Your magic recoils on you, making you confused!"); |
… | |
… | |
1039 | else |
1002 | else |
1040 | { |
1003 | { |
1041 | new_draw_info (NDI_UNIQUE, 0, op, "You lose control of the mana! The uncontrolled magic blasts you!"); |
1004 | new_draw_info (NDI_UNIQUE, 0, op, "You lose control of the mana! The uncontrolled magic blasts you!"); |
1042 | tmp = get_archetype (LOOSE_MANA); |
1005 | tmp = get_archetype (LOOSE_MANA); |
1043 | tmp->level = skill->level; |
1006 | tmp->level = skill->level; |
1044 | tmp->x = op->x; |
|
|
1045 | tmp->y = op->y; |
|
|
1046 | |
1007 | |
1047 | /* increase the area of destruction a little for more powerful spells */ |
1008 | /* increase the area of destruction a little for more powerful spells */ |
1048 | tmp->range += isqrt (power); |
1009 | tmp->range += isqrt (power); |
1049 | |
1010 | |
1050 | if (power > 25) |
1011 | if (power > 25) |
1051 | tmp->stats.dam = 25 + isqrt (power); |
1012 | tmp->stats.dam = 25 + isqrt (power); |
1052 | else |
1013 | else |
1053 | tmp->stats.dam = power; /* nasty recoils! */ |
1014 | tmp->stats.dam = power; /* nasty recoils! */ |
1054 | |
1015 | |
1055 | tmp->stats.maxhp = tmp->count; |
1016 | tmp->stats.maxhp = tmp->count; |
1056 | insert_ob_in_map (tmp, op->map, NULL, 0); |
1017 | |
|
|
1018 | tmp->insert_at (op); |
1057 | } |
1019 | } |
1058 | } |
1020 | } |
1059 | } |
1021 | } |
1060 | |
1022 | |
1061 | int |
1023 | int |
… | |
… | |
1075 | /* Always cast spell on caster */ |
1037 | /* Always cast spell on caster */ |
1076 | success = cast_spell (op, caster, dir, spell, stringarg); |
1038 | success = cast_spell (op, caster, dir, spell, stringarg); |
1077 | |
1039 | |
1078 | if (caster->contr->party == NULL) |
1040 | if (caster->contr->party == NULL) |
1079 | { |
1041 | { |
1080 | remove_ob (spell); |
1042 | spell->remove (); |
1081 | return success; |
1043 | return success; |
1082 | } |
1044 | } |
1083 | for (pl = first_player; pl != NULL; pl = pl->next) |
1045 | for_all_players (pl) |
1084 | if ((pl->ob->contr->party == caster->contr->party) && (on_same_map (pl->ob, caster))) |
1046 | if ((pl->ob->contr->party == caster->contr->party) && (on_same_map (pl->ob, caster))) |
1085 | { |
1047 | { |
1086 | cast_spell (pl->ob, caster, pl->ob->facing, spell, stringarg); |
1048 | cast_spell (pl->ob, caster, pl->ob->facing, spell, stringarg); |
1087 | } |
1049 | } |
1088 | remove_ob (spell); |
1050 | spell->remove (); |
1089 | return success; |
1051 | return success; |
1090 | } |
1052 | } |
1091 | |
1053 | |
1092 | /* This is where the main dispatch when someone casts a spell. |
1054 | /* This is where the main dispatch when someone casts a spell. |
1093 | * |
1055 | * |
… | |
… | |
1143 | } |
1105 | } |
1144 | |
1106 | |
1145 | /* if caster is a spell casting object, this normally shouldn't be |
1107 | /* if caster is a spell casting object, this normally shouldn't be |
1146 | * an issue, because they don't have any spellpaths set up. |
1108 | * an issue, because they don't have any spellpaths set up. |
1147 | */ |
1109 | */ |
1148 | if (caster->path_denied & spell_ob->path_attuned) |
1110 | if (caster->path_denied & spell_ob->path_attuned && !QUERY_FLAG (caster, FLAG_WIZCAST)) |
1149 | { |
1111 | { |
1150 | new_draw_info (NDI_UNIQUE, 0, op, "That spell path is denied to you."); |
1112 | new_draw_info (NDI_UNIQUE, 0, op, "That spell path is denied to you."); |
1151 | return 0; |
1113 | return 0; |
1152 | } |
1114 | } |
1153 | |
1115 | |
… | |
… | |
1186 | SP_level_spellpoint_cost (caster, spell_ob, SPELL_MANA) > op->stats.sp) |
1148 | SP_level_spellpoint_cost (caster, spell_ob, SPELL_MANA) > op->stats.sp) |
1187 | { |
1149 | { |
1188 | new_draw_info (NDI_UNIQUE, 0, op, "You don't have enough mana."); |
1150 | new_draw_info (NDI_UNIQUE, 0, op, "You don't have enough mana."); |
1189 | return 0; |
1151 | return 0; |
1190 | } |
1152 | } |
|
|
1153 | |
1191 | if (SP_level_spellpoint_cost (caster, spell_ob, SPELL_GRACE) && |
1154 | if (SP_level_spellpoint_cost (caster, spell_ob, SPELL_GRACE) && |
1192 | SP_level_spellpoint_cost (caster, spell_ob, SPELL_GRACE) > op->stats.grace) |
1155 | SP_level_spellpoint_cost (caster, spell_ob, SPELL_GRACE) > op->stats.grace) |
1193 | { |
1156 | { |
1194 | if (random_roll (0, op->stats.Wis - 1, op, PREFER_HIGH) + op->stats.grace - |
1157 | if (random_roll (0, op->stats.Wis - 1, op, PREFER_HIGH) + op->stats.grace - |
1195 | 10 * SP_level_spellpoint_cost (caster, spell_ob, SPELL_GRACE) / op->stats.maxgrace > 0) |
1158 | 10 * SP_level_spellpoint_cost (caster, spell_ob, SPELL_GRACE) / op->stats.maxgrace > 0) |
… | |
… | |
1288 | * spell is actually cast, it knows about the stringarg. |
1251 | * spell is actually cast, it knows about the stringarg. |
1289 | * necessary for the invoke command spells. |
1252 | * necessary for the invoke command spells. |
1290 | */ |
1253 | */ |
1291 | if (stringarg) |
1254 | if (stringarg) |
1292 | { |
1255 | { |
1293 | op->spellarg = strdup_local (stringarg); |
1256 | op->spellarg = strdup (stringarg); |
1294 | } |
1257 | } |
1295 | else |
1258 | else |
1296 | op->spellarg = NULL; |
1259 | op->spellarg = NULL; |
1297 | return 0; |
1260 | return 0; |
1298 | } |
1261 | } |
… | |
… | |
1691 | if (QUERY_FLAG (victim, FLAG_ALIVE)) |
1654 | if (QUERY_FLAG (victim, FLAG_ALIVE)) |
1692 | { |
1655 | { |
1693 | hit_player (victim, spell->stats.dam, spell, spell->attacktype, 1); |
1656 | hit_player (victim, spell->stats.dam, spell, spell->attacktype, 1); |
1694 | |
1657 | |
1695 | if (!spell->destroyed ()) |
1658 | if (!spell->destroyed ()) |
1696 | { |
1659 | spell->destroy (); |
1697 | remove_ob (spell); |
|
|
1698 | free_object (spell); |
|
|
1699 | } |
|
|
1700 | } |
1660 | } |
1701 | break; |
1661 | break; |
1702 | |
1662 | |
1703 | case SP_MOVING_BALL: |
1663 | case SP_MOVING_BALL: |
1704 | if (QUERY_FLAG (victim, FLAG_ALIVE)) |
1664 | if (QUERY_FLAG (victim, FLAG_ALIVE)) |