Advertisement
julioCCs

melee attack sample

Nov 18th, 2013
408
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 10.42 KB | None | 0 0
  1. Private animSetCombat As AnimationSet = New AnimationSet("melee_ped_unarmed")
  2.     Private animSetCombat2 As AnimationSet = New AnimationSet("melee_gang_unarmed")
  3.     Private animSetCombatRun As AnimationSet = New AnimationSet("move_player")
  4.     Private animSetCombatNormal As AnimationSet = New AnimationSet("melee_unarmed_base")
  5.     Private sAnimCombat As String = "hook_r_long"
  6.     Private sAnimCombat2 As String = "low_kick_nuts"
  7.  
  8. Private Sub meleeAttackTick()
  9.         If bPlayerNotInCombat AndAlso (Player.Character.Weapons.Current = Weapon.Unarmed) AndAlso Player.Character.isInMeleeCombat Then
  10.             If Player.Character.Animation.isPlaying(animSetCombatNormal, "partial_punch_r") OrElse Player.Character.Animation.isPlaying(animSetCombatNormal, "jab") Then
  11.                 Dim tmpPeds As Ped() = World.GetPeds(Player.Character.Position + Player.Character.Direction * 2, 4)
  12.                 Dim tmpTargetPos As Vector3 = Player.Character.Position + Player.Character.Direction * 4
  13.                 Dim tmpMinDist As Double = 1000
  14.                 Dim tmpTarget As Ped = Nothing
  15.                 Dim bTargetOnGround As Boolean = False
  16.  
  17.                 For Each p As Ped In tmpPeds
  18.                     If Exists(p) AndAlso (p <> Player.Character) AndAlso Not Exists(p.CurrentVehicle) AndAlso (p.Health > 0) Then
  19.                         If p.Position.DistanceTo(tmpTargetPos) < tmpMinDist Then
  20.                             tmpMinDist = p.Position.DistanceTo(tmpTargetPos)
  21.                             tmpTarget = p
  22.                         End If
  23.                     End If
  24.                 Next
  25.  
  26.                 If Exists(tmpTarget) Then
  27.                     tmpTargetPos = tmpTarget.Position
  28.                     Player.Character.Heading = Helper.DirectionToHeading(Vector3.Normalize(tmpTarget.Position - Player.Character.Position))
  29.                     tmpTarget.Velocity *= 0.3
  30.                     bTargetOnGround = (tmpTarget.isRagdoll OrElse tmpTarget.isGettingUp)
  31.                 End If
  32.  
  33.                 Dim tmpTimeOut As Date = Now
  34.  
  35.                 While (Player.Character.Position.DistanceTo(tmpTargetPos) > 1) AndAlso Exists(tmpTarget)
  36.                     shouldDrawScreenFillers()
  37.  
  38.                     myNatives.securePlayAnim(Player.Character, animSetCombatRun, "sprint", 8, AnimationFlags.Unknown01)
  39.                     myNatives.setAnimSpeed(Player.Character, animSetCombatRun.Name, "sprint", 1.2)
  40.  
  41.                     'Player.Character.ApplyForce(tmpTargetPos - Player.Character.Position)
  42.  
  43.                     While Player.Character.Animation.isPlaying(animSetCombatRun, "sprint") AndAlso _
  44.                        (Player.Character.Animation.GetCurrentAnimationTime(animSetCombatRun, "sprint") < 0.8) AndAlso _
  45.                        Player.Character.Position.DistanceTo(tmpTargetPos) > 1
  46.                         Wait(5)
  47.  
  48.                         If Exists(tmpTarget) Then
  49.                             tmpTargetPos = tmpTarget.Position
  50.  
  51.                             If (Player.Character.Position.DistanceTo(tmpTarget.Position) > 1) OrElse Not tmpTarget.isRagdoll Then
  52.                                 If Player.Character.Position.DistanceTo(tmpTarget.Position) > 1.5 Then _
  53.                                     Player.Character.Heading = Helper.DirectionToHeading(Vector3.Normalize(tmpTarget.Position + tmpTarget.Velocity * 0.25 - Player.Character.Position))
  54.  
  55.                                 'Player.Character.ApplyForce(Vector3.Normalize(tmpTargetPos - Player.Character.Position))
  56.                             End If
  57.                         End If
  58.  
  59.                         shouldDrawScreenFillers()
  60.  
  61.                         If Player.Character.Health <= 0 Then Exit While
  62.                     End While
  63.  
  64.                     If (Player.Character.Health <= 0) OrElse Now.Subtract(tmpTimeOut).TotalMilliseconds > 2000 Then Exit While
  65.  
  66.                     shouldDrawScreenFillers()
  67.  
  68.                     Wait(5)
  69.                 End While
  70.  
  71.                 If Exists(tmpTarget) Then tmpTarget.Velocity = Vector3.Zero
  72.  
  73.                 Player.Character.Velocity = Vector3.Zero
  74.  
  75.                 If Now.Subtract(tmpTimeOut).TotalMilliseconds > 2000 Then Exit Sub
  76.  
  77.                 If Player.Character.Health > 0 Then
  78.                     If Not Exists(tmpTarget) Then tmpTargetPos = Player.Character.Position + Player.Character.Direction * 4
  79.  
  80.                     Player.Character.ApplyForce((tmpTargetPos - Player.Character.Position))
  81.  
  82.                     Dim tmpAnimSet As AnimationSet = animSetCombat
  83.                     Dim tmpAnim As String = sAnimCombat
  84.  
  85.                     If bTargetOnGround Then
  86.                         tmpAnimSet = animSetCombat2
  87.                         tmpAnim = sAnimCombat2
  88.                     End If
  89.  
  90.                     myNatives.securePlayAnim(Player.Character, tmpAnimSet, tmpAnim, 8, AnimationFlags.Unknown01)
  91.                     'myNatives.setAnimPercent(Player.Character, tmpAnimSet.Name, tmpAnim, 0.2)
  92.  
  93.                     If Not bTargetOnGround Then myNatives.setAnimSpeed(Player.Character, tmpAnimSet.Name, tmpAnim, 1.5)
  94.  
  95.                     If Exists(tmpTarget) Then
  96.                         tmpTarget.Velocity *= 0.3
  97.  
  98.                         If Not tmpTarget.isRagdoll Then tmpTarget.PreventRagdoll = True
  99.                     End If
  100.  
  101.                     Dim tmpFirstHitDone As Boolean = False
  102.  
  103.                     While Player.Character.Animation.isPlaying(tmpAnimSet, tmpAnim) AndAlso _
  104.                        (Player.Character.Animation.GetCurrentAnimationTime(tmpAnimSet, tmpAnim) < 0.5)
  105.                         Wait(5)
  106.  
  107.                         shouldDrawScreenFillers()
  108.  
  109.                         If (Player.Character.Animation.GetCurrentAnimationTime(tmpAnimSet, tmpAnim) > 0.4) Then
  110.                             myNatives.setAnimSpeed(Player.Character, tmpAnimSet.Name, tmpAnim, 1.5)
  111.                         End If
  112.  
  113.                         If Exists(tmpTarget) Then
  114.                             tmpTargetPos = tmpTarget.Position
  115.  
  116.                             If (Player.Character.Position.DistanceTo(tmpTarget.Position) > 1) OrElse Not tmpTarget.isRagdoll Then
  117.                                 If Player.Character.Position.DistanceTo(tmpTarget.Position) > 2 Then _
  118.                                     Player.Character.Heading = Helper.DirectionToHeading(Vector3.Normalize(tmpTarget.Position - Player.Character.Position))
  119.  
  120.                                 Player.Character.ApplyForce(tmpTargetPos - Player.Character.Position)
  121.                             End If
  122.                         End If
  123.  
  124.                         If (Player.Character.Animation.GetCurrentAnimationTime(tmpAnimSet, tmpAnim) > 0.3) Then
  125.                             Player.Character.Heading = Helper.DirectionToHeading(Vector3.Normalize(tmpTargetPos - Player.Character.Position))
  126.  
  127.                             If Not tmpFirstHitDone Then
  128.                                 For Each p As Ped In World.GetPeds(Player.Character.Position + Player.Character.Direction, 1.2)
  129.                                     If Exists(p) AndAlso (p <> Player.Character) AndAlso Not Exists(p.CurrentVehicle) _
  130.                                        AndAlso (p.Health > 0) Then
  131.                                         If ((tmpAnim <> sAnimCombat2) AndAlso (p.Position.DistanceTo(Player.Character.Position) <= 0.75)) OrElse
  132.                                            (tmpAnim = sAnimCombat2) Then
  133.                                             Native.Function.Call("damage_char", p, TRandom.Next(50, 110), 0)
  134.                                             waitEx(100)
  135.                                             p.PreventRagdoll = False
  136.                                             'p.ForceRagdoll(7000, False)
  137.                                             p.Euphoria.BeingShot().Start(2000)
  138.                                             p.ApplyForce(Player.Character.Direction * 3, Vector3.WorldNorth * 0.5)
  139.                                             myNatives.playSoundFromPed("anim_melee_punch_to_face", Player.Character)
  140.                                             tmpFirstHitDone = True
  141.                                             increaseAbility(0.5)
  142.  
  143.                                             For Each p2 As Ped In World.GetPeds(Player.Character.Position, 10)
  144.                                                 If Exists(p2) AndAlso (p2 <> Player.Character) AndAlso Not p2.isRequiredForMission Then
  145.                                                     If (p2.PedType <> PedType.Cop) Then
  146.                                                         If (p2.Weapons.Glock.Ammo > 0) OrElse (p2.Weapons.DesertEagle.Ammo > 0) OrElse (p2.Weapons.BasicShotgun.Ammo > 0) Then
  147.                                                             p2.Task.FightAgainst(Player.Character)
  148.                                                         Else
  149.                                                             p2.Task.FleeFromChar(Player.Character)
  150.                                                         End If
  151.                                                     Else
  152.                                                         If myNatives.getWantedLevel = 0 Then
  153.                                                             Native.Function.Call("ALTER_WANTED_LEVEL", Player, 1)
  154.                                                             Native.Function.Call("APPLY_WANTED_LEVEL_CHANGE_NOW", Player)
  155.                                                         End If
  156.                                                     End If
  157.                                                 End If
  158.                                             Next
  159.  
  160.                                             Exit For
  161.                                         End If
  162.                                     End If
  163.                                 Next
  164.                             End If
  165.                         End If
  166.  
  167.                         If Player.Character.Health <= 0 Then Exit While
  168.                     End While
  169.  
  170.                     If Exists(tmpTarget) Then
  171.                         tmpTarget.PreventRagdoll = False
  172.                     End If
  173.  
  174.                     'If tmpAnim <> sAnimCombat2 Then
  175.                         myNatives.setAnimSpeed(Player.Character, tmpAnimSet.Name, tmpAnim, 0.3)
  176.                         waitEx(200)
  177.                         myNatives.setAnimSpeed(Player.Character, tmpAnimSet.Name, tmpAnim, 1)
  178.                     'End If
  179.                 End If
  180.             End If
  181.         End If
  182.  
  183.         bPlayerNotInCombat = Not Player.Character.isInMeleeCombat
  184.     End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement