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 |
… | |
… | |
337 | |
337 | |
338 | case RING: |
338 | case RING: |
339 | flag = monster->flag [FLAG_USE_RING]; |
339 | flag = monster->flag [FLAG_USE_RING]; |
340 | break; |
340 | break; |
341 | |
341 | |
|
|
342 | case RANGED: |
342 | case WAND: |
343 | case WAND: |
343 | case HORN: |
344 | case HORN: |
344 | case ROD: |
345 | case ROD: |
345 | flag = monster->flag [FLAG_USE_RANGE]; |
346 | flag = monster->flag [FLAG_USE_RANGE]; |
346 | break; |
347 | break; |
… | |
… | |
1272 | /* for target facing, we copy this value here for fast access */ |
1273 | /* for target facing, we copy this value here for fast access */ |
1273 | if (oph->head) /* force update the head - one arch one pic */ |
1274 | if (oph->head) /* force update the head - one arch one pic */ |
1274 | oph = oph->head; |
1275 | oph = oph->head; |
1275 | |
1276 | |
1276 | if (op->flag [FLAG_NO_ATTACK]) /* we never ever attack */ |
1277 | if (op->flag [FLAG_NO_ATTACK]) /* we never ever attack */ |
1277 | enemy = op->enemy = NULL; |
1278 | enemy = op->enemy = 0; |
1278 | else if ((enemy = find_enemy (op, &rv))) |
1279 | else if ((enemy = find_enemy (op, &rv))) |
1279 | /* we have an enemy, just tell him we want him dead */ |
1280 | /* we have an enemy, just tell him we want him dead */ |
1280 | enemy->attacked_by = op; /* our ptr */ |
1281 | enemy->attacked_by = op; /* our ptr */ |
1281 | |
1282 | |
1282 | /* generate hp, if applicable */ |
1283 | /* generate hp, if applicable */ |
… | |
… | |
1763 | * 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 |
1764 | * find that. |
1765 | * find that. |
1765 | */ |
1766 | */ |
1766 | // 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 |
1767 | // 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 |
1768 | radius = min (25, radius); |
1769 | min_it (radius, 25); |
1769 | |
1770 | |
1770 | /* Enemy in range! Now test for detection */ |
1771 | /* Enemy in range! Now test for detection */ |
1771 | if (rv->distance <= radius) |
1772 | if (rv->distance <= radius) |
1772 | { |
1773 | { |
1773 | /* ah, we are within range, detected? take cases */ |
1774 | /* ah, we are within range, detected? take cases */ |
… | |
… | |
1828 | return 1; |
1829 | return 1; |
1829 | |
1830 | |
1830 | if (op->map) |
1831 | if (op->map) |
1831 | unordered_mapwalk (mapwalk_buf, op, -MAX_LIGHT_RADIUS, -MAX_LIGHT_RADIUS, MAX_LIGHT_RADIUS, MAX_LIGHT_RADIUS) |
1832 | unordered_mapwalk (mapwalk_buf, op, -MAX_LIGHT_RADIUS, -MAX_LIGHT_RADIUS, MAX_LIGHT_RADIUS, MAX_LIGHT_RADIUS) |
1832 | { |
1833 | { |
|
|
1834 | mapspace &ms = m->at (nx, ny); |
|
|
1835 | |
|
|
1836 | ms.update (); |
|
|
1837 | |
1833 | /* Check the spaces with the max light radius to see if any of them |
1838 | /* Check the spaces with the max light radius to see if any of them |
1834 | * have lights, and if any of them light the player enough, then return 1. |
1839 | * have lights, and if any of them light the player enough, then return 1. |
1835 | */ |
1840 | */ |
1836 | int light = m->at (nx, ny).light; |
1841 | int light = ms.light; |
1837 | |
1842 | |
1838 | if (expect_false (light > 0) && idistance (dx, dy) <= light) |
1843 | if (expect_false (light > 0) && idistance (dx, dy) <= light) |
1839 | return 1; |
1844 | return 1; |
1840 | } |
1845 | } |
1841 | } |
1846 | } |