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.13 by root, Thu Sep 14 22:34:05 2006 UTC vs.
Revision 1.16 by root, Tue Dec 12 20:53:03 2006 UTC

117void 117void
118forklightning (object *op, object *tmp) 118forklightning (object *op, object *tmp)
119{ 119{
120 int new_dir = 1; /* direction or -1 for left, +1 for right 0 if no new bolt */ 120 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 */ 121 int t_dir; /* stores temporary dir calculation */
122 mapstruct *m; 122 maptile *m;
123 sint16 sx, sy; 123 sint16 sx, sy;
124 object *new_bolt; 124 object *new_bolt;
125 125
126 /* pick a fork direction. tmp->stats.Con is the left bias 126 /* pick a fork direction. tmp->stats.Con is the left bias
127 * i.e., the chance in 100 of forking LEFT 127 * i.e., the chance in 100 of forking LEFT
170move_bolt (object *op) 170move_bolt (object *op)
171{ 171{
172 object *tmp; 172 object *tmp;
173 int mflags; 173 int mflags;
174 sint16 x, y; 174 sint16 x, y;
175 mapstruct *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);
356 */ 356 */
357void 357void
358explosion (object *op) 358explosion (object *op)
359{ 359{
360 object *tmp; 360 object *tmp;
361 mapstruct *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)
402 * explode. 402 * explode.
403 */ 403 */
404void 404void
405explode_bullet (object *op) 405explode_bullet (object *op)
406{ 406{
407 tag_t op_tag = op->count;
408 object *tmp, *owner; 407 object *tmp, *owner;
409 408
410 if (op->other_arch == NULL) 409 if (op->other_arch == NULL)
411 { 410 {
412 LOG (llevError, "BUG: explode_bullet(): op without other_arch\n"); 411 LOG (llevError, "BUG: explode_bullet(): op without other_arch\n");
413 remove_ob (op); 412 op->remove ();
414 free_object (op); 413 op->destroy (0);
415 return; 414 return;
416 } 415 }
417 416
418 if (op->env) 417 if (op->env)
419 { 418 {
421 420
422 env = object_get_env_recursive (op); 421 env = object_get_env_recursive (op);
423 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))
424 { 423 {
425 LOG (llevError, "BUG: explode_bullet(): env out of map\n"); 424 LOG (llevError, "BUG: explode_bullet(): env out of map\n");
426 remove_ob (op); 425 op->remove ();
427 free_object (op); 426 op->destroy (0);
428 return; 427 return;
429 } 428 }
430 remove_ob (op); 429 op->remove ();
431 op->x = env->x; 430 op->x = env->x;
432 op->y = env->y; 431 op->y = env->y;
433 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);
434 } 433 }
435 else if (out_of_map (op->map, op->x, op->y)) 434 else if (out_of_map (op->map, op->x, op->y))
436 { 435 {
437 LOG (llevError, "BUG: explode_bullet(): op out of map\n"); 436 LOG (llevError, "BUG: explode_bullet(): op out of map\n");
438 remove_ob (op); 437 op->remove ();
439 free_object (op); 438 op->destroy (0);
440 return; 439 return;
441 } 440 }
442 441
443 // 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
444 // 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
445 // bad at the moment that might happen from this. 444 // bad at the moment that might happen from this.
446 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)
447 { 446 {
448 remove_ob (op); 447 op->remove ();
449 free_object (op); 448 op->destroy (0);
450 return; 449 return;
451 } 450 }
452 451
453 if (op->attacktype) 452 if (op->attacktype)
454 { 453 {
455 hit_map (op, 0, op->attacktype, 1); 454 hit_map (op, 0, op->attacktype, 1);
456 if (was_destroyed (op, op_tag)) 455 if (op->destroyed ())
457 return; 456 return;
458 } 457 }
459 458
460 /* other_arch contains what this explodes into */ 459 /* other_arch contains what this explodes into */
461 tmp = arch_to_object (op->other_arch); 460 tmp = arch_to_object (op->other_arch);
465 464
466 owner = get_owner (op); 465 owner = get_owner (op);
467 466
468 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))
469 { 468 {
470 remove_ob (op); 469 op->remove ();
471 free_object (op); 470 op->destroy (0);
472 return; 471 return;
473 } 472 }
474 473
475 tmp->x = op->x; 474 tmp->x = op->x;
476 tmp->y = op->y; 475 tmp->y = op->y;
504 /* Prevent recursion */ 503 /* Prevent recursion */
505 op->move_on = 0; 504 op->move_on = 0;
506 505
507 insert_ob_in_map (tmp, op->map, op, 0); 506 insert_ob_in_map (tmp, op->map, op, 0);
508 /* remove the firebullet */ 507 /* remove the firebullet */
509 if (!was_destroyed (op, op_tag)) 508 if (!op->destroyed ())
510 { 509 {
511 remove_ob (op); 510 op->remove ();
512 free_object (op); 511 op->destroy (0);
513 } 512 }
514} 513}
515 514
516 515
517 516
520 */ 519 */
521 520
522void 521void
523check_bullet (object *op) 522check_bullet (object *op)
524{ 523{
525 tag_t op_tag = op->count, tmp_tag;
526 object *tmp; 524 object *tmp;
527 int dam, mflags; 525 int dam, mflags;
528 mapstruct *m; 526 maptile *m;
529 sint16 sx, sy; 527 sint16 sx, sy;
530 528
531 mflags = get_map_flags (op->map, &m, op->x, op->y, &sx, &sy); 529 mflags = get_map_flags (op->map, &m, op->x, op->y, &sx, &sy);
532 530
533 if (!(mflags & P_IS_ALIVE) && !OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy))) 531 if (!(mflags & P_IS_ALIVE) && !OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy)))
546 544
547 for (tmp = get_map_ob (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) 545 for (tmp = get_map_ob (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above)
548 { 546 {
549 if (QUERY_FLAG (tmp, FLAG_ALIVE)) 547 if (QUERY_FLAG (tmp, FLAG_ALIVE))
550 { 548 {
551 tmp_tag = tmp->count;
552 dam = hit_player (tmp, op->stats.dam, op, op->attacktype, 1); 549 dam = hit_player (tmp, op->stats.dam, op, op->attacktype, 1);
553 if (was_destroyed (op, op_tag) || !was_destroyed (tmp, tmp_tag) || (op->stats.dam -= dam) < 0) 550 if (op->destroyed () || !tmp->destroyed () || (op->stats.dam -= dam) < 0)
554 { 551 {
555 if (!QUERY_FLAG (op, FLAG_REMOVED)) 552 if (!QUERY_FLAG (op, FLAG_REMOVED))
556 { 553 {
557 remove_ob (op); 554 op->remove ();
558 free_object (op); 555 op->destroy (0);
559 return; 556 return;
560 } 557 }
561 } 558 }
562 } 559 }
563 } 560 }
573void 570void
574move_bullet (object *op) 571move_bullet (object *op)
575{ 572{
576 sint16 new_x, new_y; 573 sint16 new_x, new_y;
577 int mflags; 574 int mflags;
578 mapstruct *m; 575 maptile *m;
579 576
580#if 0 577#if 0
581 /* We need a better general purpose way to do this */ 578 /* We need a better general purpose way to do this */
582 579
583 /* peterm: added to make comet leave a trail of burnouts 580 /* peterm: added to make comet leave a trail of burnouts
584 it's an unadulterated hack, but the effect is cool. */ 581 it's an unadulterated hack, but the effect is cool. */
585 if (op->stats.sp == SP_METEOR) 582 if (op->stats.sp == SP_METEOR)
586 { 583 {
587 replace_insert_ob_in_map ("fire_trail", op); 584 replace_insert_ob_in_map ("fire_trail", op);
588 if (was_destroyed (op, op_tag)) 585 if (op->destroyed ())
589 return; 586 return;
590 } /* end addition. */ 587 } /* end addition. */
591#endif 588#endif
592 589
593 /* Reached the end of its life - remove it */ 590 /* Reached the end of its life - remove it */
597 { 594 {
598 explode_bullet (op); 595 explode_bullet (op);
599 } 596 }
600 else 597 else
601 { 598 {
602 remove_ob (op); 599 op->remove ();
603 free_object (op); 600 op->destroy (0);
604 } 601 }
605 return; 602 return;
606 } 603 }
607 604
608 new_x = op->x + DIRX (op); 605 new_x = op->x + DIRX (op);
610 m = op->map; 607 m = op->map;
611 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);
612 609
613 if (mflags & P_OUT_OF_MAP) 610 if (mflags & P_OUT_OF_MAP)
614 { 611 {
615 remove_ob (op); 612 op->remove ();
616 free_object (op); 613 op->destroy (0);
617 return; 614 return;
618 } 615 }
619 616
620 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)))
621 { 618 {
623 { 620 {
624 explode_bullet (op); 621 explode_bullet (op);
625 } 622 }
626 else 623 else
627 { 624 {
628 remove_ob (op); 625 op->remove ();
629 free_object (op); 626 op->destroy (0);
630 } 627 }
631 return; 628 return;
632 } 629 }
633 630
634 remove_ob (op); 631 op->remove ();
635 op->x = new_x; 632 op->x = new_x;
636 op->y = new_y; 633 op->y = new_y;
637 if ((op = insert_ob_in_map (op, m, op, 0)) == NULL) 634 if ((op = insert_ob_in_map (op, m, op, 0)) == NULL)
638 return; 635 return;
639 636
698 tmp->map = op->map; 695 tmp->map = op->map;
699 696
700 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);
701 if (mflags & P_OUT_OF_MAP) 698 if (mflags & P_OUT_OF_MAP)
702 { 699 {
703 free_object (tmp); 700 tmp->destroy (0);
704 return 0; 701 return 0;
705 } 702 }
706 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)))
707 { 704 {
708 if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) 705 if (!QUERY_FLAG (tmp, FLAG_REFLECTING))
709 { 706 {
710 free_object (tmp); 707 tmp->destroy (0);
711 return 0; 708 return 0;
712 } 709 }
713 tmp->x = op->x; 710 tmp->x = op->x;
714 tmp->y = op->y; 711 tmp->y = op->y;
715 tmp->direction = absdir (tmp->direction + 4); 712 tmp->direction = absdir (tmp->direction + 4);
756 753
757void 754void
758move_cone (object *op) 755move_cone (object *op)
759{ 756{
760 int i; 757 int i;
761 tag_t tag;
762 758
763 /* if no map then hit_map will crash so just ignore object */ 759 /* if no map then hit_map will crash so just ignore object */
764 if (!op->map) 760 if (!op->map)
765 { 761 {
766 LOG (llevError, "Tried to move_cone object %s without a map.\n", op->name ? &op->name : "unknown"); 762 LOG (llevError, "Tried to move_cone object %s without a map.\n", op->name ? &op->name : "unknown");
781 * when their cone dies when they die. 777 * when their cone dies when they die.
782 */ 778 */
783 /* If no owner left, the spell dies out. */ 779 /* If no owner left, the spell dies out. */
784 if (get_owner (op) == NULL) 780 if (get_owner (op) == NULL)
785 { 781 {
786 remove_ob (op); 782 op->remove ();
787 free_object (op); 783 op->destroy (0);
788 return; 784 return;
789 } 785 }
790#endif 786#endif
791 787
792 tag = op->count;
793 hit_map (op, 0, op->attacktype, 0); 788 hit_map (op, 0, op->attacktype, 0);
794 789
795 /* Check to see if we should push anything. 790 /* Check to see if we should push anything.
796 * Spell objects with weight push whatever they encounter to some 791 * Spell objects with weight push whatever they encounter to some
797 * degree. 792 * degree.
798 */ 793 */
799 if (op->weight) 794 if (op->weight)
800 check_spell_knockback (op); 795 check_spell_knockback (op);
801 796
802 if (was_destroyed (op, tag)) 797 if (op->destroyed ())
803 return; 798 return;
804 799
805 if ((op->duration--) < 0) 800 if ((op->duration--) < 0)
806 { 801 {
807 remove_ob (op); 802 op->remove ();
808 free_object (op); 803 op->destroy (0);
809 return; 804 return;
810 } 805 }
811 /* Object has hit maximum range, so don't have it move 806 /* Object has hit maximum range, so don't have it move
812 * any further. When the duration above expires, 807 * any further. When the duration above expires,
813 * then the object will get removed. 808 * then the object will get removed.
852int 847int
853cast_cone (object *op, object *caster, int dir, object *spell) 848cast_cone (object *op, object *caster, int dir, object *spell)
854{ 849{
855 object *tmp; 850 object *tmp;
856 int i, success = 0, range_min = -1, range_max = 1; 851 int i, success = 0, range_min = -1, range_max = 1;
857 mapstruct *m; 852 maptile *m;
858 sint16 sx, sy; 853 sint16 sx, sy;
859 MoveType movetype; 854 MoveType movetype;
860 855
861 if (!spell->other_arch) 856 if (!spell->other_arch)
862 return 0; 857 return 0;
1017 return; 1012 return;
1018 1013
1019 if (env->type == PLAYER) 1014 if (env->type == PLAYER)
1020 esrv_del_item (env->contr, op->count); 1015 esrv_del_item (env->contr, op->count);
1021 1016
1022 remove_ob (op); 1017 op->remove ();
1023 op->x = env->x; 1018 op->x = env->x;
1024 op->y = env->y; 1019 op->y = env->y;
1025 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)
1026 return; 1021 return;
1027 } 1022 }
1029 // 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
1030 // 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
1031 // as bombs can be carried. 1026 // as bombs can be carried.
1032 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)
1033 { 1028 {
1034 remove_ob (op); 1029 op->remove ();
1035 free_object (op); 1030 op->destroy (0);
1036 return; 1031 return;
1037 } 1032 }
1038 1033
1039 /* This copies a lot of the code from the fire bullet, 1034 /* This copies a lot of the code from the fire bullet,
1040 * but using the cast_bullet isn't really feasible, 1035 * but using the cast_bullet isn't really feasible,
1075{ 1070{
1076 1071
1077 object *tmp; 1072 object *tmp;
1078 int mflags; 1073 int mflags;
1079 sint16 dx = op->x + freearr_x[dir], dy = op->y + freearr_y[dir]; 1074 sint16 dx = op->x + freearr_x[dir], dy = op->y + freearr_y[dir];
1080 mapstruct *m; 1075 maptile *m;
1081 1076
1082 mflags = get_map_flags (op->map, &m, dx, dy, &dx, &dy); 1077 mflags = get_map_flags (op->map, &m, dx, dy, &dx, &dy);
1083 if ((mflags & P_OUT_OF_MAP) || (GET_MAP_MOVE_BLOCK (m, dx, dy) & MOVE_WALK)) 1078 if ((mflags & P_OUT_OF_MAP) || (GET_MAP_MOVE_BLOCK (m, dx, dy) & MOVE_WALK))
1084 { 1079 {
1085 new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way."); 1080 new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way.");
1121get_pointed_target (object *op, int dir, int range, int type) 1116get_pointed_target (object *op, int dir, int range, int type)
1122{ 1117{
1123 object *target; 1118 object *target;
1124 sint16 x, y; 1119 sint16 x, y;
1125 int dist, mflags; 1120 int dist, mflags;
1126 mapstruct *mp; 1121 maptile *mp;
1127 1122
1128 if (dir == 0) 1123 if (dir == 0)
1129 return NULL; 1124 return NULL;
1130 1125
1131 for (dist = 1; dist < range; dist++) 1126 for (dist = 1; dist < range; dist++)
1234 } 1229 }
1235 else 1230 else
1236 { 1231 {
1237 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));
1238 target->stats.hp = target->stats.maxhp * 2; 1233 target->stats.hp = target->stats.maxhp * 2;
1239 free_object (effect); 1234 effect->destroy (0);
1240 return 0; 1235 return 0;
1241 } 1236 }
1242 } 1237 }
1243 } 1238 }
1244 else 1239 else
1271move_missile (object *op) 1266move_missile (object *op)
1272{ 1267{
1273 int i, mflags; 1268 int i, mflags;
1274 object *owner; 1269 object *owner;
1275 sint16 new_x, new_y; 1270 sint16 new_x, new_y;
1276 mapstruct *m; 1271 maptile *m;
1277 1272
1278 if (op->range-- <= 0) 1273 if (op->range-- <= 0)
1279 { 1274 {
1280 remove_ob (op); 1275 op->remove ();
1281 free_object (op); 1276 op->destroy (0);
1282 return; 1277 return;
1283 } 1278 }
1284 1279
1285 owner = get_owner (op); 1280 owner = get_owner (op);
1286#if 0 1281#if 0
1287 /* 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
1288 * monster that are then killed would continue to survive 1283 * monster that are then killed would continue to survive
1289 */ 1284 */
1290 if (owner == NULL) 1285 if (owner == NULL)
1291 { 1286 {
1292 remove_ob (op); 1287 op->remove ();
1293 free_object (op); 1288 op->destroy (0);
1294 return; 1289 return;
1295 } 1290 }
1296#endif 1291#endif
1297 1292
1298 new_x = op->x + DIRX (op); 1293 new_x = op->x + DIRX (op);
1300 1295
1301 mflags = get_map_flags (op->map, &m, new_x, new_y, &new_x, &new_y); 1296 mflags = get_map_flags (op->map, &m, new_x, new_y, &new_x, &new_y);
1302 1297
1303 if (!(mflags & P_OUT_OF_MAP) && ((mflags & P_IS_ALIVE) || OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, new_x, new_y)))) 1298 if (!(mflags & P_OUT_OF_MAP) && ((mflags & P_IS_ALIVE) || OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, new_x, new_y))))
1304 { 1299 {
1305 tag_t tag = op->count;
1306
1307 hit_map (op, op->direction, AT_MAGIC, 1); 1300 hit_map (op, op->direction, AT_MAGIC, 1);
1308 /* Basically, missile only hits one thing then goes away. 1301 /* Basically, missile only hits one thing then goes away.
1309 * 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.
1310 */ 1303 */
1311 if (!was_destroyed (op, tag)) 1304 if (!op->destroyed ())
1312 { 1305 op->destroy (0);
1313 remove_ob (op); 1306
1314 free_object (op);
1315 }
1316 return; 1307 return;
1317 } 1308 }
1318 1309
1319 remove_ob (op); 1310 op->remove ();
1311
1320 if (!op->direction || (mflags & P_OUT_OF_MAP)) 1312 if (!op->direction || (mflags & P_OUT_OF_MAP))
1321 { 1313 {
1322 free_object (op); 1314 op->destroy (0);
1323 return; 1315 return;
1324 } 1316 }
1317
1325 op->x = new_x; 1318 op->x = new_x;
1326 op->y = new_y; 1319 op->y = new_y;
1327 op->map = m; 1320 op->map = m;
1328 i = spell_find_dir (op->map, op->x, op->y, get_owner (op)); 1321 i = spell_find_dir (op->map, op->x, op->y, get_owner (op));
1329 if (i > 0 && i != op->direction) 1322 if (i > 0 && i != op->direction)
1330 { 1323 {
1331 op->direction = i; 1324 op->direction = i;
1332 SET_ANIMATION (op, op->direction); 1325 SET_ANIMATION (op, op->direction);
1333 } 1326 }
1327
1334 insert_ob_in_map (op, op->map, op, 0); 1328 insert_ob_in_map (op, op->map, op, 0);
1335} 1329}
1336 1330
1337/**************************************************************************** 1331/****************************************************************************
1338 * Destruction 1332 * Destruction
1384int 1378int
1385cast_destruction (object *op, object *caster, object *spell_ob) 1379cast_destruction (object *op, object *caster, object *spell_ob)
1386{ 1380{
1387 int i, j, range, mflags, friendly = 0, dam, dur; 1381 int i, j, range, mflags, friendly = 0, dam, dur;
1388 sint16 sx, sy; 1382 sint16 sx, sy;
1389 mapstruct *m; 1383 maptile *m;
1390 object *tmp; 1384 object *tmp;
1391 const char *skill; 1385 const char *skill;
1392 1386
1393 range = spell_ob->range + SP_level_range_adjust (caster, spell_ob); 1387 range = spell_ob->range + SP_level_range_adjust (caster, spell_ob);
1394 dam = spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob); 1388 dam = spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob);
1576mood_change (object *op, object *caster, object *spell) 1570mood_change (object *op, object *caster, object *spell)
1577{ 1571{
1578 object *tmp, *god, *head; 1572 object *tmp, *god, *head;
1579 int done_one, range, mflags, level, at, best_at; 1573 int done_one, range, mflags, level, at, best_at;
1580 sint16 x, y, nx, ny; 1574 sint16 x, y, nx, ny;
1581 mapstruct *m; 1575 maptile *m;
1582 const char *race; 1576 const char *race;
1583 1577
1584 /* We precompute some values here so that we don't have to keep 1578 /* We precompute some values here so that we don't have to keep
1585 * doing it over and over again. 1579 * doing it over and over again.
1586 */ 1580 */
1750move_ball_spell (object *op) 1744move_ball_spell (object *op)
1751{ 1745{
1752 int i, j, dam_save, dir, mflags; 1746 int i, j, dam_save, dir, mflags;
1753 sint16 nx, ny, hx, hy; 1747 sint16 nx, ny, hx, hy;
1754 object *owner; 1748 object *owner;
1755 mapstruct *m; 1749 maptile *m;
1756 1750
1757 owner = get_owner (op); 1751 owner = get_owner (op);
1758 1752
1759 /* the following logic makes sure that the ball doesn't move into a wall, 1753 /* the following logic makes sure that the ball doesn't move into a wall,
1760 * and makes sure that it will move along a wall to try and get at it's 1754 * and makes sure that it will move along a wall to try and get at it's
1791 nx = op->x; 1785 nx = op->x;
1792 ny = op->y; 1786 ny = op->y;
1793 m = op->map; 1787 m = op->map;
1794 } 1788 }
1795 1789
1796 remove_ob (op); 1790 op->remove ();
1797 op->y = ny; 1791 op->y = ny;
1798 op->x = nx; 1792 op->x = nx;
1799 insert_ob_in_map (op, m, op, 0); 1793 insert_ob_in_map (op, m, op, 0);
1800 1794
1801 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
1872#if 0 1866#if 0
1873 static int cardinal_adjust[9] = { -3, -2, -1, 0, 0, 0, 1, 2, 3 }; 1867 static int cardinal_adjust[9] = { -3, -2, -1, 0, 0, 0, 1, 2, 3 };
1874 static int diagonal_adjust[10] = { -3, -2, -2, -1, 0, 0, 1, 2, 2, 3 }; 1868 static int diagonal_adjust[10] = { -3, -2, -2, -1, 0, 0, 1, 2, 2, 3 };
1875 sint16 target_x, target_y, origin_x, origin_y; 1869 sint16 target_x, target_y, origin_x, origin_y;
1876 int adjustdir; 1870 int adjustdir;
1877 mapstruct *m; 1871 maptile *m;
1878#endif 1872#endif
1879 int basedir; 1873 int basedir;
1880 object *owner; 1874 object *owner;
1881 1875
1882 owner = get_owner (op); 1876 owner = get_owner (op);
1883 if (op->duration == 0 || owner == NULL) 1877 if (op->duration == 0 || owner == NULL)
1884 { 1878 {
1885 remove_ob (op); 1879 op->remove ();
1886 free_object (op); 1880 op->destroy (0);
1887 return; 1881 return;
1888 } 1882 }
1889 op->duration--; 1883 op->duration--;
1890 1884
1891 basedir = op->direction; 1885 basedir = op->direction;
2025cast_light (object *op, object *caster, object *spell, int dir) 2019cast_light (object *op, object *caster, object *spell, int dir)
2026{ 2020{
2027 object *target = NULL, *tmp = NULL; 2021 object *target = NULL, *tmp = NULL;
2028 sint16 x, y; 2022 sint16 x, y;
2029 int dam, mflags; 2023 int dam, mflags;
2030 mapstruct *m; 2024 maptile *m;
2031 2025
2032 dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); 2026 dam = spell->stats.dam + SP_level_dam_adjust (caster, spell);
2033 2027
2034 if (!dir) 2028 if (!dir)
2035 { 2029 {
2103cast_cause_disease (object *op, object *caster, object *spell, int dir) 2097cast_cause_disease (object *op, object *caster, object *spell, int dir)
2104{ 2098{
2105 sint16 x, y; 2099 sint16 x, y;
2106 int i, mflags, range, dam_mod, dur_mod; 2100 int i, mflags, range, dam_mod, dur_mod;
2107 object *walk; 2101 object *walk;
2108 mapstruct *m; 2102 maptile *m;
2109 2103
2110 x = op->x; 2104 x = op->x;
2111 y = op->y; 2105 y = op->y;
2112 2106
2113 /* If casting from a scroll, no direction will be available, so refer to the 2107 /* If casting from a scroll, no direction will be available, so refer to the
2205 { 2199 {
2206 object *flash; /* visual effect for inflicting disease */ 2200 object *flash; /* visual effect for inflicting disease */
2207 2201
2208 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);
2209 2203
2210 free_object (disease); /* don't need this one anymore */ 2204 disease->destroy (0); /* don't need this one anymore */
2211 flash = get_archetype (ARCH_DETECT_MAGIC); 2205 flash = get_archetype (ARCH_DETECT_MAGIC);
2212 flash->x = x; 2206 flash->x = x;
2213 flash->y = y; 2207 flash->y = y;
2214 flash->map = walk->map; 2208 flash->map = walk->map;
2215 insert_ob_in_map (flash, walk->map, op, 0); 2209 insert_ob_in_map (flash, walk->map, op, 0);
2216 return 1; 2210 return 1;
2217 } 2211 }
2218 free_object (disease); 2212 disease->destroy (0);
2219 } 2213 }
2220 } /* if living creature */ 2214 } /* if living creature */
2221 } /* for range of spaces */ 2215 } /* for range of spaces */
2222 new_draw_info (NDI_UNIQUE, 0, op, "No one caught anything!"); 2216 new_draw_info (NDI_UNIQUE, 0, op, "No one caught anything!");
2223 return 1; 2217 return 1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines