mirror of
https://github.com/IntQuant/noita_entangled_worlds.git
synced 2025-10-19 07:03:16 +00:00
make pit boss aim at closest alive player
This commit is contained in:
parent
681bc6a3b8
commit
cedc334547
1 changed files with 19 additions and 0 deletions
19
quant.ew/data/entities/animals/boss_pit/wand_rotate.lua
Normal file
19
quant.ew/data/entities/animals/boss_pit/wand_rotate.lua
Normal 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)
|
Loading…
Add table
Add a link
Reference in a new issue