AUto[matic]Pot

05/19/2012 19:02 APwI#1
The following application will recognize the highest apothecary pot in your inventory and use it when appropriate ( defined in config.ini, in % ); you can kill the application by pressing {End} and/or in the tray bar.

I wrote this for my upcoming API, but thought it might be useful to release.

Bug reports and suggestions are appreciated.


Source
Code:
#RequireAdmin
#include "globals.au3"

HotKeySet("{END}", "__Terminate")

Global Const $HP_PERCENT = IniRead("config.ini", "AutoPot", "HP", 0)
Global Const $MP_PERCENT = IniRead("config.ini", "AutoPot", "MP", 0)

Global $HP_TIMER = TimerInit()
Global $MP_TIMER = TimerInit()


While 1
	If _Char_HP_Percentage() <= $HP_PERCENT And TimerDiff($HP_TIMER) >= 15000 Then
		_Use_Potion(1)
		$HP_TIMER = TimerInit()
	EndIf

	If _Char_MP_Percentage() <= $MP_PERCENT And TimerDiff($MP_TIMER) >= 15000 Then
		_Use_Potion(2)
		$MP_TIMER = TimerInit()
	EndIf

	Sleep(25)
WEnd


Func _Use_Potion($POTION_TYPE)
	Local $POTION_LEVEL = -1
	Local $POTION_INDEX = -1
	Local $i

	For $i = 0 To _Inventory_Get_Count()
		If _Inventory_Get_Type($i) == 9 Then

			If _Inventory_Get_Level($i) <= _Char_Get_Level() And _Inventory_Get_Level($i) >= $POTION_LEVEL And _Get_Potion_Type(_Inventory_Get_Type_ID($i)) == $POTION_TYPE Then
				$POTION_LEVEL = _Inventory_Get_Level($i)
				$POTION_INDEX = $i
			EndIf

		EndIf
	Next

	If $POTION_INDEX <> -1 And $POTION_LEVEL <> -1 Then
		_Use_Item($POTION_INDEX, _Inventory_Get_Type_ID($POTION_INDEX))
	EndIf
EndFunc   ;==>_Use_Potion

Func _Get_Potion_Type($POTION_TYPE_ID)
	; ===============================================
	; Return values
	;
	; 0 - Special potion (not supported)
	; 1 - Health potion
	; 2 - Mana potion
	; ================================================
	Switch $POTION_TYPE_ID
		Case 8617 To 8621
			Return 1
		Case 8612 To 8614
			Return 1
		Case 8647 To 8651
			Return 2
		Case 8642 To 8644
			Return 2
		Case Else
			Return 0
	EndSwitch
EndFunc   ;==>_Get_Potion_Type

Func _Use_Item($INVENTORY_INDEX, $INVENTORY_TYPE_ID, $EQUIPMENT = 0)
	Local $PACKET

	$PACKET = "2800"
	$PACKET &= _Reverse_Bytes($EQUIPMENT, 2)
	$PACKET &= "01"
	$PACKET &= _Reverse_Bytes($INVENTORY_INDEX, 2)
	$PACKET &= "00"
	$PACKET &= _Reverse_Bytes($INVENTORY_TYPE_ID)

	_Send_Packet($PACKET)
EndFunc   ;==>_Use_Item
AV results ( [Only registered and activated users can see links. Click Here To Register...] )
Quote:
Originally Posted by Jotti
2012-05-19 Found nothing 2012-05-19 Found nothing
2012-05-19 Found nothing 2012-05-19 Found nothing
2012-05-19 Found nothing 2012-05-19 Found nothing
2012-05-18 Found nothing 2012-05-19 Found nothing
2012-05-19 Found nothing 2012-05-19 Found nothing
2012-05-19 Found nothing 2012-05-19 Found nothing
2012-05-19 Found nothing 2012-05-19 Found nothing
2012-05-19 Found nothing 2012-05-19 Found nothing
2012-05-19 Found nothing 2012-05-18 Found nothing
2012-05-19 Found nothing 2012-05-18 Found nothing
05/20/2012 01:18 amineurin#2
by what i seen in the source code, its free of any virus.

i like this function: _MOVE_PLAYER
more clear then i wrote it :o

thanks for sharing this and good luck with the rest of the program :)
05/23/2012 22:03 APwI#3
Updated for Imperial Fury.
06/05/2012 21:36 benyair90#4
I dont know why is not working for me, just make it works once =(, any idea what im doing wrong? plz huge noob here >_< ill be really happy if u can give me a clue