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.64 by root, Thu Jul 26 00:27:09 2007 UTC vs.
Revision 1.99 by elmex, Tue Jan 13 13:29:57 2009 UTC

1/* 1/*
2 * This file is part of Crossfire TRT, the Roguelike Realtime MORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team 4 * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 * 7 *
8 * Crossfire TRT is free software: you can redistribute it and/or modify 8 * Deliantra is free software: you can redistribute it and/or modify
9 * 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
10 * the Free Software Foundation, either version 3 of the License, or 10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version. 11 * (at your option) any later version.
12 * 12 *
13 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * 20 *
21 * The authors can be reached via e-mail to <crossfire@schmorp.de> 21 * The authors can be reached via e-mail to <support@deliantra.net>
22 */ 22 */
23 23
24#include <global.h> 24#include <global.h>
25#include <object.h> 25#include <object.h>
26#include <living.h> 26#include <living.h>
61{ 61{
62 object *wand, *tmp; 62 object *wand, *tmp;
63 int ncharges; 63 int ncharges;
64 64
65 wand = find_marked_object (op); 65 wand = find_marked_object (op);
66 if (wand == NULL || wand->type != WAND) 66 if (!wand || wand->type != WAND)
67 { 67 {
68 new_draw_info (NDI_UNIQUE, 0, op, "You need to mark the wand you want to recharge."); 68 new_draw_info (NDI_UNIQUE, 0, op, "You need to mark the wand you want to recharge.");
69 return 0; 69 return 0;
70 } 70 }
71 if (!(random_roll (0, 3, op, PREFER_HIGH))) 71 if (!(random_roll (0, 3, op, PREFER_HIGH)))
72 { 72 {
73 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s vibrates violently, then explodes!", query_name (wand)); 73 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s vibrates violently, then explodes!", query_name (wand));
74 op->play_sound (sound_find ("ob_explode")); 74 op->play_sound (sound_find ("ob_explode"));
75 esrv_del_item (op->contr, wand->count);
76 wand->destroy (); 75 wand->destroy ();
77 tmp = get_archetype ("fireball"); 76 tmp = get_archetype ("fireball");
78 tmp->stats.dam = (spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob)) / 10; 77 tmp->stats.dam = (spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob)) / 10;
79 78
80 if (!tmp->stats.dam) 79 if (!tmp->stats.dam)
122 * great a plus, the default is used. 121 * great a plus, the default is used.
123 * The # of arrows created also goes up with level, so if a 30th level mage 122 * The # of arrows created also goes up with level, so if a 30th level mage
124 * wants LOTS of arrows, and doesn't care what the plus is he could 123 * wants LOTS of arrows, and doesn't care what the plus is he could
125 * create nonnmagic arrows, or even -1, etc... 124 * create nonnmagic arrows, or even -1, etc...
126 */ 125 */
127
128int 126int
129cast_create_missile (object *op, object *caster, object *spell, int dir, const char *stringarg) 127cast_create_missile (object *op, object *caster, object *spell, int dir, const char *stringarg)
130{ 128{
131 int missile_plus = 0, bonus_plus = 0; 129 int bonus_plus = 0;
132 const char *missile_name; 130 const char *missile_name = "arrow";
133 object *tmp, *missile;
134 131
135 missile_name = "arrow";
136
137 for (tmp = op->inv; tmp != NULL; tmp = tmp->below) 132 for (object *tmp = op->inv; tmp; tmp = tmp->below)
138 if (tmp->type == BOW && QUERY_FLAG (tmp, FLAG_APPLIED)) 133 if (tmp->type == BOW && QUERY_FLAG (tmp, FLAG_APPLIED))
139 missile_name = tmp->race; 134 missile_name = tmp->race;
140 135
141 missile_plus = spell->stats.dam + SP_level_dam_adjust (caster, spell); 136 int missile_plus = spell->stats.dam + SP_level_dam_adjust (caster, spell);
142 137
143 if (archetype::find (missile_name) == NULL) 138 archetype *missile_arch = archetype::find (missile_name);
139
140 if (!missile_arch)
144 { 141 {
145 LOG (llevDebug, "Cast create_missile: could not find archetype %s\n", missile_name); 142 LOG (llevDebug, "Cast create_missile: could not find archetype %s\n", missile_name);
146 return 0; 143 return 0;
147 } 144 }
148 145
149 missile = get_archetype (missile_name); 146 object *missile = missile_arch->instance ();
150 147
151 if (stringarg) 148 if (stringarg)
152 { 149 {
153 /* If it starts with a letter, presume it is a description */ 150 /* If it starts with a letter, presume it is a description */
154 if (isalpha (*stringarg)) 151 if (isalpha (*stringarg))
172 new_draw_info_format (NDI_UNIQUE, 0, op, "You are not allowed to create %ss of %s", missile_name, stringarg); 169 new_draw_info_format (NDI_UNIQUE, 0, op, "You are not allowed to create %ss of %s", missile_name, stringarg);
173 return 0; 170 return 0;
174 } 171 }
175 172
176 give_artifact_abilities (missile, al->item); 173 give_artifact_abilities (missile, al->item);
177 /* These special arrows cost something extra. Don't have them also be magical - 174 /* These special arrows cost something extra. Don't have them also be magical -
178 * otherwise, in most cases, not enough will be created. I don't want to get into 175 * otherwise, in most cases, not enough will be created. I don't want to get into
179 * the parsing of having to do both plus and type. 176 * the parsing of having to do both plus and type.
180 */ 177 */
181 bonus_plus = 1 + (al->item->value / 5); 178 bonus_plus = 1 + (al->item->value / 5);
182 missile_plus = 0; 179 missile_plus = 0;
183 } 180 }
184 else if (atoi (stringarg) < missile_plus) 181 else if (atoi (stringarg) < missile_plus)
185 missile_plus = atoi (stringarg); 182 missile_plus = atoi (stringarg);
186 } 183 }
187 184
188 if (missile_plus > 4) 185 missile_plus = clamp (missile_plus, -4, 4);
189 missile_plus = 4;
190 else if (missile_plus < -4)
191 missile_plus = -4;
192 186
193 missile->nrof = spell->duration + SP_level_duration_adjust (caster, spell); 187 missile->nrof = spell->duration + SP_level_duration_adjust (caster, spell);
194 missile->nrof -= 3 * (missile_plus + bonus_plus); 188 missile->nrof -= 3 * (missile_plus + bonus_plus);
195 189
196 if (missile->nrof < 1) 190 if (missile->nrof < 1)
216{ 210{
217 int food_value; 211 int food_value;
218 archetype *at = NULL; 212 archetype *at = NULL;
219 object *new_op; 213 object *new_op;
220 214
221 food_value = spell_ob->stats.food + +50 * SP_level_duration_adjust (caster, spell_ob); 215 food_value = spell_ob->stats.food + 50 * SP_level_duration_adjust (caster, spell_ob);
222 216
223 if (stringarg) 217 if (stringarg)
224 { 218 {
225 at = find_archetype_by_object_type_name (FOOD, stringarg); 219 at = find_archetype_by_object_type_name (FOOD, stringarg);
226 if (at == NULL) 220 if (at == NULL)
256 && at_tmp->weight < at->weight))) 250 && at_tmp->weight < at->weight)))
257 at = at_tmp; 251 at = at_tmp;
258 } 252 }
259 } 253 }
260 } 254 }
255
261 /* Pretty unlikely (there are some very low food items), but you never 256 /* Pretty unlikely (there are some very low food items), but you never
262 * know 257 * know
263 */ 258 */
264 if (!at) 259 if (!at)
265 { 260 {
284{ 279{
285 int r, mflags, maxrange; 280 int r, mflags, maxrange;
286 object *tmp; 281 object *tmp;
287 maptile *m; 282 maptile *m;
288 283
289
290 if (!dir) 284 if (!dir)
291 { 285 {
292 examine_monster (op, op); 286 examine_monster (op, op);
293 return 1; 287 return 1;
294 } 288 }
289
295 maxrange = spell_ob->range + SP_level_range_adjust (caster, spell_ob); 290 maxrange = spell_ob->range + SP_level_range_adjust (caster, spell_ob);
296 for (r = 1; r < maxrange; r++) 291 for (r = 1; r < maxrange; r++)
297 { 292 {
298 sint16 x = op->x + r * freearr_x[dir], y = op->y + r * freearr_y[dir]; 293 sint16 x = op->x + r * freearr_x[dir], y = op->y + r * freearr_y[dir];
299 294
306 if (!QUERY_FLAG (op, FLAG_WIZCAST) && (mflags & P_NO_MAGIC)) 301 if (!QUERY_FLAG (op, FLAG_WIZCAST) && (mflags & P_NO_MAGIC))
307 { 302 {
308 new_draw_info (NDI_UNIQUE, 0, op, "Something blocks your magic."); 303 new_draw_info (NDI_UNIQUE, 0, op, "Something blocks your magic.");
309 return 0; 304 return 0;
310 } 305 }
306
311 if (mflags & P_IS_ALIVE) 307 if (mflags & P_IS_ALIVE)
312 { 308 {
313 for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = tmp->above) 309 for (tmp = GET_MAP_OB (m, x, y); tmp; tmp = tmp->above)
314 if (QUERY_FLAG (tmp, FLAG_ALIVE) && (tmp->type == PLAYER || QUERY_FLAG (tmp, FLAG_MONSTER))) 310 if (QUERY_FLAG (tmp, FLAG_ALIVE) && (tmp->type == PLAYER || QUERY_FLAG (tmp, FLAG_MONSTER)))
315 { 311 {
316 new_draw_info (NDI_UNIQUE, 0, op, "You detect something."); 312 new_draw_info (NDI_UNIQUE, 0, op, "You detect something.");
317 if (tmp->head != NULL) 313 if (tmp->head != NULL)
318 tmp = tmp->head; 314 tmp = tmp->head;
319 examine_monster (op, tmp); 315 examine_monster (op, tmp);
320 return 1; 316 return 1;
321 } 317 }
322 } 318 }
323 } 319 }
320
324 new_draw_info (NDI_UNIQUE, 0, op, "You detect nothing."); 321 new_draw_info (NDI_UNIQUE, 0, op, "You detect nothing.");
325 return 1; 322 return 1;
326} 323}
327
328 324
329/* This checks to see if 'pl' is invisible to 'mon'. 325/* This checks to see if 'pl' is invisible to 'mon'.
330 * does race check, undead check, etc 326 * does race check, undead check, etc
331 * Returns TRUE if mon can't see pl, false 327 * Returns TRUE if mon can't see pl, false
332 * otherwise. This doesn't check range, walls, etc. It 328 * otherwise. This doesn't check range, walls, etc. It
334 * pl is invisible. 330 * pl is invisible.
335 */ 331 */
336int 332int
337makes_invisible_to (object *pl, object *mon) 333makes_invisible_to (object *pl, object *mon)
338{ 334{
339
340 if (!pl->invisible) 335 if (!pl->invisible)
341 return 0; 336 return 0;
337
342 if (pl->type == PLAYER) 338 if (pl->type == PLAYER)
343 { 339 {
344 /* If race isn't set, then invisible unless it is undead */ 340 /* If race isn't set, then invisible unless it is undead */
345 if (!pl->contr->invis_race) 341 if (!pl->contr->invis_race)
346 { 342 {
347 if (QUERY_FLAG (mon, FLAG_UNDEAD)) 343 if (QUERY_FLAG (mon, FLAG_UNDEAD))
348 return 0; 344 return 0;
345
349 return 1; 346 return 1;
350 } 347 }
348
351 /* invis_race is set if we get here */ 349 /* invis_race is set if we get here */
352 if (!strcmp (pl->contr->invis_race, "undead") && is_true_undead (mon)) 350 if (pl->contr->invis_race == shstr_undead && is_true_undead (mon))
353 return 1; 351 return 1;
352
354 /* No race, can't be invisible to it */ 353 /* No race, can't be invisible to it */
355 if (!mon->race) 354 if (!mon->race)
356 return 0; 355 return 0;
356
357 if (strstr (mon->race, pl->contr->invis_race)) 357 if (mon->race.contains (pl->contr->invis_race))
358 return 1; 358 return 1;
359
359 /* Nothing matched above, return 0 */ 360 /* Nothing matched above, return 0 */
360 return 0; 361 return 0;
361 } 362 }
362 else 363 else
363 { 364 {
465 if (object *pl = op->in_player ()) 466 if (object *pl = op->in_player ())
466 { 467 {
467 if (pl->ms ().flags () & P_NO_CLERIC && !QUERY_FLAG (pl, FLAG_WIZCAST)) 468 if (pl->ms ().flags () & P_NO_CLERIC && !QUERY_FLAG (pl, FLAG_WIZCAST))
468 new_draw_info (NDI_UNIQUE, 0, pl, "You feel something fizzle inside you."); 469 new_draw_info (NDI_UNIQUE, 0, pl, "You feel something fizzle inside you.");
469 else 470 else
470 { 471 pl->player_goto (op->slaying, op->stats.hp, op->stats.sp);
471 // remove first so we do not call update_stats
472 op->remove ();
473 pl->enter_exit (op);
474 }
475 } 472 }
476 473
477 op->destroy (); 474 op->destroy ();
478} 475}
479 476
495 new_draw_info (NDI_UNIQUE, 0, op, "You feel a force starting to build up inside you."); 492 new_draw_info (NDI_UNIQUE, 0, op, "You feel a force starting to build up inside you.");
496 return 1; 493 return 1;
497 } 494 }
498 495
499 dummy = get_archetype (FORCE_NAME); 496 dummy = get_archetype (FORCE_NAME);
500 if (dummy == NULL) 497
498 if (!dummy)
501 { 499 {
502 new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); 500 new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!");
503 LOG (llevError, "cast_word_of_recall: get_archetype(force) failed!\n"); 501 LOG (llevError, "cast_word_of_recall: get_archetype(force) failed!\n");
504 return 0; 502 return 0;
505 } 503 }
575 573
576 dynbuf_text buf; 574 dynbuf_text buf;
577 575
578 if (player *pl = op->contr) 576 if (player *pl = op->contr)
579 if (object *race = archetype::find (op->race)) 577 if (object *race = archetype::find (op->race))
580 buf << "You are a " << (pl->gender ? "female" : "male") << " " << &race->name << ".\n"; 578 buf << " - You are a G<male|female> " << &race->name << ".\n";
581 579
582 if (object *god = find_god (determine_god (op))) 580 if (object *god = find_god (determine_god (op)))
583 buf << "You worship " << &god->name << ".\n"; 581 buf << " - You worship " << &god->name << ".\n";
584 else 582 else
585 buf << "You worship no god.\n"; 583 buf << " - You worship no god.\n";
586 584
587 object *tmp = present_arch_in_ob (at, op); 585 object *tmp = present_arch_in_ob (at, op);
588 586
589 if (*cp == '\0' && tmp == NULL) 587 if (*cp == '\0' && !tmp)
590 buf << "You feel very mundane. "; 588 buf << " - You feel very mundane. ";
591 else 589 else
592 { 590 {
593 buf << "You have: " << cp << ".\n"; 591 buf << " - You have: " << cp << ".\n";
594 592
595 if (tmp) 593 if (tmp)
596 for (int i = 0; i < NUM_STATS; i++) 594 for (int i = 0; i < NUM_STATS; i++)
597 if (tmp->stats.stat (i) < 0) 595 if (tmp->stats.stat (i) < 0)
598 buf.printf ("Your %s is depleted by %d.\n", statname[i], -tmp->stats.stat (i)); 596 buf.printf (" - Your %s is depleted by %d.\n", statname[i], -tmp->stats.stat (i));
599 } 597 }
600 598
601 if (is_dragon_pl (op)) 599 if (is_dragon_pl (op))
602 /* now grab the 'dragon_ability'-force from the player's inventory */ 600 /* now grab the 'dragon_ability'-force from the player's inventory */
603 for (tmp = op->inv; tmp; tmp = tmp->below) 601 for (tmp = op->inv; tmp; tmp = tmp->below)
604 { 602 {
605 if (tmp->type == FORCE && !strcmp (tmp->arch->archname, "dragon_ability_force")) 603 if (tmp->type == FORCE && tmp->arch->archname == shstr_dragon_ability_force)
606 { 604 {
607 if (tmp->stats.exp == 0) 605 if (tmp->stats.exp == 0)
608 buf << "Your metabolism isn't focused on anything.\n"; 606 buf << " - Your metabolism isn't focused on anything.\n";
609 else 607 else
610 buf << "Your metabolism is focused on " << change_resist_msg[tmp->stats.exp] << ".\n"; 608 buf << " - Your metabolism is focused on " << change_resist_msg[tmp->stats.exp] << ".\n";
611 609
612 break; 610 break;
613 } 611 }
614 } 612 }
615 613
711 */ 709 */
712 if (tmp->type != EARTHWALL) //TODO 710 if (tmp->type != EARTHWALL) //TODO
713 tmp->set_owner (op); 711 tmp->set_owner (op);
714 712
715 set_spell_skill (op, caster, spell_ob, tmp); 713 set_spell_skill (op, caster, spell_ob, tmp);
716 tmp->level = caster_level (caster, spell_ob) / 2; 714 tmp->level = casting_level (caster, spell_ob) / 2;
717 715
718 name = tmp->name; 716 name = tmp->name;
719 if (!(tmp = m->insert (tmp, x, y, op))) 717 if (!(tmp = m->insert (tmp, x, y, op)))
720 { 718 {
721 new_draw_info_format (NDI_UNIQUE, 0, op, "Something destroys your %s", name); 719 new_draw_info_format (NDI_UNIQUE, 0, op, "Something destroys your %s", name);
894 892
895 op->speed_left = -FABS (op->speed) * 5; /* Freeze them for a short while */ 893 op->speed_left = -FABS (op->speed) * 5; /* Freeze them for a short while */
896 return 1; 894 return 1;
897} 895}
898 896
899
900/* cast_heal: Heals something. 897/* cast_heal: Heals something.
901 * op is the caster. 898 * op is the caster.
902 * dir is the direction he is casting it in. 899 * dir is the direction he is casting it in.
903 * spell is the spell object. 900 * spell is the spell object.
904 */ 901 */
930 { 927 {
931 /* See how many points we actually heal. Instead of messages 928 /* See how many points we actually heal. Instead of messages
932 * based on type of spell, we instead do messages based 929 * based on type of spell, we instead do messages based
933 * on amount of damage healed. 930 * on amount of damage healed.
934 */ 931 */
935 if (heal > (tmp->stats.maxhp - tmp->stats.hp)) 932 if (heal > tmp->stats.maxhp - tmp->stats.hp)
936 heal = tmp->stats.maxhp - tmp->stats.hp; 933 heal = tmp->stats.maxhp - tmp->stats.hp;
934
937 tmp->stats.hp += heal; 935 tmp->stats.hp += heal;
938 936
939 if (tmp->stats.hp >= tmp->stats.maxhp) 937 if (tmp->stats.hp >= tmp->stats.maxhp)
940 new_draw_info (NDI_UNIQUE, 0, tmp, "You feel just fine!"); 938 new_draw_info (NDI_UNIQUE, 0, tmp, "You feel just fine!");
941 else if (heal > 50) 939 else if (heal > 50)
950 success = 1; 948 success = 1;
951 } 949 }
952 } 950 }
953 951
954 if (spell->attacktype & AT_DISEASE) 952 if (spell->attacktype & AT_DISEASE)
955 if (cure_disease (tmp, op)) 953 if (cure_disease (tmp, op, spell))
956 success = 1; 954 success = 1;
957 955
958 if (spell->attacktype & AT_POISON) 956 if (spell->attacktype & AT_POISON)
959 { 957 {
960 at = archetype::find ("poisoning"); 958 at = archetype::find ("poisoning");
1009 } 1007 }
1010 1008
1011 if (spell->stats.food && tmp->stats.food < 999) 1009 if (spell->stats.food && tmp->stats.food < 999)
1012 { 1010 {
1013 tmp->stats.food += spell->stats.food; 1011 tmp->stats.food += spell->stats.food;
1012
1014 if (tmp->stats.food > 999) 1013 if (tmp->stats.food > 999)
1015 tmp->stats.food = 999; 1014 tmp->stats.food = 999;
1015
1016 success = 1; 1016 success = 1;
1017 /* We could do something a bit better like the messages for healing above */ 1017 /* We could do something a bit better like the messages for healing above */
1018 new_draw_info (NDI_UNIQUE, 0, tmp, "You feel your belly fill with food"); 1018 new_draw_info (NDI_UNIQUE, 0, tmp, "You feel your belly fill with food");
1019 } 1019 }
1020 1020
1036}; 1036};
1037 1037
1038int 1038int
1039cast_change_ability (object *op, object *caster, object *spell_ob, int dir, int silent) 1039cast_change_ability (object *op, object *caster, object *spell_ob, int dir, int silent)
1040{ 1040{
1041 object *force = NULL; 1041 object *force = 0;
1042 int i; 1042 int i;
1043 1043
1044 /* if dir = 99 op defaults to tmp, eat_special_food() requires this. */ 1044 /* if dir = 99 op defaults to tmp, eat_special_food() requires this. */
1045 object *tmp = dir 1045 object *tmp = dir
1046 ? find_target_for_friendly_spell (op, dir) 1046 ? find_target_for_friendly_spell (op, dir)
1047 : op; 1047 : op;
1048 1048
1049 if (!tmp) 1049 if (!tmp)
1050 return 0; 1050 return 0;
1051 1051
1052 /* If we've already got a force of this type, don't add a new one. */ 1052 /* If we've already got a force of this type, don't add a new one. */
1061 } 1061 }
1062 else if (spell_ob->race && spell_ob->race == tmp2->name) 1062 else if (spell_ob->race && spell_ob->race == tmp2->name)
1063 { 1063 {
1064 if (!silent) 1064 if (!silent)
1065 new_draw_info_format (NDI_UNIQUE, 0, op, "You can not cast %s while %s is in effect", &spell_ob->name, &tmp2->name_pl); 1065 new_draw_info_format (NDI_UNIQUE, 0, op, "You can not cast %s while %s is in effect", &spell_ob->name, &tmp2->name_pl);
1066
1066 return 0; 1067 return 0;
1067 } 1068 }
1068 } 1069 }
1069 } 1070 }
1070 if (force == NULL) 1071
1072 if (!force)
1071 { 1073 {
1072 force = get_archetype (FORCE_NAME); 1074 force = get_archetype (FORCE_NAME);
1073 force->subtype = FORCE_CHANGE_ABILITY; 1075 force->subtype = FORCE_CHANGE_ABILITY;
1076
1074 if (spell_ob->race) 1077 if (spell_ob->race)
1075 force->name = spell_ob->race; 1078 force->name = spell_ob->race;
1076 else 1079 else
1077 force->name = spell_ob->name; 1080 force->name = spell_ob->name;
1081
1078 force->name_pl = spell_ob->name; 1082 force->name_pl = spell_ob->name;
1079 new_draw_info (NDI_UNIQUE, 0, op, "You create an aura of magical force."); 1083 new_draw_info (NDI_UNIQUE, 0, op, "You create an aura of magical force.");
1080 1084
1081 } 1085 }
1082 else 1086 else
1088 { 1092 {
1089 force->duration = duration; 1093 force->duration = duration;
1090 new_draw_info (NDI_UNIQUE, 0, op, "You recast the spell while in effect."); 1094 new_draw_info (NDI_UNIQUE, 0, op, "You recast the spell while in effect.");
1091 } 1095 }
1092 else 1096 else
1093 {
1094 new_draw_info (NDI_UNIQUE, 0, op, "Recasting the spell had no effect."); 1097 new_draw_info (NDI_UNIQUE, 0, op, "Recasting the spell had no effect.");
1095 }
1096 1098
1097 return 1; 1099 return 1;
1098 } 1100 }
1099 1101
1100 force->duration = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob) * 50; 1102 force->duration = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob) * 50;
1172 */ 1174 */
1173int 1175int
1174cast_bless (object *op, object *caster, object *spell_ob, int dir) 1176cast_bless (object *op, object *caster, object *spell_ob, int dir)
1175{ 1177{
1176 int i; 1178 int i;
1177 object *god = find_god (determine_god (op)), *tmp2, *force = NULL, *tmp; 1179 object *god = find_god (determine_god (op)), *force = NULL, *tmp;
1178 1180
1179 /* if dir = 99 op defaults to tmp, eat_special_food() requires this. */ 1181 /* if dir = 99 op defaults to tmp, eat_special_food() requires this. */
1180 if (dir != 0) 1182 if (dir != 0)
1181 { 1183 {
1182 tmp = find_target_for_friendly_spell (op, dir); 1184 tmp = find_target_for_friendly_spell (op, dir);
1185
1186 if (!tmp)
1187 return 0;
1183 } 1188 }
1184 else 1189 else
1185 {
1186 tmp = op; 1190 tmp = op;
1187 }
1188 1191
1189 /* If we've already got a force of this type, don't add a new one. */ 1192 /* If we've already got a force of this type, don't add a new one. */
1190 for (tmp2 = tmp->inv; tmp2 != NULL; tmp2 = tmp2->below) 1193 for (object *tmp2 = tmp->inv; tmp2; tmp2 = tmp2->below)
1191 { 1194 {
1192 if (tmp2->type == FORCE && tmp2->subtype == FORCE_CHANGE_ABILITY) 1195 if (tmp2->type == FORCE && tmp2->subtype == FORCE_CHANGE_ABILITY)
1193 { 1196 {
1194 if (tmp2->name == spell_ob->name) 1197 if (tmp2->name == spell_ob->name)
1195 { 1198 {
1201 new_draw_info_format (NDI_UNIQUE, 0, op, "You can not cast %s while %s is in effect", &spell_ob->name, &tmp2->name_pl); 1204 new_draw_info_format (NDI_UNIQUE, 0, op, "You can not cast %s while %s is in effect", &spell_ob->name, &tmp2->name_pl);
1202 return 0; 1205 return 0;
1203 } 1206 }
1204 } 1207 }
1205 } 1208 }
1209
1206 if (force == NULL) 1210 if (force == NULL)
1207 { 1211 {
1208 force = get_archetype (FORCE_NAME); 1212 force = get_archetype (FORCE_NAME);
1209 force->subtype = FORCE_CHANGE_ABILITY; 1213 force->subtype = FORCE_CHANGE_ABILITY;
1210 if (spell_ob->race) 1214 if (spell_ob->race)
1275} 1279}
1276 1280
1277/* Alchemy code by Mark Wedel 1281/* Alchemy code by Mark Wedel
1278 * 1282 *
1279 * This code adds a new spell, called alchemy. Alchemy will turn 1283 * This code adds a new spell, called alchemy. Alchemy will turn
1280 * objects to gold nuggets, the value of the gold nuggets being 1284 * objects to pyrite ("false gold"), henceforth called gold nuggets.
1281 * about 90% of that of the item itself. It uses the value of the
1282 * object before charisma adjustments, because the nuggets themselves
1283 * will be will be adjusted by charisma when sold.
1284 * 1285 *
1285 * Large nuggets are worth 25 gp each (base). You will always get 1286 * The value of the gold nuggets being about 90% of that of the item
1286 * the maximum number of large nuggets you could get. 1287 * itself. It uses the value of the object before charisma adjustments,
1287 * Small nuggets are worth 1 gp each (base). You will get from 0 1288 * because the nuggets themselves will be will be adjusted by charisma
1288 * to the max amount of small nuggets as you could get. 1289 * when sold.
1289 *
1290 * For example, if an item is worth 110 gold, you will get
1291 * 4 large nuggets, and from 0-10 small nuggets.
1292 * 1290 *
1293 * There is also a chance (1:30) that you will get nothing at all 1291 * There is also a chance (1:30) that you will get nothing at all
1294 * for the object. There is also a maximum weight that will be 1292 * for the object. There is also a maximum weight that will be
1295 * alchemised. 1293 * alchemised.
1296 */ 1294 */
1297static void 1295static void
1298alchemy_object (object *obj, uint64 &total_value, int &total_weight) 1296alchemy_object (object *obj, uint64 &total_value, int &total_weight)
1299{ 1297{
1300 uint64 value = query_cost (obj, NULL, F_TRUE); 1298 uint64 value = query_cost (obj, NULL, F_TRUE);
1301 1299
1302 /* Give third price when we alchemy money (This should hopefully 1300 /* Give third price when we alchemy money (this should hopefully
1303 * make it so that it isn't worth it to alchemy money, sell 1301 * make it so that it isn't worth it to alchemy money, sell
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.
1319 total_weight += obj->total_weight (); 1317 total_weight += obj->total_weight ();
1320 1318
1321 obj->destroy (); 1319 obj->destroy ();
1322} 1320}
1323 1321
1324static void
1325update_map (object *op, maptile *m, int small_nuggets, object *small, int large_nuggets, object *large, int x, int y)
1326{
1327 int flag = 0;
1328
1329 /* Put any nuggets below the player, but we can only pass this
1330 * flag if we are on the same space as the player
1331 */
1332 if (x == op->x && y == op->y && op->map == m)
1333 flag = INS_BELOW_ORIGINATOR;
1334
1335 if (small_nuggets)
1336 {
1337 object *tmp = small->clone ();
1338 tmp->nrof = small_nuggets;
1339 m->insert (tmp, x, y, op, flag);
1340 }
1341
1342 if (large_nuggets)
1343 {
1344 object *tmp = large->clone ();
1345 tmp->nrof = large_nuggets;
1346 m->insert (tmp, x, y, op, flag);
1347 }
1348
1349 if (object *pl = m->at (x, y).player ())
1350 if (pl->contr->ns)
1351 pl->contr->ns->look_position = 0;
1352}
1353
1354int 1322int
1355alchemy (object *op, object *caster, object *spell_ob) 1323alchemy (object *op, object *caster, object *spell_ob)
1356{ 1324{
1357 if (op->type != PLAYER) 1325 if (op->type != PLAYER)
1358 return 0; 1326 return 0;
1359 1327
1360 object *large = get_archetype ("largenugget"); 1328 archetype *nugget[3];
1361 object *small = get_archetype ("smallnugget"); 1329
1330 nugget[0] = archetype::find ("pyrite3");
1331 nugget[1] = archetype::find ("pyrite2");
1332 nugget[2] = archetype::find ("pyrite");
1362 1333
1363 /* Put a maximum weight of items that can be alchemised. Limits the power 1334 /* Put a maximum weight of items that can be alchemised. Limits the power
1364 * some, and also prevents people from alchemising every table/chair/clock 1335 * some, and also prevents people from alchemising every table/chair/clock
1365 * in sight 1336 * in sight
1366 */ 1337 */
1418 if (weight > weight_max) 1389 if (weight > weight_max)
1419 break; 1390 break;
1420 } 1391 }
1421 } 1392 }
1422 1393
1394 value -= rndm (value >> 4);
1423 value = min (value, value_max); 1395 value = min (value, value_max);
1424 1396
1425 uint64 count = value / large->value; 1397 for (int i = 0; i < sizeof (nugget) / sizeof (nugget [0]); ++i)
1426 int large_nuggets = count; 1398 if (int nrof = value / nugget [i]->value)
1427 value -= count * large->value;
1428
1429 count = value / small->value;
1430 int small_nuggets = count;
1431
1432 /* Insert all the nuggets at one time. This probably saves time, but
1433 * it also prevents us from alcheming nuggets that were just created
1434 * with this spell.
1435 */ 1399 {
1436 update_map (op, mp, small_nuggets, small, large_nuggets, large, nx, ny); 1400 value -= nrof * nugget[i]->value;
1401
1402 object *tmp = arch_to_object (nugget[i]);
1403 tmp->nrof = nrof;
1404 tmp->flag [FLAG_IDENTIFIED] = true;
1405 op->map->insert (tmp, x, y, op, 0);
1406 }
1437 1407
1438 if (weight > weight_max) 1408 if (weight > weight_max)
1439 goto bailout; 1409 goto bailout;
1440 } 1410 }
1441 } 1411 }
1442 1412
1443bailout: 1413bailout:
1444 large->destroy ();
1445 small->destroy ();
1446 return 1; 1414 return 1;
1447} 1415}
1448
1449 1416
1450/* This function removes the cursed/damned status on equipped 1417/* This function removes the cursed/damned status on equipped
1451 * items. 1418 * items.
1452 */ 1419 */
1453int 1420int
1460 if (QUERY_FLAG (tmp, FLAG_APPLIED) && 1427 if (QUERY_FLAG (tmp, FLAG_APPLIED) &&
1461 ((QUERY_FLAG (tmp, FLAG_CURSED) && QUERY_FLAG (spell, FLAG_CURSED)) || 1428 ((QUERY_FLAG (tmp, FLAG_CURSED) && QUERY_FLAG (spell, FLAG_CURSED)) ||
1462 (QUERY_FLAG (tmp, FLAG_DAMNED) && QUERY_FLAG (spell, FLAG_DAMNED)))) 1429 (QUERY_FLAG (tmp, FLAG_DAMNED) && QUERY_FLAG (spell, FLAG_DAMNED))))
1463 { 1430 {
1464 was_one++; 1431 was_one++;
1432
1465 if (tmp->level <= caster_level (caster, spell)) 1433 if (tmp->level <= casting_level (caster, spell))
1466 { 1434 {
1467 success++; 1435 success++;
1468 if (QUERY_FLAG (spell, FLAG_DAMNED)) 1436 if (QUERY_FLAG (spell, FLAG_DAMNED))
1469 CLEAR_FLAG (tmp, FLAG_DAMNED); 1437 CLEAR_FLAG (tmp, FLAG_DAMNED);
1470 1438
1471 CLEAR_FLAG (tmp, FLAG_CURSED); 1439 CLEAR_FLAG (tmp, FLAG_CURSED);
1472 CLEAR_FLAG (tmp, FLAG_KNOWN_CURSED); 1440 CLEAR_FLAG (tmp, FLAG_KNOWN_CURSED);
1473 tmp->value = 0; /* Still can't sell it */ 1441 tmp->value = 0; /* Still can't sell it */
1474 if (op->type == PLAYER) 1442
1443 if (object *pl = tmp->visible_to ())
1475 esrv_send_item (op, tmp); 1444 esrv_update_item (UPD_FLAGS, pl, tmp);
1476 } 1445 }
1477 } 1446 }
1478 1447
1479 if (op->type == PLAYER) 1448 if (op->type == PLAYER)
1480 { 1449 {
1491 1460
1492 return success; 1461 return success;
1493} 1462}
1494 1463
1495/* Identifies objects in the players inventory/on the ground */ 1464/* Identifies objects in the players inventory/on the ground */
1496
1497int 1465int
1498cast_identify (object *op, object *caster, object *spell) 1466cast_identify (object *op, object *caster, object *spell)
1499{ 1467{
1468 dynbuf_text buf;
1500 object *tmp; 1469 object *tmp;
1501 int success = 0, num_ident;
1502 1470
1503 num_ident = spell->stats.dam + SP_level_dam_adjust (caster, spell); 1471 int num_ident = spell->stats.dam + SP_level_dam_adjust (caster, spell);
1504 1472
1505 if (num_ident < 1) 1473 if (num_ident < 1)
1506 num_ident = 1; 1474 num_ident = 1;
1507 1475
1508 for (tmp = op->inv; tmp; tmp = tmp->below) 1476 for (tmp = op->inv; tmp; tmp = tmp->below)
1511 { 1479 {
1512 identify (tmp); 1480 identify (tmp);
1513 1481
1514 if (op->type == PLAYER) 1482 if (op->type == PLAYER)
1515 { 1483 {
1516 new_draw_info_format (NDI_UNIQUE, 0, op, "You identified: %s.", long_desc (tmp, op)); 1484 buf.printf ("You identified: %s.\r", long_desc (tmp, op));
1517 1485
1518 if (tmp->msg) 1486 if (tmp->msg)
1519 { 1487 buf << "The item has a story:\r" << tmp->msg << "\n\n";
1520 new_draw_info (NDI_UNIQUE, 0, op, "The item has a story:");
1521 new_draw_info (NDI_UNIQUE, 0, op, tmp->msg);
1522 }
1523 } 1488 }
1524 1489
1525 num_ident--; 1490 num_ident--;
1526 success = 1;
1527 if (!num_ident) 1491 if (!num_ident)
1528 break; 1492 break;
1529 } 1493 }
1530 } 1494 }
1531 1495
1538 for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp; tmp = tmp->above) 1502 for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp; tmp = tmp->above)
1539 if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED) && !tmp->invisible && need_identify (tmp)) 1503 if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED) && !tmp->invisible && need_identify (tmp))
1540 { 1504 {
1541 identify (tmp); 1505 identify (tmp);
1542 1506
1543 if (op->type == PLAYER) 1507 if (object *pl = tmp->visible_to ())
1544 { 1508 {
1545 new_draw_info_format (NDI_UNIQUE, 0, op, "On the ground you identified: %s.", long_desc (tmp, op)); 1509 buf.printf ("On the ground you identified: %s.\r", long_desc (tmp, op));
1546 1510
1547 if (tmp->msg) 1511 if (tmp->msg)
1548 { 1512 buf << "The item has a story:\r" << tmp->msg << "\n\n";
1549 new_draw_info (NDI_UNIQUE, 0, op, "The item has a story:");
1550 new_draw_info (NDI_UNIQUE, 0, op, tmp->msg);
1551 }
1552
1553 esrv_send_item (op, tmp);
1554 } 1513 }
1555 1514
1556 num_ident--; 1515 num_ident--;
1557 success = 1;
1558 if (!num_ident) 1516 if (!num_ident)
1559 break; 1517 break;
1560 } 1518 }
1561 } 1519 }
1562 1520
1563 if (!success) 1521 if (buf.empty ())
1564 new_draw_info (NDI_UNIQUE, 0, op, "You can't reach anything unidentified."); 1522 {
1523 op->failmsg ("You can't reach anything unidentified.");
1524 return 0;
1525 }
1565 else 1526 else
1527 {
1528 if (op->contr)
1529 op->contr->infobox (MSG_CHANNEL ("identify"), buf);
1530
1566 spell_effect (spell, op->x, op->y, op->map, op); 1531 spell_effect (spell, op->x, op->y, op->map, op);
1567 1532 return 1;
1568 return success; 1533 }
1569} 1534}
1570 1535
1571int 1536int
1572cast_detection (object *op, object *caster, object *spell, object *skill) 1537cast_detection (object *op, object *caster, object *spell, object *skill)
1573{ 1538{
1578 1543
1579 /* We precompute some values here so that we don't have to keep 1544 /* We precompute some values here so that we don't have to keep
1580 * doing it over and over again. 1545 * doing it over and over again.
1581 */ 1546 */
1582 god = find_god (determine_god (op)); 1547 god = find_god (determine_god (op));
1583 level = caster_level (caster, spell); 1548 level = casting_level (caster, spell);
1584 range = spell->range + SP_level_range_adjust (caster, spell); 1549 range = spell->range + SP_level_range_adjust (caster, spell);
1585 1550
1586 if (!skill) 1551 if (!skill)
1587 skill = caster; 1552 skill = caster;
1588 1553
1589 for (x = op->x - range; x <= op->x + range; x++) 1554 unordered_mapwalk (op, -range, -range, range, range)
1590 for (y = op->y - range; y <= op->y + range; y++)
1591 { 1555 {
1592 m = op->map;
1593 mflags = get_map_flags (m, &m, x, y, &nx, &ny);
1594 if (mflags & P_OUT_OF_MAP)
1595 continue;
1596
1597 /* For most of the detections, we only detect objects above the 1556 /* For most of the detections, we only detect objects above the
1598 * floor. But this is not true for show invisible. 1557 * floor. But this is not true for show invisible.
1599 * Basically, we just go and find the top object and work 1558 * Basically, we just go and find the top object and work
1600 * down - that is easier than working up. 1559 * down - that is easier than working up.
1601 */ 1560 */
1602 1561
1603 for (last = NULL, tmp = GET_MAP_OB (m, nx, ny); tmp; tmp = tmp->above) 1562 for (last = NULL, tmp = m->at (nx, ny).bot; tmp; tmp = tmp->above)
1604 last = tmp; 1563 last = tmp;
1605 1564
1606 /* Shouldn't happen, but if there are no objects on a space, this 1565 /* Shouldn't happen, but if there are no objects on a space, this
1607 * would happen. 1566 * would happen.
1608 */ 1567 */
1609 if (!last) 1568 if (!last)
1610 continue; 1569 continue;
1611 1570
1612 done_one = 0; 1571 done_one = 0;
1613 floor = 0; 1572 floor = 0;
1614 detect = NULL; 1573 detect = NULL;
1615 for (tmp = last; tmp; tmp = tmp->below) 1574 for (tmp = last; tmp; tmp = tmp->below)
1616 { 1575 {
1617 /* show invisible */ 1576 /* show invisible */
1618 if (QUERY_FLAG (spell, FLAG_MAKE_INVIS) && 1577 if (QUERY_FLAG (spell, FLAG_MAKE_INVIS) &&
1619 /* Might there be other objects that we can make visible? */ 1578 /* Might there be other objects that we can make visible? */
1620 (tmp->invisible && (QUERY_FLAG (tmp, FLAG_MONSTER) || 1579 (tmp->invisible && (QUERY_FLAG (tmp, FLAG_MONSTER) ||
1621 (tmp->type == PLAYER && !QUERY_FLAG (tmp, FLAG_WIZ)) || 1580 (tmp->type == PLAYER && !QUERY_FLAG (tmp, FLAG_WIZ))
1622 tmp->type == CF_HANDLE || 1581 || tmp->type == CF_HANDLE
1623 tmp->type == TRAPDOOR || tmp->type == EXIT || tmp->type == HOLE || 1582 || tmp->type == TRAPDOOR || tmp->type == EXIT || tmp->type == HOLE
1624 tmp->type == BUTTON || tmp->type == TELEPORTER || 1583 || tmp->type == BUTTON || tmp->type == TELEPORTER
1625 tmp->type == GATE || tmp->type == LOCKED_DOOR || 1584 || tmp->type == GATE || tmp->type == LOCKED_DOOR
1626 tmp->type == WEAPON || tmp->type == ALTAR || tmp->type == SIGN || 1585 || tmp->type == WEAPON || tmp->type == ALTAR || tmp->type == SIGN
1627 tmp->type == TRIGGER_PEDESTAL || tmp->type == SPECIAL_KEY || 1586 || tmp->type == TRIGGER_PEDESTAL || tmp->type == SPECIAL_KEY
1628 tmp->type == TREASURE || tmp->type == BOOK || tmp->type == HOLY_ALTAR))) 1587 || tmp->type == TREASURE || tmp->type == BOOK || tmp->type == HOLY_ALTAR)))
1629 { 1588 {
1630 if (random_roll (0, skill->level - 1, op, PREFER_HIGH) > level / 4) 1589 if (random_roll (0, skill->level - 1, op, PREFER_HIGH) > level / 4)
1631 { 1590 {
1632 tmp->invisible = 0; 1591 tmp->invisible = 0;
1633 done_one = 1; 1592 done_one = 1;
1634 } 1593 }
1635 } 1594 }
1636 1595
1637 if (QUERY_FLAG (tmp, FLAG_IS_FLOOR)) 1596 if (QUERY_FLAG (tmp, FLAG_IS_FLOOR))
1638 floor = 1; 1597 floor = 1;
1639 1598
1640 /* All detections below this point don't descend beneath the floor, 1599 /* All detections below this point don't descend beneath the floor,
1641 * so just continue on. We could be clever and look at the type of 1600 * so just continue on. We could be clever and look at the type of
1642 * detection to completely break out if we don't care about objects beneath 1601 * detection to completely break out if we don't care about objects beneath
1643 * the floor, but once we get to the floor, not likely a very big issue anyways. 1602 * the floor, but once we get to the floor, not likely a very big issue anyways.
1644 */ 1603 */
1645 if (floor) 1604 if (floor)
1646 continue; 1605 continue;
1647 1606
1648 /* I had thought about making detect magic and detect curse 1607 /* I had thought about making detect magic and detect curse
1649 * show the flash the magic item like it does for detect monster. 1608 * show the flash the magic item like it does for detect monster.
1650 * however, if the object is within sight, this would then make it 1609 * however, if the object is within sight, this would then make it
1651 * difficult to see what object is magical/cursed, so the 1610 * difficult to see what object is magical/cursed, so the
1652 * effect wouldn't be as apparant. 1611 * effect wouldn't be as apparent.
1653 */ 1612 */
1654 1613
1655 /* detect magic */ 1614 /* detect magic */
1656 if (QUERY_FLAG (spell, FLAG_KNOWN_MAGICAL) && 1615 if (QUERY_FLAG (spell, FLAG_KNOWN_MAGICAL) &&
1657 !QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_IDENTIFIED) && is_magical (tmp)) 1616 !QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_IDENTIFIED) && is_magical (tmp))
1658 { 1617 {
1659 SET_FLAG (tmp, FLAG_KNOWN_MAGICAL); 1618 SET_FLAG (tmp, FLAG_KNOWN_MAGICAL);
1660 /* make runes more visibile */ 1619 /* make runes more visibile */
1661 if (tmp->type == RUNE && tmp->attacktype & AT_MAGIC) 1620 if (tmp->type == RUNE && tmp->attacktype & AT_MAGIC)
1662 tmp->stats.Cha /= 4; 1621 tmp->stats.Cha /= 4;
1622
1663 done_one = 1; 1623 done_one = 1;
1664 } 1624 }
1625
1665 /* detect monster */ 1626 /* detect monster */
1666 if (QUERY_FLAG (spell, FLAG_MONSTER) && (QUERY_FLAG (tmp, FLAG_MONSTER) || tmp->type == PLAYER)) 1627 if (QUERY_FLAG (spell, FLAG_MONSTER) && (QUERY_FLAG (tmp, FLAG_MONSTER) || tmp->type == PLAYER))
1667 { 1628 {
1668 done_one = 2; 1629 done_one = 2;
1630
1669 if (!detect) 1631 if (!detect)
1670 detect = tmp; 1632 detect = tmp;
1671 } 1633 }
1634
1672 /* Basically, if race is set in the spell, then the creatures race must 1635 /* Basically, if race is set in the spell, then the creatures race must
1673 * match that. if the spell race is set to GOD, then the gods opposing 1636 * match that. if the spell race is set to GOD, then the gods opposing
1674 * race must match. 1637 * race must match.
1675 */ 1638 */
1676 if (spell->race && QUERY_FLAG (tmp, FLAG_MONSTER) && tmp->race && 1639 if (spell->race && QUERY_FLAG (tmp, FLAG_MONSTER) && tmp->race &&
1677 ((!strcmp (spell->race, "GOD") && god && god->slaying && strstr (god->slaying, tmp->race)) || 1640 ((spell->race == shstr_GOD && god && god->slaying.contains (tmp->race)) ||
1678 (strstr (spell->race, tmp->race)))) 1641 spell->race.contains (tmp->race)))
1679 { 1642 {
1680 done_one = 2; 1643 done_one = 2;
1644
1681 if (!detect) 1645 if (!detect)
1682 detect = tmp; 1646 detect = tmp;
1683 } 1647 }
1648
1684 if (QUERY_FLAG (spell, FLAG_KNOWN_CURSED) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED) && 1649 if (QUERY_FLAG (spell, FLAG_KNOWN_CURSED) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED) &&
1685 (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED))) 1650 (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)))
1686 { 1651 {
1687 SET_FLAG (tmp, FLAG_KNOWN_CURSED); 1652 SET_FLAG (tmp, FLAG_KNOWN_CURSED);
1688 done_one = 1; 1653 done_one = 1;
1689 } 1654 }
1690 } /* for stack of objects on this space */ 1655 } /* for stack of objects on this space */
1691 1656
1692 /* Code here puts an effect of the spell on the space, so you can see 1657 /* Code here puts an effect of the spell on the space, so you can see
1693 * where the magic is. 1658 * where the magic is.
1694 */ 1659 */
1695 if (done_one) 1660 if (done_one)
1696 { 1661 {
1697 object *detect_ob = arch_to_object (spell->other_arch); 1662 object *detect_ob = arch_to_object (spell->other_arch);
1698 1663
1699 /* if this is set, we want to copy the face */ 1664 /* if this is set, we want to copy the face */
1700 if (done_one == 2 && detect) 1665 if (done_one == 2 && detect)
1701 { 1666 {
1702 detect_ob->face = detect->face; 1667 detect_ob->face = detect->face;
1703 detect_ob->animation_id = detect->animation_id; 1668 detect_ob->animation_id = detect->animation_id;
1704 detect_ob->anim_speed = detect->anim_speed; 1669 detect_ob->anim_speed = detect->anim_speed;
1705 detect_ob->last_anim = 0; 1670 detect_ob->last_anim = 0;
1706 /* by default, the detect_ob is already animated */ 1671 /* by default, the detect_ob is already animated */
1707 if (!QUERY_FLAG (detect, FLAG_ANIMATE)) 1672 if (!QUERY_FLAG (detect, FLAG_ANIMATE))
1708 CLEAR_FLAG (detect_ob, FLAG_ANIMATE); 1673 CLEAR_FLAG (detect_ob, FLAG_ANIMATE);
1709 } 1674 }
1710 1675
1711 m->insert (detect_ob, nx, ny, op); 1676 m->insert (detect_ob, nx, ny, op);
1712 } 1677 }
1713 } /* for processing the surrounding spaces */ 1678 } /* for processing the surrounding spaces */
1714 1679
1715 1680
1716 /* Now process objects in the players inventory if detect curse or magic */ 1681 /* Now process objects in the players inventory if detect curse or magic */
1717 if (QUERY_FLAG (spell, FLAG_KNOWN_CURSED) || QUERY_FLAG (spell, FLAG_KNOWN_MAGICAL)) 1682 if (QUERY_FLAG (spell, FLAG_KNOWN_CURSED) || QUERY_FLAG (spell, FLAG_KNOWN_MAGICAL))
1718 { 1683 {
1719 done_one = 0; 1684 done_one = 0;
1685
1720 for (tmp = op->inv; tmp; tmp = tmp->below) 1686 for (tmp = op->inv; tmp; tmp = tmp->below)
1721 { 1687 {
1722 if (!tmp->invisible && !QUERY_FLAG (tmp, FLAG_IDENTIFIED)) 1688 if (!tmp->invisible && !QUERY_FLAG (tmp, FLAG_IDENTIFIED))
1723 { 1689 {
1724 if (QUERY_FLAG (spell, FLAG_KNOWN_MAGICAL) && is_magical (tmp) && !QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL)) 1690 if (QUERY_FLAG (spell, FLAG_KNOWN_MAGICAL) && is_magical (tmp) && !QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL))
1725 { 1691 {
1726 SET_FLAG (tmp, FLAG_KNOWN_MAGICAL); 1692 SET_FLAG (tmp, FLAG_KNOWN_MAGICAL);
1727 if (op->type == PLAYER) 1693
1694 if (object *pl = tmp->visible_to ())
1728 esrv_send_item (op, tmp); 1695 esrv_update_item (UPD_FLAGS, pl, tmp);
1729 } 1696 }
1697
1730 if (QUERY_FLAG (spell, FLAG_KNOWN_CURSED) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED) && 1698 if (QUERY_FLAG (spell, FLAG_KNOWN_CURSED) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED) &&
1731 (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED))) 1699 (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)))
1732 { 1700 {
1733 SET_FLAG (tmp, FLAG_KNOWN_CURSED); 1701 SET_FLAG (tmp, FLAG_KNOWN_CURSED);
1734 if (op->type == PLAYER) 1702
1703 if (object *pl = tmp->visible_to ())
1735 esrv_send_item (op, tmp); 1704 esrv_update_item (UPD_FLAGS, pl, tmp);
1736 } 1705 }
1737 } /* if item is not identified */ 1706 } /* if item is not identified */
1738 } /* for the players inventory */ 1707 } /* for the players inventory */
1739 } /* if detect magic/curse and object is a player */ 1708 } /* if detect magic/curse and object is a player */
1709
1740 return 1; 1710 return 1;
1741} 1711}
1742 1712
1743 1713
1744/** 1714/**
1757 1727
1758 new_draw_info (NDI_UNIQUE, 0, victim, "You feel energy course through you."); 1728 new_draw_info (NDI_UNIQUE, 0, victim, "You feel energy course through you.");
1759 1729
1760 if (victim->stats.sp >= victim->stats.maxsp * 2) 1730 if (victim->stats.sp >= victim->stats.maxsp * 2)
1761 { 1731 {
1762 object *tmp;
1763
1764 new_draw_info (NDI_UNIQUE, 0, victim, "Your head explodes!"); 1732 new_draw_info (NDI_UNIQUE, 0, victim, "Your head explodes!");
1765
1766 /* Explodes a fireball centered at player */
1767 tmp = get_archetype (EXPLODING_FIREBALL);
1768 tmp->dam_modifier = random_roll (1, caster_level, victim, PREFER_LOW) / 5 + 1;
1769 tmp->stats.maxhp = random_roll (1, caster_level, victim, PREFER_LOW) / 10 + 2;
1770
1771 tmp->insert_at (victim);
1772 victim->stats.sp = 2 * victim->stats.maxsp; 1733 victim->stats.sp = 2 * victim->stats.maxsp;
1734 create_exploding_ball_at (victim, caster_level);
1773 } 1735 }
1774 else if (victim->stats.sp >= victim->stats.maxsp * 1.88) 1736 else if (victim->stats.sp >= victim->stats.maxsp * 1.88)
1775 new_draw_info (NDI_UNIQUE, NDI_ORANGE, victim, "You feel like your head is going to explode."); 1737 new_draw_info (NDI_UNIQUE | NDI_ORANGE, 0, victim, "You feel like your head is going to explode.");
1776 else if (victim->stats.sp >= victim->stats.maxsp * 1.66) 1738 else if (victim->stats.sp >= victim->stats.maxsp * 1.66)
1777 new_draw_info (NDI_UNIQUE, 0, victim, "You get a splitting headache!"); 1739 new_draw_info (NDI_UNIQUE, 0, victim, "You get a splitting headache!");
1778 else if (victim->stats.sp >= victim->stats.maxsp * 1.5) 1740 else if (victim->stats.sp >= victim->stats.maxsp * 1.5)
1779 { 1741 {
1780 new_draw_info (NDI_UNIQUE, 0, victim, "Chaos fills your world."); 1742 new_draw_info (NDI_UNIQUE, 0, victim, "Chaos fills your world.");
1826 } 1788 }
1827 /* give sp */ 1789 /* give sp */
1828 if (spell->stats.dam > 0) 1790 if (spell->stats.dam > 0)
1829 { 1791 {
1830 plyr->stats.sp += spell->stats.dam + SP_level_dam_adjust (caster, spell); 1792 plyr->stats.sp += spell->stats.dam + SP_level_dam_adjust (caster, spell);
1831 charge_mana_effect (plyr, caster_level (caster, spell)); 1793 charge_mana_effect (plyr, casting_level (caster, spell));
1832 return 1; 1794 return 1;
1833 } 1795 }
1834 /* suck sp away. Can't suck sp from yourself */ 1796 /* suck sp away. Can't suck sp from yourself */
1835 else if (op != plyr) 1797 else if (op != plyr)
1836 { 1798 {
1848 /* Player doesn't get full credit */ 1810 /* Player doesn't get full credit */
1849 sucked = (sucked * rate) / 100; 1811 sucked = (sucked * rate) / 100;
1850 op->stats.sp += sucked; 1812 op->stats.sp += sucked;
1851 if (sucked > 0) 1813 if (sucked > 0)
1852 { 1814 {
1853 charge_mana_effect (op, caster_level (caster, spell)); 1815 charge_mana_effect (op, casting_level (caster, spell));
1854 } 1816 }
1855 } 1817 }
1856 return 1; 1818 return 1;
1857 } 1819 }
1858 return 0; 1820 return 0;
1934 break; 1896 break;
1935 } 1897 }
1936 } 1898 }
1937} 1899}
1938 1900
1939
1940
1941/* cast_consecrate() - a spell to make an altar your god's */ 1901/* cast_consecrate() - a spell to make an altar your god's */
1942int 1902int
1943cast_consecrate (object *op, object *caster, object *spell) 1903cast_consecrate (object *op, object *caster, object *spell)
1944{ 1904{
1945 char buf[MAX_BUF]; 1905 char buf[MAX_BUF];
1957 if (QUERY_FLAG (tmp, FLAG_IS_FLOOR)) 1917 if (QUERY_FLAG (tmp, FLAG_IS_FLOOR))
1958 break; 1918 break;
1959 if (tmp->type == HOLY_ALTAR) 1919 if (tmp->type == HOLY_ALTAR)
1960 { 1920 {
1961 1921
1962 if (tmp->level > caster_level (caster, spell)) 1922 if (tmp->level > casting_level (caster, spell))
1963 { 1923 {
1964 new_draw_info_format (NDI_UNIQUE, 0, op, "You are not powerful enough to reconsecrate the %s", &tmp->name); 1924 new_draw_info_format (NDI_UNIQUE, 0, op, "You are not powerful enough to reconsecrate the %s", &tmp->name);
1965 return 0; 1925 return 0;
1966 } 1926 }
1967 else 1927 else
1968 { 1928 {
1969 /* If we got here, we are consecrating an altar */ 1929 /* If we got here, we are consecrating an altar */
1970 sprintf (buf, "Altar of %s", &god->name); 1930 sprintf (buf, "Altar of %s", &god->name);
1971 tmp->name = buf; 1931 tmp->name = buf;
1972 tmp->level = caster_level (caster, spell); 1932 tmp->level = casting_level (caster, spell);
1973 tmp->other_arch = god->arch; 1933 tmp->other_arch = god->arch;
1934
1974 if (op->type == PLAYER) 1935 if (op->type == PLAYER)
1975 esrv_update_item (UPD_NAME, op, tmp); 1936 esrv_update_item (UPD_NAME, op, tmp);
1937
1976 new_draw_info_format (NDI_UNIQUE, 0, op, "You consecrated the altar to %s!", &god->name); 1938 new_draw_info_format (NDI_UNIQUE, 0, op, "You consecrated the altar to %s!", &god->name);
1977 return 1; 1939 return 1;
1978 } 1940 }
1979 } 1941 }
1980 } 1942 }
2018 return 0; 1980 return 0;
2019 } 1981 }
2020 1982
2021 /* if no direction specified, pick one */ 1983 /* if no direction specified, pick one */
2022 if (!dir) 1984 if (!dir)
2023 dir = find_free_spot (NULL, op->map, op->x, op->y, 1, 9); 1985 dir = find_free_spot (spell->other_arch, op->map, op->x, op->y, 1, 9);
2024 1986
2025 m = op->map; 1987 m = op->map;
2026 x = op->x + freearr_x[dir]; 1988 x = op->x + freearr_x[dir];
2027 y = op->y + freearr_y[dir]; 1989 y = op->y + freearr_y[dir];
2028 1990
2029 /* if there's no place to put the golem, abort */ 1991 /* if there's no place to put the golem, abort */
2030 if ((dir == -1) || (get_map_flags (m, &m, x, y, &x, &y) & P_OUT_OF_MAP) || 1992 if (dir < 0 || (get_map_flags (m, &m, x, y, &x, &y) & P_OUT_OF_MAP)
2031 ((spell->other_arch->move_type & GET_MAP_MOVE_BLOCK (m, x, y)) == spell->other_arch->move_type)) 1993 || ((spell->other_arch->move_type & GET_MAP_MOVE_BLOCK (m, x, y)) == spell->other_arch->move_type))
2032 { 1994 {
2033 new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way."); 1995 new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way.");
2034 return 0; 1996 return 0;
2035 } 1997 }
2036 1998
2040 if (!weapon) 2002 if (!weapon)
2041 { 2003 {
2042 new_draw_info (NDI_BLACK, 0, op, "You must mark a weapon to use with this spell!"); 2004 new_draw_info (NDI_BLACK, 0, op, "You must mark a weapon to use with this spell!");
2043 return 0; 2005 return 0;
2044 } 2006 }
2007
2045 if (spell->race && strcmp (weapon->arch->archname, spell->race)) 2008 if (spell->race && weapon->arch->archname != spell->race)
2046 { 2009 {
2047 new_draw_info (NDI_UNIQUE, 0, op, "The spell fails to transform your weapon."); 2010 new_draw_info (NDI_UNIQUE, 0, op, "The spell fails to transform your weapon.");
2048 return 0; 2011 return 0;
2049 } 2012 }
2013
2050 if (weapon->type != WEAPON) 2014 if (weapon->type != WEAPON)
2051 { 2015 {
2052 new_draw_info (NDI_UNIQUE, 0, op, "You need to wield a weapon to animate it."); 2016 new_draw_info (NDI_UNIQUE, 0, op, "You need to wield a weapon to animate it.");
2053 return 0; 2017 return 0;
2054 } 2018 }
2019
2055 if (QUERY_FLAG (weapon, FLAG_APPLIED)) 2020 if (QUERY_FLAG (weapon, FLAG_APPLIED))
2056 { 2021 {
2057 new_draw_info_format (NDI_BLACK, 0, op, "You need to unequip %s before using it in this spell", query_name (weapon)); 2022 new_draw_info_format (NDI_BLACK, 0, op, "You need to unequip %s before using it in this spell", query_name (weapon));
2058 return 0; 2023 return 0;
2059 } 2024 }
2060 2025
2061 if (weapon->nrof > 1) 2026 weapon = weapon->split ();
2062 {
2063 tmp = get_split_ob (weapon, 1);
2064 esrv_send_item (op, weapon);
2065 weapon = tmp;
2066 }
2067 2027
2068 /* create the golem object */ 2028 /* create the golem object */
2069 tmp = arch_to_object (spell->other_arch); 2029 tmp = arch_to_object (spell->other_arch);
2070 2030
2071 /* if animated by a player, give the player control of the golem */ 2031 /* if animated by a player, give the player control of the golem */
2076 tmp->set_owner (op); 2036 tmp->set_owner (op);
2077 op->contr->golem = tmp; 2037 op->contr->golem = tmp;
2078 set_spell_skill (op, caster, spell, tmp); 2038 set_spell_skill (op, caster, spell, tmp);
2079 2039
2080 /* Give the weapon to the golem now. A bit of a hack to check the 2040 /* Give the weapon to the golem now. A bit of a hack to check the
2081 * removed flag - it should only be set if get_split_object was 2041 * removed flag - it should only be set if weapon->split was
2082 * used above. 2042 * used above.
2083 */ 2043 */
2084 if (!QUERY_FLAG (weapon, FLAG_REMOVED)) 2044 if (!QUERY_FLAG (weapon, FLAG_REMOVED))
2085 weapon->remove (); 2045 weapon->remove ();
2086 2046
2087 insert_ob_in_ob (weapon, tmp); 2047 tmp->insert (weapon);
2088 esrv_send_item (op, weapon); 2048
2089 /* To do everything necessary to let a golem use the weapon is a pain, 2049 /* To do everything necessary to let a golem use the weapon is a pain,
2090 * so instead, just set it as equipped (otherwise, we need to update 2050 * so instead, just set it as equipped (otherwise, we need to update
2091 * body_info, skills, etc) 2051 * body_info, skills, etc)
2092 */ 2052 */
2093 SET_FLAG (tmp, FLAG_USE_WEAPON); 2053 SET_FLAG (tmp, FLAG_USE_WEAPON);
2167 tmp->state = weapon->state; 2127 tmp->state = weapon->state;
2168 tmp->flag [FLAG_ANIMATE] = weapon->flag [FLAG_ANIMATE]; 2128 tmp->flag [FLAG_ANIMATE] = weapon->flag [FLAG_ANIMATE];
2169 } 2129 }
2170 2130
2171 /* make experience increase in proportion to the strength of the summoned creature. */ 2131 /* make experience increase in proportion to the strength of the summoned creature. */
2172 tmp->stats.exp *= 1 + (MAX (spell->stats.maxgrace, spell->stats.sp) / caster_level (caster, spell)); 2132 tmp->stats.exp *= 1 + (MAX (spell->stats.maxgrace, spell->stats.sp) / casting_level (caster, spell));
2173 2133
2174 tmp->speed_left = -1; 2134 tmp->speed_left = -1;
2175 tmp->direction = dir; 2135 tmp->direction = dir;
2176 2136
2177 m->insert (tmp, x, y, op); 2137 m->insert (tmp, x, y, op);
2181/* cast_daylight() - changes the map darkness level *lower* */ 2141/* cast_daylight() - changes the map darkness level *lower* */
2182 2142
2183/* cast_change_map_lightlevel: Was cast_daylight/nightfall. 2143/* cast_change_map_lightlevel: Was cast_daylight/nightfall.
2184 * This changes the light level for the entire map. 2144 * This changes the light level for the entire map.
2185 */ 2145 */
2186
2187int 2146int
2188cast_change_map_lightlevel (object *op, object *caster, object *spell) 2147cast_change_map_lightlevel (object *op, object *caster, object *spell)
2189{ 2148{
2190 int success; 2149 int success;
2191 2150
2199 if (spell->stats.dam < 0) 2158 if (spell->stats.dam < 0)
2200 new_draw_info (NDI_UNIQUE, 0, op, "It can be no brighter here."); 2159 new_draw_info (NDI_UNIQUE, 0, op, "It can be no brighter here.");
2201 else 2160 else
2202 new_draw_info (NDI_UNIQUE, 0, op, "It can be no darker here."); 2161 new_draw_info (NDI_UNIQUE, 0, op, "It can be no darker here.");
2203 } 2162 }
2163
2204 return success; 2164 return success;
2205} 2165}
2206
2207
2208
2209
2210 2166
2211/* create an aura spell object and put it in the player's inventory. 2167/* create an aura spell object and put it in the player's inventory.
2212 * as usual, op is player, caster is the object casting the spell, 2168 * as usual, op is player, caster is the object casting the spell,
2213 * spell is the spell object itself. 2169 * spell is the spell object itself.
2214 */ 2170 */
2226 2182
2227 new_aura->duration = spell->duration + 10 * SP_level_duration_adjust (caster, spell); 2183 new_aura->duration = spell->duration + 10 * SP_level_duration_adjust (caster, spell);
2228 2184
2229 new_aura->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); 2185 new_aura->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell);
2230 2186
2231 new_aura->set_owner (op);
2232 set_spell_skill (op, caster, spell, new_aura); 2187 set_spell_skill (op, caster, spell, new_aura);
2233 new_aura->attacktype = spell->attacktype; 2188 new_aura->attacktype = spell->attacktype;
2234 2189
2235 new_aura->level = caster_level (caster, spell); 2190 new_aura->level = casting_level (caster, spell);
2191
2236 if (refresh) 2192 if (refresh)
2237 new_draw_info (NDI_UNIQUE, 0, op, "You recast the spell while in effect."); 2193 new_draw_info (NDI_UNIQUE, 0, op, "You recast the spell while in effect.");
2238 else 2194 else
2239 new_draw_info (NDI_UNIQUE, 0, op, "You create an aura of magical force."); 2195 new_draw_info (NDI_UNIQUE, 0, op, "You create an aura of magical force.");
2196
2240 insert_ob_in_ob (new_aura, op); 2197 insert_ob_in_ob (new_aura, op);
2198 new_aura->set_owner (op);
2199
2241 return 1; 2200 return 1;
2242} 2201}
2243
2244 2202
2245/* move aura function. An aura is a part of someone's inventory, 2203/* move aura function. An aura is a part of someone's inventory,
2246 * which he carries with him, but which acts on the map immediately 2204 * which he carries with him, but which acts on the map immediately
2247 * around him. 2205 * around him.
2248 * Aura parameters: 2206 * Aura parameters:
2249 * duration: duration counter. 2207 * duration: duration counter.
2250 * attacktype: aura's attacktype 2208 * attacktype: aura's attacktype
2251 * other_arch: archetype to drop where we attack 2209 * other_arch: archetype to drop where we attack
2252 */ 2210 */
2253
2254void 2211void
2255move_aura (object *aura) 2212move_aura (object *aura)
2256{ 2213{
2257 int i, mflags;
2258 object *env;
2259 maptile *m;
2260
2261 /* auras belong in inventories */ 2214 /* auras belong in inventories */
2262 env = aura->env; 2215 object *env = aura->env;
2216 object *owner = aura->owner;
2263 2217
2264 /* no matter what we've gotta remove the aura... 2218 /* no matter what we've gotta remove the aura...
2265 * we'll put it back if its time isn't up. 2219 * we'll put it back if its time isn't up.
2266 */ 2220 */
2267 aura->remove (); 2221 aura->remove ();
2272 aura->destroy (); 2226 aura->destroy ();
2273 return; 2227 return;
2274 } 2228 }
2275 2229
2276 /* auras only exist in inventories */ 2230 /* auras only exist in inventories */
2277 if (env == NULL || env->map == NULL) 2231 if (!env || !env->map)
2278 { 2232 {
2279 aura->destroy (); 2233 aura->destroy ();
2280 return; 2234 return;
2281 } 2235 }
2282 2236
2283 /* we need to jump out of the inventory for a bit 2237 /* we need to jump out of the inventory for a bit
2284 * in order to hit the map conveniently. 2238 * in order to hit the map conveniently.
2285 */ 2239 */
2286 aura->insert_at (env, aura); 2240 aura->insert_at (env, aura);
2287 2241
2288 for (i = 1; i < 9; i++) 2242 for (int i = 1; i < 9; i++)
2289 { 2243 {
2290 sint16 nx, ny; 2244 mapxy pos (env);
2245 pos.move (i);
2291 2246
2292 nx = aura->x + freearr_x[i];
2293 ny = aura->y + freearr_y[i];
2294 mflags = get_map_flags (env->map, &m, nx, ny, &nx, &ny);
2295
2296 /* Consider the movement tyep of the person with the aura as 2247 /* Consider the movement type of the person with the aura as
2297 * movement type of the aura. Eg, if the player is flying, the aura 2248 * movement type of the aura. Eg, if the player is flying, the aura
2298 * is flying also, if player is walking, it is on the ground, etc. 2249 * is flying also, if player is walking, it is on the ground, etc.
2299 */ 2250 */
2300 if (!(mflags & P_OUT_OF_MAP) && !(OB_TYPE_MOVE_BLOCK (env, GET_MAP_MOVE_BLOCK (m, nx, ny)))) 2251 if (pos.normalise () && !(OB_TYPE_MOVE_BLOCK (env, pos->move_block)))
2301 { 2252 {
2302 hit_map (aura, i, aura->attacktype, 0); 2253 hit_map (aura, i, aura->attacktype, 0);
2303 2254
2304 if (aura->other_arch) 2255 if (aura->other_arch)
2305 m->insert (arch_to_object (aura->other_arch), nx, ny, aura); 2256 pos.insert (arch_to_object (aura->other_arch), aura);
2306 } 2257 }
2307 } 2258 }
2308 2259
2309 /* put the aura back in the player's inventory */ 2260 /* put the aura back in the player's inventory */
2310 aura->remove (); 2261 env->insert (aura);
2311 insert_ob_in_ob (aura, env); 2262 aura->set_owner (owner);
2312} 2263}
2313 2264
2314/* moves the peacemaker spell. 2265/* moves the peacemaker spell.
2315 * op is the piece object. 2266 * op is the piece object.
2316 */ 2267 */
2317
2318void 2268void
2319move_peacemaker (object *op) 2269move_peacemaker (object *op)
2320{ 2270{
2321 object *tmp; 2271 for (object *tmp = op->ms ().bot; tmp; tmp = tmp->above)
2322
2323 for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above)
2324 { 2272 {
2325 int atk_lev, def_lev; 2273 int atk_lev, def_lev;
2326 object *victim = tmp; 2274 object *victim = tmp->head_ ();
2327 2275
2328 if (tmp->head)
2329 victim = tmp->head;
2330 if (!QUERY_FLAG (victim, FLAG_MONSTER)) 2276 if (!QUERY_FLAG (victim, FLAG_MONSTER))
2331 continue; 2277 continue;
2278
2332 if (QUERY_FLAG (victim, FLAG_UNAGGRESSIVE)) 2279 if (QUERY_FLAG (victim, FLAG_UNAGGRESSIVE))
2333 continue; 2280 continue;
2281
2334 if (victim->stats.exp == 0) 2282 if (victim->stats.exp == 0)
2335 continue; 2283 continue;
2336 2284
2337 def_lev = MAX (1, victim->level); 2285 def_lev = MAX (1, victim->level);
2338 atk_lev = MAX (1, op->level); 2286 atk_lev = MAX (1, op->level);
2339 2287
2340 if (rndm (0, atk_lev - 1) > def_lev) 2288 if (rndm (0, atk_lev - 1) > def_lev)
2341 { 2289 {
2342 /* make this sucker peaceful. */ 2290 /* make this sucker peaceful. */
2343 2291
2292 INVOKE_OBJECT (KILL, victim, ARG_OBJECT (op));
2344 change_exp (op->owner, victim->stats.exp, op->skill, 0); 2293 change_exp (op->owner, victim->stats.exp, op->skill, 0);
2345 victim->stats.exp = 0; 2294 victim->stats.exp = 0;
2346#if 0 2295#if 0
2347 /* No idea why these were all set to zero - if something 2296 /* No idea why these were all set to zero - if something
2348 * makes this creature agressive, he should still do damage. 2297 * makes this creature agressive, he should still do damage.
2355 victim->attack_movement = RANDO2; 2304 victim->attack_movement = RANDO2;
2356 SET_FLAG (victim, FLAG_UNAGGRESSIVE); 2305 SET_FLAG (victim, FLAG_UNAGGRESSIVE);
2357 SET_FLAG (victim, FLAG_RUN_AWAY); 2306 SET_FLAG (victim, FLAG_RUN_AWAY);
2358 SET_FLAG (victim, FLAG_RANDOM_MOVE); 2307 SET_FLAG (victim, FLAG_RANDOM_MOVE);
2359 CLEAR_FLAG (victim, FLAG_MONSTER); 2308 CLEAR_FLAG (victim, FLAG_MONSTER);
2309
2360 if (victim->name) 2310 if (victim->name)
2361 {
2362 new_draw_info_format (NDI_UNIQUE, 0, op->owner, "%s no longer feels like fighting.", &victim->name); 2311 new_draw_info_format (NDI_UNIQUE, 0, op->owner, "%s no longer feels like fighting.", &victim->name);
2363 } 2312 }
2364 }
2365 } 2313 }
2366} 2314}
2367
2368 2315
2369/* This writes a rune that contains the appropriate message. 2316/* This writes a rune that contains the appropriate message.
2370 * There really isn't any adjustments we make. 2317 * There really isn't any adjustments we make.
2371 */ 2318 */
2372
2373int 2319int
2374write_mark (object *op, object *spell, const char *msg) 2320write_mark (object *op, object *spell, const char *msg)
2375{ 2321{
2376 char rune[HUGE_BUF];
2377 object *tmp;
2378
2379 if (!msg || msg[0] == 0) 2322 if (!msg || msg[0] == 0)
2380 { 2323 {
2381 new_draw_info (NDI_UNIQUE, 0, op, "Write what?"); 2324 new_draw_info (NDI_UNIQUE, 0, op, "Write what?");
2382 return 0; 2325 return 0;
2383 } 2326 }
2386 { 2329 {
2387 new_draw_info (NDI_UNIQUE, 0, op, "Trying to cheat are we?"); 2330 new_draw_info (NDI_UNIQUE, 0, op, "Trying to cheat are we?");
2388 LOG (llevInfo, "write_rune: player %s tried to write bogus rune %s\n", &op->name, msg); 2331 LOG (llevInfo, "write_rune: player %s tried to write bogus rune %s\n", &op->name, msg);
2389 return 0; 2332 return 0;
2390 } 2333 }
2334
2391 if (!spell->other_arch) 2335 if (!spell->other_arch)
2392 return 0; 2336 return 0;
2337
2393 tmp = arch_to_object (spell->other_arch); 2338 object *tmp = arch_to_object (spell->other_arch);
2394
2395 snprintf (rune, sizeof (rune), "%s\n", msg);
2396 2339
2397 tmp->race = op->name; /*Save the owner of the rune */ 2340 tmp->race = op->name; /*Save the owner of the rune */
2398 tmp->msg = rune; 2341 tmp->msg = msg;
2399 2342
2400 tmp->insert_at (op, op, INS_BELOW_ORIGINATOR); 2343 tmp->insert_at (op, op, INS_BELOW_ORIGINATOR);
2344
2401 return 1; 2345 return 1;
2402} 2346}
2347

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines