|
You last visited: Today at 21:10
Advertisement
In need of a functioning salvage function
Discussion on In need of a functioning salvage function within the GW Bots forum part of the Guild Wars category.
02/17/2020, 00:35
|
#16
|
elite*gold: 0
Join Date: Mar 2018
Posts: 24
Received Thanks: 18
|
Quote:
Originally Posted by sadusten
Code:
SalvageNonWeapon(2992, 819)
Sleep(5000)
Func SalvageNonWeapon($kit_id, $item_id)
|
"$kit_id" is the ItemID of the Salvage Kit, "$item_id" is the ItemID of the item you want to salvage. Both IDs you gave are ModelIDs.
However, i integrated this code to my GWA2 like this:
Code:
;~ Description: Salvage the material out of a trophy. Will not work on 'Type' <> 30.
Func SalvageTrophy($aItem, $aBagsToUse = 16)
Local $lOffset[4] = [0, 0x18, 0x2C, 0x690]
Local $lSalvageSessionID = MemoryReadPtr($mBasePointer, $lOffset)
If IsDllStruct($aItem) = 0 Then
Local $lItemID = $aItem
Else
Local $lItemID = DllStructGetData($aItem, 'ID')
EndIf
If DllStructGetData(GetItemByItemID($lItemID), 'Type') <> 30 Then Return
Local $lSalvageKit = FindSalvageKit($aBagsToUse)
If $lSalvageKit = 0 Then Return
Return SendPacket(0x10, $HEADER_SALVAGE_INITIATE, $lSalvageSessionID[1], $lSalvageKit, $lItemID)
EndFunc ;==>SalvageTrophy
Now I have the problem, that if I run my code,
Code:
SalvageTrophy(GetItemBySlot(1, 1))
it will crash around 3 of 4 times und run smooth ~ 1 time. If it works, I can salvage as many items as i want. When I restart GW it might work again or it crashes (most of the time it crashes, though). I can't find a pattern there and if i catch the packets that are getting sent it is exactly the same as the packets sent when i manually salvage the item.
Does somebody of you know what is happening here?
|
|
|
02/17/2020, 03:00
|
#17
|
elite*gold: 0
Join Date: Jul 2019
Posts: 103
Received Thanks: 83
|
Quote:
Originally Posted by smiley232
"$kit_id" is the ItemID of the Salvage Kit, "$item_id" is the ItemID of the item you want to salvage. Both IDs you gave are ModelIDs.
However, i integrated this code to my GWA2 like this:
Code:
;~ Description: Salvage the material out of a trophy. Will not work on 'Type' <> 30.
Func SalvageTrophy($aItem, $aBagsToUse = 16)
Local $lOffset[4] = [0, 0x18, 0x2C, 0x690]
Local $lSalvageSessionID = MemoryReadPtr($mBasePointer, $lOffset)
If IsDllStruct($aItem) = 0 Then
Local $lItemID = $aItem
Else
Local $lItemID = DllStructGetData($aItem, 'ID')
EndIf
If DllStructGetData(GetItemByItemID($lItemID), 'Type') <> 30 Then Return
Local $lSalvageKit = FindSalvageKit($aBagsToUse)
If $lSalvageKit = 0 Then Return
Return SendPacket(0x10, $HEADER_SALVAGE_INITIATE, $lSalvageSessionID[1], $lSalvageKit, $lItemID)
EndFunc ;==>SalvageTrophy
Now I have the problem, that if I run my code,
Code:
SalvageTrophy(GetItemBySlot(1, 1))
it will crash around 3 of 4 times und run smooth ~ 1 time. If it works, I can salvage as many items as i want. When I restart GW it might work again or it crashes (most of the time it crashes, though). I can't find a pattern there and if i catch the packets that are getting sent it is exactly the same as the packets sent when i manually salvage the item.
Does somebody of you know what is happening here?
|
First thing that comes to mind since it does successfully work at times is that you are salvaging too fast. Salvaging just like buying from a mat trader is very angry about the speed at which you do it. So you may need to add more delay to the rate you are salvaging.
|
|
|
02/17/2020, 12:00
|
#18
|
elite*gold: 0
Join Date: Mar 2018
Posts: 24
Received Thanks: 18
|
If it crashes, it crashes when I try to salvage the very first item (for testing i literally salvage only 1 item per click). It will not salvage this item then. I know the standard salvage approach, so it is either a very stupid mistake on my end or something with the api is broken.
//edit:
I've found the pattern: When I (manually) salvage at least one item before calling "SalvageTrophy()" it will work as intended. When I call it without salvaging before, it will crash.
|
|
|
02/17/2020, 14:27
|
#19
|
elite*gold: 0
Join Date: Jul 2019
Posts: 103
Received Thanks: 83
|
Quote:
Originally Posted by smiley232
If it crashes, it crashes when I try to salvage the very first item (for testing i literally salvage only 1 item per click). It will not salvage this item then. I know the standard salvage approach, so it is either a very stupid mistake on my end or something with the api is broken.
//edit:
I've found the pattern: When I (manually) salvage at least one item before calling "SalvageTrophy()" it will work as intended. When I call it without salvaging before, it will crash.
|
Makes me wonder if the salvage session location in memory isn't initialized until a previous function call. I would check what the values are at the memory before and after you do a manual salvage. It may be in a null state or bad values.
|
|
|
02/17/2020, 19:09
|
#20
|
elite*gold: 143
Join Date: Oct 2011
Posts: 72
Received Thanks: 31
|
Quote:
Originally Posted by smiley232
If it crashes, it crashes when I try to salvage the very first item (for testing i literally salvage only 1 item per click). It will not salvage this item then. I know the standard salvage approach, so it is either a very stupid mistake on my end or something with the api is broken.
//edit:
I've found the pattern: When I (manually) salvage at least one item before calling "SalvageTrophy()" it will work as intended. When I call it without salvaging before, it will crash.
|
i will quote myself from another post:
Quote:
|
Originally Posted by Zvend
u will probably get kicked with code 007 or get a crash when u send a salvage packet for a weapon. thats why some items can be salvaged only into materials.
For weapons u get a packet back from the Gameserver, which contains the the array of the mods.
So if you send the salvage packet for a weapon, then u get some packets back, where ur client cannot handle it, bcs it was not prepared for the incoming packets.
you will need to prepare a few things clientside before sending the final packet for weapon salvaging. Thats why GWA2 hooked the function, which also sends the right packet. There is a workaround for that where u block the incoming packets and just send the salvage packet. but thats nasty and will only update the inventory when changing the map and will also probably crash when the bot tries to do sth with the item or the invisible items u got through the salvage.
|
i am not sure if the packet is enqueued correctly in GWA2. Seems like there is just more not working fine.
i was able to enqueue the salvage packets without any problems with GWCA.
so u gotta need to fix the 2 patterns and the asm.
|
|
|
02/22/2020, 12:47
|
#21
|
elite*gold: 0
Join Date: Sep 2014
Posts: 354
Received Thanks: 120
|
Oh my...anyone have a Func _Gwen_Read() laying around.... holy smokes
|
|
|
02/22/2020, 20:20
|
#22
|
elite*gold: 143
Join Date: Oct 2011
Posts: 72
Received Thanks: 31
|
Quote:
Originally Posted by phat34
Oh my...anyone have a Func _Gwen_Read() laying around.... holy smokes
|
My API is called Gwen. and if u know the naming convention in autoit its mostlikely to call funcs _UDF_FuncName().
if u wanna know:
GW + Zvend = Gwend but Gwen is better, since my name is pronounced Zven
|
|
|
02/25/2020, 11:29
|
#23
|
elite*gold: 0
Join Date: Sep 2014
Posts: 354
Received Thanks: 120
|
That’s hot I think
|
|
|
02/28/2020, 17:00
|
#24
|
elite*gold: 0
Join Date: Aug 2015
Posts: 52
Received Thanks: 8
|
I did use smiley232's salvagetrophy() function by salvaging with getitembyslot(1,1) but i though i'd make it salvage anywhere in bag or bank, wich i now have, and its working kinda neat, still have to do 1 manually salvage before running the function to avoid crash ofc. It salvages my roots without any problem continously, but the problem i have when trying to salvage my bramble bows is that it wants to salvage the purples & the golds, and i've been trying to make it not do that by having it only returning the amount of bows of white+blues inside the GetBowsCount(), and also blocking purple&gold out of the SalvageBramles() It basically doesnt go past if it finds a gold/purple bow, am i returning it wrong? or what am i missing here, anybody got a clue?
Code:
;Outandfarming()
inventory()
Func inventory()
out("Salvaging")
While GetRootCount() > 0
SalvageRoots(GetItemIDfromMobelID(819))
Sleep(getping() + 800)
If findsalvagekit() = 0 Then
out("Salvage kit")
If getgoldcharacter() < 100 Then
out("Golds")
withdrawgold(100)
Sleep(getping() + 1250)
EndIf
buyitem(2, 1, 100)
findsalvagekit()
Sleep(getping() + 1250)
EndIf
WEnd
While GetBowsCount() > 0
SalvageBrambles(GetItemIDfromMobelID($modeid_breambellong))
Sleep(getping() + 800)
SalvageBrambles(GetItemIDfromMobelID($modeid_breambelshort))
Sleep(getping() + 800)
SalvageBrambles(GetItemIDfromMobelID($modeid_breambelflat))
Sleep(getping() + 800)
SalvageBrambles(GetItemIDfromMobelID($modeid_breambelhorn))
Sleep(getping() + 800)
;SAME AS FIBER WATCH OUT (RECURVE)-->
SalvageBrambles(GetItemIDfromMobelID($modeid_breambelrecurve))
Sleep(getping() + 800)
WEnd
EndFunc ;==>inventory
Func GetItemIDfromMobelID($aModelID)
For $i = 1 To 16
For $j = 1 To DllStructGetData(GetBag($i), 'slots')
Local $item = GetItemBySlot($i, $j)
If DllStructGetData($item, 'ModelId') == $aModelID Then Return DllStructGetData($item, 'Id')
Next
Next
EndFunc ;==>GetItemIDfromMobelID
;REGION DRAGON ROOTS
Func SalvageRoots($aitem, $aBagsToUse = 16)
Local $lOffset[4] = [0, 0x18, 0x2C, 0x690]
Local $lSalvageSessionID = MemoryReadPtr($mBasePointer, $lOffset)
If IsDllStruct($aitem) = 0 Then
Local $lItemID = $aitem
Else
Local $lItemID = DllStructGetData($aitem, 'ID')
EndIf
If DllStructGetData(GetItemByItemID($lItemID), 'Type') <> 30 Then Return
Local $lSalvageKit = findsalvagekit() ;FindSalvageKit($aBagsToUse)
If $lSalvageKit = 0 Then Return
Return SendPacket(0x10, $HEADER_SALVAGE_MATS, $lSalvageSessionID[1], $lSalvageKit, $lItemID)
EndFunc ;==>SalvageRoots
Func GetRootCount()
Local $AAMOUNTROOTS = 0
Local $item
Local $i
Local $bag
Local $SLOT
For $bag = 1 To 16
For $SLOT = 1 To DllStructGetData(GetBag($bag), 'Slots')
Local $item = GetItemBySlot($bag, $SLOT)
;DRAGON ROOTS
If DllStructGetData($item, 'ModelID') == $modelid_dragonroots Then
$AAMOUNTROOTS += DllStructGetData($item, "Quantity")
Else
ContinueLoop
EndIf
Next
Next
Return $AAMOUNTROOTS
EndFunc ;==>GetRootCount
;REGION BRAMBLES
Func SalvageBrambles($aitem, $aBagsToUse = 16)
Local $lOffset[4] = [0, 0x18, 0x2C, 0x690]
Local $lSalvageSessionID = MemoryReadPtr($mBasePointer, $lOffset)
If IsDllStruct($aitem) = 0 Then
Local $lItemID = $aitem
Else
Local $lItemID = DllStructGetData($aitem, 'ID')
EndIf
If DllStructGetData(GetItemByItemID($lItemID), 'Type') <> 5 Then Return
Local $itemrarity = getrarity($aitem)
If $itemrarity = $rarity_gold Or $itemrarity = $rarity_purple Then Return
Local $lSalvageKit = findsalvagekit() ;FindSalvageKit($aBagsToUse)
If $lSalvageKit = 0 Then Return
Return SendPacket(0x10, $HEADER_SALVAGE_MATS, $lSalvageSessionID[1], $lSalvageKit, $lItemID)
EndFunc ;==>SalvageBrambles
Func GetBowsCount()
Local $AAMOUNTBOWS = 0
Local $item
Local $i
Local $bag
Local $SLOT
For $bag = 1 To 16
For $SLOT = 1 To DllStructGetData(GetBag($bag), 'Slots')
Local $item = GetItemBySlot($bag, $SLOT)
Local $M = DllStructGetData($item, 'ModelID')
Local $T = DllStructGetData($item, "Type")
Local $lRarity = getrarity($item)
;BRAMBLE BOWS
If $M = $modeid_breambelshort Or $M = $modeid_breambelrecurve Or $M = $modeid_breambellong Or $M = $modeid_breambelhorn Or $M = $modeid_breambelflat And $T = 5 Then
If $lRarity = $rarity_blue Or $lRarity = $rarity_white Then
$AAMOUNTBOWS += DllStructGetData($item, "Quantity")
else
ContinueLoop
EndIf
EndIf
Next
Next
Return $AAMOUNTBOWS
EndFunc ;==>GetBowsCount
|
|
|
02/29/2020, 02:07
|
#25
|
elite*gold: 143
Join Date: Oct 2011
Posts: 72
Received Thanks: 31
|
Quote:
Originally Posted by sadusten
I did use smiley232's salvagetrophy() function by salvaging with getitembyslot(1,1) but i though i'd make it salvage anywhere in bag or bank, wich i now have, and its working kinda neat, still have to do 1 manually salvage before running the function to avoid crash ofc. It salvages my roots without any problem continously, but the problem i have when trying to salvage my bramble bows is that it wants to salvage the purples & the golds, and i've been trying to make it not do that by having it only returning the amount of bows of white+blues inside the GetBowsCount(), and also blocking purple&gold out of the SalvageBramles() It basically doesnt go past if it finds a gold/purple bow, am i returning it wrong? or what am i missing here, anybody got a clue? 
|
I dont know what u really tried to achieve there. The code is a real mess.
Here is sth with freehand from me what i would have done.
Maybe it helps you to understand how to code more effective
Code:
Func _GWA2_GetItemIsWeapon($Item)
If Not $Item Then Return SetError(1, 0, False)
Switch _GWA2_GetItemType($Item)
Case $GWA2_ITEMTYPE_AXE, $GWA2_ITEMTYPE_BOW, $GWA2_ITEMTYPE_FOCUS, _
$GWA2_ITEMTYPE_HAMMER, $GWA2_ITEMTYPE_WAND, $GWA2_ITEMTYPE_SHIELD, _
$GWA2_ITEMTYPE_STAFF, $GWA2_ITEMTYPE_SWORD, $GWA2_ITEMTYPE_DAGGERS, _
$GWA2_ITEMTYPE_SCYTHE, $GWA2_ITEMTYPE_SPEAR
Return True
Case Else
Return False
EndSwitch
EndFunc
Func _GWA2_ManageItem($Item)
Local $ModelID = _GWA2_GetItemModelID($Item)
Local $ExtraID = _GWA2_GetItemExtraID($Item)
Local $Type = _GWA2_GetItemType($Item)
Local $Quantity = _GWA2_GetItemQuantity($Item)
Local $Rarity = _GWA2_GetItemRarity($Item)
Local $InvSpace = _GWA2_GetInventorySpace()
Local $StoSpace = _GWA2_GetStorageSpace()
;Salvage Hot Fix, Dont forget Rarity Checkup when removing this.
If _GWA2_GetItemIsWeapon($Item) Then Return 0
If $InvSpace <= 1 Then
If $StoSpace <= 1 Then
;3 stands for the amount of crap the bot shall sell to create room
If Not _GWA2_SellCrap(3) Then Return -1
Else
;Stores some Item to the inventory while managing this
If Not _GWA2_CacheItemsInStorage($StoSpace) Then Return -1
EndIf
EndIf
Switch ($ModelID)
Case $GWA2_ITEMMODEL_DRAGON_ROOTS ;, .... and more
For $it = 1 To $Quantity
_GWA2_SalvageItem($Item)
Sleep(GetPing() * 2 + 125) ;You gotta play with this, lol
Next
Case $GWA2_ITEMMODEL_ECTOPLASM ;, ...
_GWA2_StoreItem($Item)
;etc...
EndSwitch
_GWA2_ResetCachedItems()
EndFunc
Func _GWA2_ManageInventory()
Local $BagIndex, $Bag
Local $Slot, $Item
For $BagIndex = 1 To 4
$Bag = _GWA2_GetBag($BagIndex)
If Not $Bag Then ContinueLoop
For $Slot = 1 To _GWA2_GetBagMaxSlots($Bag)
$Item = _GWA2_GetItemBySlot($Bag, $Slot)
If Not $Item Then ContinueLoop
If _GWA2_ManageItem($Item) = -1 Then
;You basicly dont want this to happen
;But prepare for the worst case here:
Return _GWA2_WorstCase_Inventory()
EndIf
Next
Next
EndFunc
|
|
|
02/29/2020, 02:21
|
#26
|
elite*gold: 0
Join Date: Aug 2015
Posts: 52
Received Thanks: 8
|
Quote:
Originally Posted by Zvend
I dont know what u really tried to achieve there. The code is a real mess.
Here is sth with freehand from me what i would have done.
Maybe it helps you to understand how to code more effective
Code:
Func _GWA2_GetItemIsWeapon($Item)
If Not $Item Then Return SetError(1, 0, False)
Switch _GWA2_GetItemType($Item)
Case $GWA2_ITEMTYPE_AXE, $GWA2_ITEMTYPE_BOW, $GWA2_ITEMTYPE_FOCUS, _
$GWA2_ITEMTYPE_HAMMER, $GWA2_ITEMTYPE_WAND, $GWA2_ITEMTYPE_SHIELD, _
$GWA2_ITEMTYPE_STAFF, $GWA2_ITEMTYPE_SWORD, $GWA2_ITEMTYPE_DAGGERS, _
$GWA2_ITEMTYPE_SCYTHE, $GWA2_ITEMTYPE_SPEAR
Return True
Case Else
Return False
EndSwitch
EndFunc
Func _GWA2_ManageItem($Item)
Local $ModelID = _GWA2_GetItemModelID($Item)
Local $ExtraID = _GWA2_GetItemExtraID($Item)
Local $Type = _GWA2_GetItemType($Item)
Local $Quantity = _GWA2_GetItemQuantity($Item)
Local $Rarity = _GWA2_GetItemRarity($Item)
Local $InvSpace = _GWA2_GetInventorySpace()
Local $StoSpace = _GWA2_GetStorageSpace()
;Salvage Hot Fix, Dont forget Rarity Checkup when removing this.
If _GWA2_GetItemIsWeapon($Item) Then Return 0
If $InvSpace <= 1 Then
If $StoSpace <= 1 Then
;3 stands for the amount of crap the bot shall sell to create room
If Not _GWA2_SellCrap(3) Then Return -1
Else
;Stores some Item to the inventory while managing this
If Not _GWA2_CacheItemsInStorage($StoSpace) Then Return -1
EndIf
EndIf
Switch ($ModelID)
Case $GWA2_ITEMMODEL_DRAGON_ROOTS ;, .... and more
For $it = 1 To $Quantity
_GWA2_SalvageItem($Item)
Sleep(GetPing() * 2 + 125) ;You gotta play with this, lol
Next
Case $GWA2_ITEMMODEL_ECTOPLASM ;, ...
_GWA2_StoreItem($Item)
;etc...
EndSwitch
_GWA2_ResetCachedItems()
EndFunc
Func _GWA2_ManageInventory()
Local $BagIndex, $Bag
Local $Slot, $Item
For $BagIndex = 1 To 4
$Bag = _GWA2_GetBag($BagIndex)
If Not $Bag Then ContinueLoop
For $Slot = 1 To _GWA2_GetBagMaxSlots($Bag)
$Item = _GWA2_GetItemBySlot($Bag, $Slot)
If Not $Item Then ContinueLoop
If _GWA2_ManageItem($Item) = -1 Then
;You basicly dont want this to happen
;But prepare for the worst case here:
Return _GWA2_WorstCase_Inventory()
EndIf
Next
Next
EndFunc
|
What i want to achive is to salvage dragon roots, and that works. I also want to salvage my bramble bows wich salvages into fiber aswell. But since you cannot salvage gold or purples without crashing, i want my func to skip those raritys. Your script looks even more complicated, atleast for me. My script finds the purple/gold bows, but doesnt salvage them, wich is good, but does not go past them to find blues and whites if they are in a slot below them.
are you saying i should call like this?
Code:
if $rarity = gold and $rarity = purple then
If _GWA2_GetItemIsWeapon($Item) Then Return 0
endif
|
|
|
02/29/2020, 02:33
|
#27
|
elite*gold: 143
Join Date: Oct 2011
Posts: 72
Received Thanks: 31
|
Try to avoid while loops.. they re mostly the reason why ur code gets stuck
|
|
|
02/29/2020, 02:57
|
#28
|
elite*gold: 0
Join Date: Aug 2015
Posts: 52
Received Thanks: 8
|
Quote:
Originally Posted by Zvend
Try to avoid while loops.. they re mostly the reason why ur code gets stuck
|
okay ill give it a go tomorrow, thank you
|
|
|
02/29/2020, 04:55
|
#29
|
elite*gold: 0
Join Date: Sep 2014
Posts: 354
Received Thanks: 120
|
We use while loops with deadlock timers to avoid the issues...
You need to iterate thought all the inventory in your bags and yes return zero when you get to the bramble bows.... then your for next loop should easily go to the next item... I will try to provide some example code but its readily available... search for a material buying/salvaging bot and you will find the code there...
|
|
|
02/29/2020, 13:03
|
#30
|
elite*gold: 143
Join Date: Oct 2011
Posts: 72
Received Thanks: 31
|
Quote:
Originally Posted by phat34
We use while loops with deadlock timers to avoid the issues...
You need to iterate thought all the inventory in your bags and yes return zero when you get to the bramble bows.... then your for next loop should easily go to the next item... I will try to provide some example code but its readily available... search for a material buying/salvaging bot and you will find the code there...
|
If you know how many instances you need to go through, then never call while loops :X
Thats a really bad style
|
|
|
 |
