Skip to content

Commit a5f43b0

Browse files
committed
Merge branch 'development' into browncoat-mission
2 parents ef42f3e + b2c504e commit a5f43b0

File tree

3 files changed

+90
-4
lines changed

3 files changed

+90
-4
lines changed

.github/workflows/meson.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ jobs:
8484
sudo pip install meson
8585
8686
- name: ccache
87-
uses: hendrikmuhs/ccache-action@v1.2.11 # Keep this at 1.2.11 until #181 or #182 is closed
87+
uses: hendrikmuhs/ccache-action@v1
8888
with:
8989
key: ${{ github.job }}-${{ matrix.os }}
9090

@@ -175,6 +175,8 @@ jobs:
175175
env:
176176
OSXCROSS_MACPORTS_MIRROR: "https://packages.macports.org"
177177
run: |
178+
echo "::group::Installing pkg-config"
179+
sudo apt install pkg-config
178180
echo "::group::Installing mac deps"
179181
omp install libsdl2 onetbb lz4 libpng minizip luajit flac
180182
echo "OSXCROSS_PKG_CONFIG_PATH=${{env.OSXCROSS_TARGET}}/macports/pkgs/opt/local/libexec/onetbb/lib/pkgconfig" >> $GITHUB_ENV
@@ -191,7 +193,7 @@ jobs:
191193
github_token: ${{ secrets.GITHUB_TOKEN }}
192194

193195
- name: ccache
194-
uses: hendrikmuhs/ccache-action@v1.2.11 # Keep this at 1.2.11 until #181 or #182 is closed
196+
uses: hendrikmuhs/ccache-action@v1
195197
with:
196198
key: ${{ github.job }}-${{ matrix.os }}
197199

Data/Base.rte/AI/NativeCrabAI.lua

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,16 @@ function NativeCrabAI:Create(Owner)
88
local Members = {};
99

1010
Members.lateralMoveState = Actor.LAT_STILL;
11+
Members.jumpState = ACrab.NOTJUMPING;
1112
Members.deviceState = ACrab.STILL;
1213
Members.lastAIMode = Actor.AIMODE_NONE;
1314
Members.teamBlockState = Actor.NOTBLOCKED;
1415
Members.SentryFacing = Owner.HFlipped;
1516
Members.fire = false;
17+
Members.groundContact = 5;
18+
Members.flying = false;
1619

20+
Members.AirTimer = Timer();
1721
Members.ReloadTimer = Timer();
1822
Members.BlockedTimer = Timer();
1923
Members.TargetLostTimer = Timer();
@@ -38,6 +42,15 @@ function NativeCrabAI:Create(Owner)
3842
-- set shooting skill
3943
Members.aimSpeed, Members.aimSkill = SharedBehaviors.GetTeamShootingSkill(Owner.Team);
4044

45+
-- the native AI assume the jetpack cannot be destroyed
46+
if Owner.Jetpack then
47+
if not Members.isPlayerOwned then
48+
Owner.Jetpack.JetTimeTotal = Owner.Jetpack.JetTimeTotal * 1.2; -- increase jetpack fuel to compensate for extra fuel spend
49+
end
50+
51+
Members.minBurstTime = math.min(Owner.Jetpack.BurstSpacing*2, Owner.Jetpack.JetTimeTotal*0.99); -- in milliseconds
52+
end
53+
4154
setmetatable(Members, self);
4255
self.__index = self;
4356
return Members;
@@ -46,6 +59,12 @@ end
4659
function NativeCrabAI:Update(Owner)
4760
self.Ctrl = Owner:GetController();
4861

62+
-- Our jetpack might have thrust balancing enabled, so update for our current mass
63+
if Owner.Jetpack then
64+
self.jetImpulseFactor = Owner.Jetpack:EstimateImpulse(false) * GetPPM() / TimerMan.DeltaTimeSecs;
65+
self.jetBurstFactor = (Owner.Jetpack:EstimateImpulse(true) * GetPPM() / TimerMan.DeltaTimeSecs - self.jetImpulseFactor) * math.pow(TimerMan.DeltaTimeSecs, 2) * 0.5;
66+
end
67+
4968
if self.isPlayerOwned then
5069
if self.PlayerInterferedTimer:IsPastSimTimeLimit() then
5170
-- Tell the coroutines to abort to avoid memory leaks
@@ -273,6 +292,50 @@ function NativeCrabAI:Update(Owner)
273292
end
274293
end
275294

