forked from taichunmin/dont-starve-together-game-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgiantutils.lua
27 lines (21 loc) · 798 Bytes
/
giantutils.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
local WANDER_AWAY_DIST = 100
function GetWanderAwayPoint(pt)
local theta = math.random() * 2 * PI
local radius = WANDER_AWAY_DIST
local ground = TheWorld
-- Walk the circle trying to find a valid spawn point
local steps = 12
for i = 1, 12 do
local offset = Vector3(radius * math.cos( theta ), 0, -radius * math.sin( theta ))
local wander_point = pt + offset
local wx, wy, wz = wander_point:Get()
if ground.Map:IsPassableAtPoint(wx, wy, wz, false, true) and
ground.Pathfinder:IsClear(
pt.x, pt.y, pt.z,
wander_point.x, wander_point.y, wander_point.z,
{ ignorewalls = true }) then
return wander_point
end
theta = theta - (2 * PI / steps)
end
end