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

Commit aa387f3

Browse files
committed
Anti Personnel Mine tweaks;
Detection ray now starts closer to the mine and is more easily blocked by terrain
1 parent b0793eb commit aa387f3

File tree

1 file changed

+18
-19
lines changed
  • Data/Base.rte/Devices/Explosives/AntiPersonnelMine

1 file changed

+18
-19
lines changed

Data/Base.rte/Devices/Explosives/AntiPersonnelMine/MineSet.lua

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -99,27 +99,26 @@ function Update(self)
9999
self.delayTimer:Reset();
100100

101101
local rayHitPos = Vector();
102-
local startPos = self.Pos + Vector(self.Radius, 0):RadRotate(detectionAngle);
103-
local terrainRaycast = SceneMan:CastStrengthRay(startPos, Vector(self.laserLength, 0):RadRotate(detectionAngle), 10, rayHitPos, 1, rte.airID, SceneMan.SceneWrapsX);
104-
105-
if terrainRaycast == true then
106-
self.tempLaserLength = SceneMan:ShortestDistance(startPos, rayHitPos, SceneMan.SceneWrapsX).Magnitude;
107-
else
108-
self.tempLaserLength = self.laserLength;
109-
end
110-
local raycast = SceneMan:CastMORay(startPos, Vector(self.tempLaserLength, 0):RadRotate(detectionAngle), self.ID, self.alliedTeam, rte.airID, true, 4);
111-
if raycast ~= rte.NoMOID then
112-
local target = ToMOSRotating(MovableMan:GetMOFromID(raycast)):GetRootParent();
113-
if not (target.Team == self.alliedTeam and IsActor(target)) and (target.Vel.Magnitude * (1 + math.abs(target.AngularVel) + math.sqrt(target.Radius))) > self.detonateThreshold then
114-
self.actionPhase = 2;
115-
self.blink = false;
116-
self.faceDirection = detectionAngle;
102+
local startPos = self.Pos + Vector(1, 0):RadRotate(detectionAngle);
103+
local hitTerrain = SceneMan:CastStrengthRay(startPos, Vector(self.laserLength, 0):RadRotate(detectionAngle), 10, rayHitPos, 1, rte.airID, SceneMan.SceneWrapsX);
104+
105+
self.tempLaserLength = hitTerrain and SceneMan:ShortestDistance(startPos, rayHitPos, SceneMan.SceneWrapsX).Magnitude or self.laserLength;
106+
107+
if self.tempLaserLength > 3 then
108+
local raycast = SceneMan:CastMORay(startPos, Vector(self.tempLaserLength, 0):RadRotate(detectionAngle), self.ID, self.alliedTeam, rte.airID, true, 4);
109+
if raycast ~= rte.NoMOID then
110+
local target = ToMOSRotating(MovableMan:GetMOFromID(raycast)):GetRootParent();
111+
if not (target.Team == self.alliedTeam and IsActor(target)) and (target.Vel.Magnitude * (1 + math.abs(target.AngularVel) + math.sqrt(target.Radius))) > self.detonateThreshold then
112+
self.actionPhase = 2;
113+
self.blink = false;
114+
self.faceDirection = detectionAngle;
115+
end
117116
end
117+
local effectpar = CreateMOPixel("Mine Laser Beam ".. math.random(3), "Base.rte");
118+
effectpar.Pos = startPos + Vector(math.random() * self.tempLaserLength, 0):RadRotate(detectionAngle);
119+
effectpar.EffectRotAngle = detectionAngle;
120+
MovableMan:AddParticle(effectpar);
118121
end
119-
local effectpar = CreateMOPixel("Mine Laser Beam ".. math.random(3), "Base.rte");
120-
effectpar.Pos = startPos + Vector(math.random() * self.tempLaserLength, 0):RadRotate(detectionAngle);
121-
effectpar.EffectRotAngle = detectionAngle;
122-
MovableMan:AddParticle(effectpar);
123122
end
124123

125124
elseif self.actionPhase == 2 then

0 commit comments

Comments
 (0)