tickeater: add tickeater - eats as soon as player is below given HP threshold

botutils: add clickRandomPointCenter and implemented to existing scripts
This commit is contained in:
illumineawake 2020-06-12 23:47:29 +10:00
parent 1f0cbce503
commit caeaa4dcc2
11 changed files with 317 additions and 27 deletions

View File

@ -133,11 +133,23 @@ public interface AutoHopConfig extends Config
return true;
}
@ConfigItem(
keyName = "bankIgnore",
name = "Ignore near Bank",
description = "Don't hop if within 15 tiles of a bank, to avoid causing your character to hop if you walk into Bank/GE with this plugin turned on",
titleSection = "hopTitle",
position = 9
)
default boolean bankIgnore()
{
return true;
}
@ConfigTitleSection(
keyName = "worldsTitle",
name = "Worlds",
description = "",
position = 9
position = 10
)
default Title worldsTitle()
{
@ -149,7 +161,7 @@ public interface AutoHopConfig extends Config
name = "American",
description = "Allow hopping to American worlds",
titleSection = "worldsTitle",
position = 10
position = 11
)
default boolean american()
{
@ -161,7 +173,7 @@ public interface AutoHopConfig extends Config
name = "UK",
description = "Allow hopping to UK worlds",
titleSection = "worldsTitle",
position = 11
position = 12
)
default boolean unitedkingdom()
{
@ -173,7 +185,7 @@ public interface AutoHopConfig extends Config
name = "German",
description = "Allow hopping to German worlds",
titleSection = "worldsTitle",
position = 12
position = 13
)
default boolean germany()
{
@ -185,7 +197,7 @@ public interface AutoHopConfig extends Config
name = "Australian",
description = "Allow hopping to Australian worlds",
titleSection = "worldsTitle",
position = 13
position = 14
)
default boolean australia()
{
@ -196,7 +208,7 @@ public interface AutoHopConfig extends Config
keyName = "ignoresTitle",
name = "Ignore",
description = "",
position = 14
position = 15
)
default Title ignoresTitle()
{
@ -208,7 +220,7 @@ public interface AutoHopConfig extends Config
name = "Friends",
description = "Don't hop when the player spawned is on your friend list",
titleSection = "ignoresTitle",
position = 15
position = 16
)
default boolean friends()
{
@ -220,7 +232,7 @@ public interface AutoHopConfig extends Config
name = "Clan members",
description = "Don't hop when the player spawned is in your clan chat",
titleSection = "ignoresTitle",
position = 16
position = 17
)
default boolean clanmember()
{

View File

@ -8,12 +8,14 @@ import javax.inject.Inject;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.ChatMessageType;
import net.runelite.api.Client;
import net.runelite.api.GameObject;
import net.runelite.api.GameState;
import net.runelite.api.Player;
import net.runelite.api.events.ChatMessage;
import net.runelite.api.events.GameStateChanged;
import net.runelite.api.events.GameTick;
import net.runelite.api.events.PlayerSpawned;
import net.runelite.api.queries.GameObjectQuery;
import net.runelite.api.util.Text;
import net.runelite.api.widgets.WidgetInfo;
import net.runelite.client.chat.ChatColorType;

View File

@ -11,6 +11,7 @@ import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ArrayBlockingQueue;
@ -36,6 +37,7 @@ import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.config.ConfigPanelItem;
import net.runelite.client.game.ItemManager;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.plugins.PluginManager;
@ -335,6 +337,27 @@ public class BotUtils extends Plugin
.list;
}
public MenuEntry getInventoryItem(ItemManager itemManager, String menuOption, int opcode) {
Widget inventoryWidget = client.getWidget(WidgetInfo.INVENTORY);
if (inventoryWidget != null)
{
Collection<WidgetItem> items = inventoryWidget.getWidgetItems();
for (WidgetItem item : items)
{
String[] menuActions = itemManager.getItemDefinition(item.getId()).getInventoryActions();
for (String action : menuActions)
{
if (action != null && action.equals(menuOption))
{
MenuEntry menuEntry = new MenuEntry("", "", item.getId(), opcode, item.getIndex(), 9764864, false);
return menuEntry;
}
}
}
}
return null;
}
public List<Widget> getEquippedItems(int[] itemIds)
{
assert client.isClientThread();
@ -591,6 +614,13 @@ public class BotUtils extends Plugin
click(point);
}
public void clickRandomPointCenter(int min, int max)
{
Point point = new Point(client.getCenterX() + getRandomIntBetweenRange(min, max), client.getCenterY() + getRandomIntBetweenRange(min, max));
click(point);
}
//Not very accurate, recommend using isMovingTick()
public boolean isMoving()
{

View File

@ -170,7 +170,7 @@ public class PowerSkillerPlugin extends Plugin
{
log.info("enabling run");
targetMenu = new MenuEntry("Toggle Run", "", 1, 57, -1, 10485782, false);
utils.clickRandomPoint(0, 200);
utils.clickRandomPointCenter(-100, 100);
}
}
@ -181,7 +181,7 @@ public class PowerSkillerPlugin extends Plugin
{
targetObject = nextTree;
targetMenu = new MenuEntry("", "", nextTree.getId(), 3, targetObject.getSceneMinLocation().getX(), targetObject.getSceneMinLocation().getY(), false);
utils.clickRandomPoint(0, 200);
utils.clickRandomPointCenter(-100, 100);
}
else
{
@ -206,7 +206,7 @@ public class PowerSkillerPlugin extends Plugin
.filter(item -> itemIds.contains(item.getId()))
.forEach((item) -> {
targetMenu = new MenuEntry("", "", item.getId(), 37, item.getIndex(), 9764864, false);
utils.clickRandomPoint(0, 200);
utils.clickRandomPointCenter(-100, 100);
try
{
Thread.sleep(utils.getRandomIntBetweenRange(config.randLow(), config.randHigh()));

View File

@ -38,8 +38,6 @@ public class RooftopAgilityPanel extends PluginPanel
agilityPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
agilityPanel.setLayout(new DynamicGridLayout(2, 1));
JLabel locationLabel = new JLabel("Location:");
JComboBox locationCmb = new JComboBox();
JLabel markLabel = new JLabel("Pickup Mark of Grace");
JCheckBox markCheck = new JCheckBox();
markCheck.setSelected(true);
@ -93,8 +91,6 @@ public class RooftopAgilityPanel extends PluginPanel
}
});
agilityPanel.add(locationLabel);
agilityPanel.add(locationCmb);
agilityPanel.add(markLabel);
agilityPanel.add(markCheck);
startPanel.add(startBot);

View File

@ -130,7 +130,7 @@ public class RooftopAgilityPlugin extends Plugin
log.info("enabling run");
targetMenu = new MenuEntry("Toggle Run", "", 1, 57, -1, 10485782, false);
utils.sleep(60, 350);
utils.clickRandomPoint(0, 200);
utils.clickRandomPointCenter(-100, 100);
}
}
@ -142,7 +142,6 @@ public class RooftopAgilityPlugin extends Plugin
List<Integer> decObstacles = List.of(ROUGH_WALL_14412, ROUGH_WALL_14898, ROUGH_WALL, WALL_14927);
List<Integer> groundObjObstacles = List.of(TIGHTROPE_14899, TIGHTROPE_14911, LOG_BALANCE_23145, BALANCING_ROPE_23557, TIGHTROPE, TIGHTROPE_11406, TIGHTROPE_14932);
log.info(String.valueOf(obstacle.getObstacleId()));
//if (obstacle.getObstacleId() == ROUGH_WALL_14412 || obstacle.getObstacleId()== ROUGH_WALL_14898 || obstacle.getObstacleId() == ROUGH_WALL || obstacle.getObstacleId() == WALL_14927)
if (decObstacles.contains(obstacle.getObstacleId()))
{
DecorativeObject decObstacle = utils.findNearestDecorObject(obstacle.getObstacleId());
@ -150,11 +149,10 @@ public class RooftopAgilityPlugin extends Plugin
{
targetMenu = new MenuEntry("", "", decObstacle.getId(), 3, decObstacle.getLocalLocation().getSceneX(), decObstacle.getLocalLocation().getSceneY(), false);
utils.sleep(60, 350);
utils.clickRandomPoint(client.getCenterX() + utils.getRandomIntBetweenRange(0, 300), client.getCenterY() + utils.getRandomIntBetweenRange(0, 300));
utils.clickRandomPointCenter(-100, 100);
return;
}
}
//if (obstacle.getObstacleId() == TIGHTROPE_14899 || obstacle.getObstacleId() == TIGHTROPE_14911 || obstacle.getObstacleId() == LOG_BALANCE_23145 || obstacle.getObstacleId() == BALANCING_ROPE_23557 || obstacle.getObstacleId() == TIGHTROPE || obstacle.getObstacleId() == TIGHTROPE_11406)
if (groundObjObstacles.contains(obstacle.getObstacleId()))
{
GroundObject groundObstacle = utils.findNearestGroundObject(obstacle.getObstacleId());
@ -162,7 +160,7 @@ public class RooftopAgilityPlugin extends Plugin
{
targetMenu = new MenuEntry("", "", groundObstacle.getId(), 3, groundObstacle.getLocalLocation().getSceneX(), groundObstacle.getLocalLocation().getSceneY(), false);
utils.sleep(60, 350);
utils.clickRandomPoint(client.getCenterX() + utils.getRandomIntBetweenRange(0, 300), client.getCenterY() + utils.getRandomIntBetweenRange(0, 300));
utils.clickRandomPointCenter(-100, 100);
return;
}
}
@ -171,7 +169,7 @@ public class RooftopAgilityPlugin extends Plugin
{
targetMenu = new MenuEntry("", "", objObstacle.getId(), 3, objObstacle.getSceneMinLocation().getX(), objObstacle.getSceneMinLocation().getY(), false);
utils.sleep(60, 350);
utils.clickRandomPoint(client.getCenterX() + utils.getRandomIntBetweenRange(0, 300), client.getCenterY() + utils.getRandomIntBetweenRange(0, 300));
utils.clickRandomPointCenter(-100, 100);
return;
}
}
@ -236,8 +234,7 @@ public class RooftopAgilityPlugin extends Plugin
log.info("Picking up mark of grace");
targetMenu = new MenuEntry("", "", ItemID.MARK_OF_GRACE, 20, markOfGraceTile.getSceneLocation().getX(), markOfGraceTile.getSceneLocation().getY(), false);
utils.sleep(60, 350);
utils.clickRandomPoint(client.getCenterX() + utils.getRandomIntBetweenRange(0, 300), client.getCenterY() + utils.getRandomIntBetweenRange(0, 300));
return;
utils.clickRandomPointCenter(-100, 100); return;
case FIND_OBSTACLE:
findObstacle();
return;

