Add various new scripts
This commit is contained in:
52
smither/smither.gradle.kts
Normal file
52
smither/smither.gradle.kts
Normal 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 Smither" // This is the name that is used in the external plugin manager panel
|
||||
project.extra["PluginDescription"] = "I shall make weapons from your bones!" // 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"]
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
59
smither/src/main/java/io/reisub/openosrs/smither/Config.java
Normal file
59
smither/src/main/java/io/reisub/openosrs/smither/Config.java
Normal file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* 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.smither;
|
||||
|
||||
import net.runelite.client.config.Button;
|
||||
import net.runelite.client.config.ConfigGroup;
|
||||
import net.runelite.client.config.ConfigItem;
|
||||
|
||||
@ConfigGroup("chaossmither")
|
||||
|
||||
public interface Config extends net.runelite.client.config.Config {
|
||||
@ConfigItem(
|
||||
keyName = "metalType",
|
||||
name = "Type",
|
||||
description = "Choose metal type",
|
||||
position = 0
|
||||
)
|
||||
default Metal metalType() { return Metal.MITHRIL; }
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "product",
|
||||
name = "Product",
|
||||
description = "Choose product",
|
||||
position = 1
|
||||
)
|
||||
default Product product() { return Product.PLATEBODY; }
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "startButton",
|
||||
name = "Start/Stop",
|
||||
description = "Start the script",
|
||||
position = 100
|
||||
)
|
||||
default Button startButton() {
|
||||
return new Button();
|
||||
}
|
||||
}
|
18
smither/src/main/java/io/reisub/openosrs/smither/Metal.java
Normal file
18
smither/src/main/java/io/reisub/openosrs/smither/Metal.java
Normal file
@ -0,0 +1,18 @@
|
||||
package io.reisub.openosrs.smither;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import net.runelite.api.ItemID;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum Metal {
|
||||
BRONZE(ItemID.BRONZE_BAR),
|
||||
IRON(ItemID.IRON_BAR),
|
||||
STEEL(ItemID.STEEL_BAR),
|
||||
MITHRIL(ItemID.MITHRIL_BAR),
|
||||
ADAMANTITE(ItemID.ADAMANTITE_BAR),
|
||||
RUNITE(ItemID.RUNITE_BAR);
|
||||
|
||||
private final int barId;
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package io.reisub.openosrs.smither;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum Product {
|
||||
PLATEBODY(5, 22);
|
||||
|
||||
private final int requiredBars;
|
||||
private final int interfaceId;
|
||||
}
|
@ -0,0 +1,89 @@
|
||||
package io.reisub.openosrs.smither;
|
||||
|
||||
import com.google.inject.Provides;
|
||||
|
||||
import io.reisub.openosrs.smither.tasks.HandleBank;
|
||||
import io.reisub.openosrs.smither.tasks.Smith;
|
||||
import io.reisub.openosrs.util.CScript;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import io.reisub.openosrs.util.Util;
|
||||
import io.reisub.openosrs.util.enums.Activity;
|
||||
import io.reisub.openosrs.util.tasks.Eat;
|
||||
import io.reisub.openosrs.util.tasks.KittenTask;
|
||||
import io.reisub.openosrs.util.tasks.Run;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.AnimationID;
|
||||
import net.runelite.api.events.AnimationChanged;
|
||||
import net.runelite.api.events.ChatMessage;
|
||||
import net.runelite.api.events.ConfigButtonClicked;
|
||||
import net.runelite.api.events.ItemContainerChanged;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.eventbus.Subscribe;
|
||||
import net.runelite.client.plugins.PluginDependency;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.plugins.iutils.iUtils;
|
||||
import net.runelite.client.plugins.iutils.scripts.iScript;
|
||||
import org.pf4j.Extension;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Extension
|
||||
@PluginDependency(Util.class)
|
||||
@PluginDependency(iUtils.class)
|
||||
@PluginDescriptor(
|
||||
name = "Chaos Smither",
|
||||
description = "I shall make weapons from your bones!",
|
||||
enabledByDefault = false
|
||||
)
|
||||
@Slf4j
|
||||
public class Smither extends CScript {
|
||||
@Inject
|
||||
private Config config;
|
||||
|
||||
@Provides
|
||||
Config provideConfig(ConfigManager configManager) {
|
||||
return configManager.getConfig(Config.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
|
||||
lastActionTimeout = Duration.ofSeconds(5);
|
||||
|
||||
Run runTask = injector.getInstance(Run.class);
|
||||
runTask.setInterval(70, 95);
|
||||
tasks.add(runTask);
|
||||
|
||||
addTask(HandleBank.class);
|
||||
addTask(Smith.class);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Subscribe
|
||||
private void onItemContainerChanged(ItemContainerChanged event) {
|
||||
int bars = (int) game.inventory().withId(config.metalType().getBarId()).count();
|
||||
|
||||
if (bars < config.product().getRequiredBars() && currentActivity == Activity.SMITHING) {
|
||||
setActivity(Activity.IDLE);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Subscribe
|
||||
private void onAnimationChanged(AnimationChanged event) {
|
||||
if (!isLoggedIn()) return;
|
||||
|
||||
int animId = game.localPlayer().animation();
|
||||
switch (animId) {
|
||||
case AnimationID.SMITHING_ANVIL:
|
||||
case AnimationID.SMITHING_IMCANDO_HAMMER:
|
||||
setActivity(Activity.SMITHING);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
package io.reisub.openosrs.smither.tasks;
|
||||
|
||||
import io.reisub.openosrs.smither.Config;
|
||||
import io.reisub.openosrs.smither.Smither;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import io.reisub.openosrs.util.enums.Activity;
|
||||
import net.runelite.api.ItemID;
|
||||
import net.runelite.client.plugins.iutils.game.iObject;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
|
||||
public class HandleBank extends Task {
|
||||
@Inject
|
||||
private Smither plugin;
|
||||
|
||||
@Inject
|
||||
private Config config;
|
||||
|
||||
private Instant lastBanking = Instant.EPOCH;
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Banking";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
return plugin.getCurrentActivity() == Activity.IDLE
|
||||
&& game.inventory().withId(config.metalType().getBarId()).count() < config.product().getRequiredBars()
|
||||
&& Duration.between(lastBanking, Instant.now()).getSeconds() > 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
if (!bank.isOpen()) {
|
||||
iObject bankObj = game.objects().withName("Bank chest", "Bank booth", "Bank Chest-wreck", "Bank chest").nearest();
|
||||
if (bankObj == null) return;
|
||||
|
||||
if (bankObj.actions().contains("Bank")) {
|
||||
bankObj.interact("Bank");
|
||||
} else if (bankObj.actions().contains("Use")) {
|
||||
bankObj.interact("Use");
|
||||
} else {
|
||||
bankObj.interact(0);
|
||||
}
|
||||
|
||||
game.waitUntil(() -> bank.isOpen(), 15);
|
||||
}
|
||||
|
||||
int barCount = bank.quantity(config.metalType().getBarId()) + (int) game.inventory().withId(config.metalType().getBarId()).count();
|
||||
|
||||
if (barCount < config.product().getRequiredBars()) {
|
||||
plugin.stop("Out of bars, stopping plugin.");
|
||||
}
|
||||
|
||||
bank.depositExcept(false, ItemID.HAMMER, ItemID.IMCANDO_HAMMER, config.metalType().getBarId());
|
||||
game.sleepDelay();
|
||||
|
||||
bank.withdraw(config.metalType().getBarId(), 28, false);
|
||||
game.sleepDelay();
|
||||
|
||||
bank.close();
|
||||
game.sleepDelay();
|
||||
|
||||
lastBanking = Instant.now();
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package io.reisub.openosrs.smither.tasks;
|
||||
|
||||
import io.reisub.openosrs.smither.Config;
|
||||
import io.reisub.openosrs.smither.Smither;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import io.reisub.openosrs.util.enums.Activity;
|
||||
import net.runelite.api.AnimationID;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.client.plugins.iutils.game.iObject;
|
||||
import net.runelite.client.plugins.iutils.game.iWidget;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class Smith extends Task {
|
||||
@Inject
|
||||
private Smither plugin;
|
||||
|
||||
@Inject
|
||||
private Config config;
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Smithing";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
return plugin.getCurrentActivity() == Activity.IDLE
|
||||
&& !bank.isOpen()
|
||||
&& game.inventory().withId(config.metalType().getBarId()).count() >= config.product().getRequiredBars();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
iObject anvil = game.objects().withName("Anvil").withAction("Smith").nearest();
|
||||
if (anvil == null) return;
|
||||
|
||||
anvil.interact("Smith");
|
||||
game.waitUntil(() -> game.widget(WidgetInfo.SMITHING_INVENTORY_ITEMS_CONTAINER) != null, 15);
|
||||
|
||||
iWidget productWidget = game.widget(312, config.product().getInterfaceId());
|
||||
if (productWidget == null) return;
|
||||
|
||||
productWidget.interact("Smith");
|
||||
|
||||
game.waitUntil(() -> game.localPlayer().animation() == AnimationID.SMITHING_ANVIL
|
||||
|| game.localPlayer().animation() == AnimationID.SMITHING_IMCANDO_HAMMER, 10);
|
||||
game.tick();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user