code snippet
Code:
Public Sub BotOn()
If OBJMGR.IsAttached = False Then
DoOutput("Can't start yet. Attach first!")
Exit Sub
End If
Dim _lastActionTime As Date = Date.Now
_isBotOn = True
Form1.cmdStartStop.Text = "Stop"
GOOEY.FocusWoW()
Do Until _isBotOn = False
''#0 Are we alive?
If OBJMGR.LocalPlayer.Health = 0 Then
DoOutput("LocalPlayer died. Shutting down")
BotOff()
Exit Do
End If
''#1 Are we in combat?
'is anything targeting us?
Dim _attackersCount As Int32 = OBJMGR.GetTargetCount(OBJMGR.LocalPlayer)
If _attackersCount > 0 Then
Do Until OBJMGR.LocalPlayer.TargetGuid > 0
DoOutput("something is targeting us")
DoOutput("waiting for auto-target...")
Threading.Thread.Sleep(rndm.Next(750, 1250))
Application.DoEvents()
Loop
''kill the target
COMBAT.KillCurrentTarget()
Continue Do 'jump back up to priority 0
End If
''#2 Do we need to heal?
If OBJMGR.LocalPlayer.HealthAsPercent <= 50 Then
DoOutput("Need to heal! //todo: add code here")
Dim _cancelEarly As Boolean = False
Do Until OBJMGR.LocalPlayer.HealthAsPercent > 95
DoOutput("--loop until health > 95% -- ")
If OBJMGR.GetTargetCount(OBJMGR.LocalPlayer) > 0 Then
DoOutput("ambush while healing. do self defense!")
Continue Do 'jump back to priority 0
End If
If _isBotOn = False Then
_cancelEarly = True 'user press 'stop button' during heal
Exit Do
End If
Application.DoEvents()
Threading.Thread.Sleep(rndm.Next(1280, 1790))
Loop
If _cancelEarly Then
Exit Do 'ie. don't show 'health normal' message. could use label right after outer loop + goto ...
End If
DoOutput("Health Normal. Continue.")
End If
''#3 Any mobs to kill, in range?
If OBJMGR.GetTargetCountInArea(OBJMGR.LocalPlayer.WorldPos, COMBAT.MaxAttackRange) > 0 Then
DoOutput("Target Available!")
If COMBAT.TargetClosestMob Then
COMBAT.KillCurrentTarget()
End If
End If
''#4 don't go afk
''todo
''If timeSpan > userSetting then
''Jump or something
Application.DoEvents()
Loop
DoOutput("Bot OFF")
End Sub
*just looking over the post, huge bug (never actually tested the 'heal' section)
it should be this
Code:
''#2 Do we need to heal?
If OBJMGR.LocalPlayer.HealthAsPercent <= 50 Then
DoOutput("Need to heal! //todo: add code here")
Do Until OBJMGR.LocalPlayer.HealthAsPercent > 95
DoOutput("--loop until health > 95% -- ")
If OBJMGR.GetTargetCount(OBJMGR.LocalPlayer) > 0 Then
DoOutput("ambush while healing. do self defense!")
Exit Do
End If
If _isBotOn = False Then Exit Do 'user requested bot to stop
Application.DoEvents()
Threading.Thread.Sleep(rndm.Next(1280, 1790))
Loop
DoOutput("Health Normal. Continue.")
End If
Not going to re-upload file. Edit yourself if it causes you to die.