Need Help with salvage function

11/08/2018 22:50 lasse1993#1
Hello people,

first of all. I'm a big noob. Im just cooking some copy pasta out of all the bots i got to get them to do whatever i want :D So far it worked alright. Until now.

I try to add the ability to salvage runes and sell them to the runes merchant to my feather bots.... but well, i dont get it to work.

My main problem for now is the function SalvageMod() does nothing. It is part of the GWA2.au3 collection

Code:
Func SalvageMod($aModIndex)
	Return SendPacket(0x8, $HEADER_SALVAGE_MODS, $aModIndex)
EndFunc   ;==>SalvageMod
I hope you can tell me what i do wrong ... Isn't Runes Index 0 and Insignias Index 1 ?

Code:
Func CI_Salvage($BAGINDEX)
	Local $bag
	Local $I
	Local $AITEM
	$BAG = GETBAG($BAGINDEX)
	For $I = 1 To DllStructGetData($BAG, "slots") ;von 1 bis X slots von Bags
		If FindSalvageKit() = 0 Then
			If GETGOLDCHARACTER() < 500 And GETGOLDSTORAGE() > 499 Then
				WITHDRAWGOLD(500)
				Sleep(GetPing()+500)
			EndIf
			Local $J = 0
			Do
				BuyItem(3, 1, 400) ;buy 3th position
				Sleep(GetPing()+500)
				$J = $J + 1
			Until FindSalvageKit() <> 0 Or $J = 3
			If $J = 3 Then ExitLoop
			Sleep(GetPing()+500)
		EndIf
		$AITEM = GETITEMBYSLOT($Bagindex, $I)
		If DllStructGetData($AITEM, "ID") = 0 Then ContinueLoop ;this is a skip
	  If CheckCustomTopRunes_Array Then
		   SalvageMod(1)
	  ElseIf CheckCustomTopInsignias_Array Then
		   SalvageMod(0)
	  ElseIf CheckCustomMidRunes_Array Then
		   SalvageMod(1)
	  ElseIf CheckCustomMidInsignias_Array Then
		   SalvageMod(0)
	  ElseIf CheckCustomLowRunes_Array Then
		   SalvageMod(1)
	  ElseIf CheckCustomLowInsignias_Array Then
		   SalvageMod(0)
EndIf
		Sleep(GetPing()+500)
	Next
EndFunc
PS: It would be awesome if you tell me how to sell those runes to the rune merchant (request price -> sell). Would save me a lot of time since im a total noob :P
11/09/2018 19:08 lasse1993#2
Thanks a lot mate !
Gonna edit my stuff and hope it turns my shit into gold :pogchamp:

Edit:

You provided me a huge step further and i can now salvage runes out of armors and sell them YEY

But if i'm going to loop through my inventory the bot tries to salvage the already salvaged mods again which result in a dc/error.

To prevent that im trying to combine my If statement with the model ID of an array. But if i add the AND part it wont salvage any mod anymore...

Can someone tell me where my mistake is?

Code:
If CheckCustomTopRunes_Array($aItem) AND CheckCustom_PickUp_ArmorPieces_Array($lModelID) Then
		   $aIndex = 1 ;0 = insignia | 1 = rune
			   StartSalvage($aItem)
			   Sleep(GetPing() + 800)
			   SalvageMod($aIndex)
		  Sleep(GetPing() + 800)


;~ ==== ArmorPieces ====
Global $Custom_PickUp_ArmorPieces_Array[5] = [1154, 1156, 1159, 1166, 1167]

Func CheckCustom_PickUp_ArmorPieces_Array($lModelID)
For $p = 0 To (UBound($Custom_PickUp_ArmorPieces_Array) -1)
If ($lModelID == $Custom_PickUp_ArmorPieces_Array[$p]) Then Return True
Next
EndFunc
I found a work around but its suuuuuuuper slow so i still would love to find the solution to it!

Right now the bot has to sell the rune right after he salvaged it. But im using some "messy" code which makes it really slow. (Loop to check for propper runes and salvage them, if one is salvaged another loop starts to find the rune and sell it to the rune merchant. After that salvaging continues ...)

Question: Do i need all the sleep commands? And should they be that long? Or could i lower them to ~150-250ms instead of 500-800 ?

Code:
If CheckCustomTopRunes_Array($aItem) Then
		   $aIndex = 1 ;0 = insignia | 1 = rune
			   StartSalvage($aItem)
			   Sleep(GetPing() + 800)
			   SalvageMod($aIndex)
			   SellRunes($BagIndex)
		  Sleep(GetPing() + 800)

Func SellRunes($BAGINDEX)
	Local $AITEM
	Local $BAG = GETBAG($BAGINDEX)
	Local $NUMOFSLOTS = DllStructGetData($BAG, "slots")
	$runemerchant = GetNearestNPCToCoords(16471, 12577)
	GoToNPC($runemerchant)
	For $I = 1 To $NUMOFSLOTS
		$AITEM = GETITEMBYSLOT($BAGINDEX, $I)
		If DllStructGetData($AITEM, "ID") = 0 Then ContinueLoop
		If CheckcustomRunes_Array ($AITEM) Then
			TraderRequestSell($AITEM)
			TraderSell()
		EndIf
		Sleep(GetPing()+250)
	Next
EndFunc
Full Function if it helps or smth...