Advertisement
Guest User

Untitled

a guest
Nov 24th, 2015
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 3.38 KB | None | 0 0
  1.  Public Sub Attacker()    
  2.             If Kernel.Looter.IsLooting Then
  3.                 Exit Sub
  4.             End If
  5.         Dim NewMonster As Creature = GetNextTarget()
  6.         If NewMonster IsNot Nothing Then
  7.             Attack(NewMonster)
  8.         End If
  9.     End Sub
  10.    Private Function GetNextTarget() As Creature
  11.         Dim CreatureList As List(Of Creature) = (From j As Creature In Client.BattleList.GetCreatures Where j.DistanceTo(Client.PlayerLocation) <= 8 Order By Math.Round(j.DistanceTo(Client.PlayerLocation)) Select j).ToList
  12.         Dim Tlist As List(Of Target) = (From t As Target In [Global].TargetList Order By t.Prio Select t).ToList
  13.         Tlist.Reverse()
  14.         Dim count As Integer = 0
  15.         For Each c As Creature In CreatureList
  16.             For Each t As Target In Tlist
  17.                 If t.Name.ToLower = c.Name.ToLower Then
  18.                     If c.IsReachable Then
  19.                         TargetsAround = 1
  20.                         Return c
  21.                     End If
  22.                 End If
  23.             Next
  24.         Next
  25.         TargetsAround = 0
  26.         Return Nothing
  27.     End Function
  28.   Private Sub Attack(ByVal newMonster As Creature)
  29.         Dim target As Target = [Global].TargetList.FirstOrDefault(Function(t) t.Name.ToLower = NewMonster.Name.ToLower)
  30.         Player.Stop()
  31.         Thread.Sleep(500)
  32.         newMonster.Attack()
  33.         'wait until the monster is beeing attacked
  34.         While Player.RedSquare = 0
  35.             Thread.Sleep(10)
  36.         End While
  37.         KeepStance(NewMonster, target)
  38.     End Sub
  39.  
  40.  Private Sub KeepStance(ByVal creature As Creature, ByVal target As Target)
  41.  
  42.         While Player.RedSquare > 0
  43.             Dim newMonster = GetNextTarget()
  44.             If newMonster IsNot Nothing Then
  45.                 If newMonster.Id <> creature.Id Then
  46.                     If isNewTargetBetter(creature, newMonster) Then
  47.                         Attack(newMonster)
  48.                         Exit Sub
  49.                     End If
  50.                 End If
  51.             End If
  52.             Select Case target.FollowType
  53.                 Case Settnings.FollowMode.Reach
  54.                     ReachStance(creature, target)
  55.                 Case Settnings.FollowMode.Distance
  56.                     DistanceStance(creature, target)
  57.                 Case Settnings.FollowMode.ReachFace
  58.                     ReachFace(creature, target)
  59.                 Case Settnings.FollowMode.Stand
  60.                     'NOTHING
  61.             End Select
  62.         End While
  63.         'creature died
  64.         If Kernel.Looter.LootWhenALlDead = False Then
  65.             WaitForLoot = Date.Now.AddSeconds(3)
  66.         End If
  67.     End Sub
  68.  Private Function isNewTargetBetter(ByVal currentTarget As Creature, ByVal newtarget As Creature) As Boolean
  69.         Try
  70.             If (currentTarget.Target.Prio - newtarget.Target.Prio) * 2 > StickToTarget_Prio Then
  71.                 Return True
  72.             End If
  73.             Dim oldDist As Integer = Math.Round(currentTarget.Location.DistanceTo(Client.PlayerLocation))
  74.             Dim newDist As Integer = Math.Round(newtarget.Location.DistanceTo(Client.PlayerLocation))
  75.             Dim diff As Integer = Math.Round(oldDist - newDist)
  76.             If diff * 2 > StickToTarget_Prio Then
  77.                 Return True
  78.             End If
  79.             Return False
  80.         Catch ex As Exception
  81.             Return False
  82.         End Try
  83.     End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement