yupplemayham/Resources/scripts/ai/scared_behaviour.lua
Ethan Adams 1f38730c96 Added normal parameter for easier knockback implemention script-side
Moved scripts to more descriptive location
2024-06-25 15:40:17 -04:00

29 lines
586 B
Lua

-- helper functions
function lookAway(actor, pos)
y = actor.position.y - pos.y
x = actor.position.x - pos.x
rotation = math.atan(y, x)
actor.rotation = math.deg(rotation)
end
function distance(a, b)
return math.sqrt((math.abs(a.x - b.x)^2) + (math.abs(a.y - b.y)^2))
end
function idle(actor, target)
-- do nothing here for now
end
function patrol(actor, target)
-- do nothing for now
end
function alert(actor, target)
if target ~= nil then
lookAway(actor, target.position)
if distance(actor.position, target.position) < 250 then
actor:moveForward()
end
end
end