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

Commit b079f33

Browse files
committed
You can now add a twirly effect to the SmokeTrail script
1 parent eb4b9f2 commit b079f33

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

Base.rte/Scripts/Shared/SmokeTrail.lua

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,30 @@
11
function Create(self)
22
self.smokeTrailLifeTime = self:NumberValueExists("SmokeTrailLifeTime") and self:GetNumberValue("SmokeTrailLifeTime") or 150;
33
self.smokeTrailRadius = self:NumberValueExists("SmokeTrailRadius") and self:GetNumberValue("SmokeTrailRadius") or ToMOSprite(self):GetSpriteHeight() * 0.5;
4+
self.smokeTrailTwirl = self:NumberValueExists("SmokeTrailTwirl") and self:GetNumberValue("SmokeTrailTwirl") or 0;
5+
self.smokeTwirlCounter = math.random() < 0.5 and math.pi or 0;
46
end
57
function Update(self)
68
local effect;
79
local offset = self.Vel * rte.PxTravelledPerFrame; --The effect will be created the next frame so move it one frame backwards towards the barrel
810

9-
local trailLength = math.floor(offset.Magnitude + 0.5);
10-
for i = 1, trailLength, 6 do
11-
effect = CreateMOSParticle("Tiny Smoke Trail 1", "Base.rte");
11+
local trailLength = math.floor(offset.Magnitude * 0.5 - 1);
12+
for i = 1, trailLength do
13+
local effect = CreateMOSParticle("Tiny Smoke Trail 1", "Base.rte");
1214
if effect then
1315
effect.Pos = self.Pos - offset * (i/trailLength) + Vector(RangeRand(-1, 1), RangeRand(-1, 1)) * self.smokeTrailRadius;
14-
effect.Vel = self.Vel * RangeRand(0.75, 1.0);
15-
effect.Lifetime = self.smokeTrailLifeTime * RangeRand(1.0, 1.5);
16+
effect.Vel = self.Vel * RangeRand(0.75, 1);
17+
effect.Lifetime = self.smokeTrailLifeTime * RangeRand(0.5, 1);
18+
19+
if self.smokeTrailTwirl > 0 then
20+
effect.AirResistance = effect.AirResistance * RangeRand(0.9, 1);
21+
effect.GlobalAccScalar = effect.GlobalAccScalar * math.random();
22+
23+
effect.Pos = self.Pos - offset + offset * i/trailLength;
24+
effect.Vel = self.Vel + Vector(0, math.sin(self.smokeTwirlCounter) * self.smokeTrailTwirl + RangeRand(-0.1, 0.1)):RadRotate(self.Vel.AbsRadAngle);
25+
26+
self.smokeTwirlCounter = self.smokeTwirlCounter + RangeRand(-0.2, 0.4);
27+
end
1628
MovableMan:AddParticle(effect);
1729
end
1830
end

Ronin.rte/Devices/Weapons/RPG7/RPG7.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ AddAmmo = AEmitter
5151
SmokeTrailLifeTime = 500
5252
AddCustomValue = NumberValue
5353
SmokeTrailRadius = 1
54+
AddCustomValue = NumberValue
55+
SmokeTrailTwirl = 4
5456
SpriteFile = ContentFile
5557
FilePath = Ronin.rte/Devices/Weapons/RPG7/RPG.png
5658
FrameCount = 1

0 commit comments

Comments
 (0)