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

Comparing deliantra/server/server/spell_attack.C (file contents):
Revision 1.14 by root, Thu Sep 14 23:13:49 2006 UTC vs.
Revision 1.17 by root, Tue Dec 12 21:39:57 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
140 140
141 if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (m, sx, sy))) 141 if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (m, sx, sy)))
142 return; 142 return;
143 143
144 /* OK, we made a fork */ 144 /* OK, we made a fork */
145 new_bolt = get_object (); 145 new_bolt = object::create ();
146 copy_object (tmp, new_bolt); 146 tmp->copy_to (new_bolt);
147 147
148 /* reduce chances of subsequent forking */ 148 /* reduce chances of subsequent forking */
149 new_bolt->stats.Dex -= 10; 149 new_bolt->stats.Dex -= 10;
150 tmp->stats.Dex -= 10; /* less forks from main bolt too */ 150 tmp->stats.Dex -= 10; /* less forks from main bolt too */
151 new_bolt->stats.Con += 25 * new_dir; /* adjust the left bias */ 151 new_bolt->stats.Con += 25 * new_dir; /* adjust the left bias */
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->destroy ();
180 free_object (op);
181 return; 180 return;
182 } 181 }
183 182
184 hit_map (op, 0, op->attacktype, 1); 183 hit_map (op, 0, op->attacktype, 1);
185 184
250 update_turn_face (op); /* A bolt *must* be IS_TURNABLE */ 249 update_turn_face (op); /* A bolt *must* be IS_TURNABLE */
251 return; 250 return;
252 } 251 }
253 else 252 else
254 { /* Create a copy of this object and put it ahead */ 253 { /* Create a copy of this object and put it ahead */
255 tmp = get_object (); 254 tmp = object::create ();
256 copy_object (op, tmp); 255 op->copy_to (tmp);
257 tmp->speed_left = -0.1; 256 tmp->speed_left = -0.1;
258 tmp->x += DIRX (tmp), tmp->y += DIRY (tmp); 257 tmp->x += DIRX (tmp), tmp->y += DIRY (tmp);
259 tmp = insert_ob_in_map (tmp, op->map, op, 0); 258 tmp = insert_ob_in_map (tmp, op->map, op, 0);
260 /* To make up for the decrease at the top of the function */ 259 /* To make up for the decrease at the top of the function */
261 tmp->duration++; 260 tmp->duration++;
320 tmp->map = op->map; 319 tmp->map = op->map;
321 320
322 mflags = get_map_flags (tmp->map, &tmp->map, tmp->x, tmp->y, &tmp->x, &tmp->y); 321 mflags = get_map_flags (tmp->map, &tmp->map, tmp->x, tmp->y, &tmp->x, &tmp->y);
323 if (mflags & P_OUT_OF_MAP) 322 if (mflags & P_OUT_OF_MAP)
324 { 323 {
325 free_object (tmp); 324 tmp->destroy ();
326 return 0; 325 return 0;
327 } 326 }
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 ();
333 return 0; 333 return 0;
334 } 334 }
335
335 tmp->x = op->x; 336 tmp->x = op->x;
336 tmp->y = op->y; 337 tmp->y = op->y;
337 tmp->direction = absdir (tmp->direction + 4); 338 tmp->direction = absdir (tmp->direction + 4);
338 tmp->map = op->map; 339 tmp->map = op->map;
339 } 340 }
341
340 if ((tmp = insert_ob_in_map (tmp, tmp->map, op, 0)) != NULL) 342 if ((tmp = insert_ob_in_map (tmp, tmp->map, op, 0)) != NULL)
341 move_bolt (tmp); 343 move_bolt (tmp);
344
342 return 1; 345 return 1;
343} 346}
344 347
345 348
346 349
356 */ 359 */
357void 360void
358explosion (object *op) 361explosion (object *op)
359{ 362{
360 object *tmp; 363 object *tmp;
361 mapstruct *m = op->map; 364 maptile *m = op->map;
362 int i; 365 int i;
363 366
364 if (--(op->duration) < 0) 367 if (--(op->duration) < 0)
365 { 368 {
366 remove_ob (op); 369 op->destroy ();
367 free_object (op);
368 return; 370 return;
369 } 371 }
372
370 hit_map (op, 0, op->attacktype, 0); 373 hit_map (op, 0, op->attacktype, 0);
371 374
372 if (op->range > 0) 375 if (op->range > 0)
373 { 376 {
374 for (i = 1; i < 9; i++) 377 for (i = 1; i < 9; i++)
380 /* ok_to_put_more already does things like checks for walls, 383 /* ok_to_put_more already does things like checks for walls,
381 * out of map, etc. 384 * out of map, etc.
382 */ 385 */
383 if (ok_to_put_more (op->map, dx, dy, op, op->attacktype)) 386 if (ok_to_put_more (op->map, dx, dy, op, op->attacktype))
384 { 387 {
385 tmp = get_object (); 388 tmp = object::create ();
386 copy_object (op, tmp); 389 op->copy_to (tmp);
387 tmp->state = 0; 390 tmp->state = 0;
388 tmp->speed_left = -0.21; 391 tmp->speed_left = -0.21;
389 tmp->range--; 392 tmp->range--;
390 tmp->value = 0; 393 tmp->value = 0;
391 tmp->x = dx; 394 tmp->x = dx;
407 object *tmp, *owner; 410 object *tmp, *owner;
408 411
409 if (op->other_arch == NULL) 412 if (op->other_arch == NULL)
410 { 413 {
411 LOG (llevError, "BUG: explode_bullet(): op without other_arch\n"); 414 LOG (llevError, "BUG: explode_bullet(): op without other_arch\n");
412 remove_ob (op); 415 op->destroy ();
413 free_object (op);
414 return; 416 return;
415 } 417 }
416 418
417 if (op->env) 419 if (op->env)
418 { 420 {
420 422
421 env = object_get_env_recursive (op); 423 env = object_get_env_recursive (op);
422 if (env->map == NULL || out_of_map (env->map, env->x, env->y)) 424 if (env->map == NULL || out_of_map (env->map, env->x, env->y))
423 { 425 {
424 LOG (llevError, "BUG: explode_bullet(): env out of map\n"); 426 LOG (llevError, "BUG: explode_bullet(): env out of map\n");
425 remove_ob (op); 427 op->destroy ();
426 free_object (op);
427 return; 428 return;
428 } 429 }
430
429 remove_ob (op); 431 op->remove ();
430 op->x = env->x; 432 op->x = env->x;
431 op->y = env->y; 433 op->y = env->y;
432 insert_ob_in_map (op, env->map, op, INS_NO_MERGE | INS_NO_WALK_ON); 434 insert_ob_in_map (op, env->map, op, INS_NO_MERGE | INS_NO_WALK_ON);
433 } 435 }
434 else if (out_of_map (op->map, op->x, op->y)) 436 else if (out_of_map (op->map, op->x, op->y))
435 { 437 {
436 LOG (llevError, "BUG: explode_bullet(): op out of map\n"); 438 LOG (llevError, "BUG: explode_bullet(): op out of map\n");
437 remove_ob (op); 439 op->destroy ();
438 free_object (op);
439 return; 440 return;
440 } 441 }
441 442
442 // elmex Tue Aug 15 17:46:51 CEST 2006: Prevent explosions of any kind on safe maps 443 // 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 444 // NOTE: If this breaks something important: remove this. I can't think of anything
444 // bad at the moment that might happen from this. 445 // 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) 446 if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE)
446 { 447 {
447 remove_ob (op); 448 op->destroy ();
448 free_object (op);
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->destroy ();
470 free_object (op);
471 return; 470 return;
472 } 471 }
473 472
474 tmp->x = op->x; 473 tmp->x = op->x;
475 tmp->y = op->y; 474 tmp->y = op->y;
505 504
506 insert_ob_in_map (tmp, op->map, op, 0); 505 insert_ob_in_map (tmp, op->map, op, 0);
507 /* remove the firebullet */ 506 /* remove the firebullet */
508 if (!op->destroyed ()) 507 if (!op->destroyed ())
509 { 508 {
510 remove_ob (op); 509 op->destroy ();
511 free_object (op);
512 } 510 }
513} 511}
514 512
515 513
516 514
521void 519void
522check_bullet (object *op) 520check_bullet (object *op)
523{ 521{
524 object *tmp; 522 object *tmp;
525 int dam, mflags; 523 int dam, mflags;
526 mapstruct *m; 524 maptile *m;
527 sint16 sx, sy; 525 sint16 sx, sy;
528 526
529 mflags = get_map_flags (op->map, &m, op->x, op->y, &sx, &sy); 527 mflags = get_map_flags (op->map, &m, op->x, op->y, &sx, &sy);
530 528
531 if (!(mflags & P_IS_ALIVE) && !OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy))) 529 if (!(mflags & P_IS_ALIVE) && !OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy)))
549 dam = hit_player (tmp, op->stats.dam, op, op->attacktype, 1); 547 dam = hit_player (tmp, op->stats.dam, op, op->attacktype, 1);
550 if (op->destroyed () || !tmp->destroyed () || (op->stats.dam -= dam) < 0) 548 if (op->destroyed () || !tmp->destroyed () || (op->stats.dam -= dam) < 0)
551 { 549 {
552 if (!QUERY_FLAG (op, FLAG_REMOVED)) 550 if (!QUERY_FLAG (op, FLAG_REMOVED))
553 { 551 {
554 remove_ob (op); 552 op->destroy ();
555 free_object (op);
556 return; 553 return;
557 } 554 }
558 } 555 }
559 } 556 }
560 } 557 }
570void 567void
571move_bullet (object *op) 568move_bullet (object *op)
572{ 569{
573 sint16 new_x, new_y; 570 sint16 new_x, new_y;
574 int mflags; 571 int mflags;
575 mapstruct *m; 572 maptile *m;
576 573
577#if 0 574#if 0
578 /* We need a better general purpose way to do this */ 575 /* We need a better general purpose way to do this */
579 576
580 /* peterm: added to make comet leave a trail of burnouts 577 /* peterm: added to make comet leave a trail of burnouts
589 586
590 /* Reached the end of its life - remove it */ 587 /* Reached the end of its life - remove it */
591 if (--op->range <= 0) 588 if (--op->range <= 0)
592 { 589 {
593 if (op->other_arch) 590 if (op->other_arch)
594 {
595 explode_bullet (op); 591 explode_bullet (op);
596 }
597 else 592 else
598 { 593 op->destroy ();
599 remove_ob (op); 594
600 free_object (op);
601 }
602 return; 595 return;
603 } 596 }
604 597
605 new_x = op->x + DIRX (op); 598 new_x = op->x + DIRX (op);
606 new_y = op->y + DIRY (op); 599 new_y = op->y + DIRY (op);
607 m = op->map; 600 m = op->map;
608 mflags = get_map_flags (m, &m, new_x, new_y, &new_x, &new_y); 601 mflags = get_map_flags (m, &m, new_x, new_y, &new_x, &new_y);
609 602
610 if (mflags & P_OUT_OF_MAP) 603 if (mflags & P_OUT_OF_MAP)
611 { 604 {
612 remove_ob (op); 605 op->destroy ();
613 free_object (op);
614 return; 606 return;
615 } 607 }
616 608
617 if (!op->direction || OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, new_x, new_y))) 609 if (!op->direction || OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, new_x, new_y)))
618 { 610 {
619 if (op->other_arch) 611 if (op->other_arch)
620 {
621 explode_bullet (op); 612 explode_bullet (op);
622 }
623 else 613 else
624 { 614 op->destroy ();
625 remove_ob (op); 615
626 free_object (op);
627 }
628 return; 616 return;
629 } 617 }
630 618
631 remove_ob (op); 619 op->remove ();
632 op->x = new_x; 620 op->x = new_x;
633 op->y = new_y; 621 op->y = new_y;
634 if ((op = insert_ob_in_map (op, m, op, 0)) == NULL) 622 if ((op = insert_ob_in_map (op, m, op, 0)) == NULL)
635 return; 623 return;
636 624
695 tmp->map = op->map; 683 tmp->map = op->map;
696 684
697 mflags = get_map_flags (tmp->map, &tmp->map, tmp->x, tmp->y, &tmp->x, &tmp->y); 685 mflags = get_map_flags (tmp->map, &tmp->map, tmp->x, tmp->y, &tmp->x, &tmp->y);
698 if (mflags & P_OUT_OF_MAP) 686 if (mflags & P_OUT_OF_MAP)
699 { 687 {
700 free_object (tmp); 688 tmp->destroy ();
701 return 0; 689 return 0;
702 } 690 }
691
703 if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y))) 692 if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y)))
704 { 693 {
705 if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) 694 if (!QUERY_FLAG (tmp, FLAG_REFLECTING))
706 { 695 {
707 free_object (tmp); 696 tmp->destroy ();
708 return 0; 697 return 0;
709 } 698 }
699
710 tmp->x = op->x; 700 tmp->x = op->x;
711 tmp->y = op->y; 701 tmp->y = op->y;
712 tmp->direction = absdir (tmp->direction + 4); 702 tmp->direction = absdir (tmp->direction + 4);
713 tmp->map = op->map; 703 tmp->map = op->map;
714 } 704 }
705
715 if ((tmp = insert_ob_in_map (tmp, tmp->map, op, 0)) != NULL) 706 if ((tmp = insert_ob_in_map (tmp, tmp->map, op, 0)) != NULL)
716 {
717 check_bullet (tmp); 707 check_bullet (tmp);
718 } 708
719 return 1; 709 return 1;
720} 710}
721 711
722 712
723 713
777 * when their cone dies when they die. 767 * when their cone dies when they die.
778 */ 768 */
779 /* If no owner left, the spell dies out. */ 769 /* If no owner left, the spell dies out. */
780 if (get_owner (op) == NULL) 770 if (get_owner (op) == NULL)
781 { 771 {
782 remove_ob (op); 772 op->destroy ();
783 free_object (op);
784 return; 773 return;
785 } 774 }
786#endif 775#endif
787 776
788 hit_map (op, 0, op->attacktype, 0); 777 hit_map (op, 0, op->attacktype, 0);
797 if (op->destroyed ()) 786 if (op->destroyed ())
798 return; 787 return;
799 788
800 if ((op->duration--) < 0) 789 if ((op->duration--) < 0)
801 { 790 {
802 remove_ob (op); 791 op->destroy ();
803 free_object (op);
804 return; 792 return;
805 } 793 }
806 /* Object has hit maximum range, so don't have it move 794 /* Object has hit maximum range, so don't have it move
807 * any further. When the duration above expires, 795 * any further. When the duration above expires,
808 * then the object will get removed. 796 * then the object will get removed.
817 { 805 {
818 sint16 x = op->x + freearr_x[absdir (op->stats.sp + i)], y = op->y + freearr_y[absdir (op->stats.sp + i)]; 806 sint16 x = op->x + freearr_x[absdir (op->stats.sp + i)], y = op->y + freearr_y[absdir (op->stats.sp + i)];
819 807
820 if (ok_to_put_more (op->map, x, y, op, op->attacktype)) 808 if (ok_to_put_more (op->map, x, y, op, op->attacktype))
821 { 809 {
822 object *tmp = get_object (); 810 object *tmp = object::create ();
823 811
824 copy_object (op, tmp); 812 op->copy_to (tmp);
825 tmp->x = x; 813 tmp->x = x;
826 tmp->y = y; 814 tmp->y = y;
827 815
828 tmp->duration = op->duration + 1; 816 tmp->duration = op->duration + 1;
829 817
847int 835int
848cast_cone (object *op, object *caster, int dir, object *spell) 836cast_cone (object *op, object *caster, int dir, object *spell)
849{ 837{
850 object *tmp; 838 object *tmp;
851 int i, success = 0, range_min = -1, range_max = 1; 839 int i, success = 0, range_min = -1, range_max = 1;
852 mapstruct *m; 840 maptile *m;
853 sint16 sx, sy; 841 sint16 sx, sy;
854 MoveType movetype; 842 MoveType movetype;
855 843
856 if (!spell->other_arch) 844 if (!spell->other_arch)
857 return 0; 845 return 0;
1012 return; 1000 return;
1013 1001
1014 if (env->type == PLAYER) 1002 if (env->type == PLAYER)
1015 esrv_del_item (env->contr, op->count); 1003 esrv_del_item (env->contr, op->count);
1016 1004
1017 remove_ob (op); 1005 op->remove ();
1018 op->x = env->x; 1006 op->x = env->x;
1019 op->y = env->y; 1007 op->y = env->y;
1020 if ((op = insert_ob_in_map (op, env->map, op, 0)) == NULL) 1008 if ((op = insert_ob_in_map (op, env->map, op, 0)) == NULL)
1021 return; 1009 return;
1022 } 1010 }
1024 // elmex Tue Aug 15 17:46:51 CEST 2006: Prevent bomb from exploding 1012 // 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 1013 // on a safe map. I don't like this special casing, but it seems to be neccessary
1026 // as bombs can be carried. 1014 // as bombs can be carried.
1027 if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) 1015 if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE)
1028 { 1016 {
1029 remove_ob (op); 1017 op->destroy ();
1030 free_object (op);
1031 return; 1018 return;
1032 } 1019 }
1033 1020
1034 /* This copies a lot of the code from the fire bullet, 1021 /* This copies a lot of the code from the fire bullet,
1035 * but using the cast_bullet isn't really feasible, 1022 * but using the cast_bullet isn't really feasible,
1070{ 1057{
1071 1058
1072 object *tmp; 1059 object *tmp;
1073 int mflags; 1060 int mflags;
1074 sint16 dx = op->x + freearr_x[dir], dy = op->y + freearr_y[dir]; 1061 sint16 dx = op->x + freearr_x[dir], dy = op->y + freearr_y[dir];
1075 mapstruct *m; 1062 maptile *m;
1076 1063
1077 mflags = get_map_flags (op->map, &m, dx, dy, &dx, &dy); 1064 mflags = get_map_flags (op->map, &m, dx, dy, &dx, &dy);
1078 if ((mflags & P_OUT_OF_MAP) || (GET_MAP_MOVE_BLOCK (m, dx, dy) & MOVE_WALK)) 1065 if ((mflags & P_OUT_OF_MAP) || (GET_MAP_MOVE_BLOCK (m, dx, dy) & MOVE_WALK))
1079 { 1066 {
1080 new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way."); 1067 new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way.");
1116get_pointed_target (object *op, int dir, int range, int type) 1103get_pointed_target (object *op, int dir, int range, int type)
1117{ 1104{
1118 object *target; 1105 object *target;
1119 sint16 x, y; 1106 sint16 x, y;
1120 int dist, mflags; 1107 int dist, mflags;
1121 mapstruct *mp; 1108 maptile *mp;
1122 1109
1123 if (dir == 0) 1110 if (dir == 0)
1124 return NULL; 1111 return NULL;
1125 1112
1126 for (dist = 1; dist < range; dist++) 1113 for (dist = 1; dist < range; dist++)
1229 } 1216 }
1230 else 1217 else
1231 { 1218 {
1232 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s looks stronger!", query_name (target)); 1219 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s looks stronger!", query_name (target));
1233 target->stats.hp = target->stats.maxhp * 2; 1220 target->stats.hp = target->stats.maxhp * 2;
1234 free_object (effect); 1221 effect->destroy ();
1235 return 0; 1222 return 0;
1236 } 1223 }
1237 } 1224 }
1238 } 1225 }
1239 else 1226 else
1266move_missile (object *op) 1253move_missile (object *op)
1267{ 1254{
1268 int i, mflags; 1255 int i, mflags;
1269 object *owner; 1256 object *owner;
1270 sint16 new_x, new_y; 1257 sint16 new_x, new_y;
1271 mapstruct *m; 1258 maptile *m;
1272 1259
1273 if (op->range-- <= 0) 1260 if (op->range-- <= 0)
1274 { 1261 {
1275 remove_ob (op); 1262 op->destroy ();
1276 free_object (op);
1277 return; 1263 return;
1278 } 1264 }
1279 1265
1280 owner = get_owner (op); 1266 owner = get_owner (op);
1281#if 0 1267#if 0
1282 /* It'd make things nastier if this wasn't here - spells cast by 1268 /* It'd make things nastier if this wasn't here - spells cast by
1283 * monster that are then killed would continue to survive 1269 * monster that are then killed would continue to survive
1284 */ 1270 */
1285 if (owner == NULL) 1271 if (owner == NULL)
1286 { 1272 {
1287 remove_ob (op); 1273 op->destroy ();
1288 free_object (op);
1289 return; 1274 return;
1290 } 1275 }
1291#endif 1276#endif
1292 1277
1293 new_x = op->x + DIRX (op); 1278 new_x = op->x + DIRX (op);
1300 hit_map (op, op->direction, AT_MAGIC, 1); 1285 hit_map (op, op->direction, AT_MAGIC, 1);
1301 /* Basically, missile only hits one thing then goes away. 1286 /* Basically, missile only hits one thing then goes away.
1302 * we need to remove it if someone hasn't already done so. 1287 * we need to remove it if someone hasn't already done so.
1303 */ 1288 */
1304 if (!op->destroyed ()) 1289 if (!op->destroyed ())
1305 free_object (op); 1290 op->destroy ();
1306 1291
1307 return; 1292 return;
1308 } 1293 }
1309 1294
1310 remove_ob (op); 1295 op->remove ();
1311 1296
1312 if (!op->direction || (mflags & P_OUT_OF_MAP)) 1297 if (!op->direction || (mflags & P_OUT_OF_MAP))
1313 { 1298 {
1314 free_object (op); 1299 op->destroy ();
1315 return; 1300 return;
1316 } 1301 }
1317 1302
1318 op->x = new_x; 1303 op->x = new_x;
1319 op->y = new_y; 1304 op->y = new_y;
1378int 1363int
1379cast_destruction (object *op, object *caster, object *spell_ob) 1364cast_destruction (object *op, object *caster, object *spell_ob)
1380{ 1365{
1381 int i, j, range, mflags, friendly = 0, dam, dur; 1366 int i, j, range, mflags, friendly = 0, dam, dur;
1382 sint16 sx, sy; 1367 sint16 sx, sy;
1383 mapstruct *m; 1368 maptile *m;
1384 object *tmp; 1369 object *tmp;
1385 const char *skill; 1370 const char *skill;
1386 1371
1387 range = spell_ob->range + SP_level_range_adjust (caster, spell_ob); 1372 range = spell_ob->range + SP_level_range_adjust (caster, spell_ob);
1388 dam = spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob); 1373 dam = spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob);
1570mood_change (object *op, object *caster, object *spell) 1555mood_change (object *op, object *caster, object *spell)
1571{ 1556{
1572 object *tmp, *god, *head; 1557 object *tmp, *god, *head;
1573 int done_one, range, mflags, level, at, best_at; 1558 int done_one, range, mflags, level, at, best_at;
1574 sint16 x, y, nx, ny; 1559 sint16 x, y, nx, ny;
1575 mapstruct *m; 1560 maptile *m;
1576 const char *race; 1561 const char *race;
1577 1562
1578 /* We precompute some values here so that we don't have to keep 1563 /* We precompute some values here so that we don't have to keep
1579 * doing it over and over again. 1564 * doing it over and over again.
1580 */ 1565 */
1744move_ball_spell (object *op) 1729move_ball_spell (object *op)
1745{ 1730{
1746 int i, j, dam_save, dir, mflags; 1731 int i, j, dam_save, dir, mflags;
1747 sint16 nx, ny, hx, hy; 1732 sint16 nx, ny, hx, hy;
1748 object *owner; 1733 object *owner;
1749 mapstruct *m; 1734 maptile *m;
1750 1735
1751 owner = get_owner (op); 1736 owner = get_owner (op);
1752 1737
1753 /* the following logic makes sure that the ball doesn't move into a wall, 1738 /* the following logic makes sure that the ball doesn't move into a wall,
1754 * and makes sure that it will move along a wall to try and get at it's 1739 * and makes sure that it will move along a wall to try and get at it's
1785 nx = op->x; 1770 nx = op->x;
1786 ny = op->y; 1771 ny = op->y;
1787 m = op->map; 1772 m = op->map;
1788 } 1773 }
1789 1774
1790 remove_ob (op); 1775 op->remove ();
1791 op->y = ny; 1776 op->y = ny;
1792 op->x = nx; 1777 op->x = nx;
1793 insert_ob_in_map (op, m, op, 0); 1778 insert_ob_in_map (op, m, op, 0);
1794 1779
1795 dam_save = op->stats.dam; /* save the original dam: we do halfdam on 1780 dam_save = op->stats.dam; /* save the original dam: we do halfdam on
1866#if 0 1851#if 0
1867 static int cardinal_adjust[9] = { -3, -2, -1, 0, 0, 0, 1, 2, 3 }; 1852 static int cardinal_adjust[9] = { -3, -2, -1, 0, 0, 0, 1, 2, 3 };
1868 static int diagonal_adjust[10] = { -3, -2, -2, -1, 0, 0, 1, 2, 2, 3 }; 1853 static int diagonal_adjust[10] = { -3, -2, -2, -1, 0, 0, 1, 2, 2, 3 };
1869 sint16 target_x, target_y, origin_x, origin_y; 1854 sint16 target_x, target_y, origin_x, origin_y;
1870 int adjustdir; 1855 int adjustdir;
1871 mapstruct *m; 1856 maptile *m;
1872#endif 1857#endif
1873 int basedir; 1858 int basedir;
1874 object *owner; 1859 object *owner;
1875 1860
1876 owner = get_owner (op); 1861 owner = get_owner (op);
1877 if (op->duration == 0 || owner == NULL) 1862 if (op->duration == 0 || owner == NULL)
1878 { 1863 {
1879 remove_ob (op); 1864 op->destroy ();
1880 free_object (op);
1881 return; 1865 return;
1882 } 1866 }
1867
1883 op->duration--; 1868 op->duration--;
1884 1869
1885 basedir = op->direction; 1870 basedir = op->direction;
1886 if (basedir == 0) 1871 if (basedir == 0)
1887 { 1872 {
2019cast_light (object *op, object *caster, object *spell, int dir) 2004cast_light (object *op, object *caster, object *spell, int dir)
2020{ 2005{
2021 object *target = NULL, *tmp = NULL; 2006 object *target = NULL, *tmp = NULL;
2022 sint16 x, y; 2007 sint16 x, y;
2023 int dam, mflags; 2008 int dam, mflags;
2024 mapstruct *m; 2009 maptile *m;
2025 2010
2026 dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); 2011 dam = spell->stats.dam + SP_level_dam_adjust (caster, spell);
2027 2012
2028 if (!dir) 2013 if (!dir)
2029 { 2014 {
2097cast_cause_disease (object *op, object *caster, object *spell, int dir) 2082cast_cause_disease (object *op, object *caster, object *spell, int dir)
2098{ 2083{
2099 sint16 x, y; 2084 sint16 x, y;
2100 int i, mflags, range, dam_mod, dur_mod; 2085 int i, mflags, range, dam_mod, dur_mod;
2101 object *walk; 2086 object *walk;
2102 mapstruct *m; 2087 maptile *m;
2103 2088
2104 x = op->x; 2089 x = op->x;
2105 y = op->y; 2090 y = op->y;
2106 2091
2107 /* If casting from a scroll, no direction will be available, so refer to the 2092 /* If casting from a scroll, no direction will be available, so refer to the
2199 { 2184 {
2200 object *flash; /* visual effect for inflicting disease */ 2185 object *flash; /* visual effect for inflicting disease */
2201 2186
2202 new_draw_info_format (NDI_UNIQUE, 0, op, "You inflict %s on %s!", &disease->name, &walk->name); 2187 new_draw_info_format (NDI_UNIQUE, 0, op, "You inflict %s on %s!", &disease->name, &walk->name);
2203 2188
2204 free_object (disease); /* don't need this one anymore */ 2189 disease->destroy (); /* don't need this one anymore */
2205 flash = get_archetype (ARCH_DETECT_MAGIC); 2190 flash = get_archetype (ARCH_DETECT_MAGIC);
2206 flash->x = x; 2191 flash->x = x;
2207 flash->y = y; 2192 flash->y = y;
2208 flash->map = walk->map; 2193 flash->map = walk->map;
2209 insert_ob_in_map (flash, walk->map, op, 0); 2194 insert_ob_in_map (flash, walk->map, op, 0);
2210 return 1; 2195 return 1;
2211 } 2196 }
2212 free_object (disease); 2197
2198 disease->destroy ();
2213 } 2199 }
2214 } /* if living creature */ 2200 } /* if living creature */
2215 } /* for range of spaces */ 2201 } /* for range of spaces */
2216 new_draw_info (NDI_UNIQUE, 0, op, "No one caught anything!"); 2202 new_draw_info (NDI_UNIQUE, 0, op, "No one caught anything!");
2217 return 1; 2203 return 1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines