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.15 by root, Sat Sep 16 22:24:13 2006 UTC vs.
Revision 1.16 by root, Tue Dec 12 20:53:03 2006 UTC

174 sint16 x, y; 174 sint16 x, y;
175 maptile *m; 175 maptile *m;
176 176
177 if (--(op->duration) < 0) 177 if (--(op->duration) < 0)
178 { 178 {
179 remove_ob (op); 179 op->remove ();
180 free_object (op); 180 op->destroy (0);
181 return; 181 return;
182 } 182 }
183 183
184 hit_map (op, 0, op->attacktype, 1); 184 hit_map (op, 0, op->attacktype, 1);
185 185
320 tmp->map = op->map; 320 tmp->map = op->map;
321 321
322 mflags = get_map_flags (tmp->map, &tmp->map, tmp->x, tmp->y, &tmp->x, &tmp->y); 322 mflags = get_map_flags (tmp->map, &tmp->map, tmp->x, tmp->y, &tmp->x, &tmp->y);
323 if (mflags & P_OUT_OF_MAP) 323 if (mflags & P_OUT_OF_MAP)
324 { 324 {
325 free_object (tmp); 325 tmp->destroy (0);
326 return 0; 326 return 0;
327 } 327 }
328 if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y))) 328 if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y)))
329 { 329 {
330 if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) 330 if (!QUERY_FLAG (tmp, FLAG_REFLECTING))
331 { 331 {
332 free_object (tmp); 332 tmp->destroy (0);
333 return 0; 333 return 0;
334 } 334 }
335 tmp->x = op->x; 335 tmp->x = op->x;
336 tmp->y = op->y; 336 tmp->y = op->y;
337 tmp->direction = absdir (tmp->direction + 4); 337 tmp->direction = absdir (tmp->direction + 4);
361 maptile *m = op->map; 361 maptile *m = op->map;
362 int i; 362 int i;
363 363
364 if (--(op->duration) < 0) 364 if (--(op->duration) < 0)
365 { 365 {
366 remove_ob (op); 366 op->remove ();
367 free_object (op); 367 op->destroy (0);
368 return; 368 return;
369 } 369 }
370 hit_map (op, 0, op->attacktype, 0); 370 hit_map (op, 0, op->attacktype, 0);
371 371
372 if (op->range > 0) 372 if (op->range > 0)
407 object *tmp, *owner; 407 object *tmp, *owner;
408 408
409 if (op->other_arch == NULL) 409 if (op->other_arch == NULL)
410 { 410 {
411 LOG (llevError, "BUG: explode_bullet(): op without other_arch\n"); 411 LOG (llevError, "BUG: explode_bullet(): op without other_arch\n");
412 remove_ob (op); 412 op->remove ();
413 free_object (op); 413 op->destroy (0);
414 return; 414 return;
415 } 415 }
416 416
417 if (op->env) 417 if (op->env)
418 { 418 {
420 420
421 env = object_get_env_recursive (op); 421 env = object_get_env_recursive (op);
422 if (env->map == NULL || out_of_map (env->map, env->x, env->y)) 422 if (env->map == NULL || out_of_map (env->map, env->x, env->y))
423 { 423 {
424 LOG (llevError, "BUG: explode_bullet(): env out of map\n"); 424 LOG (llevError, "BUG: explode_bullet(): env out of map\n");
425 remove_ob (op); 425 op->remove ();
426 free_object (op); 426 op->destroy (0);
427 return; 427 return;
428 } 428 }
429 remove_ob (op); 429 op->remove ();
430 op->x = env->x; 430 op->x = env->x;
431 op->y = env->y; 431 op->y = env->y;
432 insert_ob_in_map (op, env->map, op, INS_NO_MERGE | INS_NO_WALK_ON); 432 insert_ob_in_map (op, env->map, op, INS_NO_MERGE | INS_NO_WALK_ON);
433 } 433 }
434 else if (out_of_map (op->map, op->x, op->y)) 434 else if (out_of_map (op->map, op->x, op->y))
435 { 435 {
436 LOG (llevError, "BUG: explode_bullet(): op out of map\n"); 436 LOG (llevError, "BUG: explode_bullet(): op out of map\n");
437 remove_ob (op); 437 op->remove ();
438 free_object (op); 438 op->destroy (0);
439 return; 439 return;
440 } 440 }
441 441
442 // elmex Tue Aug 15 17:46:51 CEST 2006: Prevent explosions of any kind on safe maps 442 // 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 443 // NOTE: If this breaks something important: remove this. I can't think of anything
444 // bad at the moment that might happen from this. 444 // 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) 445 if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE)
446 { 446 {
447 remove_ob (op); 447 op->remove ();
448 free_object (op); 448 op->destroy (0);
449 return; 449 return;
450 } 450 }
451 451
452 if (op->attacktype) 452 if (op->attacktype)
453 { 453 {
464 464
465 owner = get_owner (op); 465 owner = get_owner (op);
466 466
467 if ((tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER) && owner && !tailor_god_spell (tmp, owner)) 467 if ((tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER) && owner && !tailor_god_spell (tmp, owner))
468 { 468 {
469 remove_ob (op); 469 op->remove ();
470 free_object (op); 470 op->destroy (0);
471 return; 471 return;
472 } 472 }
473 473
474 tmp->x = op->x; 474 tmp->x = op->x;
475 tmp->y = op->y; 475 tmp->y = op->y;
505 505
506 insert_ob_in_map (tmp, op->map, op, 0); 506 insert_ob_in_map (tmp, op->map, op, 0);
507 /* remove the firebullet */ 507 /* remove the firebullet */
508 if (!op->destroyed ()) 508 if (!op->destroyed ())
509 { 509 {
510 remove_ob (op); 510 op->remove ();
511 free_object (op); 511 op->destroy (0);
512 } 512 }
513} 513}
514 514
515 515
516 516
549 dam = hit_player (tmp, op->stats.dam, op, op->attacktype, 1); 549 dam = hit_player (tmp, op->stats.dam, op, op->attacktype, 1);
550 if (op->destroyed () || !tmp->destroyed () || (op->stats.dam -= dam) < 0) 550 if (op->destroyed () || !tmp->destroyed () || (op->stats.dam -= dam) < 0)
551 { 551 {
552 if (!QUERY_FLAG (op, FLAG_REMOVED)) 552 if (!QUERY_FLAG (op, FLAG_REMOVED))
553 { 553 {
554 remove_ob (op); 554 op->remove ();
555 free_object (op); 555 op->destroy (0);
556 return; 556 return;
557 } 557 }
558 } 558 }
559 } 559 }
560 } 560 }
594 { 594 {
595 explode_bullet (op); 595 explode_bullet (op);
596 } 596 }
597 else 597 else
598 { 598 {
599 remove_ob (op); 599 op->remove ();
600 free_object (op); 600 op->destroy (0);
601 } 601 }
602 return; 602 return;
603 } 603 }
604 604
605 new_x = op->x + DIRX (op); 605 new_x = op->x + DIRX (op);
607 m = op->map; 607 m = op->map;
608 mflags = get_map_flags (m, &m, new_x, new_y, &new_x, &new_y); 608 mflags = get_map_flags (m, &m, new_x, new_y, &new_x, &new_y);
609 609
610 if (mflags & P_OUT_OF_MAP) 610 if (mflags & P_OUT_OF_MAP)
611 { 611 {
612 remove_ob (op); 612 op->remove ();
613 free_object (op); 613 op->destroy (0);
614 return; 614 return;
615 } 615 }
616 616
617 if (!op->direction || OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, new_x, new_y))) 617 if (!op->direction || OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, new_x, new_y)))
618 { 618 {
620 { 620 {
621 explode_bullet (op); 621 explode_bullet (op);
622 } 622 }
623 else 623 else
624 { 624 {
625 remove_ob (op); 625 op->remove ();
626 free_object (op); 626 op->destroy (0);
627 } 627 }
628 return; 628 return;
629 } 629 }
630 630
631 remove_ob (op); 631 op->remove ();
632 op->x = new_x; 632 op->x = new_x;
633 op->y = new_y; 633 op->y = new_y;
634 if ((op = insert_ob_in_map (op, m, op, 0)) == NULL) 634 if ((op = insert_ob_in_map (op, m, op, 0)) == NULL)
635 return; 635 return;
636 636
695 tmp->map = op->map; 695 tmp->map = op->map;
696 696
697 mflags = get_map_flags (tmp->map, &tmp->map, tmp->x, tmp->y, &tmp->x, &tmp->y); 697 mflags = get_map_flags (tmp->map, &tmp->map, tmp->x, tmp->y, &tmp->x, &tmp->y);
698 if (mflags & P_OUT_OF_MAP) 698 if (mflags & P_OUT_OF_MAP)
699 { 699 {
700 free_object (tmp); 700 tmp->destroy (0);
701 return 0; 701 return 0;
702 } 702 }
703 if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y))) 703 if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y)))
704 { 704 {
705 if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) 705 if (!QUERY_FLAG (tmp, FLAG_REFLECTING))
706 { 706 {
707 free_object (tmp); 707 tmp->destroy (0);
708 return 0; 708 return 0;
709 } 709 }
710 tmp->x = op->x; 710 tmp->x = op->x;
711 tmp->y = op->y; 711 tmp->y = op->y;
712 tmp->direction = absdir (tmp->direction + 4); 712 tmp->direction = absdir (tmp->direction + 4);
777 * when their cone dies when they die. 777 * when their cone dies when they die.
778 */ 778 */
779 /* If no owner left, the spell dies out. */ 779 /* If no owner left, the spell dies out. */
780 if (get_owner (op) == NULL) 780 if (get_owner (op) == NULL)
781 { 781 {
782 remove_ob (op); 782 op->remove ();
783 free_object (op); 783 op->destroy (0);
784 return; 784 return;
785 } 785 }
786#endif 786#endif
787 787
788 hit_map (op, 0, op->attacktype, 0); 788 hit_map (op, 0, op->attacktype, 0);
797 if (op->destroyed ()) 797 if (op->destroyed ())
798 return; 798 return;
799 799
800 if ((op->duration--) < 0) 800 if ((op->duration--) < 0)
801 { 801 {
802 remove_ob (op); 802 op->remove ();
803 free_object (op); 803 op->destroy (0);
804 return; 804 return;
805 } 805 }
806 /* Object has hit maximum range, so don't have it move 806 /* Object has hit maximum range, so don't have it move
807 * any further. When the duration above expires, 807 * any further. When the duration above expires,
808 * then the object will get removed. 808 * then the object will get removed.
1012 return; 1012 return;
1013 1013
1014 if (env->type == PLAYER) 1014 if (env->type == PLAYER)
1015 esrv_del_item (env->contr, op->count); 1015 esrv_del_item (env->contr, op->count);
1016 1016
1017 remove_ob (op); 1017 op->remove ();
1018 op->x = env->x; 1018 op->x = env->x;
1019 op->y = env->y; 1019 op->y = env->y;
1020 if ((op = insert_ob_in_map (op, env->map, op, 0)) == NULL) 1020 if ((op = insert_ob_in_map (op, env->map, op, 0)) == NULL)
1021 return; 1021 return;
1022 } 1022 }
1024 // elmex Tue Aug 15 17:46:51 CEST 2006: Prevent bomb from exploding 1024 // 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 1025 // on a safe map. I don't like this special casing, but it seems to be neccessary
1026 // as bombs can be carried. 1026 // as bombs can be carried.
1027 if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) 1027 if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE)
1028 { 1028 {
1029 remove_ob (op); 1029 op->remove ();
1030 free_object (op); 1030 op->destroy (0);
1031 return; 1031 return;
1032 } 1032 }
1033 1033
1034 /* This copies a lot of the code from the fire bullet, 1034 /* This copies a lot of the code from the fire bullet,
1035 * but using the cast_bullet isn't really feasible, 1035 * but using the cast_bullet isn't really feasible,
1229 } 1229 }
1230 else 1230 else
1231 { 1231 {
1232 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s looks stronger!", query_name (target)); 1232 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s looks stronger!", query_name (target));
1233 target->stats.hp = target->stats.maxhp * 2; 1233 target->stats.hp = target->stats.maxhp * 2;
1234 free_object (effect); 1234 effect->destroy (0);
1235 return 0; 1235 return 0;
1236 } 1236 }
1237 } 1237 }
1238 } 1238 }
1239 else 1239 else
1270 sint16 new_x, new_y; 1270 sint16 new_x, new_y;
1271 maptile *m; 1271 maptile *m;
1272 1272
1273 if (op->range-- <= 0) 1273 if (op->range-- <= 0)
1274 { 1274 {
1275 remove_ob (op); 1275 op->remove ();
1276 free_object (op); 1276 op->destroy (0);
1277 return; 1277 return;
1278 } 1278 }
1279 1279
1280 owner = get_owner (op); 1280 owner = get_owner (op);
1281#if 0 1281#if 0
1282 /* It'd make things nastier if this wasn't here - spells cast by 1282 /* It'd make things nastier if this wasn't here - spells cast by
1283 * monster that are then killed would continue to survive 1283 * monster that are then killed would continue to survive
1284 */ 1284 */
1285 if (owner == NULL) 1285 if (owner == NULL)
1286 { 1286 {
1287 remove_ob (op); 1287 op->remove ();
1288 free_object (op); 1288 op->destroy (0);
1289 return; 1289 return;
1290 } 1290 }
1291#endif 1291#endif
1292 1292
1293 new_x = op->x + DIRX (op); 1293 new_x = op->x + DIRX (op);
1300 hit_map (op, op->direction, AT_MAGIC, 1); 1300 hit_map (op, op->direction, AT_MAGIC, 1);
1301 /* Basically, missile only hits one thing then goes away. 1301 /* Basically, missile only hits one thing then goes away.
1302 * we need to remove it if someone hasn't already done so. 1302 * we need to remove it if someone hasn't already done so.
1303 */ 1303 */
1304 if (!op->destroyed ()) 1304 if (!op->destroyed ())
1305 free_object (op); 1305 op->destroy (0);
1306 1306
1307 return; 1307 return;
1308 } 1308 }
1309 1309
1310 remove_ob (op); 1310 op->remove ();
1311 1311
1312 if (!op->direction || (mflags & P_OUT_OF_MAP)) 1312 if (!op->direction || (mflags & P_OUT_OF_MAP))
1313 { 1313 {
1314 free_object (op); 1314 op->destroy (0);
1315 return; 1315 return;
1316 } 1316 }
1317 1317
1318 op->x = new_x; 1318 op->x = new_x;
1319 op->y = new_y; 1319 op->y = new_y;
1785 nx = op->x; 1785 nx = op->x;
1786 ny = op->y; 1786 ny = op->y;
1787 m = op->map; 1787 m = op->map;
1788 } 1788 }
1789 1789
1790 remove_ob (op); 1790 op->remove ();
1791 op->y = ny; 1791 op->y = ny;
1792 op->x = nx; 1792 op->x = nx;
1793 insert_ob_in_map (op, m, op, 0); 1793 insert_ob_in_map (op, m, op, 0);
1794 1794
1795 dam_save = op->stats.dam; /* save the original dam: we do halfdam on 1795 dam_save = op->stats.dam; /* save the original dam: we do halfdam on
1874 object *owner; 1874 object *owner;
1875 1875
1876 owner = get_owner (op); 1876 owner = get_owner (op);
1877 if (op->duration == 0 || owner == NULL) 1877 if (op->duration == 0 || owner == NULL)
1878 { 1878 {
1879 remove_ob (op); 1879 op->remove ();
1880 free_object (op); 1880 op->destroy (0);
1881 return; 1881 return;
1882 } 1882 }
1883 op->duration--; 1883 op->duration--;
1884 1884
1885 basedir = op->direction; 1885 basedir = op->direction;
2199 { 2199 {
2200 object *flash; /* visual effect for inflicting disease */ 2200 object *flash; /* visual effect for inflicting disease */
2201 2201
2202 new_draw_info_format (NDI_UNIQUE, 0, op, "You inflict %s on %s!", &disease->name, &walk->name); 2202 new_draw_info_format (NDI_UNIQUE, 0, op, "You inflict %s on %s!", &disease->name, &walk->name);
2203 2203
2204 free_object (disease); /* don't need this one anymore */ 2204 disease->destroy (0); /* don't need this one anymore */
2205 flash = get_archetype (ARCH_DETECT_MAGIC); 2205 flash = get_archetype (ARCH_DETECT_MAGIC);
2206 flash->x = x; 2206 flash->x = x;
2207 flash->y = y; 2207 flash->y = y;
2208 flash->map = walk->map; 2208 flash->map = walk->map;
2209 insert_ob_in_map (flash, walk->map, op, 0); 2209 insert_ob_in_map (flash, walk->map, op, 0);
2210 return 1; 2210 return 1;
2211 } 2211 }
2212 free_object (disease); 2212 disease->destroy (0);
2213 } 2213 }
2214 } /* if living creature */ 2214 } /* if living creature */
2215 } /* for range of spaces */ 2215 } /* for range of spaces */
2216 new_draw_info (NDI_UNIQUE, 0, op, "No one caught anything!"); 2216 new_draw_info (NDI_UNIQUE, 0, op, "No one caught anything!");
2217 return 1; 2217 return 1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines