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
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ protected void startUp() {
cacheConfigValues();
SplitFlagMap map = SplitFlagMap.fromResources();
Map<WorldPoint, Set<Transport>> transports = Transport.loadAllFromResources();

List<Restriction> restrictions = Restriction.loadAllFromResources();
pathfinderConfig = new PathfinderConfig(map, transports, restrictions, client, config);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
import net.runelite.api.Skill;
import net.runelite.api.coords.WorldPoint;
import net.runelite.client.plugins.microbot.Microbot;
import net.runelite.client.plugins.microbot.util.poh.PohTeleports;
import net.runelite.client.plugins.microbot.util.poh.PohTransport;
import net.runelite.client.plugins.microbot.util.poh.data.HouseStyle;
import net.runelite.client.plugins.microbot.util.poh.data.MountedMythical;
import net.runelite.client.plugins.microbot.util.poh.data.NexusPortal;

import java.io.IOException;
import java.io.InputStream;
Expand All @@ -27,14 +32,6 @@ public class Transport {
private int objectId;
@Getter
private String name;
/**
* Used by PohTransport to trace back to the PohTransportable that can execute the teleportation
*/
@Getter
private String enumValue;
@Getter
private String enumClass;
//END microbot variables

/**
* A location placeholder different from null to use for permutation transports
Expand Down Expand Up @@ -134,7 +131,7 @@ public class Transport {
* Creates a new transport from an origin-only transport
* and a destination-only transport, and merges requirements
*/
Transport(Transport origin, Transport destination) {
public Transport(Transport origin, Transport destination) {
this.origin = origin.origin;
this.destination = destination.destination;

Expand Down Expand Up @@ -174,14 +171,57 @@ public class Transport {
//START microbot variables
this.name = origin.getName();
this.objectId = origin.getObjectId();
this.enumValue = origin.getEnumValue();
this.action = origin.getAction();
this.currencyName = origin.getCurrencyName();
this.currencyAmount = origin.getCurrencyAmount();
this.isMembers = origin.isMembers;
//END microbot variables
}

/**
* Base Transport constructor
*/
public Transport(WorldPoint origin, WorldPoint destination, String displayInfo, TransportType transportType, boolean isMember, int duration) {
this.origin = origin;
this.destination = destination;
this.displayInfo = displayInfo;
this.type = transportType;
this.isMembers = isMember;
this.duration = duration;
}

/**
* Object interaction Transport constructor
*/
public Transport(WorldPoint origin, WorldPoint destination, String displayInfo, TransportType transportType, boolean isMember, String action, String target, int objectId) {
this(origin, destination, displayInfo, transportType, isMember, 1);
this.action = action;
this.name = target;
this.objectId = objectId;
}

/**
* Transport constructor with item requirements
*/
public Transport(WorldPoint destination, String displayInfo, TransportType transportType, boolean isMember, int maxWildernessLevel, Set<Set<Integer>> itemIdRequirements) {
this(null, destination, displayInfo, transportType, isMember, 1);
this.maxWildernessLevel = maxWildernessLevel;
this.itemIdRequirements = itemIdRequirements != null ? new HashSet<>(itemIdRequirements) : new HashSet<>();
}

/**
* Transport constructor with skill requirements
*/
public Transport(WorldPoint destination, String displayInfo, TransportType transportType, boolean isMember, int maxWildernessLevel, Map<Skill, Integer> skillRequirement) {
this(null, destination, displayInfo, transportType, isMember, 1);
this.maxWildernessLevel = maxWildernessLevel;
if (skillRequirement != null) {
for (Map.Entry<Skill, Integer> entry : skillRequirement.entrySet()) {
this.skillLevels[entry.getKey().ordinal()] = entry.getValue();
}
}
}

Transport(Map<String, String> fieldMap, TransportType transportType) {
final String DELIM = " ";
final String DELIM_MULTI = ";";
Expand Down Expand Up @@ -209,13 +249,6 @@ public class Transport {
}

//START microbot variables
if((value = fieldMap.get("EnumValue")) != null && !value.trim().isEmpty()) {
this.enumValue = value.trim();
}
if((value = fieldMap.get("EnumClass")) != null && !value.trim().isEmpty()) {
this.enumClass = value.trim();
}

if ((value = fieldMap.get("menuOption menuTarget objectID")) != null && !value.trim().isEmpty()) {
value = value.trim(); // Remove leading/trailing spaces

Expand Down Expand Up @@ -548,8 +581,6 @@ public static HashMap<WorldPoint, Set<Transport>> loadAllFromResources() {
addTransports(transports, "wilderness_obelisks.tsv", TransportType.WILDERNESS_OBELISK);
addTransports(transports, "magic_carpets.tsv", TransportType.MAGIC_CARPET);
addTransports(transports, "npcs.tsv", TransportType.NPC);
addTransports(transports, "teleportation_portal_poh.tsv", TransportType.TELEPORTATION_PORTAL);
addTransports(transports, "teleportation_poh.tsv", TransportType.POH);
System.out.println("Loaded " + transports.size() + " transports");
return transports;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import net.runelite.client.plugins.microbot.util.magic.RuneFilter;
import net.runelite.client.plugins.microbot.util.player.Rs2Player;
import net.runelite.client.plugins.microbot.util.poh.PohTeleports;
import net.runelite.client.plugins.microbot.util.poh.PohTransport;
import net.runelite.client.plugins.microbot.util.poh.data.HouseStyle;
import net.runelite.client.plugins.microbot.util.tabs.Rs2Tab;
import net.runelite.client.plugins.microbot.util.walker.Rs2Walker;
Expand Down Expand Up @@ -192,7 +193,7 @@ public void refresh(WorldPoint target) {
}
}

/** Specialized method for only updating player-held item and spell transports */
/** Specialized method for adding usableTeleports to `transports` */
public void refreshTeleports(int packedLocation, int wildernessLevel) {
Set<Transport> usableWildyTeleports = new HashSet<>(usableTeleports.size());
if (ignoreTeleportAndItems) return;
Expand Down Expand Up @@ -255,15 +256,16 @@ private void refreshTransports(WorldPoint target) {
useGnomeGliders &= QuestState.FINISHED.equals(Rs2Player.getQuestState(Quest.THE_GRAND_TREE));
useSpiritTrees &= QuestState.FINISHED.equals(Rs2Player.getQuestState(Quest.TREE_GNOME_VILLAGE));
useQuetzals &= QuestState.FINISHED.equals(Rs2Player.getQuestState(Quest.TWILIGHTS_PROMISE));
usePoh &= PohTeleports.hasHouse();

transports.clear();
transportsPacked.clear();
usableTeleports.clear();
// Check spirit tree farming states for farmable spirit trees
Rs2SpiritTreeCache.getInstance().update();
//Rs2SpiritTreeCache.logAllTreeStates();
for (Map.Entry<WorldPoint, Set<Transport>> entry : allTransports.entrySet()) {

// Check spirit tree farming states for farmable spirit trees
Rs2SpiritTreeCache.getInstance().update();
//Rs2SpiritTreeCache.logAllTreeStates();

for (Map.Entry<WorldPoint, Set<Transport>> entry : createMergedList().entrySet()) {
WorldPoint point = entry.getKey();
Set<Transport> usableTransports = new HashSet<>(entry.getValue().size());
for (Transport transport : entry.getValue()) {
Expand All @@ -283,13 +285,37 @@ private void refreshTransports(WorldPoint target) {
transportsPacked.put(WorldPointUtil.packWorldPoint(point), usableTransports);
}
}

// Filter similar transports based on distance when walk with banked transports is enabled
if (useBankItems && config.maxSimilarTransportDistance() > 0) {
filterSimilarTransports(target);
}
}

private Map<WorldPoint, Set<Transport>> createMergedList() {
if (!usePoh) return allTransports;
Map<WorldPoint, Set<Transport>> mergedTransports = new HashMap<>();

// Start with putting all the TSV imported persistent transports
for (var entry : allTransports.entrySet()) {
mergedTransports.put(entry.getKey(), new HashSet<>(entry.getValue()));
}

// Add transports from PoH to somewhere in the world
for (var entry : Rs2PohCache.getAvailableTransportsMap(allTransports).entrySet()) {
mergedTransports
.computeIfAbsent(entry.getKey(), k -> new HashSet<>())
.addAll(entry.getValue());
}
// Add transports from the world to PoH
for (var entry : PohTeleports.getTransportsToPoh().entrySet()) {
mergedTransports
.computeIfAbsent(entry.getKey(), k -> new HashSet<>())
.addAll(entry.getValue());
}
return mergedTransports;
}

public void refresh() {
refresh(null);
}
Expand Down Expand Up @@ -449,36 +475,32 @@ private boolean useTransport(Transport transport) {
}
// Check Spirit Tree specific requirements (farming state for farmable trees)
if (transport.getType() == TransportType.SPIRIT_TREE) return isSpiritTreeUsable(transport);

// If the transport has varbit requirements & the varbits do not match
if (!varbitChecks(transport)) {
log.debug("Transport ( O: {} D: {} ) requires varbits {}", transport.getOrigin(), transport.getDestination(), transport.getVarbits());
return false;
}

// If the transport has varplayer requirements & the varplayers do not match
if (!varplayerChecks(transport)) {
log.debug("Transport ( O: {} D: {} ) requires varplayers {}", transport.getOrigin(), transport.getDestination(), transport.getVarplayers());
return false;
}

// If you don't have the required currency & amount for transport
if (transport.getCurrencyAmount() > 0
&& !Rs2Inventory.hasItemAmount(transport.getCurrencyName(), transport.getCurrencyAmount())
&& !(ShortestPathPlugin.getPathfinderConfig().useBankItems && Rs2Bank.count(transport.getCurrencyName()) >= transport.getCurrencyAmount())) {
log.debug("Transport ( O: {} D: {} ) requires {} x {}", transport.getOrigin(), transport.getDestination(), transport.getCurrencyAmount(), transport.getCurrencyName());
return false;
}

// Check if Teleports are globally disabled
if (TransportType.isTeleport(transport.getType()) && Rs2Walker.disableTeleports) {
log.debug("Transport ( O: {} D: {} ) is a teleport but teleports are globally disabled", transport.getOrigin(), transport.getDestination());
return false;
}
if (transport.getType() == TransportType.POH) {
boolean isUsable = Rs2PohCache.isTransportUsable(transport);
if (!isUsable)
{
log.debug("Transport ( O: {} D: {} ) is a POH teleport but is not usable", transport.getOrigin(), transport.getDestination());
}
return isUsable;
}

// Check Teleport Item Settings
if (transport.getType() == TELEPORTATION_ITEM) {
Expand Down Expand Up @@ -509,16 +531,6 @@ private boolean useTransport(Transport transport) {
return hasRequiredItems;
}

//Check PoH fairy ring requirement
if(transport.getType() == FAIRY_RING && HouseStyle.isPohExitLocation(transport.getOrigin())) {
boolean isUsable = Rs2PohCache.isTransportUsable(transport);
if (!isUsable) {
log.debug("Transport ( O: {} D: {} ) is a POH-Fairy-ring teleport but is not usable", transport.getOrigin(), transport.getDestination());
}
return isUsable;
}


return true;
}

Expand Down
Loading