… | |
… | |
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)) |
… | |
… | |
280 | * we remove the magic flag - that can be derived from |
278 | * we remove the magic flag - that can be derived from |
281 | * spob->attacktype. |
279 | * spob->attacktype. |
282 | * This function sets up the appropriate owner and skill |
280 | * This function sets up the appropriate owner and skill |
283 | * pointers. |
281 | * pointers. |
284 | */ |
282 | */ |
285 | |
|
|
286 | int |
283 | int |
287 | 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) |
288 | { |
285 | { |
289 | object *tmp = NULL; |
286 | object *tmp = NULL; |
290 | int mflags; |
287 | int mflags; |
… | |
… | |
315 | |
312 | |
316 | tmp->x = op->x + DIRX (tmp); |
313 | tmp->x = op->x + DIRX (tmp); |
317 | tmp->y = op->y + DIRY (tmp); |
314 | tmp->y = op->y + DIRY (tmp); |
318 | tmp->map = op->map; |
315 | tmp->map = op->map; |
319 | |
316 | |
|
|
317 | maptile *newmap; |
320 | 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); |
321 | if (mflags & P_OUT_OF_MAP) |
319 | if (mflags & P_OUT_OF_MAP) |
322 | { |
320 | { |
323 | tmp->destroy (); |
321 | tmp->destroy (); |
324 | return 0; |
322 | return 0; |
325 | } |
323 | } |
|
|
324 | |
|
|
325 | tmp->map = newmap; |
326 | |
326 | |
327 | 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))) |
328 | { |
328 | { |
329 | if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) |
329 | if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) |
330 | { |
330 | { |
… | |
… | |
536 | |
536 | |
537 | /* 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 */ |
538 | if (!(mflags & P_IS_ALIVE)) |
538 | if (!(mflags & P_IS_ALIVE)) |
539 | return; |
539 | return; |
540 | |
540 | |
541 | 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) |
542 | { |
542 | { |
543 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
543 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
544 | { |
544 | { |
545 | dam = hit_player (tmp, op->stats.dam, op, op->attacktype, 1); |
545 | dam = hit_player (tmp, op->stats.dam, op, op->attacktype, 1); |
546 | if (op->destroyed () || !tmp->destroyed () || (op->stats.dam -= dam) < 0) |
546 | if (op->destroyed () || !tmp->destroyed () || (op->stats.dam -= dam) < 0) |
… | |
… | |
553 | } |
553 | } |
554 | } |
554 | } |
555 | } |
555 | } |
556 | } |
556 | } |
557 | |
557 | |
558 | |
|
|
559 | /* Basically, we move 'op' one square, and if it hits something, |
558 | /* Basically, we move 'op' one square, and if it hits something, |
560 | * call check_bullet. |
559 | * call check_bullet. |
561 | * This function is only applicable to bullets, but not to all |
560 | * This function is only applicable to bullets, but not to all |
562 | * fired arches (eg, bolts). |
561 | * fired arches (eg, bolts). |
563 | */ |
562 | */ |
564 | |
|
|
565 | void |
563 | void |
566 | move_bullet (object *op) |
564 | move_bullet (object *op) |
567 | { |
565 | { |
568 | sint16 new_x, new_y; |
566 | sint16 new_x, new_y; |
569 | int mflags; |
567 | int mflags; |
… | |
… | |
624 | { |
622 | { |
625 | op->direction = absdir (op->direction + 4); |
623 | op->direction = absdir (op->direction + 4); |
626 | update_turn_face (op); |
624 | update_turn_face (op); |
627 | } |
625 | } |
628 | else |
626 | else |
629 | { |
|
|
630 | check_bullet (op); |
627 | check_bullet (op); |
631 | } |
|
|
632 | } |
628 | } |
633 | |
629 | |
634 | |
630 | |
635 | |
631 | |
636 | |
632 | |
… | |
… | |
678 | |
674 | |
679 | tmp->x = op->x + freearr_x[dir]; |
675 | tmp->x = op->x + freearr_x[dir]; |
680 | tmp->y = op->y + freearr_y[dir]; |
676 | tmp->y = op->y + freearr_y[dir]; |
681 | tmp->map = op->map; |
677 | tmp->map = op->map; |
682 | |
678 | |
|
|
679 | maptile *newmap; |
683 | 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); |
684 | if (mflags & P_OUT_OF_MAP) |
681 | if (mflags & P_OUT_OF_MAP) |
685 | { |
682 | { |
686 | tmp->destroy (); |
683 | tmp->destroy (); |
687 | return 0; |
684 | return 0; |
688 | } |
685 | } |
|
|
686 | |
|
|
687 | tmp->map = newmap; |
689 | |
688 | |
690 | 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))) |
691 | { |
690 | { |
692 | if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) |
691 | if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) |
693 | { |
692 | { |
… | |
… | |
699 | tmp->y = op->y; |
698 | tmp->y = op->y; |
700 | tmp->direction = absdir (tmp->direction + 4); |
699 | tmp->direction = absdir (tmp->direction + 4); |
701 | tmp->map = op->map; |
700 | tmp->map = op->map; |
702 | } |
701 | } |
703 | |
702 | |
704 | if ((tmp = insert_ob_in_map (tmp, tmp->map, op, 0)) != NULL) |
703 | if ((tmp = insert_ob_in_map (tmp, tmp->map, op, 0))) |
705 | check_bullet (tmp); |
704 | check_bullet (tmp); |
706 | |
705 | |
707 | return 1; |
706 | return 1; |
708 | } |
707 | } |
709 | |
708 | |
… | |
… | |
746 | |
745 | |
747 | /* 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 */ |
748 | if (!op->map) |
747 | if (!op->map) |
749 | { |
748 | { |
750 | 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"); |
751 | op->speed = 0; |
750 | op->set_speed (0); |
752 | update_ob_speed (op); |
|
|
753 | return; |
751 | return; |
754 | } |
752 | } |
755 | |
753 | |
756 | /* lava saves it's life, but not yours :) */ |
754 | /* lava saves it's life, but not yours :) */ |
757 | if (QUERY_FLAG (op, FLAG_LIFESAVE)) |
755 | if (QUERY_FLAG (op, FLAG_LIFESAVE)) |
… | |
… | |
1123 | if (GET_MAP_MOVE_BLOCK (mp, x, y) & MOVE_FLY_LOW) |
1121 | if (GET_MAP_MOVE_BLOCK (mp, x, y) & MOVE_FLY_LOW) |
1124 | return NULL; |
1122 | return NULL; |
1125 | |
1123 | |
1126 | if (mflags & P_IS_ALIVE) |
1124 | if (mflags & P_IS_ALIVE) |
1127 | { |
1125 | { |
1128 | 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) |
1129 | { |
1127 | { |
1130 | if (QUERY_FLAG (target->head ? target->head : target, FLAG_MONSTER)) |
1128 | if (QUERY_FLAG (target->head ? target->head : target, FLAG_MONSTER)) |
1131 | { |
1129 | { |
1132 | return target; |
1130 | return target; |
1133 | } |
1131 | } |
… | |
… | |
1397 | mflags = get_map_flags (m, &m, sx, sy, &sx, &sy); |
1395 | mflags = get_map_flags (m, &m, sx, sy, &sx, &sy); |
1398 | if (mflags & P_OUT_OF_MAP) |
1396 | if (mflags & P_OUT_OF_MAP) |
1399 | continue; |
1397 | continue; |
1400 | if (mflags & P_IS_ALIVE) |
1398 | if (mflags & P_IS_ALIVE) |
1401 | { |
1399 | { |
1402 | 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) |
1403 | { |
1401 | { |
1404 | if (QUERY_FLAG (tmp, FLAG_ALIVE) || tmp->type == PLAYER) |
1402 | if (QUERY_FLAG (tmp, FLAG_ALIVE) || tmp->type == PLAYER) |
1405 | break; |
1403 | break; |
1406 | } |
1404 | } |
1407 | if (tmp) |
1405 | if (tmp) |
… | |
… | |
1530 | force->stats.ac = spell_ob->stats.ac; |
1528 | force->stats.ac = spell_ob->stats.ac; |
1531 | force->stats.wc = spell_ob->stats.wc; |
1529 | force->stats.wc = spell_ob->stats.wc; |
1532 | |
1530 | |
1533 | change_abil (tmp, force); /* Mostly to display any messages */ |
1531 | change_abil (tmp, force); /* Mostly to display any messages */ |
1534 | insert_ob_in_ob (force, tmp); |
1532 | insert_ob_in_ob (force, tmp); |
1535 | fix_player (tmp); |
1533 | tmp->update_stats (); |
1536 | return 1; |
1534 | return 1; |
1537 | |
1535 | |
1538 | } |
1536 | } |
1539 | |
1537 | |
1540 | |
1538 | |
… | |
… | |
1591 | |
1589 | |
1592 | /* 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 */ |
1593 | if (!(mflags & P_IS_ALIVE)) |
1591 | if (!(mflags & P_IS_ALIVE)) |
1594 | continue; |
1592 | continue; |
1595 | |
1593 | |
1596 | 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) |
1597 | if (QUERY_FLAG (tmp, FLAG_MONSTER)) |
1595 | if (QUERY_FLAG (tmp, FLAG_MONSTER)) |
1598 | break; |
1596 | break; |
1599 | |
1597 | |
1600 | /* There can be living objects that are not monsters */ |
1598 | /* There can be living objects that are not monsters */ |
1601 | if (!tmp || tmp->type == PLAYER) |
1599 | if (!tmp || tmp->type == PLAYER) |
… | |
… | |
2024 | return 0; |
2022 | return 0; |
2025 | } |
2023 | } |
2026 | |
2024 | |
2027 | if (mflags & P_IS_ALIVE && spell->attacktype) |
2025 | if (mflags & P_IS_ALIVE && spell->attacktype) |
2028 | { |
2026 | { |
2029 | 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) |
2030 | if (QUERY_FLAG (target, FLAG_MONSTER)) |
2028 | if (QUERY_FLAG (target, FLAG_MONSTER)) |
2031 | { |
2029 | { |
2032 | /* oky doky. got a target monster. Lets make a blinding attack */ |
2030 | /* oky doky. got a target monster. Lets make a blinding attack */ |
2033 | if (target->head) |
2031 | if (target->head) |
2034 | target = target->head; |
2032 | target = target->head; |
… | |
… | |
2116 | |
2114 | |
2117 | /* 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 */ |
2118 | if (mflags & P_IS_ALIVE) |
2116 | if (mflags & P_IS_ALIVE) |
2119 | { |
2117 | { |
2120 | /* search this square for a victim */ |
2118 | /* search this square for a victim */ |
2121 | 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) |
2122 | if (QUERY_FLAG (walk, FLAG_MONSTER) || (walk->type == PLAYER)) |
2120 | if (QUERY_FLAG (walk, FLAG_MONSTER) || (walk->type == PLAYER)) |
2123 | { /* found a victim */ |
2121 | { /* found a victim */ |
2124 | object *disease = arch_to_object (spell->other_arch); |
2122 | object *disease = arch_to_object (spell->other_arch); |
2125 | |
2123 | |
2126 | disease->set_owner (op); |
2124 | disease->set_owner (op); |