From da3922f1aa532b628693f5093f464d263831b153 Mon Sep 17 00:00:00 2001 From: Steph Enders Date: Thu, 15 Dec 2022 22:37:34 -0500 Subject: Disable enemy movement through enemies or treasure --- dnglib/defaults.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'dnglib/defaults.lua') diff --git a/dnglib/defaults.lua b/dnglib/defaults.lua index 77f688c..5b1c7c5 100644 --- a/dnglib/defaults.lua +++ b/dnglib/defaults.lua @@ -98,6 +98,9 @@ function onUpdate(dt) player = c_get_player_position() assert(type(player) == "table", "Player is not a table") + + treasures = c_get_treasures() + assert(type(treasures) == "table", "treasures is not a table") map = c_get_map(); assert(type(map) == "table", "map is not a table") @@ -105,10 +108,11 @@ function onUpdate(dt) for _, v in ipairs(enemies) do local next; if diff_time >= MOV_TIME then - next = algs.pathfind(v, player, map) + next = algs.pathfind(v, player, enemies, treasures, map) else next = { dx = 0, dy = 0 } end + new_pos = c_move_enemy(v.id, next.dx, next.dy) assert(type(new_pos) == "table", "new_pos is not a table") if new_pos.x == player.x and new_pos.y == player.y then -- cgit v1.2.3-54-g00ecf