Skip to content

Commit d4e0d18

Browse files
committed
Fixed issue with browncoat script poking at AI
1 parent 830fbe1 commit d4e0d18

File tree

3 files changed

+27
-18
lines changed

3 files changed

+27
-18
lines changed

Data/Base.rte/AI/HumanBehaviors.lua

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1723,13 +1723,6 @@ function HumanBehaviors.GoToWpt(AI, Owner, Abort)
17231723
else
17241724
nextLatMove = Actor.LAT_STILL;
17251725
end
1726-
if not (Owner.FGLeg and Owner.BGLeg) then
1727-
if CurrDist.X * Owner.FlipFactor > 5 and -CurrDist.Y > math.abs(CurrDist.X) then
1728-
AI.flying = true;
1729-
elseif not AI.jump then
1730-
AI.proneState = AHuman.GOPRONE;
1731-
end
1732-
end
17331726
end
17341727

17351728
if Waypoint.Type == "right" then

Data/Base.rte/AI/NativeHumanAI.lua

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ function NativeHumanAI:Create(Owner)
1515
Members.SentryFacing = Owner.HFlipped;
1616
Members.fire = false;
1717
Members.groundContact = 5;
18+
Members.flying = false;
1819

1920
Members.squadShoot = false;
2021
Members.useMedikit = false;
@@ -247,9 +248,19 @@ function NativeHumanAI:Update(Owner)
247248
self.groundContact = self.groundContact - 1;
248249
end
249250
end
250-
self.flying = false;
251+
252+
local newFlying = false;
253+
if not (Owner.FGLeg and Owner.BGLeg) then
254+
newFlying = true;
255+
end
256+
251257
if self.groundContact < 0 then
252-
self.flying = true;
258+
newFlying = true;
259+
end
260+
261+
if self.flying ~= newFlying then
262+
Owner:SendMessage("AI_IsFlying", newFlying);
263+
self.flying = newFlying;
253264
end
254265

255266
Owner:EquipShieldInBGArm(); -- try to equip a shield

Data/Browncoats.rte/Actors/Infantry/BrowncoatBoss/BrowncoatBoss.lua

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,18 @@ function OnStride(self)
9999

100100
end
101101

102+
function OnMessage(self, message, context)
103+
if message == "AI_IsFlying" then
104+
if not self:IsPlayerControlled() then
105+
if context == true and self.isInAir == false then
106+
self.isInAir = true;
107+
elseif context == false and self.isInAir == true then
108+
self.isInAir = false;
109+
end
110+
end
111+
end
112+
end
113+
102114
function Update(self)
103115

104116
self.voiceSound.Pos = self.Pos;
@@ -158,24 +170,17 @@ function Update(self)
158170
end
159171
end
160172
end
161-
else
162-
-- This is really bad, we should be communicating with messages or something
163-
if self.AI.flying == true and self.isInAir == false then
164-
self.isInAir = true;
165-
elseif self.AI.flying == false and self.isInAir == true then
166-
self.isInAir = false;
167-
end
168173
end
169174

170175
-- Jumppack custom fx, for extra control actor-side
171176

172-
local jumpPackTrigger = self.Jetpack:IsEmitting() and not self.jetpackEmitting;
177+
local jumpPackTrigger = self.Jetpack and self.Jetpack:IsEmitting() and not self.jetpackEmitting;
173178

174179
if jumpPackTrigger then
175180
BrowncoatBossFunctions.JumpPack(self)
176181
end
177182

178-
if not self.Jetpack:IsEmitting() then
183+
if not self.Jetpack or not self.Jetpack:IsEmitting() then
179184
self.jetpackEmitting = false;
180185
end
181186

0 commit comments

Comments
 (0)