Skip to content

Commit b223b83

Browse files
committed
Fix and tweak Disarmer so that it works faster
1 parent f86f430 commit b223b83

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

Data/Base.rte/Devices/Tools/Disarmer/Disarmer.lua

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
function Create(self)
2+
self.disarmTicks = 3;
3+
self.disarmRange = GetPPM() * 4;
4+
25
self.delayTimer = Timer();
36
self.overallTimer = Timer();
47
self.scanTimer = Timer();
8+
9+
self.tickDuration = 1000;
10+
self.disarmTime = self.disarmTicks * self.tickDuration;
511
self.actionPhase = 0;
612
self.blink = false;
7-
8-
self.disarmRange = GetPPM() * 4;
913
self.MuzzleOffset = Vector(self.disarmRange * 0.5, 0);
1014
self.targetTable = {};
1115

@@ -17,20 +21,20 @@ end
1721
function Update(self)
1822
if self.Magazine then
1923
if self:IsActivated() then
20-
self.Magazine.RoundCount = math.ceil(4000 - self.overallTimer.ElapsedSimTimeMS);
21-
if self.delayTimer:IsPastSimMS(1000) then
24+
self.Magazine.RoundCount = math.ceil(self.disarmTime - self.overallTimer.ElapsedSimTimeMS);
25+
if self.delayTimer:IsPastSimMS(self.tickDuration) then
2226
self.delayTimer:Reset();
2327
self.blink = false;
2428
local targetCount = 0;
2529
self.actionPhase = self.actionPhase + 1;
2630
for i = 1, #self.targetTable do
2731
if self.targetTable[i] and IsMOSRotating(self.targetTable[i]) and SceneMan:ShortestDistance(self.MuzzlePos, self.targetTable[i].Pos, SceneMan.SceneWrapsX):MagnitudeIsLessThan(self.disarmRange + 5) then
2832
targetCount = targetCount + 1;
29-
local detectPar = CreateMOPixel("Disarmer Detection Particle ".. (self.actionPhase == 4 and "Safe" or "Neutral"));
33+
local detectPar = CreateMOPixel("Disarmer Detection Particle ".. (self.actionPhase == self.disarmTicks and "Safe" or "Neutral"));
3034
detectPar.Pos = self.targetTable[i].Pos;
3135
MovableMan:AddParticle(detectPar);
3236

33-
if self.actionPhase == 4 then
37+
if self.actionPhase == self.disarmTicks then
3438
local itemName = string.gsub(self.targetTable[i]:GetModuleAndPresetName(), " Active", "");
3539
local disarmedItem = CreateTDExplosive(itemName);
3640
disarmedItem.Pos = self.targetTable[i].Pos;
@@ -46,30 +50,30 @@ function Update(self)
4650
self.actionPhase = 0;
4751
self.overallTimer:Reset();
4852
self.errorSound:Play(self.Pos);
49-
elseif self.actionPhase == 4 then
50-
self.ReloadTime = 1000 + (1000 * targetCount);
53+
elseif self.actionPhase == self.disarmTicks then
54+
self.BaseReloadTime = 1000 + (500 * targetCount);
5155
self:Reload();
5256
end
5357
end
54-
if self.actionPhase > 0 and self.actionPhase < 4 then
58+
if self.actionPhase > 0 and self.actionPhase < self.disarmTicks then
5559
if self.blink == false then
5660
self.blink = true;
5761
local soundfx = CreateAEmitter("Disarmer Sound Blip");
5862
soundfx.Pos = self.Pos;
5963
MovableMan:AddParticle(soundfx);
6064
end
61-
elseif self.actionPhase == 4 then
65+
elseif self.actionPhase == self.disarmTicks then
6266
local soundfx = CreateAEmitter("Disarmer Sound Disarm");
6367
soundfx.Pos = self.Pos;
6468
MovableMan:AddParticle(soundfx);
6569
end
6670
else
6771
self.delayTimer:Reset();
6872
self.overallTimer:Reset();
69-
self.Magazine.RoundCount = 4000;
73+
self.Magazine.RoundCount = self.disarmTime;
7074
self.actionPhase = 0;
7175

72-
if self:GetParent() and self.scanTimer:IsPastSimMS(500) then
76+
if self:GetParent() and self.scanTimer:IsPastSimMS(self.tickDuration * 0.5) then
7377
self.targetTable = {};
7478
self.scanTimer:Reset();
7579
local alarm = false;

0 commit comments

Comments
 (0)