diff --git a/classes/spearhead_base.lua b/classes/spearhead_base.lua index affc977..d398132 100644 --- a/classes/spearhead_base.lua +++ b/classes/spearhead_base.lua @@ -315,6 +315,10 @@ do -- INIT UTIL ---@param points Array function UTIL.enlargeConvexHull(points, meters) + if points == nil or #points == 0 then + return {} + end + ---@type Array local allpoints = {} @@ -383,6 +387,10 @@ end ---@return Array function UTIL.GetTangentHullPointsFromOrigin(hull, origin) + if hull == nil or #hull <= 0 then + return {} + end + local function orientation(a, b, c) -- Returns >0 if c is to the left of ab, <0 if to the right, 0 if colinear return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x) diff --git a/classes/stageClasses/helpers/BattleManager.lua b/classes/stageClasses/helpers/BattleManager.lua index e7a04f3..3242934 100644 --- a/classes/stageClasses/helpers/BattleManager.lua +++ b/classes/stageClasses/helpers/BattleManager.lua @@ -222,6 +222,7 @@ function BattleManager:GetRandomPoint(origin, groups) local hulls = Spearhead.Util.getSeparatedConvexHulls(points, 50) local hull = Spearhead.Util.randomFromList(hulls) --[[@as Array]] + if not hull then return nil end local enlargedHull = Spearhead.Util.enlargeConvexHull(hull, 25) local shootPoints = Spearhead.Util.GetTangentHullPointsFromOrigin(enlargedHull, origin)