Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Send Action #99

Open
wants to merge 4 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main/java/org/rev317/min/accessors/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public interface Client {

int[] getMenuAction4();

long[] getMenuHash();

CollisionMap[] getCollisionMap();

boolean walkTo(int clickType, int sizeX, int sizeY, int startX, int startY, int destX, int destY, int type, int face, boolean arbitrary, int rotation);
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/org/rev317/min/api/methods/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,20 @@ public static boolean hasAction4() {
}
}

/**
* Determines whether this client has menu hash hooked
*
* @return <code>true</code> if menu hash is hooked
*/
public static boolean hasMenuHash() {
try {
Loader.getClient().getMenuHash();
return true;
} catch (AbstractMethodError e) {
return false;
}
}

/**
* Returns the settings within the client
*
Expand Down
17 changes: 16 additions & 1 deletion src/main/java/org/rev317/min/api/methods/Menu.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public class Menu {
public static void interact(SceneObject object, SceneObjects.Option action) {
if (Game.hasAction4()) {
sendAction(action.getActionId(), object.getHash(), object.getLocalRegionX(), object.getLocalRegionY(), object.getId(), 0);
} else if (Game.hasMenuHash()) {
sendAction(action.getActionId(), object.getId(), object.getLocalRegionX(), object.getLocalRegionY(), object.getHash(), 0);
} else {
sendAction(action.getActionId(), object.getHash(), object.getLocalRegionX(), object.getLocalRegionY());
}
Expand Down Expand Up @@ -57,8 +59,11 @@ public static void interact(SceneObject object, int actionIndex) {
actionId = SceneObjects.Option.FIFTH.getActionId();
break;
}

if (Game.hasAction4()) {
sendAction(actionId, object.getHash(), object.getLocalRegionX(), object.getLocalRegionY(), object.getId(), 0);
} else if (Game.hasMenuHash()) {
sendAction(actionId, object.getId(), object.getLocalRegionX(), object.getLocalRegionY(), object.getHash(), 0);
} else {
sendAction(actionId, object.getHash(), object.getLocalRegionX(), object.getLocalRegionY());
}
Expand Down Expand Up @@ -315,14 +320,24 @@ public static void sendAction(int action, int cmd1, int cmd2, int cmd3, int inde
* @param index
*/
public static void sendAction(int action, int cmd1, int cmd2, int cmd3, int cmd4, int index) {
sendAction(action, cmd1, cmd2, cmd3, (long) cmd4, index);
}

public static void sendAction(int action, int cmd1, int cmd2, int cmd3, long hash, int index) {
Client client = Loader.getClient();

client.getMenuAction1()[index] = cmd1;
client.getMenuAction2()[index] = cmd2;
client.getMenuAction3()[index] = cmd3;

if (Game.hasMenuHash()) {
client.getMenuHash()[index] = hash;
}

if (Game.hasAction4()) {
client.getMenuAction4()[index] = cmd4;
client.getMenuAction4()[index] = (int) hash;
}

client.getMenuActionId()[index] = action;

client.doAction(index);
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/rev317/min/callback/MenuAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,15 @@ public static void intercept(int index) {
int action2 = client.getMenuAction2()[index];
int action3 = client.getMenuAction3()[index];
int action4 = 0;
long menuHash = 0;
int actionId = client.getMenuActionId()[index];
if (DActions.debugActions()) {
if (Game.hasAction4()) {
action4 = client.getMenuAction4()[index];
System.out.println(String.format(outputs[0][outputIndex], index, action1, action2, action3, action4, actionId));
} else if (Game.hasMenuHash()) {
menuHash = client.getMenuHash()[index];
System.out.println(String.format(outputs[0][outputIndex], index, action1, action2, action3, menuHash, actionId));
} else {
System.out.println(String.format(outputs[1][outputIndex], index, action1, action2, action3, actionId));
}
Expand Down