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 @@ -77,7 +77,7 @@ AIOMagicConfig provideConfig(ConfigManager configManager) {
@Inject
private SpinFlaxScript spinFlaxScript;

public final static String version = "1.2.1"; // bumped
public final static String version = "1.2.2";

@Getter
private Rs2CombatSpells combatSpell;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ public boolean run() {
return;
}

Rs2Bank.withdrawX(plugin.getSuperHeatItem().getItemID(), requiredOre);
if (!withdrawExactAmount(plugin.getSuperHeatItem().getItemID(), requiredOre)) {
return;
}

if (requiredCoal > 0) {
if (!Rs2Bank.hasBankItem(ItemID.COAL, requiredCoal)) {
Expand All @@ -125,8 +127,15 @@ public boolean run() {
return;
}

Rs2Bank.withdrawX(ItemID.COAL, requiredCoal);
if (!withdrawExactAmount(ItemID.COAL, requiredCoal)) {
return;
}
}

if (!hasBankedMaterialsForCycle(requiredOre, requiredCoal)) {
return;
}

Rs2Bank.closeBank();
sleepUntil(() -> !Rs2Bank.isOpen());
break;
Expand Down Expand Up @@ -203,4 +212,31 @@ public static int[] calculateOreAndCoal(SuperHeatItem superHeatItem, int emptySl

return new int[]{oreToWithdraw, coalToWithdraw};
}

private boolean withdrawExactAmount(int itemId, int amount) {
if (amount <= 0) {
return true;
}

if (!Rs2Bank.withdrawX(true, itemId, amount)) {
return false;
}

Rs2Inventory.waitForInventoryChanges(1200);
sleepUntil(() -> Rs2Inventory.hasItemAmount(itemId, amount), 2500);
return Rs2Inventory.hasItemAmount(itemId, amount);
}

private boolean hasBankedMaterialsForCycle(int requiredOre, int requiredCoal) {
boolean hasRequiredOre = Rs2Inventory.hasItemAmount(plugin.getSuperHeatItem().getItemID(), requiredOre);
if (!hasRequiredOre) {
return false;
}

if (requiredCoal <= 0) {
return true;
}

return Rs2Inventory.hasItemAmount(ItemID.COAL, requiredCoal);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
)
@Slf4j
public class GiantMolePlugin extends Plugin {
public static final String version = "0.0.4";
public static final String version = "0.0.5";

@Inject
private GiantMoleConfig config;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,13 @@ public void goInsideMoleHill()
*/
public static WorldPoint getMoleLocation()
{
if (isInMoleTunnel())
if (!isInMoleTunnel())
{
return Microbot.getClient().getHintArrowPoint();
return null;
}
return null;
return Microbot.getClientThread()
.runOnClientThreadOptional(() -> Microbot.getClient().getHintArrowPoint())
.orElse(null);
}

/**
Expand All @@ -308,7 +310,10 @@ public static boolean isMoleDead()
*/
public Rs2NpcModel getMole()
{
return new Rs2NpcModel(Microbot.getClient().getHintArrowNpc());
return Microbot.getClientThread()
.runOnClientThreadOptional(() -> Microbot.getClient().getHintArrowNpc())
.map(Rs2NpcModel::new)
.orElse(null);
}

/**
Expand Down Expand Up @@ -352,22 +357,34 @@ public void walkToMole()
public void attackMole()
{
Rs2NpcModel mole = getMole();
if (mole != null && !Rs2Combat.inCombat())
if (mole == null || Rs2Combat.inCombat())
{
// Mole's "dig" animation is 3314; if it's mid-dig or dead, skip
if (mole.getAnimation() == 3314 || isMoleDead())
{
return;
}
return;
}

// If pathfinder is active, exit it before attacking
if (ShortestPathPlugin.getPathfinder() != null)
{
ShortestPathPlugin.exit();
sleep(600, 800);
}
boolean moleIsDigging = Microbot.getClientThread()
.runOnClientThreadOptional(() ->
{
NPC hintNpc = Microbot.getClient().getHintArrowNpc();
return hintNpc != null && hintNpc.getAnimation() == 3314;
})
.orElse(false);

// Mole's "dig" animation is 3314; if it's mid-dig or dead, skip
if (moleIsDigging || isMoleDead())
{
return;
}

// If pathfinder is active, exit it before attacking
if (ShortestPathPlugin.getPathfinder() != null)
{
ShortestPathPlugin.exit();
sleep(600, 800);
}

Rs2Npc.interact(mole, "Attack");
if (Rs2Npc.interact(mole, "Attack"))
{
sleep(600, 800);
}
}
Expand Down Expand Up @@ -458,6 +475,10 @@ public boolean needBanking(GiantMoleConfig config)
// (1) If inventory is full, we need to bank
if (Rs2Inventory.isFull())
{
if (config.toggleBuryBones() && buryBonesInInventory())
{
return false;
}
Microbot.log("Inventory is full, banking...");
return true;
}
Expand Down Expand Up @@ -615,7 +636,24 @@ private void lootBones(GiantMoleConfig config)
{
Microbot.pauseAllScripts.compareAndSet(true, false);
}
buryBonesInInventory();
}
}

private boolean buryBonesInInventory()
{
List<Rs2ItemModel> bones = Rs2Inventory.getBones();
if (bones == null || bones.isEmpty())
{
return false;
}
if (Rs2Inventory.interact(bones.get(0), "Bury"))
{
Rs2Player.waitForAnimation();
sleep(150, 300);
return true;
}
return false;
}

private void lootRunes(GiantMoleConfig config)
Expand Down