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

Comparing deliantra/server/server/spell_attack.C (file contents):
Revision 1.14 by root, Thu Sep 14 23:13:49 2006 UTC vs.
Revision 1.29 by root, Mon Jan 29 16:11:48 2007 UTC

1/* 1/*
2 CrossFire, A Multiplayer game for X-windows 2 * CrossFire, A Multiplayer game for X-windows
3 3 *
4 * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team
4 Copyright (C) 2002-2003 Mark Wedel & Crossfire Development Team 5 * Copyright (C) 2002-2003 Mark Wedel & Crossfire Development Team
5 Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (C) 1992 Frank Tore Johansen
6 7 *
7 This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version. 11 * (at your option) any later version.
11 12 *
12 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,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details. 16 * GNU General Public License for more details.
16 17 *
17 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
18 along with this program; if not, write to the Free Software 19 * along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 21 *
21 The authors can be reached via e-mail at <crossfire@schmorp.de> 22 * The authors can be reached via e-mail at <crossfire@schmorp.de>
22*/ 23 */
23 24
24/* This file contains all the spell attack code. Grouping this code 25/* This file contains all the spell attack code. Grouping this code
25 * together should hopefully make it easier to find the relevent bits 26 * together should hopefully make it easier to find the relevent bits
26 * of code 27 * of code
27 */ 28 */
28 29
29#include <global.h> 30#include <global.h>
30#include <object.h> 31#include <object.h>
31#include <living.h> 32#include <living.h>
32#ifndef __CEXTRACT__
33# include <sproto.h> 33#include <sproto.h>
34#endif
35#include <spells.h> 34#include <spells.h>
36#include <sounds.h> 35#include <sounds.h>
37 36
38/* this function checks to see if a spell pushes objects as well 37/* this function checks to see if a spell pushes objects as well
39 * as flies over and damages them (only used for cones for now) 38 * as flies over and damages them (only used for cones for now)
57 { 56 {
58 weight_move = op->weight + (op->weight * op->level) / 3; 57 weight_move = op->weight + (op->weight * op->level) / 3;
59 /*LOG (llevDebug, "DEBUG: arch weighs %d and masses %d (%s,level %d)\n", op->weight,weight_move,op->name,op->level); */ 58 /*LOG (llevDebug, "DEBUG: arch weighs %d and masses %d (%s,level %d)\n", op->weight,weight_move,op->name,op->level); */
60 } 59 }
61 60
62 for (tmp = get_map_ob (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) 61 for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above)
63 { 62 {
64 int num_sections = 1; 63 int num_sections = 1;
65 64
66 /* don't move DM */ 65 /* don't move DM */
67 if (QUERY_FLAG (tmp, FLAG_WIZ)) 66 if (QUERY_FLAG (tmp, FLAG_WIZ))
117void 116void
118forklightning (object *op, object *tmp) 117forklightning (object *op, object *tmp)
119{ 118{
120 int new_dir = 1; /* direction or -1 for left, +1 for right 0 if no new bolt */ 119 int new_dir = 1; /* direction or -1 for left, +1 for right 0 if no new bolt */
121 int t_dir; /* stores temporary dir calculation */ 120 int t_dir; /* stores temporary dir calculation */
122 mapstruct *m; 121 maptile *m;
123 sint16 sx, sy; 122 sint16 sx, sy;
124 object *new_bolt; 123 object *new_bolt;
125 124
126 /* pick a fork direction. tmp->stats.Con is the left bias 125 /* pick a fork direction. tmp->stats.Con is the left bias
127 * i.e., the chance in 100 of forking LEFT 126 * i.e., the chance in 100 of forking LEFT
140 139
141 if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (m, sx, sy))) 140 if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (m, sx, sy)))
142 return; 141 return;
143 142
144 /* OK, we made a fork */ 143 /* OK, we made a fork */
145 new_bolt = get_object (); 144 new_bolt = tmp->clone ();
146 copy_object (tmp, new_bolt);
147 145
148 /* reduce chances of subsequent forking */ 146 /* reduce chances of subsequent forking */
149 new_bolt->stats.Dex -= 10; 147 new_bolt->stats.Dex -= 10;
150 tmp->stats.Dex -= 10; /* less forks from main bolt too */ 148 tmp->stats.Dex -= 10; /* less forks from main bolt too */
151 new_bolt->stats.Con += 25 * new_dir; /* adjust the left bias */ 149 new_bolt->stats.Con += 25 * new_dir; /* adjust the left bias */
152 new_bolt->speed_left = -0.1; 150 new_bolt->speed_left = -0.1;
153 new_bolt->direction = t_dir; 151 new_bolt->direction = t_dir;
154 new_bolt->duration++; 152 new_bolt->duration++;
155 new_bolt->x = sx;
156 new_bolt->y = sy;
157 new_bolt->stats.dam /= 2; /* reduce daughter bolt damage */ 153 new_bolt->stats.dam /= 2; /* reduce daughter bolt damage */
158 new_bolt->stats.dam++; 154 new_bolt->stats.dam++;
159 tmp->stats.dam /= 2; /* reduce father bolt damage */ 155 tmp->stats.dam /= 2; /* reduce father bolt damage */
160 tmp->stats.dam++; 156 tmp->stats.dam++;
161 new_bolt = insert_ob_in_map (new_bolt, m, op, 0); 157 if ((new_bolt = m->insert (new_bolt, sx, sy, op)))
162 update_turn_face (new_bolt); 158 update_turn_face (new_bolt);
163} 159}
164 160
165/* move_bolt: moves bolt 'op'. Basically, it just advances a space, 161/* move_bolt: moves bolt 'op'. Basically, it just advances a space,
166 * and checks for various things that may stop it. 162 * and checks for various things that may stop it.
167 */ 163 */
170move_bolt (object *op) 166move_bolt (object *op)
171{ 167{
172 object *tmp; 168 object *tmp;
173 int mflags; 169 int mflags;
174 sint16 x, y; 170 sint16 x, y;
175 mapstruct *m; 171 maptile *m;
176 172
177 if (--(op->duration) < 0) 173 if (--op->duration < 0)
178 { 174 {
179 remove_ob (op); 175 op->destroy ();
180 free_object (op);
181 return; 176 return;
182 } 177 }
183 178
184 hit_map (op, 0, op->attacktype, 1); 179 hit_map (op, 0, op->attacktype, 1);
185 180
186 if (!op->direction) 181 if (!op->direction)
187 return; 182 return;
188 183
189 if (--op->range < 0) 184 if (--op->range < 0)
190 {
191 op->range = 0; 185 op->range = 0;
192 }
193 else 186 else
194 { 187 {
195 x = op->x + DIRX (op); 188 x = op->x + DIRX (op);
196 y = op->y + DIRY (op); 189 y = op->y + DIRY (op);
197 m = op->map; 190 m = op->map;
205 * on the space. So only call reflwall if we think the data it returns 198 * on the space. So only call reflwall if we think the data it returns
206 * will be useful. 199 * will be useful.
207 */ 200 */
208 if (OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, x, y)) || ((mflags & P_IS_ALIVE) && reflwall (m, x, y, op))) 201 if (OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, x, y)) || ((mflags & P_IS_ALIVE) && reflwall (m, x, y, op)))
209 { 202 {
210
211 if (!QUERY_FLAG (op, FLAG_REFLECTING)) 203 if (!QUERY_FLAG (op, FLAG_REFLECTING))
212 return; 204 return;
213 205
214 /* Since walls don't run diagonal, if the bolt is in 206 /* Since walls don't run diagonal, if the bolt is in
215 * one of 4 main directions, it just reflects back in the 207 * one of 4 main directions, it just reflects back in the
245 else if (left) 237 else if (left)
246 op->direction = absdir (op->direction + 2); 238 op->direction = absdir (op->direction + 2);
247 else if (right) 239 else if (right)
248 op->direction = absdir (op->direction - 2); 240 op->direction = absdir (op->direction - 2);
249 } 241 }
242
250 update_turn_face (op); /* A bolt *must* be IS_TURNABLE */ 243 update_turn_face (op); /* A bolt *must* be IS_TURNABLE */
251 return; 244 return;
252 } 245 }
253 else 246 else
254 { /* Create a copy of this object and put it ahead */ 247 { /* Create a copy of this object and put it ahead */
255 tmp = get_object (); 248 object *tmp = op->clone ();
256 copy_object (op, tmp); 249
250 m->insert (tmp, x, y, op);
257 tmp->speed_left = -0.1; 251 tmp->speed_left = -0.1;
258 tmp->x += DIRX (tmp), tmp->y += DIRY (tmp);
259 tmp = insert_ob_in_map (tmp, op->map, op, 0);
260 /* To make up for the decrease at the top of the function */ 252 /* To make up for the decrease at the top of the function */
261 tmp->duration++; 253 tmp->duration++;
262 254
263 /* New forking code. Possibly create forks of this object 255 /* New forking code. Possibly create forks of this object
264 * going off in other directions. 256 * going off in other directions.
265 */ 257 */
266
267 if (rndm (0, 99) < tmp->stats.Dex) 258 if (rndm (0, 99) < tmp->stats.Dex)
268 { /* stats.Dex % of forking */ 259 { /* stats.Dex % of forking */
269 forklightning (op, tmp); 260 forklightning (op, tmp);
270 } 261 }
262
271 /* In this way, the object left behind sticks on the space, but 263 /* In this way, the object left behind sticks on the space, but
272 * doesn't create any bolts that continue to move onward. 264 * doesn't create any bolts that continue to move onward.
273 */ 265 */
274 op->range = 0; 266 op->range = 0;
275 } /* copy object and move it along */ 267 } /* copy object and move it along */
282 * we remove the magic flag - that can be derived from 274 * we remove the magic flag - that can be derived from
283 * spob->attacktype. 275 * spob->attacktype.
284 * This function sets up the appropriate owner and skill 276 * This function sets up the appropriate owner and skill
285 * pointers. 277 * pointers.
286 */ 278 */
287
288int 279int
289fire_bolt (object *op, object *caster, int dir, object *spob, object *skill) 280fire_bolt (object *op, object *caster, int dir, object *spob, object *skill)
290{ 281{
291 object *tmp = NULL; 282 object *tmp = NULL;
292 int mflags; 283 int mflags;
310 301
311 tmp->direction = dir; 302 tmp->direction = dir;
312 if (QUERY_FLAG (tmp, FLAG_IS_TURNABLE)) 303 if (QUERY_FLAG (tmp, FLAG_IS_TURNABLE))
313 SET_ANIMATION (tmp, dir); 304 SET_ANIMATION (tmp, dir);
314 305
315 set_owner (tmp, op); 306 tmp->set_owner (op);
316 set_spell_skill (op, caster, spob, tmp); 307 set_spell_skill (op, caster, spob, tmp);
317 308
318 tmp->x = op->x + DIRX (tmp); 309 tmp->x = op->x + DIRX (tmp);
319 tmp->y = op->y + DIRY (tmp); 310 tmp->y = op->y + DIRY (tmp);
320 tmp->map = op->map; 311 tmp->map = op->map;
321 312
313 maptile *newmap;
322 mflags = get_map_flags (tmp->map, &tmp->map, tmp->x, tmp->y, &tmp->x, &tmp->y); 314 mflags = get_map_flags (tmp->map, &newmap, tmp->x, tmp->y, &tmp->x, &tmp->y);
323 if (mflags & P_OUT_OF_MAP) 315 if (mflags & P_OUT_OF_MAP)
324 { 316 {
325 free_object (tmp); 317 tmp->destroy ();
326 return 0; 318 return 0;
327 } 319 }
320
321 tmp->map = newmap;
322
328 if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y))) 323 if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y)))
329 { 324 {
330 if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) 325 if (!QUERY_FLAG (tmp, FLAG_REFLECTING))
331 { 326 {
332 free_object (tmp); 327 tmp->destroy ();
333 return 0; 328 return 0;
334 } 329 }
330
335 tmp->x = op->x; 331 tmp->x = op->x;
336 tmp->y = op->y; 332 tmp->y = op->y;
337 tmp->direction = absdir (tmp->direction + 4); 333 tmp->direction = absdir (tmp->direction + 4);
338 tmp->map = op->map; 334 tmp->map = op->map;
339 } 335 }
340 if ((tmp = insert_ob_in_map (tmp, tmp->map, op, 0)) != NULL) 336
337 if ((tmp = tmp->insert_at (tmp, op)))
341 move_bolt (tmp); 338 move_bolt (tmp);
339
342 return 1; 340 return 1;
343} 341}
344 342
345 343
346 344
355 * At least that is what I think this does. 353 * At least that is what I think this does.
356 */ 354 */
357void 355void
358explosion (object *op) 356explosion (object *op)
359{ 357{
360 object *tmp;
361 mapstruct *m = op->map; 358 maptile *m = op->map;
362 int i; 359 int i;
363 360
364 if (--(op->duration) < 0) 361 if (--op->duration < 0)
365 { 362 {
366 remove_ob (op); 363 op->destroy ();
367 free_object (op);
368 return; 364 return;
369 } 365 }
366
370 hit_map (op, 0, op->attacktype, 0); 367 hit_map (op, 0, op->attacktype, 0);
371 368
372 if (op->range > 0) 369 if (op->range > 0)
373 { 370 {
374 for (i = 1; i < 9; i++) 371 for (i = 1; i < 9; i++)
375 { 372 {
376 sint16 dx, dy; 373 sint16 dx, dy;
377 374
378 dx = op->x + freearr_x[i]; 375 dx = op->x + freearr_x[i];
379 dy = op->y + freearr_y[i]; 376 dy = op->y + freearr_y[i];
377
380 /* ok_to_put_more already does things like checks for walls, 378 /* ok_to_put_more already does things like checks for walls,
381 * out of map, etc. 379 * out of map, etc.
382 */ 380 */
383 if (ok_to_put_more (op->map, dx, dy, op, op->attacktype)) 381 if (ok_to_put_more (op->map, dx, dy, op, op->attacktype))
384 { 382 {
385 tmp = get_object (); 383 object *tmp = op->clone ();
386 copy_object (op, tmp); 384
387 tmp->state = 0; 385 tmp->state = 0;
388 tmp->speed_left = -0.21; 386 tmp->speed_left = -0.21;
389 tmp->range--; 387 tmp->range--;
390 tmp->value = 0; 388 tmp->value = 0;
391 tmp->x = dx; 389
392 tmp->y = dy; 390 m->insert (tmp, dx, dy, op);
393 insert_ob_in_map (tmp, m, op, 0);
394 } 391 }
395 } 392 }
396 } 393 }
397} 394}
398 395
407 object *tmp, *owner; 404 object *tmp, *owner;
408 405
409 if (op->other_arch == NULL) 406 if (op->other_arch == NULL)
410 { 407 {
411 LOG (llevError, "BUG: explode_bullet(): op without other_arch\n"); 408 LOG (llevError, "BUG: explode_bullet(): op without other_arch\n");
412 remove_ob (op); 409 op->destroy ();
413 free_object (op);
414 return; 410 return;
415 } 411 }
416 412
417 if (op->env) 413 if (op->env)
418 { 414 {
419 object *env;
420
421 env = object_get_env_recursive (op); 415 object *env = object_get_env_recursive (op);
422 if (env->map == NULL || out_of_map (env->map, env->x, env->y)) 416 if (env->map == NULL || out_of_map (env->map, env->x, env->y))
423 { 417 {
424 LOG (llevError, "BUG: explode_bullet(): env out of map\n"); 418 LOG (llevError, "BUG: explode_bullet(): env out of map\n");
425 remove_ob (op); 419 op->destroy ();
426 free_object (op);
427 return; 420 return;
428 } 421 }
429 remove_ob (op); 422
430 op->x = env->x; 423 op->insert_at (env, op, INS_NO_MERGE | INS_NO_WALK_ON);
431 op->y = env->y;
432 insert_ob_in_map (op, env->map, op, INS_NO_MERGE | INS_NO_WALK_ON);
433 } 424 }
434 else if (out_of_map (op->map, op->x, op->y)) 425 else if (out_of_map (op->map, op->x, op->y))
435 { 426 {
436 LOG (llevError, "BUG: explode_bullet(): op out of map\n"); 427 LOG (llevError, "BUG: explode_bullet(): op out of map\n");
437 remove_ob (op); 428 op->destroy ();
438 free_object (op);
439 return; 429 return;
440 } 430 }
441 431
442 // elmex Tue Aug 15 17:46:51 CEST 2006: Prevent explosions of any kind on safe maps 432 // elmex Tue Aug 15 17:46:51 CEST 2006: Prevent explosions of any kind on safe maps
443 // NOTE: If this breaks something important: remove this. I can't think of anything 433 // NOTE: If this breaks something important: remove this. I can't think of anything
444 // bad at the moment that might happen from this. 434 // bad at the moment that might happen from this.
445 if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) 435 if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE)
446 { 436 {
447 remove_ob (op); 437 op->destroy ();
448 free_object (op);
449 return; 438 return;
450 } 439 }
451 440
452 if (op->attacktype) 441 if (op->attacktype)
453 { 442 {
457 } 446 }
458 447
459 /* other_arch contains what this explodes into */ 448 /* other_arch contains what this explodes into */
460 tmp = arch_to_object (op->other_arch); 449 tmp = arch_to_object (op->other_arch);
461 450
462 copy_owner (tmp, op); 451 tmp->set_owner (op);
463 tmp->skill = op->skill; 452 tmp->skill = op->skill;
464 453
465 owner = get_owner (op); 454 owner = op->owner;
466 455
467 if ((tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER) && owner && !tailor_god_spell (tmp, owner)) 456 if ((tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER) && owner && !tailor_god_spell (tmp, owner))
468 { 457 {
469 remove_ob (op); 458 op->destroy ();
470 free_object (op);
471 return; 459 return;
472 } 460 }
473
474 tmp->x = op->x;
475 tmp->y = op->y;
476 461
477 /* special for bombs - it actually has sane values for these */ 462 /* special for bombs - it actually has sane values for these */
478 if (op->type == SPELL_EFFECT && op->subtype == SP_BOMB) 463 if (op->type == SPELL_EFFECT && op->subtype == SP_BOMB)
479 { 464 {
480 tmp->attacktype = op->attacktype; 465 tmp->attacktype = op->attacktype;
484 } 469 }
485 else 470 else
486 { 471 {
487 if (op->attacktype & AT_MAGIC) 472 if (op->attacktype & AT_MAGIC)
488 tmp->attacktype |= AT_MAGIC; 473 tmp->attacktype |= AT_MAGIC;
474
489 /* Spell doc describes what is going on here */ 475 /* Spell doc describes what is going on here */
490 tmp->stats.dam = op->dam_modifier; 476 tmp->stats.dam = op->dam_modifier;
491 tmp->range = op->stats.maxhp; 477 tmp->range = op->stats.maxhp;
492 tmp->duration = op->stats.hp; 478 tmp->duration = op->stats.hp;
493 /* Used for spell tracking - just need a unique val for this spell - 479 /* Used for spell tracking - just need a unique val for this spell -
501 tmp->stats.sp = op->direction; 487 tmp->stats.sp = op->direction;
502 488
503 /* Prevent recursion */ 489 /* Prevent recursion */
504 op->move_on = 0; 490 op->move_on = 0;
505 491
506 insert_ob_in_map (tmp, op->map, op, 0); 492 tmp->insert_at (op, op);
507 /* remove the firebullet */ 493 /* remove the firebullet */
508 if (!op->destroyed ()) 494 op->destroy ();
509 {
510 remove_ob (op);
511 free_object (op);
512 }
513} 495}
514
515
516 496
517/* checks to see what op should do, given the space it is on 497/* checks to see what op should do, given the space it is on
518 * (eg, explode, damage player, etc) 498 * (eg, explode, damage player, etc)
519 */ 499 */
520
521void 500void
522check_bullet (object *op) 501check_bullet (object *op)
523{ 502{
524 object *tmp; 503 object *tmp;
525 int dam, mflags; 504 int dam, mflags;
526 mapstruct *m; 505 maptile *m;
527 sint16 sx, sy; 506 sint16 sx, sy;
528 507
529 mflags = get_map_flags (op->map, &m, op->x, op->y, &sx, &sy); 508 mflags = get_map_flags (op->map, &m, op->x, op->y, &sx, &sy);
530 509
531 if (!(mflags & P_IS_ALIVE) && !OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy))) 510 if (!(mflags & P_IS_ALIVE) && !OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy)))
540 519
541 /* If nothing alive on this space, no reason to do anything further */ 520 /* If nothing alive on this space, no reason to do anything further */
542 if (!(mflags & P_IS_ALIVE)) 521 if (!(mflags & P_IS_ALIVE))
543 return; 522 return;
544 523
545 for (tmp = get_map_ob (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) 524 for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above)
546 { 525 {
547 if (QUERY_FLAG (tmp, FLAG_ALIVE)) 526 if (QUERY_FLAG (tmp, FLAG_ALIVE))
548 { 527 {
549 dam = hit_player (tmp, op->stats.dam, op, op->attacktype, 1); 528 dam = hit_player (tmp, op->stats.dam, op, op->attacktype, 1);
550 if (op->destroyed () || !tmp->destroyed () || (op->stats.dam -= dam) < 0) 529 if (op->destroyed () || !tmp->destroyed () || (op->stats.dam -= dam) < 0)
551 { 530 {
552 if (!QUERY_FLAG (op, FLAG_REMOVED)) 531 if (!QUERY_FLAG (op, FLAG_REMOVED))
553 { 532 {
554 remove_ob (op); 533 op->destroy ();
555 free_object (op);
556 return; 534 return;
557 } 535 }
558 } 536 }
559 } 537 }
560 } 538 }
561} 539}
562
563 540
564/* Basically, we move 'op' one square, and if it hits something, 541/* Basically, we move 'op' one square, and if it hits something,
565 * call check_bullet. 542 * call check_bullet.
566 * This function is only applicable to bullets, but not to all 543 * This function is only applicable to bullets, but not to all
567 * fired arches (eg, bolts). 544 * fired arches (eg, bolts).
568 */ 545 */
569
570void 546void
571move_bullet (object *op) 547move_bullet (object *op)
572{ 548{
573 sint16 new_x, new_y; 549 sint16 new_x, new_y;
574 int mflags; 550 int mflags;
575 mapstruct *m; 551 maptile *m;
576 552
577#if 0 553#if 0
578 /* We need a better general purpose way to do this */ 554 /* We need a better general purpose way to do this */
579 555
580 /* peterm: added to make comet leave a trail of burnouts 556 /* peterm: added to make comet leave a trail of burnouts
589 565
590 /* Reached the end of its life - remove it */ 566 /* Reached the end of its life - remove it */
591 if (--op->range <= 0) 567 if (--op->range <= 0)
592 { 568 {
593 if (op->other_arch) 569 if (op->other_arch)
594 {
595 explode_bullet (op); 570 explode_bullet (op);
596 }
597 else 571 else
598 { 572 op->destroy ();
599 remove_ob (op); 573
600 free_object (op);
601 }
602 return; 574 return;
603 } 575 }
604 576
605 new_x = op->x + DIRX (op); 577 new_x = op->x + DIRX (op);
606 new_y = op->y + DIRY (op); 578 new_y = op->y + DIRY (op);
607 m = op->map; 579 m = op->map;
608 mflags = get_map_flags (m, &m, new_x, new_y, &new_x, &new_y); 580 mflags = get_map_flags (m, &m, new_x, new_y, &new_x, &new_y);
609 581
610 if (mflags & P_OUT_OF_MAP) 582 if (mflags & P_OUT_OF_MAP)
611 { 583 {
612 remove_ob (op); 584 op->destroy ();
613 free_object (op);
614 return; 585 return;
615 } 586 }
616 587
617 if (!op->direction || OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, new_x, new_y))) 588 if (!op->direction || OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, new_x, new_y)))
618 { 589 {
619 if (op->other_arch) 590 if (op->other_arch)
620 {
621 explode_bullet (op); 591 explode_bullet (op);
622 }
623 else 592 else
624 { 593 op->destroy ();
625 remove_ob (op); 594
626 free_object (op);
627 }
628 return; 595 return;
629 } 596 }
630 597
631 remove_ob (op); 598 if (!(op = m->insert (op, new_x, new_y, op)))
632 op->x = new_x;
633 op->y = new_y;
634 if ((op = insert_ob_in_map (op, m, op, 0)) == NULL)
635 return; 599 return;
636 600
637 if (reflwall (op->map, op->x, op->y, op)) 601 if (reflwall (op->map, op->x, op->y, op))
638 { 602 {
639 op->direction = absdir (op->direction + 4); 603 op->direction = absdir (op->direction + 4);
640 update_turn_face (op); 604 update_turn_face (op);
641 } 605 }
642 else 606 else
643 {
644 check_bullet (op); 607 check_bullet (op);
645 }
646} 608}
647 609
648 610
649 611
650 612
685 647
686 tmp->direction = dir; 648 tmp->direction = dir;
687 if (QUERY_FLAG (tmp, FLAG_IS_TURNABLE)) 649 if (QUERY_FLAG (tmp, FLAG_IS_TURNABLE))
688 SET_ANIMATION (tmp, dir); 650 SET_ANIMATION (tmp, dir);
689 651
690 set_owner (tmp, op); 652 tmp->set_owner (op);
691 set_spell_skill (op, caster, spob, tmp); 653 set_spell_skill (op, caster, spob, tmp);
692 654
693 tmp->x = op->x + freearr_x[dir]; 655 tmp->x = op->x + freearr_x[dir];
694 tmp->y = op->y + freearr_y[dir]; 656 tmp->y = op->y + freearr_y[dir];
695 tmp->map = op->map; 657 tmp->map = op->map;
696 658
659 maptile *newmap;
697 mflags = get_map_flags (tmp->map, &tmp->map, tmp->x, tmp->y, &tmp->x, &tmp->y); 660 mflags = get_map_flags (tmp->map, &newmap, tmp->x, tmp->y, &tmp->x, &tmp->y);
698 if (mflags & P_OUT_OF_MAP) 661 if (mflags & P_OUT_OF_MAP)
699 { 662 {
700 free_object (tmp); 663 tmp->destroy ();
701 return 0; 664 return 0;
702 } 665 }
666
667 tmp->map = newmap;
668
703 if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y))) 669 if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y)))
704 { 670 {
705 if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) 671 if (!QUERY_FLAG (tmp, FLAG_REFLECTING))
706 { 672 {
707 free_object (tmp); 673 tmp->destroy ();
708 return 0; 674 return 0;
709 } 675 }
676
710 tmp->x = op->x; 677 tmp->x = op->x;
711 tmp->y = op->y; 678 tmp->y = op->y;
712 tmp->direction = absdir (tmp->direction + 4); 679 tmp->direction = absdir (tmp->direction + 4);
713 tmp->map = op->map; 680 tmp->map = op->map;
714 } 681 }
715 if ((tmp = insert_ob_in_map (tmp, tmp->map, op, 0)) != NULL) 682
716 { 683 if ((tmp = tmp->insert_at (tmp, op)))
717 check_bullet (tmp); 684 check_bullet (tmp);
718 } 685
719 return 1; 686 return 1;
720} 687}
721 688
722 689
723 690
733void 700void
734cone_drop (object *op) 701cone_drop (object *op)
735{ 702{
736 object *new_ob = arch_to_object (op->other_arch); 703 object *new_ob = arch_to_object (op->other_arch);
737 704
738 new_ob->x = op->x;
739 new_ob->y = op->y;
740 new_ob->level = op->level; 705 new_ob->level = op->level;
741 set_owner (new_ob, op->owner); 706 new_ob->set_owner (op->owner);
742 707
743 /* preserve skill ownership */ 708 /* preserve skill ownership */
744 if (op->skill && op->skill != new_ob->skill) 709 if (op->skill && op->skill != new_ob->skill)
745 {
746 new_ob->skill = op->skill; 710 new_ob->skill = op->skill;
747 }
748 insert_ob_in_map (new_ob, op->map, op, 0);
749 711
712 new_ob->insert_at (op, op);
750} 713}
751 714
752/* move_cone: causes cone object 'op' to move a space/hit creatures */ 715/* move_cone: causes cone object 'op' to move a space/hit creatures */
753 716
754void 717void
758 721
759 /* if no map then hit_map will crash so just ignore object */ 722 /* if no map then hit_map will crash so just ignore object */
760 if (!op->map) 723 if (!op->map)
761 { 724 {
762 LOG (llevError, "Tried to move_cone object %s without a map.\n", op->name ? &op->name : "unknown"); 725 LOG (llevError, "Tried to move_cone object %s without a map.\n", op->name ? &op->name : "unknown");
763 op->speed = 0; 726 op->set_speed (0);
764 update_ob_speed (op);
765 return; 727 return;
766 } 728 }
767 729
768 /* lava saves it's life, but not yours :) */ 730 /* lava saves it's life, but not yours :) */
769 if (QUERY_FLAG (op, FLAG_LIFESAVE)) 731 if (QUERY_FLAG (op, FLAG_LIFESAVE))
775#if 0 737#if 0
776 /* Disable this - enabling it makes monsters easier, as 738 /* Disable this - enabling it makes monsters easier, as
777 * when their cone dies when they die. 739 * when their cone dies when they die.
778 */ 740 */
779 /* If no owner left, the spell dies out. */ 741 /* If no owner left, the spell dies out. */
780 if (get_owner (op) == NULL) 742 if (op->owner == NULL)
781 { 743 {
782 remove_ob (op); 744 op->destroy ();
783 free_object (op);
784 return; 745 return;
785 } 746 }
786#endif 747#endif
787 748
788 hit_map (op, 0, op->attacktype, 0); 749 hit_map (op, 0, op->attacktype, 0);
797 if (op->destroyed ()) 758 if (op->destroyed ())
798 return; 759 return;
799 760
800 if ((op->duration--) < 0) 761 if ((op->duration--) < 0)
801 { 762 {
802 remove_ob (op); 763 op->destroy ();
803 free_object (op);
804 return; 764 return;
805 } 765 }
806 /* Object has hit maximum range, so don't have it move 766 /* Object has hit maximum range, so don't have it move
807 * any further. When the duration above expires, 767 * any further. When the duration above expires,
808 * then the object will get removed. 768 * then the object will get removed.
817 { 777 {
818 sint16 x = op->x + freearr_x[absdir (op->stats.sp + i)], y = op->y + freearr_y[absdir (op->stats.sp + i)]; 778 sint16 x = op->x + freearr_x[absdir (op->stats.sp + i)], y = op->y + freearr_y[absdir (op->stats.sp + i)];
819 779
820 if (ok_to_put_more (op->map, x, y, op, op->attacktype)) 780 if (ok_to_put_more (op->map, x, y, op, op->attacktype))
821 { 781 {
822 object *tmp = get_object (); 782 object *tmp = op->clone ();
823
824 copy_object (op, tmp);
825 tmp->x = x;
826 tmp->y = y;
827 783
828 tmp->duration = op->duration + 1; 784 tmp->duration = op->duration + 1;
829 785
830 /* Use for spell tracking - see ok_to_put_more() */ 786 /* Use for spell tracking - see ok_to_put_more() */
831 tmp->stats.maxhp = op->stats.maxhp; 787 tmp->stats.maxhp = op->stats.maxhp;
832 insert_ob_in_map (tmp, op->map, op, 0); 788
789 op->map->insert (tmp, x, y, op);
790
833 if (tmp->other_arch) 791 if (tmp->other_arch)
834 cone_drop (tmp); 792 cone_drop (tmp);
835 } 793 }
836 } 794 }
837} 795}
847int 805int
848cast_cone (object *op, object *caster, int dir, object *spell) 806cast_cone (object *op, object *caster, int dir, object *spell)
849{ 807{
850 object *tmp; 808 object *tmp;
851 int i, success = 0, range_min = -1, range_max = 1; 809 int i, success = 0, range_min = -1, range_max = 1;
852 mapstruct *m; 810 maptile *m;
853 sint16 sx, sy; 811 sint16 sx, sy;
854 MoveType movetype; 812 MoveType movetype;
855 813
856 if (!spell->other_arch) 814 if (!spell->other_arch)
857 return 0; 815 return 0;
913 if ((movetype & GET_MAP_MOVE_BLOCK (m, sx, sy)) == movetype) 871 if ((movetype & GET_MAP_MOVE_BLOCK (m, sx, sy)) == movetype)
914 continue; 872 continue;
915 873
916 success = 1; 874 success = 1;
917 tmp = arch_to_object (spell->other_arch); 875 tmp = arch_to_object (spell->other_arch);
918 set_owner (tmp, op); 876 tmp->set_owner (op);
919 set_spell_skill (op, caster, spell, tmp); 877 set_spell_skill (op, caster, spell, tmp);
920 tmp->level = caster_level (caster, spell); 878 tmp->level = caster_level (caster, spell);
921 tmp->x = sx;
922 tmp->y = sy;
923 tmp->attacktype = spell->attacktype; 879 tmp->attacktype = spell->attacktype;
924 880
925 /* holy word stuff */ 881 /* holy word stuff */
926 if ((tmp->attacktype & AT_HOLYWORD) || (tmp->attacktype & AT_GODPOWER)) 882 if ((tmp->attacktype & AT_HOLYWORD) || (tmp->attacktype & AT_GODPOWER))
927 if (!tailor_god_spell (tmp, op)) 883 if (!tailor_god_spell (tmp, op))
964 920
965 if (!(tmp->move_type & MOVE_FLY_LOW)) 921 if (!(tmp->move_type & MOVE_FLY_LOW))
966 LOG (llevDebug, "cast_cone(): arch %s doesn't have flying 1\n", &spell->other_arch->name); 922 LOG (llevDebug, "cast_cone(): arch %s doesn't have flying 1\n", &spell->other_arch->name);
967 923
968 if (!tmp->move_on && tmp->stats.dam) 924 if (!tmp->move_on && tmp->stats.dam)
969 {
970 LOG (llevDebug, "cast_cone(): arch %s doesn't have move_on set\n", &spell->other_arch->name); 925 LOG (llevDebug, "cast_cone(): arch %s doesn't have move_on set\n", &spell->other_arch->name);
971 }
972 926
973 insert_ob_in_map (tmp, m, op, 0); 927 m->insert (tmp, sx, sy, op);
974 928
975 /* This is used for tracking spells so that one effect doesn't hit 929 /* This is used for tracking spells so that one effect doesn't hit
976 * a single space too many times. 930 * a single space too many times.
977 */ 931 */
978 tmp->stats.maxhp = tmp->count; 932 tmp->stats.maxhp = tmp->count;
997void 951void
998animate_bomb (object *op) 952animate_bomb (object *op)
999{ 953{
1000 int i; 954 int i;
1001 object *env, *tmp; 955 object *env, *tmp;
1002 archetype *at;
1003 956
1004 if (op->state != NUM_ANIMATIONS (op) - 1) 957 if (op->state != NUM_ANIMATIONS (op) - 1)
1005 return; 958 return;
1006 959
1007 env = object_get_env_recursive (op); 960 env = object_get_env_recursive (op);
1012 return; 965 return;
1013 966
1014 if (env->type == PLAYER) 967 if (env->type == PLAYER)
1015 esrv_del_item (env->contr, op->count); 968 esrv_del_item (env->contr, op->count);
1016 969
1017 remove_ob (op); 970 if (!(op = op->insert_at (env, op)))
1018 op->x = env->x;
1019 op->y = env->y;
1020 if ((op = insert_ob_in_map (op, env->map, op, 0)) == NULL)
1021 return; 971 return;
1022 } 972 }
1023 973
1024 // elmex Tue Aug 15 17:46:51 CEST 2006: Prevent bomb from exploding 974 // elmex Tue Aug 15 17:46:51 CEST 2006: Prevent bomb from exploding
1025 // on a safe map. I don't like this special casing, but it seems to be neccessary 975 // on a safe map. I don't like this special casing, but it seems to be neccessary
1026 // as bombs can be carried. 976 // as bombs can be carried.
1027 if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) 977 if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE)
1028 { 978 {
1029 remove_ob (op); 979 op->destroy ();
1030 free_object (op);
1031 return; 980 return;
1032 } 981 }
1033 982
1034 /* This copies a lot of the code from the fire bullet, 983 /* This copies a lot of the code from the fire bullet,
1035 * but using the cast_bullet isn't really feasible, 984 * but using the cast_bullet isn't really feasible,
1036 * so just set up the appropriate values. 985 * so just set up the appropriate values.
1037 */ 986 */
1038 at = archetype::find (SPLINT); 987 if (archetype *at = archetype::find (SPLINT))
1039 if (at)
1040 { 988 {
1041 for (i = 1; i < 9; i++) 989 for (i = 1; i < 9; i++)
1042 { 990 {
1043 if (out_of_map (op->map, op->x + freearr_x[i], op->y + freearr_x[i])) 991 if (out_of_map (op->map, op->x + freearr_x[i], op->y + freearr_x[i]))
1044 continue; 992 continue;
993
1045 tmp = arch_to_object (at); 994 tmp = arch_to_object (at);
1046 tmp->direction = i; 995 tmp->direction = i;
1047 tmp->range = op->range; 996 tmp->range = op->range;
1048 tmp->stats.dam = op->stats.dam; 997 tmp->stats.dam = op->stats.dam;
1049 tmp->duration = op->duration; 998 tmp->duration = op->duration;
1050 tmp->attacktype = op->attacktype; 999 tmp->attacktype = op->attacktype;
1051 copy_owner (tmp, op); 1000 tmp->set_owner (op);
1052 if (op->skill && op->skill != tmp->skill) 1001 if (op->skill && op->skill != tmp->skill)
1053 {
1054 tmp->skill = op->skill; 1002 tmp->skill = op->skill;
1055 } 1003
1056 if (QUERY_FLAG (tmp, FLAG_IS_TURNABLE)) 1004 if (QUERY_FLAG (tmp, FLAG_IS_TURNABLE))
1057 SET_ANIMATION (tmp, i); 1005 SET_ANIMATION (tmp, i);
1058 tmp->x = op->x + freearr_x[i]; 1006
1059 tmp->y = op->y + freearr_x[i]; 1007 op->map->insert (tmp, op->x + freearr_x[i], op->y + freearr_x[i], op);
1060 insert_ob_in_map (tmp, op->map, op, 0);
1061 move_bullet (tmp); 1008 move_bullet (tmp);
1062 } 1009 }
1063 } 1010 }
1064 1011
1065 explode_bullet (op); 1012 explode_bullet (op);
1070{ 1017{
1071 1018
1072 object *tmp; 1019 object *tmp;
1073 int mflags; 1020 int mflags;
1074 sint16 dx = op->x + freearr_x[dir], dy = op->y + freearr_y[dir]; 1021 sint16 dx = op->x + freearr_x[dir], dy = op->y + freearr_y[dir];
1075 mapstruct *m; 1022 maptile *m;
1076 1023
1077 mflags = get_map_flags (op->map, &m, dx, dy, &dx, &dy); 1024 mflags = get_map_flags (op->map, &m, dx, dy, &dx, &dy);
1078 if ((mflags & P_OUT_OF_MAP) || (GET_MAP_MOVE_BLOCK (m, dx, dy) & MOVE_WALK)) 1025 if ((mflags & P_OUT_OF_MAP) || (GET_MAP_MOVE_BLOCK (m, dx, dy) & MOVE_WALK))
1079 { 1026 {
1080 new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way."); 1027 new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way.");
1086 tmp->range = spell->range + SP_level_range_adjust (caster, spell); 1033 tmp->range = spell->range + SP_level_range_adjust (caster, spell);
1087 tmp->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); 1034 tmp->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell);
1088 tmp->duration = spell->duration + SP_level_duration_adjust (caster, spell); 1035 tmp->duration = spell->duration + SP_level_duration_adjust (caster, spell);
1089 tmp->attacktype = spell->attacktype; 1036 tmp->attacktype = spell->attacktype;
1090 1037
1091 set_owner (tmp, op); 1038 tmp->set_owner (op);
1092 set_spell_skill (op, caster, spell, tmp); 1039 set_spell_skill (op, caster, spell, tmp);
1093 tmp->x = dx; 1040
1094 tmp->y = dy; 1041 m->insert (tmp, dx, dy, op);
1095 insert_ob_in_map (tmp, m, op, 0);
1096 return 1; 1042 return 1;
1097} 1043}
1098 1044
1099/**************************************************************************** 1045/****************************************************************************
1100 * 1046 *
1116get_pointed_target (object *op, int dir, int range, int type) 1062get_pointed_target (object *op, int dir, int range, int type)
1117{ 1063{
1118 object *target; 1064 object *target;
1119 sint16 x, y; 1065 sint16 x, y;
1120 int dist, mflags; 1066 int dist, mflags;
1121 mapstruct *mp; 1067 maptile *mp;
1122 1068
1123 if (dir == 0) 1069 if (dir == 0)
1124 return NULL; 1070 return NULL;
1125 1071
1126 for (dist = 1; dist < range; dist++) 1072 for (dist = 1; dist < range; dist++)
1139 if (GET_MAP_MOVE_BLOCK (mp, x, y) & MOVE_FLY_LOW) 1085 if (GET_MAP_MOVE_BLOCK (mp, x, y) & MOVE_FLY_LOW)
1140 return NULL; 1086 return NULL;
1141 1087
1142 if (mflags & P_IS_ALIVE) 1088 if (mflags & P_IS_ALIVE)
1143 { 1089 {
1144 for (target = get_map_ob (mp, x, y); target; target = target->above) 1090 for (target = GET_MAP_OB (mp, x, y); target; target = target->above)
1145 { 1091 {
1146 if (QUERY_FLAG (target->head ? target->head : target, FLAG_MONSTER)) 1092 if (QUERY_FLAG (target->head ? target->head : target, FLAG_MONSTER))
1147 { 1093 {
1148 return target; 1094 return target;
1149 } 1095 }
1216 if (effect->attacktype & AT_DEATH) 1162 if (effect->attacktype & AT_DEATH)
1217 { 1163 {
1218 effect->level = spell->stats.dam + SP_level_dam_adjust (caster, spell); 1164 effect->level = spell->stats.dam + SP_level_dam_adjust (caster, spell);
1219 1165
1220 /* casting death spells at undead isn't a good thing */ 1166 /* casting death spells at undead isn't a good thing */
1221 if QUERY_FLAG
1222 (target, FLAG_UNDEAD) 1167 if (QUERY_FLAG (target, FLAG_UNDEAD))
1223 { 1168 {
1224 if (random_roll (0, 2, op, PREFER_LOW)) 1169 if (random_roll (0, 2, op, PREFER_LOW))
1225 { 1170 {
1226 new_draw_info (NDI_UNIQUE, 0, op, "Idiot! Your spell boomerangs!"); 1171 new_draw_info (NDI_UNIQUE, 0, op, "Idiot! Your spell boomerangs!");
1227 effect->x = op->x; 1172 effect->x = op->x;
1229 } 1174 }
1230 else 1175 else
1231 { 1176 {
1232 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s looks stronger!", query_name (target)); 1177 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s looks stronger!", query_name (target));
1233 target->stats.hp = target->stats.maxhp * 2; 1178 target->stats.hp = target->stats.maxhp * 2;
1234 free_object (effect); 1179 effect->destroy ();
1235 return 0; 1180 return 0;
1236 } 1181 }
1237 } 1182 }
1238 } 1183 }
1239 else 1184 else
1240 { 1185 {
1241 /* how much woe to inflict :) */ 1186 /* how much woe to inflict :) */
1242 effect->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); 1187 effect->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell);
1243 } 1188 }
1244 1189
1245 set_owner (effect, op); 1190 effect->set_owner (op);
1246 set_spell_skill (op, caster, spell, effect); 1191 set_spell_skill (op, caster, spell, effect);
1247 1192
1248 /* ok, tell it where to be, and insert! */ 1193 /* ok, tell it where to be, and insert! */
1249 effect->x = target->x; 1194 effect->insert_at (target, op);
1250 effect->y = target->y;
1251 insert_ob_in_map (effect, target->map, op, 0);
1252 1195
1253 return 1; 1196 return 1;
1254} 1197}
1255 1198
1256 1199
1266move_missile (object *op) 1209move_missile (object *op)
1267{ 1210{
1268 int i, mflags; 1211 int i, mflags;
1269 object *owner; 1212 object *owner;
1270 sint16 new_x, new_y; 1213 sint16 new_x, new_y;
1271 mapstruct *m; 1214 maptile *m;
1272 1215
1273 if (op->range-- <= 0) 1216 if (op->range-- <= 0)
1274 { 1217 {
1275 remove_ob (op); 1218 op->destroy ();
1276 free_object (op);
1277 return; 1219 return;
1278 } 1220 }
1279 1221
1280 owner = get_owner (op); 1222 owner = op->owner;
1281#if 0 1223#if 0
1282 /* It'd make things nastier if this wasn't here - spells cast by 1224 /* It'd make things nastier if this wasn't here - spells cast by
1283 * monster that are then killed would continue to survive 1225 * monster that are then killed would continue to survive
1284 */ 1226 */
1285 if (owner == NULL) 1227 if (owner == NULL)
1286 { 1228 {
1287 remove_ob (op); 1229 op->destroy ();
1288 free_object (op);
1289 return; 1230 return;
1290 } 1231 }
1291#endif 1232#endif
1292 1233
1293 new_x = op->x + DIRX (op); 1234 new_x = op->x + DIRX (op);
1300 hit_map (op, op->direction, AT_MAGIC, 1); 1241 hit_map (op, op->direction, AT_MAGIC, 1);
1301 /* Basically, missile only hits one thing then goes away. 1242 /* Basically, missile only hits one thing then goes away.
1302 * we need to remove it if someone hasn't already done so. 1243 * we need to remove it if someone hasn't already done so.
1303 */ 1244 */
1304 if (!op->destroyed ()) 1245 if (!op->destroyed ())
1305 free_object (op); 1246 op->destroy ();
1306 1247
1307 return; 1248 return;
1308 } 1249 }
1309 1250
1310 remove_ob (op); 1251 op->remove ();
1311 1252
1312 if (!op->direction || (mflags & P_OUT_OF_MAP)) 1253 if (!op->direction || (mflags & P_OUT_OF_MAP))
1313 { 1254 {
1314 free_object (op); 1255 op->destroy ();
1315 return; 1256 return;
1316 } 1257 }
1317 1258
1318 op->x = new_x; 1259 i = spell_find_dir (m, new_x, new_y, op->owner);
1319 op->y = new_y;
1320 op->map = m;
1321 i = spell_find_dir (op->map, op->x, op->y, get_owner (op));
1322 if (i > 0 && i != op->direction) 1260 if (i > 0 && i != op->direction)
1323 { 1261 {
1324 op->direction = i; 1262 op->direction = i;
1325 SET_ANIMATION (op, op->direction); 1263 SET_ANIMATION (op, op->direction);
1326 } 1264 }
1327 1265
1328 insert_ob_in_map (op, op->map, op, 0); 1266 m->insert (op, new_x, new_y, op);
1329} 1267}
1330 1268
1331/**************************************************************************** 1269/****************************************************************************
1332 * Destruction 1270 * Destruction
1333 ****************************************************************************/ 1271 ****************************************************************************/
1378int 1316int
1379cast_destruction (object *op, object *caster, object *spell_ob) 1317cast_destruction (object *op, object *caster, object *spell_ob)
1380{ 1318{
1381 int i, j, range, mflags, friendly = 0, dam, dur; 1319 int i, j, range, mflags, friendly = 0, dam, dur;
1382 sint16 sx, sy; 1320 sint16 sx, sy;
1383 mapstruct *m; 1321 maptile *m;
1384 object *tmp; 1322 object *tmp;
1385 const char *skill; 1323 const char *skill;
1386 1324
1387 range = spell_ob->range + SP_level_range_adjust (caster, spell_ob); 1325 range = spell_ob->range + SP_level_range_adjust (caster, spell_ob);
1388 dam = spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob); 1326 dam = spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob);
1411 for (j = -range; j < range; j++) 1349 for (j = -range; j < range; j++)
1412 { 1350 {
1413 m = op->map; 1351 m = op->map;
1414 sx = op->x + i; 1352 sx = op->x + i;
1415 sy = op->y + j; 1353 sy = op->y + j;
1354
1416 mflags = get_map_flags (m, &m, sx, sy, &sx, &sy); 1355 mflags = get_map_flags (m, &m, sx, sy, &sx, &sy);
1417 if (mflags & P_OUT_OF_MAP) 1356 if (mflags & P_OUT_OF_MAP)
1418 continue; 1357 continue;
1358
1419 if (mflags & P_IS_ALIVE) 1359 if (mflags & P_IS_ALIVE)
1420 { 1360 {
1421 for (tmp = get_map_ob (m, sx, sy); tmp; tmp = tmp->above) 1361 for (tmp = GET_MAP_OB (m, sx, sy); tmp; tmp = tmp->above)
1422 {
1423 if (QUERY_FLAG (tmp, FLAG_ALIVE) || tmp->type == PLAYER) 1362 if (QUERY_FLAG (tmp, FLAG_ALIVE) || tmp->type == PLAYER)
1424 break; 1363 break;
1425 } 1364
1426 if (tmp) 1365 if (tmp)
1427 { 1366 {
1428 if (tmp->head) 1367 if (tmp->head)
1429 tmp = tmp->head; 1368 tmp = tmp->head;
1430 1369
1433 { 1372 {
1434 if (spell_ob->subtype == SP_DESTRUCTION) 1373 if (spell_ob->subtype == SP_DESTRUCTION)
1435 { 1374 {
1436 hit_player (tmp, dam, op, spell_ob->attacktype, 0); 1375 hit_player (tmp, dam, op, spell_ob->attacktype, 0);
1437 if (spell_ob->other_arch) 1376 if (spell_ob->other_arch)
1438 {
1439 tmp = arch_to_object (spell_ob->other_arch); 1377 m->insert (arch_to_object (spell_ob->other_arch), sx, sy, op);
1440 tmp->x = sx;
1441 tmp->y = sy;
1442 insert_ob_in_map (tmp, m, op, 0);
1443 }
1444 } 1378 }
1445 else if (spell_ob->subtype == SP_FAERY_FIRE && tmp->resist[ATNR_MAGIC] != 100) 1379 else if (spell_ob->subtype == SP_FAERY_FIRE && tmp->resist[ATNR_MAGIC] != 100)
1446 { 1380 {
1447 if (make_object_glow (tmp, 1, dur) && spell_ob->other_arch) 1381 if (make_object_glow (tmp, 1, dur) && spell_ob->other_arch)
1448 {
1449 object *effect = arch_to_object (spell_ob->other_arch); 1382 m->insert (arch_to_object (spell_ob->other_arch), sx, sy, op);
1450
1451 effect->x = sx;
1452 effect->y = sy;
1453 insert_ob_in_map (effect, m, op, 0);
1454 }
1455 } 1383 }
1456 } 1384 }
1457 } 1385 }
1458 } 1386 }
1459 } 1387 }
1460 } 1388 }
1389
1461 op->skill = skill; 1390 op->skill = skill;
1462 return 1; 1391 return 1;
1463} 1392}
1464 1393
1465/*************************************************************************** 1394/***************************************************************************
1549 force->stats.ac = spell_ob->stats.ac; 1478 force->stats.ac = spell_ob->stats.ac;
1550 force->stats.wc = spell_ob->stats.wc; 1479 force->stats.wc = spell_ob->stats.wc;
1551 1480
1552 change_abil (tmp, force); /* Mostly to display any messages */ 1481 change_abil (tmp, force); /* Mostly to display any messages */
1553 insert_ob_in_ob (force, tmp); 1482 insert_ob_in_ob (force, tmp);
1554 fix_player (tmp); 1483 tmp->update_stats ();
1555 return 1; 1484 return 1;
1556 1485
1557} 1486}
1558
1559 1487
1560/********************************************************************** 1488/**********************************************************************
1561 * mood change 1489 * mood change
1562 * Arguably, this may or may not be an attack spell. But since it 1490 * Arguably, this may or may not be an attack spell. But since it
1563 * effects monsters, it seems best to put it into this file 1491 * effects monsters, it seems best to put it into this file
1570mood_change (object *op, object *caster, object *spell) 1498mood_change (object *op, object *caster, object *spell)
1571{ 1499{
1572 object *tmp, *god, *head; 1500 object *tmp, *god, *head;
1573 int done_one, range, mflags, level, at, best_at; 1501 int done_one, range, mflags, level, at, best_at;
1574 sint16 x, y, nx, ny; 1502 sint16 x, y, nx, ny;
1575 mapstruct *m; 1503 maptile *m;
1576 const char *race; 1504 const char *race;
1577 1505
1578 /* We precompute some values here so that we don't have to keep 1506 /* We precompute some values here so that we don't have to keep
1579 * doing it over and over again. 1507 * doing it over and over again.
1580 */ 1508 */
1593 else if (god && !strcmp (spell->race, "GOD_FRIEND")) 1521 else if (god && !strcmp (spell->race, "GOD_FRIEND"))
1594 race = god->race; 1522 race = god->race;
1595 else 1523 else
1596 race = spell->race; 1524 race = spell->race;
1597 1525
1598
1599 for (x = op->x - range; x <= op->x + range; x++) 1526 for (x = op->x - range; x <= op->x + range; x++)
1600 for (y = op->y - range; y <= op->y + range; y++) 1527 for (y = op->y - range; y <= op->y + range; y++)
1601 { 1528 {
1602
1603 done_one = 0; 1529 done_one = 0;
1604 m = op->map; 1530 m = op->map;
1605 nx = x; 1531 nx = x;
1606 ny = y; 1532 ny = y;
1607 mflags = get_map_flags (m, &m, x, y, &nx, &ny); 1533 mflags = get_map_flags (m, &m, x, y, &nx, &ny);
1610 1536
1611 /* If there is nothing living on this space, no need to go further */ 1537 /* If there is nothing living on this space, no need to go further */
1612 if (!(mflags & P_IS_ALIVE)) 1538 if (!(mflags & P_IS_ALIVE))
1613 continue; 1539 continue;
1614 1540
1541 // players can only affect spaces that they can actually see
1542 if (caster && caster->contr
1543 && caster->contr->visibility_at (m, nx, ny) < 70)
1544 continue;
1545
1615 for (tmp = get_map_ob (m, nx, ny); tmp; tmp = tmp->above) 1546 for (tmp = GET_MAP_TOP (m, nx, ny); tmp; tmp = tmp->below)
1616 if (QUERY_FLAG (tmp, FLAG_MONSTER)) 1547 if (QUERY_FLAG (tmp, FLAG_MONSTER))
1617 break; 1548 break;
1618 1549
1619 /* There can be living objects that are not monsters */ 1550 /* There can be living objects that are not monsters */
1620 if (!tmp || tmp->type == PLAYER) 1551 if (!tmp || tmp->type == PLAYER)
1627 head = tmp; 1558 head = tmp;
1628 1559
1629 /* Make sure the race is OK. Likewise, only effect undead if spell specifically allows it */ 1560 /* Make sure the race is OK. Likewise, only effect undead if spell specifically allows it */
1630 if (race && head->race && !strstr (race, head->race)) 1561 if (race && head->race && !strstr (race, head->race))
1631 continue; 1562 continue;
1563
1632 if (QUERY_FLAG (head, FLAG_UNDEAD) && !QUERY_FLAG (spell, FLAG_UNDEAD)) 1564 if (QUERY_FLAG (head, FLAG_UNDEAD) && !QUERY_FLAG (spell, FLAG_UNDEAD))
1633 continue; 1565 continue;
1634 1566
1635 /* Now do a bunch of stuff related to saving throws */ 1567 /* Now do a bunch of stuff related to saving throws */
1636 best_at = -1; 1568 best_at = -1;
1673 if (random_roll (0, 100, caster, PREFER_LOW) >= (20 + MIN (50, 2 * (level - head->level)))) 1605 if (random_roll (0, 100, caster, PREFER_LOW) >= (20 + MIN (50, 2 * (level - head->level))))
1674 /* Failed, no effect */ 1606 /* Failed, no effect */
1675 continue; 1607 continue;
1676 } 1608 }
1677 1609
1678 /* Done with saving throw. Now start effecting the monster */ 1610 /* Done with saving throw. Now start affecting the monster */
1679 1611
1680 /* aggravation */ 1612 /* aggravation */
1681 if (QUERY_FLAG (spell, FLAG_MONSTER)) 1613 if (QUERY_FLAG (spell, FLAG_MONSTER))
1682 { 1614 {
1683 CLEAR_FLAG (head, FLAG_SLEEP); 1615 CLEAR_FLAG (head, FLAG_SLEEP);
1700 if (QUERY_FLAG (spell, FLAG_BERSERK) && !QUERY_FLAG (head, FLAG_BERSERK)) 1632 if (QUERY_FLAG (spell, FLAG_BERSERK) && !QUERY_FLAG (head, FLAG_BERSERK))
1701 { 1633 {
1702 SET_FLAG (head, FLAG_BERSERK); 1634 SET_FLAG (head, FLAG_BERSERK);
1703 done_one = 1; 1635 done_one = 1;
1704 } 1636 }
1637
1705 /* charm */ 1638 /* charm */
1706 if (QUERY_FLAG (spell, FLAG_NO_ATTACK) && !QUERY_FLAG (head, FLAG_FRIENDLY)) 1639 if (QUERY_FLAG (spell, FLAG_NO_ATTACK) && !QUERY_FLAG (head, FLAG_FRIENDLY))
1707 { 1640 {
1708 SET_FLAG (head, FLAG_FRIENDLY);
1709 /* Prevent uncontolled outbreaks of self replicating monsters. 1641 /* Prevent uncontolled outbreaks of self replicating monsters.
1710 Typical use case is charm, go somwhere, use aggravation to make hostile. 1642 Typical use case is charm, go somwhere, use aggravation to make hostile.
1711 This could lead to fun stuff like mice outbreak in bigworld and server crawl. */ 1643 This could lead to fun stuff like mice outbreak in bigworld and server crawl. */
1712 CLEAR_FLAG (head, FLAG_GENERATOR); 1644 CLEAR_FLAG (head, FLAG_GENERATOR);
1713 set_owner (head, op); 1645 head->set_owner (op);
1714 set_spell_skill (op, caster, spell, head); 1646 set_spell_skill (op, caster, spell, head);
1715 add_friendly_object (head); 1647 add_friendly_object (head);
1716 head->attack_movement = PETMOVE; 1648 head->attack_movement = PETMOVE;
1717 done_one = 1; 1649 done_one = 1;
1718 change_exp (op, head->stats.exp / 2, head->skill, SK_EXP_ADD_SKILL); 1650 change_exp (op, head->stats.exp / 2, head->skill, SK_EXP_ADD_SKILL);
1719 head->stats.exp = 0; 1651 head->stats.exp = 0;
1720 } 1652 }
1721 1653
1722 /* If a monster was effected, put an effect in */ 1654 /* If a monster was effected, put an effect in */
1723 if (done_one && spell->other_arch) 1655 if (done_one && spell->other_arch)
1724 {
1725 tmp = arch_to_object (spell->other_arch); 1656 m->insert (arch_to_object (spell->other_arch), nx, ny, op);
1726 tmp->x = nx;
1727 tmp->y = ny;
1728 insert_ob_in_map (tmp, m, op, 0);
1729 }
1730 } /* for y */ 1657 } /* for y */
1731 1658
1732 return 1; 1659 return 1;
1733} 1660}
1734 1661
1744move_ball_spell (object *op) 1671move_ball_spell (object *op)
1745{ 1672{
1746 int i, j, dam_save, dir, mflags; 1673 int i, j, dam_save, dir, mflags;
1747 sint16 nx, ny, hx, hy; 1674 sint16 nx, ny, hx, hy;
1748 object *owner; 1675 object *owner;
1749 mapstruct *m; 1676 maptile *m;
1750 1677
1751 owner = get_owner (op); 1678 owner = op->owner;
1752 1679
1753 /* the following logic makes sure that the ball doesn't move into a wall, 1680 /* the following logic makes sure that the ball doesn't move into a wall,
1754 * and makes sure that it will move along a wall to try and get at it's 1681 * and makes sure that it will move along a wall to try and get at it's
1755 * victim. The block immediately below more or less chooses a random 1682 * victim. The block immediately below more or less chooses a random
1756 * offset to move the ball, eg, keep it mostly on course, with some 1683 * offset to move the ball, eg, keep it mostly on course, with some
1785 nx = op->x; 1712 nx = op->x;
1786 ny = op->y; 1713 ny = op->y;
1787 m = op->map; 1714 m = op->map;
1788 } 1715 }
1789 1716
1790 remove_ob (op); 1717 m->insert (op, nx, ny, op);
1791 op->y = ny;
1792 op->x = nx;
1793 insert_ob_in_map (op, m, op, 0);
1794 1718
1795 dam_save = op->stats.dam; /* save the original dam: we do halfdam on 1719 dam_save = op->stats.dam; /* save the original dam: we do halfdam on
1796 surrounding squares */ 1720 surrounding squares */
1797 1721
1798 /* loop over current square and neighbors to hit. 1722 /* loop over current square and neighbors to hit.
1824 1748
1825 } 1749 }
1826 1750
1827 /* insert the other arch */ 1751 /* insert the other arch */
1828 if (op->other_arch && !(OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, hx, hy)))) 1752 if (op->other_arch && !(OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, hx, hy))))
1829 { 1753 m->insert (arch_to_object (op->other_arch), hx, hy, op);
1830 new_ob = arch_to_object (op->other_arch);
1831 new_ob->x = hx;
1832 new_ob->y = hy;
1833 insert_ob_in_map (new_ob, m, op, 0);
1834 }
1835 } 1754 }
1836 1755
1837 /* restore to the center location and damage */ 1756 /* restore to the center location and damage */
1838 op->stats.dam = dam_save; 1757 op->stats.dam = dam_save;
1839 1758
1840 i = spell_find_dir (op->map, op->x, op->y, get_owner (op)); 1759 i = spell_find_dir (op->map, op->x, op->y, op->owner);
1841 1760
1842 if (i >= 0) 1761 if (i >= 0)
1843 { /* we have a preferred direction! */ 1762 { /* we have a preferred direction! */
1844 /* pick another direction if the preferred dir is blocked. */ 1763 /* pick another direction if the preferred dir is blocked. */
1845 if (get_map_flags (op->map, &m, nx + freearr_x[i], ny + freearr_y[i], &hx, &hy) & P_OUT_OF_MAP || 1764 if (get_map_flags (op->map, &m, nx + freearr_x[i], ny + freearr_y[i], &hx, &hy) & P_OUT_OF_MAP ||
1846 OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, hx, hy))) 1765 OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, hx, hy)))
1847 {
1848 i = absdir (i + rndm (0, 2) - 1); /* -1, 0, +1 */ 1766 i = absdir (i + rndm (0, 2) - 1); /* -1, 0, +1 */
1849 } 1767
1850 op->direction = i; 1768 op->direction = i;
1851 } 1769 }
1852} 1770}
1853 1771
1854 1772
1866#if 0 1784#if 0
1867 static int cardinal_adjust[9] = { -3, -2, -1, 0, 0, 0, 1, 2, 3 }; 1785 static int cardinal_adjust[9] = { -3, -2, -1, 0, 0, 0, 1, 2, 3 };
1868 static int diagonal_adjust[10] = { -3, -2, -2, -1, 0, 0, 1, 2, 2, 3 }; 1786 static int diagonal_adjust[10] = { -3, -2, -2, -1, 0, 0, 1, 2, 2, 3 };
1869 sint16 target_x, target_y, origin_x, origin_y; 1787 sint16 target_x, target_y, origin_x, origin_y;
1870 int adjustdir; 1788 int adjustdir;
1871 mapstruct *m; 1789 maptile *m;
1872#endif 1790#endif
1873 int basedir; 1791 int basedir;
1874 object *owner; 1792 object *owner;
1875 1793
1876 owner = get_owner (op); 1794 owner = op->owner;
1877 if (op->duration == 0 || owner == NULL) 1795 if (op->duration == 0 || owner == NULL)
1878 { 1796 {
1879 remove_ob (op); 1797 op->destroy ();
1880 free_object (op);
1881 return; 1798 return;
1882 } 1799 }
1800
1883 op->duration--; 1801 op->duration--;
1884 1802
1885 basedir = op->direction; 1803 basedir = op->direction;
1886 if (basedir == 0) 1804 if (basedir == 0)
1887 { 1805 {
1984 1902
1985 if (!spell->other_arch) 1903 if (!spell->other_arch)
1986 return 0; 1904 return 0;
1987 1905
1988 tmp = get_archetype (SWARM_SPELL); 1906 tmp = get_archetype (SWARM_SPELL);
1989 tmp->x = op->x;
1990 tmp->y = op->y;
1991 set_owner (tmp, op); /* needed so that if swarm elements kill, caster gets xp. */ 1907 tmp->set_owner (op); /* needed so that if swarm elements kill, caster gets xp. */
1992 set_spell_skill (op, caster, spell, tmp); 1908 set_spell_skill (op, caster, spell, tmp);
1993 1909
1994 tmp->level = caster_level (caster, spell); /*needed later, to get level dep. right. */ 1910 tmp->level = caster_level (caster, spell); /*needed later, to get level dep. right. */
1995 tmp->spell = arch_to_object (spell->other_arch); 1911 tmp->spell = arch_to_object (spell->other_arch);
1996 1912
1997 tmp->attacktype = tmp->spell->attacktype; 1913 tmp->attacktype = tmp->spell->attacktype;
1998 1914
1999 if (tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER) 1915 if (tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER)
2000 {
2001 if (!tailor_god_spell (tmp, op)) 1916 if (!tailor_god_spell (tmp, op))
2002 return 1; 1917 return 1;
2003 } 1918
2004 tmp->duration = SP_level_duration_adjust (caster, spell); 1919 tmp->duration = SP_level_duration_adjust (caster, spell);
2005 for (i = 0; i < spell->duration; i++) 1920 for (i = 0; i < spell->duration; i++)
2006 tmp->duration += die_roll (1, 3, op, PREFER_HIGH); 1921 tmp->duration += die_roll (1, 3, op, PREFER_HIGH);
2007 1922
2008 tmp->direction = dir; 1923 tmp->direction = dir;
2009 tmp->invisible = 1; 1924 tmp->invisible = 1;
2010 insert_ob_in_map (tmp, op->map, op, 0); 1925
1926 tmp->insert_at (op, op);
2011 return 1; 1927 return 1;
2012} 1928}
2013 1929
2014 1930
2015/* See the spells documentation file for why this is its own 1931/* See the spells documentation file for why this is its own
2019cast_light (object *op, object *caster, object *spell, int dir) 1935cast_light (object *op, object *caster, object *spell, int dir)
2020{ 1936{
2021 object *target = NULL, *tmp = NULL; 1937 object *target = NULL, *tmp = NULL;
2022 sint16 x, y; 1938 sint16 x, y;
2023 int dam, mflags; 1939 int dam, mflags;
2024 mapstruct *m; 1940 maptile *m;
2025 1941
2026 dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); 1942 dam = spell->stats.dam + SP_level_dam_adjust (caster, spell);
2027 1943
2028 if (!dir) 1944 if (!dir)
2029 { 1945 {
2043 return 0; 1959 return 0;
2044 } 1960 }
2045 1961
2046 if (mflags & P_IS_ALIVE && spell->attacktype) 1962 if (mflags & P_IS_ALIVE && spell->attacktype)
2047 { 1963 {
2048 for (target = get_map_ob (m, x, y); target; target = target->above) 1964 for (target = GET_MAP_OB (m, x, y); target; target = target->above)
2049 if (QUERY_FLAG (target, FLAG_MONSTER)) 1965 if (QUERY_FLAG (target, FLAG_MONSTER))
2050 { 1966 {
2051 /* oky doky. got a target monster. Lets make a blinding attack */ 1967 /* oky doky. got a target monster. Lets make a blinding attack */
2052 if (target->head) 1968 if (target->head)
2053 target = target->head; 1969 target = target->head;
2075 { 1991 {
2076 tmp->glow_radius = spell->range + SP_level_range_adjust (caster, spell); 1992 tmp->glow_radius = spell->range + SP_level_range_adjust (caster, spell);
2077 if (tmp->glow_radius > MAX_LIGHT_RADII) 1993 if (tmp->glow_radius > MAX_LIGHT_RADII)
2078 tmp->glow_radius = MAX_LIGHT_RADII; 1994 tmp->glow_radius = MAX_LIGHT_RADII;
2079 } 1995 }
2080 tmp->x = x; 1996
2081 tmp->y = y; 1997 m->insert (tmp, x, y, op);
2082 insert_ob_in_map (tmp, m, op, 0);
2083 return 1; 1998 return 1;
2084} 1999}
2085 2000
2086 2001
2087 2002
2097cast_cause_disease (object *op, object *caster, object *spell, int dir) 2012cast_cause_disease (object *op, object *caster, object *spell, int dir)
2098{ 2013{
2099 sint16 x, y; 2014 sint16 x, y;
2100 int i, mflags, range, dam_mod, dur_mod; 2015 int i, mflags, range, dam_mod, dur_mod;
2101 object *walk; 2016 object *walk;
2102 mapstruct *m; 2017 maptile *m;
2103 2018
2104 x = op->x; 2019 x = op->x;
2105 y = op->y; 2020 y = op->y;
2106 2021
2107 /* If casting from a scroll, no direction will be available, so refer to the 2022 /* If casting from a scroll, no direction will be available, so refer to the
2135 2050
2136 /* Only bother looking on this space if there is something living here */ 2051 /* Only bother looking on this space if there is something living here */
2137 if (mflags & P_IS_ALIVE) 2052 if (mflags & P_IS_ALIVE)
2138 { 2053 {
2139 /* search this square for a victim */ 2054 /* search this square for a victim */
2140 for (walk = get_map_ob (m, x, y); walk; walk = walk->above) 2055 for (walk = GET_MAP_OB (m, x, y); walk; walk = walk->above)
2141 if (QUERY_FLAG (walk, FLAG_MONSTER) || (walk->type == PLAYER)) 2056 if (QUERY_FLAG (walk, FLAG_MONSTER) || (walk->type == PLAYER))
2142 { /* found a victim */ 2057 { /* found a victim */
2143 object *disease = arch_to_object (spell->other_arch); 2058 object *disease = arch_to_object (spell->other_arch);
2144 2059
2145 set_owner (disease, op); 2060 disease->set_owner (op);
2146 set_spell_skill (op, caster, spell, disease); 2061 set_spell_skill (op, caster, spell, disease);
2147 disease->stats.exp = 0; 2062 disease->stats.exp = 0;
2148 disease->level = caster_level (caster, spell); 2063 disease->level = caster_level (caster, spell);
2149 2064
2150 /* do level adjustments */ 2065 /* do level adjustments */
2199 { 2114 {
2200 object *flash; /* visual effect for inflicting disease */ 2115 object *flash; /* visual effect for inflicting disease */
2201 2116
2202 new_draw_info_format (NDI_UNIQUE, 0, op, "You inflict %s on %s!", &disease->name, &walk->name); 2117 new_draw_info_format (NDI_UNIQUE, 0, op, "You inflict %s on %s!", &disease->name, &walk->name);
2203 2118
2204 free_object (disease); /* don't need this one anymore */ 2119 disease->destroy (); /* don't need this one anymore */
2205 flash = get_archetype (ARCH_DETECT_MAGIC); 2120 walk->map->insert (get_archetype (ARCH_DETECT_MAGIC), x, y, op);
2206 flash->x = x;
2207 flash->y = y;
2208 flash->map = walk->map;
2209 insert_ob_in_map (flash, walk->map, op, 0);
2210 return 1; 2121 return 1;
2211 } 2122 }
2212 free_object (disease); 2123
2124 disease->destroy ();
2213 } 2125 }
2214 } /* if living creature */ 2126 } /* if living creature */
2215 } /* for range of spaces */ 2127 } /* for range of spaces */
2128
2216 new_draw_info (NDI_UNIQUE, 0, op, "No one caught anything!"); 2129 new_draw_info (NDI_UNIQUE, 0, op, "No one caught anything!");
2217 return 1; 2130 return 1;
2218} 2131}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines