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

Commit a53064c

Browse files
committed
Nano Rifle improvements
1 parent b955d15 commit a53064c

File tree

5 files changed

+102
-76
lines changed

5 files changed

+102
-76
lines changed

Techion.rte/Devices/Weapons/NanoRifle/NanoDestroy.lua renamed to Techion.rte/Devices/Weapons/NanoRifle/NanoEffect.lua

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@ function Create(self)
33
for id = 1, MovableMan:GetMOIDCount() - 1 do
44
local mo = MovableMan:GetMOFromID(id);
55
if mo and mo.UniqueID == self.Sharpness then
6-
self.target = mo;
6+
self.target = ToMOSRotating(mo);
77
break;
88
end
99
end
1010

11+
self.healing = self.target.Team == self.Team;
12+
self.healMultiplier = self.target.ModuleName == "Techion.rte" and 1.0 or 0.5;
13+
1114
if self.target then
1215
--Current number of damage pulses.
1316
self.pulses = 0;
@@ -19,10 +22,10 @@ function Create(self)
1922
self.flickerChance = 0.9;
2023

2124
--Length of time between pulses of damage.
22-
self.damageTime = 300;
25+
self.pulseTime = 300;
2326

2427
--Timer for damage.
25-
self.damageTimer = Timer();
28+
self.pulseTimer = Timer();
2629

2730
--Offset information.
2831
self.Pos = self.Pos + self.Vel * rte.PxTravelledPerFrame;
@@ -52,22 +55,34 @@ function Update(self)
5255
MovableMan:AddParticle(flicker);
5356
end
5457

55-
--Cause damage.
56-
if self.damageTimer:IsPastSimMS(self.damageTime + self.target.Material.StructuralIntegrity * 2) then
58+
--Cause damage to enemies, or heal friendlies.
59+
if self.pulseTimer:IsPastSimMS(self.pulseTime + self.target.Material.StructuralIntegrity * 2) then
5760

5861
if IsAttachable(self.target) then
5962
self.nextTarget = ToAttachable(self.target):GetParent();
6063
self.nextTargetOffset = ToAttachable(self.target).ParentOffset;
6164
end
62-
63-
local woundName = ToMOSRotating(self.target):GetEntryWoundPresetName();
64-
if woundName ~= "" then
65-
local wound = CreateAEmitter(woundName);
66-
wound.EmitAngle = self.targetOffset.AbsRadAngle + RangeRand(-0.1, 0.1);
67-
ToMOSRotating(self.target):AddWound(wound, self.targetOffset + Vector(math.random(-1, 1), math.random(-1, 1)), true);
65+
if self.healing then
66+
if self.target.WoundCount > 0 then
67+
local damage = self.target:RemoveWounds(1);
68+
local parent = self.target:GetParent() or self.target;
69+
if IsActor(parent) then
70+
ToActor(parent):AddHealth(damage * self.healMultiplier);
71+
end
72+
else
73+
--Move on to the next target MO to repair.
74+
self.target = nil;
75+
end
76+
else
77+
local woundName = ToMOSRotating(self.target):GetEntryWoundPresetName();
78+
if woundName ~= "" then
79+
local wound = CreateAEmitter(woundName);
80+
wound.EmitAngle = self.targetOffset.AbsRadAngle + RangeRand(-0.1, 0.1);
81+
ToMOSRotating(self.target):AddWound(wound, self.targetOffset + Vector(math.random(-1, 1), math.random(-1, 1)), true);
82+
end
6883
end
6984
self.pulses = self.pulses + 1;
70-
self.damageTimer:Reset();
85+
self.pulseTimer:Reset();
7186
end
7287
if self.pulses > self.maxPulses then
7388
self.ToDelete = true;
@@ -79,6 +94,10 @@ function Update(self)
7994

8095
self.nextTarget = nil;
8196
else
82-
self:GibThis();
97+
if self.healing then
98+
self.ToDelete = true;
99+
else
100+
self:GibThis();
101+
end
83102
end
84103
end

