@@ -25,7 +25,7 @@ function Create(self)
25
25
self .activateSound = CreateSoundContainer (" Explosive Device Activate" , " Base.rte" );
26
26
self .blipSound = CreateSoundContainer (" Timed Explosive Blip" , " Coalition.rte" );
27
27
28
- RemoteExplosiveStick (self );
28
+ TimedExplosiveStick (self );
29
29
end
30
30
31
31
function Update (self )
@@ -34,7 +34,7 @@ function Update(self)
34
34
TimedExplosiveTable [self .tableNum ] = self ;
35
35
end
36
36
37
- RemoteExplosiveStick (self );
37
+ TimedExplosiveStick (self );
38
38
39
39
if self .stuck then
40
40
if self .lifeTimer :IsPastSimMS (self .detonateDelay ) then
@@ -89,6 +89,70 @@ function Update(self)
89
89
end
90
90
end
91
91
92
+ function TimedExplosiveStick (self )
93
+ if self .actionPhase == 0 then
94
+ local checkVec = Vector (self .Vel .X , self .Vel .Y + 1 ):SetMagnitude (math.max (self .Vel .Magnitude * rte .PxTravelledPerFrame , self .Radius ));
95
+ -- Find a user to ignore hits with
96
+ if not self .userID then
97
+ self .userID = rte .NoMOID ;
98
+ local moCheck = SceneMan :CastMORay (self .Pos , checkVec * (- 2 ), self .ID , - 1 , rte .airID , true , 1 );
99
+ if moCheck ~= rte .NoMOID then
100
+ local rootID = MovableMan :GetMOFromID (moCheck ).RootID ;
101
+ if rootID ~= rte .NoMOID then
102
+ self .userID = rootID ;
103
+ end
104
+ end
105
+ end
106
+ local rayHitPos = Vector ();
107
+ local rayHit = false ;
108
+ for i = 1 , 2 do
109
+ local checkPos = self .Pos + (checkVec / i );
110
+ local checkPix = SceneMan :GetMOIDPixel (checkPos .X , checkPos .Y );
111
+ if checkPix ~= rte .NoMOID and MovableMan :GetMOFromID (checkPix ).RootID ~= self .userID then
112
+ checkPos = checkPos + SceneMan :ShortestDistance (checkPos , self .Pos , SceneMan .SceneWrapsX ):SetMagnitude (ToMOSprite (self ):GetSpriteWidth () * 0.5 - 1 );
113
+ self .target = ToMOSRotating (MovableMan :GetMOFromID (checkPix ));
114
+ self .stickPosition = SceneMan :ShortestDistance (self .target .Pos , checkPos , SceneMan .SceneWrapsX );
115
+ self .stickRotation = self .target .RotAngle ;
116
+ self .stickDirection = self .RotAngle ;
117
+
118
+ if self .activateSound then
119
+ self .activateSound :Play (self .Pos );
120
+ end
121
+ self .stuck = true ;
122
+ rayHit = true ;
123
+ break ;
124
+ end
125
+ end
126
+ if rayHit then
127
+ self .actionPhase = 1 ;
128
+ elseif SceneMan :CastStrengthRay (self .Pos , checkVec , 0 , rayHitPos , 1 , rte .airID , SceneMan .SceneWrapsX ) then
129
+ self .Pos = rayHitPos + SceneMan :ShortestDistance (rayHitPos , self .Pos , SceneMan .SceneWrapsX ):SetMagnitude (ToMOSprite (self ):GetSpriteWidth () * 0.5 - 1 );
130
+ self .PinStrength = 1000 ;
131
+ self .AngularVel = 0 ;
132
+ self .stuck = true ;
133
+ self .actionPhase = 2 ;
134
+
135
+ if self .activateSound then
136
+ self .activateSound :Play (self .Pos );
137
+ end
138
+ end
139
+ else
140
+ self .Vel = Vector ();
141
+ self .AngularVel = 0 ;
142
+ if self .actionPhase == 1 then
143
+ if self .target and self .target .ID ~= rte .NoMOID and not self .target .ToDelete then
144
+ self .Pos = self .target .Pos + Vector (self .stickPosition .X , self .stickPosition .Y ):RadRotate (self .target .RotAngle - self .stickRotation );
145
+ self .RotAngle = self .stickDirection + (self .target .RotAngle - self .stickRotation );
146
+ self .PinStrength = 1000 ;
147
+ self .Vel = Vector ();
148
+ else
149
+ self .PinStrength = 0 ;
150
+ self .actionPhase = 0 ;
151
+ end
152
+ end
153
+ end
154
+ end
155
+
92
156
function Destroy (self )
93
157
TimedExplosiveTable [self .tableNum ] = nil ;
94
158
end
0 commit comments