Skip to content

Commit 9c6a444

Browse files
committed
lots of Thunderer turret stuff
1 parent 9c4decf commit 9c6a444

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+132
-134
lines changed

Data/Browncoats.rte/Actors/Turrets/Thunderer/Thunderer.ini

Lines changed: 73 additions & 73 deletions
Large diffs are not rendered by default.
1 Byte
-12 Bytes
12 Bytes
-1 Bytes

Data/Browncoats.rte/Actors/Turrets/Thunderer/ThundererGun.lua

Lines changed: 58 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,21 @@ function OnFire(self)
1313
self.firingAnim = true;
1414

1515
local casing = self.Casing:Clone();
16-
casing.Pos = self.Pos + (self.currentBarrel == 1 and self.bottomEjectorOffset or self.topEjectorOffset);
17-
casing.Vel = self.Vel + Vector(0, self.currentBarrel == 1 and 5 or -5):RadRotate(self.RotAngle);
16+
casing.Pos = self.Pos + (self.currentBarrel == 0 and self.bottomEjectorOffset or self.topEjectorOffset);
17+
casing.Vel = self.Vel + Vector(0, self.currentBarrel == 0 and 5 or -5):RadRotate(self.RotAngle);
1818
casing.Team = self.Team;
1919
casing.RotAngle = self.RotAngle;
2020
casing.HFlipped = self.HFlipped;
21-
casing.AngularVel = self.currentBarrel == 1 and math.random(-3, -5) or math.random(3, 5);
21+
casing.AngularVel = self.currentBarrel == 0 and math.random(-3, -5) or math.random(3, 5);
2222
MovableMan:AddParticle(casing);
23+
24+
-- Set it up for next time, so we're sitting on the right MuzzleOffset rather than the wrong one up until the point of fire
25+
self.MuzzleOffset = self.currentBarrel == 1 and self.bottomMuzzleOffset or self.topMuzzleOffset;
2326
end
2427

2528
function OnReload(self)
2629
self.reloadToSmoke = true;
2730
self.animTimer:Reset();
28-
29-
if self.currentBaseFrame ~= 20 then
30-
self.oldFrame = self.Frame;
31-
end
3231
end
3332

3433
function Create(self)
@@ -44,7 +43,7 @@ function Create(self)
4443
self.servoMoving = false;
4544

4645
self.Casing= CreateAEmitter("Casing Browncoat AA-50", "Browncoats.rte");
47-
self.Shot = CreateAEmitter("Browncoat AA-50 Shot", "Browncoats.rte");
46+
self.Shot = CreateAEmitter("Shot Browncoat AA-50", "Browncoats.rte");
4847

4948
self.firingAnim = false;
5049
self.animTimer = Timer();
@@ -53,13 +52,13 @@ function Create(self)
5352

5453
self.currentBarrel = 0;
5554

56-
self.topMuzzleOffset = Vector(55, -8);
57-
self.bottomMuzzleOffset = Vector(55, 6);
55+
self.topMuzzleOffset = Vector(42, -4);
56+
self.bottomMuzzleOffset = Vector(42, 10);
5857

59-
self.topEjectorOffset = Vector(12, -10);
60-
self.bottomEjectorOffset = Vector(12, 13);
58+
self.topEjectorOffset = Vector(-5, -4);
59+
self.bottomEjectorOffset = Vector(-5, 10);
6160

62-
self.MuzzleOffset = self.topMuzzleOffset;
61+
self.MuzzleOffset = self.bottomMuzzleOffset;
6362

