mirror of
https://gitlab.com/2009scape/rt4-client.git
synced 2025-12-09 16:45:46 -07:00
Commit start of plugin work
This commit is contained in:
parent
2bcf5c564d
commit
a6577064b0
18 changed files with 426 additions and 46 deletions
|
|
@ -1,9 +1,10 @@
|
||||||
{
|
{
|
||||||
"ip_management": "test.2009scape.org",
|
"ip_management": "play.2009scape.org",
|
||||||
"ip_address": "test.2009scape.org",
|
"ip_address": "play.2009scape.org",
|
||||||
"world": 1,
|
"world": 1,
|
||||||
"server_port": 43594,
|
"server_port": 43594,
|
||||||
"wl_port": 43595,
|
"wl_port": 43595,
|
||||||
"js5_port": 43595,
|
"js5_port": 43595,
|
||||||
"mouseWheelZoom": true
|
"mouseWheelZoom": true,
|
||||||
|
"pluginsFolder": "plugins"
|
||||||
}
|
}
|
||||||
58
client/src/main/java/plugin/Plugin.java
Normal file
58
client/src/main/java/plugin/Plugin.java
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
package plugin;
|
||||||
|
|
||||||
|
import rt4.Npc;
|
||||||
|
import rt4.Player;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The base plugin class which is meant to be extended by plugins.
|
||||||
|
* Contains callbacks to many parts of the internal client code.
|
||||||
|
*/
|
||||||
|
public abstract class Plugin {
|
||||||
|
long timeOfLastDraw;
|
||||||
|
|
||||||
|
void _init() {
|
||||||
|
Init();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _draw() {
|
||||||
|
long nowTime = System.currentTimeMillis();
|
||||||
|
Draw(nowTime - timeOfLastDraw);
|
||||||
|
timeOfLastDraw = nowTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draw() is called by the client rendering loop so that plugins can draw information onto the screen.
|
||||||
|
* This will be called once per frame, meaning it is framerate bound.
|
||||||
|
* @param timeDelta the time (ms) elapsed since the last draw call.
|
||||||
|
*/
|
||||||
|
public void Draw(long timeDelta) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Init() is called when the plugin is first loaded
|
||||||
|
*/
|
||||||
|
public void Init() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OnXPUpdate() is called when the client receives an XP update packet. This includes at login.
|
||||||
|
*/
|
||||||
|
public void OnXPUpdate() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update() is called once per tick, aka once every 600ms.
|
||||||
|
*/
|
||||||
|
public void Update() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PlayerOverheadDraw() is called once per frame, for every player on the screen. :) Expensive.
|
||||||
|
* @param screenX the X coordinate on the screen for overhead drawing
|
||||||
|
* @param screenY the Y coordinate on the screen for overhead drawing
|
||||||
|
*/
|
||||||
|
public void PlayerOverheadDraw(Player player, int screenX, int screenY) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* NPCOverheadDraw() is called once per frame, for every NPC on the screen. :) Expensive.
|
||||||
|
* @param screenX the X coordinate on the screen for overhead drawing
|
||||||
|
* @param screenY the Y coordinate on the screen for overhead drawing
|
||||||
|
*/
|
||||||
|
public void NPCOverheadDraw(Npc npc, int screenX, int screenY) {}
|
||||||
|
}
|
||||||
57
client/src/main/java/plugin/PluginInfo.java
Normal file
57
client/src/main/java/plugin/PluginInfo.java
Normal file
|
|
@ -0,0 +1,57 @@
|
||||||
|
package plugin;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A data class for storing information about plugins.
|
||||||
|
* @author ceikry
|
||||||
|
*/
|
||||||
|
class PluginInfo {
|
||||||
|
double version;
|
||||||
|
String author;
|
||||||
|
String description;
|
||||||
|
|
||||||
|
public PluginInfo(String author, String description, double version) {
|
||||||
|
this.version = version;
|
||||||
|
this.author = author;
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static PluginInfo loadFromFile(File file) {
|
||||||
|
Properties prop = new Properties();
|
||||||
|
|
||||||
|
try {
|
||||||
|
prop.load(new FileReader(file));
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
System.err.println("File does not exist! - " + file.getAbsolutePath());
|
||||||
|
return new PluginInfo("", "", 0.0);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return new PluginInfo("", "", 0.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new PluginInfo(
|
||||||
|
prop.get("AUTHOR").toString(),
|
||||||
|
prop.get("DESCRIPTION").toString(),
|
||||||
|
Double.parseDouble(prop.get("VERSION").toString())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
PluginInfo that = (PluginInfo) o;
|
||||||
|
return Double.compare(that.version, version) == 0 && Objects.equals(author, that.author) && Objects.equals(description, that.description);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(version, author, description);
|
||||||
|
}
|
||||||
|
}
|
||||||
93
client/src/main/java/plugin/PluginRepository.java
Normal file
93
client/src/main/java/plugin/PluginRepository.java
Normal file
|
|
@ -0,0 +1,93 @@
|
||||||
|
package plugin;
|
||||||
|
|
||||||
|
import rt4.GlobalJsonConfig;
|
||||||
|
import rt4.Npc;
|
||||||
|
import rt4.Player;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLClassLoader;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Responsible for loading and broadcasting methods to all plugins.
|
||||||
|
* @author ceikry
|
||||||
|
*/
|
||||||
|
public class PluginRepository {
|
||||||
|
static HashMap<PluginInfo, Plugin> loadedPlugins = new HashMap<>();
|
||||||
|
|
||||||
|
public static void registerPlugin(PluginInfo info, Plugin plugin) {
|
||||||
|
loadedPlugins.put(info, plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void reloadPlugins() {
|
||||||
|
loadedPlugins.clear();
|
||||||
|
Init();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Init() {
|
||||||
|
File pluginsDirectory = new File(GlobalJsonConfig.instance.pluginsFolder);
|
||||||
|
|
||||||
|
if (!pluginsDirectory.exists()) {
|
||||||
|
System.out.println("Skipping plugin initialization - " + pluginsDirectory.getAbsolutePath() + " does not exist.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
URL[] classPath = {pluginsDirectory.toURI().toURL()};
|
||||||
|
URLClassLoader loader = new URLClassLoader(classPath);
|
||||||
|
|
||||||
|
for(File file : Objects.requireNonNull(pluginsDirectory.listFiles())) {
|
||||||
|
if(!file.isDirectory()) continue;
|
||||||
|
|
||||||
|
File infoFile = new File(file.getAbsoluteFile() + File.separator + "plugin.properties");
|
||||||
|
File pluginRoot = new File(file.getAbsoluteFile() + File.separator + "plugin.class");
|
||||||
|
|
||||||
|
PluginInfo info;
|
||||||
|
if (infoFile.exists())
|
||||||
|
info = PluginInfo.loadFromFile(infoFile);
|
||||||
|
else
|
||||||
|
info = new PluginInfo("Unknown", "", 1.0);
|
||||||
|
|
||||||
|
if (!pluginRoot.exists()) {
|
||||||
|
System.err.println("Unable to load plugin " + file.getName() + " because plugin.class is absent!");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Class<?> clazz = loader.loadClass(file.getName() + ".plugin");
|
||||||
|
|
||||||
|
try {
|
||||||
|
Plugin thisPlugin = (Plugin) clazz.newInstance();
|
||||||
|
thisPlugin._init();
|
||||||
|
registerPlugin(info, thisPlugin);
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.err.println("Error loading plugin " + file.getName() + ":");
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("Successfully loaded plugin " + file.getName() + ", version " + info.version);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.err.println("Unexpected exception during plugin initialization:");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Update() {
|
||||||
|
loadedPlugins.values().forEach(Plugin::Update);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Draw() {
|
||||||
|
loadedPlugins.values().forEach(Plugin::_draw);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void NPCOverheadDraw(Npc npc, int screenX, int screenY) {
|
||||||
|
loadedPlugins.values().forEach((plugin) -> plugin.NPCOverheadDraw(npc, screenX, screenY));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void PlayerOverheadDraw(Player player, int screenX, int screenY) {
|
||||||
|
loadedPlugins.values().forEach((plugin) -> plugin.PlayerOverheadDraw(player, screenX, screenY));
|
||||||
|
}
|
||||||
|
}
|
||||||
44
client/src/main/java/plugin/api/API.java
Normal file
44
client/src/main/java/plugin/api/API.java
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
package plugin.api;
|
||||||
|
|
||||||
|
import rt4.Font;
|
||||||
|
import rt4.Fonts;
|
||||||
|
import rt4.JagString;
|
||||||
|
|
||||||
|
public class API {
|
||||||
|
public static void DrawText(FontType fontType, FontColor color, TextModifier mod, String text, int screenX, int screenY) {
|
||||||
|
JagString js = JagString.parse(text);
|
||||||
|
|
||||||
|
Font font;
|
||||||
|
switch (fontType) {
|
||||||
|
case SMALL:
|
||||||
|
font = Fonts.p11Full;
|
||||||
|
break;
|
||||||
|
case LARGE:
|
||||||
|
font = Fonts.p12Full;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (mod) {
|
||||||
|
case CENTER:
|
||||||
|
font.renderCenter(js, screenX, screenY, color.colorCode, -1);
|
||||||
|
break;
|
||||||
|
case LEFT:
|
||||||
|
font.renderLeft(js, screenX, screenY, color.colorCode, -1);
|
||||||
|
break;
|
||||||
|
case RIGHT:
|
||||||
|
font.renderRight(js, screenX, screenY, color.colorCode, -1);
|
||||||
|
break;
|
||||||
|
case SHAKE:
|
||||||
|
font.renderShake(js, screenX, screenY, color.colorCode, -1, 100);
|
||||||
|
break;
|
||||||
|
case WAVE:
|
||||||
|
font.renderWave(js, screenX, screenY, color.colorCode, -1);
|
||||||
|
break;
|
||||||
|
case WAVE_2:
|
||||||
|
font.renderWave2(js, screenX, screenY, color.colorCode, -1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
17
client/src/main/java/plugin/api/FontColor.java
Normal file
17
client/src/main/java/plugin/api/FontColor.java
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
package plugin.api;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
public class FontColor {
|
||||||
|
public static FontColor YELLOW = new FontColor(16776960);
|
||||||
|
|
||||||
|
public final int colorCode;
|
||||||
|
|
||||||
|
FontColor(int colorCode) {
|
||||||
|
this.colorCode = colorCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static FontColor fromColor(Color color) {
|
||||||
|
return new FontColor(color.getRed() << 16 + color.getGreen() << 8 + color.getBlue());
|
||||||
|
}
|
||||||
|
}
|
||||||
6
client/src/main/java/plugin/api/FontType.java
Normal file
6
client/src/main/java/plugin/api/FontType.java
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
package plugin.api;
|
||||||
|
|
||||||
|
public enum FontType {
|
||||||
|
SMALL,
|
||||||
|
LARGE
|
||||||
|
}
|
||||||
10
client/src/main/java/plugin/api/TextModifier.java
Normal file
10
client/src/main/java/plugin/api/TextModifier.java
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
package plugin.api;
|
||||||
|
|
||||||
|
public enum TextModifier {
|
||||||
|
CENTER,
|
||||||
|
LEFT,
|
||||||
|
RIGHT,
|
||||||
|
SHAKE,
|
||||||
|
WAVE,
|
||||||
|
WAVE_2
|
||||||
|
}
|
||||||
|
|
@ -3,6 +3,7 @@ package rt4;
|
||||||
import org.openrs2.deob.annotation.OriginalArg;
|
import org.openrs2.deob.annotation.OriginalArg;
|
||||||
import org.openrs2.deob.annotation.OriginalMember;
|
import org.openrs2.deob.annotation.OriginalMember;
|
||||||
import org.openrs2.deob.annotation.Pc;
|
import org.openrs2.deob.annotation.Pc;
|
||||||
|
import plugin.PluginRepository;
|
||||||
|
|
||||||
public class Cheat {
|
public class Cheat {
|
||||||
@OriginalMember(owner = "client!p", name = "f", descriptor = "Lclient!na;")
|
@OriginalMember(owner = "client!p", name = "f", descriptor = "Lclient!na;")
|
||||||
|
|
@ -97,6 +98,7 @@ public class Cheat {
|
||||||
public static int rectDebug = 0;
|
public static int rectDebug = 0;
|
||||||
@OriginalMember(owner = "client!jg", name = "e", descriptor = "Z")
|
@OriginalMember(owner = "client!jg", name = "e", descriptor = "Z")
|
||||||
public static boolean qaOpTest = false;
|
public static boolean qaOpTest = false;
|
||||||
|
public static final JagString RELOADPLUGINS = JagString.parse("::reloadplugins");
|
||||||
|
|
||||||
@OriginalMember(owner = "client!en", name = "a", descriptor = "(IIIB)V")
|
@OriginalMember(owner = "client!en", name = "a", descriptor = "(IIIB)V")
|
||||||
public static void teleport(@OriginalArg(0) int arg0, @OriginalArg(1) int arg1, @OriginalArg(2) int arg2) {
|
public static void teleport(@OriginalArg(0) int arg0, @OriginalArg(1) int arg1, @OriginalArg(2) int arg2) {
|
||||||
|
|
@ -228,6 +230,9 @@ public class Cheat {
|
||||||
shiftClick = true;
|
shiftClick = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (arg0.equalsIgnoreCase(RELOADPLUGINS)) {
|
||||||
|
PluginRepository.reloadPlugins();
|
||||||
|
}
|
||||||
//}
|
//}
|
||||||
Protocol.outboundBuffer.p1isaac(44);
|
Protocol.outboundBuffer.p1isaac(44);
|
||||||
Protocol.outboundBuffer.p1(arg0.length() - 1);
|
Protocol.outboundBuffer.p1(arg0.length() - 1);
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package rt4;
|
||||||
import org.openrs2.deob.annotation.OriginalArg;
|
import org.openrs2.deob.annotation.OriginalArg;
|
||||||
import org.openrs2.deob.annotation.OriginalMember;
|
import org.openrs2.deob.annotation.OriginalMember;
|
||||||
import org.openrs2.deob.annotation.Pc;
|
import org.openrs2.deob.annotation.Pc;
|
||||||
|
import plugin.PluginRepository;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
|
|
@ -499,6 +500,7 @@ public class Cs1ScriptRunner {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (component.clientCode == 1405) {
|
if (component.clientCode == 1405) {
|
||||||
|
PluginRepository.Draw();
|
||||||
if (!Cheat.displayFps) {
|
if (!Cheat.displayFps) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,5 +26,5 @@ public class GlobalJsonConfig {
|
||||||
int wl_port;
|
int wl_port;
|
||||||
int js5_port;
|
int js5_port;
|
||||||
boolean mouseWheelZoom = GlobalConfig.MOUSEWHEEL_ZOOM;
|
boolean mouseWheelZoom = GlobalConfig.MOUSEWHEEL_ZOOM;
|
||||||
|
public String pluginsFolder = "plugins";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -154,7 +154,7 @@ public final class NpcType {
|
||||||
private int resizeY = 128;
|
private int resizeY = 128;
|
||||||
|
|
||||||
@OriginalMember(owner = "client!me", name = "s", descriptor = "I")
|
@OriginalMember(owner = "client!me", name = "s", descriptor = "I")
|
||||||
private int multiNpcVarbit = -1;
|
public int multiNpcVarbit = -1;
|
||||||
|
|
||||||
@OriginalMember(owner = "client!me", name = "fb", descriptor = "I")
|
@OriginalMember(owner = "client!me", name = "fb", descriptor = "I")
|
||||||
public int crawlSound = -1;
|
public int crawlSound = -1;
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package rt4;
|
||||||
import org.openrs2.deob.annotation.OriginalArg;
|
import org.openrs2.deob.annotation.OriginalArg;
|
||||||
import org.openrs2.deob.annotation.OriginalMember;
|
import org.openrs2.deob.annotation.OriginalMember;
|
||||||
import org.openrs2.deob.annotation.Pc;
|
import org.openrs2.deob.annotation.Pc;
|
||||||
|
import plugin.PluginRepository;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
|
@ -316,14 +317,14 @@ public final class ScriptRunner {
|
||||||
MaterialManager.method2731(0, 0, 0, 0, 0);
|
MaterialManager.method2731(0, 0, 0, 0, 0);
|
||||||
client.audioLoop();
|
client.audioLoop();
|
||||||
method3858();
|
method3858();
|
||||||
method2726(arg4, arg3, arg2, anInt5029, arg0, anInt5029);
|
drawOverheads(arg4, arg3, arg2, anInt5029, arg0, anInt5029);
|
||||||
MiniMap.method4000(arg3, arg2, arg0, anInt5029, anInt5029, arg4);
|
MiniMap.method4000(arg3, arg2, arg0, anInt5029, anInt5029, arg4);
|
||||||
} else {
|
} else {
|
||||||
SoftwareRaster.fillRect(arg2, arg4, arg3, arg0, 0);
|
SoftwareRaster.fillRect(arg2, arg4, arg3, arg0, 0);
|
||||||
SceneGraph.method2954(Camera.renderX, Camera.anInt40, Camera.renderZ, Camera.cameraPitch, Camera.cameraYaw, aByteArrayArrayArray15, anIntArray205, anIntArray338, anIntArray518, anIntArray134, anIntArray476, Player.plane + 1, local387, PlayerList.self.xFine >> 7, PlayerList.self.zFine >> 7);
|
SceneGraph.method2954(Camera.renderX, Camera.anInt40, Camera.renderZ, Camera.cameraPitch, Camera.cameraYaw, aByteArrayArrayArray15, anIntArray205, anIntArray338, anIntArray518, anIntArray134, anIntArray476, Player.plane + 1, local387, PlayerList.self.xFine >> 7, PlayerList.self.zFine >> 7);
|
||||||
client.audioLoop();
|
client.audioLoop();
|
||||||
method3858();
|
method3858();
|
||||||
method2726(arg4, arg3, arg2, 256, arg0, 256);
|
drawOverheads(arg4, arg3, arg2, 256, arg0, 256);
|
||||||
MiniMap.method4000(arg3, arg2, arg0, 256, 256, arg4);
|
MiniMap.method4000(arg3, arg2, arg0, 256, 256, arg4);
|
||||||
}
|
}
|
||||||
((Js5GlTextureProvider) Rasteriser.textureProvider).method3239(Protocol.sceneDelta);
|
((Js5GlTextureProvider) Rasteriser.textureProvider).method3239(Protocol.sceneDelta);
|
||||||
|
|
@ -350,7 +351,7 @@ public final class ScriptRunner {
|
||||||
}
|
}
|
||||||
|
|
||||||
@OriginalMember(owner = "client!lc", name = "a", descriptor = "(IIIIIII)V")
|
@OriginalMember(owner = "client!lc", name = "a", descriptor = "(IIIIIII)V")
|
||||||
public static void method2726(@OriginalArg(0) int arg0, @OriginalArg(1) int arg1, @OriginalArg(2) int arg2, @OriginalArg(3) int arg3, @OriginalArg(4) int arg4, @OriginalArg(5) int arg5) {
|
public static void drawOverheads(@OriginalArg(0) int arg0, @OriginalArg(1) int arg1, @OriginalArg(2) int arg2, @OriginalArg(3) int arg3, @OriginalArg(4) int arg4, @OriginalArg(5) int arg5) {
|
||||||
OverheadChat.size = 0;
|
OverheadChat.size = 0;
|
||||||
@Pc(5) int local5;
|
@Pc(5) int local5;
|
||||||
@Pc(642) int local642;
|
@Pc(642) int local642;
|
||||||
|
|
@ -360,18 +361,25 @@ public final class ScriptRunner {
|
||||||
@Pc(359) int local359;
|
@Pc(359) int local359;
|
||||||
@Pc(639) int local639;
|
@Pc(639) int local639;
|
||||||
for (local5 = -1; local5 < PlayerList.size + NpcList.size; local5++) {
|
for (local5 = -1; local5 < PlayerList.size + NpcList.size; local5++) {
|
||||||
@Pc(17) PathingEntity local17;
|
@Pc(17) PathingEntity entity;
|
||||||
if (local5 == -1) {
|
if (local5 == -1) {
|
||||||
local17 = PlayerList.self;
|
entity = PlayerList.self;
|
||||||
} else if (PlayerList.size > local5) {
|
} else if (PlayerList.size > local5) {
|
||||||
local17 = PlayerList.players[PlayerList.ids[local5]];
|
entity = PlayerList.players[PlayerList.ids[local5]];
|
||||||
} else {
|
} else {
|
||||||
local17 = NpcList.npcs[NpcList.ids[local5 - PlayerList.size]];
|
entity = NpcList.npcs[NpcList.ids[local5 - PlayerList.size]];
|
||||||
}
|
}
|
||||||
if (local17 != null && local17.isVisible()) {
|
if (entity != null && entity.isVisible()) {
|
||||||
|
setOverheadScreenCoordinateOffsets(arg4 >> 1, arg3, entity, arg5, entity.method2691() + 15, arg1 >> 1);
|
||||||
|
if (local5 >= PlayerList.size) {
|
||||||
|
PluginRepository.NPCOverheadDraw((Npc) entity,arg2 + anInt1951, arg0 + anInt548);
|
||||||
|
} else {
|
||||||
|
PluginRepository.PlayerOverheadDraw((Player) entity,arg2 + anInt1951, arg0 + anInt548);
|
||||||
|
}
|
||||||
|
|
||||||
@Pc(58) NpcType local58;
|
@Pc(58) NpcType local58;
|
||||||
if (local17 instanceof Npc) {
|
if (entity instanceof Npc) {
|
||||||
local58 = ((Npc) local17).type;
|
local58 = ((Npc) entity).type;
|
||||||
if (local58.multiNpcs != null) {
|
if (local58.multiNpcs != null) {
|
||||||
local58 = local58.getMultiNpc();
|
local58 = local58.getMultiNpc();
|
||||||
}
|
}
|
||||||
|
|
@ -381,17 +389,17 @@ public final class ScriptRunner {
|
||||||
}
|
}
|
||||||
@Pc(161) int local161;
|
@Pc(161) int local161;
|
||||||
if (local5 >= PlayerList.size) {
|
if (local5 >= PlayerList.size) {
|
||||||
local58 = ((Npc) local17).type;
|
local58 = ((Npc) entity).type;
|
||||||
if (local58.multiNpcs != null) {
|
if (local58.multiNpcs != null) {
|
||||||
local58 = local58.getMultiNpc();
|
local58 = local58.getMultiNpc();
|
||||||
}
|
}
|
||||||
if (local58.headicon >= 0 && Sprites.headiconPrayers.length > local58.headicon) {
|
if (local58.headicon >= 0 && Sprites.headiconPrayers.length > local58.headicon) {
|
||||||
if (local58.iconHeight == -1) {
|
if (local58.iconHeight == -1) {
|
||||||
local265 = local17.method2691() + 15;
|
local265 = entity.method2691() + 15;
|
||||||
} else {
|
} else {
|
||||||
local265 = local58.iconHeight + 15;
|
local265 = local58.iconHeight + 15;
|
||||||
}
|
}
|
||||||
method3326(arg4 >> 1, arg3, local17, arg5, local265, arg1 >> 1);
|
setOverheadScreenCoordinateOffsets(arg4 >> 1, arg3, entity, arg5, local265, arg1 >> 1);
|
||||||
if (anInt1951 > -1) {
|
if (anInt1951 > -1) {
|
||||||
Sprites.headiconPrayers[local58.headicon].render(arg2 + anInt1951 - 12, arg0 + -30 - -anInt548);
|
Sprites.headiconPrayers[local58.headicon].render(arg2 + anInt1951 - 12, arg0 + -30 - -anInt548);
|
||||||
}
|
}
|
||||||
|
|
@ -401,11 +409,11 @@ public final class ScriptRunner {
|
||||||
@Pc(322) MapMarker local322 = local308[local310];
|
@Pc(322) MapMarker local322 = local308[local310];
|
||||||
if (local322 != null && local322.type == 1 && local322.actorTargetId == NpcList.ids[local5 - PlayerList.size] && client.loop % 20 < 10) {
|
if (local322 != null && local322.type == 1 && local322.actorTargetId == NpcList.ids[local5 - PlayerList.size] && client.loop % 20 < 10) {
|
||||||
if (local58.iconHeight == -1) {
|
if (local58.iconHeight == -1) {
|
||||||
local359 = local17.method2691() + 15;
|
local359 = entity.method2691() + 15;
|
||||||
} else {
|
} else {
|
||||||
local359 = local58.iconHeight + 15;
|
local359 = local58.iconHeight + 15;
|
||||||
}
|
}
|
||||||
method3326(arg4 >> 1, arg3, local17, arg5, local359, arg1 >> 1);
|
setOverheadScreenCoordinateOffsets(arg4 >> 1, arg3, entity, arg5, local359, arg1 >> 1);
|
||||||
if (anInt1951 > -1) {
|
if (anInt1951 > -1) {
|
||||||
Sprites.headhints[local322.anInt4048].render(arg2 + anInt1951 - 12, anInt548 + -28 + arg0);
|
Sprites.headhints[local322.anInt4048].render(arg2 + anInt1951 - 12, anInt548 + -28 + arg0);
|
||||||
}
|
}
|
||||||
|
|
@ -413,9 +421,9 @@ public final class ScriptRunner {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
local74 = 30;
|
local74 = 30;
|
||||||
@Pc(77) Player local77 = (Player) local17;
|
@Pc(77) Player local77 = (Player) entity;
|
||||||
if (local77.anInt1669 != -1 || local77.anInt1649 != -1) {
|
if (local77.anInt1669 != -1 || local77.anInt1649 != -1) {
|
||||||
method3326(arg4 >> 1, arg3, local17, arg5, local17.method2691() + 15, arg1 >> 1);
|
setOverheadScreenCoordinateOffsets(arg4 >> 1, arg3, entity, arg5, entity.method2691() + 15, arg1 >> 1);
|
||||||
if (anInt1951 > -1) {
|
if (anInt1951 > -1) {
|
||||||
if (local77.anInt1669 != -1) {
|
if (local77.anInt1669 != -1) {
|
||||||
Sprites.headiconPks[local77.anInt1669].render(anInt1951 + arg2 - 12, arg0 + -30 + anInt548);
|
Sprites.headiconPks[local77.anInt1669].render(anInt1951 + arg2 - 12, arg0 + -30 + anInt548);
|
||||||
|
|
@ -432,7 +440,7 @@ public final class ScriptRunner {
|
||||||
for (local161 = 0; local161 < local159.length; local161++) {
|
for (local161 = 0; local161 < local159.length; local161++) {
|
||||||
@Pc(173) MapMarker local173 = local159[local161];
|
@Pc(173) MapMarker local173 = local159[local161];
|
||||||
if (local173 != null && local173.type == 10 && PlayerList.ids[local5] == local173.actorTargetId) {
|
if (local173 != null && local173.type == 10 && PlayerList.ids[local5] == local173.actorTargetId) {
|
||||||
method3326(arg4 >> 1, arg3, local17, arg5, local17.method2691() + 15, arg1 >> 1);
|
setOverheadScreenCoordinateOffsets(arg4 >> 1, arg3, entity, arg5, entity.method2691() + 15, arg1 >> 1);
|
||||||
if (anInt1951 > -1) {
|
if (anInt1951 > -1) {
|
||||||
Sprites.headhints[local173.anInt4048].render(arg2 + anInt1951 - 12, arg0 + (anInt548 - local74));
|
Sprites.headhints[local173.anInt4048].render(arg2 + anInt1951 - 12, arg0 + (anInt548 - local74));
|
||||||
}
|
}
|
||||||
|
|
@ -440,25 +448,25 @@ public final class ScriptRunner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (local17.chatMessage != null && (local5 >= PlayerList.size || Chat.publicFilter == 0 || Chat.publicFilter == 3 || Chat.publicFilter == 1 && FriendsList.contains(((Player) local17).username))) {
|
if (entity.chatMessage != null && (local5 >= PlayerList.size || Chat.publicFilter == 0 || Chat.publicFilter == 3 || Chat.publicFilter == 1 && FriendsList.contains(((Player) entity).username))) {
|
||||||
method3326(arg4 >> 1, arg3, local17, arg5, local17.method2691(), arg1 >> 1);
|
setOverheadScreenCoordinateOffsets(arg4 >> 1, arg3, entity, arg5, entity.method2691(), arg1 >> 1);
|
||||||
if (anInt1951 > -1 && OverheadChat.size < OverheadChat.CAPACITY) {
|
if (anInt1951 > -1 && OverheadChat.size < OverheadChat.CAPACITY) {
|
||||||
OverheadChat.anIntArray389[OverheadChat.size] = Fonts.b12Full.getStringWidth(local17.chatMessage) / 2;
|
OverheadChat.anIntArray389[OverheadChat.size] = Fonts.b12Full.getStringWidth(entity.chatMessage) / 2;
|
||||||
OverheadChat.anIntArray387[OverheadChat.size] = Fonts.b12Full.lineHeight;
|
OverheadChat.anIntArray387[OverheadChat.size] = Fonts.b12Full.lineHeight;
|
||||||
OverheadChat.anIntArray385[OverheadChat.size] = anInt1951;
|
OverheadChat.anIntArray385[OverheadChat.size] = anInt1951;
|
||||||
OverheadChat.anIntArray392[OverheadChat.size] = anInt548;
|
OverheadChat.anIntArray392[OverheadChat.size] = anInt548;
|
||||||
OverheadChat.colors[OverheadChat.size] = local17.chatColor;
|
OverheadChat.colors[OverheadChat.size] = entity.chatColor;
|
||||||
OverheadChat.effects[OverheadChat.size] = local17.chatEffect;
|
OverheadChat.effects[OverheadChat.size] = entity.chatEffect;
|
||||||
OverheadChat.loops[OverheadChat.size] = local17.chatLoops;
|
OverheadChat.loops[OverheadChat.size] = entity.chatLoops;
|
||||||
OverheadChat.messages[OverheadChat.size] = local17.chatMessage;
|
OverheadChat.messages[OverheadChat.size] = entity.chatMessage;
|
||||||
OverheadChat.size++;
|
OverheadChat.size++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (local17.hitpointsBarVisibleUntil > client.loop) {
|
if (entity.hitpointsBarVisibleUntil > client.loop) {
|
||||||
@Pc(508) Sprite local508 = Sprites.hitbars[0];
|
@Pc(508) Sprite local508 = Sprites.hitbars[0];
|
||||||
@Pc(512) Sprite local512 = Sprites.hitbars[1];
|
@Pc(512) Sprite local512 = Sprites.hitbars[1];
|
||||||
if (local17 instanceof Npc) {
|
if (entity instanceof Npc) {
|
||||||
@Pc(518) Npc local518 = (Npc) local17;
|
@Pc(518) Npc local518 = (Npc) entity;
|
||||||
@Pc(528) Sprite[] local528 = (Sprite[]) HitBarList.hitBars.get(local518.type.hitBarId);
|
@Pc(528) Sprite[] local528 = (Sprite[]) HitBarList.hitBars.get(local518.type.hitBarId);
|
||||||
if (local528 == null) {
|
if (local528 == null) {
|
||||||
local528 = SpriteLoader.loadAlphaSprites(local518.type.hitBarId, client.js5Archive8);
|
local528 = SpriteLoader.loadAlphaSprites(local518.type.hitBarId, client.js5Archive8);
|
||||||
|
|
@ -472,19 +480,19 @@ public final class ScriptRunner {
|
||||||
}
|
}
|
||||||
@Pc(571) NpcType local571 = local518.type;
|
@Pc(571) NpcType local571 = local518.type;
|
||||||
if (local571.iconHeight == -1) {
|
if (local571.iconHeight == -1) {
|
||||||
local310 = local17.method2691();
|
local310 = entity.method2691();
|
||||||
} else {
|
} else {
|
||||||
local310 = local571.iconHeight;
|
local310 = local571.iconHeight;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
local310 = local17.method2691();
|
local310 = entity.method2691();
|
||||||
}
|
}
|
||||||
method3326(arg4 >> 1, arg3, local17, arg5, local508.height + local310 + 10, arg1 >> 1);
|
setOverheadScreenCoordinateOffsets(arg4 >> 1, arg3, entity, arg5, local508.height + local310 + 10, arg1 >> 1);
|
||||||
if (anInt1951 > -1) {
|
if (anInt1951 > -1) {
|
||||||
local161 = anInt1951 + arg2 - (local508.width >> 1);
|
local161 = anInt1951 + arg2 - (local508.width >> 1);
|
||||||
local359 = anInt548 + arg0 - 3;
|
local359 = anInt548 + arg0 - 3;
|
||||||
local508.render(local161, local359);
|
local508.render(local161, local359);
|
||||||
local639 = local508.width * local17.hitpointsBar / 255;
|
local639 = local508.width * entity.hitpointsBar / 255;
|
||||||
local642 = local508.height;
|
local642 = local508.height;
|
||||||
if (GlRenderer.enabled) {
|
if (GlRenderer.enabled) {
|
||||||
GlRaster.method1183(local161, local359, local161 + local639, local359 + local642);
|
GlRaster.method1183(local161, local359, local161 + local639, local359 + local642);
|
||||||
|
|
@ -500,19 +508,19 @@ public final class ScriptRunner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (local74 = 0; local74 < 4; local74++) {
|
for (local74 = 0; local74 < 4; local74++) {
|
||||||
if (local17.hitVisibleUntil[local74] > client.loop) {
|
if (entity.hitVisibleUntil[local74] > client.loop) {
|
||||||
if (local17 instanceof Npc) {
|
if (entity instanceof Npc) {
|
||||||
@Pc(725) Npc local725 = (Npc) local17;
|
@Pc(725) Npc local725 = (Npc) entity;
|
||||||
@Pc(728) NpcType local728 = local725.type;
|
@Pc(728) NpcType local728 = local725.type;
|
||||||
if (local728.iconHeight == -1) {
|
if (local728.iconHeight == -1) {
|
||||||
local265 = local17.method2691() / 2;
|
local265 = entity.method2691() / 2;
|
||||||
} else {
|
} else {
|
||||||
local265 = local728.iconHeight / 2;
|
local265 = local728.iconHeight / 2;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
local265 = local17.method2691() / 2;
|
local265 = entity.method2691() / 2;
|
||||||
}
|
}
|
||||||
method3326(arg4 >> 1, arg3, local17, arg5, local265, arg1 >> 1);
|
setOverheadScreenCoordinateOffsets(arg4 >> 1, arg3, entity, arg5, local265, arg1 >> 1);
|
||||||
if (anInt1951 > -1) {
|
if (anInt1951 > -1) {
|
||||||
if (local74 == 1) {
|
if (local74 == 1) {
|
||||||
anInt548 -= 20;
|
anInt548 -= 20;
|
||||||
|
|
@ -525,8 +533,8 @@ public final class ScriptRunner {
|
||||||
anInt548 -= 10;
|
anInt548 -= 10;
|
||||||
anInt1951 += 15;
|
anInt1951 += 15;
|
||||||
}
|
}
|
||||||
Sprites.hitmarks[local17.hitTypes[local74]].render(arg2 + anInt1951 - 12, arg0 + anInt548 - 12);
|
Sprites.hitmarks[entity.hitTypes[local74]].render(arg2 + anInt1951 - 12, arg0 + anInt548 - 12);
|
||||||
Fonts.p11Full.renderCenter(JagString.parseInt(local17.hitDamages[local74]), anInt1951 + arg2 - 1, anInt548 + 3 + arg0, 16777215, 0);
|
Fonts.p11Full.renderCenter(JagString.parseInt(entity.hitDamages[local74]), anInt1951 + arg2 - 1, anInt548 + 3 + arg0, 16777215, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1224,7 +1232,7 @@ public final class ScriptRunner {
|
||||||
}
|
}
|
||||||
|
|
||||||
@OriginalMember(owner = "client!og", name = "a", descriptor = "(BIILclient!fe;III)V")
|
@OriginalMember(owner = "client!og", name = "a", descriptor = "(BIILclient!fe;III)V")
|
||||||
public static void method3326(@OriginalArg(1) int arg0, @OriginalArg(2) int arg1, @OriginalArg(3) PathingEntity arg2, @OriginalArg(4) int arg3, @OriginalArg(5) int arg4, @OriginalArg(6) int arg5) {
|
public static void setOverheadScreenCoordinateOffsets(@OriginalArg(1) int arg0, @OriginalArg(2) int arg1, @OriginalArg(3) PathingEntity arg2, @OriginalArg(4) int arg3, @OriginalArg(5) int arg4, @OriginalArg(6) int arg5) {
|
||||||
method1026(arg5, arg1, arg2.zFine, arg4, arg0, arg2.xFine, arg3);
|
method1026(arg5, arg1, arg2.zFine, arg4, arg0, arg2.xFine, arg3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package rt4;
|
||||||
import org.openrs2.deob.annotation.OriginalArg;
|
import org.openrs2.deob.annotation.OriginalArg;
|
||||||
import org.openrs2.deob.annotation.OriginalMember;
|
import org.openrs2.deob.annotation.OriginalMember;
|
||||||
import org.openrs2.deob.annotation.Pc;
|
import org.openrs2.deob.annotation.Pc;
|
||||||
|
import plugin.PluginRepository;
|
||||||
|
|
||||||
public class WorldMap {
|
public class WorldMap {
|
||||||
@OriginalMember(owner = "client!nc", name = "e", descriptor = "Lclient!na;")
|
@OriginalMember(owner = "client!nc", name = "e", descriptor = "Lclient!na;")
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import org.openrs2.deob.annotation.OriginalArg;
|
||||||
import org.openrs2.deob.annotation.OriginalClass;
|
import org.openrs2.deob.annotation.OriginalClass;
|
||||||
import org.openrs2.deob.annotation.OriginalMember;
|
import org.openrs2.deob.annotation.OriginalMember;
|
||||||
import org.openrs2.deob.annotation.Pc;
|
import org.openrs2.deob.annotation.Pc;
|
||||||
|
import plugin.PluginRepository;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
@ -217,6 +218,7 @@ public final class client extends GameShell {
|
||||||
public static void main(@OriginalArg(0) String[] arg0) {
|
public static void main(@OriginalArg(0) String[] arg0) {
|
||||||
try {
|
try {
|
||||||
GlobalJsonConfig.load(GlobalConfig.EXTENDED_CONFIG_PATH);
|
GlobalJsonConfig.load(GlobalConfig.EXTENDED_CONFIG_PATH);
|
||||||
|
PluginRepository.Init();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
27
plugin-playground/build.gradle
Normal file
27
plugin-playground/build.gradle
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
plugins {
|
||||||
|
id 'java'
|
||||||
|
}
|
||||||
|
|
||||||
|
version 'unspecified'
|
||||||
|
|
||||||
|
targetCompatibility = 1.8
|
||||||
|
sourceCompatibility = 1.8
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
|
||||||
|
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
|
||||||
|
implementation(rootProject.project("client"))
|
||||||
|
}
|
||||||
|
|
||||||
|
test {
|
||||||
|
useJUnitPlatform()
|
||||||
|
}
|
||||||
|
|
||||||
|
task buildPlugins {
|
||||||
|
dependsOn(classes)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
package OverheadDebugPlugin;
|
||||||
|
|
||||||
|
import plugin.Plugin;
|
||||||
|
import plugin.api.API;
|
||||||
|
import plugin.api.FontColor;
|
||||||
|
import plugin.api.FontType;
|
||||||
|
import plugin.api.TextModifier;
|
||||||
|
import rt4.*;
|
||||||
|
|
||||||
|
public class plugin extends Plugin {
|
||||||
|
@Override
|
||||||
|
public void PlayerOverheadDraw(Player player, int screenX, int screenY) {
|
||||||
|
API.DrawText(
|
||||||
|
FontType.SMALL,
|
||||||
|
FontColor.YELLOW,
|
||||||
|
TextModifier.CENTER,
|
||||||
|
player.username.toString(),
|
||||||
|
screenX,
|
||||||
|
screenY
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void NPCOverheadDraw(Npc npc, int screenX, int screenY) {
|
||||||
|
String npcSb =
|
||||||
|
(npc.type.name.strEquals(JagString.parse("null"))
|
||||||
|
? npc.type.getMultiNpc() != null
|
||||||
|
? "Wrapper [" + npc.type.getMultiNpc().name + " " + npc.type.getMultiNpc().id + "]"
|
||||||
|
: "Wrapper"
|
||||||
|
: npc.type.name) +
|
||||||
|
" [Lvl: " +
|
||||||
|
npc.type.combatLevel +
|
||||||
|
"] [ID: " +
|
||||||
|
npc.type.id +
|
||||||
|
"] [Vb: " +
|
||||||
|
npc.type.multiNpcVarbit + "]";
|
||||||
|
|
||||||
|
API.DrawText(
|
||||||
|
FontType.SMALL,
|
||||||
|
FontColor.YELLOW,
|
||||||
|
TextModifier.CENTER,
|
||||||
|
npcSb,
|
||||||
|
screenX,
|
||||||
|
screenY
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -17,3 +17,5 @@ include(
|
||||||
)
|
)
|
||||||
|
|
||||||
startParameter.excludedTaskNames << ':playground:run'
|
startParameter.excludedTaskNames << ':playground:run'
|
||||||
|
include 'plugin-playground'
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue