From 76b25c5b04897463ec17f32486cc2d8eed8b6691 Mon Sep 17 00:00:00 2001 From: Yuri Moens Date: Wed, 27 Oct 2021 11:04:04 +0200 Subject: [PATCH] Add pickup nest task --- .../io/reisub/dreambot/cplanker/CPlanker.java | 1 + .../dreambot/cplanker/tasks/PickupNest.java | 31 +++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 CPlanker/src/io/reisub/dreambot/cplanker/tasks/PickupNest.java diff --git a/CPlanker/src/io/reisub/dreambot/cplanker/CPlanker.java b/CPlanker/src/io/reisub/dreambot/cplanker/CPlanker.java index 3f9389c..742e4a4 100644 --- a/CPlanker/src/io/reisub/dreambot/cplanker/CPlanker.java +++ b/CPlanker/src/io/reisub/dreambot/cplanker/CPlanker.java @@ -20,6 +20,7 @@ public class CPlanker extends CTaskScript { getUI().setCustomLines(1); addNodes( + new PickupNest(), new Chop(), new BuyPlanks(), new Teleport(), diff --git a/CPlanker/src/io/reisub/dreambot/cplanker/tasks/PickupNest.java b/CPlanker/src/io/reisub/dreambot/cplanker/tasks/PickupNest.java new file mode 100644 index 0000000..17cc03d --- /dev/null +++ b/CPlanker/src/io/reisub/dreambot/cplanker/tasks/PickupNest.java @@ -0,0 +1,31 @@ +package io.reisub.dreambot.cplanker.tasks; + +import org.dreambot.api.methods.Calculations; +import org.dreambot.api.methods.MethodProvider; +import org.dreambot.api.methods.container.impl.Inventory; +import org.dreambot.api.methods.filter.Filter; +import org.dreambot.api.methods.item.GroundItems; +import org.dreambot.api.script.TaskNode; +import org.dreambot.api.wrappers.items.GroundItem; + +public class PickupNest extends TaskNode { + @Override + public boolean accept() { + GroundItem nest = GroundItems.closest(groundItem -> groundItem.getName().contains("nest")); + return nest != null + && !Inventory.isFull(); + } + + @Override + public int execute() { + int count = Inventory.fullSlotCount(); + + GroundItem nest = GroundItems.closest(groundItem -> groundItem.getName().contains("nest")); + if (nest == null) return Calculations.random(250, 400); + + nest.interact(); + MethodProvider.sleepUntil(() -> Inventory.fullSlotCount() > count, Calculations.random(4000, 4500)); + + return Calculations.random(250, 400); + } +}