Beginner Bot programming questions

01/22/2024 13:15 dhanvin#16
Quote:
Originally Posted by Mrjambix View Post
The headers are accurate, are you trying to ONLY Salvage? or is there more functions to this? Post the entire script so we can take a look at it.
Simple, I press a button and call a function with:

Code:
$aitem = GetItemBySlot(1, 1)
StartSalvage($aitem)
it seems the StartSalvage goes trough but then the client crashes.

It seems I am missing something / not understanding how it (should) work, for now I just want to salvage items to get materials without any further logic.
01/22/2024 18:31 Mrjambix#17
Quote:
Originally Posted by dhanvin View Post
Simple, I press a button and call a function with:

Code:
$aitem = GetItemBySlot(1, 1)
StartSalvage($aitem)
it seems the StartSalvage goes trough but then the client crashes.

It seems I am missing something / not understanding how it (should) work, for now I just want to salvage items to get materials without any further logic.
Try the following:

Code:
$aItem = GetItemBySlot(1, 1)
Local $lItemID = DllStructGetData($aItem, 'ID')
$itemStruct = GetItemByItemID($lItemID)
Local $lItemName = GetItemName($itemStruct)
If FindSalvageKit() <> 0 Then
    StartSalvage($aItem)
EndIf
What it does is this checks for the availability of a salvage kit using FindSalvageKit().
If a salvage kit is found (indicated by FindSalvageKit() returning a non-zero value), it proceeds to call StartSalvage($aItem)
01/23/2024 16:11 dhanvin#18
Quote:
Originally Posted by Mrjambix View Post
Try the following:

Code:
$aItem = GetItemBySlot(1, 1)
Local $lItemID = DllStructGetData($aItem, 'ID')
$itemStruct = GetItemByItemID($lItemID)
Local $lItemName = GetItemName($itemStruct)
If FindSalvageKit() <> 0 Then
    StartSalvage($aItem)
EndIf
What it does is this checks for the availability of a salvage kit using FindSalvageKit().
If a salvage kit is found (indicated by FindSalvageKit() returning a non-zero value), it proceeds to call StartSalvage($aItem)
I tried that, still crashes. Is it maybe because I'm doing in the pre?

I had to change "Case 2992 to Case 2993", because in gwtoolbox it shows me as ID 2993.

Code:
;~ Description: Returns item ID of salvage kit in inventory.
Func FindSalvageKit()
	Local $lItem
	Local $lKit = 0
	Local $lUses = 101
	For $i = 1 To 16
		For $j = 1 To DllStructGetData(GetBag($i), 'Slots')
			$lItem = GetItemBySlot($i, $j)
			Switch DllStructGetData($lItem, 'ModelID')
				Case 2993
					If DllStructGetData($lItem, 'Value') / 2 < $lUses Then
						$lKit = DllStructGetData($lItem, 'ID')
						$lUses = DllStructGetData($lItem, 'Value') / 2
					EndIf
						ContinueLoop
			EndSwitch
		Next
	Next
	Return $lKit
EndFunc   ;==>FindSalvageKit
Code:
*--> Crash <--*
Exception: c0000005 
Memory at address ffffffff could not be written
App: Gw.exe
BaseAddr: 00520000
ProgramId: 1
Build: 37325
When: 1/23/2024 21:39:54
Flags: 0
01/24/2024 21:57 Underavelvetmoon#19
There needs to be a sleep between each salvage, you aren't trying to salvage multiple items rapidly are you? If you do this even normally without a script it will crash your game. So if you have a loop to search for an item and salvage, there needs to be a sleep called in that loop.
01/25/2024 19:13 Mrjambix#20
Quote:
Originally Posted by Underavelvetmoon View Post
There needs to be a sleep between each salvage, you aren't trying to salvage multiple items rapidly are you? If you do this even normally without a script it will crash your game. So if you have a loop to search for an item and salvage, there needs to be a sleep called in that loop.
I replicated his issue and it's coming from elsewhere.
not using the sleep between salvage isn't what's causing that crash, although you are 100% right, it will cause another crash if he doesn't add it.

The issue so far I've traced it back to the Command SalvageFunction and SalvageGlobal.

Code:
	_('CommandSalvage:')
	_('push eax')
	_('push ecx')
	_('push ebx')
	_('mov ebx,SalvageGlobal')
	_('mov ecx,dword[eax+4]')
	_('mov dword[ebx],ecx')
	_('add ebx,4')
	_('mov ecx,dword[eax+8]')
	_('mov dword[ebx],ecx')
	_('mov ebx,dword[eax+4]')
	_('push ebx')
	_('mov ebx,dword[eax+8]')
	_('push ebx')
	_('mov ebx,dword[eax+c]')
	_('push ebx')
	_('call SalvageFunction')
	_('add esp,C')
	_('pop ebx')
	_('pop ecx')
	_('pop eax')
	_('ljmp CommandReturn')

Code:
	
