Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Mar 21st, 2010 | Syntax: None | Size: 28.63 KB | Hits: 204 | Expires: Never
Copy text to clipboard
  1. ;GWCA Interrupt Bot
  2. #RequireAdmin
  3. #include <GUIConstantsEx.au3>
  4. #include <EditConstants.au3>
  5. #include <WindowsConstants.au3>
  6. #include <StaticConstants.au3>
  7. #include <ComboConstants.au3>
  8. #include <Array.au3>
  9. #include "GWCAConstants.au3"
  10.  
  11. Opt("GUIOnEventMode", 1)
  12.  
  13. Global $cGUI = GUICreate("GWCA Tool - Interrupt Bot", 300, 250) ;GUI for communication
  14. Global $bEnabled = False ;Boolean for whether bot is enabled or not
  15. Global $fSkillSet = "gwca-skillset.ini" ;Path to skillset file
  16. Global $skillList ;Array that holds the list of normal skills
  17. Global $specialList ;Array that holds the list of special skills
  18. Global $lock = 0 ;Var that determines whether the Lock is on and who it's on
  19. Global $skillDelay = 0 ;For use with delay.
  20. Global $miss = 0 ;Miss chance thingy
  21. Global $tAfterCast[2] = [0,0] ;For not using skills while in aftercast
  22. Global $aSkillQueue[1] = [0] ;Skill Queue for the new mechanics
  23. Global $aPrioritySkill[6] ;Data of the currently prioritized skill
  24. Global $aPing[2] ;Array for saving current ping
  25. Global $tUpdatePing = 0 ;Timer for renewing ping info
  26. Global $bMiss = False ;Variable used by the Miss function
  27. Global $fSkillNames = @ScriptDir & "\new list.txt" ;Path to skillnames file
  28.  
  29. ;TAB GLOBALS
  30. Global $iTab = 1 ;Number of the current tab
  31. Global $aTabNormal[2] = ["", ""] ;Array of the normal skills
  32. Global $aTabSpecial[2] = ["", ""] ;Array of the special skills
  33. Global $aTabSkillSet[2] = ["", ""] ;Array of the current selected skill sets
  34. Global $aTabSkillmode[2] = [4, 4] ;Array of the skill mode
  35. Global $aTabSpecialLock[2] = [4, 4] ;Array of the special lock mode
  36. Global $aTabSpecialSkill[2] = ["None", "None"] ;Array of the special skill
  37. Global $aTabDelay[2] = ["", ""] ;Yeye
  38. Global $aTabNormalSkills[16] = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4] ;Yup!
  39.  
  40. GUIRegisterMsg(0x500, "WndCallback")
  41. GUIRegisterMsg(0x4A, "SkillLogCallback")
  42. GUIRegisterMsg(0x501, "SkillCancelCallback")
  43.  
  44. HotKeySet("{F5}", "LockOnOff")
  45. HotKeySet("{F6}", "BotOnOff")
  46. HotKeySet("{F7}", "DelayOnOff")
  47. ;HotKeySet("{F8}", "MissOnOff")
  48. HotKeySet("{F8}", "SwapTab")
  49.  
  50. ;# GUI SECTION #
  51. GUISetOnEvent($GUI_EVENT_CLOSE, "EventHandler")
  52.  
  53. GUISetFont(8)
  54. GUICtrlCreateMenu("")
  55. GUICtrlSetState(-1, $GUI_DISABLE)
  56. $itemSave = GUICtrlCreateMenuItem("&Save", -1)
  57. GUICtrlSetOnEvent(-1, "EventHandler")
  58. $itemDelete = GUICtrlCreateMenuItem("&Del", -1)
  59. GUICtrlSetOnEvent(-1, "EventHandler")
  60. $itemClear = GUICtrlCreateMenuItem("&Clr", -1)
  61. GUICtrlSetOnEvent(-1, "EventHandler")
  62. ;GUICtrlCreateMenuItem("", -1)
  63. $itemLock = GUICtrlCreateMenuitem("&Lock off", -1)
  64. GUICtrlSetOnEvent(-1, "EventHandler")
  65. $itemMiss = GUICtrlCreateMenuItem("&Miss off", -1)
  66. GUICtrlSetOnEvent(-1, "EventHandler")
  67. ;GUICtrlCreateMenuItem("", -1)
  68. ;$itemInfo = GUICtrlCreateMenuItem("&Help", -1)
  69. $itemTab = GUICtrlCreateMenuItem("&Swap (1)", -1)
  70. GUICtrlSetOnEvent(-1, "EventHandler")
  71. $editSkills = GUICtrlCreateEdit("", 0, 0, 300, 71, BitOR($ES_MULTILINE, $WS_VSCROLL))
  72. $editSpecial = GUICtrlCreateEdit("", 0, 100, 300, 45, BitOR($ES_MULTILINE, $WS_VSCROLL))
  73. $const_checkTop = 202
  74. $check1 = GUICtrlCreateCheckbox("1",15, $const_checkTop)
  75. $check2 = GUICtrlCreateCheckbox("2",50, $const_checkTop)
  76. $check3 = GUICtrlCreateCheckbox("3",85, $const_checkTop)
  77. $check4 = GUICtrlCreateCheckbox("4",120, $const_checkTop)
  78. $check5 = GUICtrlCreateCheckbox("5",155, $const_checkTop)
  79. $check6 = GUICtrlCreateCheckbox("6",190, $const_checkTop)
  80. $check7 = GUICtrlCreateCheckbox("7", 225, $const_checkTop)
  81. $check8 = GUICtrlCreateCheckbox("8", 260, $const_checkTop)
  82. $labelDistance = GUICtrlCreateLabel("Max distance:", 7, 178)
  83. $inputDistance = GUICtrlCreateInput("1250", 77, 175, 45, 20)
  84. $labelActivation = GUICtrlCreateLabel("Min activation:", 180, 178)
  85. $inputActivation = GUICtrlCreateInput("0.6", 253, 175, 35, 20)
  86. $checkSkillmode = GUICtrlCreateCheckbox("Attack skills", 7, 150)
  87. $checkLockmode = GUICtrlCreateCheckBox("Special lock", 90, 150)
  88. $checkDelay = GUICtrlCreateCheckbox("Delay", 130, 174)
  89. $btnOnOff = GUICtrlCreateButton("Enable bot", 225, 75, 70, 20)
  90. GUICtrlSetOnEvent(-1, "EventHandler")
  91. $comboSkillSet = GUICtrlCreateCombo("", 5, 75, 215, 20, BitOr($CBS_SORT, $GUI_SS_DEFAULT_COMBO, $CBS_DROPDOWNLIST))
  92. GUICtrlSetOnEvent(-1, "EventHandler")
  93. $labelSpecial = GUICtrlCreateLabel("Special skill: ", 176, 154)
  94. $comboSpecial = GUICtrlCreateCombo("", 238, 150, 50, 20, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_DROPDOWNLIST))
  95. GUICtrlSetData(-1, "None|1|2|3|4|5|6|7|8", "None")
  96. GUICtrlSetState($checkDelay, $GUI_CHECKED)
  97.  
  98. GUISetBkColor(0xCCCCCC)
  99. UpdateSkillsets()
  100.  
  101. GUISetState(True, $cGUI)
  102. ;# END OF GUI  #
  103.  
  104. ;# LOOP #
  105. $cbType = "int"
  106.  
  107. While 1
  108.         If TimerDiff($aPrioritySkill[5]) >= ($aPrioritySkill[2] * 1000) AND $aPrioritySkill[0] <> "" Then ClearPrioritySkill()
  109.         For $i = 1 To $aSkillQueue[0] Step 1 ;Queue handling and cleaning up
  110.                 If $i > $aSkillQueue[0] Then ExitLoop
  111.                 $aSkillInfo = SplitSkillInfo($aSkillQueue[$i])
  112.  
  113.                 If TimerDiff($aSkillInfo[5]) >= ($aSkillInfo[2] * 1000) Then DeleteSkillFromQueue($aSkillQueue, $i)
  114.                 If TimerDiff($aPrioritySkill[5]) >= ($aPrioritySkill[2] * 1000) Then
  115.                         MakePrioritySkill($aSkillInfo)
  116.                         DeleteSkillFromQueue($aSkillQueue, $i)
  117.                 EndIf
  118.                 If $aSkillInfo[4] > $aPrioritySkill[4] Then
  119.                         MakePrioritySkill($aSkillInfo)
  120.                         DeleteSkillFromQueue($aSkillQueue, $i)
  121.                 EndIf
  122.         Next
  123.  
  124.         If $bEnabled Then
  125.                 If $aPrioritySkill[0] <> "" Then
  126.                         $bUsed = False
  127.  
  128.                         If TimerDiff($tUpdatePing) > 500 Then ;Don't waste time updating ping all the time
  129.                                 $tUpdatePing = TimerInit()
  130.                                 $aPing = CmdCB($CA_GETPING)
  131.                         EndIf
  132.  
  133.                         If GUICtrlRead($checkDelay) <> 1 Then
  134.                                 $skillTime = ComputeSkillTime($aPrioritySkill, False)
  135.                                 $skillTime -= $aPing[0] / 1.25
  136.  
  137.                                 If $skillTime > 375 AND TimerDiff($skillDelay) > GetDelayMode() Then
  138.                                         CmdCB($CA_CASTING)
  139.                                         If $cbVar[0] > 0 Then $bUsed = True
  140.  
  141.                                         If Not $bUsed Then
  142.                                                 If $aPrioritySkill[4] = 2 Then ;Special skill
  143.                                                         $specialSkill = GUICtrlRead($comboSpecial) ;Load in the special skill
  144.                                                         If $specialSkill <> "None" Then ;If no special skill simply skip
  145.                                                                 CmdCB($CA_SKILLRECHARGE, $specialSkill)
  146.                                                                 If $cbVar[0] = 0 Then ;Check if recharging
  147.                                                                         Cmd(GetSkillMode(), $specialSkill, $aPrioritySkill[1]) ;Fire!
  148.                                                                         $skillDelay = TimerInit() ;Reset the skill delay timer
  149.                                                                         $bUsed = True
  150.                                                                         ClearPrioritySkill()
  151.                                                                 EndIf
  152.                                                         EndIf
  153.                                                 EndIf
  154.                                         EndIf
  155.  
  156.                                         If Not $bUsed Then
  157.                                                 For $i = 1 To 8 Step 1 ;Step through all 8 skills
  158.                                                         If GUICtrlRead(Eval("check"&$i)) = 1 Then ;If enabled then use it
  159.                                                                 $skillTime = (ComputeSkillTime($aPrioritySkill, False) - ($aPing[0] / 1.25))
  160.                                                                 If $skillTime < 370 Then
  161.                                                                         $bUsed = True
  162.                                                                         ClearPrioritySkill()
  163.                                                                         ExitLoop
  164.                                                                 EndIf
  165.                                                                 CmdCB($CA_SKILLRECHARGE, $i)
  166.                                                                 If $cbVar[0] = 0 Then ;Check if recharging
  167.                                                                         Cmd(GetSkillMode(), $i, $aPrioritySkill[1]) ;Fire!
  168.                                                                         $skillDelay = TimerInit() ;Reset the skill delay timer
  169.                                                                         $bUsed = True
  170.                                                                         ClearPrioritySkill()
  171.                                                                         ExitLoop ;You hopefully won't need to interrupt it more than once!
  172.                                                                 EndIf
  173.                                                         EndIf
  174.                                                 Next
  175.                                         EndIf
  176.                                         $bMiss = False
  177.                                 EndIf
  178.  
  179.                         Else
  180.                                 $skillTime = ComputeSkillTime($aPrioritySkill)
  181.                                 $skillTime -= $aPing[0] / 1.25
  182.  
  183.                                 If $skillTime < ComputeRuptTime($aPrioritySkill) AND $skillTime > 290 AND TimerDiff($skillDelay) > GetDelayMode() Then
  184.                                         If $miss Then
  185.                                                 If Random(1,7,1) = 1 Then
  186.                                                         $bMiss = True
  187.                                                         Do
  188.                                                                 Sleep(10)
  189.                                                         Until (ComputeSkillTime($aPrioritySkill) - ($aPing[0] / 1.25)) < 200
  190.                                                 EndIf
  191.                                         EndIf
  192.  
  193.                                         CmdCB($CA_CASTING)
  194.                                         If $cbVar[0] > 0 Then $bUsed = True
  195.  
  196.                                         If Not $bUsed Then
  197.                                                 If $aPrioritySkill[4] = 2 Then ;Special skill
  198.                                                         $specialSkill = GUICtrlRead($comboSpecial) ;Load in the special skill
  199.                                                         If $specialSkill <> "None" Then ;If no special skill simply skip
  200.                                                                 CmdCB($CA_SKILLRECHARGE, $specialSkill)
  201.                                                                 If $cbVar[0] = 0 Then ;Check if recharging
  202.                                                                         Cmd(GetSkillMode(), $specialSkill, $aPrioritySkill[1]) ;Fire!
  203.                                                                         $skillDelay = TimerInit() ;Reset the skill delay timer
  204.                                                                         $bUsed = True
  205.                                                                         ClearPrioritySkill()
  206.                                                                 EndIf
  207.                                                         EndIf
  208.                                                 EndIf
  209.                                         EndIf
  210.  
  211.                                         If Not $bUsed Then
  212.                                                 For $i = 1 To 8 Step 1 ;Step through all 8 skills
  213.                                                         If GUICtrlRead(Eval("check"&$i)) = 1 Then ;If enabled then use it
  214.                                                                 $skillTime = (ComputeSkillTime($aPrioritySkill) - ($aPing[0] / 1.25))
  215.                                                                 If $skillTime < 285 AND Not $bMiss Then
  216.                                                                         $bUsed = True
  217.                                                                         ClearPrioritySkill()
  218.                                                                         ExitLoop
  219.                                                                 EndIf
  220.                                                                 CmdCB($CA_SKILLRECHARGE, $i)
  221.                                                                 If $cbVar[0] = 0 Then ;Check if recharging
  222.                                                                         Cmd(GetSkillMode(), $i, $aPrioritySkill[1]) ;Fire!
  223.                                                                         $skillDelay = TimerInit() ;Reset the skill delay timer
  224.                                                                         $bUsed = True
  225.                                                                         ClearPrioritySkill()
  226.                                                                         ExitLoop ;You hopefully won't need to interrupt it more than once!
  227.                                                                 EndIf
  228.                                                         EndIf
  229.                                                 Next
  230.                                         EndIf
  231.                                         $bMiss = False
  232.                                 EndIf
  233.                         EndIf
  234.                 EndIf
  235.         EndIf
  236.  
  237.         Sleep(10) ;Throttle CPU
  238. WEnd
  239.  
  240. ;# FUNCTIONS #
  241. Func SkillLogCallback($hwnd, $msg, $wparam, $lparam)
  242.         Local $skillName, $bFound = 0, $specialSkill, $skillTime
  243.  
  244.         $recvCDS = DllStructCreate("ptr;dword;ptr", $lparam) ;COPYDATASTRUCT
  245.  
  246.         If DllStructGetData($recvCDS, 1) = 1 AND $bEnabled Then
  247.                 $skillStruct = DllStructCreate($tagSKILLLOGSTRUCT, DllStructGetData($recvCDS, 3))
  248.  
  249.                 If DllStructGetData($skillStruct, "Allegiance") <> 0x300 AND DllStructGetData($skillStruct, "Allegiance") <> 0x301 Then Return
  250.                 If DllStructGetData($skillStruct, "Distance") > GUICtrlRead($inputDistance) Then Return
  251.                 If DllStructGetData($skillStruct, "Activation") < GUICtrlRead($inputActivation) Then Return
  252.  
  253.                 $skillName = ReadSkillName($fSkillNames, DllStructGetData($skillStruct, "SkillId"))
  254.                 For $i = 1 To $specialList[0] Step 1
  255.                         If $skillName = $specialList[$i] Then ;Check the name against special list first (fool-proof if you have duplicates!)
  256.                                 $bFound = 2
  257.                                 ExitLoop
  258.                         EndIf
  259.                 Next
  260.                 If Not $bFound Then ;Make sure we don't overwrite the special skill if there's a duplicate :O
  261.                         For $i = 1 To $skillList[0] Step 1
  262.                                 If $skillName = $skillList[$i] Then ;Check the name of the skill against your list
  263.                                         $bFound = 1
  264.                                         ExitLoop
  265.                                 EndIf
  266.                         Next
  267.                 EndIf
  268.  
  269.                 If $lock <> 0 AND GUICtrlRead($checkLockmode) = 4 AND $bFound = 1 Then
  270.                         If $lock <> DllStructGetData($skillStruct, "AgentId") Then $bFound = 0
  271.                 ElseIf $lock = 0 AND GUICtrlRead($checkLockmode) = 4 AND $bFound = 1 Then
  272.                         $bFound = 0
  273.                 ElseIf GUICtrlRead($checkLockmode) = 1 AND $bFound = 2 Then
  274.                         If $lock = 0 OR $lock <> DllStructGetData($skillStruct, "AgentId") Then $bFound = 0
  275.                 EndIf
  276.  
  277.                 ;If GUICtrlRead($checkLockmode) = 1 AND $bFound = 2 Then
  278.                 ;       If $lock = 0 OR $lock <> DllStructGetData($skillStruct, "AgentId") Then $bFound = 0
  279.                 ;ElseIf GUICtrlRead($checkLockmode) = 4 Then
  280.                 ;       If $lock <> 0 AND $lock = DllStructGetData($skillStruct, "AgentId") Then $bFound = 2
  281.                 ;EndIf
  282.  
  283.                 If $bFound Then
  284.                         AddSkillToQueue($aSkillQueue, $skillName, DllStructGetData($skillStruct, "AgentId"), _
  285.                                 DllStructGetData($skillStruct, "Activation"), DllStructGetData($skillStruct, "Distance"), _
  286.                                 $bFound, DllStructGetData($skillStruct, "Ping"))
  287.                 EndIf
  288.         EndIf
  289.  
  290.         #cs
  291.         If DllStructGetData($recvCDS, 1) = 1 AND $bEnabled Then ;Check that bot is on and the struct is meant for our handling
  292.                 $skillStruct = DllStructCreate($tagSKILLLOGSTRUCT, DllStructGetData($recvCDS, 3)) ;LOGGEDSKILLSTRUCT
  293.  
  294.                 ;If DllStructGetData($skillStruct, "MyId") = DllStructGetData($skillStruct, "AgentId") AND DllStructGetData($skillStruct, "Activation") > 0 Then
  295.                 ;       $tAfterCast[0] = TimerInit()
  296.                 ;       $tAfterCast[1] = DllStructGetData($skillStruct, "Activation") + 750
  297.                 ;EndIf
  298.                 If DllStructGetData($skillStruct, "Casting") == 1 Then Return ;Don't fire interrupts while you're using skills youself
  299.                 If DllStructGetData($skillStruct, "Allegiance") == 0x300 Then ;Only fire interrupts at enemies (foes) doh!
  300.                         If DllStructGetData($skillStruct, "Distance") <= GUICtrlRead($inputDistance) Then ;Check that they're in the desired range
  301.                                 If DllStructGetData($skillStruct, "Activation") >= GUICtrlRead($inputActivation) Then ;Check that it's not faster than the desired activation
  302.                                         $skillName = ReadSkillName($fSkillNames, DllStructGetData($skillStruct, "SkillId")) ;Load the skill name using skill id
  303.                                         For $i = 1 To $specialList[0] Step 1
  304.                                                 If $skillName = $specialList[$i] Then ;Check the name against special list first (fool-proof if you have duplicates!)
  305.                                                         $bFound = 2
  306.                                                         ExitLoop
  307.                                                 EndIf
  308.                                         Next
  309.                                         If Not $bFound Then ;Make sure we don't overwrite the special skill if there's a duplicate :O
  310.                                                 For $i = 1 To $skillList[0] Step 1
  311.                                                         If $skillName = $skillList[$i] Then ;Check the name of the skill against your list
  312.                                                                 $bFound = 1
  313.                                                                 ExitLoop
  314.                                                         EndIf
  315.                                                 Next
  316.                                         EndIf
  317.  
  318.                                         If GUICtrlRead($checkLockmode) = 1 AND $bFound = 2 Then
  319.                                                 If $lock = 0 OR $lock <> DllStructGetData($skillStruct, "AgentId") Then $bFound = 0
  320.                                         ElseIf GUICtrlRead($checkLockmode) = 4 Then
  321.                                                 If $lock <> 0 AND $lock = DllStructGetData($skillStruct, "AgentId") Then $bFound = 2
  322.                                         EndIf
  323.  
  324.                                         If $bFound > 0 Then
  325.                                                 $skillTime = DllStructGetData($skillStruct, "Activation") * 1000
  326.                                                 $skillTime -= DllStructGetData($skillStruct, "Ping")
  327.  
  328.                                                 ;$sleepTime = CastDiff($tAfterCast)
  329.                                                 ;If $sleepTime < 0 Then
  330.                                                 ;       $sleepTime = Abs($sleepTime)
  331.                                                 ;Else
  332.                                                 ;       $sleepTime = 0
  333.                                                 ;EndIf
  334.  
  335.                                                 ;$skillTime -= $sleepTime
  336.  
  337.                                                 If $skillTime <= 250 Then Return
  338.  
  339.                                                 ;If $sleepTime > 0 Then Sleep($sleepTime)
  340.  
  341.                                                 If GUICtrlRead($checkDelay) = 1 Then ;Delay on
  342.                                                         If TimerDiff($skillDelay) < 1250 Then Return ;2700 Then Return ;Dont spam interrupts
  343.  
  344.                                                         If GUICtrlRead($checkSkillmode) = 1 Then $skillTime -= (FlightTime(DllStructGetData($skillStruct, "Distance"), 0.42) * 1000)
  345.  
  346.                                                         If $skillTime < 370 Then
  347.                                                                 Return
  348.                                                         ElseIf $skillTime > 800 Then
  349.                                                                 Sleep(450)
  350.  
  351.                                                         Else
  352.                                                                 Sleep($skillTime-370)
  353.                                                         EndIf
  354.                                                 Else
  355.                                                         If TimerDiff($skillDelay) < 1000 Then Return
  356.                                                 EndIf
  357.  
  358.                                                 If $miss Then
  359.                                                         If Random(1,7,1) = 1 Then Sleep(300)
  360.                                                 EndIf
  361.  
  362.                                                 If $bFound = 2 Then
  363.                                                         $specialSkill = GUICtrlRead($comboSpecial) ;Load in the special skill
  364.                                                         If $specialSkill <> "None" Then ;If no special skill simply skip
  365.                                                                 If DllStructGetData($skillStruct, "Recharge"&$specialSkill) = 0 Then ;Check if recharging
  366.                                                                         Cmd(GetSkillMode(), $specialSkill, DllStructGetData($skillStruct, "AgentId")) ;Fire!
  367.                                                                         $skillDelay = TimerInit() ;Reset the skill delay timer
  368.                                                                         Return ;Remember to return as we don't want to interrupt something twice
  369.                                                                 EndIf
  370.                                                         EndIf
  371.                                                 EndIf
  372.  
  373.                                                 For $i = 1 To 8 Step 1 ;Step through all 8 skills
  374.                                                         If GUICtrlRead(Eval("check"&$i)) = 1 Then ;If enabled then use it
  375.                                                                 If DllStructGetData($skillStruct, "Recharge"&$i) = 0 Then ;Check if recharging
  376.                                                                         Cmd(GetSkillMode(), $i, DllStructGetData($skillStruct, "AgentId")) ;Fire!
  377.                                                                         $skillDelay = TimerInit() ;Reset the skill delay timer
  378.                                                                         Return ;You hopefully won't need to interrupt it more than once!
  379.                                                                 EndIf
  380.                                                         EndIf
  381.                                                 Next
  382.                                         EndIf
  383.                                 EndIf
  384.                         EndIf
  385.                 EndIf
  386.         EndIf
  387.         #ce
  388. EndFunc
  389.  
  390. Func SkillCancelCallback($hwnd, $msg, $wparam, $lparam)
  391.         Local $skillName = "", $bDeleted = 0
  392.  
  393.         If $bEnabled Then
  394.                 $skillName = ReadSkillName($fSkillNames, $lparam)
  395.                 $wparam = Number($wparam)
  396.  
  397.                 If $aPrioritySkill[0] = $skillName AND $aPrioritySkill[1] = $wparam Then
  398.                         ClearPrioritySkill()
  399.                         $bDeleted += 1
  400.                         Return
  401.                 EndIf
  402.  
  403.                 For $i = 1 To $aSkillQueue[0] Step 1
  404.                         $aSkillSplit = SplitSkillInfo($aSkillQueue[$i])
  405.                         If $aSkillSplit[0] = $skillName AND $aSkillSplit[1] = $wparam Then
  406.                                 DeleteSkillFromQueue($aSkillQueue, $i)
  407.                                 $bDeleted += 1
  408.                                 Return
  409.                         EndIf
  410.                 Next
  411.         EndIf
  412. EndFunc
  413.  
  414. Func ReadSkillName($fSkillFile, $SkillId)
  415.         $SkillId = Number($SkillId) ;Convert the Id to number (from Hex, String, etc.)
  416.         If StringMid($fSkillFile, 2, 2) = ":\" OR StringMid($fSkillFile, 2, 2) = ":/" Then ;If it's a file
  417.                 $fRead = FileRead($fSkillFile) ;Read it up
  418.         Else
  419.                 $fRead = $fSkillFile ;If not, presume it's a cached list
  420.         EndIf
  421.         $fPos = StringInStr($fRead, $SkillId & "|") ;Check for existance
  422.         If Not $fPos Then Return $SkillId ;If not, return the Id
  423.  
  424.         $iNameStartPos = $fPos + StringLen($SkillId) + 1 ;Find out where the skillname starts
  425.         $nextLine = StringInStr($fRead, @CRLF, 0, 1, $iNameStartPos) ;Find out where the next line begins
  426.         $count =  $nextLine - $iNameStartPos ;Compute length of name
  427.         $sName = StringMid($fRead, $iNameStartPos, $count) ;Load it in
  428.         Return $sName
  429. EndFunc
  430.  
  431. Func UpdateSkillsets()
  432.         GUICtrlSetData($comboSkillSet, "") ;Clear the old list of skillsets
  433.  
  434.         $setNames = IniReadSectionNames($fSkillSet)
  435.         If Not @error Then
  436.                 For $i = 1 To $setNames[0] Step 1
  437.                         GUICtrlSetData($comboSkillSet, $setNames[$i])
  438.                 Next
  439.         EndIf
  440. EndFunc
  441.  
  442. Func GetSkillMode()
  443.         Switch(GUICtrlRead($checkSkillmode))
  444.                 Case 1
  445.                         Return $CA_USESKILLBARATTACKSKILL
  446.                 Case Else
  447.                         Return $CA_USESKILLBARSKILL
  448.         EndSwitch
  449. EndFunc
  450.  
  451. Func LockOnOff()
  452.         If WinActive($sGW) OR WinActive("GWCA Tool - Interrupt Bot") Then
  453.                 $cbType = "int"
  454.                 CmdCB($CA_GETCURRENTTARGET)
  455.                 If @error OR $cbVar[0] = 0 Then
  456.                         ;MsgBox(48, "No target", "Either Guild Wars ain't running, or you're simply not targetting anything!")
  457.                         $lock = 0
  458.                         GUICtrlSetData($itemLock, "Lock off")
  459.                 Else
  460.                         $lock = $cbVar[0]
  461.                         GUICtrlSetData($itemLock, "Lock on")
  462.                         Cmd($CA_STATUSBOT, 0, 1)
  463.                 EndIf
  464.                 #cs
  465.                 Switch($lock)
  466.                         Case 0
  467.                                 $cbType = "int"
  468.                                 CmdCB($CA_GETCURRENTTARGET)
  469.                                 If @error OR $cbVar[0] = 0 Then
  470.                                         ;MsgBox(48, "No target", "Either Guild Wars ain't running, or you're simply not targetting anything!")
  471.                                         $lock = 0
  472.                                         GUICtrlSetData($itemLock, "Lock off")
  473.                                 Else
  474.                                         $lock = $cbVar[0]
  475.                                         GUICtrlSetData($itemLock, "Lock on")
  476.                                         Cmd($CA_STATUSBOT, 0, 1)
  477.                                 EndIf
  478.                         Case Else
  479.                                 $lock = 0
  480.                                 GUICtrlSetData($itemLock, "Lock off")
  481.                                 Cmd($CA_STATUSBOT, 0, 2)
  482.                 EndSwitch
  483.                 #ce
  484.         Else
  485.                 HotKeySet(@HotKeyPressed)
  486.                 Send(@HotKeyPressed)
  487.                 HotKeySet(@HotKeyPressed, "LockOnOff")
  488.         EndIf
  489. EndFunc
  490.  
  491. Func BotOnOff()
  492.         If WinActive($sGW) OR WinActive("GWCA Tool - Interrupt Bot") Then
  493.                 $bEnabled = Not $bEnabled
  494.                 If $bEnabled Then
  495.                         Cmd($CA_STATUSBOT, 1, 0)
  496.                         GUICtrlSetData($btnOnOff, "Disable bot") ;Disable most of the GUI and update button text
  497.                         GUICtrlSetState($editSkills, $GUI_DISABLE)
  498.                         GUICtrlSetState($editSpecial, $GUI_DISABLE)
  499.                         GUICtrlSetState($check1, $GUI_DISABLE)
  500.                         GUICtrlSetState($check2, $GUI_DISABLE)
  501.                         GUICtrlSetState($check3, $GUI_DISABLE)
  502.                         GUICtrlSetState($check4, $GUI_DISABLE)
  503.                         GUICtrlSetState($check5, $GUI_DISABLE)
  504.                         GUICtrlSetState($check6, $GUI_DISABLE)
  505.                         GUICtrlSetState($check7, $GUI_DISABLE)
  506.                         GUICtrlSetState($check8, $GUI_DISABLE)
  507.                         GUICtrlSetState($inputActivation, $GUI_DISABLE)
  508.                         GUICtrlSetState($inputDistance, $GUI_DISABLE)
  509.                         GUICtrlSetState($comboSkillSet, $GUI_DISABLE)
  510.                         GUICtrlSetState($itemSave, $GUI_DISABLE)
  511.                         GUICtrlSetState($itemDelete, $GUI_DISABLE)
  512.                         GUICtrlSetState($itemClear, $GUI_DISABLE)
  513.                         ;GUICtrlSetState($itemInfo, $GUI_DISABLE)
  514.                         GUICtrlSetState($checkSkillmode, $GUI_DISABLE)
  515.                         GUICtrlSetState($comboSpecial, $GUI_DISABLE)
  516.                         GUICtrlSetState($checkLockmode, $GUI_DISABLE)
  517.                         $skillList = StringSplit(GUICtrlRead($editSkills), ",") ;Split skills by delimiter ,
  518.                         $specialList = StringSplit(GUICtrlRead($editSpecial), ",") ;Same
  519.                         For $i = 1 To $skillList[0] Step 1 ;Loop through to remove all odd spaces
  520.                                 Do
  521.                                         If StringLeft($skillList[$i], 1) = " " Then $skillList[$i] = StringTrimLeft($skillList[$i], 1)
  522.                                         If StringRight($skillList[$i], 1) = " " Then $skillList[$i] = StringTrimRight($skillList[$i], 1)
  523.                                 Until StringLeft($skillList[$i], 1) <> " " AND StringRight($skillList[$i], 1) <> " "
  524.                         Next
  525.                         For $i = 1 To $specialList[0] Step 1 ;Exactly the same
  526.                                 Do
  527.                                         If StringLeft($specialList[$i], 1) = " " Then $specialList[$i] = StringTrimLeft($specialList[$i], 1)
  528.                                         If StringRight($specialList[$i], 1) = " " Then $specialList[$i] = StringTrimRight($specialList[$i], 1)
  529.                                 Until StringLeft($specialList[$i], 1) <> " " AND StringRight($specialList[$i], 1) <> " "
  530.                         Next
  531.                         Cmd($CA_SETLOGANDHWND, 1, $cGUI) ;Turn the baby on!
  532.  
  533.                 Else
  534.                         Cmd($CA_SETLOGANDHWND, 0, 0) ;Turn her off :\
  535.                         Cmd($CA_STATUSBOT, 2, 0)
  536.                         GUICtrlSetData($btnOnOff, "Enable bot") ;Enable the GUI and update button text
  537.                         GUICtrlSetState($editSkills, $GUI_ENABLE)
  538.                         GUICtrlSetState($editSpecial, $GUI_ENABLE)
  539.                         GUICtrlSetState($check1, $GUI_ENABLE)
  540.                         GUICtrlSetState($check2, $GUI_ENABLE)
  541.                         GUICtrlSetState($check3, $GUI_ENABLE)
  542.                         GUICtrlSetState($check4, $GUI_ENABLE)
  543.                         GUICtrlSetState($check5, $GUI_ENABLE)
  544.                         GUICtrlSetState($check6, $GUI_ENABLE)
  545.                         GUICtrlSetState($check7, $GUI_ENABLE)
  546.                         GUICtrlSetState($check8, $GUI_ENABLE)
  547.                         GUICtrlSetState($inputActivation, $GUI_ENABLE)
  548.                         GUICtrlSetState($inputDistance, $GUI_ENABLE)
  549.                         GUICtrlSetState($comboSkillSet, $GUI_ENABLE)
  550.                         GUICtrlSetState($itemSave, $GUI_ENABLE)
  551.                         GUICtrlSetState($itemDelete, $GUI_ENABLE)
  552.                         GUICtrlSetState($itemClear, $GUI_ENABLE)
  553.                         ;GUICtrlSetState($itemInfo, $GUI_ENABLE)
  554.                         GUICtrlSetState($checkSkillmode, $GUI_ENABLE)
  555.                         GUICtrlSetState($comboSpecial, $GUI_ENABLE)
  556.                         GUICtrlSetState($checkLockmode, $GUI_ENABLE)
  557.                 EndIf
  558.         Else
  559.                 HotKeySet(@HotKeyPressed)
  560.                 Send(@HotKeyPressed)
  561.                 HotKeySet(@HotKeyPressed, "BotOnOff")
  562.         EndIf
  563. EndFunc
  564.  
  565. Func DelayOnOff()
  566.         If WinActive($sGW) OR WinActive("GWCA Tool - Interrupt Bot") Then
  567.                 If GUICtrlRead($checkDelay) = 1 Then
  568.                         Cmd($CA_STATUSDELAY, 0)
  569.                         GUICtrlSetState($checkDelay, $GUI_UNCHECKED)
  570.                 Else
  571.                         Cmd($CA_STATUSDELAY, 1)
  572.                         GUICtrlSetState($checkDelay, $GUI_CHECKED)
  573.                 EndIf
  574.         Else
  575.                 HotKeySet(@HotKeyPressed)
  576.                 Send(@HotKeyPressed)
  577.                 HotKeySet(@HotKeyPressed, "BotOnOff")
  578.         EndIf
  579. EndFunc
  580.  
  581. Func MissOnOff()
  582.         If WinActive($sGW) OR WinActive("GWCA Tool - Interrupt Bot") Then
  583.                 If $miss Then
  584.                         $miss = Not $miss
  585.                         Cmd($CA_STATUSMISS, 0)
  586.                         GUICtrlSetData($itemMiss, "Miss off")
  587.                 Else
  588.                         $miss = Not $miss
  589.                         Cmd($CA_STATUSMISS, 1)
  590.                         GUICtrlSetData($itemMiss, "Miss on")
  591.                 EndIf
  592.         Else
  593.                 HotKeySet(@HotKeyPressed)
  594.                 Send(@HotKeyPressed)
  595.                 HotKeySet(@HotKeyPressed, "BotOnOff")
  596.         EndIf
  597. EndFunc
  598.  
  599. Func FlightTime($distance, $bowTime = 0.42)
  600.         Return $distance / 1000 * $bowTime
  601. EndFunc
  602.  
  603. Func CastDiff($aCastTime)
  604.         If Not IsArray($aCastTime) Then Return 0
  605.         Return TimerDiff($aCastTime[0]) - $aCastTime[1]
  606. EndFunc
  607.  
  608. Func ClearQueue(ByRef $aQueue)
  609.         If Not IsArray($aQueue) Then Return 0
  610.  
  611.         Dim $aQueue[1] = [0]
  612.  
  613.         Return 1
  614. EndFunc
  615.  
  616. Func AddSkillToQueue(ByRef $aQueue, $iSkill, $iAgent, $fActivation, $fDistance, $iPriority, $iPing)
  617.         If Not IsArray($aQueue) Then Return 0
  618.  
  619.         $aQueue[0] += 1
  620.         ReDim $aQueue[$aQueue[0]+1]
  621.         $aQueue[$aQueue[0]] = $iSkill&","&$iAgent&","&$fActivation&","&$fDistance&","&$iPriority&","&TimerInit()&","&$iPing
  622.  
  623.         Return 1
  624. EndFunc
  625.  
  626. Func SplitSkillInfo($sSkillInfo)
  627.         Return StringSplit($sSkillInfo, ",", 2)
  628. EndFunc
  629.  
  630. Func DeleteSkillFromQueue(ByRef $aQueue, $iIndex)
  631.         If Not IsArray($aQueue) Then Return 0
  632.         If $iIndex > $aQueue[0] Then Return 0
  633.         $aQueue[0] -= 1
  634.         Return _ArrayDelete($aQueue, $iIndex)
  635. EndFunc
  636.  
  637. Func MakePrioritySkill($aSkillInfo)
  638.         $aPrioritySkill = $aSkillInfo
  639. EndFunc
  640.  
  641. Func ClearPrioritySkill()
  642.         $aPrioritySkill[0] = ""
  643.         For $i = 1 To UBound($aPrioritySkill)-1 Step 1
  644.                 $aPrioritySkill[$i] = 0
  645.         Next
  646. EndFunc
  647.  
  648. Func GetDelayMode()
  649.         Switch(GUICtrlRead($checkDelay))
  650.                 Case 1
  651.                         Return 1600
  652.                 Case Else
  653.                         Return 1400
  654.         EndSwitch
  655. EndFunc
  656.  
  657. Func ComputeSkillTime($aSkill, $bReduceLong = True)
  658.         If Not IsArray($aSkill) Then Return -1
  659.         Local $iTime
  660.  
  661.         $iTime = ($aSkill[2] * 1000) - 50
  662.         $iTime -= TimerDiff($aSkill[5])
  663.         If GUICtrlRead($checkSkillmode) = 1 Then $iTime -= (FlightTime($aSkill[3], 0.41) * 1000)
  664.  
  665.         Return $iTime
  666. EndFunc
  667.  
  668. Func ComputeRuptTime($aSkill)
  669.         Select
  670.                 Case ($aSkill[2] * 1000) < 800
  671.                         Return 335
  672.                 Case ($aSkill[2] * 1000) < 1100
  673.                         Return 520
  674.                 Case ($aSkill[2] * 1000) < 2100
  675.                         Return 700
  676.                 Case Else
  677.                         Return 800
  678.         EndSelect
  679. EndFunc
  680.  
  681. Func LoadTab($iTab)
  682.         Local $i = $iTab -1
  683.  
  684.         GUICtrlSetData($editSkills, $aTabNormal[$i])
  685.         GUICtrlSetData($editSpecial, $aTabSpecial[$i])
  686.         If $aTabSkillSet[$i] <> "" Then GUICtrlSetData($comboSkillSet, $aTabSkillSet[$i])
  687.         GUICtrlSetState($checkSkillmode, $aTabSkillmode[$i])
  688.         GUICtrlSetState($checkLockmode, $aTabSpecialLock[$i])
  689.         GUICtrlSetData($comboSpecial, $aTabSpecialSkill[$i])
  690.         GUICtrlSetState($checkDelay, $aTabDelay[$i])
  691.  
  692.         For $j = 1 To 8 Step 1
  693.                 GUICtrlSetState(Eval("check"&$j), $aTabNormalSkills[$j + ($i * 8) - 1])
  694.         Next
  695. EndFunc
  696.  
  697. Func SwapTab()
  698.         If WinActive($sGW) OR WinActive("GWCA Tool - Interrupt Bot") Then
  699.                 If $iTab = 1 Then
  700.                         $iTab = 2
  701.                         $aTabNormal[0] = GUICtrlRead($editSkills)
  702.                         $aTabSpecial[0] = GUICtrlRead($editSpecial)
  703.                         $aTabSkillSet[0] = GUICtrlRead($comboSkillSet)
  704.                         $aTabSkillmode[0] = GUICtrlRead($checkSkillmode)
  705.                         $aTabSpecialLock[0] = GUICtrlRead($checkLockmode)
  706.                         $aTabSpecialSkill[0] = GUICtrlRead($comboSpecial)
  707.                         $aTabDelay[0] = GUICtrlRead($checkDelay)
  708.                         For $i = 1 To 8 Step 1
  709.                                 $aTabNormalSkills[$i-1] = GUICtrlRead(Eval("check"&$i))
  710.                         Next
  711.  
  712.                 ElseIf $iTab = 2 Then
  713.                         $iTab = 1
  714.                         $aTabNormal[1] = GUICtrlRead($editSkills)
  715.                         $aTabSpecial[1] = GUICtrlRead($editSpecial)
  716.                         $aTabSkillSet[1] = GUICtrlRead($comboSkillSet)
  717.                         $aTabSkillmode[1] = GUICtrlRead($checkSkillmode)
  718.                         $aTabSpecialLock[1] = GUICtrlRead($checkLockmode)
  719.                         $aTabSpecialSkill[1] = GUICtrlRead($comboSpecial)
  720.                         $aTabDelay[1] = GUICtrlRead($checkDelay)
  721.                         For $i = 1 To 8 Step 1
  722.                                 $aTabNormalSkills[$i+7] = GUICtrlRead(Eval("check"&$i))
  723.                         Next
  724.                 EndIf
  725.  
  726.                 For $i = 1 To $aSkillQueue[0] Step 1
  727.                         DeleteSkillFromQueue($aSkillQueue, 1)
  728.                 Next
  729.  
  730.                 GUICtrlSetData($itemTab, "Swap ("&$iTab&")")
  731.                 LoadTab($iTab)
  732.                 Cmd($CA_STATUSTAB, $iTab)
  733.         Else
  734.                 HotKeySet(@HotKeyPressed)
  735.                 Send(@HotKeyPressed)
  736.                 HotKeySet(@HotKeyPressed, "BotOnOff")
  737.         EndIf
  738. EndFunc
  739.  
  740. Func EventHandler()
  741.         Switch(@GUI_CtrlId)
  742.                 Case $GUI_EVENT_CLOSE
  743.                         Exit
  744.  
  745.                 Case $itemLock
  746.                         LockOnOff()
  747.  
  748.                 Case $itemMiss
  749.                         MissOnOff()
  750.  
  751.                 Case $itemClear
  752.                         Select
  753.                         Case GUICtrlRead($editSkills) <> "" OR GUICtrlRead($editSpecial) <> ""
  754.                                 $bGoThrough = MsgBox(1, "Clear skills", "Are you sure you want to clear the current skills?")
  755.                                 If $bGoThrough = 1 Then
  756.                                         GUICtrlSetData($editSkills, "")
  757.                                         GUICtrlSetData($editSpecial, "")
  758.                                         UpdateSkillsets()
  759.                                 EndIf
  760.                         Case Else
  761.                                 MsgBox(48, "No skills to clear", "You cannot clear the current skills when there are none!")
  762.                         EndSelect
  763.  
  764.                 Case $itemSave
  765.                         Select
  766.                         Case GUICtrlRead($editSkills) <> "" OR GUICtrlRead($editSpecial) <> ""
  767.                                 $sSetName = InputBox("Save skillset", "Please enter a name for the skillset you're saving", GUICtrlRead($comboSkillSet))
  768.                                 Select
  769.                                 Case Not @error AND $sSetName <> ""
  770.                                         IniWrite($fSkillSet, $sSetName, "Skills", GUICtrlRead($editSkills))
  771.                                         IniWrite($fSkillSet, $sSetName, "Special", GUICtrlRead($editSpecial))
  772.                                         UpdateSkillsets()
  773.                                         GUICtrlSetData($comboSkillSet, $sSetName)
  774.                                 Case $sSetName = "" AND Not @error
  775.                                         MsgBox(48, "No name", "You forgot to specify a name for the skillset!")
  776.                                 EndSelect
  777.                         Case Else
  778.                                 MsgBox(48, "No skills written", "You didn't write any skills into any of the lists!")
  779.                         EndSelect
  780.  
  781.                 Case $itemDelete
  782.                         Select
  783.                         Case GUICtrlRead($comboSkillSet) <> ""
  784.                                 $bGoThrough = MsgBox(1, "Delete skillset", "Are you sure you want to delete skillset "&GUICtrlRead($comboSkillSet)&"?")
  785.                                 If $bGoThrough = 1 Then
  786.                                         IniDelete($fSkillSet, GUICtrlRead($comboSkillSet))
  787.                                         UpdateSkillsets()
  788.                                 EndIf
  789.                         Case Else
  790.                                 MsgBox(48, "No skillset selected", "You have to select the skillset you wish to delete!")
  791.                         EndSelect
  792.  
  793.                 ;Case $itemInfo
  794.                 ;       MsgBox(0, "Help", "If you really fail so much that you need help for understanding this tool then you fail!"&@LF& _
  795.                 ;                       "Only thing that you really need to know is that the upper editbox (the biggest) is for the ""normal"" skills and the lower one (the smallest)"& _
  796.                 ;                       " is for the ""special"" skills that need special treatment xD"&@LF&@LF& _
  797.                 ;                       "Common distances:"&@LF&"Melee = 150, Aggro = 1012, Spell = 1247, Recurve = 1250, Longbow = 1450"&@LF&@LF& _
  798.                 ;                       "The lock mechanism is very advanced and has two modes. Use wisely.")
  799.  
  800.                 Case $itemTab
  801.                         SwapTab()
  802.  
  803.                 Case $comboSkillSet
  804.                         GUICtrlSetData($editSkills, IniRead($fSkillSet, GUICtrlRead($comboSkillSet), "Skills", ""))
  805.                         GUICtrlSetData($editSpecial, IniRead($fSkillSet, GUICtrlRead($comboSkillSet), "Special", ""))
  806.  
  807.                 Case $btnOnOff
  808.                         BotOnOff()
  809.         EndSwitch
  810. EndFunc