Unlimit interaction distance (#156)

* Unlimit object distance interaction limit

BoundingBoxCheck still needs to be modified to allow objects at the very top of viewport to be accepted.

* Update ClientTransform.java

Fix the previous problem, would help if I called the new method and not the original during testing RIP.
This commit is contained in:
Tyler Bochard
2019-05-01 01:48:06 -04:00
committed by GitHub
parent 2d22f9486c
commit bee830c5fd

View File

@@ -2,6 +2,7 @@ package net.runelite.client.rs.bytecode.transformers;
import javassist.CtBehavior;
import javassist.CtClass;
import javassist.CtField;
import javassist.CtMember;
import javassist.CtMethod;
import javassist.CtNewMethod;
@@ -32,6 +33,8 @@ public class ClientTransform implements Transform {
transformGetCollisionMaps();
transformDraw2010Menu();
transformRenderSelf();
transformboundingBoxCheck();
transformcheckClickBox();
ByteCodePatcher.modifiedClasses.add(ct);
} catch (Exception e) {
@@ -245,44 +248,6 @@ public class ClientTransform implements Transform {
}
}
/*
public void setMenuEntries(MenuEntry[] arrmenuEntry) {
int n2 = 0;
String[] arrstring = this.1protect$getMenuOptions();
String[] arrstring2 = this.1protect$getMenuTargets();
int[] arrn = this.1protect$getMenuIdentifiers();
int[] arrn2 = this.1protect$getMenuTypes();
int[] arrn3 = this.1protect$getMenuActionParams0();
int[] arrn4 = this.1protect$getMenuActionParams1();
boolean[] arrbl = this.getMenuForceLeftClick();
MenuEntry[] arrmenuEntry2 = arrmenuEntry;
int n3 = arrmenuEntry2.length;
int n4 = 0;
do {
String string;
if (n4 >= n3) {
this.setMenuOptionCount(n2);
oldMenuEntryCount = n2;
return;
}
MenuEntry menuEntry = arrmenuEntry2[n4];
int n5 = menuEntry.getType();
if (!(n5 != MenuAction.NPC_THIRD_OPTION.getId() && n5 != MenuAction.NPC_FIFTH_OPTION.getId() || n2 != arrmenuEntry.length - 1 || bv.ak.getLocalPlayer().getWorldLocation().getRegionID() != 13358 || (string = menuEntry.getOption().toLowerCase()).hashCode() != 974723797 && string.hashCode() != -1108625161)) {
n5 = MenuAction.CANCEL.getId();
}
arrstring[n2] = menuEntry.getOption();
arrstring2[n2] = menuEntry.getTarget();
arrn[n2] = menuEntry.getIdentifier();
arrn2[n2] = n5;
arrn3[n2] = menuEntry.getParam0();
arrn4[n2] = menuEntry.getParam1();
arrbl[n2] = menuEntry.isForceLeftClick();
++n2;
++n4;
} while (true);
}
*/
public void transformOnMenuOptionsChanged() {
CtMethod onMenuOptionsChanged;
try {
@@ -328,7 +293,7 @@ public class ClientTransform implements Transform {
draw2010Menu = ct.getDeclaredMethod("draw2010Menu");
ct.removeMethod(draw2010Menu);
draw2010Menu = CtNewMethod.make(
" public void draw2010Menu() {" +
" public void draw2010Menu() {" +
" int n2 = this.getMenuX();" +
" int n3 = this.getMenuY();" +
" int n4 = this.getMenuWidth();" +
@@ -377,4 +342,171 @@ public class ClientTransform implements Transform {
e.printStackTrace();
}
}
//TODO: fix not being able to click far away objects towards top of screen only.
public void transformboundingBoxCheck() {
CtMethod boundingboxCheck2;
try {
boundingboxCheck2 = CtMethod.make(" public boolean boundingboxCheck2(net.runelite.api.Model model, int n2, int n3, int n4) {" +
" int n5 = "+ByteCodePatcher.clientInstance+".getCameraPitch();" +
" int n6 = "+ByteCodePatcher.clientInstance+".getCameraYaw();" +
" int n7 = net.runelite.api.Perspective.SINE[n5];" +
" int n8 = net.runelite.api.Perspective.COSINE[n5];" +
" int n9 = net.runelite.api.Perspective.SINE[n6];" +
" int n10 = net.runelite.api.Perspective.COSINE[n6];" +
" int n11 = "+ByteCodePatcher.clientInstance+".getCenterX();" +
" int n12 = "+ByteCodePatcher.clientInstance+".getCenterY();" +
" int n13 = "+ByteCodePatcher.clientInstance+".getViewportMouseX();" +
" int n14 = "+ByteCodePatcher.clientInstance+".getViewportMouseY();" +
" int n15 = "+ByteCodePatcher.clientInstance+".get3dZoom();" +
" int n16 = (n13 - n11) * 50 / n15;" +
" int n17 = (n14 - n12) * 50 / n15;" +
" int n18 = (n13 - n11) * 10000 / n15;" +
" int n19 = (n14 - n12) * 10000 / n15;" +
" int n20 = client.rl$rot1(n17, 50, n8, n7);" +
" int n21 = client.rl$rot2(n17, 50, n8, n7);" +
" n17 = n20;" +
" n20 = client.rl$rot1(n19, 10000, n8, n7);" +
" int n22 = client.rl$rot2(n19, 10000, n8, n7);" +
" n19 = n20;" +
" n20 = client.rl$rot3(n16, n21, n10, n9);" +
" n21 = client.rl$rot4(n16, n21, n10, n9);" +
" n16 = n20;" +
" n20 = client.rl$rot3(n18, n22, n10, n9);" +
" n22 = client.rl$rot4(n18, n22, n10, n9);" +
" int n23 = (n20 - n16) / 2;" +
" int n24 = (n19 - n17) / 2;" +
" int n25 = (n22 - n21) / 2;" +
" int n26 = Math.abs(n23);" +
" int n27 = Math.abs(n24);" +
" int n28 = Math.abs(n25);" +
" int n29 = n2 + model.getCenterX();" +
" int n30 = n3 + model.getCenterY();" +
" int n31 = n4 + model.getCenterZ();" +
" int n32 = model.getExtremeX();" +
" int n33 = model.getExtremeY();" +
" int n34 = model.getExtremeZ();" +
" int n35 = (n16 + n20) / 2;" +
" int n36 = (n17 + n19) / 2;" +
" int n37 = (n22 + n21) / 2;" +
" int n38 = n35 - n29;" +
" int n39 = n36 - n30;" +
" int n40 = n37 - n31;" +
" if (Math.abs(n38) > n32 + n26) {" +
" return false;" +
" }" +
" if (Math.abs(n39) > n33 + n27) {" +
" return false;" +
" }" +
" if (Math.abs(n40) > n34 + n28) {" +
" return false;" +
" }" +
" if (Math.abs(n40 * n24 - n39 * n25) > n33 * n28 + n34 * n27) {" +
" return false;" +
" }" +
" if (Math.abs(n38 * n25 - n40 * n23) > n34 * n26 + n32 * n28) {" +
" return false;" +
" }" +
" if (Math.abs(n39 * n23 - n38 * n24) <= n33 * n26 + n32 * n27) return true;" +
" return false;" +
" }", ct);
ct.addMethod(boundingboxCheck2);
} catch (Exception e) {
e.printStackTrace();
}
}
public void transformcheckClickBox() {
CtMethod checkClickBox;
try {
checkClickBox = ct.getDeclaredMethod("checkClickbox");
ct.removeMethod(checkClickBox);
checkClickBox = CtMethod.make("public void checkClickbox(net.runelite.api.Model model, int n2, int n3, int n4, int n5, int n6, int n7, int n8, int n9, long l2) {"+
" int n10;" +
" int n11;" +
" int n12;" +
" int n13;" +
" int n14;" +
" net.runelite.rs.api.RSModel rSModel = (net.runelite.rs.api.RSModel)model;" +
" boolean bl2 = l2 != 0L && (int)(l2 >>> 16 & 1L) != 1;" +
" boolean bl3 = "+ByteCodePatcher.clientInstance+".getViewportContainsMouse();" +
" if (!bl2) return;" +
" if (!bl3) return;" +
" boolean bl4 = this.boundingboxCheck2((net.runelite.api.Model)rSModel, n7, n8, n9);" +
" if (!bl4) {" +
" return;" +
" }" +
" if (rSModel.isClickable()) {" +
" this.addHashAtMouse(l2);" +
" return;" +
" }" +
" int n15 = rSModel.getVerticesCount();" +
" int n16 = rSModel.getTrianglesCount();" +
" int[] arrn = rSModel.getVerticesX();" +
" int[] arrn2 = rSModel.getVerticesY();" +
" int[] arrn3 = rSModel.getVerticesZ();" +
" int[] arrn4 = rSModel.getTrianglesX();" +
" int[] arrn5 = rSModel.getTrianglesY();" +
" int[] arrn6 = rSModel.getTrianglesZ();" +
" int[] arrn7 = rSModel.getFaceColors3();" +
" int n17 = "+ByteCodePatcher.clientInstance+".get3dZoom();" +
" int n18 = "+ByteCodePatcher.clientInstance+".getCenterX();" +
" int n19 = "+ByteCodePatcher.clientInstance+".getCenterY();" +
" int n20 = 0;" +
" int n21 = 0;" +
" if (n2 != 0) {" +
" n20 = net.runelite.api.Perspective.SINE[n2];" +
" n21 = net.runelite.api.Perspective.COSINE[n2];" +
" }" +
" for (n14 = 0; n14 < n15; ++n14) {" +
" n11 = arrn[n14];" +
" n13 = arrn2[n14];" +
" n12 = arrn3[n14];" +
" if (n2 != 0) {" +
" n10 = n12 * n20 + n11 * n21 >> 16;" +
" n12 = n12 * n21 - n11 * n20 >> 16;" +
" n11 = n10;" +
" }" +
" n10 = (n12 += n9) * n5 + n6 * (n11 += n7) >> 16;" +
" n12 = n6 * n12 - n11 * n5 >> 16;" +
" n11 = n10;" +
" n10 = n4 * (n13 += n8) - n12 * n3 >> 16;" +
" if ((n12 = n13 * n3 + n4 * n12 >> 16) >= 50) {" +
" client.rl$modelViewportYs[n14] = n11 * n17 / n12 + n18;" +
" client.rl$modelViewportXs[n14] = n10 * n17 / n12 + n19;" +
" continue;" +
" }" +
" client.rl$modelViewportYs[n14] = -5000;" +
" }" +
" n14 = "+ByteCodePatcher.clientInstance+".getViewportMouseX();" +
" n11 = "+ByteCodePatcher.clientInstance+".getViewportMouseY();" +
" n13 = 0;" +
" while (n13 < n16) {" +
" if (arrn7[n13] != -2) {" +
" int n22;" +
" boolean bl5;" +
" int n23;" +
" n12 = arrn4[n13];" +
" n10 = arrn5[n13];" +
" int n24 = arrn6[n13];" +
" int n25 = rl$modelViewportYs[n12];" +
" int n26 = rl$modelViewportYs[n10];" +
" int n27 = rl$modelViewportYs[n24];" +
" int n28 = rl$modelViewportXs[n12];" +
" int n29 = rl$modelViewportXs[n10];" +
" int n30 = rl$modelViewportXs[n24];" +
" if (n25 != -5000 && n26 != -5000 && n27 != -5000 && (bl5 = (n23 = (n22 = rSModel.isClickable() ? 20 : 5) + n11) < n28 && n23 < n29 && n23 < n30 ? false : ((n23 = n11 - n22) > n28 && n23 > n29 && n23 > n30 ? false : ((n23 = n22 + n14) < n25 && n23 < n26 && n23 < n27 ? false : (n23 = n14 - n22) <= n25 || n23 <= n26 || n23 <= n27)))) {" +
" this.addHashAtMouse(l2);" +
" return;" +
" }" +
" }" +
" ++n13;" +
" }" +
" }"
, ct);
ct.addMethod(checkClickBox);
} catch (Exception e) {
e.printStackTrace();
}
}
}