In need of a functioning salvage function

02/07/2020 22:13 sadusten#1
Hi, now that the gwa's been updated i figured ill give botting a go again.
I updated my old bots, where the same identifying & selling functions still works but my salvage functions do not sadly..

So was wondering if theres any kind soul out there that has a working salvage function they'd like to share :)
02/08/2020 19:58 phat34#2
looking into this...as well as buying/selling mats is still non-operational
02/09/2020 05:16 sadusten#3
yea, ive tried couple of different salvage funcs that ive scrambled from different bots, some of them crashes, some wont but nothing salvages :>
02/10/2020 00:12 Zvend#4
you will need assembly if you want to do that with autoit.
u can only salvage non-weapon items by packets without the hook.
Look at the old Salvage Implementation, then fix the patterns and change the asm to the new GW Compiler and it will probably work again
02/10/2020 15:04 sadusten#5
Quote:
Originally Posted by Zvend View Post
you will need assembly if you want to do that with autoit.
u can only salvage non-weapon items by packets without the hook.
Look at the old Salvage Implementation, then fix the patterns and change the asm to the new GW Compiler and it will probably work again
I'm not very educated with more indept things, i mean i've created 10 or more bots using functions from other bots and adjusting etc but don't rly know more than that, so you're saying its possible to salvage non weapon items, for example dragon roots. How would a function like that look today compared to the old :) sorry!
02/10/2020 16:22 Zvend#6
cant really tell you in autoit. didnt take a look into the "updated" one.

but try sth like this:

Code:
SendPacket(0x10, 0x7D, session_id, kit_id, item_id)
You find the session id in the WorldContext i think the offset was 0x660 or 0x690. Or have a look on old gwa2 script do that
02/11/2020 21:28 sadusten#7
Quote:
Originally Posted by Zvend View Post
cant really tell you in autoit. didnt take a look into the "updated" one.

but try sth like this:

Code:
SendPacket(0x10, 0x7D, session_id, kit_id, item_id)
You find the session id in the WorldContext i think the offset was 0x660 or 0x690. Or have a look on old gwa2 script do that
Yea i tried couple different ones like
Code:
SendPacket(0x10, 0x7D, 0x690, 2992, 819)
Code:
SendPacket(0x4, 0x7F, 0x690, 2992, 819)
1 gave me 007 error and the others just doesnt do anything :p
02/11/2020 22:11 Zvend#8
Quote:
Originally Posted by sadusten View Post
Yea i tried couple different ones like
Code:
SendPacket(0x10, 0x7D, 0x690, 2992, 819)
Code:
SendPacket(0x4, 0x7F, 0x690, 2992, 819)
1 gave me 007 error and the others just doesnt do anything :p
Its because 0x690 is an offset inside the WorldContext.
Lets say you have a big shelf called GameContext
The shelf 'GameContext' has some drawer.
there is like:
  • AgentContext
  • ItemContext
  • MapContext
  • GuildContext
  • and more Contexts and non Contexts.

and there is the WorldContext.

each of the Contexts saves a bunch of information.
So the WorldContext stores for example the current active quest, the current mission states, your unlocked skills, your earned points like kurzick, balth etc
so a bunch of stuff related to the 'world'.

the world drawer starts at 0x0 when u start to pull it.
so u will need to pull the drawer until u see the offset 0x690. There is the session ID needed for your Salvaging.

You will need the read some layers of Memory.

This is the file i made for my own API months ago but i dont use autoit anymore. U can easily see what offsets u ll need to read out:

Code:
;File: Interface_GuildWarsBase.au3              //epvp edit: also called BasePointer
;{
Func _Gwen_GetGameContext()
	If $_GameContext = 0 Then 
		$_GameContext = _Gwen_Read($_BasePointer)
		$_GameContext = _Gwen_Read($_GameContext + 0x18)
	EndIf
	Return $_GameContext
EndFunc

;}
this is how u get the GameContext. U will need to fin out how to get the BasePointer by urself or look into ur GWA2.

Code:
;File: Interface_GameContext.au3
;{
    Global Enum $CONTEXT_AGENT      = 0x08, _
                $CONTEXT_MAP        = 0x14, _
                $CONTEXT_WORLD      = 0x2C, _
                $CONTEXT_CINEMATIC  = 0x30, _
                $CONTEXT_GADGET     = 0x38, _
                $CONTEXT_GUILD      = 0x3C, _
                $CONTEXT_ITEM       = 0x40, _
                $CONTEXT_ACCOUNT    = 0x44, _
                $CONTEXT_PARTY      = 0x4C, _
                $CONTEXT_TRADE      = 0x58
;}
So u see where to read the WorldContext from.

