Halloween tots grabber and farmer

10/19/2019 09:23 manolobarcelona#16
Any update?
05/21/2020 22:31 natanders#17
Code:
#NoTrayIcon
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiEdit.au3>
#include <Math.au3>
#include "GWA2.au3"
#include "Constants.au3"


Opt("MustDeclareVars", True) 	; have to declare variables with either Local or Global.
Opt("GUIOnEventMode", True)		; enable gui on event mode

Global $boolInitialized = False
Global $boolRunning = False

Global $lastDistrict = -1
Global $Rendering = True

Global Const $MainGui = GUICreate("Skelefarm - Quest Acceptor", 172, 190)
	GUICtrlCreateLabel("Skelefarm - Quest Acceptor", 8, 6, 156, 17, $SS_CENTER)
	Global Const $inputCharName = GUICtrlCreateCombo("", 8, 24, 150, 22)
		GUICtrlSetData(-1, GetLoggedCharNames())
   Global Const $cbxHideGW = GUICtrlCreateCheckbox("Disable Graphics", 8, 48)
   Global Const $cbxOnTop = GUICtrlCreateCheckbox("Always On Top", 8, 68)
;~ 	GUICtrlCreateLabel("Runs:", 8, 92)
;~ 	Global Const $lblRunsCount = GUICtrlCreateLabel(0, 80, 92, 30)
;~ 	GUICtrlCreateLabel("Fails:", 8, 112)
;~ 	Global Const $lblFailsCount = GUICtrlCreateLabel(0, 80, 112, 30)
	Global Const $lblLog = GUICtrlCreateLabel("", 8, 130, 154, 30)
	Global Const $btnStart = GUICtrlCreateButton("Start", 8, 162, 154, 25)

GUICtrlSetOnEvent($btnStart, "EventHandler")
GUICtrlSetOnEvent($cbxOnTop, "EventHandler")
GUICtrlSetOnEvent($cbxHideGW, "EventHandler")
GUISetOnEvent($GUI_EVENT_CLOSE, "EventHandler")
GUISetState  [MENTION=330060]Sw_[/MENTION]SHOW)

Do
	Sleep(100)
Until $boolInitialized

If GetMapID() <> $LA_ID Then
	TravelTo($LA_ID)
EndIf

; abandon quest if we have it:
If DllStructGetData(GetQuestByID($EVERY_BIT_HELPS), "ID") <> 0 Then
	AbandonQuest($EVERY_BIT_HELPS)
	Sleep(GetPing()+100)
EndIf

While 1
	If $boolRunning Then

		; Gold check
		If GetGoldCharacter() >= 99*1000  Then
		   If GetGoldStorage() < 900*1000 Then
				DepositGold(_Min(1000*1000 - GetGoldStorage(), 100*1000))
			Else
				EctoBuy()
			EndIf
		 EndIf
		 
		 If CountSlots() < 5 Then
			StoreTricks()
		 EndIf
		 

		; Inventory check / managment
		InventoryManagement()

		Out("Moving to the guy")
		MoveTo(5240, 9082) ; go close to the steward
		Local $Steward = GetNearestNPCToCoords(5332, 9048)
		Sleep(100)
		GoNPC($Steward)
		Sleep(300)
		Out("Accepting quest")
		AcceptQuest($EVERY_BIT_HELPS)
		Sleep(300)
		Out("Accepting reward")
		QuestReward($EVERY_BIT_HELPS)

		Sleep(300)
		Out("Zoning")
		Local $lDistrict = nextRandomDis()
		MoveMap($LA_ID, $lRegion[$lDistrict], 0, $lLanguage[$lDistrict])
		WaitMapLoading($LA_ID, 10*1000, 2.5*1000) ; zone, wait 2.5 sec at the end

	Else
		Sleep(100)
	EndIf
WEnd

