home · contact · privacy
Server: Ensure that AI does not move towards enemies outside its FOV.
authorChristian Heller <c.heller@plomlompom.de>
Sun, 3 Aug 2014 21:29:12 +0000 (23:29 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Sun, 3 Aug 2014 21:29:12 +0000 (23:29 +0200)
src/server/ai.c
src/server/field_of_view.h

index c6139287125f9881c1f0179b5e8b35225cfa4dda..91a6c8618c918e7eaf925085b1c288f2f5f638da 100644 (file)
@@ -5,6 +5,7 @@
 #include <stdint.h> /* uint8_t, uint16_t, uint32_t, UINT16_MAX */
 #include <stdlib.h> /* free() */
 #include "../common/try_malloc.h" /* try_malloc() */
+#include "field_of_view.h" /* HIDDEN */
 #include "hardcoded_strings.h" /* s */
 #include "thing_actions.h" /* get_thing_action_id_by_name() */
 #include "things.h" /* struct Thing */
@@ -138,7 +139,8 @@ static char get_dir_to_nearest_enemy(struct Thing * t_origin)
     struct Thing * t = world.things;
     for (; t != NULL; t = t->next)
     {
-        if (!t->lifepoints || t == t_origin)
+        if (   !t->lifepoints || t == t_origin
+            || HIDDEN == t_origin->fov_map[t->pos.y*world.map.length+t->pos.x])
         {
             continue;
         }
index 9060f1dcb7b849d01196fed23f04be4b9fed681e..aa8fe7c5bebece7e7ce7c9fb799f0699e2041d27 100644 (file)
@@ -15,7 +15,7 @@ struct Thing;
 
 /* States that cells in the field of view map may be in. */
 enum fov_cell_states {
-    HIDDEN = 0x00,
+    HIDDEN  = 0x00,
     VISIBLE = 0x01
 };