make pit boss aim at closest alive player

This commit is contained in:
bgkillas 2024-11-02 18:46:56 -04:00
parent 681bc6a3b8
commit cedc334547

View file

@ -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)