Func InventoryManagement()
	Local $skele = GetItemByModelIDExtended($MODEL_ID_CAPTURED_SKELETON)

	If $skele[1] == 0 And $skele[2] == 0 Then
		MsgBox(0, "Done", "No more skeles to exchange")
		Exit
	EndIf

	If DllStructGetData($skele[0], 'Quantity') <= 2 Then
		Local $haveSome = False
		Local $curBag = $skele[1]
		Local $curSlot = $skele[2] + 1
		If $curSlot > DllStructGetData(GetBag($curBag), 'Slots') Then
			$curBag += 1
			$curSlot = 1
		EndIf
		While 1
			Local $next = GetItemByModelIDExtended($MODEL_ID_CAPTURED_SKELETON, $curBag, $curSlot)
			If $next[1] == 0 And $next[2] == 0 Then
				If $haveSome Then
					For $bag=$curBag To 4
						For $slot=$curSlot To DllStructGetData(GetBag($bag), 'Slots')
							If DllStructGetData(GetItemBySlot($bag, $slot), 'ModelID') == 0 Then
								MoveItem($skele[0], $bag, $slot)
								Return
							EndIf
						Next
					Next
				Else
					MsgBox(0, "Done", "Only "&DllStructGetData($skele[0], 'Quantity')&" left")
					Exit
				EndIf
			EndIf

			If DllStructGetData($next[0], 'Quantity') <= 248 Then
				MoveItem($skele[0], $next[1], $next[2])
				ExitLoop
			EndIf

			$curBag = $next[1]
			$curSlot = $next[2] + 1
			If $curSlot > DllStructGetData(GetBag($curBag), 'Slots') Then
				$curBag += 1
				$curSlot = 1
			EndIf
			$haveSome = True
		WEnd
	EndIf
EndFunc

; returns a 3-element array containing: The item struct, the bag where it is, the slot where it is.
Func GetItemByModelIDExtended($ModelID, $StartBag = 1, $StartSlot = 1)
	Local $retArr[3] = [False, 0, 0]
	For $bag = $StartBag To 4
		For $slot = $StartSlot To DllStructGetData(GetBag($bag), 'Slots')
			Local $item = GetItemBySlot($bag, $slot)
			If DllStructGetData($item, 'ModelID') == $ModelID Then
				$retArr[0] = $item
				$retArr[1] = $bag
				$retArr[2] = $slot
				Return $retArr
			EndIf
		Next
	Next
	Return $retArr
EndFunc

Func nextRandomDis()
	Local $tmp
	While 1
		$tmp = Random(1, 11, 1)
		If $tmp <> $lastDistrict Then
			$lastDistrict = $tmp
			Return $tmp
		EndIf
	WEnd
EndFunc

Func EventHandler()
	Switch  [MENTION=3027413]Gui_[/MENTION]CtrlId
		Case $GUI_EVENT_CLOSE
			Exit
		Case $cbxHideGW
			ClearMemory()
			ToggleRendering()
		Case $btnStart
			If $boolRunning Then
				GUICtrlSetData($btnStart, "Resume")
				$boolRunning = False
			ElseIf $boolInitialized Then
				GUICtrlSetData($btnStart, "Pause")
				$boolRunning = True
			Else
				$boolRunning = True
				GUICtrlSetData($btnStart, "Initializing...")
				GUICtrlSetState($btnStart, $GUI_DISABLE)
				GUICtrlSetState($inputCharName, $GUI_DISABLE)
				WinSetTitle($MainGui, "", GUICtrlRead($inputCharName))
				If GUICtrlRead($inputCharName) = "" Then
					If Initialize(ProcessExists("gw.exe"), True, False, False) = False Then	; don't need string logs or event system
						MsgBox(0, "Error", "Guild Wars it not running.")
						Exit
					EndIf
				Else
					If Initialize(GUICtrlRead($inputCharName), True, False, False) = False Then ; don't need string logs or event system
						MsgBox(0, "Error", "Can't find a Guild Wars client with that character name.")
						Exit
					EndIf
				EndIf
				GUICtrlSetData($btnStart, "Pause")
				GUICtrlSetState($btnStart, $GUI_ENABLE)
				$boolInitialized = True
			EndIf
		Case $cbxOnTop
			WinSetOnTop($MainGui, "", GUICtrlRead($cbxOnTop)==$GUI_CHECKED)
	EndSwitch
EndFunc

Func ToggleRendering()
	If $Rendering Then
		DisableRendering()
		WinSetState(GetWindowHandle(), "",  [MENTION=330060]Sw_[/MENTION]HIDE)
		ClearMemory()
	Else
		EnableRendering()
		WinSetState(GetWindowHandle(), "",  [MENTION=330060]Sw_[/MENTION]SHOW)
	EndIf
	$Rendering = Not $Rendering
EndFunc