Techion.rte/Devices/Weapons/NanoRifle/NanoRifle.ini

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ AddEffect = MOPixel
9090

9191

9292
AddEffect = AEmitter
93-
PresetName = Nanobot Destroy Effect
94-
ScriptPath = Techion.rte/Devices/Weapons/NanoRifle/NanoDestroy.lua
93+
PresetName = Nanobot Effect
94+
ScriptPath = Techion.rte/Devices/Weapons/NanoRifle/NanoEffect.lua
9595
Mass = 0
9696
PinStrength = 1000
9797
LifeTime = 8000
@@ -105,7 +105,7 @@ AddEffect = AEmitter
105105
EmissionSound = SoundContainer
106106
AttenuationStartDistance = 195
107107
AddSound = ContentFile
108-
FilePath = Techion.rte/Devices/Weapons/NanoRifle/Sounds/NanoDestroy.flac
108+
FilePath = Techion.rte/Devices/Weapons/NanoRifle/Sounds/NanoEffect.flac
109109
LoopSetting = -1
110110
EmissionEnabled = 0
111111
EmissionsIgnoreThis = 0
@@ -299,7 +299,7 @@ AddDevice = HDFirearm
299299
Magazine = Magazine
300300
CopyOf = Magazine Techion Nano Rifle
301301
Flash = Attachable
302-
CopyOf = Muzzle Flash Shotgun
302+
CopyOf = Muzzle Flash Techion Laser
303303
FireSound = SoundContainer
304304
AttenuationStartDistance = 220
305305
AddSound = ContentFile
Lines changed: 46 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
function Create(self)
22

33
self.laserTimer = Timer();
4-
self.laserCheckDelay = 50;
4+
self.laserCheckDelay = 30;
55
self.laserLength = self.SharpLength + FrameMan.PlayerScreenWidth * 0.3;
66
self.laserSpaceCheck = 8; --For optimization purposes. Smaller value means a more accurate but slower check.
77

@@ -12,60 +12,63 @@ function Update(self)
1212

1313
if self.laserTimer:IsPastSimMS(self.laserCheckDelay) then
1414
self.laserTimer:Reset();
15-
16-
if self.RootID ~= self.ID then
17-
local actor = MovableMan:GetMOFromID(self.RootID);
18-
if MovableMan:IsActor(actor) and ToActor(actor):GetController():IsState(Controller.AIM_SHARP) then
19-
local roughLandPos = self.MuzzlePos + Vector(self.laserLength, 0):RadRotate(ToActor(actor):GetAimAngle(true));
20-
for i = 0, self.laserDensity do
21-
local checkPos = self.MuzzlePos + Vector(self.laserSpaceCheck * i, 0):RadRotate(ToActor(actor):GetAimAngle(true));
22-
if SceneMan.SceneWrapsX == true then
23-
if checkPos.X > SceneMan.SceneWidth then
24-
checkPos = Vector(checkPos.X - SceneMan.SceneWidth, checkPos.Y);
25-
elseif checkPos.X < 0 then
26-
checkPos = Vector(SceneMan.SceneWidth + checkPos.X, checkPos.Y);
27-
end
15+
local actor = self:GetRootParent();
16+
if IsActor(actor) and ToActor(actor):GetController():IsState(Controller.AIM_SHARP) then
17+
local actor = ToActor(actor);
18+
local aimAngle = actor:GetAimAngle(true);
19+
local roughLandPos = self.MuzzlePos + Vector(self.laserLength, 0):RadRotate(aimAngle);
20+
for i = 0, self.laserDensity do
21+
local checkPos = self.MuzzlePos + Vector(self.laserSpaceCheck * i, 0):RadRotate(aimAngle);
22+
if SceneMan.SceneWrapsX == true then
23+
if checkPos.X > SceneMan.SceneWidth then
24+
checkPos = Vector(checkPos.X - SceneMan.SceneWidth, checkPos.Y);
25+
elseif checkPos.X < 0 then
26+
checkPos = Vector(SceneMan.SceneWidth + checkPos.X, checkPos.Y);
2827
end
29-
local terrCheck = SceneMan:GetTerrMatter(checkPos.X, checkPos.Y);
30-
if terrCheck == rte.airID then
31-
local moCheck = SceneMan:GetMOIDPixel(checkPos.X, checkPos.Y);
32-
if moCheck ~= rte.NoMOID and MovableMan:GetMOFromID(moCheck).Team ~= actor.Team then
33-
roughLandPos = checkPos;
34-
break;
35-
end
36-
else
28+
end
29+
local terrCheck = SceneMan:GetTerrMatter(checkPos.X, checkPos.Y);
30+
if terrCheck == rte.airID then
31+
local moCheck = SceneMan:GetMOIDPixel(checkPos.X, checkPos.Y);
32+
if moCheck ~= rte.NoMOID and MovableMan:GetMOFromID(moCheck).Team ~= actor.Team then
3733
roughLandPos = checkPos;
3834
break;
3935
end
36+
else
37+
roughLandPos = checkPos;
38+
break;
4039
end
40+
end
4141

