Advertisement
julioCCs

IronmanV Laser Beam idea

Feb 16th, 2016
592
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 13.96 KB | None | 0 0
  1. Public Sub laserBeam(targetPos As Vector3)
  2.             Dim pos As Vector3
  3.  
  4.             If laserBeamType = 0 Then
  5.                 If THelper.Exists(armor.repulsorObject) Then
  6.                     pos = armor.repulsorObject.Position
  7.                 Else
  8.                     If laserBeamTwoHanded Then
  9.                         pos = Native.Function.Call(Of Vector3)(Native.Hash.GET_PED_BONE_COORDS, user, Bone.SKEL_R_Hand, 0.1 + armor.hand_R_Offset.X, 0.1 + armor.hand_R_Offset.Y, -0.1 + armor.hand_R_Offset.Z)
  10.                     Else
  11.                         pos = Native.Function.Call(Of Vector3)(Native.Hash.GET_PED_BONE_COORDS, user, Bone.SKEL_R_Hand, 0.1 + armor.hand_R_Offset.X, 0.02 + armor.hand_R_Offset.Y, -0.1 + armor.hand_R_Offset.Z)
  12.                     End If
  13.                 End If
  14.             Else
  15.                 If firstPerson AndAlso bFlying Then
  16.                     pos = Native.Function.Call(Of Vector3)(Native.Hash.GET_PED_BONE_COORDS, user, Bone.SKEL_Spine2, -0.15, 0, 0)
  17.                 Else
  18.                     pos = Native.Function.Call(Of Vector3)(Native.Hash.GET_PED_BONE_COORDS, user, Bone.SKEL_Spine2, 0.05, 0, 0)
  19.                 End If
  20.             End If
  21.  
  22.             Dim pos2 As Vector3 = targetPos
  23.             Dim sizeCoef As Double = 0.17
  24.             Dim sizeCoefChange As Double = 0.00015
  25.             Dim tmpPos As Vector3 = pos
  26.             Dim tmpCamDir As Vector3 = Vector3.Normalize(pos2 - pos) ' THelper.RotationToDirection(GameplayCamera.Rotation)
  27.  
  28.             If laserBeamType = 1 Then
  29.                 tmpPos += tmpCamDir * Math.Max(0.2, Math.Min(1, speed.Length))
  30.             End If
  31.  
  32.             If laserBeamType = 0 Then
  33.                 sizeCoef = 0.1
  34.                 sizeCoefChange = 0.0001
  35.             End If
  36.  
  37.             If bLaserBeamTriggerExtraFX Then
  38.                 bLaserBeamTriggerExtraFX = False
  39.  
  40.                 'If (speed.Length < 5) Then
  41.                 If laserBeamType = 1 Then
  42.                     THelper.ptfx_triggerOnPedBone(user, Bone.SKEL_Spine3, "scr_trev1_trailer_boosh", "scr_trevor1", New Vector3(0.25, 0.3, 0), New Vector3(190, 0, 0), 0.55)
  43.                 ElseIf laserBeamType = 0 Then
  44.                     THelper.ptfx_triggerOnPedBone(user, Bone.SKEL_R_Hand, "scr_trev1_trailer_boosh", "scr_trevor1", New Vector3(0.2, 0, 0), New Vector3(95, 0, 0), 0.35)
  45.                 End If
  46.                 'End If
  47.             End If
  48.  
  49.             Dim tmpTargetEnt As Entity = Nothing
  50.             Dim tmpTargetVec As Vector3
  51.  
  52.             If timeCounter Mod 100 = 0 Then
  53.                 For Each e As Entity In closerTargets
  54.                     Try
  55.                         If THelper.Exists(e) Then
  56.                             Native.Function.Call(Native.Hash.SET_ENTITY_CAN_BE_DAMAGED, e, True)
  57.  
  58.                             If (Native.Function.Call(Of Boolean)(Native.Hash.HAS_ENTITY_BEEN_DAMAGED_BY_ENTITY, e, user)) Then
  59.                                 Native.Function.Call(Native.Hash.CLEAR_ENTITY_LAST_DAMAGE_ENTITY, e)
  60.  
  61.                                 If (Native.Function.Call(Of Boolean)(Native.Hash.IS_ENTITY_VISIBLE, e)) Then
  62.                                     'If e.Model.IsVehicle AndAlso (e <> user.CurrentVehicle) Then
  63.                                     tmpTargetEnt = e
  64.  
  65.                                     If Not THelper.victimExists(victims, e) Then
  66.                                         Dim tmpV As THelper.TVictim = New THelper.TVictim(e)
  67.  
  68.                                         If THelper.isPed(e) Then
  69.                                             THelper.setPedToRagdoll(e, 2000, 2000)
  70.  
  71.                                             THelper.damagePed(e, 25 * laserBeamSizeCoef, 1)
  72.                                         End If
  73.  
  74.                                         tmpV.flightDir = tmpCamDir
  75.                                         tmpV.bPlayVehCrashSound = False
  76.                                         tmpV.desiredSpeed = laserBeamSizeCoef * 4
  77.  
  78.                                         victims.Add(tmpV)
  79.                                     End If
  80.  
  81.                                     Exit For
  82.                                     'End If
  83.                                 End If
  84.                             End If
  85.                         End If
  86.                     Catch
  87.                     End Try
  88.                 Next
  89.  
  90.                 If Not THelper.Exists(tmpTargetEnt) Then
  91.                     Dim tmpEntToIgnore As Entity = user
  92.  
  93.                     If bFlying Then
  94.                         tmpEntToIgnore = flightEntity
  95.                     End If
  96.  
  97.                     tmpTargetEnt = THelper.getTargetedDistEntity(pos + tmpCamDir, pos2, 200, tmpEntToIgnore, 0.25)
  98.                 End If
  99.  
  100.                 If THelper.Exists(tmpTargetEnt) Then
  101.                     If Not THelper.victimExists(victims, tmpTargetEnt) Then
  102.                         Dim tmpV As THelper.TVictim = New THelper.TVictim(tmpTargetEnt)
  103.  
  104.                         If THelper.isPed(tmpTargetEnt) Then
  105.                             THelper.setPedToRagdoll(tmpTargetEnt, 2000, 2000)
  106.  
  107.                             THelper.damagePed(tmpTargetEnt, 25 * laserBeamSizeCoef, 1)
  108.                         End If
  109.  
  110.                         tmpV.flightDir = tmpCamDir
  111.                         tmpV.bPlayVehCrashSound = False
  112.                         tmpV.desiredSpeed = laserBeamSizeCoef * 4
  113.  
  114.                         victims.Add(tmpV)
  115.                     End If
  116.                 End If
  117.             End If
  118.  
  119.             Dim tmpShotPos As Vector3 = pos + tmpCamDir
  120.             Dim tmpShotPosEnd As Vector3 = pos + tmpCamDir * 50
  121.  
  122.             If timeCounter Mod 50 = 0 Then
  123.                 Native.Function.Call(Native.Hash.SHOOT_SINGLE_BULLET_BETWEEN_COORDS, tmpShotPos.X, tmpShotPos.Y, tmpShotPos.Z, tmpShotPosEnd.X, tmpShotPosEnd.Y, tmpShotPosEnd.Z, _
  124.                     1, 1, fakeShootHash, user, 1, 1, 100.0)
  125.             End If
  126.  
  127.             'If timeCounter Mod 150 = 0 Then
  128.             'Native.Function.Call(Native.Hash.SHOOT_SINGLE_BULLET_BETWEEN_COORDS, tmpShotPos.X, tmpShotPos.Y, tmpShotPos.Z, tmpShotPosEnd.X, tmpShotPosEnd.Y, tmpShotPosEnd.Z, _
  129.             '1, 1, fakeShootHash, user, 1, 1, 100.0)
  130.             'End If
  131.  
  132.             If THelper.Exists(tmpTargetEnt) Then
  133.                 tmpTargetVec = tmpTargetEnt.Position
  134.  
  135.                 If Not THelper.isVehicle(tmpTargetEnt) Then
  136.                     tmpTargetEnt.ApplyForce(tmpCamDir * THelper.getFPSCoef, Vector3.WorldNorth + Vector3.WorldEast)
  137.                 Else
  138.                     Try
  139.                         Dim tmpVeh As Vehicle = DirectCast(tmpTargetEnt, Vehicle)
  140.  
  141.                         Native.Function.Call(Native.Hash.SET_VEHICLE_DOOR_LATCHED, tmpVeh, VehicleDoor.BackLeftDoor)
  142.                         Native.Function.Call(Native.Hash.SET_VEHICLE_DOOR_LATCHED, tmpVeh, VehicleDoor.BackRightDoor)
  143.                         Native.Function.Call(Native.Hash.SET_VEHICLE_DOOR_LATCHED, tmpVeh, VehicleDoor.FrontLeftDoor)
  144.                         Native.Function.Call(Native.Hash.SET_VEHICLE_DOOR_LATCHED, tmpVeh, VehicleDoor.FrontRightDoor)
  145.                         Native.Function.Call(Native.Hash.SET_VEHICLE_DOOR_LATCHED, tmpVeh, VehicleDoor.Hood)
  146.                         Native.Function.Call(Native.Hash.SET_VEHICLE_DOOR_LATCHED, tmpVeh, VehicleDoor.Trunk)
  147.                         Native.Function.Call(Native.Hash.SET_VEHICLE_DOOR_LATCHED, tmpVeh, VehicleDoor.Trunk2)
  148.                         tmpVeh.SmashWindow(VehicleWindow.BackLeftWindow)
  149.                         tmpVeh.SmashWindow(VehicleWindow.BackRightWindow)
  150.                         tmpVeh.SmashWindow(VehicleWindow.FrontLeftWindow)
  151.                         tmpVeh.SmashWindow(VehicleWindow.FrontRightWindow)
  152.                     Catch
  153.                     End Try
  154.                 End If
  155.  
  156.                 If (laserBeamType = 1) Then
  157.                     THelper.ptfx_triggerOnCoord(tmpTargetVec, "scr_agency3b_linger_smoke", "scr_agencyheistb")
  158.  
  159.                     If Not tmpTargetEnt.IsOnFire Then _
  160.                         Native.Function.Call(Native.Hash.START_ENTITY_FIRE, tmpTargetEnt)
  161.                 End If
  162.  
  163.                 THelper.ptfx_triggerOnCoord(tmpTargetVec, "scr_fam1_blood_headshot", "scr_family1")
  164.             Else
  165.                 tmpTargetVec = THelper.getTargetedCoord(pos + tmpCamDir, pos2)
  166.             End If
  167.  
  168.             Dim tmpExpCoef As Double = 1
  169.             Dim tmpLightCoef As Double = 1
  170.  
  171.             If laserBeamType = 1 Then
  172.                 tmpExpCoef = 1.5
  173.                 tmpLightCoef = 1.3
  174.             End If
  175.  
  176.             tmpLightCoef *= laserBeamSizeCoef
  177.  
  178.             Dim tmpColor As Color = Color.FromArgb(10 + (5 * TRandom.NextDouble), 255, 25 + (50 * TRandom.NextDouble), 25 + (25 * TRandom.NextDouble)) 'Color.FromArgb(20, 255, 100, 75)
  179.  
  180.             If laserBeamType = 1 Then
  181.                 tmpColor = Color.FromArgb(10 + (5 * TRandom.NextDouble), 125 + (25 * TRandom.NextDouble), 200 + (25 * TRandom.NextDouble), 255) 'Color.FromArgb(20, 75, 200, 255)
  182.             End If
  183.  
  184.             If tmpTargetVec <> Vector3.Zero Then
  185.                 If (laserBeamType = 1) OrElse (laserBeamSizeCoef > 1.5) OrElse THelper.Exists(tmpTargetEnt) AndAlso (THelper.isObject(tmpTargetEnt)) Then
  186.                     If Now.Subtract(timerSinceLastAddedExplosion).TotalMilliseconds > 100 * THelper.getTimeCoef Then
  187.                         timerSinceLastAddedExplosion = Now
  188.  
  189.                         If THelper.Exists(tmpTargetEnt) Then
  190.                             Native.Function.Call(Native.Hash.ADD_OWNED_EXPLOSION, user, tmpTargetVec.X, tmpTargetVec.Y, tmpTargetVec.Z + 0.1, ExplosionType.Bike, 0.1 * tmpExpCoef, 0, 1, 0)
  191.                         Else
  192.                             Native.Function.Call(Native.Hash.ADD_OWNED_EXPLOSION, user, tmpTargetVec.X, tmpTargetVec.Y, tmpTargetVec.Z + 0.1, ExplosionType.Bike, 0.1 * tmpExpCoef, 0, 1, 0)
  193.                         End If
  194.  
  195.                         timerIgnoreExplosions = Now
  196.                     End If
  197.                 End If
  198.  
  199.                 Dim tmpDecalSize1 As Double = 0.5
  200.                 Dim tmpDecalSize2 As Double = 0.6
  201.  
  202.                 If laserBeamType = 1 Then
  203.                     tmpDecalSize1 += 0.2
  204.                     tmpDecalSize1 += 0.2
  205.                 End If
  206.  
  207.                 If timeCounter Mod 50 = 0 Then
  208.                     THelper.addDecal(tmpTargetVec, THelper.TDecalTypes.burn2, tmpDecalSize1 + 0.2 * TRandom.NextDouble, tmpDecalSize1 + 0.2 * TRandom.NextDouble, 20, 0.5)
  209.                     THelper.addDecal(tmpTargetVec, THelper.TDecalTypes.bang_concrete_bang, tmpDecalSize2 + 0.2 * TRandom.NextDouble, tmpDecalSize2 + 0.2 * TRandom.NextDouble, 20, 0.5, 0, 0, 0)
  210.                 End If
  211.  
  212.                 Dim tmpLightPos As Vector3 = tmpTargetVec - tmpCamDir * 0.25
  213.  
  214.                 If THelper.Exists(tmpTargetEnt) Then
  215.                     Native.Function.Call(Native.Hash.DRAW_LIGHT_WITH_RANGE, tmpLightPos.X, tmpLightPos.Y, tmpLightPos.Z, tmpColor.R, tmpColor.G, tmpColor.B, 0.35 * tmpLightCoef, 500.0 * tmpLightCoef)
  216.                     Native.Function.Call(Native.Hash.DRAW_LIGHT_WITH_RANGE, tmpLightPos.X, tmpLightPos.Y, tmpLightPos.Z, tmpColor.R, tmpColor.G, tmpColor.B, 1.0 * tmpLightCoef, 100.0 * tmpLightCoef)
  217.                 Else
  218.                     Native.Function.Call(Native.Hash.DRAW_LIGHT_WITH_RANGE, tmpLightPos.X, tmpLightPos.Y, tmpLightPos.Z, tmpColor.R, tmpColor.G, tmpColor.B, 0.35 * tmpLightCoef, 10.0 * tmpLightCoef)
  219.                     Native.Function.Call(Native.Hash.DRAW_LIGHT_WITH_RANGE, tmpLightPos.X, tmpLightPos.Y, tmpLightPos.Z, tmpColor.R, tmpColor.G, tmpColor.B, 1.0 * tmpLightCoef, 1.0 * tmpLightCoef)
  220.                 End If
  221.             End If
  222.  
  223.             Dim tmpStepSize As Double = 0.01
  224.             Dim tmpAlphaCoef As Double = 0.5
  225.             Dim tmpStepInc As Double = 0.01
  226.  
  227.             If firstPerson Then
  228.                 tmpStepSize = 0.005
  229.                 tmpStepInc = 0.005
  230.             End If
  231.  
  232.             Dim tmpDetailed As Boolean = bPlayer AndAlso getbLookingBehind(Me)
  233.  
  234.             If tmpDetailed Then
  235.                 tmpStepSize = 0.0035
  236.                 tmpStepInc = 0.0035
  237.  
  238.                 If laserBeamType = 1 Then
  239.                     tmpPos -= tmpCamDir * Math.Max(0.1, Math.Min(0.9, speed.Length))
  240.                     sizeCoef *= 0.8
  241.                 End If
  242.             End If
  243.  
  244.             For c As Integer = 0 To 100
  245.                 Dim tmpSizeCoef As Double = (sizeCoef + (0.03 * TRandom.NextDouble)) * laserBeamSizeCoef
  246.                 Dim tmpSizeCoefW As Double = (sizeCoef * 0.5 + (0.03 * TRandom.NextDouble)) * laserBeamSizeCoef
  247.                 Dim tmpAlphaF As Integer = (Math.Min(255, tmpColor.A + 50) * tmpAlphaCoef)
  248.                 Dim tmpAlphaW As Integer = (200 * tmpAlphaCoef)
  249.  
  250.                 If tmpDetailed OrElse (c Mod 3 = 0) Then
  251.                     Native.Function.Call(Native.Hash.DRAW_MARKER, MarkerType.DebugSphere, tmpPos.X, tmpPos.Y, tmpPos.Z, 0, 0, 0, 0, 0, 0, tmpSizeCoef, tmpSizeCoef, tmpSizeCoef, _
  252.                         tmpColor.R, tmpColor.G, tmpColor.B, tmpAlphaF, 0, 0, 2, 0, 0, 0, 0)
  253.                 End If
  254.  
  255.                 Native.Function.Call(Native.Hash.DRAW_MARKER, MarkerType.DebugSphere, tmpPos.X, tmpPos.Y, tmpPos.Z, 0, 0, 0, 0, 0, 0, tmpSizeCoefW, tmpSizeCoefW, tmpSizeCoefW, _
  256.                         255, 255, 255, tmpAlphaW, 0, 0, 2, 0, 0, 0, 0)
  257.  
  258.                 If (c > 1) AndAlso (c Mod 5 = 0) Then
  259.                     Native.Function.Call(Native.Hash.DRAW_LIGHT_WITH_RANGE, tmpPos.X, tmpPos.Y, tmpPos.Z, tmpColor.R, tmpColor.G, tmpColor.B, 1.0 * tmpLightCoef, 10.0 * tmpLightCoef)
  260.                     Native.Function.Call(Native.Hash.DRAW_LIGHT_WITH_RANGE, tmpPos.X, tmpPos.Y, tmpPos.Z, tmpColor.R, tmpColor.G, tmpColor.B, 2.5 * tmpLightCoef, 2.0 * tmpLightCoef)
  261.  
  262.                     If tmpAlphaCoef > 0.01 Then
  263.                         tmpAlphaCoef -= 0.01
  264.                     End If
  265.                 End If
  266.  
  267.                 sizeCoef -= sizeCoefChange
  268.  
  269.                 tmpPos += tmpCamDir * tmpStepSize
  270.  
  271.                 incMoveEase(tmpStepSize, tmpStepInc, 0.3)
  272.             Next
  273.         End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement