Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit b83a9cc

Browse files
committed
Tweaks to shared device scripts
Added RecoilTilt script which simulates recoil with simple rotation (visual only)
1 parent 9324d3d commit b83a9cc

File tree

3 files changed

+39
-25
lines changed

3 files changed

+39
-25
lines changed
Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,28 @@
11
function Create(self)
2-
self.burstTimer = Timer();
3-
self.burst = false;
4-
self.canBurst = true;
2+
self.shotsPerBurst = 3;
3+
self.coolDownDelay = (60000 / self.RateOfFire);
54
end
6-
75
function Update(self)
8-
9-
if self.canBurst == true and self:IsActivated() and self.Magazine ~= nil and self.Magazine.RoundCount > 0 then
10-
self.burstTimer:Reset();
11-
self.canBurst = false;
12-
self.burst = true;
13-
end
14-
15-
if self.burst == true then
16-
if self.burstTimer:IsPastSimMS(150) then
17-
self.burstTimer:Reset();
18-
self:Deactivate();
19-
self.burst = false;
20-
else
6+
if self.Magazine then
7+
if self.coolDownTimer then
8+
local parent = self:GetRootParent();
9+
if self.coolDownTimer:IsPastSimMS(self.coolDownDelay) and (parent and IsActor(parent)) and (not self:IsActivated() or not ToActor(parent):IsPlayerControlled()) then
10+
self.coolDownTimer, self.shotCounter = nil;
11+
else
12+
self:Deactivate();
13+
end
14+
elseif self.shotCounter then
2115
self:Activate();
22-
end
23-
else
24-
if self.canBurst == false then
25-
self:Deactivate();
26-
if self.burstTimer:IsPastSimMS(200) then
27-
self.canBurst = true;
16+
if self.FiredFrame then
17+
self.shotCounter = self.shotCounter + 1;
18+
if self.shotCounter >= self.shotsPerBurst then
19+
self.coolDownTimer = Timer();
20+
end
2821
end
22+
elseif self.FiredFrame then
23+
self.shotCounter = 1;
2924
end
25+
else
26+
self.coolDownTimer, self.shotCounter = nil;
3027
end
31-
3228
end
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
function Create(self)
2+
self.setAngle = 0;
3+
self.tilt = 0.2;
4+
end
5+
function Update(self)
6+
if self.setAngle > 0 then
7+
self.setAngle = self.setAngle - 0.0001 * self.RateOfFire;
8+
if self.setAngle < 0 then
9+
self.setAngle = 0;
10+
end
11+
end
12+
if self.FiredFrame then
13+
self.setAngle = self.setAngle + self.tilt;
14+
end
15+
self.RotAngle = self.RotAngle + self.setAngle * self.FlipFactor;
16+
local jointOffset = Vector(self.JointOffset.X * self.FlipFactor, self.JointOffset.Y):RadRotate(self.RotAngle);
17+
self.Pos = self.Pos - jointOffset + Vector(jointOffset.X, jointOffset.Y):RadRotate(-self.setAngle * self.FlipFactor);
18+
end

Base.rte/Devices/Shared/Scripts/ShotgunReload.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ function Create(self)
33
self.loadedShell = false;
44
self.reloadCycle = false;
55

6-
self.reloadDelay = self.ReloadTime;
6+
self.reloadDelay = 100;
77

88
if self.Magazine then
99
self.ammoCounter = self.Magazine.RoundCount;

0 commit comments

Comments
 (0)