SetValue('SalvageFunction', MemoryRead(GetValue('ScanSalvageFunction') + 8) - 18)
SetValue('SalvageGlobal', MemoryRead(MemoryRead(GetValue('ScanSalvageGlobal') + 8) + 1))

SetValue('SalvageFunction', '0x' & Hex(GetScannedAddress('ScanSalvageFunction', -10), 8))
SetValue('SalvageGlobal', '0x' & Hex(MemoryRead(GetScannedAddress('ScanSalvageGlobal', 1) - 0x4), 8))
Need to verify if the address above are still valid and the Patterns below which is currently the right one if it didn't change to something else.

Code:
	
AddPattern('5F5E5B741A6860EA0000') 
_('ScanSalvageFunction:')
	
;====================
AddPattern('8BFA8BD9897DF0895DF4') ;8BD9897DG0895DF4
;or 
AddPattern('33C58945FC8B45088945F08B450C8945F48B45108945F88D45EC506A10C745EC75') ; was 'ec76' dec 18th, 2020 fix -P34
_('ScanSalvageGlobal:')
01/27/2024 13:13 dhanvin#21
Quote:
Originally Posted by Mrjambix View Post
I replicated his issue and it's coming from elsewhere.
not using the sleep between salvage isn't what's causing that crash, although you are 100% right, it will cause another crash if he doesn't add it.

The issue so far I've traced it back to the Command SalvageFunction and SalvageGlobal.

Code:
	_('CommandSalvage:')
	_('push eax')
	_('push ecx')
	_('push ebx')
	_('mov ebx,SalvageGlobal')
	_('mov ecx,dword[eax+4]')
	_('mov dword[ebx],ecx')
	_('add ebx,4')
	_('mov ecx,dword[eax+8]')
	_('mov dword[ebx],ecx')
	_('mov ebx,dword[eax+4]')
	_('push ebx')
	_('mov ebx,dword[eax+8]')
	_('push ebx')
	_('mov ebx,dword[eax+c]')
	_('push ebx')
	_('call SalvageFunction')
	_('add esp,C')
	_('pop ebx')
	_('pop ecx')
	_('pop eax')
	_('ljmp CommandReturn')

Code:
	
SetValue('SalvageFunction', MemoryRead(GetValue('ScanSalvageFunction') + 8) - 18)
SetValue('SalvageGlobal', MemoryRead(MemoryRead(GetValue('ScanSalvageGlobal') + 8) + 1))

SetValue('SalvageFunction', '0x' & Hex(GetScannedAddress('ScanSalvageFunction', -10), 8))
SetValue('SalvageGlobal', '0x' & Hex(MemoryRead(GetScannedAddress('ScanSalvageGlobal', 1) - 0x4), 8))
Need to verify if the address above are still valid and the Patterns below which is currently the right one if it didn't change to something else.

Code:
	
AddPattern('5F5E5B741A6860EA0000') 
_('ScanSalvageFunction:')
	
;====================
AddPattern('8BFA8BD9897DF0895DF4') ;8BD9897DG0895DF4
;or 
AddPattern('33C58945FC8B45088945F08B450C8945F48B45108945F88D45EC506A10C745EC75') ; was 'ec76' dec 18th, 2020 fix -P34
_('ScanSalvageGlobal:')
That was it!

Somehow the whole CommandSalvage push memory code was commented out and also wrong Patterns.

Thank you very much.

Thanks everyone for helping / answers.
01/28/2024 18:25 Mrjambix#22
Quote:
Originally Posted by dhanvin View Post
That was it!

Somehow the whole CommandSalvage push memory code was commented out and also wrong Patterns.

Thank you very much.

Thanks everyone for helping / answers.
That's great! Did you manage to find the working patterns?

Working Patterns are the following:
Code:
_('ScanSalvageFunction:')
	AddPattern('33C58945FC8B45088945F08B450C8945F48B45108945F88D45EC506A10C745EC75')

_('ScanSalvageGlobal:')
	AddPattern('8B5104538945F48B4108568945E88B410C578945EC8B4110528955E48945F0')
02/01/2024 09:20 dhanvin#23
ignore
03/07/2024 04:53 agentbooth#24
im trying like heck to figure out how to code this and im kinda shit at doing it anyway. (by kinda shit i mean the only thing i have coded myself so far is making my character run around day 2 of trying)

Essentially I'm using a dervish feather farm bot and i cant stand leaving behind unid'd blues (crazy i know) going through the code i have seen some of how looting works. this is what im seeing

lots of Global Const $model_id_blah blah blah
I believe this section is saying what can be picked up so i added

; === Armor ===
Global Const $model_id_sensali_Garb = 1156
Global Const $model_id_Sensali_crestguard = 1159
#EndRegion Constants

Further down im seeing can pick up and this is in it

Local $lRarity = GetRarity($lItem)
If ($lRarity == 2624) And ($PickUpGolds == True) Then Return True ; 2624 = golden Items
Return False

How do i make it get rarity on the sensali armors and pick up blues and purples as well?