42-
local checkRoughLandPos = roughLandPos + Vector(self.laserSpaceCheck * -1, 0):RadRotate(ToActor(actor):GetAimAngle(true));
43-
for i = 0, self.laserSpaceCheck do
44-
local checkPos = checkRoughLandPos + Vector(i, 0):RadRotate(ToActor(actor):GetAimAngle(true));
45-
if SceneMan.SceneWrapsX == true then
46-
if checkPos.X > SceneMan.SceneWidth then
47-
checkPos = Vector(checkPos.X - SceneMan.SceneWidth,checkPos.Y);
48-
elseif checkPos.X < 0 then
49-
checkPos = Vector(SceneMan.SceneWidth + checkPos.X, checkPos.Y);
50-
end
42+
local checkRoughLandPos = roughLandPos + Vector(self.laserSpaceCheck * -1, 0):RadRotate(aimAngle);
43+
for i = 0, self.laserSpaceCheck do
44+
local checkPos = checkRoughLandPos + Vector(i, 0):RadRotate(aimAngle);
45+
if SceneMan.SceneWrapsX == true then
46+
if checkPos.X > SceneMan.SceneWidth then
47+
checkPos = Vector(checkPos.X - SceneMan.SceneWidth,checkPos.Y);
48+
elseif checkPos.X < 0 then
49+
checkPos = Vector(SceneMan.SceneWidth + checkPos.X, checkPos.Y);
5150
end
52-
local terrCheck = SceneMan:GetTerrMatter(checkPos.X, checkPos.Y);
53-
if terrCheck == rte.airID then
54-
local moCheck = SceneMan:GetMOIDPixel(checkPos.X, checkPos.Y);
55-
if moCheck ~= rte.NoMOID then
56-
break;
51+
end
52+
local terrCheck = SceneMan:GetTerrMatter(checkPos.X, checkPos.Y);
53+
if terrCheck == rte.airID then
54+
local moCheck = SceneMan:GetMOIDPixel(checkPos.X, checkPos.Y);
55+
if moCheck ~= rte.NoMOID then
56+
if actor:IsPlayerControlled() then
57+
local mo = MovableMan:GetMOFromID(moCheck);
58+
PrimitiveMan:DrawCirclePrimitive(ActivityMan:GetActivity():ScreenOfPlayer(actor:GetController().Player), mo.Pos, mo.Radius, 5);
5759
end
58-
else
5960
break;
6061
end
61-
roughLandPos = checkPos;
62+
else
63+
break;
6264
end
63-
64-
local laserPar = CreateMOPixel("Nano Rifle Laser Sight Glow");
65-
laserPar.Pos = roughLandPos;
66-
laserPar.Lifetime = self.laserCheckDelay * 2;
67-
MovableMan:AddParticle(laserPar);
65+
roughLandPos = checkPos;
6866
end
67+
68+
local laserPar = CreateMOPixel("Nano Rifle Laser Sight Glow");
69+
laserPar.Pos = roughLandPos;
70+
laserPar.Lifetime = self.laserCheckDelay * 2;
71+
MovableMan:AddParticle(laserPar);
6972
end
7073
end
7174
end

