Skip to content

Commit 4f126dc

Browse files
committed
feat: create walkpath debugger
1 parent bd51320 commit 4f126dc

File tree

4 files changed

+66
-1
lines changed

4 files changed

+66
-1
lines changed

src/main/java/org/runejs/client/Main.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import org.runejs.client.cache.CacheArchive;
55
import org.runejs.client.cache.CacheFileChannel;
66
import org.runejs.client.frame.ChatBox;
7+
import org.runejs.client.frame.DebugTools;
78
import org.runejs.client.frame.ScreenController;
89
import org.runejs.client.frame.ScreenMode;
910
import org.runejs.client.frame.console.Console;
@@ -872,6 +873,8 @@ public static void method353() {
872873
((Class35) Rasterizer3D.interface3).animateTextures(MovedStatics.anInt199);
873874
KeyFocusListener.draw3dScreen();
874875

876+
DebugTools.drawWalkPath();
877+
875878
if(ScreenController.frameMode == ScreenMode.FIXED) {
876879
Console.console.drawConsole(512, 334);
877880
Console.console.drawConsoleArea(512, 334);

src/main/java/org/runejs/client/SpotAnim.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import org.runejs.client.cache.media.AnimationSequence;
44
import org.runejs.client.cache.def.SpotAnimDefinition;
5+
import org.runejs.client.frame.DebugTools;
56
import org.runejs.client.media.VertexNormal;
67
import org.runejs.client.media.renderable.Model;
78
import org.runejs.client.media.renderable.Renderable;
@@ -59,8 +60,12 @@ else if(lightness > 126)
5960
}
6061

6162
public static void renderPlayers(int arg0, boolean arg1) {
62-
if(Player.localPlayer.worldX >> 7 == MovedStatics.destinationX && Player.localPlayer.worldY >> 7 == Class55.destinationY)
63+
if(Player.localPlayer.worldX >> 7 == MovedStatics.destinationX && Player.localPlayer.worldY >> 7 == Class55.destinationY) {
6364
MovedStatics.destinationX = 0;
65+
66+
DebugTools.walkpathX = null;
67+
DebugTools.walkpathY = null;
68+
}
6469
int i = Player.localPlayerCount;
6570
if(arg1)
6671
i = 1;
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package org.runejs.client.frame;
2+
3+
import org.runejs.client.MovedStatics;
4+
import org.runejs.client.media.Rasterizer;
5+
import org.runejs.client.scene.Point2d;
6+
7+
public class DebugTools {
8+
public static int[] walkpathX = null;
9+
public static int[] walkpathY = null;
10+
11+
public static void drawWalkPath() {
12+
if (walkpathX == null) {
13+
return;
14+
}
15+
16+
int lastTileX = walkpathX[0];
17+
int lastTileY = walkpathY[0];
18+
19+
Point2d pathStartPos = MovedStatics.getProjectedScreenPosition(10, lastTileY * 128 + 64, lastTileX * 128 + 64);
20+
Point2d pathFinishPos = MovedStatics.getProjectedScreenPosition(10, walkpathY[walkpathY.length - 1] * 128 + 64, walkpathX[walkpathX.length - 1] * 128 + 64);
21+
22+
Point2d lastTilePos = pathStartPos;
23+
for (int i = 1; i < walkpathX.length; i++) {
24+
int tileX = walkpathX[i];
25+
int tileY = walkpathY[i];
26+
27+
Point2d nextPos = MovedStatics.getProjectedScreenPosition(10, tileY * 128 + 64, tileX * 128 + 64);
28+
29+
if (lastTilePos != null && nextPos != null) {
30+
Rasterizer.drawDiagonalLine(lastTilePos.x, lastTilePos.y, nextPos.x, nextPos.y, 0x00FFAC);
31+
}
32+
33+
lastTileX = tileX;
34+
lastTileY = tileY;
35+
lastTilePos = nextPos;
36+
}
37+
38+
if (pathStartPos != null) {
39+
Rasterizer.drawCircle(pathStartPos.x, pathStartPos.y, 2, 0xE055DE);
40+
}
41+
42+
if (pathFinishPos != null) {
43+
Rasterizer.drawCircle(pathFinishPos.x, pathFinishPos.y, 4, 0xE055DE);
44+
}
45+
}
46+
}

src/main/java/org/runejs/client/media/renderable/actor/Pathfinding.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.runejs.client.media.renderable.actor;
22

3+
import org.runejs.client.frame.DebugTools;
34
import org.runejs.client.media.renderable.Item;
45
import org.runejs.client.message.outbound.WalkOutboundMessage;
56
import org.runejs.client.net.OutgoingPackets;
@@ -249,6 +250,14 @@ else if((waypoint & 0b1000) != 0)
249250
int x = walkingQueueX[currentIndex];
250251
int y = walkingQueueY[currentIndex];
251252

253+
DebugTools.walkpathX = new int[maxPathSize + 1];
254+
DebugTools.walkpathY = new int[maxPathSize + 1];
255+
256+
DebugTools.walkpathX[0] = startX;
257+
DebugTools.walkpathY[0] = startY;
258+
DebugTools.walkpathX[1] = x;
259+
DebugTools.walkpathY[1] = y;
260+
252261
WalkOutboundMessage.WalkType walkType = WalkOutboundMessage.WalkType.TILE;
253262

254263
if(clickType == 0) {
@@ -266,6 +275,8 @@ else if(clickType == 2) {
266275
currentIndex--;
267276
int stepX = walkingQueueX[currentIndex] - x;
268277
int stepY = walkingQueueY[currentIndex] - y;
278+
DebugTools.walkpathX[counter + 1] = walkingQueueX[currentIndex];
279+
DebugTools.walkpathY[counter + 1] = walkingQueueY[currentIndex];
269280

270281
steps.add(new WalkOutboundMessage.WalkStep(stepX, stepY));
271282
}

0 commit comments

Comments
 (0)