Skip to content

Commit 862e097

Browse files
committed
hopeful improvements to nav. need to replace jetpack stuff almost entirely I think
1 parent f7eaf81 commit 862e097

File tree

1 file changed

+23
-15
lines changed

1 file changed

+23
-15
lines changed

Data/Base.rte/AI/SharedBehaviors.lua

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -452,8 +452,8 @@ function SharedBehaviors.GoToWpt(AI, Owner, Abort)
452452

453453
if Owner.Jetpack and Owner.Head and Owner.Head:IsAttached() then
454454
if Owner.Jetpack.JetTimeLeft < AI.minBurstTime then
455-
AI.jump = false; -- not enough fuel left, no point in jumping yet
456455
if not AI.flying or Owner.Vel.Y > 4 then
456+
AI.jump = false; -- not enough fuel left, no point in jumping yet
457457
AI.refuel = true;
458458
end
459459
else
@@ -522,34 +522,42 @@ function SharedBehaviors.GoToWpt(AI, Owner, Abort)
522522
end
523523

524524
-- predict jetpack movement...
525-
local jumpHeight = Owner.JumpHeight;
525+
local jetStrength = (AI.jetImpulseFactor / Owner.Mass);
526+
local t = math.min(0.4, Owner.Jetpack.JetTimeLeft*0.001);
527+
local PixelVel = Owner.Vel * (GetPPM() * t);
528+
local Accel = SceneMan.GlobalAcc * GetPPM();
529+
530+
-- a burst use 10x more fuel
531+
if Owner.Jetpack:CanTriggerBurst() then
532+
t = math.max(math.min(0.4, Owner.Jetpack.JetTimeLeft*0.001-TimerMan.AIDeltaTimeSecs*10), TimerMan.AIDeltaTimeSecs);
533+
end
526534

527535
-- when jumping (check four directions)
528536
for k, Face in pairs(Facings) do
529-
local JetAccel = Vector(-jumpHeight, 0):RadRotate(Owner.RotAngle+1.375*math.pi+Face.facing*0.25);
530-
local JumpPos = Owner.Head.Pos + JetAccel;
537+
local JetAccel = Vector(-jetStrength, 0):RadRotate(Owner.RotAngle+1.375*math.pi+Face.facing*0.25);
538+
local JumpPos = Owner.Pos + PixelVel + (Accel + JetAccel) * (t*t*0.5);
531539

532-
-- check for obstacles from the head
533-
Trace = SceneMan:ShortestDistance(Owner.Head.Pos, JumpPos, false);
534-
local obstDist = SceneMan:CastObstacleRay(Owner.Head.Pos, Trace, JumpPos, Vector(), Owner.ID, Owner.IgnoresWhichTeam, rte.grassID, 3);
535-
if obstDist < 0 then -- no obstacles: calculate the distance from the future pos to the wpt
536-
Facings[k].range = SceneMan:ShortestDistance(Waypoint.Pos, JumpPos, false).Magnitude;
537-
else -- the ray hit terrain or start inside terrain: avoid
538-
Facings[k].range = SceneMan:ShortestDistance(Waypoint.Pos, JumpPos, false).Largest * 2;
540+
-- a burst add a one time boost to acceleration
541+
if Owner.Jetpack:CanTriggerBurst() then
542+
JumpPos = JumpPos + Vector(-AI.jetBurstFactor, 0):AbsRotateTo(JetAccel);
539543
end
544+
545+
-- check for obstacles from the head
546+
Trace = SceneMan:ShortestDistance(Owner.Pos, JumpPos, false);
547+
Facings[k].range = SceneMan:ShortestDistance(Waypoint.Pos, JumpPos, false).Magnitude;
540548
end
541549

542550
-- when falling or walking
543-
local FallPos = Owner.Head.Pos + PixelVel;
551+
local FallPos = Owner.Pos + PixelVel;
544552
if AI.flying then
545553
FallPos = FallPos + Accel * (t*t*0.5);
546554
end
547555

548556
-- check for obstacles when falling/walking
549-
local Trace = SceneMan:ShortestDistance(Owner.Head.Pos, FallPos, false);
550-
SceneMan:CastObstacleRay(Owner.Head.Pos, Trace, FallPos, Vector(), Owner.ID, Owner.IgnoresWhichTeam, rte.grassID, 3);
557+
local Trace = SceneMan:ShortestDistance(Owner.Pos, FallPos, false);
558+
SceneMan:CastObstacleRay(Owner.Pos, Trace, FallPos, Vector(), Owner.ID, Owner.IgnoresWhichTeam, rte.grassID, 3);
551559

552-
local deltaToJump = 15;
560+
local deltaToJump = 1;
553561
if Owner.Jetpack.JetpackType == AEJetpack.JumpPack then
554562
deltaToJump = deltaToJump * 1.4;
555563
end

0 commit comments

Comments
 (0)