Hi, i am creating a bot and i get stucked in one point of developing a bot.
Its my main loop function where i need to display some stuff on listview but i have problem because all is in while loop so it repeating few times always.
So what i need ?
I need to bot doing next in main loop:
- send tab to select mob ( add "searching mob" to list 1 time untill mob is found )
- if mob is selected and mob hp is greater than 0 send 3 to attack ( add "attacking mob" to list 1 time only untill attacking mob )
- when mob is dead add count +1 ( add "mob killed +1" to list 1 time when mob is dead )
repeat
At the moment it repeat and counting too many mobs, like i killed 2 he count 5 and work like :
searching mob
attacking mob
attacking mob
attacking mob
attacking mob
attacking mob
attacking mob
attacking mob
mobs killed 1
Its my main loop function where i need to display some stuff on listview but i have problem because all is in while loop so it repeating few times always.
So what i need ?
I need to bot doing next in main loop:
- send tab to select mob ( add "searching mob" to list 1 time untill mob is found )
- if mob is selected and mob hp is greater than 0 send 3 to attack ( add "attacking mob" to list 1 time only untill attacking mob )
- when mob is dead add count +1 ( add "mob killed +1" to list 1 time when mob is dead )
repeat
At the moment it repeat and counting too many mobs, like i killed 2 he count 5 and work like :
searching mob
attacking mob
attacking mob
attacking mob
attacking mob
attacking mob
attacking mob
attacking mob
mobs killed 1
Code:
Func _start()
$run = Not $run
If $run = True Then
GUICtrlSetData($bot_status, "Bot running")
_GUICtrlListBox_InsertString($List1, _NowTime() & " : Bot started", 0)
Else
GUICtrlSetData($bot_status, "Bot paused")
_GUICtrlListBox_InsertString($List1, _NowTime() & " : Bot paused", 0)
EndIf
While $run = True
; get mob hp
$handles = _KDMemory_OpenProcess($processId)
$baseAddress = _KDMemory_GetModuleBaseAddress($handles, $moduleName) + $baseOffset
$memoryData = _KDMemory_ReadProcessMemory($handles, $baseAddress, "DWORD", $enemyHpOffset)
Local $pickPause = 300
#cs
send tab to select mob ( add "searching mob" to list 1 time untill mob is found )
if mob is selected and mob hp is greater than 0 send 3 to attack ( add "attacking mob" to list 1 time only untill attacking mob )
when mob is dead add count +1 ( add "mob killed +1" to list 1 time when mob is dead )
repeat ( repeat process )
#ce
; if mob hp is grater than zero send 3 to attack it
If $memoryData[1] > 0 Then
_GUICtrlListBox_InsertString($List1, _NowTime() & " : Attacking mob", 0)
ControlSend($title, "", "", "{3}")
Sleep(500)
Else
; send space after killing mob to pick items
_GUICtrlListBox_InsertString($List1, _NowTime() & " : Picking items", 0)
ControlSend($title, "", "", "{SPACE}")
Sleep($pickPause)
ControlSend($title, "", "", "{SPACE}")
Sleep($pickPause)
ControlSend($title, "", "", "{SPACE}")
Sleep($pickPause)
ControlSend($title, "", "", "{SPACE}")
Sleep($pickPause)
ControlSend($title, "", "", "{SPACE}")
Sleep($pickPause)
ControlSend($title, "", "", "{SPACE}")
Sleep($pickPause)
; send tab to select mob
_GUICtrlListBox_InsertString($List1, _NowTime() & " : Searching mob", 0)
ControlSend($title, "", "", "{TAB}")
; add +1 to mobs killied
$mobsKilled += 1
GUICtrlSetData($killedMobs, $mobsKilled)
_GUICtrlListBox_InsertString($List1, _NowTime() & " : Mobs killed - " & $mobsKilled, 0)
EndIf
; mob hp display
GUICtrlSetData($enemyHp, $memoryData[1])
_KDMemory_CloseHandles($handles)
WEnd
EndFunc