Advertisement
julioCCs

IronmanV missile sub tick

Aug 19th, 2015
824
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 4.91 KB | None | 0 0
  1. Public Sub tick()
  2.                 timeCounter += intervalValue
  3.  
  4.                 If timeCounter > 1000 Then
  5.                     timeCounter = 0
  6.                 End If
  7.  
  8.                 If bLaunched Then
  9.                     Try
  10.                         If THelper.Exists(target) Then
  11.                             If THelper.isPed(target) Then
  12.                                 If type = TMissileType.dart Then
  13.                                     targetVec = Native.Function.Call(Of Vector3)(Native.Hash.GET_PED_BONE_COORDS, target, Bone.SKEL_Head, 0, 0, 0)
  14.                                 Else
  15.                                     targetVec = Native.Function.Call(Of Vector3)(Native.Hash.GET_PED_BONE_COORDS, target, Bone.SKEL_Spine0, 0, 0, 0)
  16.                                 End If
  17.                                 'UI.ShowSubtitle("ped")
  18.                             Else
  19.                                 targetVec = target.Position
  20.                                 'UI.ShowSubtitle("ent")
  21.                             End If
  22.                             'Else
  23.                             'UI.ShowSubtitle("pos")
  24.                         Else
  25.                             Dim tmpMissileRot As Vector3 = missile.Rotation
  26.                             tmpMissileRot.Z -= 90
  27.  
  28.                             targetVec = missile.Position + THelper.RotationToDirection(tmpMissileRot)
  29.                         End If
  30.  
  31.                         Dim tmpDist As Double = missile.Position.DistanceTo(targetVec - launchDir * 0.25)
  32.                         Dim tmpDistAhead As Double = missile.Position.DistanceTo(targetVec + launchDir * 0.25)
  33.  
  34.                         If (tmpDist > tmpDistAhead) OrElse (tmpDist < 0.5) Then
  35.                             'If type = TMissileType.dart Then
  36.                             detonateMissile(missile.Position, flightDir, False)
  37.  
  38.                             Throw New Exception("dart_ahead")
  39.                             'End If
  40.  
  41.                             target = Nothing
  42.                         End If
  43.  
  44.                         flightDir = Vector3.Normalize(targetVec - missile.Position)
  45.  
  46.                         If type = TMissileType.dart Then
  47.                             launchDir += (flightDir - launchDir) * flightFixCoef * 2
  48.                         Else
  49.                             launchDir += (flightDir - launchDir) * flightFixCoef
  50.                         End If
  51.  
  52.                         If flightFixCoef < 1 Then
  53.                             flightFixCoef += 0.025
  54.                         End If
  55.  
  56.                         Dim tmpRot As Vector3 = THelper.directionToRotation(launchDir, 0)
  57.                         tmpRot.Z += 90
  58.  
  59.                         missile.Rotation = tmpRot
  60.                         'missile.ApplyForce(launchDir * speed)
  61.                         missile.Velocity = launchDir * speed
  62.  
  63.                         Dim flightTime As Double = Now.Subtract(timerOnFlight).TotalMilliseconds
  64.  
  65.                         If flightTime > 200 Then
  66.                             If flightTime > 2000 * THelper.getTimeCoef Then
  67.                                 detonateMissile(missile.Position, launchDir, True)
  68.  
  69.                                 Throw New Exception("timeout")
  70.                             End If
  71.  
  72.                             If bInitialWait Then
  73.                                 bInitialWait = False
  74.  
  75.                                 Native.Function.Call(Native.Hash.SET_ENTITY_RECORDS_COLLISIONS, missile, False)
  76.                                 Native.Function.Call(Native.Hash.SET_ENTITY_RECORDS_COLLISIONS, missile, True)
  77.                             End If
  78.  
  79.                             If (Native.Function.Call(Of Boolean)(Native.Hash.HAS_ENTITY_COLLIDED_WITH_ANYTHING, missile)) Then
  80.                                 detonateMissile(missile.Position, launchDir)
  81.  
  82.                                 Throw New Exception("done")
  83.                             End If
  84.                         End If
  85.                     Catch ex As Exception
  86.                         bLaunched = False
  87.  
  88.                         missilesList.Remove(Me)
  89.  
  90.                         THelper.releaseSoundID(soundID)
  91.  
  92.                         If fxID > -1 Then
  93.                             THelper.ptfx_stop(fxID)
  94.                         End If
  95.  
  96.                         Try
  97.                             missile.IsVisible = False
  98.                             missile.Detach()
  99.                             missile.MarkAsNoLongerNeeded()
  100.                             missile.Position = Vector3.Zero
  101.                         Catch
  102.                         End Try
  103.  
  104.                         If playerTargets.Contains(target) Then
  105.                             playerTargets.Remove(target)
  106.                         End If
  107.                     End Try
  108.                 Else
  109.                     If timeCounter Mod 100 = 0 Then
  110.                         missile.IsVisible = False
  111.                     End If
  112.                 End If
  113.             End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement