Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Ardougne Cloak support #3

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
63 changes: 62 additions & 1 deletion com/dax/walker/engine/EntityHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,20 @@
import org.rspeer.runetek.adapter.Positionable;
import org.rspeer.runetek.adapter.component.InterfaceComponent;
import org.rspeer.runetek.adapter.scene.Npc;
import org.rspeer.runetek.api.Game;
import org.rspeer.runetek.api.commons.Time;
import org.rspeer.runetek.api.component.Dialog;
import org.rspeer.runetek.api.component.tab.Inventory;
import org.rspeer.runetek.api.movement.position.Position;
import org.rspeer.runetek.api.movement.transportation.CharterShip;
import org.rspeer.runetek.api.scene.Npcs;
import org.rspeer.runetek.api.scene.Players;
import org.rspeer.ui.Log;

import java.util.Arrays;
import java.util.Comparator;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.logging.Level;
import java.util.regex.Pattern;

@DoNotRename
Expand Down Expand Up @@ -48,7 +53,63 @@ public static PathHandleState handleCharter(CharterShip.Destination destination,
if (!CharterShip.isInterfaceOpen()) return PathHandleState.FAILED;
return CharterShip.charter(destination) ? PathHandleState.SUCCESS : PathHandleState.FAILED;
}


public static PathHandleState handleShantayPass(WalkCondition walkCondition) {
Npc shantay = Npcs.getNearest("Shantay");

AtomicBoolean exitCondition = new AtomicBoolean(false);
if (!Inventory.contains("Shantay pass") && (shantay == null || !shantay.interact("Buy-pass") || !Time.sleepUntil(() -> {
if (Inventory.contains("Shantay pass")) {
return true;
}
if (walkCondition.getAsBoolean()) {
exitCondition.set(true);
return true;
}
return false;
},5000))){
return PathHandleState.FAILED;
}
if (exitCondition.get()) return PathHandleState.EXIT;
return BrokenPathHandler.handle(new Position(3304, 3117, 0), new Position(3304, 3315, 0), walkCondition);
}

public static PathHandleState handleMagicCarpet(WalkCondition walkCondition, String destination) {
Npc target = Npcs.getNearest(npc -> npc.getName().equals("Rug Merchant") && npc.containsAction("Travel"));

if (target == null) return PathHandleState.FAILED;
if (!target.interact("Travel")) return PathHandleState.FAILED;

AtomicBoolean exitCondition = new AtomicBoolean(false);
if (Time.sleepUntil(() -> {
if (Dialog.isViewingChatOptions()) {
return true;
}
if (walkCondition.getAsBoolean()) {
exitCondition.set(true);
return true;
}
return false;
},5000) && exitCondition.get()){
return PathHandleState.EXIT;
}
if (!Dialog.process(destination)) return PathHandleState.FAILED;
if (!Time.sleepUntil(() -> Players.getLocal().getStance() == 6936, 10000)) return PathHandleState.FAILED;
if (Time.sleepUntil(() -> {
if (Players.getLocal().getStance() != 6936) {
return true;
}
if (walkCondition.getAsBoolean()) {
exitCondition.set(true);
return true;
}
return false;
},60000) && exitCondition.get()){
return PathHandleState.EXIT;
}
return PathHandleState.SUCCESS;
}

