Skip to content

Commit

Permalink
Updated the mod to use Bezel's keybinds.
Browse files Browse the repository at this point in the history
Fixed a typo in private mod instance name.
  • Loading branch information
hellrage committed Jan 24, 2022
1 parent 1946b2c commit 4e4241b
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Autocast.as3proj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<output>
<movie outputType="Application" />
<movie input="" />
<movie path="D:\Games\Steam\steamapps\common\GemCraft Frostborn Wrath\Mods\Autocast-1.3.swf" />
<movie path="D:\Games\Steam\steamapps\common\GemCraft Frostborn Wrath\Mods\Autocast-1.4.swf" />
<movie fps="30" />
<movie width="1920" />
<movie height="1080" />
Expand Down
6 changes: 5 additions & 1 deletion Changelog.txt
Original file line number Diff line number Diff line change
@@ -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
Updated to Bezel 1.x

24.01.2022 v1.4
Updated to use Bezel's keybinds.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**


Expand Down
14 changes: 7 additions & 7 deletions src/Autocast/AutocastMod.as
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
}

Expand Down
43 changes: 32 additions & 11 deletions src/Autocast/GCFWAutocast.as
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
{
Expand All @@ -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();
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
}
}

Expand Down

0 comments on commit 4e4241b

Please sign in to comment.