Skip to content

Commit 349765e

Browse files
committed
hopeful improvements to nav. need to replace jetpack stuff almost entirely I think
1 parent 19332ec commit 349765e

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

Data/Base.rte/AI/SharedBehaviors.lua

Lines changed: 9 additions & 14 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,7 +522,7 @@ function SharedBehaviors.GoToWpt(AI, Owner, Abort)
522522
end
523523

524524
-- predict jetpack movement...
525-
local jetStrength = AI.jetImpulseFactor / Owner.Mass;
525+
local jetStrength = (AI.jetImpulseFactor / Owner.Mass);
526526
local t = math.min(0.4, Owner.Jetpack.JetTimeLeft*0.001);
527527
local PixelVel = Owner.Vel * (GetPPM() * t);
528528
local Accel = SceneMan.GlobalAcc * GetPPM();
@@ -535,34 +535,29 @@ function SharedBehaviors.GoToWpt(AI, Owner, Abort)
535535
-- when jumping (check four directions)
536536
for k, Face in pairs(Facings) do
537537
local JetAccel = Vector(-jetStrength, 0):RadRotate(Owner.RotAngle+1.375*math.pi+Face.facing*0.25);
538-
local JumpPos = Owner.Head.Pos + PixelVel + (Accel + JetAccel) * (t*t*0.5);
538+
local JumpPos = Owner.Pos + PixelVel + (Accel + JetAccel) * (t*t*0.5);
539539

540540
-- a burst add a one time boost to acceleration
541541
if Owner.Jetpack:CanTriggerBurst() then
542542
JumpPos = JumpPos + Vector(-AI.jetBurstFactor, 0):AbsRotateTo(JetAccel);
543543
end
544544

545545
-- check for obstacles from the head
546-
Trace = SceneMan:ShortestDistance(Owner.Head.Pos, JumpPos, false);
547-
local obstDist = SceneMan:CastObstacleRay(Owner.Head.Pos, Trace, JumpPos, Vector(), Owner.ID, Owner.IgnoresWhichTeam, rte.grassID, 3);
548-
if obstDist < 0 then -- no obstacles: calculate the distance from the future pos to the wpt
549-
Facings[k].range = SceneMan:ShortestDistance(Waypoint.Pos, JumpPos, false).Magnitude;
550-
else -- the ray hit terrain or start inside terrain: avoid
551-
Facings[k].range = SceneMan:ShortestDistance(Waypoint.Pos, JumpPos, false).Largest * 2;
552-
end
546+
Trace = SceneMan:ShortestDistance(Owner.Pos, JumpPos, false);
547+
Facings[k].range = SceneMan:ShortestDistance(Waypoint.Pos, JumpPos, false).Magnitude;
553548
end
554549

555550
-- when falling or walking
556-
local FallPos = Owner.Head.Pos + PixelVel;
551+
local FallPos = Owner.Pos + PixelVel;
557552
if AI.flying then
558553
FallPos = FallPos + Accel * (t*t*0.5);
559554
end
560555

561556
-- check for obstacles when falling/walking
562-
local Trace = SceneMan:ShortestDistance(Owner.Head.Pos, FallPos, false);
563-
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);
564559

565-
local deltaToJump = 15;
560+
local deltaToJump = 1;
566561
if Owner.Jetpack.JetpackType == AEJetpack.JumpPack then
567562
deltaToJump = deltaToJump * 1.4;
568563
end

0 commit comments

Comments
 (0)