Add is facing and is behind checks

notifications
4n0n 2 years ago
parent 0d1741ac31
commit 13f0c93767
  1. 2
      scripts/outlaw.lua
  2. 40
      src/Unit/Unit.lua

@ -89,7 +89,7 @@ local KickTarget = Bastion.UnitManager:CreateCustomUnit('kick', function(unit)
return false return false
end end
if unit:IsInterruptible(5) then if Player:InMelee(unit) and unit:IsInterruptible(5) and Player:IsFacing(unit) then
purge = unit purge = unit
return true return true
end end

@ -385,4 +385,44 @@ function Unit:IsTanking(unit)
return isTanking return isTanking
end end
-- IsFacing
function Unit:IsFacing(unit)
local rot = ObjectRotation(self.unit)
local x, y, z = ObjectPosition(self.unit)
local x2, y2, z2 = ObjectPosition(unit.unit)
if not x or not x2 then
return false
end
local angle = math.atan2(y2 - y, x2 - x) - rot
angle = math.deg(angle)
angle = angle % 360
if angle > 180 then
angle = angle - 360
end
return math.abs(angle) < 90
end
-- IsBehind
function Unit:IsBehind(unit)
local rot = ObjectRotation(unit.unit)
local x, y, z = ObjectPosition(unit.unit)
local x2, y2, z2 = ObjectPosition(self.unit)
if not x or not x2 then
return false
end
local angle = math.atan2(y2 - y, x2 - x) - rot
angle = math.deg(angle)
angle = angle % 360
if angle > 180 then
angle = angle - 360
end
return math.abs(angle) > 90
end
return Unit return Unit

Loading…
Cancel
Save