|
Similar Threads
|
Need Help with salvage function
11/09/2018 - GW Bots - 1 Replies
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
Func SalvageMod($aModIndex)
Return SendPacket(0x8,...
|
[GWA2] How to close salvage window AFTER salvage session is complete?
05/08/2018 - GW Bots - 5 Replies
Hi all,
I'm making a bot to manage my inventory for me in-game.
1. StartSalvage() on an item I want a mod for.
2. SalvageMod() for the mod I'm after
3. Close Salvage window (without GW kicking me out!)
Can't figure out how to do step 3. Looks like when I close the salvage window in-game, it sends a packet to the GS to "cancel" the session. The GS panics when it sees that the session has already completed, and the client gets kicked from the server.
|
std::function of a function returning an std::function
11/11/2013 - C/C++ - 19 Replies
Nun muss ich nach langer Zeit auch mal wieder einen Thread erstellen, weil mir Google nicht mehr weiterhelfen kann.
Ich verzweifle an Folgendem Vorhaben:
#include <Windows.h>
#include <string>
#include <iostream>
using namespace std;
|
functioning +9 hack
07/27/2008 - Dekaron - 17 Replies
Hey guys
I need a functioning +9 !HACK! for 2Moons
Pls help me
|
Which SM this functioning?
05/12/2007 - Silkroad Online - 6 Replies
Which SM this functioning?
SM 1,97 enters normal in the SRO but option AUTO TRAINING is disactivated.
SM 1,96 does not enter in the game appears this error:
ERROR
It has something to be made? I made something wrong?
They help me please!
|
All times are GMT +1. The time now is 21:11.
|
|