Skip to content

Commit 9dd15cc

Browse files
authored
Merge pull request #191 from cortex-command-community/k98k-and-gigapulsarmagazine-lua
Fixed K98K assuming parent, causing chambering animation errors. Fixe…
2 parents a2ce340 + e478c49 commit 9dd15cc

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

Data/Ronin.rte/Devices/Weapons/K98K/K98K.lua

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,12 @@ function ThreadedUpdate(self)
111111
self.needsChamber = false;
112112
self.InheritedRotAngleTarget = 0;
113113
self.rotationSpeed = 0.1;
114-
115-
local shell = CreateMOSParticle("Casing Long");
116114

117-
shell.Pos = self.Pos;
118-
shell.Vel = self.Vel + Vector(-6 * self.FlipFactor, -4):RadRotate(self.RotAngle);
119-
shell.Team = self.Team;
120-
MovableMan:AddParticle(shell);
115+
self.shell = CreateMOSParticle("Casing Long");
116+
self.shell.Pos = self.Pos;
117+
self.shell.Vel = self.Vel + Vector(-6 * self.FlipFactor, -4):RadRotate(self.RotAngle);
118+
self.shell.Team = self.Team;
119+
self:RequestSyncedUpdate();
121120

122121
self.chamberAnim = true;
123122
end
@@ -189,7 +188,12 @@ function ThreadedUpdate(self)
189188
end
190189

191190
if self.chamberAnim then
192-
local balance = 5 + math.abs(math.sin(self.parent.RotAngle) * 5); --Laying down horizontally reduces swaying when pulling bolt
191+
local balance = 5;
192+
193+
if self.parent then
194+
balance = balance + math.abs(math.sin(self.parent.RotAngle) * 5); --Laying down horizontally reduces swaying when pulling bolt
195+
end
196+
193197
self.Frame = 1;
194198
self.SupportOffset = Vector(-5, -1);
195199
local rotTotal = math.sin(self.rotFactor)/balance;
@@ -286,6 +290,13 @@ function ThreadedUpdate(self)
286290
end
287291
end
288292

293+
function SyncedUpdate(self)
294+
if self.shell then
295+
MovableMan:AddParticle(self.shell);
296+
self.shell = nil;
297+
end
298+
end
299+
289300
function OnSave(self)
290301
self:SetNumberValue("ammoCounter", self.ammoCounter);
291302
end

Data/Techion.rte/Devices/Weapons/GigaPulsar/GigaPulsarMagazine.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function ThreadedUpdate(self)
1111
self.smoke = CreateMOSParticle("Tiny Smoke Ball 1");
1212
self.smoke.Pos = self.Pos + Vector(math.random(-1, 1), math.random(-1, 1));
1313
self.smoke.Vel = self.Vel + Vector(RangeRand(-2, 2), RangeRand(-2, 2));
14-
self.smoke.Lifetime = smoke.Lifetime * RangeRand(0.5, 1.0);
14+
self.smoke.Lifetime = self.smoke.Lifetime * RangeRand(0.5, 1.0);
1515
self:RequestSyncedUpdate();
1616
end
1717
end

0 commit comments

Comments
 (0)