1
1
function Create (self )
2
2
3
3
self .laserTimer = Timer ();
4
- self .laserCheckDelay = 50 ;
4
+ self .laserCheckDelay = 30 ;
5
5
self .laserLength = self .SharpLength + FrameMan .PlayerScreenWidth * 0.3 ;
6
6
self .laserSpaceCheck = 8 ; -- For optimization purposes. Smaller value means a more accurate but slower check.
7
7
@@ -12,60 +12,63 @@ function Update(self)
12
12
13
13
if self .laserTimer :IsPastSimMS (self .laserCheckDelay ) then
14
14
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 );
28
27
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
37
33
roughLandPos = checkPos ;
38
34
break ;
39
35
end
36
+ else
37
+ roughLandPos = checkPos ;
38
+ break ;
40
39
end
40
+ end
41
41
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 );
51
50
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 );
57
59
end
58
- else
59
60
break ;
60
61
end
61
- roughLandPos = checkPos ;
62
+ else
63
+ break ;
62
64
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 ;
68
66
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 );
69
72
end
70
73
end
71
74
end
0 commit comments