From 84223bf5aa69678e07b1fb58ebadac1c7de83b6e Mon Sep 17 00:00:00 2001 From: Clisprail Date: Thu, 31 Jul 2014 14:34:05 +0200 Subject: [PATCH] Action 4 support --- src/org/rev317/min/accessors/Client.java | 2 ++ src/org/rev317/min/api/methods/Game.java | 13 ++++++++++ src/org/rev317/min/api/methods/Menu.java | 16 ++++++++++++ src/org/rev317/min/callback/MenuAction.java | 28 ++++++++++++--------- 4 files changed, 47 insertions(+), 12 deletions(-) diff --git a/src/org/rev317/min/accessors/Client.java b/src/org/rev317/min/accessors/Client.java index 666c9b7..7b0f7f3 100644 --- a/src/org/rev317/min/accessors/Client.java +++ b/src/org/rev317/min/accessors/Client.java @@ -38,6 +38,8 @@ public interface Client { public int[] getMenuAction3(); + public int[] getMenuAction4(); + public CollisionMap[] getCollisionMap(); // args switched diff --git a/src/org/rev317/min/api/methods/Game.java b/src/org/rev317/min/api/methods/Game.java index 7d31832..d5c0e2e 100644 --- a/src/org/rev317/min/api/methods/Game.java +++ b/src/org/rev317/min/api/methods/Game.java @@ -64,5 +64,18 @@ public class Game { public static int getPlane() { return Loader.getClient().getPlane(); } + + /** + * Determines whether this client has action 4 hooked + * @return true if action 4 is hooked + */ + public static boolean hasAction4() { + try { + Loader.getClient().getMenuAction4(); + return true; + } catch(AbstractMethodError e) { + return false; + } + } } diff --git a/src/org/rev317/min/api/methods/Menu.java b/src/org/rev317/min/api/methods/Menu.java index 83d126f..77672d9 100644 --- a/src/org/rev317/min/api/methods/Menu.java +++ b/src/org/rev317/min/api/methods/Menu.java @@ -182,6 +182,19 @@ public class Menu { * @param index */ public static void sendAction(int action, int cmd1, int cmd2, int cmd3, int index) { + sendAction(action, cmd1, cmd2, cmd3, 0, index); + } + + /** + * Sends an action to the client + * @param action + * @param cmd1 + * @param cmd2 + * @param cmd3 + * @param cmd4 + * @param index + */ + public static void sendAction(int action, int cmd1, int cmd2, int cmd3, int cmd4, int index) { if (constants == null) { constants = Context.getInstance().getHookParser().getConstants(); } @@ -191,6 +204,9 @@ public class Menu { client.getMenuAction1()[index] = cmd1; client.getMenuAction2()[index] = cmd2; client.getMenuAction3()[index] = cmd3; + if(Game.hasAction4()) { + client.getMenuAction4()[4] = cmd4; + } client.getMenuActionId()[index] = action; diff --git a/src/org/rev317/min/callback/MenuAction.java b/src/org/rev317/min/callback/MenuAction.java index e9e14b7..581a9f4 100644 --- a/src/org/rev317/min/callback/MenuAction.java +++ b/src/org/rev317/min/callback/MenuAction.java @@ -3,9 +3,8 @@ package org.rev317.min.callback; import org.rev317.min.Loader; import org.rev317.min.accessors.Client; import org.rev317.min.debug.DActions; - import org.rev317.min.api.events.ActionEvent; - +import org.rev317.min.api.methods.Game; import org.rev317.min.script.ScriptEngine; /** @@ -15,18 +14,23 @@ import org.rev317.min.script.ScriptEngine; * */ public class MenuAction { - + public static void intercept(int index) { - Client client = Loader.getClient(); - int action1 = client.getMenuAction1()[index]; - int action2 = client.getMenuAction2()[index]; - int action3 = client.getMenuAction3()[index]; - int actionId = client.getMenuActionId()[index]; - if(DActions.debugActions()) { - System.out.println(String.format("[index: %d, action1: %d, action2: %d, action3: %d, id: %d]", index, action1, action2, action3, actionId)); + Client client = Loader.getClient(); + int action1 = client.getMenuAction1()[index]; + int action2 = client.getMenuAction2()[index]; + int action3 = client.getMenuAction3()[index]; + int actionId = client.getMenuActionId()[index]; + if (DActions.debugActions()) { + if(Game.hasAction4()) { + int action4 = client.getMenuAction4()[index]; + System.out.println(String.format("[index: %d, action1: %d, action2: %d, action3: %d, action4: %d, id: %d]", index, action1, action2, action3, action4, actionId)); + } else { + System.out.println(String.format("[index: %d, action1: %d, action2: %d, action3: %d, id: %d]", index, action1, action2, action3, actionId)); + } } - - final ActionEvent actionEvent = new ActionEvent(actionId,action1,action2,action3,index); + + final ActionEvent actionEvent = new ActionEvent(actionId, action1, action2, action3, index); ScriptEngine.getInstance().dispatch(actionEvent); }