Func Out($aString)
	Local $timestamp = "[" &  [MENTION=902431]Hour[/MENTION] & ":" &  [MENTION=287308]Min[/MENTION] & "] "
	GUICtrlSetData($lblLog, $timestamp & $aString)
 EndFunc   ;==>Out
 
 
 Func EctoBuy()
	Local $EctoID = 930
	If GetGoldCharacter() > 97000 Then
		Sleep(GetPing()+200)
		MoveTo(7536, 5859)
		Local $Trader = GetNearestNPCToCoords(7527, 5773)
;		$Trader = GetAgentByName("Argus[Rare Material Trader]")
		GOTONPC($Trader)
		TraderRequest($EctoID)
		Sleep(GetPing()+1000)
		While GetGoldCharacter() > 20*1000
			TraderRequest($EctoID)
			Sleep(GetPing()+100)
			TraderBuy()
		WEnd
	EndIf
 EndFunc   ;==>EctoBuy

 
 #Region ToT Storage
 Func StoreTricks()
	TrickOrTreat(1, 20)
	TrickOrTreat(2, 5)
	TrickOrTreat(3, 10)
	TrickOrTreat(4, 10)
 EndFunc
 
Func TrickOrTreat($BAGINDEX, $NUMOFSLOTS)
	Local $AITEM
	Local $M
	Local $Q
	Local $SLOT
	Local $FULL
	Local $NSLOT
	For $I = 1 To $NUMOFSLOTS
		$AITEM = GETITEMBYSLOT($BAGINDEX, $I)
		If DllStructGetData($AITEM, "ID") = 0 Then ContinueLoop
		$M = DllStructGetData($AITEM, "ModelID")
		$Q = DllStructGetData($AITEM, "quantity")
		If $M = 28434 And $Q = 250 Then
			Do
				For $BAG = 8 To 12
					$SLOT = FINDEMPTYSLOT($BAG)
					$SLOT =  [MENTION=368499]Extended[/MENTION]
					If $SLOT <> 0 Then
						$FULL = False
						$NSLOT = $SLOT
						ExitLoop 2
					Else
						$FULL = True
					EndIf
					Sleep(400)
				Next
			Until $FULL = True
			If $FULL = False Then
				MOVEITEM($AITEM, $BAG, $NSLOT)
				Sleep(Random(450, 550))
			EndIf
		EndIf
	Next
EndFunc
Func FINDEMPTYSLOT($BAGINDEX)
	Local $LITEMINFO, $ASLOT
	For $ASLOT = 1 To DllStructGetData(GETBAG($BAGINDEX), "Slots")
		Sleep(40)
		$LITEMINFO = GETITEMBYSLOT($BAGINDEX, $ASLOT)
		If DllStructGetData($LITEMINFO, "ID") = 0 Then
			SetExtended($ASLOT)
			ExitLoop
		EndIf
	Next
	Return 0
EndFunc
Func COUNTSLOTS($ANUMBAGS = 4)
	Local $LFREESLOTS = 0
	Local $LBAGSLOTS = 0
	For $i = 1 To $ANUMBAGS
		$LBAGSLOTS = DllStructGetData(GETBAG($i), "slots")
		$LFREESLOTS += $LBAGSLOTS
		For $SLOT = 1 To $LBAGSLOTS
			If DllStructGetData(GETITEMBYSLOT($i, $SLOT), "ModelID") <> 0 Then
				$LFREESLOTS -= 1
			EndIf
		Next
	Next
	Return $LFREESLOTS
EndFunc   ;==>COUNTSLOTS
#EndRegion Store Tots
I know its a little out of date. but wanted to share it freely.

Code:
#NoTrayIcon
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiEdit.au3>
#include "GWA2.au3"
#include "Constants.au3"


Opt("GUIOnEventMode", True)		; enable gui on event mode

Global $boolInitialized = False
Global $boolRunning = False
Global Const $SleepTime = 50 ; in milliseconds

Global Const $MainGui = GUICreate("Skelefarm - ToT Dropper", 172, 190)
	GUICtrlCreateLabel("Skelefarm - ToT Dropper", 8, 6, 156, 17, $SS_CENTER)
	Global Const $inputCharName = GUICtrlCreateCombo("", 8, 24, 150, 22)
		GUICtrlSetData(-1, GetLoggedCharNames())
	Global Const $lblLog = GUICtrlCreateLabel("", 8, 130, 154, 30)
	Global Const $btnStart = GUICtrlCreateButton("Start", 8, 162, 154, 25)

GUICtrlSetOnEvent($btnStart, "EventHandler")
GUISetOnEvent($GUI_EVENT_CLOSE, "EventHandler")
GUISetState [MENTION=330060]Sw_[/MENTION]SHOW)