public static boolean selectOption() {
InterfaceComponent option = Arrays.stream(Dialog.getChatOptions())
.max(Comparator.comparingInt(o -> getResponseValue(o.getText())))
Expand Down
20 changes: 20 additions & 0 deletions com/dax/walker/engine/definitions/PathLink.java
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,26 @@ public enum PathLink {
DEATH_PLATEAU_DUNGEON (
new Position(2858, 3577, 0), new Position(2269,4752,0),
(start, end, walkCondition) -> BrokenPathHandler.NextMove.SAME_FLOOR.handle() ? PathHandleState.SUCCESS : PathHandleState.FAILED
),

CARPET_SHANTAY_POLLNIVNEACH (
new Position(3311, 3109, 0), new Position(3350, 3002, 0),
(start, end, walkCondition) -> EntityHandler.handleMagicCarpet(walkCondition, "Pollnivneach")
),

CARPET_SHANTAY_BEDABIN_CAMP (
new Position(3311, 3109, 0), new Position(3181, 3043, 0),
(start, end, walkCondition) -> EntityHandler.handleMagicCarpet(walkCondition, "Bedabin camp")
),

CARPET_BEDABIN_CAMP_SHANTAY (
new Position(3181, 3043, 0), new Position(3311, 3109, 0),
(start, end, walkCondition) -> EntityHandler.handleMagicCarpet(walkCondition, "Shantay Pass")
),

CARPET_POLLNIVNEACH_SHANTAY (
new Position(3350, 3002, 0), new Position(3311, 3109, 0),
(start, end, walkCondition) -> EntityHandler.handleMagicCarpet(walkCondition, "Shantay Pass")
);

private Position a;
Expand Down
5 changes: 4 additions & 1 deletion com/dax/walker/engine/definitions/PopUpInterfaces.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

import org.rspeer.runetek.adapter.component.InterfaceComponent;
import org.rspeer.runetek.api.commons.Time;
import org.rspeer.runetek.api.component.InterfaceAddress;
import org.rspeer.runetek.api.component.Interfaces;

public enum PopUpInterfaces {

STRONGHOLD_PROMPT(() -> Interfaces.getComponent(579, 17)),
WILDERNESS_PROMPT(() -> Interfaces.getComponent(475, 11));
WILDERNESS_PROMPT(() -> Interfaces.getComponent(475, 11)),
SHANTAY_PROMPT(() -> Interfaces.getComponent(565, 17));

private RSPopUp rsPopUp;

Expand Down
10 changes: 8 additions & 2 deletions com/dax/walker/engine/definitions/Teleport.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,14 @@ public enum Teleport {
() -> WearableItemTeleport.has(WearableItemTeleport.GLORY_MATCHER),
() -> WearableItemTeleport.teleport(WearableItemTeleport.GLORY_MATCHER, Pattern.compile("(?i).*al kharid.*"))
),

;

ARDOUGNE_CLOAK_MONASTERY(
35, new Position(2609, 3222, 0),
() -> WearableItemTeleport.has(WearableItemTeleport.ARDOUGNE_CLOAK_MATCHER),
() -> WearableItemTeleport.teleport(WearableItemTeleport.ARDOUGNE_CLOAK_MATCHER, Pattern.compile("(?i).*monastery teleport.*"))
);



private int moveCost;
private Position location;
Expand Down
4 changes: 3 additions & 1 deletion com/dax/walker/engine/definitions/WearableItemTeleport.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class WearableItemTeleport {
public static final Pattern COMBAT_BRACE_MATCHER = Pattern.compile("(?i)combat brace.+\\(.+");
public static final Pattern GAMES_NECKLACE_MATCHER = Pattern.compile("(?i)game.+neck.+\\(.+");
public static final Pattern GLORY_MATCHER = Pattern.compile("(?i).+glory.*\\(.+");
public static final Pattern ARDOUGNE_CLOAK_MATCHER = Pattern.compile("(?i)ardougne cloak.?.+");


private WearableItemTeleport() {
Expand All @@ -31,7 +32,8 @@ public static boolean teleport(Pattern itemMatcher, Pattern option) {
if (teleportEquipment(itemMatcher, option)) return true;
Item inventoryItem = Inventory.getFirst(item -> itemMatcher.matcher(item.getName()).matches() && !item.isNoted());
if (inventoryItem == null) return false;
if (!inventoryItem.interact(s -> option.matcher(s).matches()) && !inventoryItem.interact("Rub")) return false;
if (inventoryItem.interact(s -> option.matcher(s).matches())) return true;
if (!inventoryItem.interact("Rub")) return false;
if (!Time.sleepUntil(Dialog::isOpen, 5000)) return false;
return Dialog.process(s -> option.matcher(s).matches());
}
Expand Down