6463
for att in self.Attachables do
6564
if string.find(att.PresetName, "Barrel Top") then
@@ -152,62 +151,25 @@ function Update(self)
152151
if self:DoneReloading() then
153152
self.currentBaseFrame = 0;
154153
self.Frame = 0;
155-
end
156-
157-
if self.firingAnim then
158-
self:Deactivate();
159-
160-
local progress = math.min(1, self.animTimer.ElapsedSimTimeMS / self.firingAnimTime);
161-
local frameNum = math.floor(4 * progress);
162-
self.Frame = self.currentBaseFrame + frameNum;
163-
164-
local barrel = self.currentBarrel == 0 and self.bottomBarrel or self.topBarrel;
165-
local ejector = self.currentBarrel == 0 and self.bottomEjector or self.topEjector;
166-
local jointOffsetX = 10 * math.sin(progress * math.pi);
167-
barrel.JointOffset = Vector(jointOffsetX, 0);
168-
ejector.JointOffset = Vector(jointOffsetX, 0);
169-
if progress == 1 then
170-
self.MuzzleOffset = self.currentBarrel == 0 and self.bottomMuzzleOffset or self.topMuzzleOffset;
171-
barrel.JointOffset = Vector();
172-
self.currentBarrel = (self.currentBarrel + 1) % 2;
173-
self.firingAnim = false;
174-
175-
-- surely this can be done better...
176-
if not self:IsReloading() then
177-
if self.RoundInMagCount == 1 then
178-
self.currentBaseFrame = 20;
179-
elseif self.RoundInMagCount == 2 then
180-
self.currentBaseFrame = 16;
181-
elseif self.RoundInMagCount == 3 then
182-
self.currentBaseFrame = 12;
183-
elseif self.RoundInMagCount == 4 then
184-
self.currentBaseFrame = 8;
185-
elseif self.RoundInMagCount == 5 then
186-
self.currentBaseFrame = 4;
187-
end
188-
189-
self.Frame = self.currentBaseFrame;
190-
end
191-
end
154+
self.currentBarrel = 0;
155+
self.MuzzleOffset = self.bottomMuzzleOffset;
192156
end
193157

194158
if self:IsReloading() then
195159
-- manually timed
196160

197-
if self.currentBaseFrame ~= 20 then
161+
if self.currentBaseFrame ~= 22 then
198162
local progress = math.min(1, self.animTimer.ElapsedSimTimeMS / (self.firingAnimTime*3));
199-
local frameNum = math.floor((20 - self.oldFrame) * progress);
200-
self.Frame = self.oldFrame + frameNum;
201-
if self.Frame == 20 then
202-
self.currentBaseFrame = 20;
203-
self.oldFrame = nil;
204-
self.Frame = 20;
163+
local frameNum = self.currentBaseFrame + math.floor((22 - self.currentBaseFrame) * progress);
164+
self.Frame = frameNum;
165+
if self.Frame == 22 then
166+
self.currentBaseFrame = 22;
205167
end
206168
end
207169

208170
if self.animTimer:IsPastSimMS(self.ReloadTime - 1000) then
209171
local progress = math.min(1, (self.animTimer.ElapsedSimTimeMS - (self.ReloadTime - 1000)) / 1000);
210-
local frameNum = math.floor(17 * progress);
172+
local frameNum = math.floor(21 * progress);
211173
self.Frame = self.currentBaseFrame + frameNum;
212174
end
213175

@@ -232,9 +194,45 @@ function Update(self)
232194
MovableMan:AddParticle(particle);
233195
end
234196
end
235-
end
236-
197+
elseif self.firingAnim then
198+
self:Deactivate();
237199

200+
local progress = math.min(1, self.animTimer.ElapsedSimTimeMS / self.firingAnimTime);
201+
local frameNum = math.floor(4 * progress);
202+
self.Frame = self.currentBaseFrame + frameNum;
203+
204+
local barrel = self.currentBarrel == 0 and self.bottomBarrel or self.topBarrel;
205+
local ejector = self.currentBarrel == 0 and self.bottomEjector or self.topEjector;
206+
local jointOffsetX = 10 * math.sin(progress * math.pi);
207+
barrel.JointOffset = Vector(jointOffsetX, 0);
208+
ejector.JointOffset = Vector(jointOffsetX, 0);
209+
if progress == 1 then
210+
-- surely this can be done better...
211+
if not self:IsReloading() then
212+
if self.currentBarrel == 0 then
213+
self.currentBaseFrame = 4;
214+
else
215+
self.currentBaseFrame = 0;
216+
end
217+
if self.RoundInMagCount == 1 then
218+
self.currentBaseFrame = 24;
219+
elseif self.RoundInMagCount == 2 then
220+
self.currentBaseFrame = 20;
221+
elseif self.RoundInMagCount == 3 then
222+
self.currentBaseFrame = 16;
223+
elseif self.RoundInMagCount == 4 then
224+
self.currentBaseFrame = 12;
225+
elseif self.RoundInMagCount == 4 then
226+
self.currentBaseFrame = 8;
227+
end
228+
self.Frame = self.currentBaseFrame;
229+
end
230+
barrel.JointOffset = Vector();
231+
self.currentBarrel = (self.currentBarrel + 1) % 2;
232+
self.firingAnim = false;
233+
end
234+
print(self.Frame)
235+
end
238236
end
239237

240238
function Destroy(self)

0 commit comments

Comments
 (0)