How to edit pickup items on a bot?

05/12/2024 16:17 greychachki#1
Hey all,

I have never done any coding so this is a new ball game. As the title suggests I'm interested in figuring out how to edit the items a bot picks up. There are a handful of excellent bots already established on here I just want to "tweak" the pickups to my tastes (unidentifying an inventory bag full of shields for starters).

An example of my attempt to have the featherbot pickup shields:

;If GetChecked ($CBX_Shields) and $ModelID = 778 Then ;778 = Bladed Shields,
;Return True
;EndIf

If GuiCtrlRead($CBX_Shields) = $GUI_CHECKED And $rarity = 2624 and $ModelID = 778 Then ;778 = Shields
Out("Picking up Gold Shield")
$Goldz += DllStructGetData($lItem, 'Quantity')
GUICtrlSetData($GoldsCount,$Goldz)
Return True
EndIf

I was able to get a checkbox for shields but the bot doesn't pickup the corresponding item.

Thanks,
05/13/2024 11:20 t7tcrusher#2
You did remove the semicolumn at the start of the lines of this script I hope? Else it will not do anything with those lines.


;If GetChecked ($CBX_Shields) and $ModelID = 778 Then ;778 = Bladed Shields,
;Return True
;EndIf
05/13/2024 19:25 greychachki#3
Quote:
Originally Posted by t7tcrusher View Post
You did remove the semicolumn at the start of the lines of this script I hope? Else it will not do anything with those lines.


;If GetChecked ($CBX_Shields) and $ModelID = 778 Then ;778 = Bladed Shields,
;Return True
;EndIf
Thank you! Yes I had the semi-colon in place. I am now picking up bladed shields of any rarity. The way the code reads I would assume it should filter out and non-golds? At least based on what I see within the script itself for the other items, ie Kamas.

If GuiCtrlRead($CBX_Shields) = $GUI_CHECKED And $RARITY = 2624 and $ModelID = 778 Then ;778 = Bladed Shield
Out("Picking up Gold Shields")
$Goldz += DllStructGetData($lItem, 'Quantity')
GUICtrlSetData($GoldsCount,$Goldz)
Return True
EndIf
05/13/2024 19:36 t7tcrusher#4
If you post the func canpickup() i can check whats happening since theres an amount of different featherbots
05/13/2024 20:08 greychachki#5
For reference:


Located in GWA2
CS
Func PickUpLoot()
If GetMapLoading() == 2 Then Disconnected()
Local $lMe
Local $lBlockedTimer
Local $lBlockedCount = 0
Local $lItemExists = True
For $i = 1 To GetMaxAgents()
If GetMapLoading() == 2 Then Disconnected()
$lMe = GetAgentByID(-2)
If DllStructGetData($lMe, 'HP') <= 0.0 Then Return
$lAgent = GetAgentByID($i)
If Not GetIsMovable($lAgent) Then ContinueLoop
If Not GetCanPickUp($lAgent) Then ContinueLoop
$lItem = GetItemByAgentID($i)

If CanPickUp($lItem) Then
Do
If GetMapLoading() == 2 Then Disconnected()
If $lBlockedCount > 2 Then UseSkillEx(6,-2)
PickUpItem($lItem)
Sleep(GetPing())
Do
Sleep(100)
$lMe = GetAgentByID(-2)
Until DllStructGetData($lMe, 'MoveX') == 0 And DllStructGetData($lMe, 'MoveY') == 0
$lBlockedTimer = TimerInit()
Do
Sleep(250)
$lItemExists = IsDllStruct(GetAgentByID($i))
Until Not $lItemExists Or TimerDiff($lBlockedTimer) > Random(5000, 7500, 1)
If $lItemExists Then $lBlockedCount += 1
Until Not $lItemExists Or $lBlockedCount > 5
EndIf
Next
EndFunc
#CE

Func CanPickUp($lItem)
If GetMapLoading() == 2 Then Disconnected()
Local $RARITY = GetRarity($lItem)
Local $Quantity
Local $ModelID = DllStructGetData($lItem, 'ModelID')
Local $ExtraID = DllStructGetData($lItem, 'ExtraID')
If $ModelID = 146 And ($ExtraID = 10 Or $ExtraID = 12) Then Return True
;If $ModelID = 931 Or $ModelID = 932 Then ;931=Monstrous Eye ;932=Monstrous Fang
;Return True
;EndIf
;If $ModelID = 923 Then ;931=Monstrous Claw
;Return True
;EndIf
05/14/2024 17:43 t7tcrusher#6
Quote:
Originally Posted by greychachki View Post
For reference:


Located in GWA2
CS
Func PickUpLoot()
If GetMapLoading() == 2 Then Disconnected()
Local $lMe
Local $lBlockedTimer
Local $lBlockedCount = 0
Local $lItemExists = True
For $i = 1 To GetMaxAgents()
If GetMapLoading() == 2 Then Disconnected()
$lMe = GetAgentByID(-2)
If DllStructGetData($lMe, 'HP') <= 0.0 Then Return
$lAgent = GetAgentByID($i)
If Not GetIsMovable($lAgent) Then ContinueLoop
If Not GetCanPickUp($lAgent) Then ContinueLoop
$lItem = GetItemByAgentID($i)

If CanPickUp($lItem) Then
Do
If GetMapLoading() == 2 Then Disconnected()
If $lBlockedCount > 2 Then UseSkillEx(6,-2)
PickUpItem($lItem)
Sleep(GetPing())
Do
Sleep(100)
$lMe = GetAgentByID(-2)
Until DllStructGetData($lMe, 'MoveX') == 0 And DllStructGetData($lMe, 'MoveY') == 0
$lBlockedTimer = TimerInit()
Do
Sleep(250)
$lItemExists = IsDllStruct(GetAgentByID($i))
Until Not $lItemExists Or TimerDiff($lBlockedTimer) > Random(5000, 7500, 1)
If $lItemExists Then $lBlockedCount += 1
Until Not $lItemExists Or $lBlockedCount > 5
EndIf
Next
EndFunc
#CE

Func CanPickUp($lItem)
If GetMapLoading() == 2 Then Disconnected()
Local $RARITY = GetRarity($lItem)
Local $Quantity
Local $ModelID = DllStructGetData($lItem, 'ModelID')
Local $ExtraID = DllStructGetData($lItem, 'ExtraID')
If $ModelID = 146 And ($ExtraID = 10 Or $ExtraID = 12) Then Return True
;If $ModelID = 931 Or $ModelID = 932 Then ;931=Monstrous Eye ;932=Monstrous Fang
;Return True
;EndIf
;If $ModelID = 923 Then ;931=Monstrous Claw
;Return True
;EndIf
You either forgot to paste a bit at the end of the canpickup function or it's incomplete.

Have to complete it a bit by guessing, but Next should work:
Code:
Func CanPickUp($lItem)
   If GetMapLoading() == 2 Then Disconnected()
   Local $RARITY = GetRarity($lItem)
   Local $Quantity
   Local $ModelID = DllStructGetData($lItem, 'ModelID')
   Local $ExtraID = DllStructGetData($lItem, 'ExtraID')
   If $ModelID = 146 And ($ExtraID = 10 Or $ExtraID = 12) Then Return True
   ElseIf GuiCtrlRead($CBX_Shields) = $GUI_CHECKED And $RARITY = 2624 and $ModelID = 778 Then ;778 = Bladed Shield
              Out("Picking up Gold Shields")
              $Goldz += DllStructGetData($lItem, 'Quantity')
              GUICtrlSetData($GoldsCount,$Goldz)
              Return True
     Else
              Return False
     EndIf
EndFunc