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.9 by root, Sun Sep 10 15:59:57 2006 UTC vs.
Revision 1.27 by root, Mon Jan 8 01:19:04 2007 UTC

1
2/*
3 * static char *rcsid_spell_attack_c =
4 * "$Id: spell_attack.C,v 1.9 2006/09/10 15:59:57 root Exp $";
5 */
6
7
8/* 1/*
9 CrossFire, A Multiplayer game for X-windows 2 CrossFire, A Multiplayer game for X-windows
10 3
4 Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team
11 Copyright (C) 2002-2003 Mark Wedel & Crossfire Development Team 5 Copyright (C) 2002-2003 Mark Wedel & Crossfire Development Team
12 Copyright (C) 1992 Frank Tore Johansen 6 Copyright (C) 1992 Frank Tore Johansen
13 7
14 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
15 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
23 17
24 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
25 along with this program; if not, write to the Free Software 19 along with this program; if not, write to the Free Software
26 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 21
28 The authors can be reached via e-mail at crossfire-devel@real-time.com 22 The authors can be reached via e-mail at <crossfire@schmorp.de>
29*/ 23*/
30 24
31/* This file contains all the spell attack code. Grouping this code 25/* This file contains all the spell attack code. Grouping this code
32 * together should hopefully make it easier to find the relevent bits 26 * together should hopefully make it easier to find the relevent bits
33 * of code 27 * of code
34 */ 28 */
35 29
36#include <global.h> 30#include <global.h>
37#include <object.h> 31#include <object.h>
38#include <living.h> 32#include <living.h>
39#ifndef __CEXTRACT__
40# include <sproto.h> 33#include <sproto.h>
41#endif
42#include <spells.h> 34#include <spells.h>
43#include <sounds.h> 35#include <sounds.h>
44 36
45/* 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
46 * 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)
64 { 56 {
65 weight_move = op->weight + (op->weight * op->level) / 3; 57 weight_move = op->weight + (op->weight * op->level) / 3;
66 /*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); */
67 } 59 }
68 60
69 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)
70 { 62 {
71 int num_sections = 1; 63 int num_sections = 1;
72 64
73 /* don't move DM */ 65 /* don't move DM */
74 if (QUERY_FLAG (tmp, FLAG_WIZ)) 66 if (QUERY_FLAG (tmp, FLAG_WIZ))
124void 116void
125forklightning (object *op, object *tmp) 117forklightning (object *op, object *tmp)
126{ 118{
127 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 */
128 int t_dir; /* stores temporary dir calculation */ 120 int t_dir; /* stores temporary dir calculation */
129 mapstruct *m; 121 maptile *m;
130 sint16 sx, sy; 122 sint16 sx, sy;
131 object *new_bolt; 123 object *new_bolt;
132 124
133 /* pick a fork direction. tmp->stats.Con is the left bias 125 /* pick a fork direction. tmp->stats.Con is the left bias
134 * i.e., the chance in 100 of forking LEFT 126 * i.e., the chance in 100 of forking LEFT
147 139
148 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)))
149 return; 141 return;
150 142
151 /* OK, we made a fork */ 143 /* OK, we made a fork */
152 new_bolt = get_object (); 144 new_bolt = tmp->clone ();
153 copy_object (tmp, new_bolt);
154 145
155 /* reduce chances of subsequent forking */ 146 /* reduce chances of subsequent forking */
156 new_bolt->stats.Dex -= 10; 147 new_bolt->stats.Dex -= 10;
157 tmp->stats.Dex -= 10; /* less forks from main bolt too */ 148 tmp->stats.Dex -= 10; /* less forks from main bolt too */
158 new_bolt->stats.Con += 25 * new_dir; /* adjust the left bias */ 149 new_bolt->stats.Con += 25 * new_dir; /* adjust the left bias */
159 new_bolt->speed_left = -0.1; 150 new_bolt->speed_left = -0.1;
160 new_bolt->direction = t_dir; 151 new_bolt->direction = t_dir;
161 new_bolt->duration++; 152 new_bolt->duration++;
162 new_bolt->x = sx;
163 new_bolt->y = sy;
164 new_bolt->stats.dam /= 2; /* reduce daughter bolt damage */ 153 new_bolt->stats.dam /= 2; /* reduce daughter bolt damage */
165 new_bolt->stats.dam++; 154 new_bolt->stats.dam++;
166 tmp->stats.dam /= 2; /* reduce father bolt damage */ 155 tmp->stats.dam /= 2; /* reduce father bolt damage */
167 tmp->stats.dam++; 156 tmp->stats.dam++;
168 new_bolt = insert_ob_in_map (new_bolt, m, op, 0); 157 if ((new_bolt = m->insert (new_bolt, sx, sy, op)))
169 update_turn_face (new_bolt); 158 update_turn_face (new_bolt);
170} 159}
171 160
172/* move_bolt: moves bolt 'op'. Basically, it just advances a space, 161/* move_bolt: moves bolt 'op'. Basically, it just advances a space,
173 * and checks for various things that may stop it. 162 * and checks for various things that may stop it.
174 */ 163 */
177move_bolt (object *op) 166move_bolt (object *op)
178{ 167{
179 object *tmp; 168 object *tmp;
180 int mflags; 169 int mflags;
181 sint16 x, y; 170 sint16 x, y;
182 mapstruct *m; 171 maptile *m;
183 172
184 if (--(op->duration) < 0) 173 if (--op->duration < 0)
185 { 174 {
186 remove_ob (op); 175 op->destroy ();
187 free_object (op);
188 return; 176 return;
189 } 177 }
178
190 hit_map (op, 0, op->attacktype, 1); 179 hit_map (op, 0, op->attacktype, 1);
191 180
192 if (!op->direction) 181 if (!op->direction)
193 return; 182 return;
194 183
195 if (--op->range < 0) 184 if (--op->range < 0)
196 {
197 op->range = 0; 185 op->range = 0;
198 }
199 else 186 else
200 { 187 {
201 x = op->x + DIRX (op); 188 x = op->x + DIRX (op);
202 y = op->y + DIRY (op); 189 y = op->y + DIRY (op);
203 m = op->map; 190 m = op->map;
211 * 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
212 * will be useful. 199 * will be useful.
213 */ 200 */
214 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)))
215 { 202 {
216
217 if (!QUERY_FLAG (op, FLAG_REFLECTING)) 203 if (!QUERY_FLAG (op, FLAG_REFLECTING))
218 return; 204 return;
219 205
220 /* Since walls don't run diagonal, if the bolt is in 206 /* Since walls don't run diagonal, if the bolt is in
221 * one of 4 main directions, it just reflects back in the 207 * one of 4 main directions, it just reflects back in the
251 else if (left) 237 else if (left)
252 op->direction = absdir (op->direction + 2); 238 op->direction = absdir (op->direction + 2);
253 else if (right) 239 else if (right)
254 op->direction = absdir (op->direction - 2); 240 op->direction = absdir (op->direction - 2);
255 } 241 }
242
256 update_turn_face (op); /* A bolt *must* be IS_TURNABLE */ 243 update_turn_face (op); /* A bolt *must* be IS_TURNABLE */
257 return; 244 return;
258 } 245 }
259 else 246 else
260 { /* Create a copy of this object and put it ahead */ 247 { /* Create a copy of this object and put it ahead */
261 tmp = get_object (); 248 object *tmp = op->clone ();
262 copy_object (op, tmp); 249
250 m->insert (tmp, x, y, op);
263 tmp->speed_left = -0.1; 251 tmp->speed_left = -0.1;
264 tmp->x += DIRX (tmp), tmp->y += DIRY (tmp);
265 tmp = insert_ob_in_map (tmp, op->map, op, 0);
266 /* 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 */
267 tmp->duration++; 253 tmp->duration++;
268 254
269 /* New forking code. Possibly create forks of this object 255 /* New forking code. Possibly create forks of this object
270 * going off in other directions. 256 * going off in other directions.
271 */ 257 */
272
273 if (rndm (0, 99) < tmp->stats.Dex) 258 if (rndm (0, 99) < tmp->stats.Dex)
274 { /* stats.Dex % of forking */ 259 { /* stats.Dex % of forking */
275 forklightning (op, tmp); 260 forklightning (op, tmp);
276 } 261 }
262
277 /* 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
278 * doesn't create any bolts that continue to move onward. 264 * doesn't create any bolts that continue to move onward.
279 */ 265 */
280 op->range = 0; 266 op->range = 0;
281 } /* copy object and move it along */ 267 } /* copy object and move it along */
288 * we remove the magic flag - that can be derived from 274 * we remove the magic flag - that can be derived from
289 * spob->attacktype. 275 * spob->attacktype.
290 * This function sets up the appropriate owner and skill 276 * This function sets up the appropriate owner and skill
291 * pointers. 277 * pointers.
292 */ 278 */
293
294int 279int
295fire_bolt (object *op, object *caster, int dir, object *spob, object *skill) 280fire_bolt (object *op, object *caster, int dir, object *spob, object *skill)
296{ 281{
297 object *tmp = NULL; 282 object *tmp = NULL;
298 int mflags; 283 int mflags;
316 301
317 tmp->direction = dir; 302 tmp->direction = dir;
318 if (QUERY_FLAG (tmp, FLAG_IS_TURNABLE)) 303 if (QUERY_FLAG (tmp, FLAG_IS_TURNABLE))
319 SET_ANIMATION (tmp, dir); 304 SET_ANIMATION (tmp, dir);
320 305
321 set_owner (tmp, op); 306 tmp->set_owner (op);
322 set_spell_skill (op, caster, spob, tmp); 307 set_spell_skill (op, caster, spob, tmp);
323 308
324 tmp->x = op->x + DIRX (tmp); 309 tmp->x = op->x + DIRX (tmp);
325 tmp->y = op->y + DIRY (tmp); 310 tmp->y = op->y + DIRY (tmp);
326 tmp->map = op->map; 311 tmp->map = op->map;
327 312
313 maptile *newmap;
328 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);
329 if (mflags & P_OUT_OF_MAP) 315 if (mflags & P_OUT_OF_MAP)
330 { 316 {
331 free_object (tmp); 317 tmp->destroy ();
332 return 0; 318 return 0;
333 } 319 }
320
321 tmp->map = newmap;
322
334 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)))
335 { 324 {
336 if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) 325 if (!QUERY_FLAG (tmp, FLAG_REFLECTING))
337 { 326 {
338 free_object (tmp); 327 tmp->destroy ();
339 return 0; 328 return 0;
340 } 329 }
330
341 tmp->x = op->x; 331 tmp->x = op->x;
342 tmp->y = op->y; 332 tmp->y = op->y;
343 tmp->direction = absdir (tmp->direction + 4); 333 tmp->direction = absdir (tmp->direction + 4);
344 tmp->map = op->map; 334 tmp->map = op->map;
345 } 335 }
346 if ((tmp = insert_ob_in_map (tmp, tmp->map, op, 0)) != NULL) 336
337 if ((tmp = tmp->insert_at (tmp, op)))
347 move_bolt (tmp); 338 move_bolt (tmp);
339
348 return 1; 340 return 1;
349} 341}
350 342
351 343
352 344
361 * At least that is what I think this does. 353 * At least that is what I think this does.
362 */ 354 */
363void 355void
364explosion (object *op) 356explosion (object *op)
365{ 357{
366 object *tmp;
367 mapstruct *m = op->map; 358 maptile *m = op->map;
368 int i; 359 int i;
369 360
370 if (--(op->duration) < 0) 361 if (--op->duration < 0)
371 { 362 {
372 remove_ob (op); 363 op->destroy ();
373 free_object (op);
374 return; 364 return;
375 } 365 }
366
376 hit_map (op, 0, op->attacktype, 0); 367 hit_map (op, 0, op->attacktype, 0);
377 368
378 if (op->range > 0) 369 if (op->range > 0)
379 { 370 {
380 for (i = 1; i < 9; i++) 371 for (i = 1; i < 9; i++)
381 { 372 {
382 sint16 dx, dy; 373 sint16 dx, dy;
383 374
384 dx = op->x + freearr_x[i]; 375 dx = op->x + freearr_x[i];
385 dy = op->y + freearr_y[i]; 376 dy = op->y + freearr_y[i];
377
386 /* ok_to_put_more already does things like checks for walls, 378 /* ok_to_put_more already does things like checks for walls,
387 * out of map, etc. 379 * out of map, etc.
388 */ 380 */
389 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))
390 { 382 {
391 tmp = get_object (); 383 object *tmp = op->clone ();
392 copy_object (op, tmp); 384
393 tmp->state = 0; 385 tmp->state = 0;
394 tmp->speed_left = -0.21; 386 tmp->speed_left = -0.21;
395 tmp->range--; 387 tmp->range--;
396 tmp->value = 0; 388 tmp->value = 0;
397 tmp->x = dx; 389
398 tmp->y = dy; 390 m->insert (tmp, dx, dy, op);
399 insert_ob_in_map (tmp, m, op, 0);
400 } 391 }
401 } 392 }
402 } 393 }
403} 394}
404 395
408 * explode. 399 * explode.
409 */ 400 */
410void 401void
411explode_bullet (object *op) 402explode_bullet (object *op)
412{ 403{
413 tag_t op_tag = op->count;
414 object *tmp, *owner; 404 object *tmp, *owner;
415 405
416 if (op->other_arch == NULL) 406 if (op->other_arch == NULL)
417 { 407 {
418 LOG (llevError, "BUG: explode_bullet(): op without other_arch\n"); 408 LOG (llevError, "BUG: explode_bullet(): op without other_arch\n");
419 remove_ob (op); 409 op->destroy ();
420 free_object (op);
421 return; 410 return;
422 } 411 }
423 412
424 if (op->env) 413 if (op->env)
425 { 414 {
426 object *env;
427
428 env = object_get_env_recursive (op); 415 object *env = object_get_env_recursive (op);
429 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))
430 { 417 {
431 LOG (llevError, "BUG: explode_bullet(): env out of map\n"); 418 LOG (llevError, "BUG: explode_bullet(): env out of map\n");
432 remove_ob (op); 419 op->destroy ();
433 free_object (op);
434 return; 420 return;
435 } 421 }
436 remove_ob (op); 422
437 op->x = env->x; 423 op->insert_at (env, op, INS_NO_MERGE | INS_NO_WALK_ON);
438 op->y = env->y;
439 insert_ob_in_map (op, env->map, op, INS_NO_MERGE | INS_NO_WALK_ON);
440 } 424 }
441 else if (out_of_map (op->map, op->x, op->y)) 425 else if (out_of_map (op->map, op->x, op->y))
442 { 426 {
443 LOG (llevError, "BUG: explode_bullet(): op out of map\n"); 427 LOG (llevError, "BUG: explode_bullet(): op out of map\n");
444 remove_ob (op); 428 op->destroy ();
445 free_object (op);
446 return; 429 return;
447 } 430 }
448 431
449 // 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
450 // 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
451 // bad at the moment that might happen from this. 434 // bad at the moment that might happen from this.
452 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)
453 { 436 {
454 remove_ob (op); 437 op->destroy ();
455 free_object (op);
456 return; 438 return;
457 } 439 }
458 440
459 if (op->attacktype) 441 if (op->attacktype)
460 { 442 {
461 hit_map (op, 0, op->attacktype, 1); 443 hit_map (op, 0, op->attacktype, 1);
462 if (was_destroyed (op, op_tag)) 444 if (op->destroyed ())
463 return; 445 return;
464 } 446 }
465 447
466 /* other_arch contains what this explodes into */ 448 /* other_arch contains what this explodes into */
467 tmp = arch_to_object (op->other_arch); 449 tmp = arch_to_object (op->other_arch);
468 450
469 copy_owner (tmp, op); 451 tmp->set_owner (op);
470 tmp->skill = op->skill; 452 tmp->skill = op->skill;
471 453
472 owner = get_owner (op); 454 owner = op->owner;
455
473 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))
474 { 457 {
475 remove_ob (op); 458 op->destroy ();
476 free_object (op);
477 return; 459 return;
478 } 460 }
479 tmp->x = op->x;
480 tmp->y = op->y;
481 461
482 /* special for bombs - it actually has sane values for these */ 462 /* special for bombs - it actually has sane values for these */
483 if (op->type == SPELL_EFFECT && op->subtype == SP_BOMB) 463 if (op->type == SPELL_EFFECT && op->subtype == SP_BOMB)
484 { 464 {
485 tmp->attacktype = op->attacktype; 465 tmp->attacktype = op->attacktype;
489 } 469 }
490 else 470 else
491 { 471 {
492 if (op->attacktype & AT_MAGIC) 472 if (op->attacktype & AT_MAGIC)
493 tmp->attacktype |= AT_MAGIC; 473 tmp->attacktype |= AT_MAGIC;
474
494 /* Spell doc describes what is going on here */ 475 /* Spell doc describes what is going on here */
495 tmp->stats.dam = op->dam_modifier; 476 tmp->stats.dam = op->dam_modifier;
496 tmp->range = op->stats.maxhp; 477 tmp->range = op->stats.maxhp;
497 tmp->duration = op->stats.hp; 478 tmp->duration = op->stats.hp;
498 /* 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 -
506 tmp->stats.sp = op->direction; 487 tmp->stats.sp = op->direction;
507 488
508 /* Prevent recursion */ 489 /* Prevent recursion */
509 op->move_on = 0; 490 op->move_on = 0;
510 491
511 insert_ob_in_map (tmp, op->map, op, 0); 492 tmp->insert_at (op, op);
512 /* remove the firebullet */ 493 /* remove the firebullet */
513 if (!was_destroyed (op, op_tag)) 494 op->destroy ();
514 {
515 remove_ob (op);
516 free_object (op);
517 }
518} 495}
519
520
521 496
522/* 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
523 * (eg, explode, damage player, etc) 498 * (eg, explode, damage player, etc)
524 */ 499 */
525
526void 500void
527check_bullet (object *op) 501check_bullet (object *op)
528{ 502{
529 tag_t op_tag = op->count, tmp_tag;
530 object *tmp; 503 object *tmp;
531 int dam, mflags; 504 int dam, mflags;
532 mapstruct *m; 505 maptile *m;
533 sint16 sx, sy; 506 sint16 sx, sy;
534 507
535 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);
536 509
537 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)))
546 519
547 /* 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 */
548 if (!(mflags & P_IS_ALIVE)) 521 if (!(mflags & P_IS_ALIVE))
549 return; 522 return;
550 523
551 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)
552 { 525 {
553 if (QUERY_FLAG (tmp, FLAG_ALIVE)) 526 if (QUERY_FLAG (tmp, FLAG_ALIVE))
554 { 527 {
555 tmp_tag = tmp->count;
556 dam = hit_player (tmp, op->stats.dam, op, op->attacktype, 1); 528 dam = hit_player (tmp, op->stats.dam, op, op->attacktype, 1);
557 if (was_destroyed (op, op_tag) || !was_destroyed (tmp, tmp_tag) || (op->stats.dam -= dam) < 0) 529 if (op->destroyed () || !tmp->destroyed () || (op->stats.dam -= dam) < 0)
558 { 530 {
559 if (!QUERY_FLAG (op, FLAG_REMOVED)) 531 if (!QUERY_FLAG (op, FLAG_REMOVED))
560 { 532 {
561 remove_ob (op); 533 op->destroy ();
562 free_object (op);
563 return; 534 return;
564 } 535 }
565 } 536 }
566 } 537 }
567 } 538 }
568} 539}
569
570 540
571/* Basically, we move 'op' one square, and if it hits something, 541/* Basically, we move 'op' one square, and if it hits something,
572 * call check_bullet. 542 * call check_bullet.
573 * This function is only applicable to bullets, but not to all 543 * This function is only applicable to bullets, but not to all
574 * fired arches (eg, bolts). 544 * fired arches (eg, bolts).
575 */ 545 */
576
577void 546void
578move_bullet (object *op) 547move_bullet (object *op)
579{ 548{
580 sint16 new_x, new_y; 549 sint16 new_x, new_y;
581 int mflags; 550 int mflags;
582 mapstruct *m; 551 maptile *m;
583 552
584#if 0 553#if 0
585 /* We need a better general purpose way to do this */ 554 /* We need a better general purpose way to do this */
586 555
587 /* peterm: added to make comet leave a trail of burnouts 556 /* peterm: added to make comet leave a trail of burnouts
588 it's an unadulterated hack, but the effect is cool. */ 557 it's an unadulterated hack, but the effect is cool. */
589 if (op->stats.sp == SP_METEOR) 558 if (op->stats.sp == SP_METEOR)
590 { 559 {
591 replace_insert_ob_in_map ("fire_trail", op); 560 replace_insert_ob_in_map ("fire_trail", op);
592 if (was_destroyed (op, op_tag)) 561 if (op->destroyed ())
593 return; 562 return;
594 } /* end addition. */ 563 } /* end addition. */
595#endif 564#endif
596 565
597 /* Reached the end of its life - remove it */ 566 /* Reached the end of its life - remove it */
598 if (--op->range <= 0) 567 if (--op->range <= 0)
599 { 568 {
600 if (op->other_arch) 569 if (op->other_arch)
601 {
602 explode_bullet (op); 570 explode_bullet (op);
603 }
604 else 571 else
605 { 572 op->destroy ();
606 remove_ob (op); 573
607 free_object (op);
608 }
609 return; 574 return;
610 } 575 }
611 576
612 new_x = op->x + DIRX (op); 577 new_x = op->x + DIRX (op);
613 new_y = op->y + DIRY (op); 578 new_y = op->y + DIRY (op);
614 m = op->map; 579 m = op->map;
615 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);
616 581
617 if (mflags & P_OUT_OF_MAP) 582 if (mflags & P_OUT_OF_MAP)
618 { 583 {
619 remove_ob (op); 584 op->destroy ();
620 free_object (op);
621 return; 585 return;
622 } 586 }
623 587
624 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)))
625 { 589 {
626 if (op->other_arch) 590 if (op->other_arch)
627 {
628 explode_bullet (op); 591 explode_bullet (op);
629 }
630 else 592 else
631 { 593 op->destroy ();
632 remove_ob (op); 594
633 free_object (op);
634 }
635 return; 595 return;
636 } 596 }
637 597
638 remove_ob (op); 598 if (!(op = m->insert (op, new_x, new_y, op)))
639 op->x = new_x;
640 op->y = new_y;
641 if ((op = insert_ob_in_map (op, m, op, 0)) == NULL)
642 return; 599 return;
643 600
644 if (reflwall (op->map, op->x, op->y, op)) 601 if (reflwall (op->map, op->x, op->y, op))
645 { 602 {
646 op->direction = absdir (op->direction + 4); 603 op->direction = absdir (op->direction + 4);
647 update_turn_face (op); 604 update_turn_face (op);
648 } 605 }
649 else 606 else
650 {
651 check_bullet (op); 607 check_bullet (op);
652 }
653} 608}
654 609
655 610
656 611
657 612
692 647
693 tmp->direction = dir; 648 tmp->direction = dir;
694 if (QUERY_FLAG (tmp, FLAG_IS_TURNABLE)) 649 if (QUERY_FLAG (tmp, FLAG_IS_TURNABLE))
695 SET_ANIMATION (tmp, dir); 650 SET_ANIMATION (tmp, dir);
696 651
697 set_owner (tmp, op); 652 tmp->set_owner (op);
698 set_spell_skill (op, caster, spob, tmp); 653 set_spell_skill (op, caster, spob, tmp);
699 654
700 tmp->x = op->x + freearr_x[dir]; 655 tmp->x = op->x + freearr_x[dir];
701 tmp->y = op->y + freearr_y[dir]; 656 tmp->y = op->y + freearr_y[dir];
702 tmp->map = op->map; 657 tmp->map = op->map;
703 658
659 maptile *newmap;
704 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);
705 if (mflags & P_OUT_OF_MAP) 661 if (mflags & P_OUT_OF_MAP)
706 { 662 {
707 free_object (tmp); 663 tmp->destroy ();
708 return 0; 664 return 0;
709 } 665 }
666
667 tmp->map = newmap;
668
710 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)))
711 { 670 {
712 if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) 671 if (!QUERY_FLAG (tmp, FLAG_REFLECTING))
713 { 672 {
714 free_object (tmp); 673 tmp->destroy ();
715 return 0; 674 return 0;
716 } 675 }
676
717 tmp->x = op->x; 677 tmp->x = op->x;
718 tmp->y = op->y; 678 tmp->y = op->y;
719 tmp->direction = absdir (tmp->direction + 4); 679 tmp->direction = absdir (tmp->direction + 4);
720 tmp->map = op->map; 680 tmp->map = op->map;
721 } 681 }
722 if ((tmp = insert_ob_in_map (tmp, tmp->map, op, 0)) != NULL) 682
723 { 683 if ((tmp = tmp->insert_at (tmp, op)))
724 check_bullet (tmp); 684 check_bullet (tmp);
725 } 685
726 return 1; 686 return 1;
727} 687}
728 688
729 689
730 690
740void 700void
741cone_drop (object *op) 701cone_drop (object *op)
742{ 702{
743 object *new_ob = arch_to_object (op->other_arch); 703 object *new_ob = arch_to_object (op->other_arch);
744 704
745 new_ob->x = op->x;
746 new_ob->y = op->y;
747 new_ob->level = op->level; 705 new_ob->level = op->level;
748 set_owner (new_ob, op->owner); 706 new_ob->set_owner (op->owner);
749 707
750 /* preserve skill ownership */ 708 /* preserve skill ownership */
751 if (op->skill && op->skill != new_ob->skill) 709 if (op->skill && op->skill != new_ob->skill)
752 {
753 new_ob->skill = op->skill; 710 new_ob->skill = op->skill;
754 }
755 insert_ob_in_map (new_ob, op->map, op, 0);
756 711
712 new_ob->insert_at (op, op);
757} 713}
758 714
759/* 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 */
760 716
761void 717void
762move_cone (object *op) 718move_cone (object *op)
763{ 719{
764 int i; 720 int i;
765 tag_t tag;
766 721
767 /* 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 */
768 if (!op->map) 723 if (!op->map)
769 { 724 {
770 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");
771 op->speed = 0; 726 op->set_speed (0);
772 update_ob_speed (op);
773 return; 727 return;
774 } 728 }
775 729
776 /* lava saves it's life, but not yours :) */ 730 /* lava saves it's life, but not yours :) */
777 if (QUERY_FLAG (op, FLAG_LIFESAVE)) 731 if (QUERY_FLAG (op, FLAG_LIFESAVE))
783#if 0 737#if 0
784 /* Disable this - enabling it makes monsters easier, as 738 /* Disable this - enabling it makes monsters easier, as
785 * when their cone dies when they die. 739 * when their cone dies when they die.
786 */ 740 */
787 /* If no owner left, the spell dies out. */ 741 /* If no owner left, the spell dies out. */
788 if (get_owner (op) == NULL) 742 if (op->owner == NULL)
789 { 743 {
790 remove_ob (op); 744 op->destroy ();
791 free_object (op);
792 return; 745 return;
793 } 746 }
794#endif 747#endif
795 748
796 tag = op->count;
797 hit_map (op, 0, op->attacktype, 0); 749 hit_map (op, 0, op->attacktype, 0);
798 750
799 /* Check to see if we should push anything. 751 /* Check to see if we should push anything.
800 * Spell objects with weight push whatever they encounter to some 752 * Spell objects with weight push whatever they encounter to some
801 * degree. 753 * degree.
802 */ 754 */
803 if (op->weight) 755 if (op->weight)
804 check_spell_knockback (op); 756 check_spell_knockback (op);
805 757
806 if (was_destroyed (op, tag)) 758 if (op->destroyed ())
807 return; 759 return;
808 760
809 if ((op->duration--) < 0) 761 if ((op->duration--) < 0)
810 { 762 {
811 remove_ob (op); 763 op->destroy ();
812 free_object (op);
813 return; 764 return;
814 } 765 }
815 /* Object has hit maximum range, so don't have it move 766 /* Object has hit maximum range, so don't have it move
816 * any further. When the duration above expires, 767 * any further. When the duration above expires,
817 * then the object will get removed. 768 * then the object will get removed.
826 { 777 {
827 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)];
828 779
829 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))
830 { 781 {
831 object *tmp = get_object (); 782 object *tmp = op->clone ();
832
833 copy_object (op, tmp);
834 tmp->x = x;
835 tmp->y = y;
836 783
837 tmp->duration = op->duration + 1; 784 tmp->duration = op->duration + 1;
838 785
839 /* Use for spell tracking - see ok_to_put_more() */ 786 /* Use for spell tracking - see ok_to_put_more() */
840 tmp->stats.maxhp = op->stats.maxhp; 787 tmp->stats.maxhp = op->stats.maxhp;
841 insert_ob_in_map (tmp, op->map, op, 0); 788
789 op->map->insert (tmp, x, y, op);
790
842 if (tmp->other_arch) 791 if (tmp->other_arch)
843 cone_drop (tmp); 792 cone_drop (tmp);
844 } 793 }
845 } 794 }
846} 795}
856int 805int
857cast_cone (object *op, object *caster, int dir, object *spell) 806cast_cone (object *op, object *caster, int dir, object *spell)
858{ 807{
859 object *tmp; 808 object *tmp;
860 int i, success = 0, range_min = -1, range_max = 1; 809 int i, success = 0, range_min = -1, range_max = 1;
861 mapstruct *m; 810 maptile *m;
862 sint16 sx, sy; 811 sint16 sx, sy;
863 MoveType movetype; 812 MoveType movetype;
864 813
865 if (!spell->other_arch) 814 if (!spell->other_arch)
866 return 0; 815 return 0;
922 if ((movetype & GET_MAP_MOVE_BLOCK (m, sx, sy)) == movetype) 871 if ((movetype & GET_MAP_MOVE_BLOCK (m, sx, sy)) == movetype)
923 continue; 872 continue;
924 873
925 success = 1; 874 success = 1;
926 tmp = arch_to_object (spell->other_arch); 875 tmp = arch_to_object (spell->other_arch);
927 set_owner (tmp, op); 876 tmp->set_owner (op);
928 set_spell_skill (op, caster, spell, tmp); 877 set_spell_skill (op, caster, spell, tmp);
929 tmp->level = caster_level (caster, spell); 878 tmp->level = caster_level (caster, spell);
930 tmp->x = sx;
931 tmp->y = sy;
932 tmp->attacktype = spell->attacktype; 879 tmp->attacktype = spell->attacktype;
933 880
934 /* holy word stuff */ 881 /* holy word stuff */
935 if ((tmp->attacktype & AT_HOLYWORD) || (tmp->attacktype & AT_GODPOWER)) 882 if ((tmp->attacktype & AT_HOLYWORD) || (tmp->attacktype & AT_GODPOWER))
936 {
937 if (!tailor_god_spell (tmp, op)) 883 if (!tailor_god_spell (tmp, op))
938 return 0; 884 return 0;
939 }
940 885
941 if (dir) 886 if (dir)
942 tmp->stats.sp = dir; 887 tmp->stats.sp = dir;
943 else 888 else
944 tmp->stats.sp = i; 889 tmp->stats.sp = i;
950 { 895 {
951 tmp->range /= 4; 896 tmp->range /= 4;
952 if (tmp->range < 2 && spell->range >= 2) 897 if (tmp->range < 2 && spell->range >= 2)
953 tmp->range = 2; 898 tmp->range = 2;
954 } 899 }
900
955 tmp->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); 901 tmp->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell);
956 tmp->duration = spell->duration + SP_level_duration_adjust (caster, spell); 902 tmp->duration = spell->duration + SP_level_duration_adjust (caster, spell);
957 903
958 /* Special bonus for fear attacks */ 904 /* Special bonus for fear attacks */
959 if (tmp->attacktype & AT_FEAR) 905 if (tmp->attacktype & AT_FEAR)
961 if (caster->type == PLAYER) 907 if (caster->type == PLAYER)
962 tmp->duration += fear_bonus[caster->stats.Cha]; 908 tmp->duration += fear_bonus[caster->stats.Cha];
963 else 909 else
964 tmp->duration += caster->level / 3; 910 tmp->duration += caster->level / 3;
965 } 911 }
912
966 if (tmp->attacktype & (AT_HOLYWORD | AT_TURN_UNDEAD)) 913 if (tmp->attacktype & (AT_HOLYWORD | AT_TURN_UNDEAD))
967 { 914 {
968 if (caster->type == PLAYER) 915 if (caster->type == PLAYER)
969 tmp->duration += turn_bonus[caster->stats.Wis] / 5; 916 tmp->duration += turn_bonus[caster->stats.Wis] / 5;
970 else 917 else
971 tmp->duration += caster->level / 3; 918 tmp->duration += caster->level / 3;
972 } 919 }
973 920
974
975 if (!(tmp->move_type & MOVE_FLY_LOW)) 921 if (!(tmp->move_type & MOVE_FLY_LOW))
976 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);
977 923
978 if (!tmp->move_on && tmp->stats.dam) 924 if (!tmp->move_on && tmp->stats.dam)
979 {
980 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);
981 } 926
982 insert_ob_in_map (tmp, m, op, 0); 927 m->insert (tmp, sx, sy, op);
983 928
984 /* 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
985 * a single space too many times. 930 * a single space too many times.
986 */ 931 */
987 tmp->stats.maxhp = tmp->count; 932 tmp->stats.maxhp = tmp->count;
988 933
989 if (tmp->other_arch) 934 if (tmp->other_arch)
990 cone_drop (tmp); 935 cone_drop (tmp);
991 } 936 }
937
992 return success; 938 return success;
993} 939}
994 940
995/**************************************************************************** 941/****************************************************************************
996 * 942 *
1005void 951void
1006animate_bomb (object *op) 952animate_bomb (object *op)
1007{ 953{
1008 int i; 954 int i;
1009 object *env, *tmp; 955 object *env, *tmp;
1010 archetype *at;
1011 956
1012 if (op->state != NUM_ANIMATIONS (op) - 1) 957 if (op->state != NUM_ANIMATIONS (op) - 1)
1013 return; 958 return;
1014 959
1015
1016 env = object_get_env_recursive (op); 960 env = object_get_env_recursive (op);
1017 961
1018 if (op->env) 962 if (op->env)
1019 { 963 {
1020 if (env->map == NULL) 964 if (env->map == NULL)
1021 return; 965 return;
1022 966
1023 if (env->type == PLAYER) 967 if (env->type == PLAYER)
1024 esrv_del_item (env->contr, op->count); 968 esrv_del_item (env->contr, op->count);
1025 969
1026 remove_ob (op); 970 if (!(op = op->insert_at (env, op)))
1027 op->x = env->x;
1028 op->y = env->y;
1029 if ((op = insert_ob_in_map (op, env->map, op, 0)) == NULL)
1030 return; 971 return;
1031 } 972 }
1032 973
1033 // 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
1034 // 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
1035 // as bombs can be carried. 976 // as bombs can be carried.
1036 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)
1037 { 978 {
1038 remove_ob (op); 979 op->destroy ();
1039 free_object (op);
1040 return; 980 return;
1041 } 981 }
1042 982
1043 /* This copies a lot of the code from the fire bullet, 983 /* This copies a lot of the code from the fire bullet,
1044 * but using the cast_bullet isn't really feasible, 984 * but using the cast_bullet isn't really feasible,
1045 * so just set up the appropriate values. 985 * so just set up the appropriate values.
1046 */ 986 */
1047 at = find_archetype (SPLINT); 987 if (archetype *at = archetype::find (SPLINT))
1048 if (at)
1049 { 988 {
1050 for (i = 1; i < 9; i++) 989 for (i = 1; i < 9; i++)
1051 { 990 {
1052 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]))
1053 continue; 992 continue;
993
1054 tmp = arch_to_object (at); 994 tmp = arch_to_object (at);
1055 tmp->direction = i; 995 tmp->direction = i;
1056 tmp->range = op->range; 996 tmp->range = op->range;
1057 tmp->stats.dam = op->stats.dam; 997 tmp->stats.dam = op->stats.dam;
1058 tmp->duration = op->duration; 998 tmp->duration = op->duration;
1059 tmp->attacktype = op->attacktype; 999 tmp->attacktype = op->attacktype;
1060 copy_owner (tmp, op); 1000 tmp->set_owner (op);
1061 if (op->skill && op->skill != tmp->skill) 1001 if (op->skill && op->skill != tmp->skill)
1062 {
1063 tmp->skill = op->skill; 1002 tmp->skill = op->skill;
1064 } 1003
1065 if (QUERY_FLAG (tmp, FLAG_IS_TURNABLE)) 1004 if (QUERY_FLAG (tmp, FLAG_IS_TURNABLE))
1066 SET_ANIMATION (tmp, i); 1005 SET_ANIMATION (tmp, i);
1067 tmp->x = op->x + freearr_x[i]; 1006
1068 tmp->y = op->y + freearr_x[i]; 1007 op->map->insert (tmp, op->x + freearr_x[i], op->y + freearr_x[i], op);
1069 insert_ob_in_map (tmp, op->map, op, 0);
1070 move_bullet (tmp); 1008 move_bullet (tmp);
1071 } 1009 }
1072 } 1010 }
1073 1011
1074 explode_bullet (op); 1012 explode_bullet (op);
1079{ 1017{
1080 1018
1081 object *tmp; 1019 object *tmp;
1082 int mflags; 1020 int mflags;
1083 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];
1084 mapstruct *m; 1022 maptile *m;
1085 1023
1086 mflags = get_map_flags (op->map, &m, dx, dy, &dx, &dy); 1024 mflags = get_map_flags (op->map, &m, dx, dy, &dx, &dy);
1087 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))
1088 { 1026 {
1089 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.");
1095 tmp->range = spell->range + SP_level_range_adjust (caster, spell); 1033 tmp->range = spell->range + SP_level_range_adjust (caster, spell);
1096 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);
1097 tmp->duration = spell->duration + SP_level_duration_adjust (caster, spell); 1035 tmp->duration = spell->duration + SP_level_duration_adjust (caster, spell);
1098 tmp->attacktype = spell->attacktype; 1036 tmp->attacktype = spell->attacktype;
1099 1037
1100 set_owner (tmp, op); 1038 tmp->set_owner (op);
1101 set_spell_skill (op, caster, spell, tmp); 1039 set_spell_skill (op, caster, spell, tmp);
1102 tmp->x = dx; 1040
1103 tmp->y = dy; 1041 m->insert (tmp, dx, dy, op);
1104 insert_ob_in_map (tmp, m, op, 0);
1105 return 1; 1042 return 1;
1106} 1043}
1107 1044
1108/**************************************************************************** 1045/****************************************************************************
1109 * 1046 *
1125get_pointed_target (object *op, int dir, int range, int type) 1062get_pointed_target (object *op, int dir, int range, int type)
1126{ 1063{
1127 object *target; 1064 object *target;
1128 sint16 x, y; 1065 sint16 x, y;
1129 int dist, mflags; 1066 int dist, mflags;
1130 mapstruct *mp; 1067 maptile *mp;
1131 1068
1132 if (dir == 0) 1069 if (dir == 0)
1133 return NULL; 1070 return NULL;
1134 1071
1135 for (dist = 1; dist < range; dist++) 1072 for (dist = 1; dist < range; dist++)
1148 if (GET_MAP_MOVE_BLOCK (mp, x, y) & MOVE_FLY_LOW) 1085 if (GET_MAP_MOVE_BLOCK (mp, x, y) & MOVE_FLY_LOW)
1149 return NULL; 1086 return NULL;
1150 1087
1151 if (mflags & P_IS_ALIVE) 1088 if (mflags & P_IS_ALIVE)
1152 { 1089 {
1153 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)
1154 { 1091 {
1155 if (QUERY_FLAG (target->head ? target->head : target, FLAG_MONSTER)) 1092 if (QUERY_FLAG (target->head ? target->head : target, FLAG_MONSTER))
1156 { 1093 {
1157 return target; 1094 return target;
1158 } 1095 }
1225 if (effect->attacktype & AT_DEATH) 1162 if (effect->attacktype & AT_DEATH)
1226 { 1163 {
1227 effect->level = spell->stats.dam + SP_level_dam_adjust (caster, spell); 1164 effect->level = spell->stats.dam + SP_level_dam_adjust (caster, spell);
1228 1165
1229 /* casting death spells at undead isn't a good thing */ 1166 /* casting death spells at undead isn't a good thing */
1230 if QUERY_FLAG
1231 (target, FLAG_UNDEAD) 1167 if (QUERY_FLAG (target, FLAG_UNDEAD))
1232 { 1168 {
1233 if (random_roll (0, 2, op, PREFER_LOW)) 1169 if (random_roll (0, 2, op, PREFER_LOW))
1234 { 1170 {
1235 new_draw_info (NDI_UNIQUE, 0, op, "Idiot! Your spell boomerangs!"); 1171 new_draw_info (NDI_UNIQUE, 0, op, "Idiot! Your spell boomerangs!");
1236 effect->x = op->x; 1172 effect->x = op->x;
1238 } 1174 }
1239 else 1175 else
1240 { 1176 {
1241 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));
1242 target->stats.hp = target->stats.maxhp * 2; 1178 target->stats.hp = target->stats.maxhp * 2;
1243 free_object (effect); 1179 effect->destroy ();
1244 return 0; 1180 return 0;
1245 } 1181 }
1246 } 1182 }
1247 } 1183 }
1248 else 1184 else
1249 { 1185 {
1250 /* how much woe to inflict :) */ 1186 /* how much woe to inflict :) */
1251 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);
1252 } 1188 }
1253 1189
1254 set_owner (effect, op); 1190 effect->set_owner (op);
1255 set_spell_skill (op, caster, spell, effect); 1191 set_spell_skill (op, caster, spell, effect);
1256 1192
1257 /* ok, tell it where to be, and insert! */ 1193 /* ok, tell it where to be, and insert! */
1258 effect->x = target->x; 1194 effect->insert_at (target, op);
1259 effect->y = target->y;
1260 insert_ob_in_map (effect, target->map, op, 0);
1261 1195
1262 return 1; 1196 return 1;
1263} 1197}
1264 1198
1265 1199
1275move_missile (object *op) 1209move_missile (object *op)
1276{ 1210{
1277 int i, mflags; 1211 int i, mflags;
1278 object *owner; 1212 object *owner;
1279 sint16 new_x, new_y; 1213 sint16 new_x, new_y;
1280 mapstruct *m; 1214 maptile *m;
1281 1215
1282 if (op->range-- <= 0) 1216 if (op->range-- <= 0)
1283 { 1217 {
1284 remove_ob (op); 1218 op->destroy ();
1285 free_object (op);
1286 return; 1219 return;
1287 } 1220 }
1288 1221
1289 owner = get_owner (op); 1222 owner = op->owner;
1290#if 0 1223#if 0
1291 /* 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
1292 * monster that are then killed would continue to survive 1225 * monster that are then killed would continue to survive
1293 */ 1226 */
1294 if (owner == NULL) 1227 if (owner == NULL)
1295 { 1228 {
1296 remove_ob (op); 1229 op->destroy ();
1297 free_object (op);
1298 return; 1230 return;
1299 } 1231 }
1300#endif 1232#endif
1301 1233
1302 new_x = op->x + DIRX (op); 1234 new_x = op->x + DIRX (op);
1304 1236
1305 mflags = get_map_flags (op->map, &m, new_x, new_y, &new_x, &new_y); 1237 mflags = get_map_flags (op->map, &m, new_x, new_y, &new_x, &new_y);
1306 1238
1307 if (!(mflags & P_OUT_OF_MAP) && ((mflags & P_IS_ALIVE) || OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, new_x, new_y)))) 1239 if (!(mflags & P_OUT_OF_MAP) && ((mflags & P_IS_ALIVE) || OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, new_x, new_y))))
1308 { 1240 {
1309 tag_t tag = op->count;
1310
1311 hit_map (op, op->direction, AT_MAGIC, 1); 1241 hit_map (op, op->direction, AT_MAGIC, 1);
1312 /* Basically, missile only hits one thing then goes away. 1242 /* Basically, missile only hits one thing then goes away.
1313 * 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.
1314 */ 1244 */
1315 if (!was_destroyed (op, tag)) 1245 if (!op->destroyed ())
1316 { 1246 op->destroy ();
1317 remove_ob (op); 1247
1318 free_object (op);
1319 }
1320 return; 1248 return;
1321 } 1249 }
1322 1250
1323 remove_ob (op); 1251 op->remove ();
1252
1324 if (!op->direction || (mflags & P_OUT_OF_MAP)) 1253 if (!op->direction || (mflags & P_OUT_OF_MAP))
1325 { 1254 {
1326 free_object (op); 1255 op->destroy ();
1327 return; 1256 return;
1328 } 1257 }
1329 op->x = new_x; 1258
1330 op->y = new_y; 1259 i = spell_find_dir (m, new_x, new_y, op->owner);
1331 op->map = m;
1332 i = spell_find_dir (op->map, op->x, op->y, get_owner (op));
1333 if (i > 0 && i != op->direction) 1260 if (i > 0 && i != op->direction)
1334 { 1261 {
1335 op->direction = i; 1262 op->direction = i;
1336 SET_ANIMATION (op, op->direction); 1263 SET_ANIMATION (op, op->direction);
1337 } 1264 }
1338 insert_ob_in_map (op, op->map, op, 0); 1265
1266 m->insert (op, new_x, new_y, op);
1339} 1267}
1340 1268
1341/**************************************************************************** 1269/****************************************************************************
1342 * Destruction 1270 * Destruction
1343 ****************************************************************************/ 1271 ****************************************************************************/
1388int 1316int
1389cast_destruction (object *op, object *caster, object *spell_ob) 1317cast_destruction (object *op, object *caster, object *spell_ob)
1390{ 1318{
1391 int i, j, range, mflags, friendly = 0, dam, dur; 1319 int i, j, range, mflags, friendly = 0, dam, dur;
1392 sint16 sx, sy; 1320 sint16 sx, sy;
1393 mapstruct *m; 1321 maptile *m;
1394 object *tmp; 1322 object *tmp;
1395 const char *skill; 1323 const char *skill;
1396 1324
1397 range = spell_ob->range + SP_level_range_adjust (caster, spell_ob); 1325 range = spell_ob->range + SP_level_range_adjust (caster, spell_ob);
1398 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);
1421 for (j = -range; j < range; j++) 1349 for (j = -range; j < range; j++)
1422 { 1350 {
1423 m = op->map; 1351 m = op->map;
1424 sx = op->x + i; 1352 sx = op->x + i;
1425 sy = op->y + j; 1353 sy = op->y + j;
1354
1426 mflags = get_map_flags (m, &m, sx, sy, &sx, &sy); 1355 mflags = get_map_flags (m, &m, sx, sy, &sx, &sy);
1427 if (mflags & P_OUT_OF_MAP) 1356 if (mflags & P_OUT_OF_MAP)
1428 continue; 1357 continue;
1358
1429 if (mflags & P_IS_ALIVE) 1359 if (mflags & P_IS_ALIVE)
1430 { 1360 {
1431 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)
1432 {
1433 if (QUERY_FLAG (tmp, FLAG_ALIVE) || tmp->type == PLAYER) 1362 if (QUERY_FLAG (tmp, FLAG_ALIVE) || tmp->type == PLAYER)
1434 break; 1363 break;
1435 } 1364
1436 if (tmp) 1365 if (tmp)
1437 { 1366 {
1438 if (tmp->head) 1367 if (tmp->head)
1439 tmp = tmp->head; 1368 tmp = tmp->head;
1440 1369
1443 { 1372 {
1444 if (spell_ob->subtype == SP_DESTRUCTION) 1373 if (spell_ob->subtype == SP_DESTRUCTION)
1445 { 1374 {
1446 hit_player (tmp, dam, op, spell_ob->attacktype, 0); 1375 hit_player (tmp, dam, op, spell_ob->attacktype, 0);
1447 if (spell_ob->other_arch) 1376 if (spell_ob->other_arch)
1448 {
1449 tmp = arch_to_object (spell_ob->other_arch); 1377 m->insert (arch_to_object (spell_ob->other_arch), sx, sy, op);
1450 tmp->x = sx;
1451 tmp->y = sy;
1452 insert_ob_in_map (tmp, m, op, 0);
1453 }
1454 } 1378 }
1455 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)
1456 { 1380 {
1457 if (make_object_glow (tmp, 1, dur) && spell_ob->other_arch) 1381 if (make_object_glow (tmp, 1, dur) && spell_ob->other_arch)
1458 {
1459 object *effect = arch_to_object (spell_ob->other_arch); 1382 m->insert (arch_to_object (spell_ob->other_arch), sx, sy, op);
1460
1461 effect->x = sx;
1462 effect->y = sy;
1463 insert_ob_in_map (effect, m, op, 0);
1464 }
1465 } 1383 }
1466 } 1384 }
1467 } 1385 }
1468 } 1386 }
1469 } 1387 }
1470 } 1388 }
1389
1471 op->skill = skill; 1390 op->skill = skill;
1472 return 1; 1391 return 1;
1473} 1392}
1474 1393
1475/*************************************************************************** 1394/***************************************************************************
1559 force->stats.ac = spell_ob->stats.ac; 1478 force->stats.ac = spell_ob->stats.ac;
1560 force->stats.wc = spell_ob->stats.wc; 1479 force->stats.wc = spell_ob->stats.wc;
1561 1480
1562 change_abil (tmp, force); /* Mostly to display any messages */ 1481 change_abil (tmp, force); /* Mostly to display any messages */
1563 insert_ob_in_ob (force, tmp); 1482 insert_ob_in_ob (force, tmp);
1564 fix_player (tmp); 1483 tmp->update_stats ();
1565 return 1; 1484 return 1;
1566 1485
1567} 1486}
1568 1487
1569 1488
1580mood_change (object *op, object *caster, object *spell) 1499mood_change (object *op, object *caster, object *spell)
1581{ 1500{
1582 object *tmp, *god, *head; 1501 object *tmp, *god, *head;
1583 int done_one, range, mflags, level, at, best_at; 1502 int done_one, range, mflags, level, at, best_at;
1584 sint16 x, y, nx, ny; 1503 sint16 x, y, nx, ny;
1585 mapstruct *m; 1504 maptile *m;
1586 const char *race; 1505 const char *race;
1587 1506
1588 /* We precompute some values here so that we don't have to keep 1507 /* We precompute some values here so that we don't have to keep
1589 * doing it over and over again. 1508 * doing it over and over again.
1590 */ 1509 */
1620 1539
1621 /* If there is nothing living on this space, no need to go further */ 1540 /* If there is nothing living on this space, no need to go further */
1622 if (!(mflags & P_IS_ALIVE)) 1541 if (!(mflags & P_IS_ALIVE))
1623 continue; 1542 continue;
1624 1543
1625 for (tmp = get_map_ob (m, nx, ny); tmp; tmp = tmp->above) 1544 for (tmp = GET_MAP_OB (m, nx, ny); tmp; tmp = tmp->above)
1626 if (QUERY_FLAG (tmp, FLAG_MONSTER)) 1545 if (QUERY_FLAG (tmp, FLAG_MONSTER))
1627 break; 1546 break;
1628 1547
1629 /* There can be living objects that are not monsters */ 1548 /* There can be living objects that are not monsters */
1630 if (!tmp || tmp->type == PLAYER) 1549 if (!tmp || tmp->type == PLAYER)
1710 if (QUERY_FLAG (spell, FLAG_BERSERK) && !QUERY_FLAG (head, FLAG_BERSERK)) 1629 if (QUERY_FLAG (spell, FLAG_BERSERK) && !QUERY_FLAG (head, FLAG_BERSERK))
1711 { 1630 {
1712 SET_FLAG (head, FLAG_BERSERK); 1631 SET_FLAG (head, FLAG_BERSERK);
1713 done_one = 1; 1632 done_one = 1;
1714 } 1633 }
1634
1715 /* charm */ 1635 /* charm */
1716 if (QUERY_FLAG (spell, FLAG_NO_ATTACK) && !QUERY_FLAG (head, FLAG_FRIENDLY)) 1636 if (QUERY_FLAG (spell, FLAG_NO_ATTACK) && !QUERY_FLAG (head, FLAG_FRIENDLY))
1717 { 1637 {
1718 SET_FLAG (head, FLAG_FRIENDLY);
1719 /* Prevent uncontolled outbreaks of self replicating monsters. 1638 /* Prevent uncontolled outbreaks of self replicating monsters.
1720 Typical use case is charm, go somwhere, use aggravation to make hostile. 1639 Typical use case is charm, go somwhere, use aggravation to make hostile.
1721 This could lead to fun stuff like mice outbreak in bigworld and server crawl. */ 1640 This could lead to fun stuff like mice outbreak in bigworld and server crawl. */
1722 CLEAR_FLAG (head, FLAG_GENERATOR); 1641 CLEAR_FLAG (head, FLAG_GENERATOR);
1723 set_owner (head, op); 1642 head->set_owner (op);
1724 set_spell_skill (op, caster, spell, head); 1643 set_spell_skill (op, caster, spell, head);
1725 add_friendly_object (head); 1644 add_friendly_object (head);
1726 head->attack_movement = PETMOVE; 1645 head->attack_movement = PETMOVE;
1727 done_one = 1; 1646 done_one = 1;
1728 change_exp (op, head->stats.exp / 2, head->skill, SK_EXP_ADD_SKILL); 1647 change_exp (op, head->stats.exp / 2, head->skill, SK_EXP_ADD_SKILL);
1729 head->stats.exp = 0; 1648 head->stats.exp = 0;
1730 } 1649 }
1731 1650
1732 /* If a monster was effected, put an effect in */ 1651 /* If a monster was effected, put an effect in */
1733 if (done_one && spell->other_arch) 1652 if (done_one && spell->other_arch)
1734 {
1735 tmp = arch_to_object (spell->other_arch); 1653 m->insert (arch_to_object (spell->other_arch), nx, ny, op);
1736 tmp->x = nx;
1737 tmp->y = ny;
1738 insert_ob_in_map (tmp, m, op, 0);
1739 }
1740 } /* for y */ 1654 } /* for y */
1741 1655
1742 return 1; 1656 return 1;
1743} 1657}
1744 1658
1754move_ball_spell (object *op) 1668move_ball_spell (object *op)
1755{ 1669{
1756 int i, j, dam_save, dir, mflags; 1670 int i, j, dam_save, dir, mflags;
1757 sint16 nx, ny, hx, hy; 1671 sint16 nx, ny, hx, hy;
1758 object *owner; 1672 object *owner;
1759 mapstruct *m; 1673 maptile *m;
1760 1674
1761 owner = get_owner (op); 1675 owner = op->owner;
1762 1676
1763 /* the following logic makes sure that the ball doesn't move into a wall, 1677 /* the following logic makes sure that the ball doesn't move into a wall,
1764 * and makes sure that it will move along a wall to try and get at it's 1678 * and makes sure that it will move along a wall to try and get at it's
1765 * victim. The block immediately below more or less chooses a random 1679 * victim. The block immediately below more or less chooses a random
1766 * offset to move the ball, eg, keep it mostly on course, with some 1680 * offset to move the ball, eg, keep it mostly on course, with some
1795 nx = op->x; 1709 nx = op->x;
1796 ny = op->y; 1710 ny = op->y;
1797 m = op->map; 1711 m = op->map;
1798 } 1712 }
1799 1713
1800 remove_ob (op); 1714 m->insert (op, nx, ny, op);
1801 op->y = ny;
1802 op->x = nx;
1803 insert_ob_in_map (op, m, op, 0);
1804 1715
1805 dam_save = op->stats.dam; /* save the original dam: we do halfdam on 1716 dam_save = op->stats.dam; /* save the original dam: we do halfdam on
1806 surrounding squares */ 1717 surrounding squares */
1807 1718
1808 /* loop over current square and neighbors to hit. 1719 /* loop over current square and neighbors to hit.
1834 1745
1835 } 1746 }
1836 1747
1837 /* insert the other arch */ 1748 /* insert the other arch */
1838 if (op->other_arch && !(OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, hx, hy)))) 1749 if (op->other_arch && !(OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, hx, hy))))
1839 { 1750 m->insert (arch_to_object (op->other_arch), hx, hy, op);
1840 new_ob = arch_to_object (op->other_arch);
1841 new_ob->x = hx;
1842 new_ob->y = hy;
1843 insert_ob_in_map (new_ob, m, op, 0);
1844 }
1845 } 1751 }
1846 1752
1847 /* restore to the center location and damage */ 1753 /* restore to the center location and damage */
1848 op->stats.dam = dam_save; 1754 op->stats.dam = dam_save;
1849 1755
1850 i = spell_find_dir (op->map, op->x, op->y, get_owner (op)); 1756 i = spell_find_dir (op->map, op->x, op->y, op->owner);
1851 1757
1852 if (i >= 0) 1758 if (i >= 0)
1853 { /* we have a preferred direction! */ 1759 { /* we have a preferred direction! */
1854 /* pick another direction if the preferred dir is blocked. */ 1760 /* pick another direction if the preferred dir is blocked. */
1855 if (get_map_flags (op->map, &m, nx + freearr_x[i], ny + freearr_y[i], &hx, &hy) & P_OUT_OF_MAP || 1761 if (get_map_flags (op->map, &m, nx + freearr_x[i], ny + freearr_y[i], &hx, &hy) & P_OUT_OF_MAP ||
1856 OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, hx, hy))) 1762 OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, hx, hy)))
1857 {
1858 i = absdir (i + rndm (0, 2) - 1); /* -1, 0, +1 */ 1763 i = absdir (i + rndm (0, 2) - 1); /* -1, 0, +1 */
1859 } 1764
1860 op->direction = i; 1765 op->direction = i;
1861 } 1766 }
1862} 1767}
1863 1768
1864 1769
1876#if 0 1781#if 0
1877 static int cardinal_adjust[9] = { -3, -2, -1, 0, 0, 0, 1, 2, 3 }; 1782 static int cardinal_adjust[9] = { -3, -2, -1, 0, 0, 0, 1, 2, 3 };
1878 static int diagonal_adjust[10] = { -3, -2, -2, -1, 0, 0, 1, 2, 2, 3 }; 1783 static int diagonal_adjust[10] = { -3, -2, -2, -1, 0, 0, 1, 2, 2, 3 };
1879 sint16 target_x, target_y, origin_x, origin_y; 1784 sint16 target_x, target_y, origin_x, origin_y;
1880 int adjustdir; 1785 int adjustdir;
1881 mapstruct *m; 1786 maptile *m;
1882#endif 1787#endif
1883 int basedir; 1788 int basedir;
1884 object *owner; 1789 object *owner;
1885 1790
1886 owner = get_owner (op); 1791 owner = op->owner;
1887 if (op->duration == 0 || owner == NULL) 1792 if (op->duration == 0 || owner == NULL)
1888 { 1793 {
1889 remove_ob (op); 1794 op->destroy ();
1890 free_object (op);
1891 return; 1795 return;
1892 } 1796 }
1797
1893 op->duration--; 1798 op->duration--;
1894 1799
1895 basedir = op->direction; 1800 basedir = op->direction;
1896 if (basedir == 0) 1801 if (basedir == 0)
1897 { 1802 {
1994 1899
1995 if (!spell->other_arch) 1900 if (!spell->other_arch)
1996 return 0; 1901 return 0;
1997 1902
1998 tmp = get_archetype (SWARM_SPELL); 1903 tmp = get_archetype (SWARM_SPELL);
1999 tmp->x = op->x;
2000 tmp->y = op->y;
2001 set_owner (tmp, op); /* needed so that if swarm elements kill, caster gets xp. */ 1904 tmp->set_owner (op); /* needed so that if swarm elements kill, caster gets xp. */
2002 set_spell_skill (op, caster, spell, tmp); 1905 set_spell_skill (op, caster, spell, tmp);
2003 1906
2004 tmp->level = caster_level (caster, spell); /*needed later, to get level dep. right. */ 1907 tmp->level = caster_level (caster, spell); /*needed later, to get level dep. right. */
2005 tmp->spell = arch_to_object (spell->other_arch); 1908 tmp->spell = arch_to_object (spell->other_arch);
2006 1909
2007 tmp->attacktype = tmp->spell->attacktype; 1910 tmp->attacktype = tmp->spell->attacktype;
2008 1911
2009 if (tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER) 1912 if (tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER)
2010 {
2011 if (!tailor_god_spell (tmp, op)) 1913 if (!tailor_god_spell (tmp, op))
2012 return 1; 1914 return 1;
2013 } 1915
2014 tmp->duration = SP_level_duration_adjust (caster, spell); 1916 tmp->duration = SP_level_duration_adjust (caster, spell);
2015 for (i = 0; i < spell->duration; i++) 1917 for (i = 0; i < spell->duration; i++)
2016 tmp->duration += die_roll (1, 3, op, PREFER_HIGH); 1918 tmp->duration += die_roll (1, 3, op, PREFER_HIGH);
2017 1919
2018 tmp->direction = dir; 1920 tmp->direction = dir;
2019 tmp->invisible = 1; 1921 tmp->invisible = 1;
2020 insert_ob_in_map (tmp, op->map, op, 0); 1922
1923 tmp->insert_at (op, op);
2021 return 1; 1924 return 1;
2022} 1925}
2023 1926
2024 1927
2025/* See the spells documentation file for why this is its own 1928/* See the spells documentation file for why this is its own
2029cast_light (object *op, object *caster, object *spell, int dir) 1932cast_light (object *op, object *caster, object *spell, int dir)
2030{ 1933{
2031 object *target = NULL, *tmp = NULL; 1934 object *target = NULL, *tmp = NULL;
2032 sint16 x, y; 1935 sint16 x, y;
2033 int dam, mflags; 1936 int dam, mflags;
2034 mapstruct *m; 1937 maptile *m;
2035 1938
2036 dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); 1939 dam = spell->stats.dam + SP_level_dam_adjust (caster, spell);
2037 1940
2038 if (!dir) 1941 if (!dir)
2039 { 1942 {
2053 return 0; 1956 return 0;
2054 } 1957 }
2055 1958
2056 if (mflags & P_IS_ALIVE && spell->attacktype) 1959 if (mflags & P_IS_ALIVE && spell->attacktype)
2057 { 1960 {
2058 for (target = get_map_ob (m, x, y); target; target = target->above) 1961 for (target = GET_MAP_OB (m, x, y); target; target = target->above)
2059 if (QUERY_FLAG (target, FLAG_MONSTER)) 1962 if (QUERY_FLAG (target, FLAG_MONSTER))
2060 { 1963 {
2061 /* oky doky. got a target monster. Lets make a blinding attack */ 1964 /* oky doky. got a target monster. Lets make a blinding attack */
2062 if (target->head) 1965 if (target->head)
2063 target = target->head; 1966 target = target->head;
2085 { 1988 {
2086 tmp->glow_radius = spell->range + SP_level_range_adjust (caster, spell); 1989 tmp->glow_radius = spell->range + SP_level_range_adjust (caster, spell);
2087 if (tmp->glow_radius > MAX_LIGHT_RADII) 1990 if (tmp->glow_radius > MAX_LIGHT_RADII)
2088 tmp->glow_radius = MAX_LIGHT_RADII; 1991 tmp->glow_radius = MAX_LIGHT_RADII;
2089 } 1992 }
2090 tmp->x = x; 1993
2091 tmp->y = y; 1994 m->insert (tmp, x, y, op);
2092 insert_ob_in_map (tmp, m, op, 0);
2093 return 1; 1995 return 1;
2094} 1996}
2095 1997
2096 1998
2097 1999
2107cast_cause_disease (object *op, object *caster, object *spell, int dir) 2009cast_cause_disease (object *op, object *caster, object *spell, int dir)
2108{ 2010{
2109 sint16 x, y; 2011 sint16 x, y;
2110 int i, mflags, range, dam_mod, dur_mod; 2012 int i, mflags, range, dam_mod, dur_mod;
2111 object *walk; 2013 object *walk;
2112 mapstruct *m; 2014 maptile *m;
2113 2015
2114 x = op->x; 2016 x = op->x;
2115 y = op->y; 2017 y = op->y;
2116 2018
2117 /* If casting from a scroll, no direction will be available, so refer to the 2019 /* If casting from a scroll, no direction will be available, so refer to the
2145 2047
2146 /* Only bother looking on this space if there is something living here */ 2048 /* Only bother looking on this space if there is something living here */
2147 if (mflags & P_IS_ALIVE) 2049 if (mflags & P_IS_ALIVE)
2148 { 2050 {
2149 /* search this square for a victim */ 2051 /* search this square for a victim */
2150 for (walk = get_map_ob (m, x, y); walk; walk = walk->above) 2052 for (walk = GET_MAP_OB (m, x, y); walk; walk = walk->above)
2151 if (QUERY_FLAG (walk, FLAG_MONSTER) || (walk->type == PLAYER)) 2053 if (QUERY_FLAG (walk, FLAG_MONSTER) || (walk->type == PLAYER))
2152 { /* found a victim */ 2054 { /* found a victim */
2153 object *disease = arch_to_object (spell->other_arch); 2055 object *disease = arch_to_object (spell->other_arch);
2154 2056
2155 set_owner (disease, op); 2057 disease->set_owner (op);
2156 set_spell_skill (op, caster, spell, disease); 2058 set_spell_skill (op, caster, spell, disease);
2157 disease->stats.exp = 0; 2059 disease->stats.exp = 0;
2158 disease->level = caster_level (caster, spell); 2060 disease->level = caster_level (caster, spell);
2159 2061
2160 /* do level adjustments */ 2062 /* do level adjustments */
2209 { 2111 {
2210 object *flash; /* visual effect for inflicting disease */ 2112 object *flash; /* visual effect for inflicting disease */
2211 2113
2212 new_draw_info_format (NDI_UNIQUE, 0, op, "You inflict %s on %s!", &disease->name, &walk->name); 2114 new_draw_info_format (NDI_UNIQUE, 0, op, "You inflict %s on %s!", &disease->name, &walk->name);
2213 2115
2214 free_object (disease); /* don't need this one anymore */ 2116 disease->destroy (); /* don't need this one anymore */
2215 flash = get_archetype (ARCH_DETECT_MAGIC); 2117 walk->map->insert (get_archetype (ARCH_DETECT_MAGIC), x, y, op);
2216 flash->x = x;
2217 flash->y = y;
2218 flash->map = walk->map;
2219 insert_ob_in_map (flash, walk->map, op, 0);
2220 return 1; 2118 return 1;
2221 } 2119 }
2222 free_object (disease); 2120
2121 disease->destroy ();
2223 } 2122 }
2224 } /* if living creature */ 2123 } /* if living creature */
2225 } /* for range of spaces */ 2124 } /* for range of spaces */
2125
2226 new_draw_info (NDI_UNIQUE, 0, op, "No one caught anything!"); 2126 new_draw_info (NDI_UNIQUE, 0, op, "No one caught anything!");
2227 return 1; 2127 return 1;
2228} 2128}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines