SHARE
TWEET

TargetingIdea.vb

julioCCs Mar 9th, 2013 412 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'https://www.youtube.com/user/GTAScripting
  2. 'http://gtaxscripting.blogspot.com/
  3. 'http://www.facebook.com/GtaIVScripting
  4. 'https://twitter.com/julionib
  5.  
  6. Imports System
  7. Imports GTA
  8. Imports System.Drawing
  9. Imports System.Windows.Forms
  10.  
  11. Public Class Targetting
  12.     Inherits Script
  13.  
  14.     Private pedsToTarget As Ped() = Nothing
  15.     Private vehiclesToTarget As Vehicle() = Nothing
  16.     Private objectsToTarget As GTA.Object() = Nothing
  17.  
  18.     Public Sub New()
  19.         Me.Interval = 10
  20.     End Sub
  21.  
  22.     Shadows Sub keyDown(ByVal sender As Object, ByVal e As GTA.KeyEventArgs) Handles MyBase.KeyDown
  23.         If e.Key = Keys.RButton Then
  24.             pedsToTarget = World.GetAllPeds
  25.             vehiclesToTarget = World.GetVehicles(Player.Character.Position, 100)
  26.             objectsToTarget = World.GetAllObjects
  27.         End If
  28.     End Sub
  29.  
  30.     Shadows Sub keyUp(ByVal sender As Object, ByVal e As GTA.KeyEventArgs) Handles MyBase.KeyUp
  31.     End Sub
  32.  
  33.     Private Sub general_tick(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Tick
  34.         If Game.isGameKeyPressed(GameKey.Aim) Then
  35.             Dim dist As Double
  36.             Dim comparePosition As Vector3
  37.             Dim vComparePos As Vector3
  38.  
  39.             If Exists(pedsToTarget) Then
  40.                 For Each p As Ped In pedsToTarget
  41.                     If Exists(p) AndAlso (p <> Player.Character) Then
  42.                         dist = p.Position.DistanceTo(Game.CurrentCamera.Position)
  43.                         comparePosition = Game.CurrentCamera.Position + Game.CurrentCamera.Direction * dist
  44.  
  45.                         If p.Position.DistanceTo(comparePosition) < 0.5 Then
  46.                             p.ForceRagdoll(2000, True)
  47.                             p.ApplyForce(Vector3.WorldUp * 0.5, Vector3.WorldNorth)
  48.                             msg("detected", 10)
  49.                         End If
  50.                     End If
  51.                 Next
  52.             End If
  53.  
  54.             If Exists(vehiclesToTarget) Then
  55.                 For Each v As Vehicle In vehiclesToTarget
  56.                     If Exists(v) AndAlso (v <> Player.Character.CurrentVehicle) AndAlso v.isOnScreen Then
  57.                         ' compare with vehicle center posistion
  58.                         dist = v.Position.DistanceTo(Game.CurrentCamera.Position)
  59.                         comparePosition = Game.CurrentCamera.Position + Game.CurrentCamera.Direction * dist
  60.  
  61.                         If v.Position.DistanceTo(comparePosition) < 0.5 Then
  62.                             v.ApplyForce(Vector3.WorldUp)
  63.                             Continue For
  64.                         End If
  65.  
  66.                         ' compare with vehicle front posistion
  67.                         vComparePos = v.GetOffsetPosition(Vector3.RelativeFront * v.Model.GetDimensions.Y * 0.5)
  68.                         dist = vComparePos.DistanceTo(Game.CurrentCamera.Position)
  69.                         comparePosition = Game.CurrentCamera.Position + Game.CurrentCamera.Direction * dist
  70.  
  71.                         If vComparePos.DistanceTo(comparePosition) < 0.5 Then
  72.                             v.ApplyForce(Vector3.WorldUp)
  73.                             Continue For
  74.                         End If
  75.  
  76.                         ' compare with vehicle back posistion
  77.                         vComparePos = v.GetOffsetPosition(Vector3.RelativeBack * v.Model.GetDimensions.Y * 0.5)
  78.                         dist = vComparePos.DistanceTo(Game.CurrentCamera.Position)
  79.                         comparePosition = Game.CurrentCamera.Position + Game.CurrentCamera.Direction * dist
  80.  
  81.                         If vComparePos.DistanceTo(comparePosition) < 0.5 Then
  82.                             v.ApplyForce(Vector3.WorldUp)
  83.                             Continue For
  84.                         End If
  85.  
  86.                         ' compare with vehicle left posistion
  87.                         vComparePos = v.GetOffsetPosition(Vector3.RelativeLeft * v.Model.GetDimensions.X * 0.5)
  88.                         dist = vComparePos.DistanceTo(Game.CurrentCamera.Position)
  89.                         comparePosition = Game.CurrentCamera.Position + Game.CurrentCamera.Direction * dist
  90.  
  91.                         If vComparePos.DistanceTo(comparePosition) < 0.5 Then
  92.                             v.ApplyForce(Vector3.WorldUp)
  93.                             Continue For
  94.                         End If
  95.  
  96.                         ' compare with vehicle right posistion
  97.                         vComparePos = v.GetOffsetPosition(Vector3.RelativeRight * v.Model.GetDimensions.X * 0.5)
  98.                         dist = vComparePos.DistanceTo(Game.CurrentCamera.Position)
  99.                         comparePosition = Game.CurrentCamera.Position + Game.CurrentCamera.Direction * dist
  100.  
  101.                         If vComparePos.DistanceTo(comparePosition) < 0.5 Then
  102.                             v.ApplyForce(Vector3.WorldUp)
  103.                             Continue For
  104.                         End If
  105.  
  106.                         ' compare with vehicle top posistion
  107.                         vComparePos = v.GetOffsetPosition(Vector3.RelativeTop * v.Model.GetDimensions.Z * 0.5)
  108.                         dist = vComparePos.DistanceTo(Game.CurrentCamera.Position)
  109.                         comparePosition = Game.CurrentCamera.Position + Game.CurrentCamera.Direction * dist
  110.  
  111.                         If vComparePos.DistanceTo(comparePosition) < 0.5 Then
  112.                             v.ApplyForce(Vector3.WorldUp)
  113.                             Continue For
  114.                         End If
  115.                     End If
  116.                 Next
  117.             End If
  118.  
  119.             If Exists(objectsToTarget) Then
  120.                 For Each o As GTA.Object In objectsToTarget
  121.                     If Exists(o) Then
  122.                         dist = o.Position.DistanceTo(Game.CurrentCamera.Position)
  123.                         comparePosition = Game.CurrentCamera.Position + Game.CurrentCamera.Direction * dist
  124.  
  125.                         If o.Position.DistanceTo(comparePosition) < 0.5 Then
  126.                             o.Detach()
  127.                             o.ApplyForce(Vector3.WorldUp)
  128.                         End If
  129.                     End If
  130.                 Next
  131.             End If
  132.         End If
  133.     End Sub
  134.  
  135.     Private Sub console_CMD(ByVal sender As Object, ByVal e As ConsoleEventArgs) Handles MyBase.ConsoleCommand
  136.     End Sub
  137.  
  138.     Private Sub GraphicsEventHandler(ByVal sender As Object, ByVal e As GTA.GraphicsEventArgs) Handles MyBase.PerFrameDrawing
  139.     End Sub
  140.  
  141.     Private Sub msg(ByVal sMsg As String, ByVal time As Int32)
  142.         Native.Function.Call("PRINT_STRING_WITH_LITERAL_STRING_NOW", "STRING", sMsg, time, 1)
  143.     End Sub
  144. End Class
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top