Techion.rte/Devices/Weapons/NanoRifle/NanoShot.lua

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
function Create(self)
22
--Collide with objects and deploy the destroy effect.
3-
self.CheckCollision = function(vel)
4-
local Trace = vel * rte.PxTravelledPerFrame;
5-
local moid = SceneMan:CastMORay(self.Pos, Trace, rte.NoMOID, self.Team, rte.airID, true, 1);
3+
self.CheckCollision = function(inverted)
4+
local trace = self.Vel * rte.PxTravelledPerFrame;
5+
if inverted then
6+
trace = trace * (-1);
7+
end
8+
local moid = SceneMan:CastMORay(self.Pos, trace, rte.NoMOID, -2, rte.airID, true, 1);
69
if moid > 0 and moid < rte.NoMOID then
710
local hitPos = Vector();
8-
SceneMan:CastFindMORay(self.Pos, Trace, moid, hitPos, rte.airID, true, 1);
9-
self.deleteNextFrame = true;
10-
self.Vel = (SceneMan:ShortestDistance(self.Pos, hitPos, true)/TimerMan.DeltaTimeSecs)/GetPPM();
11-
12-
local target = MovableMan:GetMOFromID(moid);
13-
if target then
14-
local destroy = CreateAEmitter("Nanobot Destroy Effect", "Techion.rte");
15-
destroy.Sharpness = target.UniqueID;
16-
destroy.Pos = hitPos + SceneMan:ShortestDistance(hitPos, target.Pos, true):SetMagnitude(3);
17-
destroy.Vel = target.Vel;
18-
MovableMan:AddParticle(destroy);
11+
SceneMan:CastFindMORay(self.Pos, trace, moid, hitPos, rte.airID, true, 1);
12+
local target = ToMOSRotating(MovableMan:GetMOFromID(moid));
13+
if target and (target.Team ~= self.Team or (target.WoundCount > 0 and target.PresetName ~= "Nano Rifle")) then
14+
self.deleteNextFrame = true;
15+
self.Vel = (SceneMan:ShortestDistance(self.Pos, hitPos, true)/TimerMan.DeltaTimeSecs)/GetPPM();
16+
17+
local effect = CreateAEmitter("Nanobot Effect", "Techion.rte");
18+
effect.Sharpness = target.UniqueID;
19+
effect.Pos = hitPos + SceneMan:ShortestDistance(hitPos, target.Pos, true):SetMagnitude(3);
20+
effect.Vel = target.Vel;
21+
effect.Team = self.Team;
22+
MovableMan:AddParticle(effect);
1923
end
2024
end
2125
end
@@ -24,7 +28,7 @@ function Create(self)
2428

2529
self.deleteNextFrame = false;
2630
--Check backward.
27-
self.CheckCollision(Vector(self.Vel.X, self.Vel.Y):RadRotate(math.pi));
31+
self.CheckCollision(true);
2832

2933
self.trailLength = 50;
3034

@@ -47,7 +51,7 @@ function Update(self)
4751
self.ToDelete = true;
4852
elseif self.Vel.Magnitude >= self.speedThreshold then
4953
--Check forward.
50-
self.CheckCollision(self.Vel);
54+
self.CheckCollision(false);
5155
end
5256
self.lastVel = Vector(self.Vel.X, self.Vel.Y);
5357
end

0 commit comments

Comments
 (0)