setStopPoint
Definition
-- @/lua/vehicle/ai.lua:1199
local function setStopPoint(plan, dist, args)
if not plan and currentRoute then
plan = currentRoute.plan
end
if not plan then return end
if not dist then -- reset stop segment
plan.stopSeg = math.huge
return
end
if (args or E).avoidJunction and currentRoute.path then -- prevents stopping directly in junctions
-- this code is temporary, and inefficient...
local seg
while true do
seg = getLastNodeWithinDistance(plan, dist)
local nid = currentRoute.path[plan[seg].pathidx]
if seg < plan.planCount - 1 and tableSize(mapData.graph[nid]) > 2 and plan[seg].pos:squaredDistance(mapData.positions[nid]) <= square(mapData.radius[nid]) then
dist = dist + 20
else
break
end
end
plan.stopSeg = seg
else
plan.stopSeg = getLastNodeWithinDistance(plan, dist)
end
end
Callers
@/lua/vehicle/ai.lua
laneChange(plan, max(10, dist - 20), disp * side)
setStopPoint(plan, dist, {avoidJunction = true})
trafficStates.action.forcedStop = true
--laneChange(plan, 40, -trafficStates.side.displacement) -- this is no longer needed?
setStopPoint()
trafficStates.action.forcedStop = false
if trafficStates.action.forcedStop and ego.speed < min(plan.targetSpeed or 0, 1) then -- instant plan stop
setStopPoint(plan, 0)
end
@/lua/ge/extensions/gameplay/traffic/baseRole.lua
self.veh.queuedFuncs.laneChange = {timer = 0.25, vLua = 'ai.laneChange(nil, '..changeLaneDist..', '..sideDist..')'}
self.veh.queuedFuncs.setStopPoint = {timer = 0.25, vLua = 'ai.setStopPoint(nil, '..(changeLaneDist + 20)..')'}
end