From cedc33454754236717680658d525ef5f47f91bb6 Mon Sep 17 00:00:00 2001 From: bgkillas Date: Sat, 2 Nov 2024 18:46:56 -0400 Subject: [PATCH] make pit boss aim at closest alive player --- .../entities/animals/boss_pit/wand_rotate.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 quant.ew/data/entities/animals/boss_pit/wand_rotate.lua diff --git a/quant.ew/data/entities/animals/boss_pit/wand_rotate.lua b/quant.ew/data/entities/animals/boss_pit/wand_rotate.lua new file mode 100644 index 00000000..c2510f1b --- /dev/null +++ b/quant.ew/data/entities/animals/boss_pit/wand_rotate.lua @@ -0,0 +1,19 @@ +dofile_once("data/scripts/lib/utilities.lua") + +local entity_id = GetUpdatedEntityID() +local x, y = EntityGetTransform(GetUpdatedEntityID()) + +local players = EntityGetWithTag("ew_peer") + +local closest +local dir = 0 +for _, player in ipairs(players) do + local px, py = EntityGetTransform(player) + local r = px * px + py * py + if closest == nil or r < closest then + closest = r + dir = math.atan2(py - y, px - x) + end +end + +EntitySetTransform(entity_id, x, y, dir) \ No newline at end of file