From 218267e28b8904914f7b5d15656356a53ef19b51 Mon Sep 17 00:00:00 2001 From: dginovker Date: Mon, 7 Oct 2019 10:52:30 -0400 Subject: [PATCH] Add animation id if --- pom.xml | 2 +- .../java/scriptfactory/Actions/Action.java | 1 - .../Actions/Logic/LogicHandler.java | 18 ++++++++++++++++++ src/main/java/scriptfactory/Core.java | 2 +- .../NewGuis/ConditionGuiInfo.java | 3 ++- 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 6593eab..d241bb9 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ src script-factory - 1.5 + 1.9 1.7 diff --git a/src/main/java/scriptfactory/Actions/Action.java b/src/main/java/scriptfactory/Actions/Action.java index 770bbac..5c9808f 100644 --- a/src/main/java/scriptfactory/Actions/Action.java +++ b/src/main/java/scriptfactory/Actions/Action.java @@ -55,7 +55,6 @@ public class Action { array[i] = Integer.parseInt(params.get(i)); } return array; - //return params.stream().mapToInt(Integer::parseInt).toArray(); } public Action(String action, ArrayList inputs) { diff --git a/src/main/java/scriptfactory/Actions/Logic/LogicHandler.java b/src/main/java/scriptfactory/Actions/Logic/LogicHandler.java index 128b1d9..702b74b 100644 --- a/src/main/java/scriptfactory/Actions/Logic/LogicHandler.java +++ b/src/main/java/scriptfactory/Actions/Logic/LogicHandler.java @@ -1,6 +1,8 @@ package scriptfactory.Actions.Logic; +import org.parabot.core.reflect.RefClass; import org.parabot.environment.api.utils.Filter; +import org.parabot.environment.api.utils.Time; import org.rev317.min.api.wrappers.GroundItem; import org.rev317.min.api.wrappers.Tile; import scriptfactory.Actions.Action; @@ -38,6 +40,22 @@ public class LogicHandler { return Players.getMyPlayer().isInCombat(); case "Within x Tiles of Coords": return new Tile(a.getParam(1), a.getParam(2)).distanceTo() < a.getParam(0); + case "Player Animation ID": + for (int i = 0; i <= a.getParam(1); i+=5) //Allow multiple checks for when the animation is happening + { + Time.sleep(5); + + if (a.getParam(2) == 1){ + if (Players.getMyPlayer().getAnimation() != a.getParam(0)) //"Inverse" + return true; + } + else + { + if (Players.getMyPlayer().getAnimation() == a.getParam(0)) + return true; + } + } + return false; default: log("Error: Unimplemented conditional: " + a.getAction()); } diff --git a/src/main/java/scriptfactory/Core.java b/src/main/java/scriptfactory/Core.java index 5b0aca0..1a0ecb3 100644 --- a/src/main/java/scriptfactory/Core.java +++ b/src/main/java/scriptfactory/Core.java @@ -20,7 +20,7 @@ import static scriptfactory.VarsMethods.log; * Welcome to AIO AIO - ScriptFactory. Make your own scripts! */ -@ScriptManifest(author = "Before", name = "Script Factory 1.8", category = Category.OTHER, version = 1.8, description = "Create your own scripts!", servers = "All") +@ScriptManifest(author = "Before", name = "Script Factory 1.9", category = Category.OTHER, version = 1.9, description = "Create your own scripts!", servers = "All") public class Core extends Script implements Paintable { private ArrayList actions = new ArrayList<>(); diff --git a/src/main/java/scriptfactory/NewGuis/ConditionGuiInfo.java b/src/main/java/scriptfactory/NewGuis/ConditionGuiInfo.java index f6eefc4..ddc0fb9 100644 --- a/src/main/java/scriptfactory/NewGuis/ConditionGuiInfo.java +++ b/src/main/java/scriptfactory/NewGuis/ConditionGuiInfo.java @@ -11,7 +11,7 @@ import java.util.ArrayList; */ public class ConditionGuiInfo extends NewStatementGUI { public ConditionGuiInfo(ArrayList actionList, Consumer updateTextfield) { - String[] actionTypes = new String[]{"Item is in Inventory", "Inventory slots used", "Item is on Ground", "Entity is around", "Hitpoints is below", "In Combat", "Within x Tiles of Coords"}; + String[] actionTypes = new String[]{"Item is in Inventory", "Inventory slots used", "Item is on Ground", "Entity is around", "Hitpoints is below", "In Combat", "Within x Tiles of Coords", "Detect Animation ID"}; Descriptions[] setDescs = { new Descriptions("Item to detect (eg. 4296 = bones)", "Number of them to detect (blank = 1)"), new Descriptions("Inventory slots greater than or equal to (eg. \"28\" detects a full inventory)"), @@ -20,6 +20,7 @@ public class ConditionGuiInfo extends NewStatementGUI { new Descriptions("Below health # (eg. 10)"), new Descriptions(), new Descriptions("Tiles to be within (i.e. 6)", "x Coordinate", "y Coordinate"), + new Descriptions("Animation ID to detect", "ms to look for animation (recommended 600+)", "\"1\" to look for any ID other than the one specified (use this with anim ID -1 to detect any animation)"), }; initGui("Add new condition", actionList, updateTextfield, actionTypes, setDescs);