From 535ab858a13646c9825f7486ec6e250da4c647ee Mon Sep 17 00:00:00 2001 From: Joshua Sigona Date: Wed, 10 Jun 2020 23:23:22 +0900 Subject: [PATCH] Properly stop crafting recipe if the crafting window pops up prematurely. Disallow key presses during this time. --- autocraft.ahk | 52 +++++++++++++++++++++++++++++--------------------- autocraft.exe | Bin 1129472 -> 1129472 bytes 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/autocraft.ahk b/autocraft.ahk index 71d3722..2acf342 100644 --- a/autocraft.ahk +++ b/autocraft.ahk @@ -155,8 +155,8 @@ WaitForReady() { loop { Stdout("Waiting for Ready...") sleep, 250 - } until (ActionReady() or !toggle) - if (!toggle) { + } until (ActionReady() or !toggle or CraftingWindowOpen()) + if (!toggle or CraftingWindowOpen()) { return false } else { return true @@ -296,11 +296,11 @@ StrongCraft60(ByRef STEP) { loop { if (IsMaxQuality()) { - STEP := 99 - RECIPEDONE := true Veneration(STEP,CP,DURABILITY,0) BasicSynthesis(STEP,CP,DURABILITY,0) BasicSynthesis(STEP,CP,DURABILITY) + STEP := 99 + RECIPEDONE := true } Switch STEP { @@ -462,7 +462,7 @@ CraftingRotation(ByRef STEP) { SkillTemplate(ByRef STEP,ByRef CP,ByRef DURABILITY,stepcount=1) { ;Optionally remove DURABILITY IF NOT REQUIRED. CPCOST := 18 ;CP Cost goes here. DURABILITYCOST := ModDurability(0) ;Durability Cost goes inside ModDurability. - if (CP >= CPCOST and DURABILITY >= DURABILITYCOST) { ;To prevent a touch from destroying an item, change >= to > + if (CP >= CPCOST and DURABILITY >= DURABILITYCOST and KeyPressAllowed()) { ;To prevent a touch from destroying an item, change >= to > send, {5} ;Use PressKeyWithModifier("Ctrl","1") for modifiers. ProgressStep(STEP,CP,CPCOST,stepcount) DURABILITY := DURABILITY - DURABILITYCOST @@ -476,7 +476,7 @@ Veneration(ByRef STEP,ByRef CP,ByRef DURABILITY,stepcount=1) { global VENERATION CPCOST := 18 ;CP Cost goes here. DURABILITYCOST := ModDurability(0) ;Durability Cost goes here. - if (CP >= CPCOST and DURABILITY >= DURABILITYCOST) { + if (CP >= CPCOST and DURABILITY >= DURABILITYCOST and KeyPressAllowed()) { PressKeyWithModifier("Shift","1") ;Use PressKeyWithModifier("Ctrl","1") for modifiers. ProgressStep(STEP,CP,CPCOST,stepcount) DURABILITY := DURABILITY - DURABILITYCOST @@ -491,7 +491,7 @@ GreatStrides(ByRef STEP,ByRef CP,ByRef DURABILITY,stepcount=1) { global GREATSTRIDES CPCOST := 32 ;CP Cost goes here. DURABILITYCOST := ModDurability(0) ;Durability Cost goes here. - if (CP >= CPCOST and DURABILITY >= DURABILITYCOST) { + if (CP >= CPCOST and DURABILITY >= DURABILITYCOST and KeyPressAllowed()) { PressKeyWithModifier("Ctrl","5") ;Use PressKeyWithModifier("Ctrl","1") for modifiers. ProgressStep(STEP,CP,CPCOST,stepcount) DURABILITY := DURABILITY - DURABILITYCOST @@ -506,7 +506,7 @@ HastyTouch(ByRef STEP,ByRef CP,ByRef DURABILITY,stepcount=1) { global GREATSTRIDES CPCOST := ModDurability(0) ;CP Cost goes here. DURABILITYCOST := ModDurability(10) ;Durability Cost goes here. - if (CP >= CPCOST and DURABILITY > DURABILITYCOST) { + if (CP >= CPCOST and DURABILITY > DURABILITYCOST and KeyPressAllowed()) { PressKeyWithModifier("Ctrl","3") ;Use PressKeyWithModifier("Ctrl","1") for modifiers. ProgressStep(STEP,CP,CPCOST,stepcount) DURABILITY := DURABILITY - DURABILITYCOST @@ -521,7 +521,7 @@ Innovation(ByRef STEP,ByRef CP,ByRef DURABILITY,stepcount=1) { global INNOVATION CPCOST := 18 ;CP Cost goes here. DURABILITYCOST := ModDurability(0) ;Durability Cost goes here. - if (CP >= CPCOST and DURABILITY >= DURABILITYCOST) { + if (CP >= CPCOST and DURABILITY >= DURABILITYCOST and KeyPressAllowed()) { send, {4} ;Use PressKeyWithModifier("Ctrl","1") for modifiers. ProgressStep(STEP,CP,CPCOST,stepcount) DURABILITY := DURABILITY - DURABILITYCOST @@ -535,7 +535,7 @@ Innovation(ByRef STEP,ByRef CP,ByRef DURABILITY,stepcount=1) { MastersMend(ByRef STEP,ByRef CP,ByRef DURABILITY,stepcount=1) { CPCOST := 88 ;CP Cost goes here. DURABILITYCOST := -30 ;Durability Cost goes here. - if (CP >= CPCOST and DURABILITY >= DURABILITYCOST) { + if (CP >= CPCOST and DURABILITY >= DURABILITYCOST and KeyPressAllowed()) { send, {3} ;Use PressKeyWithModifier("Ctrl","1") for modifiers. ProgressStep(STEP,CP,CPCOST,stepcount) DURABILITY := DURABILITY - DURABILITYCOST @@ -549,7 +549,7 @@ MastersMend(ByRef STEP,ByRef CP,ByRef DURABILITY,stepcount=1) { Observe(ByRef STEP,ByRef CP,ByRef DURABILITY,stepcount=1) { CPCOST := 7 ;CP Cost goes here. DURABILITYCOST := ModDurability(0) ;Durability Cost goes here. - if (CP >= CPCOST and DURABILITY >= DURABILITYCOST) { + if (CP >= CPCOST and DURABILITY >= DURABILITYCOST and KeyPressAllowed()) { PressKeyWithModifier("Ctrl","X") ;Use PressKeyWithModifier("Ctrl","1") for modifiers. ProgressStep(STEP,CP,CPCOST,stepcount) DURABILITY := DURABILITY - DURABILITYCOST @@ -562,7 +562,7 @@ Observe(ByRef STEP,ByRef CP,ByRef DURABILITY,stepcount=1) { BrandOfTheElements(ByRef STEP,ByRef CP,ByRef DURABILITY,stepcount=1) { CPCOST := 6 ;CP Cost goes here. DURABILITYCOST := ModDurability(10) ;Durability Cost goes here. - if (CP >= CPCOST) { + if (CP >= CPCOST and KeyPressAllowed()) { PressKeyWithModifier("Ctrl","X") ;Use PressKeyWithModifier("Ctrl","1") for modifiers. ProgressStep(STEP,CP,CPCOST,stepcount) DURABILITY := DURABILITY - DURABILITYCOST @@ -576,7 +576,7 @@ NameOfTheElements(ByRef STEP,ByRef CP,ByRef DURABILITY,stepcount=1) { global NAMEOFTHEELEMENTS CPCOST := 30 ;CP Cost goes here. DURABILITYCOST := ModDurability(0) ;Durability Cost goes here. - if (CP >= CPCOST and DURABILITY >= DURABILITYCOST) { + if (CP >= CPCOST and DURABILITY >= DURABILITYCOST and KeyPressAllowed()) { PressKeyWithModifier("Ctrl","Z") ;Use PressKeyWithModifier("Ctrl","1") for modifiers. ProgressStep(STEP,CP,CPCOST,stepcount) DURABILITY := DURABILITY - DURABILITYCOST @@ -591,7 +591,7 @@ FinalAppraisal(ByRef STEP,ByRef CP,ByRef DURABILITY,stepcount=1) { global FINALAPPRAISAL CPCOST := 1 ;CP Cost goes here. DURABILITYCOST := ModDurability(0) ;Durability Cost goes here. - if (CP >= CPCOST and DURABILITY >= DURABILITYCOST) { + if (CP >= CPCOST and DURABILITY >= DURABILITYCOST and KeyPressAllowed()) { PressKeyWithModifier("Alt","1") ;Use PressKeyWithModifier("Ctrl","1") for modifiers. ProgressStep(STEP,CP,CPCOST,stepcount) DURABILITY := DURABILITY - DURABILITYCOST @@ -606,7 +606,7 @@ RapidSynthesis(ByRef STEP,ByRef CP,ByRef DURABILITY,stepcount=1) { global GREATSTRIDES CPCOST := 0 ;CP Cost goes here. DURABILITYCOST := ModDurability(10) ;Durability Cost goes here. - if (CP >= CPCOST) { + if (CP >= CPCOST and KeyPressAllowed()) { PressKeyWithModifier("Shift","4") ;Use PressKeyWithModifier("Ctrl","1") for modifiers. ProgressStep(STEP,CP,CPCOST,stepcount) DURABILITY := DURABILITY - DURABILITYCOST @@ -622,7 +622,7 @@ StandardTouch(ByRef STEP,ByRef CP,ByRef DURABILITY,stepcount=1) { CPCOST := 18 ;CP Cost goes here. DURABILITYCOST := ModDurability(10) ;Durability Cost goes here. Stdout(CPCOST . "/" . DURABILITYCOST . "/" . CP . "/" . DURABILITY) - if (CP >= CPCOST and DURABILITY > DURABILITYCOST) { + if (CP >= CPCOST and DURABILITY > DURABILITYCOST and KeyPressAllowed()) { PressKeyWithModifier("Shift","2") ;Use PressKeyWithModifier("Ctrl","1") for modifiers. ProgressStep(STEP,CP,CPCOST,stepcount) DURABILITY := DURABILITY - DURABILITYCOST @@ -637,7 +637,7 @@ BasicTouch(ByRef STEP,ByRef CP,ByRef DURABILITY,stepcount=1) { global GREATSTRIDES CPCOST := 18 ;CP Cost goes here. DURABILITYCOST := ModDurability(10) ;Durability Cost goes here. - if (CP >= CPCOST and DURABILITY > DURABILITYCOST) { + if (CP >= CPCOST and DURABILITY > DURABILITYCOST and KeyPressAllowed()) { send, {2} ;Use PressKeyWithModifier("Ctrl","1") for modifiers. ProgressStep(STEP,CP,CPCOST,stepcount) DURABILITY := DURABILITY - DURABILITYCOST @@ -651,7 +651,7 @@ BasicTouch(ByRef STEP,ByRef CP,ByRef DURABILITY,stepcount=1) { BasicSynthesis(ByRef STEP,ByRef CP,ByRef DURABILITY,stepcount=1) { CPCOST := 0 ;CP Cost goes here. DURABILITYCOST := ModDurability(10) ;Durability Cost goes here. - if (CP >= CPCOST) { + if (CP >= CPCOST and KeyPressAllowed()) { send, {1} ;Use PressKeyWithModifier("Ctrl","1") for modifiers. ProgressStep(STEP,CP,CPCOST,stepcount) DURABILITY := DURABILITY - DURABILITYCOST @@ -664,7 +664,7 @@ BasicSynthesis(ByRef STEP,ByRef CP,ByRef DURABILITY,stepcount=1) { InnerQuiet(ByRef STEP,ByRef CP,ByRef DURABILITY,stepcount=1) { CPCOST := 18 DURABILITYCOST := ModDurability(0) ;Durability Cost goes here. - if (CP >= CPCOST and DURABILITY >= DURABILITYCOST) { + if (CP >= CPCOST and DURABILITY >= DURABILITYCOST and KeyPressAllowed()) { send, {5} ProgressStep(STEP,CP,CPCOST,stepcount) DURABILITY := DURABILITY - DURABILITYCOST @@ -678,7 +678,7 @@ WasteNot(ByRef STEP,ByRef CP,ByRef DURABILITY,stepcount=1) { global WASTENOT CPCOST := 56 DURABILITYCOST := ModDurability(0) ;Durability Cost goes here. - if (CP >= CPCOST and DURABILITY >= DURABILITYCOST) { + if (CP >= CPCOST and DURABILITY >= DURABILITYCOST and KeyPressAllowed()) { PressKeyWithModifier("Ctrl","1") ProgressStep(STEP,CP,CPCOST,stepcount) DURABILITY := DURABILITY - DURABILITYCOST @@ -694,7 +694,7 @@ WasteNotII(ByRef STEP,ByRef CP,ByRef DURABILITY,stepcount=1) { global WASTENOT CPCOST := 98 DURABILITYCOST := ModDurability(0) ;Durability Cost goes here. - if (CP >= CPCOST and DURABILITY >= DURABILITYCOST) { + if (CP >= CPCOST and DURABILITY >= DURABILITYCOST and KeyPressAllowed()) { PressKeyWithModifier("Ctrl","4") ProgressStep(STEP,CP,CPCOST,stepcount) DURABILITY := DURABILITY - DURABILITYCOST @@ -728,7 +728,7 @@ PressKeyWithModifier(modifier,key) { } TricksOfTheTrade(ByRef cp) { - if IsGood() { + if (IsGood() and KeyPressAllowed()) { PressKeyWithModifier("Ctrl","2") cp += 20 loop { @@ -749,6 +749,14 @@ ActionReady() { } } +KeyPressAllowed() { + if (!CraftingWindowOpen()) { + return true + } else { + return false + } +} + CraftingWindowOpen() { PixelGetColor,ScreenCol,1283,655 diff --git a/autocraft.exe b/autocraft.exe index 5a79b794eb0aa77eada30e57431b2e181e8cb9fe..5a2f47631a142d446c79bd7d01e6e4cb6f251560 100644 GIT binary patch delta 280 zcmZqp;nMKKWy2aq#ub~_GFk(v=9f(EFPRvD7(_DzF$)m00x=s9vjZ^)5OV@C7Z7s; zF%J;)0x=&D^KXC2Byf60?gcLfh9@ixU|?}akih`Rg7Gted=Vsm4H|y}8h;5Ie+Q8N zhY?}kmhFmj1RSC@74nM|oQo3EN;31(!!z?z^2_}TQu8!4HMug=6f_h|^3&6EQbCHQ o&;2SOzrFIifC%T*)q