Code:
;File: Interface_WorldContext.au3
;{
	Global Enum $WORLDCONTEXT_MERCHANT_ITEMS			= 0x0024, _
		    $WORLDCONTEXT_MERCHANT_ROWS				= 0x0028, _
	            $WORLDCONTEXT_MAP_AGENT_ARRAY			= 0x007C, _
	            $WORLDCONTEXT_ALL_FLAG				= 0x009C, _
	            $WORLDCONTEXT_PARTY_ATTRIBUTES_ARRAY		= 0x00AC, _
	            $WORLDCONTEXT_PARTY_EFFECTS_ARRAY			= 0x0508, _
	            $WORLDCONTEXT_ACTIVE_QUEST_ID			= 0x0528, _
	            $WORLDCONTEXT_QUEST_LOG				= 0x052C, _
	            $WORLDCONTEXT_MISSION_OBJECTIVES_ARRAY		= 0x0564, _
	            $WORLDCONTEXT_HERO_FLAG_ARRAY			= 0x0584, _
	            $WORLDCONTEXT_HERO_INFO_ARRAY			= 0x0594, _
	            $WORLDCONTEXT_MISSION_BONUS_ARRAY			= 0x05CC, _
	            $WORLDCONTEXT_MISSION_COMPLETED_ARRAY		= 0x05DC, _
	            $WORLDCONTEXT_MISSION_BONUS_HM_ARRAY		= 0x05EC, _
	            $WORLDCONTEXT_MISSION_COMPLETED_HM_ARRAY		= 0x05FC, _
	            $WORLDCONTEXT_UNLOCKED_MAP_ARRAY			= 0x060C, _
	            $WORLDCONTEXT_SALVAGE_SESSION_ID			= 0x0690, _
	            $WORLDCONTEXT_SKILLBAR_ARRAY			= 0x06F0, _
	            $WORLDCONTEXT_UNLOCKED_SKILLS_ARRAY			= 0x0710, _ ;Bit Field
	            $WORLDCONTEXT_EXPERIENCE				= 0x0740, _
	            $WORLDCONTEXT_CURRENT_KURZICK_POINTS		= 0x0748, _
	            $WORLDCONTEXT_TOTAL_EARNED_KURZICK_POINTS		= 0x0750, _ ;Number in the Tooltip of the Kurzick-Bar in the Hero-Panel
	            $WORLDCONTEXT_CURRENT_LUXON_POINTS			= 0x0758, _
	            $WORLDCONTEXT_TOTAL_EARNED_LUXON_POINTS		= 0x0760, _ ;Number in the Tooltip of the Luxon-Bar in the Hero-Panel
	            $WORLDCONTEXT_CURRENT_IMPERIAL_POINTS		= 0x0768, _
	            $WORLDCONTEXT_TOTAL_EARNED_IMPERIAL_POINTS		= 0x0770, _ ;Number in the Tooltip of the Imperial-Bar in the Hero-Panel
	            $WORLDCONTEXT_LEVEL					= 0x0788, _
	            $WORLDCONTEXT_CURRENT_BALTHAZAR_POINTS		= 0x0798, _
	            $WORLDCONTEXT_TOTAL_EARNED_BALTHAZAR_POINTS		= 0x07A0, _ ;Number in the Tooltip of the Balthazar-Bar in the Hero-Panel
	            $WORLDCONTEXT_CURRENT_SKILL_POINTS			= 0x07A8, _
	            $WORLDCONTEXT_TOTAL_EARNED_SKILL_POINTS		= 0x07B0, _ ;Number in the Tooltip of the Skillpoint-Field in the Hero-Panel
	            $WORLDCONTEXT_MAX_KURZICK_POINTS			= 0x07B8, _
	            $WORLDCONTEXT_MAX_LUXON_POINTS			= 0x07BC, _
	            $WORLDCONTEXT_MAX_BALTHAZAR_POINTS			= 0x07C0, _
	            $WORLDCONTEXT_MAX_IMPERIAL_POINTS			= 0x07C4, _
	            $WORLDCONTEXT_AGENT_INFO_ARRAY			= 0x07CC, _
	            $WORLDCONTEXT_NPC_ARRAY				= 0x07FC, _
	            $WORLDCONTEXT_PLAYER_ARRAY				= 0x080C, _
	            $WORLDCONTEXT_TITLE_ARRAY				= 0x081C, _
	            $WORLDCONTEXT_FOES_KILLED				= 0x084C, _
	            $WORLDCONTEXT_FOES_TO_KILL				= 0x0850
;}
and heres the important stuff of the WorldContext. (Some Offset may changed, since the API is 4 Months old and didnt get updated yet.)
But 0x690 is still the offset u want.

