ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/spell_util.C
(Generate patch)

Comparing deliantra/server/server/spell_util.C (file contents):
Revision 1.17 by root, Sat Sep 16 22:24:13 2006 UTC vs.
Revision 1.32 by root, Mon Jan 15 00:40:49 2007 UTC

1/* 1/*
2 CrossFire, A Multiplayer game for X-windows 2 CrossFire, A Multiplayer game for X-windows
3 3
4 Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team
4 Copyright (C) 2001 Mark Wedel & Crossfire Development Team 5 Copyright (C) 2001 Mark Wedel & Crossfire Development Team
5 Copyright (C) 1992 Frank Tore Johansen 6 Copyright (C) 1992 Frank Tore Johansen
6 7
7 This program is free software; you can redistribute it and/or modify 8 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 9 it under the terms of the GNU General Public License as published by
24 25
25#include <global.h> 26#include <global.h>
26#include <spells.h> 27#include <spells.h>
27#include <object.h> 28#include <object.h>
28#include <errno.h> 29#include <errno.h>
29#ifndef __CEXTRACT__
30# include <sproto.h> 30#include <sproto.h>
31#endif
32#include <sounds.h> 31#include <sounds.h>
33 32
34extern char *spell_mapping[]; 33extern char *spell_mapping[];
35 34
36/* This returns a random spell from 'ob'. If skill is set, then 35/* This returns a random spell from 'ob'. If skill is set, then
151} 150}
152 151
153/* pretty basic function - basically just takes 152/* pretty basic function - basically just takes
154 * an object, sets the x,y, and calls insert_ob_in_map 153 * an object, sets the x,y, and calls insert_ob_in_map
155 */ 154 */
156
157void 155void
158spell_effect (object *spob, int x, int y, maptile *map, object *originator) 156spell_effect (object *spob, int x, int y, maptile *map, object *originator)
159{ 157{
160
161 if (spob->other_arch != NULL) 158 if (spob->other_arch)
162 { 159 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} 160}
171 161
172/* 162/*
173 * This function takes a caster and spell and presents the 163 * This function takes a caster and spell and presents the
174 * effective level the caster needs to be to cast the spell. 164 * effective level the caster needs to be to cast the spell.
175 * basically, it just adjusts the spell->level with attuned/repelled 165 * basically, it just adjusts the spell->level with attuned/repelled
176 * spellpaths. Was called path_level_mod 166 * spellpaths. Was called path_level_mod.
177 * 167 *
178 * caster is person casting hte spell. 168 * caster is person casting the spell.
179 * spell is the spell object. 169 * spell is the spell object.
180 * Returns modified level. 170 * Returns modified level.
181 */ 171 */
182int 172int
183min_casting_level (object *caster, object *spell) 173min_casting_level (object *caster, object *spell)
184{ 174{
185 int new_level; 175 int new_level;
186 176
187 if (caster->path_denied & spell->path_attuned) 177 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; 178 return 1;
196 } 179
197 new_level = spell->level 180 new_level = spell->level
198 + ((caster->path_repelled & spell->path_attuned) ? +2 : 0) + ((caster->path_attuned & spell->path_attuned) ? -2 : 0); 181 + (caster->path_repelled & spell->path_attuned ? +2 : 0)
199 return (new_level < 1) ? 1 : new_level; 182 + (caster->path_attuned & spell->path_attuned ? -2 : 0);
200}
201 183
184 return max (1, new_level);
185}
202 186
203/* This function returns the effective level the spell 187/* This function returns the effective level the spell
204 * is being cast at. 188 * is being cast at.
205 * Note that I changed the repelled/attuned bonus to 2 from 5. 189 * Note that I changed the repelled/attuned bonus to 2 from 5.
206 * This is because the new code compares casting_level against 190 * This is because the new code compares casting_level against
212{ 196{
213 int level = caster->level; 197 int level = caster->level;
214 198
215 /* If this is a player, try to find the matching skill */ 199 /* If this is a player, try to find the matching skill */
216 if (caster->type == PLAYER && spell->skill) 200 if (caster->type == PLAYER && spell->skill)
217 {
218 int i;
219
220 for (i = 0; i < NUM_SKILLS; i++) 201 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) 202 if (caster->contr->last_skill_ob[i] && caster->contr->last_skill_ob[i]->skill == spell->skill)
222 { 203 {
223 level = caster->contr->last_skill_ob[i]->level; 204 level = caster->contr->last_skill_ob[i]->level;
224 break; 205 break;
225 } 206 }
226 }
227 207
228 /* if a rod is fired by a player, take the use_magic_item skill in consideration. */ 208 /* 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) 209 if (caster->type == ROD && caster->env && caster->env->type == PLAYER)
230 { 210 {
231 object *skill = find_skill_by_number (caster->env, SK_USE_MAGIC_ITEM); 211 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 220 /* Always make this at least 1. If this is zero, we get divide by zero
241 * errors in various places. 221 * errors in various places.
242 */ 222 */
243 if (level < 1) 223 if (level < 1)
244 level = 1; 224 level = 1;
225
245 return level; 226 return level;
246} 227}
247 228
248/* The following function scales the spellpoint cost of 229/* The following function scales the spellpoint cost of
249 * a spell by it's increased effectiveness. Some of the 230 * a spell by it's increased effectiveness. Some of the
450{ 431{
451 object *op; 432 object *op;
452 433
453 if (OUT_OF_REAL_MAP (m, x, y)) 434 if (OUT_OF_REAL_MAP (m, x, y))
454 return 0; 435 return 0;
455 for (op = get_map_ob (m, x, y); op != NULL; op = op->above) 436 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) || 437 if (QUERY_FLAG (op, FLAG_REFL_SPELL)
457 sp_op->type == LIGHTNING || (rndm (0, 99)) < 90 - (sp_op->level / 10))) 438 && (!QUERY_FLAG (op, FLAG_ALIVE)
439 || (rndm (0, 99)) < 90 - (sp_op->level / 10)))
458 return 1; 440 return 1;
459 441
460 return 0; 442 return 0;
461} 443}
462 444
479 { 461 {
480 new_draw_info (NDI_UNIQUE, 0, op, "Something is in the way."); 462 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."); 463 new_draw_info (NDI_UNIQUE, 0, op, "You cast it at your feet.");
482 dir = 0; 464 dir = 0;
483 } 465 }
484 new_op->x = op->x + freearr_x[dir]; 466
485 new_op->y = op->y + freearr_y[dir]; 467 op->map->insert (new_op,
486 if (dir == 0) 468 op->x + freearr_x[dir], op->y + freearr_y[dir],
487 insert_ob_in_map (new_op, op->map, op, INS_BELOW_ORIGINATOR); 469 op,
488 else 470 dir ? 0 : INS_BELOW_ORIGINATOR);
489 insert_ob_in_map (new_op, op->map, op, 0); 471
490 return dir; 472 return dir;
491} 473}
492 474
493/* Returns true if it is ok to put spell *op on the space/may provided. 475/* 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 476 * immune_stop is basically the attacktype of the spell (why
496 * has the AT_MAGIC bit set, and there is a counterwall 478 * has the AT_MAGIC bit set, and there is a counterwall
497 * on the space, the object doesn't get placed. if immune stop 479 * on the space, the object doesn't get placed. if immune stop
498 * does not have AT_MAGIC, then counterwalls do not effect the spell. 480 * does not have AT_MAGIC, then counterwalls do not effect the spell.
499 * 481 *
500 */ 482 */
501
502int 483int
503ok_to_put_more (maptile *m, sint16 x, sint16 y, object *op, int immune_stop) 484ok_to_put_more (maptile *m, sint16 x, sint16 y, object *op, int immune_stop)
504{ 485{
505 object *tmp; 486 if (!xy_normalise (m, x, y))
506 int mflags;
507 maptile *mp;
508
509 mp = m;
510 mflags = get_map_flags (m, &mp, x, y, &x, &y);
511
512 if (mflags & P_OUT_OF_MAP)
513 return 0; 487 return 0;
514 488
515 if (OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (mp, x, y))) 489 mapspace &ms = m->at (x, y);
490
491 if (OB_TYPE_MOVE_BLOCK (op, ms.move_block))
516 return 0; 492 return 0;
517 493
518 for (tmp = get_map_ob (mp, x, y); tmp != NULL; tmp = tmp->above) 494 for (object *tmp = ms.bot; tmp; tmp = tmp->above)
519 { 495 {
520 /* If there is a counterspell on the space, and this 496 /* If there is a counterspell on the space, and this
521 * object is using magic, don't progress. I believe we could 497 * 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 498 * 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 499 * will then remove it, but that would seem to to use more
558 534
559 /* Perhaps we should also put checks in for no magic and unholy 535 /* Perhaps we should also put checks in for no magic and unholy
560 * ground to prevent it from moving along? 536 * ground to prevent it from moving along?
561 */ 537 */
562 } 538 }
539
563 /* If it passes the above tests, it must be OK */ 540 /* If it passes the above tests, it must be OK */
564 return 1; 541 return 1;
565} 542}
566 543
567/* fire_arch_from_position: fires an archetype. 544/* fire_arch_from_position: fires an archetype.
598 return 0; 575 return 0;
599 576
600 if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (m, x, y))) 577 if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (m, x, y)))
601 { 578 {
602 new_draw_info (NDI_UNIQUE, 0, op, "You can't cast the spell on top of a wall!\n"); 579 new_draw_info (NDI_UNIQUE, 0, op, "You can't cast the spell on top of a wall!\n");
603 free_object (tmp); 580 tmp->destroy ();
604 return 0; 581 return 0;
605 } 582 }
606
607
608 583
609 tmp->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); 584 tmp->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell);
610 tmp->duration = spell->duration + SP_level_duration_adjust (caster, spell); 585 tmp->duration = spell->duration + SP_level_duration_adjust (caster, spell);
611 /* code in time.c uses food for some things, duration for others */ 586 /* code in time.c uses food for some things, duration for others */
612 tmp->stats.food = tmp->duration; 587 tmp->stats.food = tmp->duration;
613 tmp->range = spell->range + SP_level_range_adjust (caster, spell); 588 tmp->range = spell->range + SP_level_range_adjust (caster, spell);
614 tmp->attacktype = spell->attacktype; 589 tmp->attacktype = spell->attacktype;
615 tmp->x = x; 590 tmp->x = x;
616 tmp->y = y; 591 tmp->y = y;
617 tmp->direction = dir; 592 tmp->direction = dir;
618 if (get_owner (op) != NULL) 593 if (op->owner != NULL)
619 copy_owner (tmp, op); 594 tmp->set_owner (op);
620 else 595 else
621 set_owner (tmp, op); 596 tmp->set_owner (op);
622 tmp->level = caster_level (caster, spell); 597 tmp->level = caster_level (caster, spell);
623 set_spell_skill (op, caster, spell, tmp); 598 set_spell_skill (op, caster, spell, tmp);
624 599
625 /* needed for AT_HOLYWORD,AT_GODPOWER stuff */ 600 /* needed for AT_HOLYWORD,AT_GODPOWER stuff */
626 if (tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER) 601 if (tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER)
629 return 0; 604 return 0;
630 } 605 }
631 if (QUERY_FLAG (tmp, FLAG_IS_TURNABLE)) 606 if (QUERY_FLAG (tmp, FLAG_IS_TURNABLE))
632 SET_ANIMATION (tmp, dir); 607 SET_ANIMATION (tmp, dir);
633 608
634 if ((tmp = insert_ob_in_map (tmp, m, op, 0)) == NULL) 609 if ((tmp = insert_ob_in_map (tmp, m, op, 0)))
635 return 1;
636
637 move_spell_effect (tmp); 610 move_spell_effect (tmp);
638 611
639 return 1; 612 return 1;
640} 613}
641
642
643 614
644/***************************************************************************** 615/*****************************************************************************
645 * 616 *
646 * Code related to rods - perhaps better located in another file? 617 * Code related to rods - perhaps better located in another file?
647 * 618 *
648 ****************************************************************************/ 619 ****************************************************************************/
649
650void 620void
651regenerate_rod (object *rod) 621regenerate_rod (object *rod)
652{ 622{
653 if (rod->stats.hp < rod->stats.maxhp) 623 if (rod->stats.hp < rod->stats.maxhp)
654 { 624 {
688 * we then make the owner of this object the target. 658 * we then make the owner of this object the target.
689 * The owner could very well be no where near op. 659 * The owner could very well be no where near op.
690 */ 660 */
691 if (op->type != PLAYER && op->type != RUNE) 661 if (op->type != PLAYER && op->type != RUNE)
692 { 662 {
693 tmp = get_owner (op); 663 tmp = op->owner;
694 /* If the owner does not exist, or is not a monster, than apply the spell 664 /* If the owner does not exist, or is not a monster, than apply the spell
695 * to the caster. 665 * to the caster.
696 */ 666 */
697 if (!tmp || !QUERY_FLAG (tmp, FLAG_MONSTER)) 667 if (!tmp || !QUERY_FLAG (tmp, FLAG_MONSTER))
698 tmp = op; 668 tmp = op;
704 y = op->y + freearr_y[dir]; 674 y = op->y + freearr_y[dir];
705 675
706 mflags = get_map_flags (m, &m, x, y, &x, &y); 676 mflags = get_map_flags (m, &m, x, y, &x, &y);
707 677
708 if (mflags & P_OUT_OF_MAP) 678 if (mflags & P_OUT_OF_MAP)
709 tmp = NULL; 679 tmp = 0;
710 else 680 else
711 { 681 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 } 682 }
683
717 /* didn't find a player there, look in current square for a player */ 684 /* didn't find a player there, look in current square for a player */
718 if (tmp == NULL) 685 if (!tmp)
719 for (tmp = get_map_ob (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) 686 tmp = op->ms ().player ();
720 {
721 if (tmp->type == PLAYER)
722 break;
723 }
724 687
725 return tmp; 688 return tmp;
726} 689}
727 690
728 691
760 mp = m; 723 mp = m;
761 mflags = get_map_flags (m, &mp, nx, ny, &nx, &ny); 724 mflags = get_map_flags (m, &mp, nx, ny, &nx, &ny);
762 if (mflags & (P_OUT_OF_MAP | P_BLOCKSVIEW)) 725 if (mflags & (P_OUT_OF_MAP | P_BLOCKSVIEW))
763 continue; 726 continue;
764 727
765 tmp = get_map_ob (mp, nx, ny); 728 tmp = GET_MAP_OB (mp, nx, ny);
766 729
767 while (tmp != NULL && (((owner_type == PLAYER && 730 while (tmp != NULL && (((owner_type == PLAYER &&
768 !QUERY_FLAG (tmp, FLAG_MONSTER) && !QUERY_FLAG (tmp, FLAG_GENERATOR)) || 731 !QUERY_FLAG (tmp, FLAG_MONSTER) && !QUERY_FLAG (tmp, FLAG_GENERATOR)) ||
769 (owner_type != PLAYER && tmp->type != PLAYER)) || (tmp == exclude || (tmp->head && tmp->head == exclude)))) 732 (owner_type != PLAYER && tmp->type != PLAYER)) || (tmp == exclude || (tmp->head && tmp->head == exclude))))
770 tmp = tmp->above; 733 tmp = tmp->above;
825 create_treasure (head->randomitems, head, GT_INVISIBLE, op->map->difficulty, 0); 788 create_treasure (head->randomitems, head, GT_INVISIBLE, op->map->difficulty, 0);
826 789
827 insert_ob_in_map (head, op->map, op, 0); 790 insert_ob_in_map (head, op->map, op, 0);
828 791
829 /* thought it'd be cool to insert a burnout, too. */ 792 /* thought it'd be cool to insert a burnout, too. */
830 tmp = get_archetype ("burnout"); 793 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 } 794 }
836} 795}
837 796
838/* peterm: function which summons hostile monsters and 797/* peterm: function which summons hostile monsters and
839 * places them in nearby squares. 798 * places them in nearby squares.
966 if (failure <= -20 && failure > -40) /* wonder */ 925 if (failure <= -20 && failure > -40) /* wonder */
967 { 926 {
968 new_draw_info_format (NDI_UNIQUE, 0, op, "%s gives a sign to renew your faith.", godname); 927 new_draw_info_format (NDI_UNIQUE, 0, op, "%s gives a sign to renew your faith.", godname);
969 tmp = get_archetype (SPELL_WONDER); 928 tmp = get_archetype (SPELL_WONDER);
970 cast_cone (op, op, 0, tmp); 929 cast_cone (op, op, 0, tmp);
971 free_object (tmp); 930 tmp->destroy ();
972 } 931 }
973 932
974 else if (failure <= -40 && failure > -60) /* confusion */ 933 else if (failure <= -40 && failure > -60) /* confusion */
975 { 934 {
976 new_draw_info (NDI_UNIQUE, 0, op, "Your diety touches your mind!"); 935 new_draw_info (NDI_UNIQUE, 0, op, "Your diety touches your mind!");
1010 if (failure <= -20 && failure > -40) /* wonder */ 969 if (failure <= -20 && failure > -40) /* wonder */
1011 { 970 {
1012 new_draw_info (NDI_UNIQUE, 0, op, "Your spell causes an unexpected effect."); 971 new_draw_info (NDI_UNIQUE, 0, op, "Your spell causes an unexpected effect.");
1013 tmp = get_archetype (SPELL_WONDER); 972 tmp = get_archetype (SPELL_WONDER);
1014 cast_cone (op, op, 0, tmp); 973 cast_cone (op, op, 0, tmp);
1015 free_object (tmp); 974 tmp->destroy ();
1016 } 975 }
1017 976
1018 else if (failure <= -40 && failure > -60) /* confusion */ 977 else if (failure <= -40 && failure > -60) /* confusion */
1019 { 978 {
1020 new_draw_info (NDI_UNIQUE, 0, op, "Your magic recoils on you, making you confused!"); 979 new_draw_info (NDI_UNIQUE, 0, op, "Your magic recoils on you, making you confused!");
1039 else 998 else
1040 { 999 {
1041 new_draw_info (NDI_UNIQUE, 0, op, "You lose control of the mana! The uncontrolled magic blasts you!"); 1000 new_draw_info (NDI_UNIQUE, 0, op, "You lose control of the mana! The uncontrolled magic blasts you!");
1042 tmp = get_archetype (LOOSE_MANA); 1001 tmp = get_archetype (LOOSE_MANA);
1043 tmp->level = skill->level; 1002 tmp->level = skill->level;
1044 tmp->x = op->x;
1045 tmp->y = op->y;
1046 1003
1047 /* increase the area of destruction a little for more powerful spells */ 1004 /* increase the area of destruction a little for more powerful spells */
1048 tmp->range += isqrt (power); 1005 tmp->range += isqrt (power);
1049 1006
1050 if (power > 25) 1007 if (power > 25)
1051 tmp->stats.dam = 25 + isqrt (power); 1008 tmp->stats.dam = 25 + isqrt (power);
1052 else 1009 else
1053 tmp->stats.dam = power; /* nasty recoils! */ 1010 tmp->stats.dam = power; /* nasty recoils! */
1054 1011
1055 tmp->stats.maxhp = tmp->count; 1012 tmp->stats.maxhp = tmp->count;
1056 insert_ob_in_map (tmp, op->map, NULL, 0); 1013
1014 tmp->insert_at (op);
1057 } 1015 }
1058 } 1016 }
1059} 1017}
1060 1018
1061int 1019int
1075 /* Always cast spell on caster */ 1033 /* Always cast spell on caster */
1076 success = cast_spell (op, caster, dir, spell, stringarg); 1034 success = cast_spell (op, caster, dir, spell, stringarg);
1077 1035
1078 if (caster->contr->party == NULL) 1036 if (caster->contr->party == NULL)
1079 { 1037 {
1080 remove_ob (spell); 1038 spell->remove ();
1081 return success; 1039 return success;
1082 } 1040 }
1083 for (pl = first_player; pl != NULL; pl = pl->next) 1041 for_all_players (pl)
1084 if ((pl->ob->contr->party == caster->contr->party) && (on_same_map (pl->ob, caster))) 1042 if ((pl->ob->contr->party == caster->contr->party) && (on_same_map (pl->ob, caster)))
1085 { 1043 {
1086 cast_spell (pl->ob, caster, pl->ob->facing, spell, stringarg); 1044 cast_spell (pl->ob, caster, pl->ob->facing, spell, stringarg);
1087 } 1045 }
1088 remove_ob (spell); 1046 spell->remove ();
1089 return success; 1047 return success;
1090} 1048}
1091 1049
1092/* This is where the main dispatch when someone casts a spell. 1050/* This is where the main dispatch when someone casts a spell.
1093 * 1051 *
1143 } 1101 }
1144 1102
1145 /* if caster is a spell casting object, this normally shouldn't be 1103 /* if caster is a spell casting object, this normally shouldn't be
1146 * an issue, because they don't have any spellpaths set up. 1104 * an issue, because they don't have any spellpaths set up.
1147 */ 1105 */
1148 if (caster->path_denied & spell_ob->path_attuned) 1106 if (caster->path_denied & spell_ob->path_attuned && !QUERY_FLAG (caster, FLAG_WIZCAST))
1149 { 1107 {
1150 new_draw_info (NDI_UNIQUE, 0, op, "That spell path is denied to you."); 1108 new_draw_info (NDI_UNIQUE, 0, op, "That spell path is denied to you.");
1151 return 0; 1109 return 0;
1152 } 1110 }
1153 1111
1186 SP_level_spellpoint_cost (caster, spell_ob, SPELL_MANA) > op->stats.sp) 1144 SP_level_spellpoint_cost (caster, spell_ob, SPELL_MANA) > op->stats.sp)
1187 { 1145 {
1188 new_draw_info (NDI_UNIQUE, 0, op, "You don't have enough mana."); 1146 new_draw_info (NDI_UNIQUE, 0, op, "You don't have enough mana.");
1189 return 0; 1147 return 0;
1190 } 1148 }
1149
1191 if (SP_level_spellpoint_cost (caster, spell_ob, SPELL_GRACE) && 1150 if (SP_level_spellpoint_cost (caster, spell_ob, SPELL_GRACE) &&
1192 SP_level_spellpoint_cost (caster, spell_ob, SPELL_GRACE) > op->stats.grace) 1151 SP_level_spellpoint_cost (caster, spell_ob, SPELL_GRACE) > op->stats.grace)
1193 { 1152 {
1194 if (random_roll (0, op->stats.Wis - 1, op, PREFER_HIGH) + op->stats.grace - 1153 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) 1154 10 * SP_level_spellpoint_cost (caster, spell_ob, SPELL_GRACE) / op->stats.maxgrace > 0)
1288 * spell is actually cast, it knows about the stringarg. 1247 * spell is actually cast, it knows about the stringarg.
1289 * necessary for the invoke command spells. 1248 * necessary for the invoke command spells.
1290 */ 1249 */
1291 if (stringarg) 1250 if (stringarg)
1292 { 1251 {
1293 op->spellarg = strdup_local (stringarg); 1252 op->spellarg = strdup (stringarg);
1294 } 1253 }
1295 else 1254 else
1296 op->spellarg = NULL; 1255 op->spellarg = NULL;
1297 return 0; 1256 return 0;
1298 } 1257 }
1691 if (QUERY_FLAG (victim, FLAG_ALIVE)) 1650 if (QUERY_FLAG (victim, FLAG_ALIVE))
1692 { 1651 {
1693 hit_player (victim, spell->stats.dam, spell, spell->attacktype, 1); 1652 hit_player (victim, spell->stats.dam, spell, spell->attacktype, 1);
1694 1653
1695 if (!spell->destroyed ()) 1654 if (!spell->destroyed ())
1696 { 1655 spell->destroy ();
1697 remove_ob (spell);
1698 free_object (spell);
1699 }
1700 } 1656 }
1701 break; 1657 break;
1702 1658
1703 case SP_MOVING_BALL: 1659 case SP_MOVING_BALL:
1704 if (QUERY_FLAG (victim, FLAG_ALIVE)) 1660 if (QUERY_FLAG (victim, FLAG_ALIVE))

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines