Skip to content

Commit 19332ec

Browse files
committed
Further improve AI responsiveness, especially when digging
1 parent 8b94229 commit 19332ec

File tree

1 file changed

+1
-36
lines changed

1 file changed

+1
-36
lines changed

Data/Base.rte/AI/SharedBehaviors.lua

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,6 @@ function SharedBehaviors.GoToWpt(AI, Owner, Abort)
120120
else
121121
AI.proneState = AHuman.NOTPRONE;
122122
end
123-
124-
local _ai, _ownr, _abrt = coroutine.yield(); -- wait until next frame
125-
if _abrt then return true end
126123
else
127124
AI.proneState = AHuman.NOTPRONE;
128125
end
@@ -245,8 +242,6 @@ function SharedBehaviors.GoToWpt(AI, Owner, Abort)
245242
UpdatePathTimer:Reset();
246243
AI.lateralMoveState = Actor.LAT_STILL;
247244
AI.jump = false;
248-
local _ai, _ownr, _abrt = coroutine.yield(); -- wait until next frame
249-
if _abrt then return true end
250245

251246
if Owner.MOMoveTarget and MovableMan:ValidMO(Owner.MOMoveTarget) then
252247
Trace = SceneMan:ShortestDistance(Owner.Pos, Owner.MOMoveTarget.Pos, false);
@@ -306,15 +301,9 @@ function SharedBehaviors.GoToWpt(AI, Owner, Abort)
306301
local centerAngle = CurrDist.AbsRadAngle;
307302
local Ray = Vector(Owner.Height*0.3, 0):RadRotate(centerAngle); -- center
308303
if SceneMan:CastNotMaterialRay(Owner.Pos, Ray, 0, 3, false) < 0 then
309-
local _ai, _ownr, _abrt = coroutine.yield(); -- wait until next frame
310-
if _abrt then return true end
311-
312304
-- now check the tunnel's thickness
313305
Ray = Vector(Owner.Height*0.3, 0):RadRotate(centerAngle + sweepRange); -- up
314306
if SceneMan:CastNotMaterialRay(Owner.Pos, Ray, rte.airID, 3, false) < 0 then
315-
local _ai, _ownr, _abrt = coroutine.yield(); -- wait until next frame
316-
if _abrt then return true end
317-
318307
Ray = Vector(Owner.Height*0.3, 0):RadRotate(centerAngle - sweepRange); -- down
319308
if SceneMan:CastNotMaterialRay(Owner.Pos, Ray, rte.airID, 3, false) < 0 then
320309
obstacleState = Actor.PROCEEDING; -- ok the tunnel section is clear, so start walking forward while still digging
@@ -326,9 +315,6 @@ function SharedBehaviors.GoToWpt(AI, Owner, Abort)
326315
obstacleState = Actor.DIGPAUSING; -- tunnel cavity not clear yet, so stay put and dig some more
327316
end
328317

329-
local _ai, _ownr, _abrt = coroutine.yield(); -- wait until next frame
330-
if _abrt then return true end
331-
332318
local aimAngle = Owner:GetAimAngle(true);
333319
local AimVec = Vector(1, 0):RadRotate(aimAngle);
334320

@@ -355,28 +341,7 @@ function SharedBehaviors.GoToWpt(AI, Owner, Abort)
355341
end
356342

357343
-- check if we are done when we get close enough to the waypoint
358-
if SceneMan:ShortestDistance(Owner.Pos, Waypoint.Pos, false).Largest < Owner.Height*0.3 then
359-
if not SceneMan:CastStrengthRay(PrevWptPos, SceneMan:ShortestDistance(PrevWptPos, Waypoint.Pos, false), 5, Vector(), 1, rte.doorID, true) and
360-
not SceneMan:CastStrengthRay(Owner.EyePos, SceneMan:ShortestDistance(Owner.EyePos, Waypoint.Pos, false), 5, Vector(), 1, rte.doorID, true)
361-
then
362-
-- advance to the next waypoint, if there are any
363-
if Owner.MovePathSize > 0 then
364-
UpdatePathTimer:Reset();
365-
PrevWptPos = Waypoint.Pos;
366-
Owner:RemoveMovePathBeginning();
367-
368-
if Owner.MovePathSize > 0 then
369-
Waypoint.Pos = Owner.MovePath[1];
370-
Waypoint.Type = nil;
371-
if Owner.MovePathSize == 1 then
372-
Waypoint.Type = "last";
373-
end
374-
end
375-
else
376-
Waypoint = nil;
377-
end
378-
end
379-
elseif Owner.AIMode == Actor.AIMODE_GOLDDIG then
344+
if Owner.AIMode == Actor.AIMODE_GOLDDIG then
380345
Waypoint.Pos = SceneMan:MovePointToGround(Waypoint.Pos, Owner.Height*0.2, 4);
381346
end
382347
end

0 commit comments

Comments
 (0)