TL-DR:
GameContext = Read(Read(BasePointer) + 0x18)
WorldContext = Read(GameContext + 0x2C)
SessionId = Read(WorldContext + 0x690)
02/13/2020 15:15 sadusten#9
Quote:
Originally Posted by Zvend View Post

TL-DR:
GameContext = Read(Read(BasePointer) + 0x18)
WorldContext = Read(GameContext + 0x2C)
SessionId = Read(WorldContext + 0x690)


I see, so it's more complicated than what i know off, like i mentioned earlier i'm not so in depth with the whole, only basic functions etc, but thanks for letting me know the basics.
Is there anyway for me as a "noob" to find out how to fix salvaging atm or should i wait for someone that knows what they're doing to release it?

I can post the salvage functions that i've used before, and if theres anyone who can teach me or help out i'd appreciate it very much :)

Code:
Global $inputmodelid = GUICtrlCreateInput("", 30, 55, 40)
Global Const $HEADER_SALVAGE_MATS = 0x7F

While Not $botrunning
	Sleep(100)
WEnd

Bankstuff()


Func Bankstuff()
	SalvageAnything()
EndFunc   ;==>Bankstuff


Func SalvageAnything()
	Local $lquantityold, $loldvalue
	salvagekit()
	Local $lsalvagekitid = findsalvagekit(1, 4)
	Local $lsalvagekitptr = getitemptr($lsalvagekitid)
	For $bag = 1 To 4
		$lbagptr = getbagptr($bag)
		If $lbagptr = 0 Then ContinueLoop
		For $SLOT = 1 To memoryread($lbagptr + 32, "long")
			$litem = getitemptrbyslot($lbagptr, $SLOT)
			If Not getcansalvage2($litem) Then ContinueLoop
			out("Salvaging : " & $bag & "," & $SLOT)
			$lquantity = memoryread($litem + 75, "byte")
			$itemmid = memoryread($litem + 44, "long")
			$itemrarity = getrarity($litem)
			If $itemrarity = $RARITY_White Or $itemrarity = $RARITY_Blue Then
				For $i = 1 To $lquantity
					If memoryread($lsalvagekitptr + 12, "ptr") = 0 Then
						salvagekit()
						$lsalvagekitid = findsalvagekit(1, 4)
						$lsalvagekitptr = getitemptr($lsalvagekitid)
					EndIf
					$lquantityold = $lquantity
					$loldvalue = memoryread($lsalvagekitptr + 36, "short")
					startsalvage($litem, $lsalvagekitid)
					Local $ldeadlock = TimerInit()
					Do
						Sleep(200)
					Until memoryread($lsalvagekitptr + 36, "short") <> $loldvalue Or TimerDiff($ldeadlock) > 5000
				Next
			EndIf
		Next
	Next
	salvagekit()
EndFunc   ;==>SalvageAnything


Func getcansalvage2($aitemptr)
	If memoryread($aitemptr + 24, "ptr") <> 0 Then Return False
	Local $litemtype = memoryread($aitemptr + 32, "byte")
	Local $lmodelid = memoryread($aitemptr + 44, "long")
	If $lmodelid <> GUICtrlRead($InputModelId) Then Return False
	Switch $lmodelid
		Case GUICtrlRead($InputModelId)
			Return True
	EndSwitch
	Return False
EndFunc   ;==>getcansalvage2


Func StartSalvage($aItem)
	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

	Local $lSalvageKit = FindSalvageKit()
	If $lSalvageKit = 0 Then Return

	DllStructSetData($mSalvage, 2, $lItemID)
	DllStructSetData($mSalvage, 3, FindSalvageKit())
	DllStructSetData($mSalvage, 4, $lSalvageSessionID[1])

	Enqueue($mSalvagePtr, 16)
EndFunc   ;==>StartSalvage


Func SalvageMaterials()
	Return SendPacket(0x4, $HEADER_SALVAGE_MATS)
