@@ -13,22 +13,21 @@ function OnFire(self)
13
13
self .firingAnim = true ;
14
14
15
15
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 );
18
18
casing .Team = self .Team ;
19
19
casing .RotAngle = self .RotAngle ;
20
20
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 );
22
22
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 ;
23
26
end
24
27
25
28
function OnReload (self )
26
29
self .reloadToSmoke = true ;
27
30
self .animTimer :Reset ();
28
-
29
- if self .currentBaseFrame ~= 20 then
30
- self .oldFrame = self .Frame ;
31
- end
32
31
end
33
32
34
33
function Create (self )
@@ -44,7 +43,7 @@ function Create(self)
44
43
self .servoMoving = false ;
45
44
46
45
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" );
48
47
49
48
self .firingAnim = false ;
50
49
self .animTimer = Timer ();
@@ -53,13 +52,13 @@ function Create(self)
53
52
54
53
self .currentBarrel = 0 ;
55
54
56
- self .topMuzzleOffset = Vector (55 , - 8 );
57
- self .bottomMuzzleOffset = Vector (55 , 6 );
55
+ self .topMuzzleOffset = Vector (42 , - 4 );
56
+ self .bottomMuzzleOffset = Vector (42 , 10 );
58
57
59
- self .topEjectorOffset = Vector (12 , - 10 );
60
- self .bottomEjectorOffset = Vector (12 , 13 );
58
+ self .topEjectorOffset = Vector (- 5 , - 4 );
59
+ self .bottomEjectorOffset = Vector (- 5 , 10 );
61
60
62
- self .MuzzleOffset = self .topMuzzleOffset ;
61
+ self .MuzzleOffset = self .bottomMuzzleOffset ;
63
62
64
63
for att in self .Attachables do
65
64
if string.find (att .PresetName , " Barrel Top" ) then
@@ -152,62 +151,25 @@ function Update(self)
152
151
if self :DoneReloading () then
153
152
self .currentBaseFrame = 0 ;
154
153
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 ;
192
156
end
193
157
194
158
if self :IsReloading () then
195
159
-- manually timed
196
160
197
- if self .currentBaseFrame ~= 20 then
161
+ if self .currentBaseFrame ~= 22 then
198
162
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 ;
205
167
end
206
168
end
207
169
208
170
if self .animTimer :IsPastSimMS (self .ReloadTime - 1000 ) then
209
171
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 );
211
173
self .Frame = self .currentBaseFrame + frameNum ;
212
174
end
213
175
@@ -232,9 +194,45 @@ function Update(self)
232
194
MovableMan :AddParticle (particle );
233
195
end
234
196
end
235
- end
236
-
197
+ elseif self . firingAnim then
198
+ self : Deactivate ();
237
199
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
238
236
end
239
237
240
238
function Destroy (self )
0 commit comments