Skip to content
Merged
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: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ project.build.group=net.runelite
project.build.version=1.12.22

glslang.path=
microbot.version=2.1.29
microbot.version=2.1.30
microbot.commit.sha=nogit
microbot.repo.url=http://138.201.81.246:8081/repository/microbot-snapshot/
microbot.repo.username=
Expand Down
30 changes: 29 additions & 1 deletion runelite-client/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,32 @@ tasks.register<Test>("runTests") {
}
}

tasks.register<Test>("runIntegrationTest") {
group = "verification"
description = "Run Rs2ActorModel integration test with live client"
enabled = true

testClassesDirs = sourceSets.test.get().output.classesDirs
classpath = sourceSets.test.get().runtimeClasspath

jvmArgs(
"-Dfile.encoding=UTF-8",
"-Duser.timezone=Europe/Brussels",
"-ea"
)

include("**/Rs2ActorModelIntegrationTest.class")
include("**/Rs2WalkerIntegrationTest.class")

useJUnit()

testLogging {
events("passed", "skipped", "failed")
showStandardStreams = true
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
}
}

lombok.version = libs.versions.lombok.get()

java {
Expand Down Expand Up @@ -303,7 +329,9 @@ tasks.checkstyleMain {
}

tasks.withType<Test> {
enabled = false
if (name != "runIntegrationTest" && name != "runTests" && name != "runDebugTests") {
enabled = false
}
systemProperty("glslang.path", providers.gradleProperty("glslangPath").getOrElse(""))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,13 @@ public int getHealthScale()
@Override
public WorldPoint getWorldLocation()
{
if (getWorldView() != null && getWorldView().getId() != -1) {
return Microbot.getClientThread().invoke(this::projectActorLocationToMainWorld);
}

return actor.getWorldLocation();
return Microbot.getClientThread().invoke(() -> {
WorldView worldView = actor.getWorldView();
if (worldView != null && !worldView.isTopLevel()) {
return projectActorLocationToMainWorld();
}
return actor.getWorldLocation();
});
}

@Override
Expand Down Expand Up @@ -450,17 +452,15 @@ public long getHash()

public WorldPoint projectActorLocationToMainWorld() {
WorldPoint actorLocation = actor.getWorldLocation();
LocalPoint localPoint = LocalPoint.fromWorld(
getWorldView(),
actorLocation
);
WorldView wv = actor.getWorldView();
LocalPoint localPoint = LocalPoint.fromWorld(wv, actorLocation);

if (localPoint == null)
{
return actorLocation;
}

var mainWorldProjection = getWorldView().getMainWorldProjection();
var mainWorldProjection = wv.getMainWorldProjection();

if (mainWorldProjection == null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import net.runelite.client.plugins.microbot.api.player.Rs2PlayerCache;
import net.runelite.client.plugins.microbot.util.player.Rs2PlayerModel;
import net.runelite.client.plugins.microbot.util.reachable.Rs2Reachable;
import net.runelite.client.plugins.microbot.util.walker.Rs2Walker;

import javax.inject.Inject;
import java.util.ArrayList;
Expand Down Expand Up @@ -56,59 +57,26 @@ public boolean run() {
try {
if (!Microbot.isLoggedIn()) return;

/*
if (Microbot.getClient().getTopLevelWorldView().getScene().isInstance()) {
LocalPoint l = LocalPoint.fromWorld(Microbot.getClient().getTopLevelWorldView(), Microbot.getClient().getLocalPlayer().getWorldLocation());
System.out.println("was here");
WorldPoint.fromLocalInstance(Microbot.getClient(), l);
} else {
System.out.println("was here lol");
// this needs to ran on client threaad if we are on the sea
var a = Microbot.getClient().getLocalPlayer().getWorldLocation();
System.out.println(a);
}*/

var shipwreck = rs2TileObjectCache.query()
.where(x -> x.getName() != null && x.getName().toLowerCase().contains("shipwreck"))
.within(5)
.nearestOnClientThread();
var player = new Rs2PlayerModel();

var isInvFull = Rs2Inventory.count() >= Rs2Random.between(24, 28);
if (isInvFull && Rs2Inventory.count("salvage") > 0 && player.getAnimation() == -1) {
// Rs2Inventory.dropAll("large salvage");
rs2TileObjectCache.query()
.fromWorldView()
.where(x -> x.getName() != null && x.getName().equalsIgnoreCase("salvaging station"))
.where(x -> x.getWorldView().getId() == new Rs2PlayerModel().getWorldView().getId())
.nearestOnClientThread()
.click();
sleepUntil(() -> Rs2Inventory.count("salvage") == 0, 60000);
} else if (isInvFull) {
dropJunk();
} else {
if (player.getAnimation() != -1) {
log.info("Currently salvaging, waiting...");
sleep(5000, 10000);
return;
}
if (Rs2Inventory.isFull()) {
Rs2Inventory.dropAll("Logs");
return;
}

if (shipwreck == null) {
log.info("No shipwreck found nearby");
sleep(5000);
dropJunk();
return;
}
if (Rs2Player.isAnimating()) return;

rs2TileObjectCache.query().fromWorldView().where(x -> x.getName() != null && x.getName().toLowerCase().contains("salvaging hook")).nearestOnClientThread().click("Deploy");
sleepUntil(() -> player.getAnimation() != -1, 5000);
var tree = Microbot.getRs2TileObjectCache().query()
.withName("Tree")
.nearest();

if (tree != null) {
tree.click("Chop down");
sleepUntil(Rs2Player::isAnimating, 3000);
}

} catch (Exception ex) {
log.error("Error in performance test loop", ex);
log.error("Error in example script", ex);
}
}, 0, 1000, TimeUnit.MILLISECONDS);
}, 0, 600, TimeUnit.MILLISECONDS);

return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ private boolean attemptToAcquireRequirementItem(DetailedQuestStep questStep, Ite

if (worldPoint != null) {
if ((Rs2Walker.canReach(worldPoint) && worldPoint.distanceTo(Rs2Player.getWorldLocation()) < 2)
|| worldPoint.toWorldArea().hasLineOfSightTo(Microbot.getClient().getTopLevelWorldView(), Microbot.getClient().getLocalPlayer().getWorldLocation().toWorldArea())
|| worldPoint.toWorldArea().hasLineOfSightTo(Microbot.getClient().getTopLevelWorldView(), Rs2Player.getWorldLocation().toWorldArea())
&& Rs2Camera.isTileOnScreen(LocalPoint.fromWorld(Microbot.getClient().getTopLevelWorldView(), worldPoint))) {
lootGroundItem(targetItemId, 10);
} else {
Expand Down Expand Up @@ -464,7 +464,7 @@ public boolean applyNpcStep(NpcStep step) {
} else if (npc != null && (!npc.hasLineOfSight() || !Rs2Walker.canReach(npc.getWorldLocation()))) {
Rs2Walker.walkTo(npc.getWorldLocation(), 2);
} else {
if (step.getDefinedPoint().getWorldPoint().distanceTo(Microbot.getClient().getLocalPlayer().getWorldLocation()) > 3) {
if (step.getDefinedPoint().getWorldPoint().distanceTo(Rs2Player.getWorldLocation()) > 3) {
Rs2Walker.walkTo(step.getDefinedPoint().getWorldPoint(), 2);
return false;
}
Expand Down Expand Up @@ -517,7 +517,7 @@ public boolean applyObjectStep(ObjectStep step) {
return false;
}

if (step.getDefinedPoint().getWorldPoint() != null && Microbot.getClient().getLocalPlayer().getWorldLocation().distanceTo2D(step.getDefinedPoint().getWorldPoint()) > 1
if (step.getDefinedPoint().getWorldPoint() != null && Rs2Player.getWorldLocation().distanceTo2D(step.getDefinedPoint().getWorldPoint()) > 1
&& (object == null || !Rs2Walker.canReach(object.getWorldLocation()))) {
WorldPoint targetTile = null;
WorldPoint stepLocation = object == null ? step.getDefinedPoint().getWorldPoint() : object.getWorldLocation();
Expand Down Expand Up @@ -641,7 +641,7 @@ private boolean hasLineOfSightToObject(Rs2TileObjectModel object) {
}

WorldArea objectArea = object.getWorldLocation().toWorldArea();
WorldArea playerArea = Microbot.getClient().getLocalPlayer().getWorldLocation().toWorldArea();
WorldArea playerArea = Rs2Player.getWorldLocation().toWorldArea();

return Microbot.getClient().getTopLevelWorldView() != null
&& playerArea.hasLineOfSightTo(Microbot.getClient().getTopLevelWorldView(), objectArea);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ public class Cheerer
public static void createCheerers(RuneliteObjectManager runeliteObjectManager, Client client, ConfigManager configManager)
{
cheerers.clear();
if (client.getLocalPlayer() == null)
{
return;
}
createWOM(runeliteObjectManager, client);
createZoinkwiz(runeliteObjectManager, client);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,10 @@ public void onClientTick(ClientTick event)
{
redClickAnimationFrame++;
}
if (client.getLocalPlayer() == null)
{
return;
}
WorldPoint playerPosition = WorldPoint.fromLocalInstance(client, client.getLocalPlayer().getLocalLocation());
runeliteObjectGroups.forEach((groupID, extendedRuneliteObjectGroup) -> {
for (ExtendedRuneliteObject extendedRuneliteObject : extendedRuneliteObjectGroup.extendedRuneliteObjects)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,25 @@ private static int packedPointFromOrdinal(int startPacked, OrdinalDirection dire
new WorldPoint(3672, 3862, 0)
);

private volatile int cachedRegionId = -1;
private volatile long cachedRegionIdTime = 0;
private static final long REGION_CACHE_MS = 5000;
private static final int TOA_PUZZLE_REGION = 14162;

private int getCachedRegionId() {
long now = System.currentTimeMillis();
if (now - cachedRegionIdTime > REGION_CACHE_MS) {
try {
WorldPoint loc = Rs2Player.getWorldLocation();
cachedRegionId = loc != null ? loc.getRegionID() : -1;
} catch (Exception e) {
cachedRegionId = -1;
}
cachedRegionIdTime = now;
}
return cachedRegionId;
}

public List<Node> getNeighbors(Node node, VisitedTiles visited, PathfinderConfig config, Set<Integer> targets) {
final int x = WorldPointUtil.unpackWorldX(node.packedPosition);
final int y = WorldPointUtil.unpackWorldY(node.packedPosition);
Expand Down Expand Up @@ -167,7 +186,7 @@ public List<Node> getNeighbors(Node node, VisitedTiles visited, PathfinderConfig
* This piece of code is designed to allow web walker to be used in toa puzzle room
* it will dodge specific tiles in the sequence room
*/
if (Rs2Player.getWorldLocation().getRegionID() == 14162) { //toa puzzle room
if (getCachedRegionId() == TOA_PUZZLE_REGION) {
if (!targets.contains(neighborPacked)) {
WorldPoint globalWorldPoint = Rs2WorldPoint.convertInstancedWorldPoint(WorldPointUtil.unpackWorldPoint(neighborPacked));
if (globalWorldPoint != null) {
Expand Down
Loading
Loading