EndFunc   ;==>SalvageMaterials
02/13/2020 15:37 Zvend#10
Try sth like this:

Code:
Func SalvageNonWeapon($kit_id, $item_id)
    Local $session_id_offsets[4] = [0, 0x18, 0x2C, 0x690]
    Local $session_id = MemoryReadPtr($mBasePointer, $session_id_offsets)
    Return SendPacket(0x10, 0x7D, $session_id [1], $kit_id, $item_id)
EndFunc
02/13/2020 16:16 sadusten#11
Quote:
Originally Posted by Zvend View Post
Try sth like this:

Code:
Func SalvageNonWeapon($kit_id, $item_id)
    Local $session_id_offsets[4] = [0, 0x18, 0x2C, 0x690]
    Local $session_id = MemoryReadPtr($mBasePointer, $session_id_offsets)
    Return SendPacket(0x10, 0x7D, $session_id [1], $kit_id, $item_id)
EndFunc

I just did this, is this the correct way? basically to replace my StartSalvage function inside the SalvageAnything function? or am i doing completely wrong:pimp:
Code:
Global $inputmodelid = GUICtrlCreateInput("", 30, 55, 40)

While Not $botrunning
	Sleep(100)
WEnd

SalvageAnything()
sleep(5000)
;checking if it salvaged


Func SalvageAnything()
	Local $lquantityold, $loldvalue
	salvagekit()
	Local $lsalvagekitid = findsalvagekit(1, 4)
	Local $lsalvagekitptr = getitemptr($lsalvagekitid)
	For $bag = 1 To 4
		$lbagptr = getbagptr($bag)
		If $lbagptr = 0 Then ContinueLoop
		For $SLOT = 1 To memoryread($lbagptr + 32, "long")
			$litem = getitemptrbyslot($lbagptr, $SLOT)
			If Not getcansalvage2($litem) Then ContinueLoop
			out("Salvaging : " & $bag & "," & $SLOT)
			$lquantity = memoryread($litem + 75, "byte")
			$itemmid = memoryread($litem + 44, "long")
			$itemrarity = getrarity($litem)
			If $itemrarity = $RARITY_White Or $itemrarity = $RARITY_Blue Then
				For $i = 1 To $lquantity
					If memoryread($lsalvagekitptr + 12, "ptr") = 0 Then
						salvagekit()
						$lsalvagekitid = findsalvagekit(1, 4)
						$lsalvagekitptr = getitemptr($lsalvagekitid)
					EndIf
					$lquantityold = $lquantity
					$loldvalue = memoryread($lsalvagekitptr + 36, "short")



					SalvageNonWeapon(2992, 819) ;<------Heres your func


                                       ;startsalvage($litem, $lsalvagekitid)
					Local $ldeadlock = TimerInit()
					Do
						Sleep(200)
					Until memoryread($lsalvagekitptr + 36, "short") <> $loldvalue Or TimerDiff($ldeadlock) > 5000
				Next
			EndIf
		Next
	Next
	salvagekit()
EndFunc   ;==>SalvageAnything

Func getcansalvage2($aitemptr)
	If memoryread($aitemptr + 24, "ptr") <> 0 Then Return False
	Local $litemtype = memoryread($aitemptr + 32, "byte")
	Local $lmodelid = memoryread($aitemptr + 44, "long")
	If $lmodelid <> GUICtrlRead($InputModelId) Then Return False
	Switch $lmodelid
		Case GUICtrlRead($InputModelId)
			Return True
	EndSwitch
	Return False
EndFunc   ;==>getcansalvage2

Func SalvageNonWeapon($kit_id, $item_id)
    Local $session_id_offsets[4] = [0, 0x18, 0x2C, 0x690]
    Local $session_id = MemoryReadPtr($mBasePointer, $session_id_offsets)
    Return SendPacket(0x10, 0x7D, $session_id [1], $kit_id, $item_id)
EndFunc
02/14/2020 20:47 Zvend#12
Quote:
Originally Posted by sadusten View Post
I just did this, is this the correct way? basically to replace my StartSalvage function inside the SalvageAnything function? or am i doing completely wrong:pimp:
Code:
Global $inputmodelid = GUICtrlCreateInput("", 30, 55, 40)

While Not $botrunning
	Sleep(100)
WEnd

SalvageAnything()
sleep(5000)
;checking if it salvaged