Do
	Sleep(100)
Until $boolInitialized

While 1
	If $boolRunning Then
		RapeATot()
		Sleep(500)
	Else
		Sleep(250)
	EndIf
WEnd

Func RapeATot()
	For $bag=1 To 4
		For $slot=1 To DllStructGetData(GetBag($bag), 'Slots')
			Local $item = GetItemBySlot($bag, $slot)
			If DllStructGetData($item, 'ModelID') == $MODEL_ID_TOT_BAGS Then
				DropItem($item)
				Return
			EndIf
		Next
	Next
EndFunc

Func EventHandler()
	Switch [MENTION=3027413]Gui_[/MENTION]CtrlId
		Case $GUI_EVENT_CLOSE
			Exit
		Case $btnStart
			If $boolRunning Then
				GUICtrlSetData($btnStart, "Resume")
				$boolRunning = False
			ElseIf $boolInitialized Then
				GUICtrlSetData($btnStart, "Pause")
				$boolRunning = True
			Else
				$boolRunning = True
				GUICtrlSetData($btnStart, "Initializing...")
				GUICtrlSetState($btnStart, $GUI_DISABLE)
				GUICtrlSetState($inputCharName, $GUI_DISABLE)
				WinSetTitle($MainGui, "", GUICtrlRead($inputCharName))
				If GUICtrlRead($inputCharName) = "" Then
					If Initialize(ProcessExists("gw.exe"), True, False, False) = False Then	; don't need string logs or event system
						MsgBox(0, "Error", "Guild Wars it not running.")
						Exit
					EndIf
				Else
					If Initialize(GUICtrlRead($inputCharName), True, False, False) = False Then ; don't need string logs or event system
						MsgBox(0, "Error", "Can't find a Guild Wars client with that character name.")
						Exit
					EndIf
				EndIf
				GUICtrlSetData($btnStart, "Pause")
				GUICtrlSetState($btnStart, $GUI_ENABLE)
				$boolInitialized = True
			EndIf

	EndSwitch
 EndFunc

Func Out($aString)
	Local $timestamp = "[" & [MENTION=902431]Hour[/MENTION] & ":" & [MENTION=287308]Min[/MENTION] & "] "
	GUICtrlSetData($lblLog, $timestamp & $aString)
 EndFunc   ;==>Out
10/20/2020 22:31 Assasinns Cred#18
Hey,
is there a working version? Mine doesn't enter uw and steps around the reaper every few seconds (leader script)

Thanks for the help
10/21/2020 00:32 natanders#19
None that are public, of my knowledge


but this can maybe hekp you on the way

Code:
Func Main()
	If Not GoldCheck() Then Return

	If $TOA_ID Then
		SpawnpointToA()
		Sleep(GetPing()+500)
		If $SpawnpointToA1 Then
			Out("Spawnpoint 1")
			MoveTo(-4124.00, 119829.00)
		EndIf
	EndIf

	; TODO: check for being stuck

	Local $Avatar
	$Avatar = GetNearestNPCToCoords(-4124, 19829)	; try to get the avatar, might be there already.
	If DllStructGetData($Avatar, "PlayerNumber") <> $MODELID_AVATAR_OF_GRENTH Then		; nope avatar is not there, spawn him.
		Out("Spawning grenth")
		SendChat("kneel", "/")
		Local $lDeadlock = TimerInit()
		
	EndIf

	Out("Talking to the avatar of grenth")
	;GoNpc(83)
	Sleep(3500)
	GoNearestNPCToCoords(-4124.00, 19829.00)
    Sleep(2000);wait till he spawns
	Dialog(0x86) ; "Enter UW"

	Out("Waiting for uw to load")
	WaitMapLoading(72)
	If GetMapID() == $TOA_ID Then Return ; dialogs to enter uw failed. restart.
10/21/2020 06:29 MissBonvivant#20
can someone please fix this and upload? :)
10/21/2020 15:32 Waka.Waka#21
Quote:
Originally Posted by MissBonvivant View Post
can someone please fix this and upload? :)
yes do it please on your own and upload it for us all thanks
10/21/2020 17:50 Assasinns Cred#22
Quote:
Originally Posted by natanders View Post
None that are public, of my knowledge


but this can maybe hekp you on the way

