Hi,
i am writing a script that loots a ground item and then world hops and repeats. When the player enters combat it runs to a safespot waits for combat delay hops world and tries again. This works but i notice it bugs out when the script is in the middle of an iteraction or world hopping etc...
I would like the script to stop whats its doing as soon as it enters combat and move to the safespot.
What would be the correct way to achieve this.
Thanks in advance.
if(getSkills().getDynamic(Skill.HITPOINTS) < 6){
if(ItemCountInInventory() <= 14){
paint.setCurrentStatus("regenerating some health");
WalkExact(SAFE_SPOT);
sleep(60_000);
}
} else if(!myPlayer().isUnderAttack()){
TakeItem(item, position, ItemCountInInventory());
} else if (myPlayer().isUnderAttack()) {
WalkExact(SAFE_SPOT);
sleep(5000);
getWorlds().hop(nextWorldInOrder(true));
}
private void TakeItem(GroundItem item, Position position, long inventoryCount){
paint.setCurrentStatus("Looting item :" + ItemCountInInventory());
if(item == null || !position.equals(item.getPosition())){
getWorlds().hop(nextWorldInOrder(true));
} else {
item.interact("Take");
Sleep.sleepUntil(() -> inventoryCount < ItemCountInInventory(), 5000, 100);
log("InventoryCount " + ItemCountInInventory());
}
}