Func SalvageAnything()
	Local $lquantityold, $loldvalue
	salvagekit()
	Local $lsalvagekitid = findsalvagekit(1, 4)
	Local $lsalvagekitptr = getitemptr($lsalvagekitid)
	For $bag = 1 To 4
		$lbagptr = getbagptr($bag)
		If $lbagptr = 0 Then ContinueLoop
		For $SLOT = 1 To memoryread($lbagptr + 32, "long")
			$litem = getitemptrbyslot($lbagptr, $SLOT)
			If Not getcansalvage2($litem) Then ContinueLoop
			out("Salvaging : " & $bag & "," & $SLOT)
			$lquantity = memoryread($litem + 75, "byte")
			$itemmid = memoryread($litem + 44, "long")
			$itemrarity = getrarity($litem)
			If $itemrarity = $RARITY_White Or $itemrarity = $RARITY_Blue Then
				For $i = 1 To $lquantity
					If memoryread($lsalvagekitptr + 12, "ptr") = 0 Then
						salvagekit()
						$lsalvagekitid = findsalvagekit(1, 4)
						$lsalvagekitptr = getitemptr($lsalvagekitid)
					EndIf
					$lquantityold = $lquantity
					$loldvalue = memoryread($lsalvagekitptr + 36, "short")



					SalvageNonWeapon(2992, 819) ;<------Heres your func


                                       ;startsalvage($litem, $lsalvagekitid)
					Local $ldeadlock = TimerInit()
					Do
						Sleep(200)
					Until memoryread($lsalvagekitptr + 36, "short") <> $loldvalue Or TimerDiff($ldeadlock) > 5000
				Next
			EndIf
		Next
	Next
	salvagekit()
EndFunc   ;==>SalvageAnything

Func getcansalvage2($aitemptr)
	If memoryread($aitemptr + 24, "ptr") <> 0 Then Return False
	Local $litemtype = memoryread($aitemptr + 32, "byte")
	Local $lmodelid = memoryread($aitemptr + 44, "long")
	If $lmodelid <> GUICtrlRead($InputModelId) Then Return False
	Switch $lmodelid
		Case GUICtrlRead($InputModelId)
			Return True
	EndSwitch
	Return False
EndFunc   ;==>getcansalvage2

Func SalvageNonWeapon($kit_id, $item_id)
    Local $session_id_offsets[4] = [0, 0x18, 0x2C, 0x690]
    Local $session_id = MemoryReadPtr($mBasePointer, $session_id_offsets)
    Return SendPacket(0x10, 0x7D, $session_id [1], $kit_id, $item_id)
EndFunc
as i told u, if u try to salvage a weapon with it, u will get kicked or in worst case even crash.

u will need to be sure if it is NOT a weapon. based on my information u can be able to understand what to do. if not i highly recommend learning some more coding knowledge
02/15/2020 11:47 sadusten#13
Quote:
Originally Posted by Zvend View Post
as i told u, if u try to salvage a weapon with it, u will get kicked or in worst case even crash.

u will need to be sure if it is NOT a weapon. based on my information u can be able to understand what to do. if not i highly recommend learning some more coding knowledge
Im not salvaging a weapon though? Item id 819 is dragon roots.
02/15/2020 11:52 Zvend#14
Code:
While Not $botrunning
	Sleep(100)
WEnd

SalvageAnything()
sleep(5000)
;checking if it salvaged
why not using the salvage function directly instead of looping over everything which is really not necessary if u want to test a function.

you will also need to update the salvage header from 0x7D to 0x7E after the last update.
02/16/2020 22:23 sadusten#15
Quote:
Originally Posted by Zvend View Post
why not using the salvage function directly instead of looping over everything which is really not necessary if u want to test a function.

you will also need to update the salvage header from 0x7D to 0x7E after the last update.
Well yeah i realised after i posted it, that was stupid. Anyhow i did like u said doing 0x7E instead of 0x7D, but i get 007 errors:(

Code:
out("Ready.")
While Not $botrunning
	Sleep(100)
WEnd

SalvageNonWeapon(2992, 819)
Sleep(5000)


Func SalvageNonWeapon($kit_id, $item_id)
    Local $session_id_offsets[4] = [0, 0x18, 0x2C, 0x690]
    Local $session_id = MemoryReadPtr($mBasePointer, $session_id_offsets)
    Return SendPacket(0x10, 0x7E, $session_id [1], $kit_id, $item_id)
EndFunc