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 |
… | |
… | |
371 | flag = 1; |
371 | flag = 1; |
372 | break; |
372 | break; |
373 | } |
373 | } |
374 | } |
374 | } |
375 | |
375 | |
376 | if (((!(monster->pick_up & 32)) && flag) || ((monster->pick_up & 32) && (!flag))) |
376 | if (((!(monster->pick_up & 32)) && flag) || ((monster->pick_up & 32) && !flag)) |
377 | return 1; |
377 | return 1; |
378 | |
378 | |
379 | return 0; |
379 | return 0; |
380 | } |
380 | } |
381 | |
381 | |
… | |
… | |
395 | * affect stacking on this space. |
395 | * affect stacking on this space. |
396 | */ |
396 | */ |
397 | static void |
397 | static void |
398 | monster_check_pickup (object *monster) |
398 | monster_check_pickup (object *monster) |
399 | { |
399 | { |
400 | object *tmp, *next; |
|
|
401 | |
|
|
402 | for (tmp = monster->below; tmp != NULL; tmp = next) |
400 | for (object *next, *tmp = monster->below; tmp; tmp = next) |
403 | { |
401 | { |
404 | next = tmp->below; |
402 | next = tmp->below; |
|
|
403 | |
405 | if (monster_can_pick (monster, tmp)) |
404 | if (monster_can_pick (monster, tmp)) |
406 | { |
405 | { |
407 | tmp->remove (); |
406 | tmp->remove (); |
408 | tmp = insert_ob_in_ob (tmp, monster); |
407 | tmp = insert_ob_in_ob (tmp, monster); |
409 | monster_check_apply (monster, tmp); |
408 | monster_check_apply (monster, tmp); |
… | |
… | |
1273 | /* for target facing, we copy this value here for fast access */ |
1272 | /* for target facing, we copy this value here for fast access */ |
1274 | if (oph->head) /* force update the head - one arch one pic */ |
1273 | if (oph->head) /* force update the head - one arch one pic */ |
1275 | oph = oph->head; |
1274 | oph = oph->head; |
1276 | |
1275 | |
1277 | if (op->flag [FLAG_NO_ATTACK]) /* we never ever attack */ |
1276 | if (op->flag [FLAG_NO_ATTACK]) /* we never ever attack */ |
1278 | enemy = op->enemy = NULL; |
1277 | enemy = op->enemy = 0; |
1279 | else if ((enemy = find_enemy (op, &rv))) |
1278 | else if ((enemy = find_enemy (op, &rv))) |
1280 | /* we have an enemy, just tell him we want him dead */ |
1279 | /* we have an enemy, just tell him we want him dead */ |
1281 | enemy->attacked_by = op; /* our ptr */ |
1280 | enemy->attacked_by = op; /* our ptr */ |
1282 | |
1281 | |
1283 | /* generate hp, if applicable */ |
1282 | /* generate hp, if applicable */ |
… | |
… | |
1764 | * vector is real distance, so in theory this should be 18 to |
1763 | * vector is real distance, so in theory this should be 18 to |
1765 | * find that. |
1764 | * find that. |
1766 | */ |
1765 | */ |
1767 | // note that the above reasoning was utter bullshit even at the time it was written |
1766 | // 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 |
1767 | // we use 25, lets see if we have the cpu time for it |
1769 | radius = min (25, radius); |
1768 | min_it (radius, 25); |
1770 | |
1769 | |
1771 | /* Enemy in range! Now test for detection */ |
1770 | /* Enemy in range! Now test for detection */ |
1772 | if (rv->distance <= radius) |
1771 | if (rv->distance <= radius) |
1773 | { |
1772 | { |
1774 | /* ah, we are within range, detected? take cases */ |
1773 | /* ah, we are within range, detected? take cases */ |