1
1
function Create (self )
2
- self .signalStrength = 1000 ;
3
- self .maxScanRange = 400 ;
4
- self .scanSpacing = 20 ;
5
- self .dotCount = math.floor (self .maxScanRange / self .scanSpacing );
2
+ self .signalStrength = 10000 ;
3
+ self .signalDecrement = 10 ;
4
+ self .maxScanRange = 360 ;
6
5
self .scanSpreadAngle = math.rad (self .ParticleSpreadRange );
6
+ self .flashTimer = Timer ();
7
+ self .activity = ActivityMan :GetActivity ();
8
+ end
9
+
10
+ function Update (self )
11
+ local parent = self :GetRootParent ();
12
+ if IsActor (parent ) and ToActor (parent ):IsPlayerControlled () then
13
+ if self .detectedItemPos then
14
+ local timerRatio = self .flashTimer .ElapsedSimTimeMS / self .flashDelay ;
15
+ if timerRatio < 1 then
16
+ PrimitiveMan :DrawPrimitives (100 * timerRatio , {CirclePrimitive (self .activity :ScreenOfPlayer (ToActor (parent ):GetController ().Player ), self .detectedItemPos , self .detectedItemRadius * timerRatio , 188 )});
17
+ else
18
+ self .detectedItemPos = nil ;
19
+ end
20
+ end
21
+ end
7
22
end
8
23
9
24
function OnFire (self )
10
25
local signalStrength = self .signalStrength ;
11
26
local angleVariance = self .scanSpreadAngle * 0.5 - (math.random () * self .scanSpreadAngle );
12
- for i = 1 , self .dotCount do
13
- local checkPos = self .MuzzlePos + Vector ((self .scanSpacing * i ) * self .FlipFactor , 0 ):RadRotate (self .RotAngle + angleVariance );
27
+ local unseenResolution = SceneMan :GetUnseenResolution (- 1 );
28
+ local scanSpacing = math.max (math.min (unseenResolution .X , unseenResolution .Y ) * 0.5 , 1 );
29
+ local trace = Vector (self .FlipFactor , 0 ):RadRotate (self .RotAngle );
30
+ local checkPos = Vector (self .MuzzlePos .X , self .MuzzlePos .Y );
31
+ for i = 1 , self .maxScanRange / scanSpacing do
32
+ trace = Vector (trace .X , trace .Y ):SetMagnitude (i * scanSpacing );
33
+ checkPos = self .MuzzlePos + Vector (trace .X , trace .Y ):RadRotate (angleVariance );
14
34
if SceneMan .SceneWrapsX then
15
35
if checkPos .X > SceneMan .SceneWidth then
16
36
checkPos = Vector (checkPos .X - SceneMan .SceneWidth , checkPos .Y );
17
37
elseif checkPos .X < 0 then
18
38
checkPos = Vector (checkPos .X + SceneMan .SceneWidth , checkPos .Y );
19
39
end
20
40
end
21
- signalStrength = signalStrength - (40 + SceneMan :GetMaterialFromID (SceneMan :GetTerrMatter (checkPos .X , checkPos .Y )).StructuralIntegrity );
41
+ signalStrength = signalStrength - (self . signalDecrement + SceneMan :GetMaterialFromID (SceneMan :GetTerrMatter (checkPos .X , checkPos .Y )).StructuralIntegrity ) * scanSpacing ;
22
42
if signalStrength < 0 then
23
43
break ;
24
44
end
@@ -27,4 +47,13 @@ function OnFire(self)
27
47
break ;
28
48
end
29
49
end
50
+ if self .detectedItemPos == nil then
51
+ local mo = MovableMan :GetMOFromID (SceneMan :CastMORay (self .MuzzlePos , trace , self :GetRootParent ().ID , Activity .NOTEAM , rte .airID , true , 1 ));
52
+ if mo and IsMOSRotating (mo ) then
53
+ self .flashTimer :Reset ();
54
+ self .detectedItemPos = mo :GetRootParent ().Pos ;
55
+ self .detectedItemRadius = 5 + mo :GetRootParent ().Radius ;
56
+ self .flashDelay = 100 + 100 * math.sqrt (self .detectedItemRadius );
57
+ end
58
+ end
30
59
end
0 commit comments