From 4e4241b722067a521ee71b827506851212027c97 Mon Sep 17 00:00:00 2001 From: Hellrage Date: Mon, 24 Jan 2022 16:21:25 +0300 Subject: [PATCH] Updated the mod to use Bezel's keybinds. Fixed a typo in private mod instance name. --- Autocast.as3proj | 2 +- Changelog.txt | 6 ++++- README.md | 4 ++-- src/Autocast/AutocastMod.as | 14 ++++++------ src/Autocast/GCFWAutocast.as | 43 +++++++++++++++++++++++++++--------- 5 files changed, 47 insertions(+), 22 deletions(-) diff --git a/Autocast.as3proj b/Autocast.as3proj index e6c71f5..0473bd4 100644 --- a/Autocast.as3proj +++ b/Autocast.as3proj @@ -4,7 +4,7 @@ - + diff --git a/Changelog.txt b/Changelog.txt index 83f061e..99e31b1 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,6 +1,10 @@ 15.10.2020 v1.2 for 1.1.2b Thanks to piepie62's contribution there is now support for enchancement spells and visuals for both strike spell ranges and enchancement spell markers. + 20.01.2022 v1.3 Now resets the markers when entering \ restarting a stage. Also doesn't bind to enterFrame because we don't need to be running out-of-stage - Updated to Bezel 1.x \ No newline at end of file + Updated to Bezel 1.x + +24.01.2022 v1.4 + Updated to use Bezel's keybinds. \ No newline at end of file diff --git a/README.md b/README.md index e7266a3..62d60c1 100644 --- a/README.md +++ b/README.md @@ -18,10 +18,10 @@ https://github.com/gemforce-team/Autocast/blob/master/Changelog.txt ## Usage -* Press `Ctrl + 1/2/3/4/5/6` to enter marker placement mode for that strike spell. The only indication that you've done so is a floating text message. +* Press `Ctrl + Cast Spell Button` to enter marker placement mode for that strike spell. The only indication that you've done so is a floating text message. * Leftclick the desired point on the playing field, an invisible marker will be placed there. Again, you'll receive confirmation vie a floating text message. * From that point on the respective spell will be cast on that position every time it reaches max charge. (Cast attempts happen every 15 frames) -* To remove a marker, enter marker placement mode with `Ctrl + 1/2/3/4/5/6`, then rightclick. +* To remove a marker, enter marker placement mode with `Ctrl + Cast Spell Button`, then rightclick. * **Please not that at the moment markers are not reset when you enter a new level, you'll have to (re)move them individually** diff --git a/src/Autocast/AutocastMod.as b/src/Autocast/AutocastMod.as index d5e011c..451c0b7 100644 --- a/src/Autocast/AutocastMod.as +++ b/src/Autocast/AutocastMod.as @@ -12,11 +12,11 @@ package Autocast public class AutocastMod extends MovieClip implements BezelMod { - public function get VERSION():String { return "1.3"; } - public function get BEZEL_VERSION():String { return "1.0.0"; } + public function get VERSION():String { return "1.4"; } + public function get BEZEL_VERSION():String { return "1.0.1"; } public function get MOD_NAME():String { return "Autocast"; } - private var manaMason:Object; + private var autoCast:Object; internal static var bezel:Bezel; internal static var logger:Logger; @@ -37,16 +37,16 @@ package Autocast logger = bezel.getLogger("Autocast"); if (bezel.mainLoader is GCFWBezel) { - manaMason = new GCFWAutocast(); + autoCast = new GCFWAutocast(); } } public function unload():void { - if (manaMason != null) + if (autoCast != null) { - manaMason.unload(); - manaMason = null; + autoCast.unload(); + autoCast = null; } } diff --git a/src/Autocast/GCFWAutocast.as b/src/Autocast/GCFWAutocast.as index 994f1b7..4e457d2 100644 --- a/src/Autocast/GCFWAutocast.as +++ b/src/Autocast/GCFWAutocast.as @@ -5,6 +5,8 @@ package Autocast * @author Hellrage */ + import Bezel.Events.EventTypes; + import Bezel.Utils.Keybind; import com.giab.games.gcfw.GV; import com.giab.games.gcfw.constants.IngameStatus; import com.giab.games.gcfw.entity.Amplifier; @@ -21,6 +23,7 @@ package Autocast import flash.events.*; import flash.globalization.LocaleID; import flash.utils.*; + import flash.ui.Keyboard; public class GCFWAutocast extends MovieClip { @@ -36,6 +39,15 @@ package Autocast private var spellImages:Array; + private const spellKeybindNamesToIds:Object = { + "Cast freeze strike spell":0, + "Cast whiteout strike spell":1, + "Cast ice shards strike spell":2, + "Cast bolt enhancement spell":3, + "Cast beam enhancement spell":4, + "Cast barrage enhancement spell":5 + }; + public function GCFWAutocast() { super(); @@ -103,7 +115,7 @@ package Autocast private function addEventListeners(): void { AutocastMod.bezel.addEventListener("ingameClickOnScene", eh_ingameClickOnScene); - AutocastMod.bezel.addEventListener("ingameKeyDown", eh_interceptKeyboardEvent); + AutocastMod.bezel.addEventListener(EventTypes.INGAME_KEY_DOWN, eh_interceptKeyboardEvent); GV.main.addEventListener("enterFrame", eh_ingamePreRenderInfoPanel); AutocastMod.bezel.addEventListener("ingameRightClickOnScene", eh_ingameRightClickOnScene); AutocastMod.bezel.addEventListener("ingameNewScene", eh_ingameNewScene); @@ -117,7 +129,7 @@ package Autocast private function removeEventListeners(): void { AutocastMod.bezel.removeEventListener("ingameClickOnScene", eh_ingameClickOnScene); - AutocastMod.bezel.removeEventListener("ingameKeyDown", eh_interceptKeyboardEvent); + AutocastMod.bezel.removeEventListener(EventTypes.INGAME_KEY_DOWN, eh_interceptKeyboardEvent); GV.main.removeEventListener("enterFrame", eh_ingamePreRenderInfoPanel); AutocastMod.bezel.removeEventListener("ingameRightClickOnScene", eh_ingameRightClickOnScene); AutocastMod.bezel.removeEventListener("ingameNewScene", eh_ingameNewScene); @@ -139,21 +151,30 @@ package Autocast public function eh_interceptKeyboardEvent(e:Object): void { var pE:KeyboardEvent = e.eventArgs.event; - if (pE.ctrlKey) + if (pE.ctrlKey && pE.keyCode != Keyboard.CONTROL) { - if (pE.keyCode >= 49 && pE.keyCode <= 54) + pE.ctrlKey = false; + for (var keybindName:String in spellKeybindNamesToIds) { - e.eventArgs.continueDefault = false; - if (GV.ingameCore.arrIsSpellBtnVisible[pE.keyCode - 49]) - { - this.markerSpellType = pE.keyCode - 49; //keyCode 49 is digit 1, which is freeze spell, which is spellType 0 - GV.vfxEngine.createFloatingText4(GV.main.mouseX,GV.main.mouseY < 60?Number(GV.main.mouseY + 30):Number(GV.main.mouseY - 20),"Entered marker placement mode!",16768392,12,"center",Math.random() * 3 - 1.5,-4 - Math.random() * 3,0,0.55,12,0,1000); - } - else + var hkval: Keybind = AutocastMod.bezel.keybindManager.getHotkeyValue(keybindName); + if(hkval.matches(pE)) { + e.eventArgs.continueDefault = false; + tryEnterMarkerMode(spellKeybindNamesToIds[keybindName]); + pE.ctrlKey = true; return; } } + pE.ctrlKey = true; + } + } + + private function tryEnterMarkerMode(spell: int): void + { + if (GV.ingameCore.arrIsSpellBtnVisible[spell]) + { + this.markerSpellType = spell; //keyCode 49 is digit 1, which is freeze spell, which is spellType 0 + GV.vfxEngine.createFloatingText4(GV.main.mouseX,GV.main.mouseY < 60?Number(GV.main.mouseY + 30):Number(GV.main.mouseY - 20),"Entered marker placement mode!",16768392,12,"center",Math.random() * 3 - 1.5,-4 - Math.random() * 3,0,0.55,12,0,1000); } }