Initial commit
This commit is contained in:
52
blackjack/blackjack.gradle.kts
Normal file
52
blackjack/blackjack.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 = "0.0.1"
|
||||
|
||||
project.extra["PluginName"] = "Chaos Blackjack"
|
||||
project.extra["PluginDescription"] = "Blackjacks like a black Jack"
|
||||
|
||||
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"]
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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.blackjack;
|
||||
|
||||
import net.runelite.client.config.Button;
|
||||
import net.runelite.client.config.Config;
|
||||
import net.runelite.client.config.ConfigGroup;
|
||||
import net.runelite.client.config.ConfigItem;
|
||||
|
||||
@ConfigGroup("ChaosBlackjackConfig")
|
||||
|
||||
public interface BlackjackConfig extends Config {
|
||||
@ConfigItem(
|
||||
keyName = "target",
|
||||
name = "Target",
|
||||
description = "Select blackjack target",
|
||||
position = 10
|
||||
)
|
||||
default Target target() {
|
||||
return Target.THUG;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "startButton",
|
||||
name = "Start/Stop",
|
||||
description = "Start the script",
|
||||
position = 100
|
||||
)
|
||||
default Button startButton() {
|
||||
return new Button();
|
||||
}
|
||||
}
|
@ -0,0 +1,150 @@
|
||||
package io.reisub.openosrs.blackjack;
|
||||
|
||||
import com.google.inject.Provides;
|
||||
import io.reisub.openosrs.blackjack.tasks.Blackjack;
|
||||
import io.reisub.openosrs.blackjack.tasks.Escape;
|
||||
import io.reisub.openosrs.blackjack.tasks.Pickpocket;
|
||||
import io.reisub.openosrs.util.Calculations;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import io.reisub.openosrs.util.Util;
|
||||
import io.reisub.openosrs.util.tasks.Eat;
|
||||
import io.reisub.openosrs.util.tasks.KittenTask;
|
||||
import io.reisub.openosrs.util.tasks.Run;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.events.ChatMessage;
|
||||
import net.runelite.api.events.ConfigButtonClicked;
|
||||
import net.runelite.api.events.GameTick;
|
||||
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.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Extension
|
||||
@PluginDependency(Util.class)
|
||||
@PluginDependency(iUtils.class)
|
||||
@PluginDescriptor(
|
||||
name = "Chaos Blackjack",
|
||||
description = "",
|
||||
enabledByDefault = false
|
||||
)
|
||||
@Slf4j
|
||||
public class BlackjackPlugin extends iScript {
|
||||
private final String BLACKJACK_SUCCESS = "You smack the bandit over the head and render them unconscious.";
|
||||
private final String BLACKJACK_FAIL = "Your blow only glances off the bandit's head.";
|
||||
private final String PICKPOCKET = "You pick the bandit's pocket.";
|
||||
|
||||
private List<Task> tasks;
|
||||
private KittenTask kittenTask;
|
||||
private Blackjack blackjackTask;
|
||||
private Pickpocket pickpocketTask;
|
||||
private Escape escapeTask;
|
||||
private long lastAction = 0;
|
||||
|
||||
@Provides
|
||||
BlackjackConfig provideConfig(ConfigManager configManager) {
|
||||
return configManager.getConfig(BlackjackConfig.class);
|
||||
}
|
||||
|
||||
@Inject
|
||||
private Calculations calc;
|
||||
|
||||
@Override
|
||||
protected void loop() {
|
||||
for (Task t : tasks) {
|
||||
if (t.validate()) {
|
||||
lastAction = System.currentTimeMillis();
|
||||
log.info(t.getStatus());
|
||||
t.execute();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
log.info("Starting Chaos Blackjack");
|
||||
|
||||
Eat eatTask = injector.getInstance(Eat.class);
|
||||
eatTask.setWait(false);
|
||||
eatTask.setInterval(14, 24);
|
||||
|
||||
Run runTask = injector.getInstance(Run.class);
|
||||
runTask.setInterval(70, 95);
|
||||
|
||||
kittenTask = KittenTask.getInstance(injector);
|
||||
pickpocketTask = injector.getInstance(Pickpocket.class);
|
||||
blackjackTask = injector.getInstance(Blackjack.class);
|
||||
escapeTask = injector.getInstance(Escape.class);
|
||||
|
||||
tasks = new ArrayList<>();
|
||||
tasks.add(kittenTask);
|
||||
tasks.add(escapeTask);
|
||||
tasks.add(pickpocketTask);
|
||||
tasks.add(blackjackTask);
|
||||
tasks.add(eatTask);
|
||||
tasks.add(runTask);
|
||||
|
||||
blackjackTask.setReady(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
log.info("Stopping Chaos Blackjack");
|
||||
if (tasks != null) {
|
||||
tasks.clear();
|
||||
}
|
||||
|
||||
KittenTask.handleKitten = false;
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
private void onConfigButtonPressed(ConfigButtonClicked configButtonClicked) {
|
||||
if (configButtonClicked.getKey().equals("startButton")) {
|
||||
execute();
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
private void onChatMessage(ChatMessage chatMessage) {
|
||||
if (kittenTask != null) {
|
||||
kittenTask.onChatMessage(chatMessage);
|
||||
}
|
||||
|
||||
if (pickpocketTask != null && blackjackTask != null) {
|
||||
String msg = chatMessage.getMessage();
|
||||
if (msg.contains(BLACKJACK_SUCCESS) || msg.contains(BLACKJACK_FAIL)) {
|
||||
blackjackTask.setNextKnockoutTick(game.client().getTickCount() + calc.random(3, 5));
|
||||
pickpocketTask.setReady(true);
|
||||
}
|
||||
|
||||
if (msg.contains(BLACKJACK_FAIL)) {
|
||||
blackjackTask.setReady(true);
|
||||
}
|
||||
|
||||
if (msg.contains(PICKPOCKET)) {
|
||||
if (pickpocketTask.getSuccessivePickpockets() < 2) {
|
||||
pickpocketTask.setReady(true);
|
||||
} else {
|
||||
pickpocketTask.setSuccessivePickpockets(0);
|
||||
blackjackTask.setReady(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
private void onGameTick(GameTick event) {
|
||||
if (System.currentTimeMillis() > lastAction + calc.random(5000, 6000)) {
|
||||
log.info("idle, blackjacking");
|
||||
pickpocketTask.setSuccessivePickpockets(0);
|
||||
blackjackTask.setReady(true);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package io.reisub.openosrs.blackjack;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.runelite.api.NpcID;
|
||||
|
||||
public enum Target {
|
||||
BANDIT_41(NpcID.BANDIT_737),
|
||||
BANDIT_56(NpcID.BANDIT_735),
|
||||
THUG(NpcID.MENAPHITE_THUG);
|
||||
|
||||
@Getter
|
||||
private final int id;
|
||||
|
||||
Target(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package io.reisub.openosrs.blackjack.tasks;
|
||||
|
||||
import io.reisub.openosrs.blackjack.BlackjackConfig;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.runelite.client.plugins.iutils.game.iNPC;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class Blackjack extends Task {
|
||||
@Inject
|
||||
private BlackjackConfig config;
|
||||
|
||||
@Setter @Getter
|
||||
private volatile boolean ready;
|
||||
|
||||
@Setter @Getter
|
||||
private volatile long nextKnockoutTick = 0;
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Blackjacking";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
return isReady()
|
||||
&& game.client().getTickCount() >= nextKnockoutTick
|
||||
&& game.client().getLocalPlayer().getModelHeight() != 1000
|
||||
&& game.inventory().withAction("Eat", "Drink").exists();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
iNPC target = game.npcs().withId(config.target().getId()).nearest();
|
||||
if (target == null) return;
|
||||
|
||||
target.interact("Knock-Out");
|
||||
ready = false;
|
||||
game.tick();
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package io.reisub.openosrs.blackjack.tasks;
|
||||
|
||||
import io.reisub.openosrs.util.Task;
|
||||
|
||||
public class Escape extends Task {
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Escaping from combat";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package io.reisub.openosrs.blackjack.tasks;
|
||||
|
||||
import io.reisub.openosrs.blackjack.BlackjackConfig;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.runelite.client.plugins.iutils.game.iNPC;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class Pickpocket extends Task {
|
||||
@Inject
|
||||
private BlackjackConfig config;
|
||||
|
||||
@Setter
|
||||
private volatile boolean ready;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private volatile int successivePickpockets = 0;
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Pickpocketing";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
return ready && game.inventory().withAction("Eat", "Drink").exists();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
iNPC target = game.npcs().withId(config.target().getId()).nearest();
|
||||
if (target == null) return;
|
||||
|
||||
if (getSuccessivePickpockets() == 0) {
|
||||
game.sleepDelay();
|
||||
}
|
||||
|
||||
target.interact("Pickpocket");
|
||||
setSuccessivePickpockets(getSuccessivePickpockets() + 1);
|
||||
ready = false;
|
||||
game.tick();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user