… | |
… | |
27 | */ |
27 | */ |
28 | |
28 | |
29 | #include <global.h> |
29 | #include <global.h> |
30 | #include <object.h> |
30 | #include <object.h> |
31 | #include <living.h> |
31 | #include <living.h> |
32 | #ifndef __CEXTRACT__ |
|
|
33 | # include <sproto.h> |
32 | #include <sproto.h> |
34 | #endif |
|
|
35 | #include <spells.h> |
33 | #include <spells.h> |
36 | #include <sounds.h> |
34 | #include <sounds.h> |
37 | |
35 | |
38 | /* this function checks to see if a spell pushes objects as well |
36 | /* this function checks to see if a spell pushes objects as well |
39 | * as flies over and damages them (only used for cones for now) |
37 | * as flies over and damages them (only used for cones for now) |
… | |
… | |
57 | { |
55 | { |
58 | weight_move = op->weight + (op->weight * op->level) / 3; |
56 | weight_move = op->weight + (op->weight * op->level) / 3; |
59 | /*LOG (llevDebug, "DEBUG: arch weighs %d and masses %d (%s,level %d)\n", op->weight,weight_move,op->name,op->level); */ |
57 | /*LOG (llevDebug, "DEBUG: arch weighs %d and masses %d (%s,level %d)\n", op->weight,weight_move,op->name,op->level); */ |
60 | } |
58 | } |
61 | |
59 | |
62 | for (tmp = get_map_ob (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) |
60 | for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) |
63 | { |
61 | { |
64 | int num_sections = 1; |
62 | int num_sections = 1; |
65 | |
63 | |
66 | /* don't move DM */ |
64 | /* don't move DM */ |
67 | if (QUERY_FLAG (tmp, FLAG_WIZ)) |
65 | if (QUERY_FLAG (tmp, FLAG_WIZ)) |
… | |
… | |
140 | |
138 | |
141 | if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (m, sx, sy))) |
139 | if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (m, sx, sy))) |
142 | return; |
140 | return; |
143 | |
141 | |
144 | /* OK, we made a fork */ |
142 | /* OK, we made a fork */ |
145 | new_bolt = object::create (); |
143 | new_bolt = tmp->clone (); |
146 | tmp->copy_to (new_bolt); |
|
|
147 | |
144 | |
148 | /* reduce chances of subsequent forking */ |
145 | /* reduce chances of subsequent forking */ |
149 | new_bolt->stats.Dex -= 10; |
146 | new_bolt->stats.Dex -= 10; |
150 | tmp->stats.Dex -= 10; /* less forks from main bolt too */ |
147 | tmp->stats.Dex -= 10; /* less forks from main bolt too */ |
151 | new_bolt->stats.Con += 25 * new_dir; /* adjust the left bias */ |
148 | new_bolt->stats.Con += 25 * new_dir; /* adjust the left bias */ |
… | |
… | |
249 | update_turn_face (op); /* A bolt *must* be IS_TURNABLE */ |
246 | update_turn_face (op); /* A bolt *must* be IS_TURNABLE */ |
250 | return; |
247 | return; |
251 | } |
248 | } |
252 | else |
249 | else |
253 | { /* Create a copy of this object and put it ahead */ |
250 | { /* Create a copy of this object and put it ahead */ |
254 | tmp = object::create (); |
251 | tmp = op->clone (); |
255 | op->copy_to (tmp); |
252 | |
256 | tmp->speed_left = -0.1; |
253 | tmp->speed_left = -0.1; |
257 | tmp->x += DIRX (tmp), tmp->y += DIRY (tmp); |
254 | tmp->x += DIRX (tmp), tmp->y += DIRY (tmp); |
258 | tmp = insert_ob_in_map (tmp, op->map, op, 0); |
255 | tmp = insert_ob_in_map (tmp, op->map, op, 0); |
259 | /* To make up for the decrease at the top of the function */ |
256 | /* To make up for the decrease at the top of the function */ |
260 | tmp->duration++; |
257 | tmp->duration++; |
… | |
… | |
281 | * we remove the magic flag - that can be derived from |
278 | * we remove the magic flag - that can be derived from |
282 | * spob->attacktype. |
279 | * spob->attacktype. |
283 | * This function sets up the appropriate owner and skill |
280 | * This function sets up the appropriate owner and skill |
284 | * pointers. |
281 | * pointers. |
285 | */ |
282 | */ |
286 | |
|
|
287 | int |
283 | int |
288 | fire_bolt (object *op, object *caster, int dir, object *spob, object *skill) |
284 | fire_bolt (object *op, object *caster, int dir, object *spob, object *skill) |
289 | { |
285 | { |
290 | object *tmp = NULL; |
286 | object *tmp = NULL; |
291 | int mflags; |
287 | int mflags; |
… | |
… | |
309 | |
305 | |
310 | tmp->direction = dir; |
306 | tmp->direction = dir; |
311 | if (QUERY_FLAG (tmp, FLAG_IS_TURNABLE)) |
307 | if (QUERY_FLAG (tmp, FLAG_IS_TURNABLE)) |
312 | SET_ANIMATION (tmp, dir); |
308 | SET_ANIMATION (tmp, dir); |
313 | |
309 | |
314 | set_owner (tmp, op); |
310 | tmp->set_owner (op); |
315 | set_spell_skill (op, caster, spob, tmp); |
311 | set_spell_skill (op, caster, spob, tmp); |
316 | |
312 | |
317 | tmp->x = op->x + DIRX (tmp); |
313 | tmp->x = op->x + DIRX (tmp); |
318 | tmp->y = op->y + DIRY (tmp); |
314 | tmp->y = op->y + DIRY (tmp); |
319 | tmp->map = op->map; |
315 | tmp->map = op->map; |
320 | |
316 | |
|
|
317 | maptile *newmap; |
321 | mflags = get_map_flags (tmp->map, &tmp->map, tmp->x, tmp->y, &tmp->x, &tmp->y); |
318 | mflags = get_map_flags (tmp->map, &newmap, tmp->x, tmp->y, &tmp->x, &tmp->y); |
322 | if (mflags & P_OUT_OF_MAP) |
319 | if (mflags & P_OUT_OF_MAP) |
323 | { |
320 | { |
324 | tmp->destroy (); |
321 | tmp->destroy (); |
325 | return 0; |
322 | return 0; |
326 | } |
323 | } |
|
|
324 | |
|
|
325 | tmp->map = newmap; |
327 | |
326 | |
328 | if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y))) |
327 | if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y))) |
329 | { |
328 | { |
330 | if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) |
329 | if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) |
331 | { |
330 | { |
… | |
… | |
383 | /* ok_to_put_more already does things like checks for walls, |
382 | /* ok_to_put_more already does things like checks for walls, |
384 | * out of map, etc. |
383 | * out of map, etc. |
385 | */ |
384 | */ |
386 | if (ok_to_put_more (op->map, dx, dy, op, op->attacktype)) |
385 | if (ok_to_put_more (op->map, dx, dy, op, op->attacktype)) |
387 | { |
386 | { |
388 | tmp = object::create (); |
387 | tmp = op->clone (); |
389 | op->copy_to (tmp); |
|
|
390 | tmp->state = 0; |
388 | tmp->state = 0; |
391 | tmp->speed_left = -0.21; |
389 | tmp->speed_left = -0.21; |
392 | tmp->range--; |
390 | tmp->range--; |
393 | tmp->value = 0; |
391 | tmp->value = 0; |
394 | tmp->x = dx; |
392 | tmp->x = dx; |
… | |
… | |
457 | } |
455 | } |
458 | |
456 | |
459 | /* other_arch contains what this explodes into */ |
457 | /* other_arch contains what this explodes into */ |
460 | tmp = arch_to_object (op->other_arch); |
458 | tmp = arch_to_object (op->other_arch); |
461 | |
459 | |
462 | copy_owner (tmp, op); |
460 | tmp->set_owner (op); |
463 | tmp->skill = op->skill; |
461 | tmp->skill = op->skill; |
464 | |
462 | |
465 | owner = get_owner (op); |
463 | owner = op->owner; |
466 | |
464 | |
467 | if ((tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER) && owner && !tailor_god_spell (tmp, owner)) |
465 | if ((tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER) && owner && !tailor_god_spell (tmp, owner)) |
468 | { |
466 | { |
469 | op->destroy (); |
467 | op->destroy (); |
470 | return; |
468 | return; |
… | |
… | |
538 | |
536 | |
539 | /* If nothing alive on this space, no reason to do anything further */ |
537 | /* If nothing alive on this space, no reason to do anything further */ |
540 | if (!(mflags & P_IS_ALIVE)) |
538 | if (!(mflags & P_IS_ALIVE)) |
541 | return; |
539 | return; |
542 | |
540 | |
543 | for (tmp = get_map_ob (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) |
541 | for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) |
544 | { |
542 | { |
545 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
543 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
546 | { |
544 | { |
547 | dam = hit_player (tmp, op->stats.dam, op, op->attacktype, 1); |
545 | dam = hit_player (tmp, op->stats.dam, op, op->attacktype, 1); |
548 | if (op->destroyed () || !tmp->destroyed () || (op->stats.dam -= dam) < 0) |
546 | if (op->destroyed () || !tmp->destroyed () || (op->stats.dam -= dam) < 0) |
… | |
… | |
555 | } |
553 | } |
556 | } |
554 | } |
557 | } |
555 | } |
558 | } |
556 | } |
559 | |
557 | |
560 | |
|
|
561 | /* Basically, we move 'op' one square, and if it hits something, |
558 | /* Basically, we move 'op' one square, and if it hits something, |
562 | * call check_bullet. |
559 | * call check_bullet. |
563 | * This function is only applicable to bullets, but not to all |
560 | * This function is only applicable to bullets, but not to all |
564 | * fired arches (eg, bolts). |
561 | * fired arches (eg, bolts). |
565 | */ |
562 | */ |
566 | |
|
|
567 | void |
563 | void |
568 | move_bullet (object *op) |
564 | move_bullet (object *op) |
569 | { |
565 | { |
570 | sint16 new_x, new_y; |
566 | sint16 new_x, new_y; |
571 | int mflags; |
567 | int mflags; |
… | |
… | |
626 | { |
622 | { |
627 | op->direction = absdir (op->direction + 4); |
623 | op->direction = absdir (op->direction + 4); |
628 | update_turn_face (op); |
624 | update_turn_face (op); |
629 | } |
625 | } |
630 | else |
626 | else |
631 | { |
|
|
632 | check_bullet (op); |
627 | check_bullet (op); |
633 | } |
|
|
634 | } |
628 | } |
635 | |
629 | |
636 | |
630 | |
637 | |
631 | |
638 | |
632 | |
… | |
… | |
673 | |
667 | |
674 | tmp->direction = dir; |
668 | tmp->direction = dir; |
675 | if (QUERY_FLAG (tmp, FLAG_IS_TURNABLE)) |
669 | if (QUERY_FLAG (tmp, FLAG_IS_TURNABLE)) |
676 | SET_ANIMATION (tmp, dir); |
670 | SET_ANIMATION (tmp, dir); |
677 | |
671 | |
678 | set_owner (tmp, op); |
672 | tmp->set_owner (op); |
679 | set_spell_skill (op, caster, spob, tmp); |
673 | set_spell_skill (op, caster, spob, tmp); |
680 | |
674 | |
681 | tmp->x = op->x + freearr_x[dir]; |
675 | tmp->x = op->x + freearr_x[dir]; |
682 | tmp->y = op->y + freearr_y[dir]; |
676 | tmp->y = op->y + freearr_y[dir]; |
683 | tmp->map = op->map; |
677 | tmp->map = op->map; |
684 | |
678 | |
|
|
679 | maptile *newmap; |
685 | mflags = get_map_flags (tmp->map, &tmp->map, tmp->x, tmp->y, &tmp->x, &tmp->y); |
680 | mflags = get_map_flags (tmp->map, &newmap, tmp->x, tmp->y, &tmp->x, &tmp->y); |
686 | if (mflags & P_OUT_OF_MAP) |
681 | if (mflags & P_OUT_OF_MAP) |
687 | { |
682 | { |
688 | tmp->destroy (); |
683 | tmp->destroy (); |
689 | return 0; |
684 | return 0; |
690 | } |
685 | } |
|
|
686 | |
|
|
687 | tmp->map = newmap; |
691 | |
688 | |
692 | if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y))) |
689 | if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y))) |
693 | { |
690 | { |
694 | if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) |
691 | if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) |
695 | { |
692 | { |
… | |
… | |
701 | tmp->y = op->y; |
698 | tmp->y = op->y; |
702 | tmp->direction = absdir (tmp->direction + 4); |
699 | tmp->direction = absdir (tmp->direction + 4); |
703 | tmp->map = op->map; |
700 | tmp->map = op->map; |
704 | } |
701 | } |
705 | |
702 | |
706 | if ((tmp = insert_ob_in_map (tmp, tmp->map, op, 0)) != NULL) |
703 | if ((tmp = insert_ob_in_map (tmp, tmp->map, op, 0))) |
707 | check_bullet (tmp); |
704 | check_bullet (tmp); |
708 | |
705 | |
709 | return 1; |
706 | return 1; |
710 | } |
707 | } |
711 | |
708 | |
… | |
… | |
726 | object *new_ob = arch_to_object (op->other_arch); |
723 | object *new_ob = arch_to_object (op->other_arch); |
727 | |
724 | |
728 | new_ob->x = op->x; |
725 | new_ob->x = op->x; |
729 | new_ob->y = op->y; |
726 | new_ob->y = op->y; |
730 | new_ob->level = op->level; |
727 | new_ob->level = op->level; |
731 | set_owner (new_ob, op->owner); |
728 | new_ob->set_owner (op->owner); |
732 | |
729 | |
733 | /* preserve skill ownership */ |
730 | /* preserve skill ownership */ |
734 | if (op->skill && op->skill != new_ob->skill) |
731 | if (op->skill && op->skill != new_ob->skill) |
735 | { |
732 | { |
736 | new_ob->skill = op->skill; |
733 | new_ob->skill = op->skill; |
… | |
… | |
748 | |
745 | |
749 | /* if no map then hit_map will crash so just ignore object */ |
746 | /* if no map then hit_map will crash so just ignore object */ |
750 | if (!op->map) |
747 | if (!op->map) |
751 | { |
748 | { |
752 | LOG (llevError, "Tried to move_cone object %s without a map.\n", op->name ? &op->name : "unknown"); |
749 | LOG (llevError, "Tried to move_cone object %s without a map.\n", op->name ? &op->name : "unknown"); |
753 | op->speed = 0; |
750 | op->set_speed (0); |
754 | update_ob_speed (op); |
|
|
755 | return; |
751 | return; |
756 | } |
752 | } |
757 | |
753 | |
758 | /* lava saves it's life, but not yours :) */ |
754 | /* lava saves it's life, but not yours :) */ |
759 | if (QUERY_FLAG (op, FLAG_LIFESAVE)) |
755 | if (QUERY_FLAG (op, FLAG_LIFESAVE)) |
… | |
… | |
765 | #if 0 |
761 | #if 0 |
766 | /* Disable this - enabling it makes monsters easier, as |
762 | /* Disable this - enabling it makes monsters easier, as |
767 | * when their cone dies when they die. |
763 | * when their cone dies when they die. |
768 | */ |
764 | */ |
769 | /* If no owner left, the spell dies out. */ |
765 | /* If no owner left, the spell dies out. */ |
770 | if (get_owner (op) == NULL) |
766 | if (op->owner == NULL) |
771 | { |
767 | { |
772 | op->destroy (); |
768 | op->destroy (); |
773 | return; |
769 | return; |
774 | } |
770 | } |
775 | #endif |
771 | #endif |
… | |
… | |
805 | { |
801 | { |
806 | sint16 x = op->x + freearr_x[absdir (op->stats.sp + i)], y = op->y + freearr_y[absdir (op->stats.sp + i)]; |
802 | sint16 x = op->x + freearr_x[absdir (op->stats.sp + i)], y = op->y + freearr_y[absdir (op->stats.sp + i)]; |
807 | |
803 | |
808 | if (ok_to_put_more (op->map, x, y, op, op->attacktype)) |
804 | if (ok_to_put_more (op->map, x, y, op, op->attacktype)) |
809 | { |
805 | { |
810 | object *tmp = object::create (); |
806 | object *tmp = op->clone (); |
811 | |
807 | |
812 | op->copy_to (tmp); |
|
|
813 | tmp->x = x; |
808 | tmp->x = x; |
814 | tmp->y = y; |
809 | tmp->y = y; |
815 | |
810 | |
816 | tmp->duration = op->duration + 1; |
811 | tmp->duration = op->duration + 1; |
817 | |
812 | |
… | |
… | |
901 | if ((movetype & GET_MAP_MOVE_BLOCK (m, sx, sy)) == movetype) |
896 | if ((movetype & GET_MAP_MOVE_BLOCK (m, sx, sy)) == movetype) |
902 | continue; |
897 | continue; |
903 | |
898 | |
904 | success = 1; |
899 | success = 1; |
905 | tmp = arch_to_object (spell->other_arch); |
900 | tmp = arch_to_object (spell->other_arch); |
906 | set_owner (tmp, op); |
901 | tmp->set_owner (op); |
907 | set_spell_skill (op, caster, spell, tmp); |
902 | set_spell_skill (op, caster, spell, tmp); |
908 | tmp->level = caster_level (caster, spell); |
903 | tmp->level = caster_level (caster, spell); |
909 | tmp->x = sx; |
904 | tmp->x = sx; |
910 | tmp->y = sy; |
905 | tmp->y = sy; |
911 | tmp->attacktype = spell->attacktype; |
906 | tmp->attacktype = spell->attacktype; |
… | |
… | |
1033 | tmp->direction = i; |
1028 | tmp->direction = i; |
1034 | tmp->range = op->range; |
1029 | tmp->range = op->range; |
1035 | tmp->stats.dam = op->stats.dam; |
1030 | tmp->stats.dam = op->stats.dam; |
1036 | tmp->duration = op->duration; |
1031 | tmp->duration = op->duration; |
1037 | tmp->attacktype = op->attacktype; |
1032 | tmp->attacktype = op->attacktype; |
1038 | copy_owner (tmp, op); |
1033 | tmp->set_owner (op); |
1039 | if (op->skill && op->skill != tmp->skill) |
1034 | if (op->skill && op->skill != tmp->skill) |
1040 | { |
1035 | { |
1041 | tmp->skill = op->skill; |
1036 | tmp->skill = op->skill; |
1042 | } |
1037 | } |
1043 | if (QUERY_FLAG (tmp, FLAG_IS_TURNABLE)) |
1038 | if (QUERY_FLAG (tmp, FLAG_IS_TURNABLE)) |
… | |
… | |
1073 | tmp->range = spell->range + SP_level_range_adjust (caster, spell); |
1068 | tmp->range = spell->range + SP_level_range_adjust (caster, spell); |
1074 | tmp->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
1069 | tmp->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
1075 | tmp->duration = spell->duration + SP_level_duration_adjust (caster, spell); |
1070 | tmp->duration = spell->duration + SP_level_duration_adjust (caster, spell); |
1076 | tmp->attacktype = spell->attacktype; |
1071 | tmp->attacktype = spell->attacktype; |
1077 | |
1072 | |
1078 | set_owner (tmp, op); |
1073 | tmp->set_owner (op); |
1079 | set_spell_skill (op, caster, spell, tmp); |
1074 | set_spell_skill (op, caster, spell, tmp); |
1080 | tmp->x = dx; |
1075 | tmp->x = dx; |
1081 | tmp->y = dy; |
1076 | tmp->y = dy; |
1082 | insert_ob_in_map (tmp, m, op, 0); |
1077 | insert_ob_in_map (tmp, m, op, 0); |
1083 | return 1; |
1078 | return 1; |
… | |
… | |
1126 | if (GET_MAP_MOVE_BLOCK (mp, x, y) & MOVE_FLY_LOW) |
1121 | if (GET_MAP_MOVE_BLOCK (mp, x, y) & MOVE_FLY_LOW) |
1127 | return NULL; |
1122 | return NULL; |
1128 | |
1123 | |
1129 | if (mflags & P_IS_ALIVE) |
1124 | if (mflags & P_IS_ALIVE) |
1130 | { |
1125 | { |
1131 | for (target = get_map_ob (mp, x, y); target; target = target->above) |
1126 | for (target = GET_MAP_OB (mp, x, y); target; target = target->above) |
1132 | { |
1127 | { |
1133 | if (QUERY_FLAG (target->head ? target->head : target, FLAG_MONSTER)) |
1128 | if (QUERY_FLAG (target->head ? target->head : target, FLAG_MONSTER)) |
1134 | { |
1129 | { |
1135 | return target; |
1130 | return target; |
1136 | } |
1131 | } |
… | |
… | |
1203 | if (effect->attacktype & AT_DEATH) |
1198 | if (effect->attacktype & AT_DEATH) |
1204 | { |
1199 | { |
1205 | effect->level = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
1200 | effect->level = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
1206 | |
1201 | |
1207 | /* casting death spells at undead isn't a good thing */ |
1202 | /* casting death spells at undead isn't a good thing */ |
1208 | if QUERY_FLAG |
|
|
1209 | (target, FLAG_UNDEAD) |
1203 | if (QUERY_FLAG (target, FLAG_UNDEAD)) |
1210 | { |
1204 | { |
1211 | if (random_roll (0, 2, op, PREFER_LOW)) |
1205 | if (random_roll (0, 2, op, PREFER_LOW)) |
1212 | { |
1206 | { |
1213 | new_draw_info (NDI_UNIQUE, 0, op, "Idiot! Your spell boomerangs!"); |
1207 | new_draw_info (NDI_UNIQUE, 0, op, "Idiot! Your spell boomerangs!"); |
1214 | effect->x = op->x; |
1208 | effect->x = op->x; |
… | |
… | |
1227 | { |
1221 | { |
1228 | /* how much woe to inflict :) */ |
1222 | /* how much woe to inflict :) */ |
1229 | effect->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
1223 | effect->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
1230 | } |
1224 | } |
1231 | |
1225 | |
1232 | set_owner (effect, op); |
1226 | effect->set_owner (op); |
1233 | set_spell_skill (op, caster, spell, effect); |
1227 | set_spell_skill (op, caster, spell, effect); |
1234 | |
1228 | |
1235 | /* ok, tell it where to be, and insert! */ |
1229 | /* ok, tell it where to be, and insert! */ |
1236 | effect->x = target->x; |
1230 | effect->x = target->x; |
1237 | effect->y = target->y; |
1231 | effect->y = target->y; |
… | |
… | |
1261 | { |
1255 | { |
1262 | op->destroy (); |
1256 | op->destroy (); |
1263 | return; |
1257 | return; |
1264 | } |
1258 | } |
1265 | |
1259 | |
1266 | owner = get_owner (op); |
1260 | owner = op->owner; |
1267 | #if 0 |
1261 | #if 0 |
1268 | /* It'd make things nastier if this wasn't here - spells cast by |
1262 | /* It'd make things nastier if this wasn't here - spells cast by |
1269 | * monster that are then killed would continue to survive |
1263 | * monster that are then killed would continue to survive |
1270 | */ |
1264 | */ |
1271 | if (owner == NULL) |
1265 | if (owner == NULL) |
… | |
… | |
1301 | } |
1295 | } |
1302 | |
1296 | |
1303 | op->x = new_x; |
1297 | op->x = new_x; |
1304 | op->y = new_y; |
1298 | op->y = new_y; |
1305 | op->map = m; |
1299 | op->map = m; |
1306 | i = spell_find_dir (op->map, op->x, op->y, get_owner (op)); |
1300 | i = spell_find_dir (op->map, op->x, op->y, op->owner); |
1307 | if (i > 0 && i != op->direction) |
1301 | if (i > 0 && i != op->direction) |
1308 | { |
1302 | { |
1309 | op->direction = i; |
1303 | op->direction = i; |
1310 | SET_ANIMATION (op, op->direction); |
1304 | SET_ANIMATION (op, op->direction); |
1311 | } |
1305 | } |
… | |
… | |
1401 | mflags = get_map_flags (m, &m, sx, sy, &sx, &sy); |
1395 | mflags = get_map_flags (m, &m, sx, sy, &sx, &sy); |
1402 | if (mflags & P_OUT_OF_MAP) |
1396 | if (mflags & P_OUT_OF_MAP) |
1403 | continue; |
1397 | continue; |
1404 | if (mflags & P_IS_ALIVE) |
1398 | if (mflags & P_IS_ALIVE) |
1405 | { |
1399 | { |
1406 | for (tmp = get_map_ob (m, sx, sy); tmp; tmp = tmp->above) |
1400 | for (tmp = GET_MAP_OB (m, sx, sy); tmp; tmp = tmp->above) |
1407 | { |
1401 | { |
1408 | if (QUERY_FLAG (tmp, FLAG_ALIVE) || tmp->type == PLAYER) |
1402 | if (QUERY_FLAG (tmp, FLAG_ALIVE) || tmp->type == PLAYER) |
1409 | break; |
1403 | break; |
1410 | } |
1404 | } |
1411 | if (tmp) |
1405 | if (tmp) |
… | |
… | |
1534 | force->stats.ac = spell_ob->stats.ac; |
1528 | force->stats.ac = spell_ob->stats.ac; |
1535 | force->stats.wc = spell_ob->stats.wc; |
1529 | force->stats.wc = spell_ob->stats.wc; |
1536 | |
1530 | |
1537 | change_abil (tmp, force); /* Mostly to display any messages */ |
1531 | change_abil (tmp, force); /* Mostly to display any messages */ |
1538 | insert_ob_in_ob (force, tmp); |
1532 | insert_ob_in_ob (force, tmp); |
1539 | fix_player (tmp); |
1533 | tmp->update_stats (); |
1540 | return 1; |
1534 | return 1; |
1541 | |
1535 | |
1542 | } |
1536 | } |
1543 | |
1537 | |
1544 | |
1538 | |
… | |
… | |
1595 | |
1589 | |
1596 | /* If there is nothing living on this space, no need to go further */ |
1590 | /* If there is nothing living on this space, no need to go further */ |
1597 | if (!(mflags & P_IS_ALIVE)) |
1591 | if (!(mflags & P_IS_ALIVE)) |
1598 | continue; |
1592 | continue; |
1599 | |
1593 | |
1600 | for (tmp = get_map_ob (m, nx, ny); tmp; tmp = tmp->above) |
1594 | for (tmp = GET_MAP_OB (m, nx, ny); tmp; tmp = tmp->above) |
1601 | if (QUERY_FLAG (tmp, FLAG_MONSTER)) |
1595 | if (QUERY_FLAG (tmp, FLAG_MONSTER)) |
1602 | break; |
1596 | break; |
1603 | |
1597 | |
1604 | /* There can be living objects that are not monsters */ |
1598 | /* There can be living objects that are not monsters */ |
1605 | if (!tmp || tmp->type == PLAYER) |
1599 | if (!tmp || tmp->type == PLAYER) |
… | |
… | |
1693 | SET_FLAG (head, FLAG_FRIENDLY); |
1687 | SET_FLAG (head, FLAG_FRIENDLY); |
1694 | /* Prevent uncontolled outbreaks of self replicating monsters. |
1688 | /* Prevent uncontolled outbreaks of self replicating monsters. |
1695 | Typical use case is charm, go somwhere, use aggravation to make hostile. |
1689 | Typical use case is charm, go somwhere, use aggravation to make hostile. |
1696 | This could lead to fun stuff like mice outbreak in bigworld and server crawl. */ |
1690 | This could lead to fun stuff like mice outbreak in bigworld and server crawl. */ |
1697 | CLEAR_FLAG (head, FLAG_GENERATOR); |
1691 | CLEAR_FLAG (head, FLAG_GENERATOR); |
1698 | set_owner (head, op); |
1692 | head->set_owner (op); |
1699 | set_spell_skill (op, caster, spell, head); |
1693 | set_spell_skill (op, caster, spell, head); |
1700 | add_friendly_object (head); |
1694 | add_friendly_object (head); |
1701 | head->attack_movement = PETMOVE; |
1695 | head->attack_movement = PETMOVE; |
1702 | done_one = 1; |
1696 | done_one = 1; |
1703 | change_exp (op, head->stats.exp / 2, head->skill, SK_EXP_ADD_SKILL); |
1697 | change_exp (op, head->stats.exp / 2, head->skill, SK_EXP_ADD_SKILL); |
… | |
… | |
1731 | int i, j, dam_save, dir, mflags; |
1725 | int i, j, dam_save, dir, mflags; |
1732 | sint16 nx, ny, hx, hy; |
1726 | sint16 nx, ny, hx, hy; |
1733 | object *owner; |
1727 | object *owner; |
1734 | maptile *m; |
1728 | maptile *m; |
1735 | |
1729 | |
1736 | owner = get_owner (op); |
1730 | owner = op->owner; |
1737 | |
1731 | |
1738 | /* the following logic makes sure that the ball doesn't move into a wall, |
1732 | /* the following logic makes sure that the ball doesn't move into a wall, |
1739 | * and makes sure that it will move along a wall to try and get at it's |
1733 | * and makes sure that it will move along a wall to try and get at it's |
1740 | * victim. The block immediately below more or less chooses a random |
1734 | * victim. The block immediately below more or less chooses a random |
1741 | * offset to move the ball, eg, keep it mostly on course, with some |
1735 | * offset to move the ball, eg, keep it mostly on course, with some |
… | |
… | |
1820 | } |
1814 | } |
1821 | |
1815 | |
1822 | /* restore to the center location and damage */ |
1816 | /* restore to the center location and damage */ |
1823 | op->stats.dam = dam_save; |
1817 | op->stats.dam = dam_save; |
1824 | |
1818 | |
1825 | i = spell_find_dir (op->map, op->x, op->y, get_owner (op)); |
1819 | i = spell_find_dir (op->map, op->x, op->y, op->owner); |
1826 | |
1820 | |
1827 | if (i >= 0) |
1821 | if (i >= 0) |
1828 | { /* we have a preferred direction! */ |
1822 | { /* we have a preferred direction! */ |
1829 | /* pick another direction if the preferred dir is blocked. */ |
1823 | /* pick another direction if the preferred dir is blocked. */ |
1830 | if (get_map_flags (op->map, &m, nx + freearr_x[i], ny + freearr_y[i], &hx, &hy) & P_OUT_OF_MAP || |
1824 | if (get_map_flags (op->map, &m, nx + freearr_x[i], ny + freearr_y[i], &hx, &hy) & P_OUT_OF_MAP || |
… | |
… | |
1856 | maptile *m; |
1850 | maptile *m; |
1857 | #endif |
1851 | #endif |
1858 | int basedir; |
1852 | int basedir; |
1859 | object *owner; |
1853 | object *owner; |
1860 | |
1854 | |
1861 | owner = get_owner (op); |
1855 | owner = op->owner; |
1862 | if (op->duration == 0 || owner == NULL) |
1856 | if (op->duration == 0 || owner == NULL) |
1863 | { |
1857 | { |
1864 | op->destroy (); |
1858 | op->destroy (); |
1865 | return; |
1859 | return; |
1866 | } |
1860 | } |
… | |
… | |
1971 | return 0; |
1965 | return 0; |
1972 | |
1966 | |
1973 | tmp = get_archetype (SWARM_SPELL); |
1967 | tmp = get_archetype (SWARM_SPELL); |
1974 | tmp->x = op->x; |
1968 | tmp->x = op->x; |
1975 | tmp->y = op->y; |
1969 | tmp->y = op->y; |
1976 | set_owner (tmp, op); /* needed so that if swarm elements kill, caster gets xp. */ |
1970 | tmp->set_owner (op); /* needed so that if swarm elements kill, caster gets xp. */ |
1977 | set_spell_skill (op, caster, spell, tmp); |
1971 | set_spell_skill (op, caster, spell, tmp); |
1978 | |
1972 | |
1979 | tmp->level = caster_level (caster, spell); /*needed later, to get level dep. right. */ |
1973 | tmp->level = caster_level (caster, spell); /*needed later, to get level dep. right. */ |
1980 | tmp->spell = arch_to_object (spell->other_arch); |
1974 | tmp->spell = arch_to_object (spell->other_arch); |
1981 | |
1975 | |
… | |
… | |
2028 | return 0; |
2022 | return 0; |
2029 | } |
2023 | } |
2030 | |
2024 | |
2031 | if (mflags & P_IS_ALIVE && spell->attacktype) |
2025 | if (mflags & P_IS_ALIVE && spell->attacktype) |
2032 | { |
2026 | { |
2033 | for (target = get_map_ob (m, x, y); target; target = target->above) |
2027 | for (target = GET_MAP_OB (m, x, y); target; target = target->above) |
2034 | if (QUERY_FLAG (target, FLAG_MONSTER)) |
2028 | if (QUERY_FLAG (target, FLAG_MONSTER)) |
2035 | { |
2029 | { |
2036 | /* oky doky. got a target monster. Lets make a blinding attack */ |
2030 | /* oky doky. got a target monster. Lets make a blinding attack */ |
2037 | if (target->head) |
2031 | if (target->head) |
2038 | target = target->head; |
2032 | target = target->head; |
… | |
… | |
2120 | |
2114 | |
2121 | /* Only bother looking on this space if there is something living here */ |
2115 | /* Only bother looking on this space if there is something living here */ |
2122 | if (mflags & P_IS_ALIVE) |
2116 | if (mflags & P_IS_ALIVE) |
2123 | { |
2117 | { |
2124 | /* search this square for a victim */ |
2118 | /* search this square for a victim */ |
2125 | for (walk = get_map_ob (m, x, y); walk; walk = walk->above) |
2119 | for (walk = GET_MAP_OB (m, x, y); walk; walk = walk->above) |
2126 | if (QUERY_FLAG (walk, FLAG_MONSTER) || (walk->type == PLAYER)) |
2120 | if (QUERY_FLAG (walk, FLAG_MONSTER) || (walk->type == PLAYER)) |
2127 | { /* found a victim */ |
2121 | { /* found a victim */ |
2128 | object *disease = arch_to_object (spell->other_arch); |
2122 | object *disease = arch_to_object (spell->other_arch); |
2129 | |
2123 | |
2130 | set_owner (disease, op); |
2124 | disease->set_owner (op); |
2131 | set_spell_skill (op, caster, spell, disease); |
2125 | set_spell_skill (op, caster, spell, disease); |
2132 | disease->stats.exp = 0; |
2126 | disease->stats.exp = 0; |
2133 | disease->level = caster_level (caster, spell); |
2127 | disease->level = caster_level (caster, spell); |
2134 | |
2128 | |
2135 | /* do level adjustments */ |
2129 | /* do level adjustments */ |