1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992 Frank Tore Johansen |
6 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * the terms of the Affero GNU General Public License as published by the |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * option) any later version. |
11 | * option) any later version. |
12 | * |
12 | * |
13 | * This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
17 | * |
17 | * |
18 | * You should have received a copy of the Affero GNU General Public License |
18 | * You should have received a copy of the Affero GNU General Public License |
19 | * and the GNU General Public License along with this program. If not, see |
19 | * and the GNU General Public License along with this program. If not, see |
20 | * <http://www.gnu.org/licenses/>. |
20 | * <http://www.gnu.org/licenses/>. |
21 | * |
21 | * |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
23 | */ |
23 | */ |
24 | |
24 | |
25 | /* |
25 | /* |
26 | * Routines that is executed from objects based on their speed have been |
26 | * Routines that is executed from objects based on their speed have been |
… | |
… | |
28 | */ |
28 | */ |
29 | #include <global.h> |
29 | #include <global.h> |
30 | #include <spells.h> |
30 | #include <spells.h> |
31 | #include <sproto.h> |
31 | #include <sproto.h> |
32 | |
32 | |
33 | /* The following removes doors. The functions check to see if similar |
33 | /* The following removes doors. The functions check to see if similar |
34 | * doors are next to the one that is being removed, and if so, set it |
34 | * doors are next to the one that is being removed, and if so, set it |
35 | * so those will be removed shortly (in a cascade like fashion.) |
35 | * so those will be removed shortly (in a cascade like fashion.) |
36 | */ |
36 | */ |
37 | void |
37 | void |
38 | remove_door (object *op) |
38 | remove_door (object *op) |
… | |
… | |
69 | int i; |
69 | int i; |
70 | object *tmp; |
70 | object *tmp; |
71 | |
71 | |
72 | for (i = 1; i < 9; i += 2) |
72 | for (i = 1; i < 9; i += 2) |
73 | { |
73 | { |
74 | tmp = present (LOCKED_DOOR, op->map, op->x + freearr_x[i], op->y + freearr_y[i]); |
74 | tmp = present (LOCKED_DOOR, op->map, op->x + DIRX (i), op->y + DIRY (i)); |
75 | if (tmp && tmp->slaying == op->slaying) |
75 | if (tmp && tmp->slaying == op->slaying) |
76 | { /* same key both doors */ |
76 | { /* same key both doors */ |
77 | tmp->set_speed (0.1f); |
77 | tmp->set_speed (0.1f); |
78 | tmp->speed_left = -0.2f; |
78 | tmp->speed_left = -0.2f; |
79 | } |
79 | } |
… | |
… | |
609 | op->stats.grace = 0; |
609 | op->stats.grace = 0; |
610 | op->level = 0; |
610 | op->level = 0; |
611 | op->face = op->arch->face; |
611 | op->face = op->arch->face; |
612 | op->owner = 0; |
612 | op->owner = 0; |
613 | |
613 | |
|
|
614 | op->clr_flag (FLAG_NO_PICK); /* fire_bow makes arrows NO_PICK so monsters (or anything else) don't pick them mid-flight */ |
|
|
615 | |
614 | update_object (op, UP_OBJ_CHANGE); |
616 | update_object (op, UP_OBJ_CHANGE); |
615 | |
617 | |
616 | return op; |
618 | return op; |
617 | } |
619 | } |
618 | |
620 | |
… | |
… | |
689 | * about 17 squares. Tune as needed. |
691 | * about 17 squares. Tune as needed. |
690 | */ |
692 | */ |
691 | op->set_speed (op->speed - 0.05); |
693 | op->set_speed (op->speed - 0.05); |
692 | |
694 | |
693 | /* if the arrow is moving too slow.. stop it. 0.5 was chosen as lower |
695 | /* if the arrow is moving too slow.. stop it. 0.5 was chosen as lower |
694 | values look rediculous. */ |
696 | values look ridiculous. */ |
695 | if (op->speed < (op->type == ARROW ? 0.5 : MIN_ACTIVE_SPEED)) |
697 | if (op->speed < (op->type == ARROW ? 0.5 : MIN_ACTIVE_SPEED)) |
696 | { |
698 | { |
697 | stop_arrow (op); |
699 | stop_arrow (op); |
698 | return; |
700 | return; |
699 | } |
701 | } |
… | |
… | |
713 | if (pos->flags () & P_IS_ALIVE) |
715 | if (pos->flags () & P_IS_ALIVE) |
714 | { |
716 | { |
715 | object *tmp; |
717 | object *tmp; |
716 | |
718 | |
717 | for (tmp = pos->bot; tmp; tmp = tmp->above) |
719 | for (tmp = pos->bot; tmp; tmp = tmp->above) |
718 | if (tmp->flag [FLAG_ALIVE]) |
720 | if (tmp->flag [FLAG_ALIVE] && tmp != op->owner) |
719 | break; |
721 | { |
720 | |
|
|
721 | /* Not really fair, but don't let monsters hit themselves with |
722 | /* Not really fair, but don't let monsters hit themselves with |
722 | * their own arrow - this can be because they fire it then |
723 | * their own arrow - this can be because they fire it then |
723 | * move into it. |
724 | * move into it. |
724 | */ |
725 | */ |
725 | if (tmp && tmp != op->owner) |
726 | |
726 | { |
|
|
727 | /* Found living object, but it is reflecting the missile. Update |
727 | /* Found living object, but it is reflecting the missile. Update |
728 | * as below. (Note that for living creatures there is a small |
728 | * as below. (Note that for living creatures there is a small |
729 | * chance that reflect_missile fails.) |
729 | * chance that reflect_missile fails.) |
730 | */ |
730 | */ |
731 | if (tmp->flag [FLAG_REFL_MISSILE] && (rndm (0, 99)) < (90 - op->level / 10)) |
731 | if (tmp->flag [FLAG_REFL_MISSILE] && (rndm (0, 99)) < (90 - op->level / 10)) |
732 | { |
732 | { |
733 | op->direction = absdir (op->direction + 4); |
733 | op->direction = absdir (op->direction + 4); |
734 | update_turn_face (op); |
734 | update_turn_face (op); |
735 | was_reflected = 1; /* skip normal movement calculations */ |
735 | was_reflected = 1; /* skip normal movement calculations */ |
736 | } |
736 | } |
737 | else |
737 | else |
738 | { |
738 | { |
739 | /* Attack the object. */ |
739 | /* Attack the object. */ |
740 | op = hit_with_arrow (op, tmp); |
740 | op = hit_with_arrow (op, tmp); |
741 | |
741 | |
742 | if (!op) |
742 | if (!op) |
743 | return; |
743 | return; |
744 | } |
744 | } |
745 | } /* if this is not hitting its owner */ |
745 | |
746 | } /* if there is something alive on this space */ |
746 | break; |
|
|
747 | } |
|
|
748 | } |
747 | |
749 | |
748 | if (OB_TYPE_MOVE_BLOCK (op, pos->move_block)) |
750 | if (OB_TYPE_MOVE_BLOCK (op, pos->move_block)) |
749 | { |
751 | { |
750 | int retry = 0; |
752 | int retry = 0; |
751 | |
753 | |
… | |
… | |
1032 | /* Determine direction only once so we do the right thing */ |
1034 | /* Determine direction only once so we do the right thing */ |
1033 | // why is it the right thing, though? |
1035 | // why is it the right thing, though? |
1034 | if (!dir) |
1036 | if (!dir) |
1035 | dir = op->stats.sp ? op->stats.sp : rndm (1, 8); |
1037 | dir = op->stats.sp ? op->stats.sp : rndm (1, 8); |
1036 | |
1038 | |
1037 | sint16 nx = op->x + freearr_x[dir]; |
1039 | sint16 nx = op->x + DIRX (dir); |
1038 | sint16 ny = op->y + freearr_y[dir]; |
1040 | sint16 ny = op->y + DIRY (dir); |
1039 | maptile *m = op->map; |
1041 | maptile *m = op->map; |
1040 | if (get_map_flags (m, &m, nx, ny, &nx, &ny) & P_OUT_OF_MAP) |
1042 | if (get_map_flags (m, &m, nx, ny, &nx, &ny) & P_OUT_OF_MAP) |
1041 | { |
1043 | { |
1042 | LOG (llevError, "move_player_mover: Trying to push player off the map! map=%s (%d, %d)\n", &m->path, op->x, op->y); |
1044 | LOG (llevError, "move_player_mover: Trying to push player off the map! map=%s (%d, %d)\n", &m->path, op->x, op->y); |
1043 | return; |
1045 | return; |
… | |
… | |
1129 | break; |
1131 | break; |
1130 | } |
1132 | } |
1131 | } |
1133 | } |
1132 | } |
1134 | } |
1133 | |
1135 | |
1134 | /* move_creator (by peterm) |
1136 | /* move_creator (by peterm) |
1135 | * it has the creator object create it's other_arch right on top of it. |
1137 | * it has the creator object create it's other_arch right on top of it. |
1136 | * connected: what will trigger it |
1138 | * connected: what will trigger it |
1137 | * hp: how many times it may create before stopping |
1139 | * hp: how many times it may create before stopping |
1138 | * lifesave: if set, it'll never disappear but will go on creating |
1140 | * lifesave: if set, it'll never disappear but will go on creating |
1139 | * everytime it's triggered |
1141 | * everytime it's triggered |