View File

@ -36,6 +36,7 @@ include(":powerskiller")
include(":randomhandler")
include(":rooftopagility")
include(":test")
include(":tickeat")
for (project in rootProject.children) {
project.apply {

View File

@ -26,9 +26,11 @@
package net.runelite.client.plugins.test;
import com.google.inject.Provides;
import java.util.Collection;
import javax.inject.Inject;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.*;
import static net.runelite.api.ObjectID.*;
import net.runelite.api.coords.LocalPoint;
import net.runelite.api.coords.WorldArea;
import net.runelite.api.coords.WorldPoint;
@ -37,16 +39,24 @@ import net.runelite.api.events.*;
import net.runelite.api.geometry.Shapes;
import net.runelite.api.queries.ActorQuery;
import net.runelite.api.queries.GameObjectQuery;
import net.runelite.api.queries.InventoryItemQuery;
import net.runelite.api.queries.InventoryWidgetItemQuery;
import net.runelite.api.queries.PlayerQuery;
import net.runelite.api.queries.TileQuery;
import net.runelite.api.util.Text;
import net.runelite.api.widgets.Widget;
import net.runelite.api.widgets.WidgetInfo;
import net.runelite.api.queries.NPCQuery;
import net.runelite.api.widgets.WidgetItem;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.events.ConfigChanged;
import net.runelite.client.game.ItemManager;
import net.runelite.client.menus.InventoryComparableEntry;
import net.runelite.client.menus.MenuManager;
import net.runelite.client.menus.WidgetMenuOption;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDependency;
import net.runelite.client.plugins.PluginDescriptor;
@ -85,6 +95,9 @@ public class TestPlugin extends Plugin
@Inject
private BotUtils utils;
@Inject
private ItemManager itemManager;
Point point = new Point(10, 10);
GameObject object;
int timeout = 0;
@ -95,12 +108,12 @@ public class TestPlugin extends Plugin
List<WorldPoint> worldPointList = new ArrayList<>();
LocalPoint beforeLoc;
WorldPoint outsideWorldPoint = new WorldPoint(2500,2500,0);
WorldPoint outsideWorldPoint = new WorldPoint(2500, 2500, 0);
WorldPoint swWorldPoint = new WorldPoint(3160, 3208, 0);
WorldPoint neWorldPoint = new WorldPoint(3197, 3241, 0);
//WorldArea worldAreaTest = new WorldArea(swWorldPoint,20,10);
WorldArea worldAreaTest = new WorldArea(new WorldPoint(3160, 3208, 0),new WorldPoint(3160, 3208, 0));
WorldArea worldAreaCustom = new WorldArea(swWorldPoint,neWorldPoint);
WorldArea worldAreaTest = new WorldArea(new WorldPoint(3160, 3208, 0), new WorldPoint(3160, 3208, 0));
WorldArea worldAreaCustom = new WorldArea(swWorldPoint, neWorldPoint);
private final int VARROCK_REGION_ID = 12853;
@ -149,7 +162,20 @@ public class TestPlugin extends Plugin
//object = new GameObjectQuery().idEquals(TREE, TREE_1277, TREE_1278, TREE_1279, TREE_1280).filter(o -> rsAreaOutsideTest.contains(o.getWorldLocation())).result(client).nearestTo(client.getLocalPlayer());
if (client != null && client.getLocalPlayer() != null)
{
log.info(String.valueOf(client.getBoostedSkillLevel(Skill.HITPOINTS)));
/*MenuEntry[] menuEntries = client.getMenuEntries();
if (menuEntries != null)
{
for (MenuEntry entry : menuEntries)
{
if (entry.getOption().equals("Eat"))
{
log.info(entry.toString());
break;
}
}
}*/
/*if (beforeLoc != null)
{
log.info("Current Loc value: " + client.getLocalPlayer().getLocalLocation() + "before Loc value " + beforeLoc);
@ -222,7 +248,8 @@ public class TestPlugin extends Plugin
}*/
@Subscribe
public void onMenuOptionClicked(MenuOptionClicked event) {
public void onMenuOptionClicked(MenuOptionClicked event)
{
log.info("Test menu, before hook: " + event.toString());
if (testMenu != null)
{

View File

@ -0,0 +1,47 @@
/*
* Copyright (c) 2018, SomeoneWithAnInternetConnection
* Copyright (c) 2018, oplosthee <https://github.com/oplosthee>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.client.plugins.tickeat;
import javax.swing.JButton;
import javax.swing.JPanel;
import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.Range;
import net.runelite.client.config.Units;
@ConfigGroup("TickEat")
public interface TickEatConfiguration extends Config
{
@ConfigItem(
keyName = "eatHP",
name = "Eat at HP",
description = "HP to eat at",
position = 0
)
default int eatHP() { return 10; }
}

View File

@ -0,0 +1,130 @@
/*
* Copyright (c) 2018, SomeoneWithAnInternetConnection
* Copyright (c) 2018, oplosthee <https://github.com/oplosthee>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.client.plugins.tickeat;
import com.google.inject.Provides;
import javax.inject.Inject;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.*;
import net.runelite.api.coords.WorldPoint;
import net.runelite.api.events.*;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.events.ConfigChanged;
import net.runelite.client.game.ItemManager;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDependency;
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.plugins.PluginType;
import net.runelite.client.plugins.botutils.BotUtils;
import org.pf4j.Extension;
@Extension
@PluginDependency(BotUtils.class)
@PluginDescriptor(
name = "Tick Eater",
enabledByDefault = false,
description = "Illumine tick eater",
tags = {"tick"},
type = PluginType.UTILITY
)
@Slf4j
public class TickEatPlugin extends Plugin
{
@Inject
private Client client;
@Inject
private TickEatConfiguration config;
@Inject
private BotUtils utils;
@Inject
private ConfigManager configManager;
@Inject
private ItemManager itemManager;
MenuEntry targetMenu;
@Provides
TickEatConfiguration provideConfig(ConfigManager configManager)
{
return configManager.getConfig(TickEatConfiguration.class);
}
@Override
protected void startUp()
{
}
@Override
protected void shutDown()
{
configManager.setConfiguration("TickEat", "startBot", false);
}
@Subscribe
private void onHitsplatApplied(HitsplatApplied event)
{
if (event.getActor() != client.getLocalPlayer() || client.getBoostedSkillLevel(Skill.HITPOINTS) > config.eatHP())
{
return;
}
if (utils.getInventoryItem(itemManager, "Eat", 33) != null)
{
targetMenu = utils.getInventoryItem(itemManager, "Eat", 33);
utils.clickRandomPointCenter(-100, 100);
}
else
{
utils.sendGameMessage("Health is below theshold but we're out of food");
}
}
@Subscribe
public void onMenuOptionClicked(MenuOptionClicked event)
{
if (targetMenu == null)
{
return;
}
if (utils.getRandomEvent()) //for random events
{
log.info("Powerskiller not overriding due to random event");
return;
}
else
{
event.setMenuEntry(targetMenu);
targetMenu = null; //this allow the player to interact with the client without their clicks being overridden
}
}
}

View File

@ -0,0 +1,48 @@
/*
* Copyright (c) 2019 Owain van Brakel <https://github.com/Owain94>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
version = "1.0.3"
project.extra["PluginName"] = "Tick Eat"
project.extra["PluginDescription"] = "Illumine auto eat food below given HP on tick"
dependencies {
compileOnly(project(":botutils"))
}
tasks {
jar {
manifest {
attributes(mapOf(
"Plugin-Version" to project.version,
"Plugin-Id" to nameToId(project.extra["PluginName"] as String),
"Plugin-Provider" to project.extra["PluginProvider"],
"Plugin-Dependencies" to nameToId("BotUtils"),
"Plugin-Description" to project.extra["PluginDescription"],
"Plugin-License" to project.extra["PluginLicense"]
))
}
}
}