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 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 | //+GPL |
25 | //+GPL |
26 | |
26 | |
… | |
… | |
255 | /* This covers the situation where the monster is in the dark |
255 | /* This covers the situation where the monster is in the dark |
256 | * and has an enemy. If the enemy has no carried light (or isnt |
256 | * and has an enemy. If the enemy has no carried light (or isnt |
257 | * glowing!) then the monster has trouble finding the enemy. |
257 | * glowing!) then the monster has trouble finding the enemy. |
258 | * Remember we already checked to see if the monster can see in |
258 | * Remember we already checked to see if the monster can see in |
259 | * the dark. */ |
259 | * the dark. */ |
260 | radius = min (radius, MIN_MON_RADIUS + MAX_DARKNESS - op->map->darklevel ()); |
260 | min_it (radius, MIN_MON_RADIUS + MAX_DARKNESS - op->map->darklevel ()); |
261 | |
261 | |
262 | if (enemy->flag [FLAG_STEALTH]) |
262 | if (enemy->flag [FLAG_STEALTH]) |
263 | radius = radius / 2 + 1; |
263 | radius = radius / 2 + 1; |
264 | |
264 | |
265 | /* enemy should already be on this map, so don't really need to check |
265 | /* enemy should already be on this map, so don't really need to check |
… | |
… | |
1273 | /* for target facing, we copy this value here for fast access */ |
1273 | /* for target facing, we copy this value here for fast access */ |
1274 | if (oph->head) /* force update the head - one arch one pic */ |
1274 | if (oph->head) /* force update the head - one arch one pic */ |
1275 | oph = oph->head; |
1275 | oph = oph->head; |
1276 | |
1276 | |
1277 | if (op->flag [FLAG_NO_ATTACK]) /* we never ever attack */ |
1277 | if (op->flag [FLAG_NO_ATTACK]) /* we never ever attack */ |
1278 | enemy = op->enemy = NULL; |
1278 | enemy = op->enemy = 0; |
1279 | else if ((enemy = find_enemy (op, &rv))) |
1279 | else if ((enemy = find_enemy (op, &rv))) |
1280 | /* we have an enemy, just tell him we want him dead */ |
1280 | /* we have an enemy, just tell him we want him dead */ |
1281 | enemy->attacked_by = op; /* our ptr */ |
1281 | enemy->attacked_by = op; /* our ptr */ |
1282 | |
1282 | |
1283 | /* generate hp, if applicable */ |
1283 | /* generate hp, if applicable */ |
… | |
… | |
1764 | * vector is real distance, so in theory this should be 18 to |
1764 | * vector is real distance, so in theory this should be 18 to |
1765 | * find that. |
1765 | * find that. |
1766 | */ |
1766 | */ |
1767 | // note that the above reasoning was utter bullshit even at the time it was written |
1767 | // note that the above reasoning was utter bullshit even at the time it was written |
1768 | // we use 25, lets see if we have the cpu time for it |
1768 | // we use 25, lets see if we have the cpu time for it |
1769 | radius = min (25, radius); |
1769 | min_it (radius, 25); |
1770 | |
1770 | |
1771 | /* Enemy in range! Now test for detection */ |
1771 | /* Enemy in range! Now test for detection */ |
1772 | if (rv->distance <= radius) |
1772 | if (rv->distance <= radius) |
1773 | { |
1773 | { |
1774 | /* ah, we are within range, detected? take cases */ |
1774 | /* ah, we are within range, detected? take cases */ |