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

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import net.runelite.client.config.*;
import net.runelite.client.plugins.microbot.agility.enums.AgilityCourse;
import net.runelite.client.plugins.microbot.agility.enums.AgilityEquipmentOption;
import net.runelite.client.plugins.microbot.agility.enums.AgilityFoodOption;
import net.runelite.client.plugins.microbot.agility.enums.AgilityPotionOption;

@ConfigGroup("MicroAgility")
@ConfigInformation("Enable the plugin near the start of your selected agility course. <br />" +
Expand All @@ -26,6 +29,22 @@ public interface MicroAgilityConfig extends Config
)
String generalSection = "general";

@ConfigSection(
name = "Banking",
description = "Banking",
position = 1,
closedByDefault = true
)
String bankingSection = "banking";

@ConfigSection(
name = "Safety",
description = "Safety",
position = 2,
closedByDefault = true
)
String safetySection = "safety";

@ConfigItem(
keyName = selectedCourse,
name = "Course",
Expand All @@ -50,6 +69,144 @@ default int hitpoints()
return 20;
}

@ConfigItem(
keyName = "bankFood",
name = "Food",
description = "Food to withdraw when banking. None disables food banking. Auto withdraws the best available configured food.",
position = 1,
section = bankingSection
)
default AgilityFoodOption bankFood()
{
return AgilityFoodOption.NONE;
}

@ConfigItem(
keyName = "foodWithdrawAmount",
name = "Food amount",
description = "Target amount of food to have after banking.",
position = 2,
section = bankingSection
)
@Range(min = 0, max = 28)
default int foodWithdrawAmount()
{
return 0;
}

@ConfigItem(
keyName = "bankFoodAt",
name = "Bank under food",
description = "Bank when inventory food count is at or below this amount. 0 disables food banking triggers.",
position = 3,
section = bankingSection
)
@Range(min = 0, max = 28)
default int bankFoodAt()
{
return 0;
}

@ConfigItem(
keyName = "bankPotion",
name = "Potion",
description = "Potion to withdraw when banking. None disables potion banking.",
position = 4,
section = bankingSection
)
default AgilityPotionOption bankPotion()
{
return AgilityPotionOption.NONE;
}

@ConfigItem(
keyName = "potionWithdrawAmount",
name = "Potion amount",
description = "Target amount of selected potion to have after banking.",
position = 5,
section = bankingSection
)
@Range(min = 0, max = 28)
default int potionWithdrawAmount()
{
return 0;
}

@ConfigItem(
keyName = "bankOnlyAtCourseStart",
name = "Bank at course start",
description = "Only bank from the ground near the course start. This avoids asking the walker to route from rooftops or awkward course positions.",
position = 6,
section = bankingSection
)
default boolean bankOnlyAtCourseStart()
{
return true;
}

@ConfigItem(
keyName = "bankEquipment",
name = "Equipment",
description = "Optional equipment to withdraw and wear when banking from a safe course-start position.",
position = 7,
section = bankingSection
)
default AgilityEquipmentOption bankEquipment()
{
return AgilityEquipmentOption.NONE;
}

@ConfigItem(
keyName = "summerPieWithdrawAmount",
name = "Summer pie amount",
description = "Target amount of summer pies to withdraw when banking. 0 disables summer pie banking.",
position = 8,
section = bankingSection
)
@Range(min = 0, max = 28)
default int summerPieWithdrawAmount()
{
return 0;
}

@ConfigItem(
keyName = "hpSafetyWait",
name = "Wait when unsafe",
description = "If out of food and HP is too low, wait instead of stopping or continuing.",
position = 1,
section = safetySection
)
default boolean hpSafetyWait()
{
return false;
}

@ConfigItem(
keyName = "hpSafetyWaitBelow",
name = "Wait below HP",
description = "When out of food, wait if HP percentage is below this value.",
position = 2,
section = safetySection
)
@Range(min = 1, max = 99)
default int hpSafetyWaitBelow()
{
return 20;
}

