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

Comparing deliantra/server/server/spell_effect.C (file contents):
Revision 1.115 by root, Sun Nov 29 09:41:28 2009 UTC vs.
Revision 1.130 by root, Wed Apr 21 05:48:35 2010 UTC

1/* 1/*
2 * This file is part of Deliantra, the Roguelike Realtime MMORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 Frank Tore Johansen 6 * Copyright (©) 1992 Frank Tore Johansen
7 * 7 *
8 * Deliantra is free software: you can redistribute it and/or modify it under 8 * Deliantra is free software: you can redistribute it and/or modify it under
9 * the terms of the Affero GNU General Public License as published by the 9 * the terms of the Affero GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your 10 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version. 11 * option) any later version.
58} 58}
59 59
60int 60int
61recharge (object *op, object *caster, object *spell_ob) 61recharge (object *op, object *caster, object *spell_ob)
62{ 62{
63 object *wand, *tmp;
64 int ncharges; 63 int ncharges;
65 64
66 wand = find_marked_object (op); 65 object *wand = op->mark ();
66
67 if (!wand || wand->type != WAND) 67 if (!wand || wand->type != WAND)
68 { 68 {
69 new_draw_info (NDI_UNIQUE, 0, op, "You need to mark the wand you want to recharge."); 69 op->failmsg ("You need to mark the wand you want to recharge.");
70 return 0; 70 return 0;
71 } 71 }
72
72 if (!(random_roll (0, 3, op, PREFER_HIGH))) 73 if (!(random_roll (0, 3, op, PREFER_HIGH)))
73 { 74 {
74 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s vibrates violently, then explodes!", query_name (wand)); 75 op->failmsgf ("The %s vibrates violently, then explodes!", query_name (wand));
75 op->play_sound (sound_find ("ob_explode")); 76 op->play_sound (sound_find ("ob_explode"));
76 wand->destroy (); 77 wand->destroy ();
77 tmp = get_archetype (shstr_fireball); 78 object *tmp = get_archetype (shstr_fireball);
78 tmp->stats.dam = (spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob)) / 10; 79 tmp->stats.dam = (spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob)) / 10;
79 80
80 if (!tmp->stats.dam) 81 if (!tmp->stats.dam)
81 tmp->stats.dam = 1; 82 tmp->stats.dam = 1;
82 83
93 94
94 if (wand->inv && wand->inv->level) 95 if (wand->inv && wand->inv->level)
95 ncharges /= wand->inv->level; 96 ncharges /= wand->inv->level;
96 else 97 else
97 { 98 {
98 new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s is broken.", query_name (wand)); 99 op->failmsgf ("Your %s is broken.", query_name (wand));
99 return 0; 100 return 0;
100 } 101 }
101 102
102 if (!ncharges) 103 if (!ncharges)
103 ncharges = 1; 104 ncharges = 1;
104 105
105 wand->stats.food += ncharges; 106 wand->stats.food += ncharges;
106 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s glows with power.", query_name (wand)); 107 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s glows with power.", query_name (wand));
107 108
108 if (wand->arch && QUERY_FLAG (wand->arch, FLAG_ANIMATE)) 109 if (wand->arch && wand->arch->flag [FLAG_ANIMATE])
109 { 110 {
110 SET_FLAG (wand, FLAG_ANIMATE); 111 wand->set_flag (FLAG_ANIMATE);
111 wand->set_speed (wand->arch->speed); 112 wand->set_speed (wand->arch->speed);
112 } 113 }
113 114
114 return 1; 115 return 1;
115} 116}
129{ 130{
130 int bonus_plus = 0; 131 int bonus_plus = 0;
131 const char *missile_name = "arrow"; 132 const char *missile_name = "arrow";
132 133
133 for (object *tmp = op->inv; tmp; tmp = tmp->below) 134 for (object *tmp = op->inv; tmp; tmp = tmp->below)
134 if (tmp->type == BOW && QUERY_FLAG (tmp, FLAG_APPLIED)) 135 if (tmp->type == BOW && tmp->flag [FLAG_APPLIED])
135 missile_name = tmp->race; 136 missile_name = tmp->race;
136 137
137 int missile_plus = spell->stats.dam + SP_level_dam_adjust (caster, spell); 138 int missile_plus = spell->stats.dam + SP_level_dam_adjust (caster, spell);
138 139
139 archetype *missile_arch = archetype::find (missile_name); 140 archetype *missile_arch = archetype::find (missile_name);
158 break; 159 break;
159 160
160 if (!al) 161 if (!al)
161 { 162 {
162 missile->destroy (); 163 missile->destroy ();
163 new_draw_info_format (NDI_UNIQUE, 0, op, "No such object %ss of %s", missile_name, spellparam); 164 op->failmsgf ("No such object %ss of %s", missile_name, spellparam);
164 return 0; 165 return 0;
165 } 166 }
166 167
167 if (al->item->slaying) 168 if (al->item->slaying)
168 { 169 {
169 missile->destroy (); 170 missile->destroy ();
170 new_draw_info_format (NDI_UNIQUE, 0, op, "You are not allowed to create %ss of %s", missile_name, spellparam); 171 op->failmsgf ("You are not allowed to create %ss of %s", missile_name, spellparam);
171 return 0; 172 return 0;
172 } 173 }
173 174
174 give_artifact_abilities (missile, al->item); 175 give_artifact_abilities (missile, al->item);
175 /* These special arrows cost something extra. Don't have them also be magical - 176 /* These special arrows cost something extra. Don't have them also be magical -
193 194
194 missile->magic = missile_plus; 195 missile->magic = missile_plus;
195 /* Can't get any money for these objects */ 196 /* Can't get any money for these objects */
196 missile->value = 0; 197 missile->value = 0;
197 198
198 SET_FLAG (missile, FLAG_IDENTIFIED); 199 missile->set_flag (FLAG_IDENTIFIED);
199 200
200 if (!cast_create_obj (op, caster, missile, dir) && op->type == PLAYER && !missile->destroyed ()) 201 if (!cast_create_obj (op, caster, missile, dir) && op->type == PLAYER && !missile->destroyed ())
201 pick_up (op, missile); 202 pick_up (op, missile);
202 203
203 return 1; 204 return 1;
257 /* Pretty unlikely (there are some very low food items), but you never 258 /* Pretty unlikely (there are some very low food items), but you never
258 * know 259 * know
259 */ 260 */
260 if (!at) 261 if (!at)
261 { 262 {
262 new_draw_info (NDI_UNIQUE, 0, op, "You don't have enough experience to create any food."); 263 op->failmsgf ("You don't have enough experience to create any food.");
263 return 0; 264 return 0;
264 } 265 }
265 266
266 food_value /= at->stats.food; 267 food_value /= at->stats.food;
267 new_op = arch_to_object (at); 268 new_op = at->instance ();
268 new_op->nrof = food_value; 269 new_op->nrof = food_value;
269 270
270 new_op->value = 0; 271 new_op->value = 0;
271 if (new_op->nrof < 1) 272 if (new_op->nrof < 1)
272 new_op->nrof = 1; 273 new_op->nrof = 1;
297 mflags = get_map_flags (m, &m, x, y, &x, &y); 298 mflags = get_map_flags (m, &m, x, y, &x, &y);
298 299
299 if (mflags & P_OUT_OF_MAP) 300 if (mflags & P_OUT_OF_MAP)
300 break; 301 break;
301 302
302 if (!QUERY_FLAG (op, FLAG_WIZCAST) && (mflags & P_NO_MAGIC)) 303 if (!op->flag [FLAG_WIZCAST] && (mflags & P_NO_MAGIC))
303 { 304 {
304 new_draw_info (NDI_UNIQUE, 0, op, "Something blocks your magic."); 305 new_draw_info (NDI_UNIQUE, 0, op, "Something blocks your magic.");
305 return 0; 306 return 0;
306 } 307 }
307 308
308 if (mflags & P_IS_ALIVE) 309 if (mflags & P_IS_ALIVE)
309 { 310 {
310 for (tmp = GET_MAP_OB (m, x, y); tmp; tmp = tmp->above) 311 for (tmp = GET_MAP_OB (m, x, y); tmp; tmp = tmp->above)
311 if (QUERY_FLAG (tmp, FLAG_ALIVE) && (tmp->type == PLAYER || QUERY_FLAG (tmp, FLAG_MONSTER))) 312 if (tmp->flag [FLAG_ALIVE] && (tmp->type == PLAYER || tmp->flag [FLAG_MONSTER]))
312 { 313 {
313 new_draw_info (NDI_UNIQUE, 0, op, "You detect something."); 314 new_draw_info (NDI_UNIQUE, 0, op, "You detect something.");
314 if (tmp->head != NULL) 315 if (tmp->head != NULL)
315 tmp = tmp->head; 316 tmp = tmp->head;
316 examine_monster (op, tmp); 317 examine_monster (op, tmp);
339 if (pl->type == PLAYER) 340 if (pl->type == PLAYER)
340 { 341 {
341 /* If race isn't set, then invisible unless it is undead */ 342 /* If race isn't set, then invisible unless it is undead */
342 if (!pl->contr->invis_race) 343 if (!pl->contr->invis_race)
343 { 344 {
344 if (QUERY_FLAG (mon, FLAG_UNDEAD)) 345 if (mon->flag [FLAG_UNDEAD])
345 return 0; 346 return 0;
346 347
347 return 1; 348 return 1;
348 } 349 }
349 350
380int 381int
381cast_invisible (object *op, object *caster, object *spell_ob) 382cast_invisible (object *op, object *caster, object *spell_ob)
382{ 383{
383 if (op->invisible > 1000) 384 if (op->invisible > 1000)
384 { 385 {
385 new_draw_info (NDI_UNIQUE, 0, op, "You can not extend the duration of your invisibility any further"); 386 op->failmsg ("You can not extend the duration of your invisibility any further");
386 return 0; 387 return 0;
387 } 388 }
388 389
389 /* Remove the switch with 90% duplicate code - just handle the differences with 390 /* Remove the switch with 90% duplicate code - just handle the differences with
390 * and if statement or two. 391 * and if statement or two.
396 397
397 if (op->type == PLAYER) 398 if (op->type == PLAYER)
398 { 399 {
399 op->contr->invis_race = spell_ob->race; 400 op->contr->invis_race = spell_ob->race;
400 401
401 if (QUERY_FLAG (spell_ob, FLAG_MAKE_INVIS)) 402 if (spell_ob->flag [FLAG_MAKE_INVIS])
402 op->contr->tmp_invis = 0; 403 op->contr->tmp_invis = 0;
403 else 404 else
404 op->contr->tmp_invis = 1; 405 op->contr->tmp_invis = 1;
405 406
406 op->contr->hidden = 0; 407 op->contr->hidden = 0;
448 // earth to dust tears down everything that can be torn down 449 // earth to dust tears down everything that can be torn down
449 for (object *next, *tmp = m->at (sx, sy).bot; tmp; tmp = next) 450 for (object *next, *tmp = m->at (sx, sy).bot; tmp; tmp = next)
450 { 451 {
451 next = tmp->above; 452 next = tmp->above;
452 453
453 if (QUERY_FLAG (tmp, FLAG_TEAR_DOWN)) 454 if (tmp->flag [FLAG_TEAR_DOWN])
454 hit_player (tmp, 9998, op, AT_PHYSICAL, 0); 455 hit_player (tmp, 9998, op, AT_PHYSICAL, 0);
455 } 456 }
456 } 457 }
457 458
458 return 1; 459 return 1;
461void 462void
462execute_word_of_recall (object *op) 463execute_word_of_recall (object *op)
463{ 464{
464 if (object *pl = op->in_player ()) 465 if (object *pl = op->in_player ())
465 { 466 {
466 if (pl->ms ().flags () & P_NO_CLERIC && !QUERY_FLAG (pl, FLAG_WIZCAST)) 467 if (pl->ms ().flags () & P_NO_CLERIC && !pl->flag [FLAG_WIZCAST])
467 new_draw_info (NDI_UNIQUE, 0, pl, "You feel something fizzle inside you."); 468 new_draw_info (NDI_UNIQUE, 0, pl, "You feel something fizzle inside you.");
468 else 469 else
469 pl->player_goto (op->slaying, op->stats.hp, op->stats.sp); 470 pl->player_goto (op->slaying, op->stats.hp, op->stats.sp);
470 } 471 }
471 472
594 for (int i = 0; i < NUM_STATS; i++) 595 for (int i = 0; i < NUM_STATS; i++)
595 if (tmp->stats.stat (i) < 0) 596 if (tmp->stats.stat (i) < 0)
596 buf.printf (" - Your %s is depleted by %d.\n", statname[i], -tmp->stats.stat (i)); 597 buf.printf (" - Your %s is depleted by %d.\n", statname[i], -tmp->stats.stat (i));
597 } 598 }
598 599
599 if (is_dragon_pl (op)) 600 if (op->is_dragon ())
600 /* now grab the 'dragon_ability'-force from the player's inventory */ 601 /* now grab the 'dragon_ability'-force from the player's inventory */
601 for (tmp = op->inv; tmp; tmp = tmp->below) 602 for (tmp = op->inv; tmp; tmp = tmp->below)
602 { 603 {
603 if (tmp->type == FORCE && tmp->arch->archname == shstr_dragon_ability_force) 604 if (tmp->type == FORCE && tmp->arch->archname == shstr_dragon_ability_force)
604 { 605 {
645 646
646 if ((spell_ob->move_block || x != op->x || y != op->y) && 647 if ((spell_ob->move_block || x != op->x || y != op->y) &&
647 (get_map_flags (m, &m, x, y, &x, &y) & (P_OUT_OF_MAP | P_IS_ALIVE) || 648 (get_map_flags (m, &m, x, y, &x, &y) & (P_OUT_OF_MAP | P_IS_ALIVE) ||
648 ((spell_ob->move_block & GET_MAP_MOVE_BLOCK (m, x, y)) == spell_ob->move_block))) 649 ((spell_ob->move_block & GET_MAP_MOVE_BLOCK (m, x, y)) == spell_ob->move_block)))
649 { 650 {
650 new_draw_info (NDI_UNIQUE, 0, op, "Something is in the way."); 651 op->failmsg ("Something is in the way.");
651 return 0; 652 return 0;
652 } 653 }
653 654
654 if (spell_ob->other_arch) 655 if (spell_ob->other_arch)
655 tmp = arch_to_object (spell_ob->other_arch); 656 tmp = spell_ob->other_arch->instance ();
656 else if (spell_ob->race) 657 else if (spell_ob->race)
657 { 658 {
658 char buf1[MAX_BUF]; 659 char buf1[MAX_BUF];
659 660
660 sprintf (buf1, spell_ob->race, dir); 661 sprintf (buf1, spell_ob->race, dir);
664 LOG (llevError, "summon_wall: Unable to find archetype %s\n", buf1); 665 LOG (llevError, "summon_wall: Unable to find archetype %s\n", buf1);
665 new_draw_info (NDI_UNIQUE, 0, op, "This spell is broken."); 666 new_draw_info (NDI_UNIQUE, 0, op, "This spell is broken.");
666 return 0; 667 return 0;
667 } 668 }
668 669
669 tmp = arch_to_object (at); 670 tmp = at->instance ();
670 } 671 }
671 else 672 else
672 { 673 {
673 LOG (llevError, "magic_wall: spell %s lacks other_arch\n", &spell_ob->name); 674 LOG (llevError, "magic_wall: spell %s lacks other_arch\n", &spell_ob->name);
674 return 0; 675 return 0;
679 tmp->attacktype = spell_ob->attacktype; 680 tmp->attacktype = spell_ob->attacktype;
680 tmp->duration = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob); 681 tmp->duration = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob);
681 tmp->stats.dam = spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob); 682 tmp->stats.dam = spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob);
682 tmp->range = 0; 683 tmp->range = 0;
683 } 684 }
684 else if (QUERY_FLAG (tmp, FLAG_ALIVE)) 685 else if (tmp->flag [FLAG_ALIVE])
685 { 686 {
686 tmp->stats.hp = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob); 687 tmp->stats.hp = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob);
687 tmp->stats.maxhp = tmp->stats.hp; 688 tmp->stats.maxhp = tmp->stats.hp;
688 } 689 }
689 690
690 if (QUERY_FLAG (spell_ob, FLAG_IS_USED_UP) || QUERY_FLAG (tmp, FLAG_IS_USED_UP)) 691 if (spell_ob->flag [FLAG_IS_USED_UP] || tmp->flag [FLAG_IS_USED_UP])
691 { 692 {
692 tmp->stats.food = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob); 693 tmp->stats.food = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob);
693 SET_FLAG (tmp, FLAG_IS_USED_UP); 694 tmp->set_flag (FLAG_IS_USED_UP);
694 } 695 }
695 696
696 if (QUERY_FLAG (spell_ob, FLAG_TEAR_DOWN)) 697 if (spell_ob->flag [FLAG_TEAR_DOWN])
697 { 698 {
698 tmp->stats.hp = spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob); 699 tmp->stats.hp = spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob);
699 tmp->stats.maxhp = tmp->stats.hp; 700 tmp->stats.maxhp = tmp->stats.hp;
700 SET_FLAG (tmp, FLAG_TEAR_DOWN); 701 tmp->set_flag (FLAG_TEAR_DOWN);
701 SET_FLAG (tmp, FLAG_ALIVE); 702 tmp->set_flag (FLAG_ALIVE);
702 } 703 }
703 704
704 /* This can't really hurt - if the object doesn't kill anything, 705 /* This can't really hurt - if the object doesn't kill anything,
705 * these fields just won't be used. Do not set the owner for 706 * these fields just won't be used. Do not set the owner for
706 * earthwalls, though, so they survive restarts. 707 * earthwalls, though, so they survive restarts.
718 return 0; 719 return 0;
719 } 720 }
720 721
721 /* If this is a spellcasting wall, need to insert the spell object */ 722 /* If this is a spellcasting wall, need to insert the spell object */
722 if (tmp->other_arch && tmp->other_arch->type == SPELL) 723 if (tmp->other_arch && tmp->other_arch->type == SPELL)
723 insert_ob_in_ob (arch_to_object (tmp->other_arch), tmp); 724 insert_ob_in_ob (tmp->other_arch->instance (), tmp);
724 725
725 /* This code causes the wall to extend some distance in 726 /* This code causes the wall to extend some distance in
726 * each direction, or until an obstruction is encountered. 727 * each direction, or until an obstruction is encountered.
727 * posblocked and negblocked help determine how far the 728 * posblocked and negblocked help determine how far the
728 * created wall can extend, it won't go extend through 729 * created wall can extend, it won't go extend through
748 object *tmp2 = tmp->clone (); 749 object *tmp2 = tmp->clone ();
749 m->insert (tmp2, x, y, op); 750 m->insert (tmp2, x, y, op);
750 751
751 /* If this is a spellcasting wall, need to insert the spell object */ 752 /* If this is a spellcasting wall, need to insert the spell object */
752 if (tmp2->other_arch && tmp2->other_arch->type == SPELL) 753 if (tmp2->other_arch && tmp2->other_arch->type == SPELL)
753 tmp2->insert (arch_to_object (tmp2->other_arch)); 754 tmp2->insert (tmp2->other_arch->instance ());
754 755
755 } 756 }
756 else 757 else
757 posblocked = 1; 758 posblocked = 1;
758 759
765 { 766 {
766 object *tmp2 = tmp->clone (); 767 object *tmp2 = tmp->clone ();
767 m->insert (tmp2, x, y, op); 768 m->insert (tmp2, x, y, op);
768 769
769 if (tmp2->other_arch && tmp2->other_arch->type == SPELL) 770 if (tmp2->other_arch && tmp2->other_arch->type == SPELL)
770 tmp2->insert (arch_to_object (tmp2->other_arch)); 771 tmp2->insert (tmp2->other_arch->instance ());
771 } 772 }
772 else 773 else
773 negblocked = 1; 774 negblocked = 1;
774 } 775 }
775 776
776 if (QUERY_FLAG (tmp, FLAG_BLOCKSVIEW)) 777 if (tmp->flag [FLAG_BLOCKSVIEW])
777 update_all_los (op->map, op->x, op->y); 778 update_all_los (op->map, op->x, op->y);
778 779
779 return 1; 780 return 1;
780} 781}
781 782
790 if (op->type != PLAYER) 791 if (op->type != PLAYER)
791 return 0; 792 return 0;
792 793
793 if (!dir) 794 if (!dir)
794 { 795 {
795 new_draw_info (NDI_UNIQUE, 0, op, "In what direction?"); 796 op->failmsg ("In what direction?");
796 return 0; 797 return 0;
797 } 798 }
798 799
799 /* Given the new outdoor maps, can't let players dimension door for 800 /* Given the new outdoor maps, can't let players dimension door for
800 * ever, so put limits in. 801 * ever, so put limits in.
805 { 806 {
806 int count = atoi (spellparam); 807 int count = atoi (spellparam);
807 808
808 if (count > maxdist) 809 if (count > maxdist)
809 { 810 {
810 new_draw_info (NDI_UNIQUE, 0, op, "You can't dimension door that far!"); 811 op->failmsg ("You can't dimension door that far!");
811 return 0; 812 return 0;
812 } 813 }
813 814
814 for (dist = 0; dist < count; dist++) 815 for (dist = 0; dist < count; dist++)
815 { 816 {
876 break; 877 break;
877 878
878 } 879 }
879 if (!dist) 880 if (!dist)
880 { 881 {
881 new_draw_info (NDI_UNIQUE, 0, op, "Your spell failed!\n"); 882 op->failmsg ("Your spell failed!\n");
882 return 0; 883 return 0;
883 } 884 }
884 } 885 }
885 886
886 /* Actually move the player now */ 887 /* Actually move the player now */
1002 tmp->stats.grace = tmp->stats.maxgrace; 1003 tmp->stats.grace = tmp->stats.maxgrace;
1003 success = 1; 1004 success = 1;
1004 new_draw_info (NDI_UNIQUE, 0, tmp, "You feel redeemed with your god!"); 1005 new_draw_info (NDI_UNIQUE, 0, tmp, "You feel redeemed with your god!");
1005 } 1006 }
1006 1007
1007 if (spell->stats.food && tmp->stats.food < 999) 1008 if (spell->stats.food && tmp->stats.food < MAX_FOOD)
1008 { 1009 {
1009 tmp->stats.food += spell->stats.food; 1010 tmp->stats.food += spell->stats.food;
1010 1011 min_it (tmp->stats.food, MAX_FOOD);
1011 if (tmp->stats.food > 999)
1012 tmp->stats.food = 999;
1013 1012
1014 success = 1; 1013 success = 1;
1015 /* We could do something a bit better like the messages for healing above */ 1014 /* We could do something a bit better like the messages for healing above */
1016 new_draw_info (NDI_UNIQUE, 0, tmp, "You feel your belly fill with food"); 1015 new_draw_info (NDI_UNIQUE, 0, tmp, "You feel your belly fill with food");
1017 } 1016 }
1064 break; 1063 break;
1065 } 1064 }
1066 else if (spell_ob->race && spell_ob->race == tmp2->name) 1065 else if (spell_ob->race && spell_ob->race == tmp2->name)
1067 { 1066 {
1068 if (!silent) 1067 if (!silent)
1069 new_draw_info_format (NDI_UNIQUE, 0, op,
1070 "You can not cast %s while %s is in effect", 1068 op->failmsgf ("You can not cast %s while %s is in effect",
1071 &spell_ob->name, &tmp2->name_pl); 1069 &spell_ob->name, &tmp2->name_pl);
1072 1070
1073 return 0; 1071 return 0;
1074 } 1072 }
1075 } 1073 }
1076 } 1074 }
1105 1103
1106 force->name_pl = spell_ob->name; 1104 force->name_pl = spell_ob->name;
1107 1105
1108 force->speed = 1.0; 1106 force->speed = 1.0;
1109 force->speed_left = -1.0; 1107 force->speed_left = -1.0;
1110 SET_FLAG (force, FLAG_APPLIED); 1108 force->set_flag (FLAG_APPLIED);
1111 1109
1112 /* Now start processing the effects. First, protections */ 1110 /* Now start processing the effects. First, protections */
1113 for (i = 0; i < NROFATTACKS; i++) 1111 for (i = 0; i < NROFATTACKS; i++)
1114 { 1112 {
1115 if (spell_ob->resist[i]) 1113 if (spell_ob->resist[i])
1145 } 1143 }
1146 } 1144 }
1147 1145
1148 force->move_type = spell_ob->move_type; 1146 force->move_type = spell_ob->move_type;
1149 1147
1150 if (QUERY_FLAG (spell_ob, FLAG_SEE_IN_DARK)) 1148 if (spell_ob->flag [FLAG_SEE_IN_DARK])
1151 SET_FLAG (force, FLAG_SEE_IN_DARK); 1149 force->set_flag (FLAG_SEE_IN_DARK);
1152 1150
1153 if (QUERY_FLAG (spell_ob, FLAG_XRAYS)) 1151 if (spell_ob->flag [FLAG_XRAYS])
1154 SET_FLAG (force, FLAG_XRAYS); 1152 force->set_flag (FLAG_XRAYS);
1155 1153
1156 /* Haste/bonus speed */ 1154 /* Haste/bonus speed */
1157 if (spell_ob->stats.exp) 1155 if (spell_ob->stats.exp)
1158 { 1156 {
1159 if (op->speed > 0.5f) 1157 if (op->speed > 0.5f)
1240 return 0; 1238 return 0;
1241 } 1239 }
1242 force->duration = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob) * 50; 1240 force->duration = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob) * 50;
1243 force->speed = 1.0; 1241 force->speed = 1.0;
1244 force->speed_left = -1.0; 1242 force->speed_left = -1.0;
1245 SET_FLAG (force, FLAG_APPLIED); 1243 force->set_flag (FLAG_APPLIED);
1246 1244
1247 if (!god) 1245 if (!god)
1248 { 1246 {
1249 new_draw_info (NDI_UNIQUE, 0, op, "Your blessing seems empty."); 1247 new_draw_info (NDI_UNIQUE, 0, op, "Your blessing seems empty.");
1250 } 1248 }
1304 * the nuggets, alchemy the gold from that, etc. 1302 * the nuggets, alchemy the gold from that, etc.
1305 * Otherwise, give 9 silver on the gold for other objects, 1303 * Otherwise, give 9 silver on the gold for other objects,
1306 * so that it would still be more affordable to haul 1304 * so that it would still be more affordable to haul
1307 * the stuff back to town. 1305 * the stuff back to town.
1308 */ 1306 */
1309 if (QUERY_FLAG (obj, FLAG_UNPAID)) 1307 if (obj->flag [FLAG_UNPAID])
1310 value = 0; 1308 value = 0;
1311 else if (obj->type == MONEY || obj->type == GEM) 1309 else if (obj->type == MONEY || obj->type == GEM)
1312 value /= 3; 1310 value /= 3;
1313 else 1311 else
1314 value = value * 9 / 10; 1312 value = value * 9 / 10;
1368 1366
1369 for (object *next, *tmp = mp->at (nx, ny).bot; tmp; tmp = next) 1367 for (object *next, *tmp = mp->at (nx, ny).bot; tmp; tmp = next)
1370 { 1368 {
1371 next = tmp->above; 1369 next = tmp->above;
1372 1370
1373 if (tmp->weight > 0 && !QUERY_FLAG (tmp, FLAG_NO_PICK) && 1371 if (tmp->weight > 0 && !tmp->flag [FLAG_NO_PICK] &&
1374 !QUERY_FLAG (tmp, FLAG_ALIVE) && !QUERY_FLAG (tmp, FLAG_IS_CAULDRON)) 1372 !tmp->flag [FLAG_ALIVE] && !tmp->flag [FLAG_IS_CAULDRON])
1375 { 1373 {
1376 if (tmp->inv) 1374 if (tmp->inv)
1377 { 1375 {
1378 object *next1, *tmp1; 1376 object *next1, *tmp1;
1379 1377
1380 for (tmp1 = tmp->inv; tmp1; tmp1 = next1) 1378 for (tmp1 = tmp->inv; tmp1; tmp1 = next1)
1381 { 1379 {
1382 next1 = tmp1->below; 1380 next1 = tmp1->below;
1383 if (tmp1->weight > 0 && !QUERY_FLAG (tmp1, FLAG_NO_PICK) && 1381 if (tmp1->weight > 0 && !tmp1->flag [FLAG_NO_PICK] &&
1384 !QUERY_FLAG (tmp1, FLAG_ALIVE) && !QUERY_FLAG (tmp1, FLAG_IS_CAULDRON)) 1382 !tmp1->flag [FLAG_ALIVE] && !tmp1->flag [FLAG_IS_CAULDRON])
1385 alchemy_object (tmp1, value, weight); 1383 alchemy_object (tmp1, value, weight);
1386 } 1384 }
1387 } 1385 }
1388 1386
1389 alchemy_object (tmp, value, weight); 1387 alchemy_object (tmp, value, weight);
1399 for (int i = 0; i < sizeof (nugget) / sizeof (nugget [0]); ++i) 1397 for (int i = 0; i < sizeof (nugget) / sizeof (nugget [0]); ++i)
1400 if (int nrof = value / nugget [i]->value) 1398 if (int nrof = value / nugget [i]->value)
1401 { 1399 {
1402 value -= nrof * nugget[i]->value; 1400 value -= nrof * nugget[i]->value;
1403 1401
1404 object *tmp = arch_to_object (nugget[i]); 1402 object *tmp = nugget[i]->instance ();
1405 tmp->nrof = nrof; 1403 tmp->nrof = nrof;
1406 tmp->flag [FLAG_IDENTIFIED] = true; 1404 tmp->flag [FLAG_IDENTIFIED] = true;
1407 op->map->insert (tmp, x, y, op, 0); 1405 op->map->insert (tmp, x, y, op, 0);
1408 } 1406 }
1409 1407
1423remove_curse (object *op, object *caster, object *spell) 1421remove_curse (object *op, object *caster, object *spell)
1424{ 1422{
1425 int success = 0, was_one = 0; 1423 int success = 0, was_one = 0;
1426 1424
1427 for (object *tmp = op->inv; tmp; tmp = tmp->below) 1425 for (object *tmp = op->inv; tmp; tmp = tmp->below)
1428 if (QUERY_FLAG (tmp, FLAG_APPLIED) && 1426 if (tmp->flag [FLAG_APPLIED] &&
1429 ((QUERY_FLAG (tmp, FLAG_CURSED) && QUERY_FLAG (spell, FLAG_CURSED)) || 1427 ((tmp->flag [FLAG_CURSED] && spell->flag [FLAG_CURSED]) ||
1430 (QUERY_FLAG (tmp, FLAG_DAMNED) && QUERY_FLAG (spell, FLAG_DAMNED)))) 1428 (tmp->flag [FLAG_DAMNED] && spell->flag [FLAG_DAMNED])))
1431 { 1429 {
1432 was_one++; 1430 was_one++;
1433 1431
1434 if (tmp->level <= casting_level (caster, spell)) 1432 if (tmp->level <= casting_level (caster, spell))
1435 { 1433 {
1436 success++; 1434 success++;
1437 if (QUERY_FLAG (spell, FLAG_DAMNED)) 1435 if (spell->flag [FLAG_DAMNED])
1438 CLEAR_FLAG (tmp, FLAG_DAMNED); 1436 tmp->clr_flag (FLAG_DAMNED);
1439 1437
1440 CLEAR_FLAG (tmp, FLAG_CURSED); 1438 tmp->clr_flag (FLAG_CURSED);
1441 CLEAR_FLAG (tmp, FLAG_KNOWN_CURSED); 1439 tmp->clr_flag (FLAG_KNOWN_CURSED);
1442 tmp->value = 0; /* Still can't sell it */ 1440 tmp->value = 0; /* Still can't sell it */
1443 1441
1444 if (object *pl = tmp->visible_to ()) 1442 if (object *pl = tmp->visible_to ())
1445 esrv_update_item (UPD_FLAGS, pl, tmp); 1443 esrv_update_item (UPD_FLAGS, pl, tmp);
1446 } 1444 }
1471 1469
1472 int num_ident = max (1, spell->stats.dam + SP_level_dam_adjust (caster, spell)); 1470 int num_ident = max (1, spell->stats.dam + SP_level_dam_adjust (caster, spell));
1473 1471
1474 for (tmp = op->inv; tmp; tmp = tmp->below) 1472 for (tmp = op->inv; tmp; tmp = tmp->below)
1475 { 1473 {
1476 if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED) && !tmp->invisible && need_identify (tmp)) 1474 if (!tmp->flag [FLAG_IDENTIFIED] && !tmp->invisible && tmp->need_identify ())
1477 { 1475 {
1478 identify (tmp); 1476 identify (tmp);
1479 1477
1480 if (op->type == PLAYER) 1478 if (op->type == PLAYER)
1481 { 1479 {
1495 * was not fully used. 1493 * was not fully used.
1496 */ 1494 */
1497 if (num_ident) 1495 if (num_ident)
1498 { 1496 {
1499 for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp; tmp = tmp->above) 1497 for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp; tmp = tmp->above)
1500 if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED) && !tmp->invisible && need_identify (tmp)) 1498 if (!tmp->flag [FLAG_IDENTIFIED] && !tmp->invisible && tmp->need_identify ())
1501 { 1499 {
1502 identify (tmp); 1500 identify (tmp);
1503 1501
1504 if (object *pl = tmp->visible_to ()) 1502 if (object *pl = tmp->visible_to ())
1505 { 1503 {
1545 range = spell->range + SP_level_range_adjust (caster, spell); 1543 range = spell->range + SP_level_range_adjust (caster, spell);
1546 1544
1547 if (!skill) 1545 if (!skill)
1548 skill = caster; 1546 skill = caster;
1549 1547
1548 dynbuf buf;
1550 unordered_mapwalk (op, -range, -range, range, range) 1549 unordered_mapwalk (buf, op, -range, -range, range, range)
1551 { 1550 {
1552 /* For most of the detections, we only detect objects above the 1551 /* For most of the detections, we only detect objects above the
1553 * floor. But this is not true for show invisible. 1552 * floor. But this is not true for show invisible.
1554 * Basically, we just go and find the top object and work 1553 * Basically, we just go and find the top object and work
1555 * down - that is easier than working up. 1554 * down - that is easier than working up.
1556 */ 1555 */
1557 1556
1558 for (last = NULL, tmp = m->at (nx, ny).bot; tmp; tmp = tmp->above) 1557 for (last = 0, tmp = m->at (nx, ny).bot; tmp; tmp = tmp->above)
1559 last = tmp; 1558 last = tmp;
1560 1559
1561 /* Shouldn't happen, but if there are no objects on a space, this 1560 /* Shouldn't happen, but if there are no objects on a space, this
1562 * would happen. 1561 * would happen.
1563 */ 1562 */
1564 if (!last) 1563 if (!last)
1565 continue; 1564 continue;
1566 1565
1567 done_one = 0; 1566 done_one = 0;
1568 floor = 0; 1567 floor = 0;
1569 detect = NULL; 1568 detect = 0;
1570 for (tmp = last; tmp; tmp = tmp->below) 1569 for (tmp = last; tmp; tmp = tmp->below)
1571 { 1570 {
1572 /* show invisible */ 1571 /* show invisible */
1573 if (QUERY_FLAG (spell, FLAG_MAKE_INVIS) && 1572 if (spell->flag [FLAG_MAKE_INVIS]
1574 /* Might there be other objects that we can make visible? */ 1573 /* Might there be other objects that we can make visible? */
1575 (tmp->invisible && (QUERY_FLAG (tmp, FLAG_MONSTER) 1574 && (tmp->invisible && (tmp->flag [FLAG_MONSTER]
1576 || (tmp->type == PLAYER && !QUERY_FLAG (tmp, FLAG_WIZ)) 1575 || (tmp->type == PLAYER && !tmp->flag [FLAG_WIZ])
1577 || tmp->type == T_HANDLE 1576 || tmp->type == T_HANDLE
1578 || tmp->type == TRAPDOOR 1577 || tmp->type == TRAPDOOR
1579 || tmp->type == EXIT 1578 || tmp->type == EXIT
1580 || tmp->type == HOLE 1579 || tmp->type == HOLE
1581 || tmp->type == BUTTON 1580 || tmp->type == BUTTON
1582 || tmp->type == TELEPORTER 1581 || tmp->type == TELEPORTER
1583 || tmp->type == GATE 1582 || tmp->type == GATE
1584 || tmp->type == LOCKED_DOOR 1583 || tmp->type == LOCKED_DOOR
1585 || tmp->type == WEAPON 1584 || tmp->type == WEAPON
1586 || tmp->type == ALTAR 1585 || tmp->type == ALTAR
1587 || tmp->type == SIGN 1586 || (tmp->type == SIGN && tmp->face != magicmouth_face)
1588 || tmp->type == TRIGGER_PEDESTAL 1587 || tmp->type == TRIGGER_PEDESTAL
1589 || tmp->type == SPECIAL_KEY 1588 || tmp->type == SPECIAL_KEY
1590 || tmp->type == TREASURE 1589 || tmp->type == TREASURE
1591 || tmp->type == BOOK 1590 || tmp->type == BOOK
1592 || tmp->type == HOLY_ALTAR 1591 || tmp->type == HOLY_ALTAR
1593 || tmp->type == CONTAINER))) 1592 || tmp->type == CONTAINER)))
1594 { 1593 {
1594 printf ("show inv %s\n", tmp->debug_desc());//D
1595 if (random_roll (0, skill->level - 1, op, PREFER_HIGH) > level / 4) 1595 if (random_roll (0, skill->level - 1, op, PREFER_HIGH) > level / 4)
1596 { 1596 {
1597 tmp->invisible = 0; 1597 tmp->invisible = 0;
1598 done_one = 1; 1598 done_one = 1;
1599 } 1599 }
1600 } 1600 }
1601 1601
1602 if (QUERY_FLAG (tmp, FLAG_IS_FLOOR)) 1602 if (tmp->flag [FLAG_IS_FLOOR])
1603 floor = 1; 1603 floor = 1;
1604 1604
1605 /* All detections below this point don't descend beneath the floor, 1605 /* All detections below this point don't descend beneath the floor,
1606 * so just continue on. We could be clever and look at the type of 1606 * so just continue on. We could be clever and look at the type of
1607 * detection to completely break out if we don't care about objects beneath 1607 * detection to completely break out if we don't care about objects beneath
1616 * difficult to see what object is magical/cursed, so the 1616 * difficult to see what object is magical/cursed, so the
1617 * effect wouldn't be as apparent. 1617 * effect wouldn't be as apparent.
1618 */ 1618 */
1619 1619
1620 /* detect magic */ 1620 /* detect magic */
1621 if (QUERY_FLAG (spell, FLAG_KNOWN_MAGICAL) && 1621 if (spell->flag [FLAG_KNOWN_MAGICAL]
1622 !QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_IDENTIFIED) && is_magical (tmp)) 1622 && !tmp->flag [FLAG_KNOWN_MAGICAL]
1623 && !tmp->flag [FLAG_IDENTIFIED]
1624 && tmp->need_identify ()
1625 && is_magical (tmp))
1623 { 1626 {
1624 SET_FLAG (tmp, FLAG_KNOWN_MAGICAL); 1627 tmp->set_flag (FLAG_KNOWN_MAGICAL);
1625 /* make runes more visibile */ 1628 /* make runes more visible */
1626 if (tmp->type == RUNE && tmp->attacktype & AT_MAGIC) 1629 if (tmp->type == RUNE && tmp->attacktype & AT_MAGIC)
1627 tmp->stats.Cha /= 4; 1630 tmp->stats.Cha /= 4;
1628 1631
1629 done_one = 1; 1632 done_one = 1;
1630 } 1633 }
1631 1634
1632 /* detect monster */ 1635 /* detect monster */
1633 if (QUERY_FLAG (spell, FLAG_MONSTER) && (QUERY_FLAG (tmp, FLAG_MONSTER) || tmp->type == PLAYER)) 1636 if (spell->flag [FLAG_MONSTER] && (tmp->flag [FLAG_MONSTER] || tmp->type == PLAYER))
1634 { 1637 {
1635 done_one = 2; 1638 done_one = 2;
1636 1639
1637 if (!detect) 1640 if (!detect)
1638 detect = tmp; 1641 detect = tmp;
1640 1643
1641 /* Basically, if race is set in the spell, then the creatures race must 1644 /* Basically, if race is set in the spell, then the creatures race must
1642 * match that. if the spell race is set to GOD, then the gods opposing 1645 * match that. if the spell race is set to GOD, then the gods opposing
1643 * race must match. 1646 * race must match.
1644 */ 1647 */
1645 if (spell->race && QUERY_FLAG (tmp, FLAG_MONSTER) && tmp->race && 1648 if (spell->race && tmp->flag [FLAG_MONSTER] && tmp->race &&
1646 ((spell->race == shstr_GOD && god && god->slaying.contains (tmp->race)) || 1649 ((spell->race == shstr_GOD && god && god->slaying.contains (tmp->race)) ||
1647 spell->race.contains (tmp->race))) 1650 spell->race.contains (tmp->race)))
1648 { 1651 {
1649 done_one = 2; 1652 done_one = 2;
1650 1653
1651 if (!detect) 1654 if (!detect)
1652 detect = tmp; 1655 detect = tmp;
1653 } 1656 }
1654 1657
1655 if (QUERY_FLAG (spell, FLAG_KNOWN_CURSED) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED) && 1658 if (spell->flag [FLAG_KNOWN_CURSED]
1656 (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED))) 1659 && !tmp->flag [FLAG_KNOWN_CURSED]
1660 && tmp->need_identify ()
1661 && (tmp->flag [FLAG_CURSED] || tmp->flag [FLAG_DAMNED]))
1657 { 1662 {
1658 SET_FLAG (tmp, FLAG_KNOWN_CURSED); 1663 tmp->set_flag (FLAG_KNOWN_CURSED);
1659 done_one = 1; 1664 done_one = 1;
1665 }
1666
1667 // Do mining detection spell:
1668 if (spell->last_sp == 1) // 1 - detect any vein
1669 {
1670 if (tmp->type == VEIN)
1671 {
1672 if (tmp->other_arch)
1673 {
1674 if (!detect)
1675 detect = tmp->other_arch;
1676 done_one = 2;
1677 }
1678 else
1679 done_one = 1;
1680 }
1660 } 1681 }
1661 } /* for stack of objects on this space */ 1682 } /* for stack of objects on this space */
1662 1683
1663 /* Code here puts an effect of the spell on the space, so you can see 1684 /* Code here puts an effect of the spell on the space, so you can see
1664 * where the magic is. 1685 * where the magic is.
1665 */ 1686 */
1666 if (done_one) 1687 if (done_one)
1667 { 1688 {
1668 object *detect_ob = arch_to_object (spell->other_arch); 1689 object *detect_ob = spell->other_arch->instance ();
1669 1690
1670 /* if this is set, we want to copy the face */ 1691 /* if this is set, we want to copy the face */
1671 if (done_one == 2 && detect) 1692 if (done_one == 2 && detect)
1672 { 1693 {
1673 detect_ob->face = detect->face; 1694 detect_ob->face = detect->face;
1674 detect_ob->animation_id = detect->animation_id; 1695 detect_ob->animation_id = detect->animation_id;
1675 detect_ob->anim_speed = detect->anim_speed; 1696 detect_ob->anim_speed = detect->anim_speed;
1676 detect_ob->last_anim = 0; 1697 detect_ob->last_anim = 0;
1677 /* by default, the detect_ob is already animated */ 1698 /* by default, the detect_ob is already animated */
1678 if (!QUERY_FLAG (detect, FLAG_ANIMATE)) 1699 if (!detect->flag [FLAG_ANIMATE])
1679 CLEAR_FLAG (detect_ob, FLAG_ANIMATE); 1700 detect_ob->clr_flag (FLAG_ANIMATE);
1680 } 1701 }
1681 1702
1682 m->insert (detect_ob, nx, ny, op); 1703 m->insert (detect_ob, nx, ny, op, INS_ON_TOP);
1683 } 1704 }
1684 } /* for processing the surrounding spaces */ 1705 } /* for processing the surrounding spaces */
1685 1706
1686 1707
1687 /* Now process objects in the players inventory if detect curse or magic */ 1708 /* Now process objects in the players inventory if detect curse or magic */
1688 if (QUERY_FLAG (spell, FLAG_KNOWN_CURSED) || QUERY_FLAG (spell, FLAG_KNOWN_MAGICAL)) 1709 if (spell->flag [FLAG_KNOWN_CURSED] || spell->flag [FLAG_KNOWN_MAGICAL])
1689 { 1710 {
1690 done_one = 0; 1711 done_one = 0;
1691 1712
1692 for (tmp = op->inv; tmp; tmp = tmp->below) 1713 for (tmp = op->inv; tmp; tmp = tmp->below)
1693 { 1714 {
1694 if (!tmp->invisible && !QUERY_FLAG (tmp, FLAG_IDENTIFIED)) 1715 if (!tmp->invisible && !tmp->flag [FLAG_IDENTIFIED])
1695 { 1716 {
1696 if (QUERY_FLAG (spell, FLAG_KNOWN_MAGICAL) && is_magical (tmp) && !QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL)) 1717 if (spell->flag [FLAG_KNOWN_MAGICAL] && is_magical (tmp) && !tmp->flag [FLAG_KNOWN_MAGICAL])
1697 { 1718 {
1698 SET_FLAG (tmp, FLAG_KNOWN_MAGICAL); 1719 tmp->set_flag (FLAG_KNOWN_MAGICAL);
1699 1720
1700 if (object *pl = tmp->visible_to ()) 1721 if (object *pl = tmp->visible_to ())
1701 esrv_update_item (UPD_FLAGS, pl, tmp); 1722 esrv_update_item (UPD_FLAGS, pl, tmp);
1702 } 1723 }
1703 1724
1704 if (QUERY_FLAG (spell, FLAG_KNOWN_CURSED) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED) && 1725 if (spell->flag [FLAG_KNOWN_CURSED] && !tmp->flag [FLAG_KNOWN_CURSED] &&
1705 (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED))) 1726 (tmp->flag [FLAG_CURSED] || tmp->flag [FLAG_DAMNED]))
1706 { 1727 {
1707 SET_FLAG (tmp, FLAG_KNOWN_CURSED); 1728 tmp->set_flag (FLAG_KNOWN_CURSED);
1708 1729
1709 if (object *pl = tmp->visible_to ()) 1730 if (object *pl = tmp->visible_to ())
1710 esrv_update_item (UPD_FLAGS, pl, tmp); 1731 esrv_update_item (UPD_FLAGS, pl, tmp);
1711 } 1732 }
1712 } /* if item is not identified */ 1733 } /* if item is not identified */
1772 mflags = get_map_flags (m, &m, x, y, &x, &y); 1793 mflags = get_map_flags (m, &m, x, y, &x, &y);
1773 1794
1774 if (!(mflags & P_OUT_OF_MAP) && mflags & P_IS_ALIVE) 1795 if (!(mflags & P_OUT_OF_MAP) && mflags & P_IS_ALIVE)
1775 { 1796 {
1776 for (plyr = GET_MAP_OB (m, x, y); plyr != NULL; plyr = plyr->above) 1797 for (plyr = GET_MAP_OB (m, x, y); plyr != NULL; plyr = plyr->above)
1777 if (plyr != op && QUERY_FLAG (plyr, FLAG_ALIVE)) 1798 if (plyr != op && plyr->flag [FLAG_ALIVE])
1778 break; 1799 break;
1779 } 1800 }
1780 1801
1781 1802
1782 /* If we did not find a player in the specified direction, transfer 1803 /* If we did not find a player in the specified direction, transfer
1783 * to anyone on top of us. This is used for the rune of transference mostly. 1804 * to anyone on top of us. This is used for the rune of transference mostly.
1784 */ 1805 */
1785 if (plyr == NULL) 1806 if (plyr == NULL)
1786 for (plyr = GET_MAP_OB (op->map, op->x, op->y); plyr != NULL; plyr = plyr->above) 1807 for (plyr = GET_MAP_OB (op->map, op->x, op->y); plyr != NULL; plyr = plyr->above)
1787 if (plyr != op && QUERY_FLAG (plyr, FLAG_ALIVE)) 1808 if (plyr != op && plyr->flag [FLAG_ALIVE])
1788 break; 1809 break;
1789 1810
1790 if (!plyr) 1811 if (!plyr)
1791 { 1812 {
1792 new_draw_info (NDI_BLACK, 0, op, "There is no one there."); 1813 op->failmsg ("There is no one there.");
1793 return 0; 1814 return 0;
1794 } 1815 }
1795 /* give sp */ 1816 /* give sp */
1796 if (spell->stats.dam > 0) 1817 if (spell->stats.dam > 0)
1797 { 1818 {
1809 if (rate > 95) 1830 if (rate > 95)
1810 rate = 95; 1831 rate = 95;
1811 1832
1812 sucked = (plyr->stats.sp * rate) / 100; 1833 sucked = (plyr->stats.sp * rate) / 100;
1813 plyr->stats.sp -= sucked; 1834 plyr->stats.sp -= sucked;
1814 if (QUERY_FLAG (op, FLAG_ALIVE)) 1835 if (op->flag [FLAG_ALIVE])
1815 { 1836 {
1816 /* Player doesn't get full credit */ 1837 /* Player doesn't get full credit */
1817 sucked = (sucked * rate) / 100; 1838 sucked = (sucked * rate) / 100;
1818 op->stats.sp += sucked; 1839 op->stats.sp += sucked;
1819 if (sucked > 0) 1840 if (sucked > 0)
1870 * monsters either. 1891 * monsters either.
1871 */ 1892 */
1872 1893
1873 if (head->attacktype & AT_MAGIC 1894 if (head->attacktype & AT_MAGIC
1874 && !(head->attacktype & AT_COUNTERSPELL) 1895 && !(head->attacktype & AT_COUNTERSPELL)
1875 && !QUERY_FLAG (head, FLAG_MONSTER) 1896 && !head->flag [FLAG_MONSTER]
1876 && (op->level > head->level)) 1897 && (op->level > head->level))
1877 head->destroy (); 1898 head->destroy ();
1878 else 1899 else
1879 switch (head->type) 1900 switch (head->type)
1880 { 1901 {
1881 case SPELL_EFFECT: 1902 case SPELL_EFFECT:
1882 // XXX: Don't affect floor spelleffects. See also XXX comment 1903 // XXX: Don't affect floor spelleffects. See also XXX comment
1883 // about sanctuary in spell_util.C 1904 // about sanctuary in spell_util.C
1884 if (QUERY_FLAG (tmp, FLAG_IS_FLOOR)) 1905 if (tmp->flag [FLAG_IS_FLOOR])
1885 continue; 1906 continue;
1886 1907
1887 if (op->level > head->level) 1908 if (op->level > head->level)
1888 head->destroy (); 1909 head->destroy ();
1889 1910
1912 1933
1913 object *tmp, *god = find_god (determine_god (op)); 1934 object *tmp, *god = find_god (determine_god (op));
1914 1935
1915 if (!god) 1936 if (!god)
1916 { 1937 {
1917 new_draw_info (NDI_UNIQUE, 0, op, "You can't consecrate anything if you don't worship a god!"); 1938 op->failmsg ("You can't consecrate anything if you don't worship a god!");
1918 return 0; 1939 return 0;
1919 } 1940 }
1920 1941
1921 for (tmp = op->below; tmp; tmp = tmp->below) 1942 for (tmp = op->below; tmp; tmp = tmp->below)
1922 { 1943 {
1923 if (QUERY_FLAG (tmp, FLAG_IS_FLOOR)) 1944 if (tmp->flag [FLAG_IS_FLOOR])
1924 break; 1945 break;
1925 if (tmp->type == HOLY_ALTAR) 1946 if (tmp->type == HOLY_ALTAR)
1926 { 1947 {
1927 1948
1928 if (tmp->level > casting_level (caster, spell)) 1949 if (tmp->level > casting_level (caster, spell))
1929 { 1950 {
1930 new_draw_info_format (NDI_UNIQUE, 0, op, "You are not powerful enough to reconsecrate the %s", &tmp->name); 1951 op->failmsgf ("You are not powerful enough to reconsecrate the %s", &tmp->name);
1931 return 0; 1952 return 0;
1932 } 1953 }
1933 else 1954 else
1934 { 1955 {
1935 /* If we got here, we are consecrating an altar */ 1956 /* If we got here, we are consecrating an altar */
1944 new_draw_info_format (NDI_UNIQUE, 0, op, "You consecrated the altar to %s!", &god->name); 1965 new_draw_info_format (NDI_UNIQUE, 0, op, "You consecrated the altar to %s!", &god->name);
1945 return 1; 1966 return 1;
1946 } 1967 }
1947 } 1968 }
1948 } 1969 }
1949 new_draw_info (NDI_UNIQUE, 0, op, "You are not standing over an altar!"); 1970
1971 op->failmsg ("You are not standing over an altar!");
1950 return 0; 1972 return 0;
1951} 1973}
1952 1974
1953/* animate_weapon - 1975/* animate_weapon -
1954 * Generalization of staff_to_snake. Makes a golem out of the caster's weapon. 1976 * Generalization of staff_to_snake. Makes a golem out of the caster's weapon.
1961 * player checks. MSW 2003-01-06 1983 * player checks. MSW 2003-01-06
1962 */ 1984 */
1963int 1985int
1964animate_weapon (object *op, object *caster, object *spell, int dir) 1986animate_weapon (object *op, object *caster, object *spell, int dir)
1965{ 1987{
1966 object *weapon, *tmp;
1967 char buf[MAX_BUF]; 1988 char buf[MAX_BUF];
1968 int a, i; 1989 int a, i;
1969 sint16 x, y; 1990 sint16 x, y;
1970 maptile *m; 1991 maptile *m;
1971 1992
1996 2017
1997 /* if there's no place to put the golem, abort */ 2018 /* if there's no place to put the golem, abort */
1998 if (dir < 0 || (get_map_flags (m, &m, x, y, &x, &y) & P_OUT_OF_MAP) 2019 if (dir < 0 || (get_map_flags (m, &m, x, y, &x, &y) & P_OUT_OF_MAP)
1999 || ((spell->other_arch->move_type & GET_MAP_MOVE_BLOCK (m, x, y)) == spell->other_arch->move_type)) 2020 || ((spell->other_arch->move_type & GET_MAP_MOVE_BLOCK (m, x, y)) == spell->other_arch->move_type))
2000 { 2021 {
2001 new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way."); 2022 op->failmsg ("There is something in the way.");
2002 return 0; 2023 return 0;
2003 } 2024 }
2004 2025
2005 /* Use the weapon marked by the player. */ 2026 /* Use the weapon marked by the player. */
2006 weapon = find_marked_object (op); 2027 object *weapon = op->mark ();
2007 2028
2008 if (!weapon) 2029 if (!weapon)
2009 { 2030 {
2010 new_draw_info (NDI_BLACK, 0, op, "You must mark a weapon to use with this spell!"); 2031 op->failmsg ("You must mark a weapon to use with this spell!");
2011 return 0; 2032 return 0;
2012 } 2033 }
2013 2034
2014 if (spell->race && weapon->arch->archname != spell->race) 2035 if (spell->race && weapon->arch->archname != spell->race)
2015 { 2036 {
2016 new_draw_info (NDI_UNIQUE, 0, op, "The spell fails to transform your weapon."); 2037 op->failmsg ("The spell fails to transform your weapon.");
2017 return 0; 2038 return 0;
2018 } 2039 }
2019 2040
2020 if (weapon->type != WEAPON) 2041 if (weapon->type != WEAPON)
2021 { 2042 {
2022 new_draw_info (NDI_UNIQUE, 0, op, "You need to wield a weapon to animate it."); 2043 op->failmsg ("You need to wield a weapon to animate it.");
2023 return 0; 2044 return 0;
2024 } 2045 }
2025 2046
2026 if (QUERY_FLAG (weapon, FLAG_APPLIED)) 2047 if (weapon->flag [FLAG_APPLIED])
2027 { 2048 {
2028 new_draw_info_format (NDI_BLACK, 0, op, "You need to unequip %s before using it in this spell", query_name (weapon)); 2049 op->failmsgf ("You need to unequip %s before using it in this spell", query_name (weapon));
2029 return 0; 2050 return 0;
2030 } 2051 }
2031 2052
2032 weapon = weapon->split (); 2053 weapon = weapon->split ();
2033 2054
2034 /* create the golem object */ 2055 /* create the golem object */
2035 tmp = arch_to_object (spell->other_arch); 2056 object *tmp = spell->other_arch->instance ();
2036 2057
2037 /* if animated by a player, give the player control of the golem */ 2058 /* if animated by a player, give the player control of the golem */
2038 CLEAR_FLAG (tmp, FLAG_MONSTER); 2059 tmp->clr_flag (FLAG_MONSTER);
2039 tmp->stats.exp = 0; 2060 tmp->stats.exp = 0;
2040 add_friendly_object (tmp); 2061 add_friendly_object (tmp);
2041 tmp->type = GOLEM; 2062 tmp->type = GOLEM;
2042 tmp->set_owner (op); 2063 tmp->set_owner (op);
2043 op->contr->golem = tmp; 2064 op->contr->golem = tmp;
2045 2066
2046 /* Give the weapon to the golem now. A bit of a hack to check the 2067 /* Give the weapon to the golem now. A bit of a hack to check the
2047 * removed flag - it should only be set if weapon->split was 2068 * removed flag - it should only be set if weapon->split was
2048 * used above. 2069 * used above.
2049 */ 2070 */
2050 if (!QUERY_FLAG (weapon, FLAG_REMOVED)) 2071 if (!weapon->flag [FLAG_REMOVED])
2051 weapon->remove (); 2072 weapon->remove ();
2052 2073
2053 tmp->insert (weapon); 2074 tmp->insert (weapon);
2054 2075
2055 /* To do everything necessary to let a golem use the weapon is a pain, 2076 /* To do everything necessary to let a golem use the weapon is a pain,
2056 * so instead, just set it as equipped (otherwise, we need to update 2077 * so instead, just set it as equipped (otherwise, we need to update
2057 * body_info, skills, etc) 2078 * body_info, skills, etc)
2058 */ 2079 */
2059 SET_FLAG (tmp, FLAG_USE_WEAPON); 2080 tmp->set_flag (FLAG_USE_WEAPON);
2060 SET_FLAG (weapon, FLAG_APPLIED); 2081 weapon->set_flag (FLAG_APPLIED);
2061 tmp->update_stats (); 2082 tmp->update_stats ();
2062 2083
2063 /* There used to be 'odd' code that basically seemed to take the absolute 2084 /* There used to be 'odd' code that basically seemed to take the absolute
2064 * value of the weapon->magic an use that. IMO, that doesn't make sense - 2085 * value of the weapon->magic an use that. IMO, that doesn't make sense -
2065 * if you're using a crappy weapon, it shouldn't be as good. 2086 * if you're using a crappy weapon, it shouldn't be as good.
2152 success = op->map->change_map_light (spell->stats.dam); 2173 success = op->map->change_map_light (spell->stats.dam);
2153 2174
2154 if (!success) 2175 if (!success)
2155 { 2176 {
2156 if (spell->stats.dam < 0) 2177 if (spell->stats.dam < 0)
2157 new_draw_info (NDI_UNIQUE, 0, op, "It can be no brighter here."); 2178 op->failmsg ("It can be no brighter here.");
2158 else 2179 else
2159 new_draw_info (NDI_UNIQUE, 0, op, "It can be no darker here."); 2180 op->failmsg ("It can be no darker here.");
2160 } 2181 }
2161 2182
2162 return success; 2183 return success;
2163} 2184}
2164 2185
2174 2195
2175 new_aura = present_arch_in_ob (spell->other_arch, op); 2196 new_aura = present_arch_in_ob (spell->other_arch, op);
2176 if (new_aura) 2197 if (new_aura)
2177 refresh = 1; 2198 refresh = 1;
2178 else 2199 else
2179 new_aura = arch_to_object (spell->other_arch); 2200 new_aura = spell->other_arch->instance ();
2180 2201
2181 new_aura->duration = spell->duration + 10 * SP_level_duration_adjust (caster, spell); 2202 new_aura->duration = spell->duration + 10 * SP_level_duration_adjust (caster, spell);
2182 2203
2183 new_aura->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); 2204 new_aura->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell);
2184 2205
2249 if (pos.normalise () && !(OB_TYPE_MOVE_BLOCK (env, pos->move_block))) 2270 if (pos.normalise () && !(OB_TYPE_MOVE_BLOCK (env, pos->move_block)))
2250 { 2271 {
2251 hit_map (aura, i, aura->attacktype, 0); 2272 hit_map (aura, i, aura->attacktype, 0);
2252 2273
2253 if (aura->other_arch) 2274 if (aura->other_arch)
2254 pos.insert (arch_to_object (aura->other_arch), aura); 2275 pos.insert (aura->other_arch->instance (), aura);
2255 } 2276 }
2256 } 2277 }
2257 2278
2258 /* put the aura back in the player's inventory */ 2279 /* put the aura back in the player's inventory */
2259 env->insert (aura); 2280 env->insert (aura);
2269 for (object *tmp = op->ms ().bot; tmp; tmp = tmp->above) 2290 for (object *tmp = op->ms ().bot; tmp; tmp = tmp->above)
2270 { 2291 {
2271 int atk_lev, def_lev; 2292 int atk_lev, def_lev;
2272 object *victim = tmp->head_ (); 2293 object *victim = tmp->head_ ();
2273 2294
2274 if (!QUERY_FLAG (victim, FLAG_MONSTER)) 2295 if (!victim->flag [FLAG_MONSTER])
2275 continue; 2296 continue;
2276 2297
2277 if (QUERY_FLAG (victim, FLAG_UNAGGRESSIVE)) 2298 if (victim->flag [FLAG_UNAGGRESSIVE])
2278 continue; 2299 continue;
2279 2300
2280 if (victim->stats.exp == 0) 2301 if (victim->stats.exp == 0)
2281 continue; 2302 continue;
2282 2303
2298 victim->stats.sp = 0; 2319 victim->stats.sp = 0;
2299 victim->stats.grace = 0; 2320 victim->stats.grace = 0;
2300 victim->stats.Pow = 0; 2321 victim->stats.Pow = 0;
2301#endif 2322#endif
2302 victim->attack_movement = RANDO2; 2323 victim->attack_movement = RANDO2;
2303 SET_FLAG (victim, FLAG_UNAGGRESSIVE); 2324 victim->set_flag (FLAG_UNAGGRESSIVE);
2304 SET_FLAG (victim, FLAG_RUN_AWAY); 2325 victim->set_flag (FLAG_RUN_AWAY);
2305 SET_FLAG (victim, FLAG_RANDOM_MOVE); 2326 victim->set_flag (FLAG_RANDOM_MOVE);
2306 CLEAR_FLAG (victim, FLAG_MONSTER); 2327 victim->clr_flag (FLAG_MONSTER);
2307 2328
2308 if (victim->name) 2329 if (victim->name)
2309 new_draw_info_format (NDI_UNIQUE, 0, op->owner, "%s no longer feels like fighting.", &victim->name); 2330 new_draw_info_format (NDI_UNIQUE, 0, op->owner, "%s no longer feels like fighting.", &victim->name);
2310 } 2331 }
2311 } 2332 }
2317int 2338int
2318write_mark (object *op, object *spell, const char *msg) 2339write_mark (object *op, object *spell, const char *msg)
2319{ 2340{
2320 if (!msg || msg[0] == 0) 2341 if (!msg || msg[0] == 0)
2321 { 2342 {
2322 new_draw_info (NDI_UNIQUE, 0, op, "Write what?"); 2343 op->failmsg ("Write what?");
2323 return 0; 2344 return 0;
2324 } 2345 }
2325 2346
2326 if (!msg_is_safe (msg)) 2347 if (!msg_is_safe (msg))
2327 { 2348 {
2328 new_draw_info (NDI_UNIQUE, 0, op, "Trying to cheat are we?"); 2349 op->failmsg ("Trying to cheat are we? H<@-signs are not allowed in marking runes.>");
2329 LOG (llevInfo, "write_mark: player %s tried to write bogus rune %s\n", &op->name, msg); 2350 LOG (llevInfo, "write_mark: player %s tried to write bogus rune %s\n", &op->name, msg);
2330 return 0; 2351 return 0;
2331 } 2352 }
2332 2353
2333 if (!spell->other_arch) 2354 if (!spell->other_arch)
2334 return 0; 2355 return 0;
2335 2356
2336 object *tmp = arch_to_object (spell->other_arch); 2357 object *tmp = spell->other_arch->instance ();
2337 2358
2338 tmp->race = op->name; /*Save the owner of the rune */ 2359 tmp->race = op->name; /*Save the owner of the rune */
2339 tmp->msg = msg; 2360 tmp->msg = msg;
2340 2361
2341 tmp->insert_at (op, op, INS_BELOW_ORIGINATOR); 2362 tmp->insert_at (op, op, INS_BELOW_ORIGINATOR);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines