Add various new scripts

This commit is contained in:
2022-01-19 12:35:11 +01:00
parent fb86f97efa
commit 78786709eb
84 changed files with 2674 additions and 76 deletions

View File

@ -0,0 +1,52 @@
/*
* 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.0"
project.extra["PluginName"] = "Chaos MTA Helper" // This is the name that is used in the external plugin manager panel
project.extra["PluginDescription"] = "Makes Mage Training Arena slightly less terrible." // This is the description that is used in the external plugin manager panel
dependencies {
compileOnly(project(":util"))
}
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-Description" to project.extra["PluginDescription"],
"Plugin-Dependencies" to
arrayOf(
nameToId("Chaos Util"),
nameToId("iUtils")
).joinToString(),
"Plugin-License" to project.extra["PluginLicense"]
))
}
}
}

View File

@ -0,0 +1,76 @@
/*
* Copyright (c) 2018, Andrew EP | ElPinche256 <https://github.com/ElPinche256>
* 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 io.reisub.openosrs.mtahelper;
import net.runelite.client.config.Button;
import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.Keybind;
import java.awt.event.KeyEvent;
@ConfigGroup("chaosmtahelper")
public interface Config extends net.runelite.client.config.Config {
@ConfigItem(
keyName = "spellHotkey",
name = "Spell hotkey",
description = "Use this hotkey to cast telegrab or bones to bananas depending on the minigame.",
position = 0
)
default Keybind spellHotkey() {
return new Keybind(KeyEvent.VK_Q, 0);
}
@ConfigItem(
keyName = "enableTelegrabHotkey",
name = "Enable telegrab hotkey",
description = "Enable the hotkey for telegrabs.",
position = 1
)
default boolean enableTelegrabHotkey() {
return true;
}
@ConfigItem(
keyName = "enableBonesHotkey",
name = "Enable B2B hotkey",
description = "Enable the hotkey for bones to bananas.",
position = 2
)
default boolean enableBonesHotkey() {
return true;
}
@ConfigItem(
keyName = "startButton",
name = "Start/Stop",
description = "Start the script",
position = 100
)
default Button startButton() {
return new Button();
}
}

View File

@ -0,0 +1,144 @@
package io.reisub.openosrs.mtahelper;
import com.google.inject.Provides;
import io.reisub.openosrs.mtahelper.tasks.*;
import io.reisub.openosrs.util.CScript;
import io.reisub.openosrs.util.Util;
import io.reisub.openosrs.util.tasks.Run;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.*;
import net.runelite.api.coords.Direction;
import net.runelite.api.coords.LocalPoint;
import net.runelite.api.coords.WorldPoint;
import net.runelite.api.events.*;
import net.runelite.api.widgets.WidgetID;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.input.KeyListener;
import net.runelite.client.input.KeyManager;
import net.runelite.client.plugins.PluginDependency;
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.plugins.iutils.iUtils;
import net.runelite.client.plugins.mta.telekinetic.Maze;
import org.pf4j.Extension;
import javax.inject.Inject;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.time.Duration;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
import java.util.Stack;
@Extension
@PluginDependency(Util.class)
@PluginDependency(iUtils.class)
@PluginDescriptor(
name = "Chaos MTA Helper",
description = "Makes Mage Training Arena slightly less terrible.",
enabledByDefault = false
)
@Slf4j
public class MTAHelper extends CScript implements KeyListener {
@Inject
private Config config;
@Inject
private KeyManager keyManager;
private Instant lastAction = Instant.EPOCH;
@Provides
Config provideConfig(ConfigManager configManager) {
return configManager.getConfig(Config.class);
}
public static final int MTA_REGION = 13462;
@Getter
@Setter
private boolean castTelekineticGrab;
@Getter
@Setter
private boolean castBonesToBananas;
@Getter
@Setter
private long lastHighAlchemy;
@Override
protected void onStart() {
super.onStart();
keyManager.registerKeyListener(this);
Run runTask = injector.getInstance(Run.class);
runTask.setInterval(70, 95);
tasks.add(runTask);
addTask(CastTelekineticGrab.class);
addTask(CastEnchant.class);
addTask(CastHighAlch.class);
addTask(EatPeach.class);
addTask(CastBonesToBananas.class);
}
@Override
protected void onStop() {
super.onStop();
keyManager.unregisterKeyListener(this);
}
@SuppressWarnings("unused")
@Subscribe
private void onGameTick(GameTick event) {
if (!isLoggedIn()) return;
}
@SuppressWarnings("unused")
@Subscribe
private void onItemContainerChanged(ItemContainerChanged event) {
}
@SuppressWarnings("unused")
@Subscribe
private void onStatChanged(StatChanged event) {
if (event.getSkill() == Skill.MAGIC) {
lastHighAlchemy = game.ticks();
}
}
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
if (Duration.between(lastAction, Instant.now()).getSeconds() < 2) return;
lastAction = Instant.now();
if (config.enableTelegrabHotkey()
&& config.spellHotkey().matches(e)
&& game.widget(WidgetID.MTA_TELEKINETIC_GROUP_ID, 0) != null) {
castTelekineticGrab = true;
} else if (config.enableBonesHotkey()
&& config.spellHotkey().matches(e)
&& game.widget(WidgetID.MTA_GRAVEYARD_GROUP_ID, 0) != null) {
castBonesToBananas = true;
}
}
@Override
public void keyReleased(KeyEvent e) {
}
}

View File

@ -0,0 +1,41 @@
package io.reisub.openosrs.mtahelper.tasks;
import io.reisub.openosrs.mtahelper.MTAHelper;
import io.reisub.openosrs.util.Task;
import net.runelite.client.plugins.iutils.api.Spells;
import net.runelite.client.plugins.iutils.game.iObject;
import net.runelite.client.plugins.iutils.game.iWidget;
import javax.inject.Inject;
public class CastBonesToBananas extends Task {
@Inject
private MTAHelper plugin;
@Override
public String getStatus() {
return "Casting bones to bananas and depositing";
}
@Override
public boolean validate() {
return plugin.isCastBonesToBananas();
}
@Override
public void execute() {
iObject foodChute = game.objects().withName("Food chute").nearest();
if (foodChute == null) return;
foodChute.interact("Deposit");
game.sleepDelay();
game.sleepDelay();
iWidget spellWidget = game.widget(Spells.BONES_TO_BANANAS.getInfo());
if (spellWidget == null) return;
spellWidget.interact("Cast");
plugin.setCastBonesToBananas(false);
}
}

View File

@ -0,0 +1,51 @@
package io.reisub.openosrs.mtahelper.tasks;
import io.reisub.openosrs.mtahelper.MTAHelper;
import io.reisub.openosrs.util.Task;
import net.runelite.client.plugins.iutils.api.Spells;
import net.runelite.client.plugins.iutils.game.InventoryItem;
import net.runelite.client.plugins.iutils.game.iWidget;
import javax.inject.Inject;
import java.util.Set;
public class CastEnchant extends Task {
@Inject
private MTAHelper plugin;
private final String[] enchantItems = new String[]{
"Pentamid",
"Cube",
"Cylinder",
"Icosahedron",
"Dragonstone"
};
private long last = 0;
@Override
public String getStatus() {
return "Casting enchant spell";
}
@Override
public boolean validate() {
return plugin.isInRegion(MTAHelper.MTA_REGION)
&& game.localPlayer().position().z == 0
&& game.inventory().withName(enchantItems).exists()
&& game.ticks() > last + 3;
}
@Override
public void execute() {
InventoryItem item = game.inventory().withName(enchantItems).first();
if (item == null) return;
iWidget spellWidget = game.widget(Spells.LVL5_ENCHANT.getInfo());
if (spellWidget == null) return;
spellWidget.useOn(item);
last = game.ticks();
}
}

View File

@ -0,0 +1,66 @@
package io.reisub.openosrs.mtahelper.tasks;
import io.reisub.openosrs.mtahelper.MTAHelper;
import io.reisub.openosrs.util.Task;
import net.runelite.api.widgets.WidgetID;
import net.runelite.client.plugins.iutils.api.Spells;
import net.runelite.client.plugins.iutils.game.InventoryItem;
import net.runelite.client.plugins.iutils.game.iWidget;
import net.runelite.client.plugins.mta.alchemy.AlchemyItem;
import javax.inject.Inject;
public class CastHighAlch extends Task {
@Inject
private MTAHelper plugin;
private long last;
private AlchemyItem best = null;
@Override
public String getStatus() {
return "Casting high alchemy";
}
@Override
public boolean validate() {
best = getBest();
return plugin.isInRegion(MTAHelper.MTA_REGION)
&& game.localPlayer().position().z == 2
&& game.ticks() >= plugin.getLastHighAlchemy() + 5
&& best != null
&& (!game.inventory().withName("Coins").exists() || (game.inventory().withName("Coins").exists() && game.inventory().withName("Coins").quantity() < 10000))
&& game.inventory().withId(best.getId()).exists();
}
@Override
public void execute() {
InventoryItem item = game.inventory().withId(best.getId()).first();
if (item == null) return;
iWidget spellWidget = game.widget(Spells.HIGH_LEVEL_ALCHEMY.getInfo());
if (spellWidget == null) return;
spellWidget.useOn(item);
plugin.setLastHighAlchemy(game.ticks());
}
private AlchemyItem getBest() {
for (int i = 0; i < 5; i++) { // 12
iWidget textWidget = game.widget(WidgetID.MTA_ALCHEMY_GROUP_ID, 7 + i);
if (textWidget == null) return null;
String item = textWidget.text();
iWidget pointsWidget = game.widget(WidgetID.MTA_ALCHEMY_GROUP_ID, 12 + i);
int points = Integer.parseInt(pointsWidget.text());
if (points == 30) {
return AlchemyItem.find(item);
}
}
return null;
}
}

View File

@ -0,0 +1,37 @@
package io.reisub.openosrs.mtahelper.tasks;
import io.reisub.openosrs.mtahelper.MTAHelper;
import io.reisub.openosrs.util.Task;
import net.runelite.client.plugins.iutils.api.Spells;
import net.runelite.client.plugins.iutils.game.iNPC;
import net.runelite.client.plugins.iutils.game.iWidget;
import javax.inject.Inject;
public class CastTelekineticGrab extends Task {
@Inject
private MTAHelper plugin;
@Override
public String getStatus() {
return "Casting telekinetic grab";
}
@Override
public boolean validate() {
return plugin.isCastTelekineticGrab();
}
@Override
public void execute() {
plugin.setCastTelekineticGrab(false);
iNPC mazeGuardian = game.npcs().withName("<col=ff9040>Maze Guardian</col>").first();
if (mazeGuardian == null) return;
iWidget spellWidget = game.widget(Spells.TELEKINETIC_GRAB.getInfo());
if (spellWidget == null) return;
spellWidget.useOn(mazeGuardian);
}
}

View File

@ -0,0 +1,35 @@
package io.reisub.openosrs.mtahelper.tasks;
import io.reisub.openosrs.util.Task;
import net.runelite.api.Skill;
import net.runelite.client.plugins.iutils.game.InventoryItem;
public class EatPeach extends Task {
private long last;
@Override
public String getStatus() {
return "Eating a peach";
}
@Override
public boolean validate() {
int missingHp = game.baseLevel(Skill.HITPOINTS) - game.modifiedLevel(Skill.HITPOINTS);
return game.inventory().withName("Peach").exists()
&& missingHp >= 8
&& game.ticks() >= last + 3;
}
@Override
public void execute() {
InventoryItem peach = game.inventory().withName("Peach").first();
if (peach == null) return;
peach.interact("Eat");
game.tick();
last = game.ticks();
}
}