295+
-- check if the feet reach the ground
296+
if self.AirTimer:IsPastSimMS(250) then
297+
self.AirTimer:Reset();
298+
299+
local Origin = {};
300+
if Owner.LeftFGLeg then
301+
table.insert(Origin, Vector(Owner.LeftFGLeg.Pos.X, Owner.LeftFGLeg.Pos.Y) + Vector(0, 4));
302+
end
303+
if Owner.RightFGLeg then
304+
table.insert(Origin, Vector(Owner.RightFGLeg.Pos.X, Owner.RightFGLeg.Pos.Y) + Vector(0, 4));
305+
end
306+
if Owner.LeftBGLeg then
307+
table.insert(Origin, Vector(Owner.LeftBGLeg.Pos.X, Owner.LeftBGLeg.Pos.Y) + Vector(0, 4));
308+
end
309+
if Owner.RightBGLeg then
310+
table.insert(Origin, Vector(Owner.RightBGLeg.Pos.X, Owner.RightBGLeg.Pos.Y) + Vector(0, 4));
311+
end
312+
if #Origin == 0 then
313+
table.insert(Origin, Vector(Owner.Pos.X, Owner.Pos.Y) + Vector(0, 4 + ToMOSprite(Owner):GetSpriteHeight() + Owner.SpriteOffset.Y));
314+
end
315+
for i = 1, #Origin do
316+
if SceneMan:GetTerrMatter(Origin[i].X, Origin[i].Y) ~= rte.airID then
317+
self.groundContact = 5;
318+
break;
319+
else
320+
self.groundContact = self.groundContact - 1;
321+
end
322+
end
323+
324+
local newFlying = false;
325+
if not (Owner.LeftFGLeg and Owner.RightFGLeg and Owner.LeftBGLeg and Owner.RightBGLeg) then
326+
newFlying = true;
327+
end
328+
329+
if self.groundContact < 0 then
330+
newFlying = true;
331+
end
332+
333+
if self.flying ~= newFlying then
334+
Owner:SendMessage("AI_IsFlying", newFlying);
335+
self.flying = newFlying;
336+
end
337+
end
338+
276339
-- controller states
277340
self.Ctrl:SetState(Controller.WEAPON_FIRE, self.fire or self.squadShoot);
278341

@@ -285,6 +348,24 @@ function NativeCrabAI:Update(Owner)
285348
elseif self.lateralMoveState == Actor.LAT_RIGHT then
286349
self.Ctrl:SetState(Controller.MOVE_RIGHT, true);
287350
end
351+
352+
if self.jump and Owner.Jetpack and Owner.Jetpack.JetTimeLeft > TimerMan.AIDeltaTimeMS then
353+
if self.jumpState == ACrab.PREJUMP then
354+
self.jumpState = ACrab.UPJUMP;
355+
elseif self.jumpState ~= ACrab.UPJUMP then -- the jetpack is off
356+
self.jumpState = ACrab.PREJUMP;
357+
end
358+
else
359+
self.jumpState = ACrab.NOTJUMPING;
360+
end
361+
362+
if Owner.Jetpack then
363+
if self.jumpState == ACrab.PREJUMP then
364+
self.Ctrl:SetState(Controller.BODY_JUMPSTART, true); -- try to trigger a burst
365+
elseif self.jumpState == ACrab.UPJUMP then
366+
self.Ctrl:SetState(Controller.BODY_JUMP, true); -- trigger normal jetpack emission
367+
end
368+
end
288369
end
289370

290371
function NativeCrabAI:Destroy(Owner)

Data/Base.rte/AI/SharedBehaviors.lua

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,9 @@ function SharedBehaviors.GoToWpt(AI, Owner, Abort)
630630
AI.lateralMoveState = Actor.LAT_STILL;
631631
AI.jump = false;
632632

633+
local _ai, _ownr, _abrt = coroutine.yield(); -- wait until next frame
634+
if _abrt then return true end
635+
633636
if Owner.MOMoveTarget and MovableMan:ValidMO(Owner.MOMoveTarget) then
634637
Trace = SceneMan:ShortestDistance(Owner.Pos, Owner.MOMoveTarget.Pos, false);
635638
if Trace.Largest > Owner.Height * 0.4 + (Owner.MOMoveTarget.Height or 100) * 0.4 or
@@ -837,7 +840,7 @@ function SharedBehaviors.GoToWpt(AI, Owner, Abort)
837840
end
838841
end
839842

840-
if Owner.Jetpack and Owner.Head and Owner.Head:IsAttached() then
843+
if Owner.Jetpack then
841844
if Owner.Jetpack.JetTimeLeft < AI.minBurstTime then
842845
if not AI.flying or Owner.Vel.Y > 4 then
843846
AI.jump = false; -- not enough fuel left, no point in jumping yet
@@ -944,7 +947,7 @@ function SharedBehaviors.GoToWpt(AI, Owner, Abort)
944947
local Trace = SceneMan:ShortestDistance(Owner.Pos, FallPos, false);
945948
SceneMan:CastObstacleRay(Owner.Pos, Trace, FallPos, Vector(), Owner.ID, Owner.IgnoresWhichTeam, rte.grassID, 3);
946949

947-
local deltaToJump = 1;
950+
local deltaToJump = 5;
948951
if Owner.Jetpack.JetpackType == AEJetpack.JumpPack then
949952
deltaToJump = deltaToJump * 1.4;
950953
end

0 commit comments

Comments
 (0)