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 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 |
… | |
… | |
689 | * about 17 squares. Tune as needed. |
689 | * about 17 squares. Tune as needed. |
690 | */ |
690 | */ |
691 | op->set_speed (op->speed - 0.05); |
691 | op->set_speed (op->speed - 0.05); |
692 | |
692 | |
693 | /* if the arrow is moving too slow.. stop it. 0.5 was chosen as lower |
693 | /* if the arrow is moving too slow.. stop it. 0.5 was chosen as lower |
694 | values look rediculous. */ |
694 | values look ridiculous. */ |
695 | if (op->speed < (op->type == ARROW ? 0.5 : MIN_ACTIVE_SPEED)) |
695 | if (op->speed < (op->type == ARROW ? 0.5 : MIN_ACTIVE_SPEED)) |
696 | { |
696 | { |
697 | stop_arrow (op); |
697 | stop_arrow (op); |
698 | return; |
698 | return; |
699 | } |
699 | } |
… | |
… | |
713 | if (pos->flags () & P_IS_ALIVE) |
713 | if (pos->flags () & P_IS_ALIVE) |
714 | { |
714 | { |
715 | object *tmp; |
715 | object *tmp; |
716 | |
716 | |
717 | for (tmp = pos->bot; tmp; tmp = tmp->above) |
717 | for (tmp = pos->bot; tmp; tmp = tmp->above) |
718 | if (tmp->flag [FLAG_ALIVE]) |
718 | if (tmp->flag [FLAG_ALIVE] && tmp != op->owner) |
719 | break; |
719 | { |
720 | |
|
|
721 | /* Not really fair, but don't let monsters hit themselves with |
720 | /* Not really fair, but don't let monsters hit themselves with |
722 | * their own arrow - this can be because they fire it then |
721 | * their own arrow - this can be because they fire it then |
723 | * move into it. |
722 | * move into it. |
724 | */ |
723 | */ |
725 | if (tmp && tmp != op->owner) |
724 | |
726 | { |
|
|
727 | /* Found living object, but it is reflecting the missile. Update |
725 | /* Found living object, but it is reflecting the missile. Update |
728 | * as below. (Note that for living creatures there is a small |
726 | * as below. (Note that for living creatures there is a small |
729 | * chance that reflect_missile fails.) |
727 | * chance that reflect_missile fails.) |
730 | */ |
728 | */ |
731 | if (tmp->flag [FLAG_REFL_MISSILE] && (rndm (0, 99)) < (90 - op->level / 10)) |
729 | if (tmp->flag [FLAG_REFL_MISSILE] && (rndm (0, 99)) < (90 - op->level / 10)) |
732 | { |
730 | { |
733 | op->direction = absdir (op->direction + 4); |
731 | op->direction = absdir (op->direction + 4); |
734 | update_turn_face (op); |
732 | update_turn_face (op); |
735 | was_reflected = 1; /* skip normal movement calculations */ |
733 | was_reflected = 1; /* skip normal movement calculations */ |
736 | } |
734 | } |
737 | else |
735 | else |
738 | { |
736 | { |
739 | /* Attack the object. */ |
737 | /* Attack the object. */ |
740 | op = hit_with_arrow (op, tmp); |
738 | op = hit_with_arrow (op, tmp); |
741 | |
739 | |
742 | if (!op) |
740 | if (!op) |
743 | return; |
741 | return; |
744 | } |
742 | } |
745 | } /* if this is not hitting its owner */ |
743 | |
746 | } /* if there is something alive on this space */ |
744 | break; |
|
|
745 | } |
|
|
746 | } |
747 | |
747 | |
748 | if (OB_TYPE_MOVE_BLOCK (op, pos->move_block)) |
748 | if (OB_TYPE_MOVE_BLOCK (op, pos->move_block)) |
749 | { |
749 | { |
750 | int retry = 0; |
750 | int retry = 0; |
751 | |
751 | |