Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Sub tick()
- timeCounter += intervalValue
- If timeCounter > 1000 Then
- timeCounter = 0
- End If
- If bLaunched Then
- Try
- If THelper.Exists(target) Then
- If THelper.isPed(target) Then
- If type = TMissileType.dart Then
- targetVec = Native.Function.Call(Of Vector3)(Native.Hash.GET_PED_BONE_COORDS, target, Bone.SKEL_Head, 0, 0, 0)
- Else
- targetVec = Native.Function.Call(Of Vector3)(Native.Hash.GET_PED_BONE_COORDS, target, Bone.SKEL_Spine0, 0, 0, 0)
- End If
- 'UI.ShowSubtitle("ped")
- Else
- targetVec = target.Position
- 'UI.ShowSubtitle("ent")
- End If
- 'Else
- 'UI.ShowSubtitle("pos")
- Else
- Dim tmpMissileRot As Vector3 = missile.Rotation
- tmpMissileRot.Z -= 90
- targetVec = missile.Position + THelper.RotationToDirection(tmpMissileRot)
- End If
- Dim tmpDist As Double = missile.Position.DistanceTo(targetVec - launchDir * 0.25)
- Dim tmpDistAhead As Double = missile.Position.DistanceTo(targetVec + launchDir * 0.25)
- If (tmpDist > tmpDistAhead) OrElse (tmpDist < 0.5) Then
- 'If type = TMissileType.dart Then
- detonateMissile(missile.Position, flightDir, False)
- Throw New Exception("dart_ahead")
- 'End If
- target = Nothing
- End If
- flightDir = Vector3.Normalize(targetVec - missile.Position)
- If type = TMissileType.dart Then
- launchDir += (flightDir - launchDir) * flightFixCoef * 2
- Else
- launchDir += (flightDir - launchDir) * flightFixCoef
- End If
- If flightFixCoef < 1 Then
- flightFixCoef += 0.025
- End If
- Dim tmpRot As Vector3 = THelper.directionToRotation(launchDir, 0)
- tmpRot.Z += 90
- missile.Rotation = tmpRot
- 'missile.ApplyForce(launchDir * speed)
- missile.Velocity = launchDir * speed
- Dim flightTime As Double = Now.Subtract(timerOnFlight).TotalMilliseconds
- If flightTime > 200 Then
- If flightTime > 2000 * THelper.getTimeCoef Then
- detonateMissile(missile.Position, launchDir, True)
- Throw New Exception("timeout")
- End If
- If bInitialWait Then
- bInitialWait = False
- Native.Function.Call(Native.Hash.SET_ENTITY_RECORDS_COLLISIONS, missile, False)
- Native.Function.Call(Native.Hash.SET_ENTITY_RECORDS_COLLISIONS, missile, True)
- End If
- If (Native.Function.Call(Of Boolean)(Native.Hash.HAS_ENTITY_COLLIDED_WITH_ANYTHING, missile)) Then
- detonateMissile(missile.Position, launchDir)
- Throw New Exception("done")
- End If
- End If
- Catch ex As Exception
- bLaunched = False
- missilesList.Remove(Me)
- THelper.releaseSoundID(soundID)
- If fxID > -1 Then
- THelper.ptfx_stop(fxID)
- End If
- Try
- missile.IsVisible = False
- missile.Detach()
- missile.MarkAsNoLongerNeeded()
- missile.Position = Vector3.Zero
- Catch
- End Try
- If playerTargets.Contains(target) Then
- playerTargets.Remove(target)
- End If
- End Try
- Else
- If timeCounter Mod 100 = 0 Then
- missile.IsVisible = False
- End If
- End If
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement