Skip to content

Commit

Permalink
feat: Tile markers in ::debug with alt+shift+click
Browse files Browse the repository at this point in the history
  • Loading branch information
Pazaz committed Jan 27, 2024
1 parent 79fb9b2 commit 32e1816
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 12 deletions.
46 changes: 40 additions & 6 deletions client/src/main/java/client.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import jagex2.dash3d.entity.*;
import jagex2.dash3d.type.LocSpawned;
import jagex2.dash3d.type.LocTemporary;
import jagex2.dash3d.type.Tile;
import jagex2.datastruct.JString;
import jagex2.datastruct.LinkList;
import jagex2.graphics.*;
Expand Down Expand Up @@ -35,6 +36,10 @@ public class client extends GameShell {
public boolean showDebug = false;
public boolean showPerformance = false;

// alt+shift click to add a tile overlay
public Tile[] userTileMarkers = new Tile[4];
public int userTileMarkerIndex = 0;

@OriginalMember(owner = "client!client", name = "E", descriptor = "I")
public static int opHeld1Counter;

Expand Down Expand Up @@ -1257,7 +1262,7 @@ public static void main(@OriginalArg(0) String[] args) {
signlink.sunjava = true;
}

signlink.startpriv(InetAddress.getByName("w1.225.2004scape.org"));
signlink.startpriv(InetAddress.getByName("localhost"));

@Pc(82) client c = new client();
c.initApplication(789, 532);
Expand Down Expand Up @@ -1362,12 +1367,12 @@ private void draw2DEntityElements() {
if (this.showDebug) {
// true tile overlay
if (entity.pathLength > 0 || entity.forceMoveEndCycle >= loopCycle || entity.forceMoveStartCycle > loopCycle) {
int halfUnit = 64 * entity.size;
this.drawTileOverlay(entity.pathTileX[0] * 128 + halfUnit, entity.pathTileZ[0] * 128 + halfUnit, this.currentLevel, entity.size, 0x666666, true);
int halfUnit = 64 * entity.size;
this.drawTileOverlay(entity.pathTileX[0] * 128 + halfUnit, entity.pathTileZ[0] * 128 + halfUnit, this.currentLevel, entity.size, 0x00FFFF, false);
}

// local tile overlay
this.drawTileOverlay(entity.x, entity.z, this.currentLevel, entity.size, 0x444444, false);
this.drawTileOverlay(entity.x, entity.z, this.currentLevel, entity.size, 0x666666, false);

int offsetY = 0;
this.projectFromGround(entity, entity.height + 30);
Expand Down Expand Up @@ -1558,6 +1563,16 @@ private void draw2DEntityElements() {
}
}

if (this.showDebug) {
for (int i = 0; i < this.userTileMarkers.length; i++) {
if (this.userTileMarkers[i] == null || this.userTileMarkers[i].level != this.currentLevel || this.userTileMarkers[i].x < 0 || this.userTileMarkers[i].z < 0 || this.userTileMarkers[i].x >= 104 || this.userTileMarkers[i].z >= 104) {
continue;
}

this.drawTileOverlay(this.userTileMarkers[i].x * 128 + 64, this.userTileMarkers[i].z * 128 + 64, this.userTileMarkers[i].level, 1, 0xFFFF00, false);
}
}

for (@Pc(483) int i = 0; i < this.chatCount; i++) {
int x = this.chatX[i];
@Pc(495) int y = this.chatY[i];
Expand Down Expand Up @@ -6903,7 +6918,7 @@ private void drawTileOverlay(int x, int z, int level, int size, int color, boole
int x2, y2;
int x3, y3;

int halfUnit = 64 * size;
int halfUnit = 64 * size;
this.project(x - halfUnit, height, z - halfUnit);
x0 = this.projectX;
y0 = this.projectY;
Expand Down Expand Up @@ -8300,7 +8315,7 @@ public URL getCodeBase() {

try {
if (super.frame != null) {
return new URL("http://w1.225.2004scape.org:" + (portOffset + 80));
return new URL("http://localhost:" + (portOffset + 80));
}
} catch (@Pc(21) Exception ex) {
}
Expand Down Expand Up @@ -8497,6 +8512,21 @@ private boolean tryMove(@OriginalArg(0) int srcX, @OriginalArg(4) int srcZ, @Ori
int startX = this.bfsStepX[length];
int startZ = this.bfsStepZ[length];

if (this.showDebug && super.actionKey[6] == 1 && super.actionKey[7] == 1) {
// check if tile is already added, if so remove it
for (int i = 0; i < this.userTileMarkers.length; i++) {
if (this.userTileMarkers[i] != null && this.userTileMarkers[i].x == World3D.clickTileX && this.userTileMarkers[i].z == World3D.clickTileZ) {
this.userTileMarkers[i] = null;
return false;
}
}

// add new
this.userTileMarkers[this.userTileMarkerIndex] = new Tile(this.currentLevel, World3D.clickTileX, World3D.clickTileZ);
this.userTileMarkerIndex = this.userTileMarkerIndex + 1 & (this.userTileMarkers.length - 1);
return false;
}

if (type == 0) {
// MOVE_GAMECLICK
this.out.p1isaac(181);
Expand Down Expand Up @@ -10053,6 +10083,10 @@ private void readLocalPlayer(@OriginalArg(2) Packet buf, @OriginalArg(1) int siz
}
} else if (updateType == 3) {
this.currentLevel = buf.gBit(2);
if (this.showDebug) {
this.userTileMarkers = new Tile[4];
this.userTileMarkerIndex = 0;
}
int localX = buf.gBit(7);
int localZ = buf.gBit(7);
int jump = buf.gBit(1);
Expand Down
28 changes: 28 additions & 0 deletions client/src/main/java/jagex2/client/GameShell.java
Original file line number Diff line number Diff line change
Expand Up @@ -396,22 +396,36 @@ public final void keyPressed(@OriginalArg(0) KeyEvent e) {
}

if (code == 37) {
// KEY_LEFT
ch = 1;
} else if (code == 39) {
// KEY_RIGHT
ch = 2;
} else if (code == 38) {
// KEY_UP
ch = 3;
} else if (code == 40) {
// KEY_DOWN
ch = 4;
} else if (code == 17) {
// CONTROL
ch = 5;
} else if (code == 16) {
// SHIFT
ch = 6; // (custom)
} else if (code == 18) {
// ALT
ch = 7; // (custom)
} else if (code == 8) {
// BACKSPACE
ch = 8;
} else if (code == 127) {
// DELETE
ch = 8;
} else if (code == 9) {
ch = 9;
} else if (code == 10) {
// ENTER
ch = 10;
} else if (code >= 112 && code <= 123) {
ch = code + 1008 - 112;
Expand Down Expand Up @@ -451,22 +465,36 @@ public final void keyReleased(@OriginalArg(0) KeyEvent e) {
}

if (code == 37) {
// KEY_LEFT
ch = 1;
} else if (code == 39) {
// KEY_RIGHT
ch = 2;
} else if (code == 38) {
// KEY_UP
ch = 3;
} else if (code == 40) {
// KEY_DOWN
ch = 4;
} else if (code == 17) {
// CONTROL
ch = 5;
} else if (code == 16) {
// SHIFT
ch = 6; // (custom)
} else if (code == 18) {
// ALT
ch = 7; // (custom)
} else if (code == 8) {
// BACKSPACE
ch = 8;
} else if (code == 127) {
// DELETE
ch = 8;
} else if (code == 9) {
ch = 9;
} else if (code == 10) {
// ENTER
ch = 10;
} else if (code >= 112 && code <= 123) {
ch = code + 1008 - 112;
Expand Down
12 changes: 6 additions & 6 deletions client/src/main/java/jagex2/dash3d/World3D.java
Original file line number Diff line number Diff line change
Expand Up @@ -1123,17 +1123,17 @@ public void drawMinimapTile(@OriginalArg(3) int level, @OriginalArg(4) int x, @O

int shape = overlay.shape;
@Pc(71) int angle = overlay.rotation;
@Pc(74) int bcakground = overlay.backgroundRgb;
@Pc(74) int background = overlay.backgroundRgb;
@Pc(77) int foreground = overlay.foregroundRgb;
@Pc(82) int[] mask = this.MINIMAP_TILE_MASK[shape];
@Pc(87) int[] rotation = this.MINIMAP_TILE_ROTATION_MAP[angle];
@Pc(89) int off = 0;
if (bcakground != 0) {
if (background != 0) {
for (int i = 0; i < 4; i++) {
dst[offset] = mask[rotation[off++]] == 0 ? bcakground : foreground;
dst[offset + 1] = mask[rotation[off++]] == 0 ? bcakground : foreground;
dst[offset + 2] = mask[rotation[off++]] == 0 ? bcakground : foreground;
dst[offset + 3] = mask[rotation[off++]] == 0 ? bcakground : foreground;
dst[offset] = mask[rotation[off++]] == 0 ? background : foreground;
dst[offset + 1] = mask[rotation[off++]] == 0 ? background : foreground;
dst[offset + 2] = mask[rotation[off++]] == 0 ? background : foreground;
dst[offset + 3] = mask[rotation[off++]] == 0 ? background : foreground;
offset += step;
}
return;
Expand Down

0 comments on commit 32e1816

Please sign in to comment.