Code:
Func Main()
	If Not GoldCheck() Then Return

	If $TOA_ID Then
		SpawnpointToA()
		Sleep(GetPing()+500)
		If $SpawnpointToA1 Then
			Out("Spawnpoint 1")
			MoveTo(-4124.00, 119829.00)
		EndIf
	EndIf

	; TODO: check for being stuck

	Local $Avatar
	$Avatar = GetNearestNPCToCoords(-4124, 19829)	; try to get the avatar, might be there already.
	If DllStructGetData($Avatar, "PlayerNumber") <> $MODELID_AVATAR_OF_GRENTH Then		; nope avatar is not there, spawn him.
		Out("Spawning grenth")
		SendChat("kneel", "/")
		Local $lDeadlock = TimerInit()
		
	EndIf

	Out("Talking to the avatar of grenth")
	;GoNpc(83)
	Sleep(3500)
	GoNearestNPCToCoords(-4124.00, 19829.00)
    Sleep(2000);wait till he spawns
	Dialog(0x86) ; "Enter UW"

	Out("Waiting for uw to load")
	WaitMapLoading(72)
	If GetMapID() == $TOA_ID Then Return ; dialogs to enter uw failed. restart.
You are a hero for me! now i just have the problem that i get skeleid -1

Code:
Func GetSkeleID()
	; for some reasons sometimes it does not work. So just do the whole thing multiple times.
	For $i=1 To 3
		Local $lAgentArray = GetAgentArray(0xDB)
		Local $lMe = GetAgentByID(-2)
		Local $lSkeleID = -1
		Local $lClosestSkeleDistance = 25000000 ; 25000000 = compass distance^2, skele will be less than that.
		For $i = 1 To $lAgentArray[0]
			If DllStructGetData($lAgentArray[$i], 'PlayerNumber') == $MODELID_SKELETON_OF_DHUUM Then
				Local $lDistance = GetPseudoDistance($lMe, $lAgentArray[$i])
				If $lDistance < $lClosestSkeleDistance Then ; we found a closer skele
					$lSkeleID = DllStructGetData($lAgentArray[$i], "ID")
					$lClosestSkeleDistance = $lDistance
				EndIf
			EndIf
		Next
		If $lSkeleID > 0 Then Return $lSkeleID
		Sleep(1500)
	Next
	If $lSkeleID == -1 Then WriteChat("ERROR - CANNOT FIND SKELE - TELL SOMEONE ABOUT IT")
	Return $lSkeleID
EndFunc
10/22/2020 01:59 natanders#23
well we need more farmers - so here we go

maybe you guys can help tweak it for forthcoming Pantheon weeks so we are ready for next years halloween :feelsbadman::lul:
10/22/2020 18:33 Waka.Waka#24
there is no follower .au3 or am i missing something? the include file only has functions in it but there is main script for a follower.au3 for the other 7 slots of the party
10/22/2020 20:20 natanders#25
Quote:
Originally Posted by Waka.Waka View Post
there is no follower .au3 or am i missing something? the include file only has functions in it but there is main script for a follower.au3 for the other 7 slots of the party
yes you are right. there is no follower.. and that is not one I like to make puplic yet
10/22/2020 21:45 Waka.Waka#26
Quote:
Originally Posted by natanders View Post
yes you are right. there is no follower.. and that is not one I like to make puplic yet
well you pretty much wrote everything down you need for it in shared foulder.
it could work with any class (sec class cant be monk since leader is searched by monk second profession) thats smart by the way.. then follow.. then if distance is 2 big (because leader used deaths charge) you can ee to the target and use any spells (X/Ele could work with aoe or even just Lod) just edit mapcheck with UW map to start the script.. can basically be a loop until mapid <> uw.
10/22/2020 23:39 siegsiet#27
follow skele bot ANY CLASS CAN BE A/MO thats smart by the way..
10/23/2020 11:53 Assasinns Cred#28
Quote:
Originally Posted by siegsiet View Post
follow skele bot ANY CLASS CAN BE A/MO thats smart by the way..
If your mates code new functions or rename them you should share the shared too :D
10/23/2020 12:28 Toxicland#29
Had to change the following in Skele Acceptor:
Quote:
WaitMapLoading($LA_ID, 10*1000, 2.5*1000) ; zone, wait 2.5 sec at the end
Threw an error because of 2 inputs, had to remove the "10*1000", runs fine afterwards
10/23/2020 14:24 Waka.Waka#30
Quote:
Originally Posted by Assasinns Cred View Post
If your mates code new functions or rename them you should share the shared too :D
just fixed the version for myself as i described it top.. you can have it if you want