ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/monster.C
(Generate patch)

Comparing deliantra/server/server/monster.C (file contents):
Revision 1.85 by root, Sun Apr 11 00:34:06 2010 UTC vs.
Revision 1.96 by root, Wed Nov 16 23:42:02 2016 UTC

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;
593 594
594 for (bow = mon->inv; bow; bow = bow->below) 595 for (bow = mon->inv; bow; bow = bow->below)
595 if (bow->type == BOW && bow->race == item->race) 596 if (bow->type == BOW && bow->race == item->race)
596 { 597 {
597 mon->set_flag (FLAG_READY_BOW); 598 mon->set_flag (FLAG_READY_BOW);
598 LOG (llevMonster, "Found correct bow for arrows.\n");
599 return; /* nothing more to do for arrows */ 599 return; /* nothing more to do for arrows */
600 } 600 }
601 } 601 }
602 602
603 if (item->type == TREASURE && mon->will_apply & WILL_APPLY_TREASURE) 603 if (item->type == TREASURE && mon->will_apply & WILL_APPLY_TREASURE)
941 */ 941 */
942 if (head->spellitem == NULL) 942 if (head->spellitem == NULL)
943 { 943 {
944 if ((spell_item = monster_choose_random_spell (head)) == NULL) 944 if ((spell_item = monster_choose_random_spell (head)) == NULL)
945 { 945 {
946 LOG (llevMonster, "Turned off spells in %s\n", &head->name);
947 head->clr_flag (FLAG_CAST_SPELL); /* Will be turned on when picking up book */ 946 head->clr_flag (FLAG_CAST_SPELL); /* Will be turned on when picking up book */
948 return 0; 947 return 0;
949 } 948 }
950 949
951 if (spell_item->type == SPELLBOOK) 950 if (spell_item->type == SPELLBOOK)
1051 if (!(dir = path_to_player (part, pl, 0))) 1050 if (!(dir = path_to_player (part, pl, 0)))
1052 return 0; 1051 return 0;
1053 1052
1054 if (head->flag [FLAG_FRIENDLY] && (owner = head->owner) != NULL) 1053 if (head->flag [FLAG_FRIENDLY] && (owner = head->owner) != NULL)
1055 { 1054 {
1056 int dir2 = find_dir_2 (head->x - owner->x, head->y - owner->y); 1055 int dir2 = find_dir_2 (owner->x - head->x, owner->y - head->y);
1057 1056
1058 if (dirdiff (dir, dir2) < 1) 1057 if (dirdiff (dir, dir2) < 1)
1059 return 0; /* Might hit owner with skill -thrown rocks for example ? */ 1058 return 0; /* Might hit owner with skill -thrown rocks for example ? */
1060 } 1059 }
1061 1060
1093 if (!(dir = path_to_player (part, pl, 0))) 1092 if (!(dir = path_to_player (part, pl, 0)))
1094 return 0; 1093 return 0;
1095 1094
1096 if (head->flag [FLAG_FRIENDLY] && (owner = head->owner) != NULL) 1095 if (head->flag [FLAG_FRIENDLY] && (owner = head->owner) != NULL)
1097 { 1096 {
1098 int dir2 = find_dir_2 (head->x - owner->x, head->y - owner->y); 1097 int dir2 = find_dir_2 (owner->x - head->x, owner->y - head->y);
1099 1098
1100 if (dirdiff (dir, dir2) < 2) 1099 if (dirdiff (dir, dir2) < 2)
1101 return 0; /* Might hit owner with spell */ 1100 return 0; /* Might hit owner with spell */
1102 } 1101 }
1103 1102
1165 if (head->flag [FLAG_CONFUSED]) 1164 if (head->flag [FLAG_CONFUSED])
1166 dir = absdir (dir + rndm (3) + rndm (3) - 2); 1165 dir = absdir (dir + rndm (3) + rndm (3) - 2);
1167 1166
1168 if (head->flag [FLAG_FRIENDLY] && (owner = head->owner) != NULL) 1167 if (head->flag [FLAG_FRIENDLY] && (owner = head->owner) != NULL)
1169 { 1168 {
1170 int dir2 = find_dir_2 (head->x - owner->x, head->y - owner->y); 1169 int dir2 = find_dir_2 (owner->x - head->x, owner->y - head->y);
1171 1170
1172 if (dirdiff (dir, dir2) < 1) 1171 if (dirdiff (dir, dir2) < 1)
1173 return 0; /* Might hit owner with arrow */ 1172 return 0; /* Might hit owner with arrow */
1174 } 1173 }
1175 1174
1274 /* for target facing, we copy this value here for fast access */ 1273 /* for target facing, we copy this value here for fast access */
1275 if (oph->head) /* force update the head - one arch one pic */ 1274 if (oph->head) /* force update the head - one arch one pic */
1276 oph = oph->head; 1275 oph = oph->head;
1277 1276
1278 if (op->flag [FLAG_NO_ATTACK]) /* we never ever attack */ 1277 if (op->flag [FLAG_NO_ATTACK]) /* we never ever attack */
1279 enemy = op->enemy = NULL; 1278 enemy = op->enemy = 0;
1280 else if ((enemy = find_enemy (op, &rv))) 1279 else if ((enemy = find_enemy (op, &rv)))
1281 /* we have an enemy, just tell him we want him dead */ 1280 /* we have an enemy, just tell him we want him dead */
1282 enemy->attacked_by = op; /* our ptr */ 1281 enemy->attacked_by = op; /* our ptr */
1283 1282
1284 /* generate hp, if applicable */ 1283 /* generate hp, if applicable */
1765 * 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
1766 * find that. 1765 * find that.
1767 */ 1766 */
1768 // 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
1769 // 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
1770 radius = min (25, radius); 1769 min_it (radius, 25);
1771 1770
1772 /* Enemy in range! Now test for detection */ 1771 /* Enemy in range! Now test for detection */
1773 if (rv->distance <= radius) 1772 if (rv->distance <= radius)
1774 { 1773 {
1775 /* ah, we are within range, detected? take cases */ 1774 /* ah, we are within range, detected? take cases */
1830 return 1; 1829 return 1;
1831 1830
1832 if (op->map) 1831 if (op->map)
1833 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)
1834 { 1833 {
1834 mapspace &ms = m->at (nx, ny);
1835
1836 ms.update ();
1837
1835 /* 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
1836 * 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.
1837 */ 1840 */
1838 int light = m->at (nx, ny).light; 1841 int light = ms.light;
1839 1842
1840 if (expect_false (light > 0) && idistance (dx, dy) <= light) 1843 if (expect_false (light > 0) && idistance (dx, dy) <= light)
1841 return 1; 1844 return 1;
1842 } 1845 }
1843 } 1846 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines