Quote:
Originally Posted by mhaendler
Code:
#cs
#################################
# #
# Equip Stuff #
# #
# by mhaendler #
# #
#################################
#ce
#RequireAdmin
#NoTrayIcon
#include "GWA2.au3"
#include <ButtonConstants.au3>
#include <Array.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
HotKeySet("{End}", "_Exit")
HotKeySet("{PAUSE}", "ActiveSwitchToHpArmor") ; Bind the Pause / Start Bot Function to the Pause Key
Func _Exit() ; you stop / exit function;
Exit
EndFunc
Opt("GUIOnEventMode", True)
Opt("GUICloseOnESC", False)
Opt("MustDeclareVars", True)
; ==== Bot global variables ====
Global $bBotRunning = False
Global $bBotInitialized = False
Global $equipHpArmor = false
; ==== GUI ====
Global Const $mainGui = GUICreate("Armor Switch", 149, 70)
GUISetOnEvent($GUI_EVENT_CLOSE, "_exit")
Global $Input
$Input = GUICtrlCreateCombo("", 8, 8, 129, 21)
GUICtrlSetData(-1, GetLoggedCharNames())
Global Const $Button = GUICtrlCreateButton("Start", 8, 40, 131, 25)
GUICtrlSetOnEvent(-1, "GuiButtonHandler")
GUISetState(@SW_SHOW)
;~ Description: Handles the button presses
Func GuiButtonHandler()
If $bBotRunning Then
GUICtrlSetData($Button, "Will pause after this run")
GUICtrlSetState($Button, $GUI_DISABLE)
$bBotRunning = False
ElseIf $bBotInitialized Then
GUICtrlSetData($Button, "Pause")
$bBotRunning = True
Else
Local $CharName = GUICtrlRead($Input)
If $CharName == "" Then
If Initialize(ProcessExists("gw.exe")) = False Then
MsgBox(0, "Error", "Guild Wars is not running.")
Exit
EndIf
Else
If Initialize($CharName) = False Then
MsgBox(0, "Error", "Could not find a Guild Wars client with a character named '" & $CharName & "'")
Exit
EndIf
EndIf
GUICtrlSetState($Input, $GUI_DISABLE)
GUICtrlSetData($Button, "Pause")
$bBotRunning = True
$bBotInitialized = True
EndIf
EndFunc ;==>GuiButtonHandler
While Not $bBotRunning
Sleep(100)
WEnd
While True
if($equipHpArmor) Then
SwitchToHpArmor()
$equipHpArmor = false
EndIf
Sleep(100) ; Little sleep to reduce CPU usage
WEnd
Func SwitchToHpArmor()
;Here edit your stuff to get the headpiece and switch it
;its probably a bad idea to go for hardcoded slots but thats your turn now
EquipItem(GetItemBySlot(4, 1))
Sleep(400)
$equipArmor = false
EndFunc
Func ActiveSwitchToHpArmor()
$equipHpArmor = not $equipHpArmor
EndFunc ;==>ChestLoop
Here a basic script to do that. It binds the {PAUSE}-Button and Switches the Armor / Weapon / Headpice on Bag 4 Slot 1. Thats hardcoded and not the best way to do it. You probably want to load it via the model id and then equip it, but thats your turn. get into coding. develop stuff and share it ;)
I did not test it, but i dont see a point why it should not work
_
mhaendler
|
hi thanks for this, could you help me out by explaining a piece of code that i dont understand how it works.
i see the pause key binds to the func ActiveSwitchToHpArmor
however the func that actually does the stuff i need is called SwitchToHpArmor
so how does this Func ActiveSwitchToHpArmor()
$equipHpArmor = not $equipHpArmor
call the other func without naming it?
hope what i am trying to explain can be understood thanks
also a second question if you dont mind..
my bots often DC ive tried everything to fix the DC issue to no avail so im trying to make the bot relog.
how can you make the bot relog after a crash?
i have found the code below: however if i put that function in my code, how do i make sure that function is called, does the auto it language automatically call everything in order of the file?
also this code only seems to press the button to reconnect, what if a relog is needed?
Id really like to get into coding these but getting to grips with the first bit of understanding is going to be tough
thanks
Func DisconnectCheck()
Static Local $gs_obj = GetValue('PacketLocation')
While MemoryRead($gs_obj ) = 0 ; While Disconnected
ControlSend($mGWHwnd,'','','{ENTER}') ; Hit enter key until you log back in
Sleep(Random(5000,10000,1))
WEnd
EndFunc
or
Func DCCheck()
Local $aX, $aY
$aX = DllStructGetData(GetAgentByID(-2), "X"
$aY = DllStructGetData(GetAgentByID(-2), "Y"
If $aX = 0 And $aY = 0 Then ; Is this the correct check for this type of DC?
Sleep(3000)
Send("{ENTER}" ; Presses OK in the error 007 window
Sleep(3000)
Send("{ENTER}" ; Selects the last used character and travels to the last used outpost
Sleep(8000)
EndIf
EndFunc
the only way i can understand the answer to my first question is that this code:
$equipHpArmor = not $equipHpArmor
changes the $equipHpArmor variable to true? but thats just a wild guess as the wording of the code does not imply that it does that at all to me?