Kod:
#include <GUIConstants.au3>
#include <GUIListView.au3>
#include <EditConstants.au3>
#include <String.au3>
#include <WindowsConstants.au3>
#NoTrayIcon
$wintitel = "HG Fuser+ v1.2"
$fusen = False
$fertig = True
$luckon = True
$luckyResult = False
$ErrorCheck = False
$ElixErrorSwitch = False
$TimerOn = False
$TimeOnBtn = False
$fInterrupt = 0
;Load from Ini
$alchemy_packet = IniRead("settings.ini","opcodes","alchemy","")
$result_packet = IniRead("settings.ini","opcodes","result","")
$info_packet = IniRead("settings.ini","opcodes","info","")
$stonesover_packet = IniRead("settings.ini","opcodes","stonesend","")
$bot_port = IniRead("settings.ini","other","bot_port","")
;Write Ini
IniWrite("settings.ini","ElixKeyPos","value","1")
IniWrite("settings.ini","PowdersKeyPos","value","1")
IniWrite("settings.ini","ElixirsID","value",IniRead("settings.ini","Elixirs","weapon",""))
IniWrite("settings.ini","PowdersID","value",IniRead("settings.ini","LuckyPowders","13D",""))
;GUI
$fenster = GUICreate(""&$wintitel&" by HardGroove 2013",482,485)
GUICtrlCreateLabel("Fuse until +", 16, 18, 60, 12)
$plus_combo = GUICtrlCreateCombo("1", 96, 16, 40, 25)
GUICtrlSetData(-1, "2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18")
$start_btn = GUICtrlCreateButton("START", 375, 7, 99, 40)
$stop_btn = GUICtrlCreateButton("STOP", 375, 54, 99, 40)
GUICtrlCreateLabel("Elixirs left:", 16, 115, 60, 12)
$elexiere_box = GUICtrlCreateInput("n/a", 96, 112, 40, 21,$ES_ReadOnly)
GUICtrlCreateLabel("Lucky Powders:", 16, 139, 76, 20)
$powder_box = GUICtrlCreateInput("n/a", 96, 136, 40, 21,$ES_ReadOnly)
GUICtrlCreateLabel("Lucky Stones:", 16, 163, 86, 20)
$stone_box = GUICtrlCreateInput("n/a", 96, 160, 40, 21,$ES_ReadOnly)
$LuckyStoneBox = GUICtrlCreateCheckbox("Lucky Stone add from:", 200, 16, 129, 17)
$LuckyCombo = GUICtrlCreateCombo("1", 332, 16, 40, 25)
GUICtrlSetData(-1, "2|3|4|5|6|7|8|9|10|11|12|13")
GUICtrlCreateLabel("Elixirs type", 16, 42, 52, 20)
$ElixirSwitch = GUICtrlCreateCombo("Weapon", 96, 40, 72, 25)
GUICtrlSetData(-1,"Protector|Accessory|Shield")
$PowdersID = GUICtrlCreateCombo("13", 96, 64, 40, 25)
GUICtrlSetData(-1,"12|11|10|9|8|7|6|5|4|3|2|1")
$Label1 = GUICtrlCreateLabel("Powder dgr", 16, 66, 58, 17)
$Immortal = GUICtrlCreateCheckbox("Immortal check (Case sensitive)", 200, 65)
$Steady = GUICtrlCreateCheckbox("Steady check (Case sensitive)", 200, 41)
;$ResetBtn = GUICtrlCreateButton("Reset", 163, 101, 99, 25)
$HelpBtn = GUICtrlCreateButton("Help", 375, 101, 99, 25)
$HomeBtn = GUICtrlCreateButton("Home", 375, 133, 99, 25)
GUICtrlCreateLabel("Reset", 174, 114, 27, 17)
GUICtrlCreateLabel("millisec", 256, 114, 34, 17)
$TimeResetSelect = GUICtrlCreateInput("2000", 209, 112, 41, 21)
GUICtrlSetTip($TimeResetSelect,"Auto reset time in milliseconds!"&@CR&"This is in case, if program will stuck!")
GUICtrlCreateLabel("Fusing time", 149, 139, 60, 17)
GUICtrlCreateLabel("sec", 256, 139, 20, 17)
$FusingTime = GUICtrlCreateInput("n/a", 209, 136, 41, 21,$ES_ReadOnly)
GUICtrlSetTip($FusingTime,"Fusing timer, it shows how long it takes to fuse 1 stone!")
$Group1 = GUICtrlCreateGroup("", 8, 2, 175, 92)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("", 8, 96, 295, 94)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group3 = GUICtrlCreateGroup("", 190, 2, 185, 92)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$leiste = GUICtrlCreateProgress(8, 233, 465, 20)
$liste = GUICtrlCreateListView("Log", 8, 261, 465, 216)
_GUICtrlListView_SetColumnWidth($liste,0,442)
$header = HWnd(_GUICtrlListView_GetHeader($liste))
ControlDisable($fenster, "", $header)
GUICtrlCreateListViewItem(@HOUR&":"&@MIN&":"&@SEC&" - Tool is started...",$liste)
GUISetState(@SW_SHOW)
WinSetOnTop(""&$wintitel,"",1);
Global $opcodecheck = False
Global $sError = True
Global $iError = True
GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND")
;connect to phCOnnector
TCPStartUp()
$socket = TCPConnect("127.0.0.1", $bot_port)
If $socket > 0 then
GUICtrlCreateListViewItem(@HOUR&":"&@MIN&":"&@SEC&" - Connected to phConnector...",$liste)
_GUICtrlListView_Scroll($liste,0,20)
Else
GUICtrlCreateListViewItem(@HOUR&":"&@MIN&":"&@SEC&" - Connection Error!!! Check the ports...",$liste)
_GUICtrlListView_Scroll($liste,0,20)
Sleep(1000)
Exit
EndIf
While 1
$recv = ReadPacket()
$msg = GUIGetMsg()
If $recv<>"" then
$size = Dec(StringMid($recv, 3, 2) & StringMid($recv, 1, 2))
$opcode = StringMid($recv, 7, 2) & StringMid($recv, 5, 2)
$data = StringMid($recv, 13)
BeginParse($data, $size)
;If $opcode = "B150" then Alchemy Result
If $opcode = $result_packet then
$TimerOn = True
$ok = ParseByte() ;->01
if $ok= "01" then
$dummy = ParseByte() ;->02
$iSuccess = ParseByte() ;->01
$iPos = ParseByte() ;->11
$dummy = ParseDWord() ;->00 00 00 00
$iId = ParseDWord()
Global $plus = ParseByte() ;->01
$totalElixircount = GUICtrlRead($elexiere_box)
GUICtrlSetData($elexiere_box, $totalElixircount-1)
$totalPowdercount = GUICtrlRead($powder_box)
GUICtrlSetData($powder_box, $totalPowdercount-1)
$log = FileOpen("log.txt", 1)
FileWriteLine($log,@MDAY&"/"&@MON&"/"&@YEAR&" "&@HOUR&":"&@MIN&":"&@SEC&" - Item is + "& Dec($plus))
FileClose($log)
GUICtrlCreateListViewItem(@HOUR&":"&@MIN&":"&@SEC&" - Item is +"& Dec($plus), $liste)
_GUICtrlListView_Scroll($liste,0,20)
If Dec($plus) >= GUICtrlRead($plus_combo) then ;Success
GUICtrlCreateListViewItem(@HOUR&":"&@MIN&":"&@SEC&" - Desired + is Succeeded!", $liste)
_GUICtrlListView_Scroll($liste,0,20)
GUICtrlSetData($start_btn, "START")
$log = FileOpen("log.txt", 1)
FileWriteLine($log,@MDAY&"/"&@MON&"/"&@YEAR&" "&@HOUR&":"&@MIN&":"&@SEC&" - Item is + "& Dec($plus))
FileClose($log)
$fusen = False
$luckon = False
$TimeOnBtn = False
Beep(850,200)
Beep(850,500)
MsgBox(0x40000,"Info","Alchemy was successful! Item is +"& Dec($plus))
EndIf
If GUICtrlRead($LuckyStoneBox) = $GUI_CHECKED And $luckon = True Then ;Lucky stone Check
If Dec($plus) >= GUICtrlRead($LuckyCombo) Then
Local $leisteupd = 0
Global $luckyResult = True
$log = FileOpen("log.txt", 1)
FileWriteLine($log,@MDAY&"/"&@MON&"/"&@YEAR&" "&@HOUR&":"&@MIN&":"&@SEC&" - Adding Magic stone of Luck!")
FileClose($log)
GUICtrlCreateListViewItem(@HOUR&":"&@MIN&":"&@SEC&" - Adding Magic stone of Luck!", $liste)
_GUICtrlListView_Scroll($liste,0,20)
InjectPacket("7151", "0204020D0E") ;From slot 2!
LoadBarFunc()
EndIf
EndIf
$FindImmo = IniReadSection("settings.ini", "ImmoStones") ;Immortal stone Check
For $i = 1 To $FindImmo[0][0]
$iFindImmo = StringInStr($data,$FindImmo[$i][1],0,1,53)
If $iFindImmo Not = 0 Then
$iError = False
EndIf
Next
If GUICtrlRead($Immortal) = $GUI_CHECKED And $iError = True Then
$fusen = False
$TimerOn = False
$log = FileOpen("log.txt", 1)
FileWriteLine($log,@MDAY&"/"&@MON&"/"&@YEAR&" "&@HOUR&":"&@MIN&":"&@SEC&" - No Immortal found on the item!")
FileClose($log)
GUICtrlCreateListViewItem(@HOUR&":"&@MIN&":"&@SEC&" - No Immortal found on the item!", $liste)
_GUICtrlListView_Scroll($liste,0,20)
MsgBox(0x40040,"ERROR","No Immortal found on the item!")
GUICtrlSetData($start_btn, "START")
EndIf
Local $FindSteady = IniReadSection("settings.ini", "SteadyStones") ;Steady stone Check
For $i = 1 To $FindSteady[0][0]
$iFindSteady = StringInStr($data,$FindSteady[$i][1],0,1,53)
If $iFindSteady Not = 0 Then
$sError = False
EndIf
Next
If GUICtrlRead($Steady) = $GUI_CHECKED And $sError = True Then
$fusen = False
$TimerOn = False
$log = FileOpen("log.txt", 1)
FileWriteLine($log,@MDAY&"/"&@MON&"/"&@YEAR&" "&@HOUR&":"&@MIN&":"&@SEC&" - No Steady found on the item!")
FileClose($log)
Beep(850,950)
MsgBox(0x40000,"ERROR","No Steady found on the item!")
GUICtrlSetData($start_btn, "START")
EndIf
If $luckyResult = False Then
GUICtrlSetData($leiste,0)
$ErrorCheck = False
$iError = True
$sError = True
$fertig = True
EndIf
Else ;If code B150 apears with not $ok = 1, when this error apears! << $ok = 2
$log = FileOpen("log.txt", 1)
FileWriteLine($log,@MDAY&"/"&@MON&"/"&@YEAR&" "&@HOUR&":"&@MIN&":"&@SEC&" - Error detected! Process is stopped... Error codes info.txt file in extra folder, have explanation about these error codes...")
FileWriteLine($log,@MDAY&"/"&@MON&"/"&@YEAR&" "&@HOUR&":"&@MIN&":"&@SEC&" - Reason: "&$data)
FileClose($log)
;error: 021254 << Coused by stones. Trying to fuse again, before old fuse still exist (Solution: Contact me!)
;error: 020A54 << Lucky powder not match (Solution: check for lucky powders degree, they should match with item degree!)
;error: 020954 << Elixir not match (Solution: check for elixirs degree, they should match with item degree!)
;error: 022254 << Amount of blue option on item is maxed! (This appears if you try to add magic stone on item, but his blue option is max!)
;error: 020300 << ???
GUICtrlCreateListViewItem(@HOUR&":"&@MIN&":"&@SEC&" - Error detected! Process is stopped... Check log for error code!", $liste)
_GUICtrlListView_Scroll($liste,0,20)
GUICtrlSetData($leiste,0)
GUICtrlSetData($start_btn, "START")
$fertig = True
$TimerOn = False
$fusen = False
MsgBox(0x40040,"Error","Something is wrong! Check log for error code!")
EndIf
EndIf
If $opcode = "B151" And $luckyResult = True Then
$luckyResult = False
$log = FileOpen("log.txt", 1)
FileWriteLine($log,@MDAY&"/"&@MON&"/"&@YEAR&" "&@HOUR&":"&@MIN&":"&@SEC&" - Magic stone of Luck is added successfully!")
FileClose($log)
GUICtrlCreateListViewItem(@HOUR&":"&@MIN&":"&@SEC&" - Magic stone of Luck is added successfully!", $liste)
_GUICtrlListView_Scroll($liste,0,20)
GUICtrlSetData($leiste,0)
$ErrorCheck = False
$iError = True
$sError = True
$fertig = True
EndIf
If $TimerOn = True And $TimeOnBtn = True Then ;Timer
$Timed = TimerDiff($Timer)
GUICtrlSetData($FusingTime,Int($Timed)/1000)
If $Timed > GUICtrlRead($TimeResetSelect)+8000 Then
$log = FileOpen("log.txt", 1)
FileWriteLine($log,@MDAY&"/"&@MON&"/"&@YEAR&" "&@HOUR&":"&@MIN&":"&@SEC&" - Tool is stuck, restarting!")
FileClose($log)
GUICtrlCreateListViewItem(@HOUR&":"&@MIN&":"&@SEC&" - Tool is stuck, restarting!",$liste)
_GUICtrlListView_Scroll($liste,0,20)
$ErrorCheck = False
$fertig = True
$TimerOn = False
EndIf
EndIf
;If $opcode = "3013" Then Check inventory for items!
If $opcode = $info_packet Then
IniDelete("settings.ini","ElixPos")
IniDelete("settings.ini","ElixirsCount")
IniDelete("settings.ini","PowdersPos")
IniDelete("settings.ini","PowdersCount")
IniDelete("settings.ini","ElixKeyPos")
IniDelete("settings.ini","PowdersKeyPos")
IniWrite("settings.ini","ElixKeyPos","value","1")
IniWrite("settings.ini","PowdersKeyPos","value","1")
$opcodecheck = True
$Elixkey = 1
$Powderskey = 1
$i = 0
$ii = 0
$ElixSearch = StringInStr($data,IniRead("settings.ini","ElixirsID","value","ERROR"),0,1) ;elixirs search
$PowderSearch = StringInStr($data,IniRead("settings.ini","PowdersID","value","ERROR"),0,1) ;powders search
;elixirs check
If $ElixSearch = 0 Then ;if there is no elixirs found it sets 0
GUICtrlSetData($elexiere_box,"0")
EndIf
If $ElixSearch Not = 0 Then
Do
$Pos = StringMid($data,$ElixSearch-10,2) ;possition in inventory
IniWrite("settings.ini","ElixPos",$Elixkey,$Pos)
$iCount = StringMid($data,$ElixSearch+8,2) ;check how much elixirs are in one stack
IniWrite("settings.ini","ElixirsCount",$Elixkey,$iCount)
$iPos = $ElixSearch+8 ;search other elixirs from last elixirs position in string
$Elixkey = $Elixkey + 1
$ElixSearch = StringInStr($data,IniRead("settings.ini","ElixirsID","value","ERROR"),0,1,$iPos)
$TotalElixirs = $i + dec($iCount)
$i = $TotalElixirs
Until $ElixSearch = 0
If $ElixSearch = 0 Then GUICtrlSetData($elexiere_box,$TotalElixirs)
EndIf
;powders check
If $PowderSearch = 0 Then ;if there is no powders found it sets 0
GUICtrlSetData($powder_box,"0")
EndIf
If $PowderSearch Not = 0 Then
Do
$Poss = StringMid($data,$PowderSearch-10,2) ;possition in inventory
IniWrite("settings.ini","PowdersPos",$Powderskey,$Poss)
$iiCount = StringMid($data,$PowderSearch+8,2) ;check how much powders are in one stack
IniWrite("settings.ini","PowdersCount",$Powderskey,$iiCount)
$iiPos = $PowderSearch+8 ;search other powder from last powders position in string
$Powderskey = $Powderskey + 1
$PowderSearch = StringInStr($data,IniRead("settings.ini","PowdersID","value","ERROR"),0,1,$iiPos)
$TotalPowders = $ii + dec($iiCount)
$ii = $TotalPowders
Until $PowderSearch = 0
If $PowderSearch = 0 Then GUICtrlSetData($powder_box,$TotalPowders)
EndIf
EndIf
;If $opcode = "B034" Then stones are over!
If $opcode = $stonesover_packet And GUICtrlRead($LuckyStoneBox) = $GUI_CHECKED Then
$ok = ParseByte() ;->01
$type = ParseByte() ;->0F
if ($ok="01") and ($type="0F") then
$iPos = ParseByte() ;->0E
If $iPos = "0E" Then
$fusen = False
$luckon = False
$log = FileOpen("log.txt", 1)
FileWriteLine($log,@MDAY&"/"&@MON&"/"&@YEAR&" "&@HOUR&":"&@MIN&":"&@SEC&" - No more Magic stones of luck left!")
FileClose($log)
Beep(850,950)
MsgBox(0x40000,"Error","No more Magic stones of luck left!")
GUICtrlSetData($start_btn, "START")
EndIf
EndIf
EndIf
EndIf ; end of action packet!
Switch $msg
Case $GUI_Event_Close
ExitLoop
Case $HelpBtn
MsgBox(0x40000,"Help","How to use HG Fuser+ tool:"&@CRLF&@CRLF&"1. Put your Item in to 1st slot, and Lucky stone in to 2nd one (if you want to use them)."&@CRLF&"2. Choose, on which +? program should stop."&@CRLF&"3. Select Elixirs type and Lucky powders degree."&@CRLF&"4. Teleport once, to get information about elixirs and lucky powders, that will be writen in to memory. MAX number of elixirs and powders in 1 inventory slot is 255!!! Once you do teleport, DO NOT MOVE or TOUCH, elixirs or lucky powders in your inventory while you are fusing or about to fuse... Otherwise program will lose possition of you elixirs or lucky powders and will stop work (will give you error). When you must teleport again, to write new information."&@CRLF&"5. Steady and Immortal check options is case sensitive, if program cannot find any information in the item about immo or steady, it will simply stop (Checks after every fuse). If program cannot find info on your item, but its there, when please update the settings.ini file with stones codes, by using ""MSCODE finder"" program in extra folder. Note: every degree item have different codes for stones, also some items at the same degree could have different codes to, so make sure your settings.ini is updated!"&@CRLF&"6. Make sure you add correct lucky stones in second slot, it should match the Item degree! It will automaticaly add lucky stones FROM desired +. That means if you set add it from +3, it will add on +4, +5, +6 and so on... Every time before making next fuse."&@CRLF&"7. Reset button is in case if program stuck, thats because of server lag. So you wont need to restart program again, or do teleportation."&@CRLF&"8. Stop button works, but only after he complete his last fuse. Because packet injection with command to do fuse, starts once you press the button ""START"" and at the begining of load bar on loop process! So make sure you know which ""+"" you want to get before you start the program!"&@CRLF&@CRLF&"IMPORTANT!!! Do not keep this HELP window open, it is part of the script, and program wont work until you close it! Especially before you Teleport to get info of elixirs and powders, make sure this window is CLOSED!!!"&@CRLF&@CRLF&"Happy fusing!!! :)"&@CRLF&@CRLF&"Created by HardGroove @ 2013")
Case $HomeBtn
ShellExecute("http://toolsforsro.blogspot.com")
Case $stop_btn
StopFunction()
$TimeOnBtn = False
Case $start_btn
If GUICtrlRead($start_btn) = "START" And $fusen = False And $opcodecheck = True Then
$fusen = True
$luckon = True
$TimeOnBtn = True
$log = FileOpen("log.txt", 1)
FileWriteLine($log,@MDAY&"/"&@MON&"/"&@YEAR&" "&@HOUR&":"&@MIN&":"&@SEC&" - Tool is started!")
FileClose($log)
GUICtrlCreateListViewItem(@HOUR&":"&@MIN&":"&@SEC&" - Tool is started!",$liste)
_GUICtrlListView_Scroll($liste,0,20)
GUICtrlSetData($start_btn, "Fusing...")
Else
If GUICtrlRead($start_btn) = "START" Then
Beep(850,250)
MsgBox(0x40000,"Info","Please teleport at least once, to record elixirs and lucky powder info!")
EndIf
EndIf
Case $ElixirSwitch
If GUICtrlRead($ElixirSwitch) = "Weapon" Then
IniWrite("settings.ini","ElixirsID","value",IniRead("settings.ini","Elixirs","weapon",""))
If $ElixErrorSwitch = True Then
$opcodecheck = False
$ElixErrorSwitch = False
EndIf
ElseIf GUICtrlRead($ElixirSwitch) = "Protector" Then
IniWrite("settings.ini","ElixirsID","value",IniRead("settings.ini","Elixirs","protector",""))
If $ElixErrorSwitch = True Then
$opcodecheck = False
$ElixErrorSwitch = False
EndIf
ElseIf GUICtrlRead($ElixirSwitch) = "Accessory" Then
IniWrite("settings.ini","ElixirsID","value",IniRead("settings.ini","Elixirs","accessory",""))
If $ElixErrorSwitch = True Then
$opcodecheck = False
$ElixErrorSwitch = False
EndIf
ElseIf GUICtrlRead($ElixirSwitch) = "Shield" Then
IniWrite("settings.ini","ElixirsID","value",IniRead("settings.ini","Elixirs","shield",""))
If $ElixErrorSwitch = True Then
$opcodecheck = False
$ElixErrorSwitch = False
EndIf
EndIf
;Case $ResetBtn
;If GUICtrlRead($start_btn) = "Fusing..." And $fertig = False Then
;$fusen = False
;$fertig = True
;GUICtrlSetData($start_btn, "START")
;GUICtrlSetData($leiste,0)
;EndIf
Case $PowdersID
If GUICtrlRead($PowdersID) = "13" Then
IniWrite("settings.ini","PowdersID","value",IniRead("settings.ini","LuckyPowders","13D",""))
If $ElixErrorSwitch = True Then
$opcodecheck = False
$ElixErrorSwitch = False
EndIf
ElseIf GUICtrlRead($PowdersID) = "12" Then
IniWrite("settings.ini","PowdersID","value",IniRead("settings.ini","LuckyPowders","12D",""))
If $ElixErrorSwitch = True Then
$opcodecheck = False
$ElixErrorSwitch = False
EndIf
ElseIf GUICtrlRead($PowdersID) = "11" Then
IniWrite("settings.ini","PowdersID","value",IniRead("settings.ini","LuckyPowders","11D",""))
If $ElixErrorSwitch = True Then
$opcodecheck = False
$ElixErrorSwitch = False
EndIf
ElseIf GUICtrlRead($PowdersID) = "10" Then
IniWrite("settings.ini","PowdersID","value",IniRead("settings.ini","LuckyPowders","10D",""))
If $ElixErrorSwitch = True Then
$opcodecheck = False
$ElixErrorSwitch = False
EndIf
ElseIf GUICtrlRead($PowdersID) = "9" Then
IniWrite("settings.ini","PowdersID","value",IniRead("settings.ini","LuckyPowders","9D",""))
If $ElixErrorSwitch = True Then
$opcodecheck = False
$ElixErrorSwitch = False
EndIf
ElseIf GUICtrlRead($PowdersID) = "8" Then
IniWrite("settings.ini","PowdersID","value",IniRead("settings.ini","LuckyPowders","8D",""))
If $ElixErrorSwitch = True Then
$opcodecheck = False
$ElixErrorSwitch = False
EndIf
ElseIf GUICtrlRead($PowdersID) = "7" Then
IniWrite("settings.ini","PowdersID","value",IniRead("settings.ini","LuckyPowders","7D",""))
If $ElixErrorSwitch = True Then
$opcodecheck = False
$ElixErrorSwitch = False
EndIf
ElseIf GUICtrlRead($PowdersID) = "6" Then
IniWrite("settings.ini","PowdersID","value",IniRead("settings.ini","LuckyPowders","6D",""))
If $ElixErrorSwitch = True Then
$opcodecheck = False
$ElixErrorSwitch = False
EndIf
ElseIf GUICtrlRead($PowdersID) = "5" Then
IniWrite("settings.ini","PowdersID","value",IniRead("settings.ini","LuckyPowders","5D",""))
If $ElixErrorSwitch = True Then
$opcodecheck = False
$ElixErrorSwitch = False
EndIf
ElseIf GUICtrlRead($PowdersID) = "4" Then
IniWrite("settings.ini","PowdersID","value",IniRead("settings.ini","LuckyPowders","4D",""))
If $ElixErrorSwitch = True Then
$opcodecheck = False
$ElixErrorSwitch = False
EndIf
ElseIf GUICtrlRead($PowdersID) = "3" Then
IniWrite("settings.ini","PowdersID","value",IniRead("settings.ini","LuckyPowders","3D",""))
If $ElixErrorSwitch = True Then
$opcodecheck = False
$ElixErrorSwitch = False
EndIf
ElseIf GUICtrlRead($PowdersID) = "2" Then
IniWrite("settings.ini","PowdersID","value",IniRead("settings.ini","LuckyPowders","2D",""))
If $ElixErrorSwitch = True Then
$opcodecheck = False
$ElixErrorSwitch = False
EndIf
ElseIf GUICtrlRead($PowdersID) = "1" Then
IniWrite("settings.ini","PowdersID","value",IniRead("settings.ini","LuckyPowders","1D",""))
If $ElixErrorSwitch = True Then
$opcodecheck = False
$ElixErrorSwitch = False
EndIf
EndIf
EndSwitch
;Injecting packet
If $fusen = True And $fertig = True And $opcodecheck = True then
$fInterrupt = 0
$ElixErrorSwitch = True
$Timer = TimerInit()
;--------------------------------------------------------------
;Elixirs info read
$EKeyChange = IniRead("settings.ini","ElixKeyPos","value","") ;Key of possition in inventory
$PKeyChange = IniRead("settings.ini","PowdersKeyPos","value","")
;Elixirs Quantity value change
$ECountCheck = IniRead("settings.ini","ElixirsCount",$EKeyChange,"ERROR") ;check quantity
$PCountCheck = IniRead("settings.ini","PowdersCount",$PKeyChange,"ERROR")
$ECountDown = dec($ECountCheck)-1 ;-1 after every fuse
$PCountDown = dec($PCountCheck)-1
IniWrite("settings.ini","ElixirsCount",$EKeyChange,hex($ECountDown,2)) ;write new value after -1
IniWrite("settings.ini","PowdersCount",$PKeyChange,hex($PCountDown,2))
;if count = 0 then
If $ECountDown = 0 Then
IniWrite("settings.ini","ElixKeyPos","value",$EKeyChange+1) ;Switch Key pos
EndIf
If $PCountDown = 0 Then
IniWrite("settings.ini","PowdersKeyPos","value",$PKeyChange+1)
EndIf
;--------------------------------------------------------------
Local $elixirInject = IniRead("settings.ini","ElixPos",$EKeyChange,"ERROR") ;Elixirs Position
Local $powderInject = IniRead("settings.ini","PowdersPos",$PKeyChange,"ERROR") ;Powders position
If $elixirInject = "ERROR" Then
$opcodecheck = False
$fusen = False
$TimerOn = False
$luckon = False
$log = FileOpen("log.txt", 1)
FileWriteLine($log,@MDAY&"/"&@MON&"/"&@YEAR&" "&@HOUR&":"&@MIN&":"&@SEC&" - No more Elixirs left! Process is stopped...")
FileClose($log)
GUICtrlCreateListViewItem(@HOUR&":"&@MIN&":"&@SEC&" - No more Elixirs left! Process is stopped...",$liste)
_GUICtrlListView_Scroll($liste,0,20)
GUICtrlSetData($start_btn, "START")
Beep(850,950)
MsgBox(0x40000,"ERROR","No more Elixirs left!")
ElseIf $powderInject = "ERROR" Then
$opcodecheck = False
$fusen = False
$TimerOn = False
$luckon = False
$log = FileOpen("log.txt", 1)
FileWriteLine($log,@MDAY&"/"&@MON&"/"&@YEAR&" "&@HOUR&":"&@MIN&":"&@SEC&" - No more Lucky left! Process is stopped...")
FileClose($log)
GUICtrlCreateListViewItem(@HOUR&":"&@MIN&":"&@SEC&" - No more Lucky left! Process is stopped...",$liste)
_GUICtrlListView_Scroll($liste,0,20)
GUICtrlSetData($start_btn, "START")
Beep(850,950)
MsgBox(0x40000,"ERROR","No more Lucky Powders left!")
EndIf
Local $leisteupd = 0
If $fusen = True And $opcodecheck = True then
$fertig = false
$ErrorCheck = True
GUICtrlCreateListViewItem(@HOUR&":"&@MIN&":"&@SEC&" - Fusing...", $liste)
_GUICtrlListView_Scroll($liste,0,20)
InjectPacket($alchemy_packet, "0203030D"&$elixirInject&""&$powderInject)
LoadBarFunc()
EndIf
EndIf
WEnd
;==> Action functions
Func InjectPacket($opcode, $data, $security = "0100")
$size = Hex(Int(StringLen($data) / 2), 4)
$size = StringMid($size, 3, 2) & StringMid($size, 1, 2)
$opcode = StringMid($opcode, 3, 2) & StringMid($opcode, 1, 2)
$packet = _HexToString($size & $opcode & $security & $data)
TCPSend($socket, $packet)
EndFunc ;==>InjectPacket
Func ReadPacket()
$recv = Hex(Binary(TCPRecv($socket, 2)))
If $recv = "" Then
Return ""
Else
$size = Dec(StringMid($recv, 3, 2) & StringMid($recv, 1, 2))
$recv &= Hex(Binary(TCPRecv($socket, $size+4)))
Return $recv
EndIf
EndFunc ;==>ReadPacket
Func StopFunction()
If GUICtrlRead($start_btn) = "Fusing..." And $fusen = True Then
$fusen = False
$luckon = False
GUICtrlCreateListViewItem(@HOUR&":"&@MIN&":"&@SEC&" - Doing last fuse, this cannot be stopped! Why? Read help file...",$liste)
_GUICtrlListView_Scroll($liste,0,20)
GUICtrlSetData($start_btn, "START")
Else
GUICtrlCreateListViewItem(@HOUR&":"&@MIN&":"&@SEC&" - Don't be stupid, the program is not running, there is nothing to stop...",$liste)
_GUICtrlListView_Scroll($liste,0,20)
EndIf
EndFunc ;==>Stop function
Func LoadBarFunc()
Do
$leisteupd = $leisteupd + 1
GUICtrlSetData($leiste,$leisteupd)
If $fInterrupt <> 0 Then ;STOP function
Switch $fInterrupt
Case 1
GUICtrlCreateListViewItem(@HOUR&":"&@MIN&":"&@SEC&" - Tool is stoped!",$liste)
_GUICtrlListView_Scroll($liste,0,20)
EndSwitch
Return
EndIf
sleep(32)
Until $leisteupd = 100
EndFunc ;==>Load bar function
Func _WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
; The Func 2 button was pressed so set the flag
If BitAND($wParam, 0x0000FFFF) = $stop_btn Then $fInterrupt = 1
Return $GUI_RUNDEFMSG
EndFunc ;==>_WM_COMMAND
;==> Parser
Func BeginParse($buffer, $size)
Global $globalParseIndex = 1
Global $globalParseSize = $size
Global $globalParseBuffer = $buffer
EndFunc
Func ParseByte()
$result = StringMid($globalParseBuffer, $globalParseIndex, 2)
$globalParseIndex = $globalParseIndex + 2
return $result
EndFunc
Func ParseWord()
$low = ParseByte()
$hi = ParseByte()
return $hi & $low
EndFunc
Func ParseDword()
$low = ParseWord()
$hi = ParseWord()
return $hi & $low
EndFunc
Func ParseQWord()
$low = ParseDword()
$hi = ParseDword()
return $hi & $low
EndFunc