+ if (dir_to_nearest_thing)
+ {
+ t_eye->command = get_thing_action_id_by_name(s[S_CMD_MOVE]);
+ t_eye->arg = dir_to_nearest_thing;
+ return 1;
+ }
+ return 0;
+}
+
+
+
+static uint8_t seeing_thing(struct Thing * t_eye, char filter)
+{
+ if (t_eye->fov_map && 'e' == filter)
+ {
+ struct Thing * t = world.things;
+ for (; t; t = t->next)
+ {
+ if ( t != t_eye
+ && 'v' == t_eye->fov_map[t->pos.y*world.map.length + t->pos.x])
+ {
+ if (t->lifepoints && t->type != t_eye->type)
+ {
+ return 1;
+ }
+ }
+ }
+ }
+ else if (t_eye->mem_map && 'c' == filter)
+ {
+ struct ThingInMemory * tm = t_eye->t_mem;
+ for (; tm; tm = tm->next)
+ {
+ if (' ' != t_eye->mem_map[tm->pos.y * world.map.length + tm->pos.x])
+ {
+ struct ThingType * tt = get_thing_type(tm->type);
+ if (tt->consumable)
+ {
+ return 1;
+ }
+ }
+ }
+ }
+ return 0;
+}
+
+
+
+static int16_t get_inventory_slot_to_consume(struct Thing * t_owner)
+{
+ uint8_t compare_consumability = 0;
+ int16_t selection = -1;
+ struct Thing * t = t_owner->owns;;
+ uint8_t i;
+ for (i = 0; t; t = t->next, i++)
+ {
+ struct ThingType * tt = get_thing_type(t->type);
+ if (tt->consumable > compare_consumability)
+ {
+ compare_consumability = tt->consumable;
+ selection = i;
+ }
+ }
+ return selection;
+}
+
+
+
+static uint8_t standing_on_consumable(struct Thing * t_standing)
+{
+ struct Thing * t = world.things;
+ for (; t; t = t->next)
+ {
+ if ( t != t_standing
+ && t->pos.y == t_standing->pos.y && t->pos.x == t_standing->pos.x)
+ {
+ struct ThingType * tt = get_thing_type(t->type);
+ if (tt->consumable)
+ {
+ return 1;
+ }
+ }
+ }
+ return 0;