@ConfigItem(
keyName = "hpSafetyResumeAt",
name = "Resume at HP",
description = "Resume once HP percentage is at or above this value.",
position = 3,
section = safetySection
)
@Range(min = 1, max = 100)
default int hpSafetyResumeAt()
{
return 50;
}

@ConfigItem(
keyName = shouldAlch,
name = "Alch",
Expand Down Expand Up @@ -110,4 +267,4 @@ default int alchSkipChance()
{
return 5;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ public class MicroAgilityOverlay extends OverlayPanel
@Override
public Dimension render(Graphics2D graphics)
{
if (plugin.getAgilityScript().isShuttingDown() || !plugin.getAgilityScript().isRunning())
{
return null;
}

try
{
panelComponent.setPreferredSize(new Dimension(200, 300));
Expand All @@ -45,7 +50,7 @@ public Dimension render(Graphics2D graphics)

panelComponent.getChildren().add(LineComponent.builder()
.left("Current Obstacle")
.right(Integer.toString(config.agilityCourse().getHandler().getCurrentObstacleIndex()))
.right(Integer.toString(plugin.getAgilityScript().getCurrentObstacleIndex()))
.build());

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.plugins.microbot.PluginConstants;
import net.runelite.client.plugins.microbot.agility.courses.AgilityCourseHandler;
import net.runelite.api.gameval.ItemID;
import net.runelite.client.plugins.microbot.util.inventory.Rs2Inventory;
import net.runelite.client.plugins.microbot.util.inventory.Rs2ItemModel;
import net.runelite.client.plugins.microbot.util.player.Rs2Player;
Expand All @@ -34,7 +35,7 @@
@Slf4j
public class MicroAgilityPlugin extends Plugin
{
public static final String version = "1.2.7";
public static final String version = "1.3.0";
@Inject
private MicroAgilityConfig config;
@Inject
Expand Down Expand Up @@ -65,10 +66,14 @@ protected void startUp() throws AWTException
agilityScript.run();
}

@Override
protected void shutDown()
{
if (overlayManager != null)
{
overlayManager.remove(agilityOverlay);
}
agilityScript.shutdown();
overlayManager.remove(agilityOverlay);
}

public AgilityCourseHandler getCourseHandler()
Expand All @@ -78,22 +83,43 @@ public AgilityCourseHandler getCourseHandler()

public List<Rs2ItemModel> getInventoryFood()
{
return Rs2Inventory.getInventoryFood().stream().filter(i -> !(i.getName().toLowerCase().contains("summer pie"))).collect(Collectors.toList());
return Rs2Inventory.getInventoryFood().stream().filter(i -> !isSummerPie(i)).collect(Collectors.toList());
}

public List<Rs2ItemModel> getSummerPies()
{
return Rs2Inventory.getInventoryFood().stream().filter(i -> i.getName().toLowerCase().contains("summer pie")).collect(Collectors.toList());
return Rs2Inventory.getInventoryFood().stream().filter(this::isSummerPie).collect(Collectors.toList());
}

public boolean hasRequiredLevel()
{
if (getSummerPies().isEmpty() || !getCourseHandler().canBeBoosted())
return hasRequiredLevel(getCourseHandler());
}

public boolean hasRequiredLevel(AgilityCourseHandler courseHandler)
{
int requiredLevel = courseHandler.getRequiredLevel();
if (Rs2Player.getRealSkillLevel(Skill.AGILITY) >= requiredLevel)
{
return true;
}

if (getSummerPies().isEmpty() || !courseHandler.canBeBoosted())
{
return Rs2Player.getRealSkillLevel(Skill.AGILITY) >= getCourseHandler().getRequiredLevel();
return false;
}

return Rs2Player.getBoostedSkillLevel(Skill.AGILITY) >= getCourseHandler().getRequiredLevel();
return Rs2Player.getBoostedSkillLevel(Skill.AGILITY) >= requiredLevel;
}

public boolean hasRealRequiredLevel(AgilityCourseHandler courseHandler)
{
return Rs2Player.getRealSkillLevel(Skill.AGILITY) >= courseHandler.getRequiredLevel();
}

private boolean isSummerPie(Rs2ItemModel item)
{
return item != null && (item.getId() == ItemID.SUMMER_PIE || item.getId() == ItemID.HALF_SUMMER_PIE);
}

public AgilityScript getAgilityScript() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,48 @@ public interface AgilityCourseHandler

Integer getRequiredLevel();

default void reset()
{
}

default WorldPoint getPlayerWorldLocation()
{
return Microbot.getClientThread().invoke(() -> Microbot.getClient().getLocalPlayer().getWorldLocation());
}

default int getClientPlane()
{
return Microbot.getClientThread().invoke(() -> Microbot.getClient().getTopLevelWorldView().getPlane());
}

default int getVarbitValue(int varbitId)
{
return Microbot.getClientThread().invoke(() -> Microbot.getClient().getVarbitValue(varbitId));
}

default boolean canBeBoosted()
{
return true;
}

default boolean hasRequiredCourseItems()
{
return true;
}

default String getMissingRequiredCourseItemsMessage()
{
return "You do not have the required items for this course.";
}

default boolean handleCourseActions(WorldPoint playerWorldLocation)
{
return handleWalkToStart(playerWorldLocation);
}

default TileObject getCurrentObstacle()
{
WorldPoint playerLocation = Microbot.getClientThread().invoke(() -> Microbot.getClient().getLocalPlayer().getWorldLocation());
WorldPoint playerLocation = getPlayerWorldLocation();

List<AgilityObstacleModel> matchingObstacles = getObstacles().stream()
.filter(o -> o.getOperationX().check(playerLocation.getX(), o.getRequiredX()) && o.getOperationY().check(playerLocation.getY(), o.getRequiredY()))
Expand Down Expand Up @@ -75,7 +109,9 @@ default TileObject getCurrentObstacle()
return true;
};

return Rs2GameObject.getAll(validObjectPredicate).stream().findFirst().orElse(null);
return Rs2GameObject.getAll(validObjectPredicate).stream()
.min(Comparator.comparingInt(obj -> obj.getWorldLocation().distanceTo(playerLocation)))
.orElse(null);
}

// Simple method to check if we should click or wait
Expand Down Expand Up @@ -118,8 +154,8 @@ default boolean waitForCompletion(final int agilityExp, final int plane)
}

// Check other completion conditions (health loss, plane change)
if (Rs2Player.getHealthPercentage() < initialHealth ||
Microbot.getClient().getTopLevelWorldView().getPlane() != plane)
if (Rs2Player.getHealthPercentage() < initialHealth ||
getClientPlane() != plane)
{
return true;
}
Expand All @@ -134,8 +170,8 @@ default boolean waitForCompletion(final int agilityExp, final int plane)

default int getCurrentObstacleIndex()
{
WorldPoint playerLoc = Microbot.getClientThread().invoke(() -> Microbot.getClient().getLocalPlayer().getWorldLocation());
int playerPlane = Microbot.getClient().getTopLevelWorldView().getPlane();
WorldPoint playerLoc = getPlayerWorldLocation();
int playerPlane = getClientPlane();

if (playerPlane == 0 && playerLoc.distanceTo(getStartPoint()) < 5)
{
Expand Down Expand Up @@ -183,12 +219,12 @@ default int getCurrentObstacleIndex()
}
}

return (closestIndex != -1) ? closestIndex : 0;
return closestIndex;
}

default boolean handleWalkToStart(WorldPoint playerWorldLocation)
{
if (Microbot.getClient().getTopLevelWorldView().getPlane() != 0)
if (getClientPlane() != 0)
{
return false;
}
Expand Down
Loading
Loading