Skip to content

Commit ddad55d

Browse files
committed
JumpPack AI improvements
1 parent eeacb6d commit ddad55d

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

Data/Base.rte/AI/HumanBehaviors.lua

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,6 +1295,7 @@ function HumanBehaviors.GoToWpt(AI, Owner, Abort)
12951295
end
12961296
else
12971297
local updateInterval = SettingsMan.AIUpdateInterval;
1298+
12981299
-- Try swapping direction, with a 15% random chance per tick while we're stuck
12991300
if PosRand() > (1 - 0.15) / updateInterval then
13001301
nextLatMove = AI.lateralMoveState == Actor.LAT_LEFT and Actor.LAT_RIGHT or Actor.LAT_LEFT;
@@ -1306,7 +1307,7 @@ function HumanBehaviors.GoToWpt(AI, Owner, Abort)
13061307
end
13071308

13081309
-- refuelling done
1309-
if AI.refuel and Owner.Jetpack and Owner.Jetpack.JetTimeLeft >= Owner.Jetpack.JetTimeTotal * 0.99 then
1310+
if AI.refuel and Owner.Jetpack and Owner.Jetpack.JetpackType == AEJetpack.Standard and Owner.Jetpack.JetTimeLeft >= Owner.Jetpack.JetTimeTotal * 0.99 then
13101311
AI.jump = true;
13111312
end
13121313
end
@@ -1770,7 +1771,7 @@ function HumanBehaviors.GoToWpt(AI, Owner, Abort)
17701771
-- do we have a target we want to shoot at?
17711772
if (AI.Target and AI.canHitTarget and AI.BehaviorName ~= "AttackTarget") then
17721773
-- are we also flying
1773-
if AI.flying then
1774+
if AI.flying and Owner.Jetpack.JetpackType == AEJetpack.Standard then
17741775
-- predict jetpack movement when jumping and there is a target (check one direction)
17751776
local jetStrength = AI.jetImpulseFactor / Owner.Mass;
17761777
local t = math.min(0.4, Owner.Jetpack.JetTimeLeft*0.001);
@@ -1816,7 +1817,7 @@ function HumanBehaviors.GoToWpt(AI, Owner, Abort)
18161817
AI.jump = false;
18171818
end
18181819
else
1819-
if Waypoint.Type ~= "drop" and not Lower(Waypoint, Owner, 20) then
1820+
if Waypoint.Type ~= "drop" and not Lower(Waypoint, Owner, 20) and Owner.Jetpack.JetpackType == AEJetpack.Standard then
18201821
-- jump over low obstacles unless we want to jump off a ledge
18211822
if nextLatMove == Actor.LAT_RIGHT and (Obstacles[Obst.R_LOW] or Obstacles[Obst.R_FRONT]) and not Obstacles[Obst.R_UP] then
18221823
AI.jump = true;
@@ -1872,11 +1873,16 @@ function HumanBehaviors.GoToWpt(AI, Owner, Abort)
18721873
local Trace = SceneMan:ShortestDistance(Owner.Head.Pos, FallPos, false);
18731874
SceneMan:CastObstacleRay(Owner.Head.Pos, Trace, FallPos, Vector(), Owner.ID, Owner.IgnoresWhichTeam, rte.grassID, 3);
18741875

1876+
local deltaToJump = 25;
1877+
if Owner.Jetpack.JetpackType == AEJetpack.JumpPack then
1878+
deltaToJump = deltaToJump * 1.4;
1879+
end
1880+
18751881
table.sort(Facings, function(A, B) return A.range < B.range end);
18761882
local delta = SceneMan:ShortestDistance(Waypoint.Pos, FallPos, false).Magnitude - Facings[1].range;
18771883
if delta < 1 then
18781884
AI.jump = false;
1879-
elseif AI.flying or delta > 25 then
1885+
elseif delta > deltaToJump or (AI.flying and Owner.Jetpack.JetpackType == AEJetpack.Standard) then
18801886
AI.jump = true;
18811887
nextAimAngle = Owner:GetAimAngle(false) * 0.5 + Facings[1].aim * 0.5; -- adjust jetpack nozzle direction
18821888
nextLatMove = Actor.LAT_STILL;

Data/Base.rte/AI/NativeHumanAI.lua

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ function NativeHumanAI:Update(Owner)
220220

221221

222222
-- check if the feet reach the ground
223-
if self.AirTimer:IsPastSimMS(120) then
223+
if self.AirTimer:IsPastSimMS(250) then
224224
self.AirTimer:Reset();
225225

226226
local Origin = {};
@@ -459,7 +459,12 @@ function NativeHumanAI:Update(Owner)
459459
end
460460
end
461461
elseif self.flying then -- avoid falling damage
462-
if (not self.jump and Owner.Vel.Y > 9) or (self.jump and Owner.Vel.Y > 6) then
462+
local jumpThreshold = 9;
463+
if Owner.Jetpack and Owner.Jetpack.JetpackType == AEJetpack.JumpPack then
464+
jumpThreshold = jumpThreshold * 3;
465+
end
466+
467+
if (not self.jump and Owner.Vel.Y > jumpThreshold) or (self.jump and Owner.Vel.Y > jumpThreshold * 0.66) then
463468
self.jump = true;
464469

465470
-- try falling straight down

0 commit comments

Comments
 (0)