Initial commit
This commit is contained in:
@ -0,0 +1,20 @@
|
||||
package io.reisub.openosrs.tempoross;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum Activity {
|
||||
IDLE("Idle"),
|
||||
FISHING("Fishing"),
|
||||
COOKING("Cooking"),
|
||||
ATTACKING("Attacking"),
|
||||
DOUSING_FIRE("Dousing"),
|
||||
REPAIRING_MAST("Repairing"),
|
||||
TETHERING_MAST("Tethering"),
|
||||
STOCKING_CANNON("Stocking"),
|
||||
FILLING_BUCKETS("Filling");
|
||||
|
||||
private final String actionString;
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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.tempoross;
|
||||
|
||||
import net.runelite.client.config.Button;
|
||||
import net.runelite.client.config.ConfigGroup;
|
||||
import net.runelite.client.config.ConfigItem;
|
||||
|
||||
@ConfigGroup("ChaosTemporossConfig")
|
||||
|
||||
public interface Config extends net.runelite.client.config.Config {
|
||||
@ConfigItem(
|
||||
keyName = "startButton",
|
||||
name = "Start/Stop",
|
||||
description = "Start the script",
|
||||
position = 100
|
||||
)
|
||||
default Button startButton() {
|
||||
return new Button();
|
||||
}
|
||||
}
|
@ -0,0 +1,368 @@
|
||||
package io.reisub.openosrs.tempoross;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.inject.Provides;
|
||||
|
||||
import io.reisub.openosrs.tempoross.tasks.*;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import io.reisub.openosrs.util.Util;
|
||||
import io.reisub.openosrs.util.tasks.Run;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.*;
|
||||
import net.runelite.api.events.*;
|
||||
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.game.iObject;
|
||||
import net.runelite.client.plugins.iutils.game.iWidget;
|
||||
import net.runelite.client.plugins.iutils.iUtils;
|
||||
import net.runelite.client.plugins.iutils.scripts.iScript;
|
||||
import org.pf4j.Extension;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static net.runelite.api.AnimationID.IDLE;
|
||||
|
||||
@Extension
|
||||
@PluginDependency(Util.class)
|
||||
@PluginDependency(iUtils.class)
|
||||
@PluginDescriptor(
|
||||
name = "Chaos Tempoross",
|
||||
description = "Plays the Tempoross minigame",
|
||||
enabledByDefault = false
|
||||
)
|
||||
@Slf4j
|
||||
public class Tempoross extends iScript {
|
||||
private static final String WAVE_INCOMING_MESSAGE = "a colossal wave closes in...";
|
||||
private static final String WAVE_END_SAFE = "as the wave washes over you";
|
||||
private static final String WAVE_END_DANGEROUS = "the wave slams into you";
|
||||
private static final String TEMPOROSS_VULNERABLE_MESSAGE = "tempoross is vulnerable";
|
||||
|
||||
private static final int VARB_IS_TETHERED = 11895;
|
||||
|
||||
private static final int TEMPOROSS_REGION = 12078;
|
||||
private static final int UNKAH_REWARD_POOL_REGION = 12588;
|
||||
private static final int UNKAH_BOAT_REGION = 12332;
|
||||
|
||||
private static final int FIRE_SPREAD_MILLIS = 24000;
|
||||
private static final int FIRE_SPAWN_MILLIS = 9600;
|
||||
private static final int FIRE_SPREADING_SPAWN_MILLIS = 1200;
|
||||
private static final int WAVE_IMPACT_MILLIS = 7800;
|
||||
|
||||
public static final int FIRE_ID = 37582;
|
||||
public static final int DOUSING_FIRE_ANIM_ID = 2771;
|
||||
|
||||
private final Set<Integer> TEMPOROSS_GAMEOBJECTS = ImmutableSet.of(
|
||||
FIRE_ID, NullObjectID.NULL_41006, NullObjectID.NULL_41007, NullObjectID.NULL_41352,
|
||||
NullObjectID.NULL_41353, NullObjectID.NULL_41354, NullObjectID.NULL_41355, ObjectID.DAMAGED_MAST_40996,
|
||||
ObjectID.DAMAGED_MAST_40997, ObjectID.DAMAGED_TOTEM_POLE, ObjectID.DAMAGED_TOTEM_POLE_41011);
|
||||
|
||||
//41006 = shadow before fire is burning
|
||||
//41007 = shadow just before fire is jumping over to a next spot
|
||||
//41354/41355 = a totem to grapple on to
|
||||
//41352/41353 = a mast to grapple on to
|
||||
//41010/41011 = a totem that is broken
|
||||
//40996/40997 = a broken mast
|
||||
|
||||
@Getter
|
||||
private final Map<GameObject, TemporossObject> temporossObjects = new HashMap<>();
|
||||
|
||||
@Getter
|
||||
private boolean waveIncoming;
|
||||
|
||||
@Getter
|
||||
private int phase = 1;
|
||||
|
||||
@Getter
|
||||
private int playersReady;
|
||||
|
||||
@Getter
|
||||
private int energy;
|
||||
|
||||
@Getter
|
||||
private int essence;
|
||||
|
||||
@Getter
|
||||
private int stormIntensity;
|
||||
|
||||
@Getter
|
||||
private Activity currentActivity;
|
||||
|
||||
@Getter
|
||||
private Instant lastActionTime;
|
||||
|
||||
private List<Task> tasks;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Provides
|
||||
Config provideConfig(ConfigManager configManager) {
|
||||
return configManager.getConfig(Config.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loop() {
|
||||
for (Task t : tasks) {
|
||||
if (t.validate()) {
|
||||
log.info(t.getStatus());
|
||||
t.execute();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
game.sleepDelay();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
log.info("Starting Chaos Tempoross");
|
||||
|
||||
Run runTask = injector.getInstance(Run.class);
|
||||
runTask.setInterval(70, 95);
|
||||
|
||||
tasks = new ArrayList<>();
|
||||
tasks.add(runTask);
|
||||
tasks.add(injector.getInstance(EnterBoat.class));
|
||||
tasks.add(injector.getInstance(FillBuckets.class));
|
||||
tasks.add(injector.getInstance(LeaveBoat.class));
|
||||
tasks.add(injector.getInstance(Repair.class));
|
||||
tasks.add(injector.getInstance(Tether.class));
|
||||
tasks.add(injector.getInstance(Attack.class));
|
||||
tasks.add(injector.getInstance(Stock.class));
|
||||
tasks.add(injector.getInstance(Fish.class));
|
||||
tasks.add(injector.getInstance(Cook.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
log.info("Stopping Chaos Tempoross");
|
||||
if (tasks != null) {
|
||||
tasks.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Subscribe
|
||||
private void onConfigButtonPressed(ConfigButtonClicked configButtonClicked) {
|
||||
if (configButtonClicked.getKey().equals("startButton")) {
|
||||
execute();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Subscribe
|
||||
private void onGameTick(GameTick event) {
|
||||
if (isInDesert() || isOnBoat()) {
|
||||
playersReady = parseWidget(687, 3);
|
||||
} else if (isInTemperossArea()) {
|
||||
energy = parseWidget(437, 35);
|
||||
essence = parseWidget(437, 45);
|
||||
stormIntensity = parseWidget(437, 55);
|
||||
}
|
||||
|
||||
checkActionTimeout();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Subscribe
|
||||
private void onGameObjectSpawned(GameObjectSpawned event) {
|
||||
GameObject gameObject = event.getGameObject();
|
||||
|
||||
if (!TEMPOROSS_GAMEOBJECTS.contains(gameObject.getId())) return;
|
||||
|
||||
TemporossObject temporossObject;
|
||||
|
||||
switch (event.getGameObject().getId()) {
|
||||
case FIRE_ID:
|
||||
temporossObject = new TemporossObject(gameObject, Instant.now(), FIRE_SPREAD_MILLIS);
|
||||
break;
|
||||
case NullObjectID.NULL_41006:
|
||||
temporossObject = new TemporossObject(gameObject, Instant.now(), FIRE_SPAWN_MILLIS);
|
||||
break;
|
||||
case NullObjectID.NULL_41007:
|
||||
temporossObject = new TemporossObject(gameObject, Instant.now(), FIRE_SPREADING_SPAWN_MILLIS);
|
||||
break;
|
||||
default:
|
||||
temporossObject = new TemporossObject(gameObject, Instant.now(), WAVE_IMPACT_MILLIS);
|
||||
}
|
||||
|
||||
temporossObjects.put(gameObject, temporossObject);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Subscribe
|
||||
private void onGameObjectDespawned(GameObjectDespawned gameObjectDespawned) {
|
||||
int id = gameObjectDespawned.getGameObject().getId();
|
||||
|
||||
if (id == FIRE_ID) {
|
||||
if (currentActivity == Activity.DOUSING_FIRE) {
|
||||
setActivity(Activity.IDLE);
|
||||
}
|
||||
}
|
||||
|
||||
Set<Integer> brokenMastsTotems = ImmutableSet.of(
|
||||
ObjectID.DAMAGED_MAST_40996,
|
||||
ObjectID.DAMAGED_MAST_40997,
|
||||
ObjectID.DAMAGED_TOTEM_POLE,
|
||||
ObjectID.DAMAGED_TOTEM_POLE_41011
|
||||
);
|
||||
|
||||
if (brokenMastsTotems.contains(id)) {
|
||||
if (currentActivity == Activity.REPAIRING_MAST) {
|
||||
setActivity(Activity.IDLE);
|
||||
}
|
||||
}
|
||||
|
||||
temporossObjects.remove(gameObjectDespawned.getGameObject());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Subscribe
|
||||
private void onChatMessage(ChatMessage chatMessage) {
|
||||
if (chatMessage.getType() != ChatMessageType.GAMEMESSAGE) return;
|
||||
|
||||
String message = chatMessage.getMessage().toLowerCase();
|
||||
if (message.contains(WAVE_INCOMING_MESSAGE)) {
|
||||
waveIncoming = true;
|
||||
} else if (message.contains(WAVE_END_SAFE) || message.contains(WAVE_END_DANGEROUS)) {
|
||||
if (message.contains(WAVE_END_SAFE)) {
|
||||
setActivity(Activity.IDLE);
|
||||
}
|
||||
waveIncoming = false;
|
||||
} else if (message.contains(TEMPOROSS_VULNERABLE_MESSAGE)) {
|
||||
phase++;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Subscribe
|
||||
private void onAnimationChanged(AnimationChanged event) {
|
||||
if (game.client().getGameState() != GameState.LOGGED_IN) return;
|
||||
|
||||
if (event.getActor() != game.client().getLocalPlayer()) return;
|
||||
|
||||
int animId = game.localPlayer().animation();
|
||||
switch (animId) {
|
||||
case AnimationID.FISHING_BAREHAND:
|
||||
case AnimationID.FISHING_BAREHAND_WINDUP_1:
|
||||
case AnimationID.FISHING_BAREHAND_WINDUP_2:
|
||||
setActivity(Activity.FISHING);
|
||||
case AnimationID.COOKING_RANGE:
|
||||
iObject shrine = game.objects().withName("Shrine").nearest();
|
||||
if (shrine != null && shrine.position().distanceTo(game.localPlayer().position()) <= 3) {
|
||||
setActivity(Activity.COOKING);
|
||||
} else {
|
||||
setActivity(Activity.STOCKING_CANNON);
|
||||
}
|
||||
case DOUSING_FIRE_ANIM_ID:
|
||||
setActivity(Activity.DOUSING_FIRE);
|
||||
case AnimationID.CONSTRUCTION:
|
||||
case AnimationID.CONSTRUCTION_IMCANDO:
|
||||
setActivity(Activity.REPAIRING_MAST);
|
||||
case AnimationID.USING_GILDED_ALTAR:
|
||||
setActivity(Activity.TETHERING_MAST);
|
||||
case AnimationID.LOOKING_INTO:
|
||||
setActivity(Activity.FILLING_BUCKETS);
|
||||
case 0:
|
||||
setActivity(Activity.ATTACKING);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Subscribe
|
||||
private void onItemContainerChanged(ItemContainerChanged event) {
|
||||
final ItemContainer container = event.getItemContainer();
|
||||
|
||||
int rawFish = (int) game.inventory().withId(ItemID.RAW_HARPOONFISH).count();
|
||||
int cookedFish = (int) game.inventory().withId(ItemID.HARPOONFISH).count();
|
||||
int emptyBuckets = (int) game.inventory().withId(ItemID.BUCKET).count();
|
||||
|
||||
if (rawFish == 0 && currentActivity == Activity.COOKING) {
|
||||
setActivity(Activity.IDLE);
|
||||
} else if (game.inventory().full() && currentActivity == Activity.FISHING) {
|
||||
setActivity(Activity.IDLE);
|
||||
} else if (cookedFish == 0 && currentActivity == Activity.STOCKING_CANNON) {
|
||||
setActivity(Activity.IDLE);
|
||||
} else if (emptyBuckets == 0 && currentActivity == Activity.FILLING_BUCKETS) {
|
||||
setActivity(Activity.IDLE);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Subscribe
|
||||
private void onNpcSpawned(NpcSpawned npcSpawned) {
|
||||
if (npcSpawned.getNpc().getId() == NpcID.FISHING_SPOT_10569
|
||||
&& !game.inventory().full()
|
||||
&& (currentActivity == Activity.COOKING || currentActivity == Activity.FISHING)) {
|
||||
setActivity(Activity.IDLE);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Subscribe
|
||||
private void onVarbitChanged(VarbitChanged event) {
|
||||
if (game.client().getVarbitValue(VARB_IS_TETHERED) > 0) {
|
||||
setActivity(Activity.TETHERING_MAST);
|
||||
}
|
||||
|
||||
if (game.client().getVarbitValue(VARB_IS_TETHERED) <= 0 && currentActivity == Activity.TETHERING_MAST) {
|
||||
setActivity(Activity.IDLE);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isOnBoat() {
|
||||
return game.localPlayer().position().regionID() == UNKAH_BOAT_REGION;
|
||||
}
|
||||
|
||||
public boolean isInDesert() {
|
||||
return game.localPlayer().position().regionID() == UNKAH_REWARD_POOL_REGION;
|
||||
}
|
||||
|
||||
public boolean isInTemperossArea() {
|
||||
return game.localPlayer().position().regionID() == TEMPOROSS_REGION;
|
||||
}
|
||||
|
||||
private int parseWidget(int group, int file) {
|
||||
iWidget widget = game.widget(group, file);
|
||||
if (widget == null || widget.text().equals("")) return 0;
|
||||
|
||||
Pattern regex = Pattern.compile("\\d+|None");
|
||||
Matcher matcher = regex.matcher(widget.text());
|
||||
|
||||
if (matcher.find()) {
|
||||
String match = matcher.group(0);
|
||||
if (match.equals("None")) return 0;
|
||||
|
||||
return Integer.parseInt(match);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private void setActivity(Activity action) {
|
||||
currentActivity = action;
|
||||
|
||||
if (action != Activity.IDLE) {
|
||||
lastActionTime = Instant.now();
|
||||
}
|
||||
}
|
||||
|
||||
private void checkActionTimeout() {
|
||||
if (currentActivity == Activity.IDLE) return;
|
||||
|
||||
int animId = game.localPlayer().animation();
|
||||
if (animId != IDLE || lastActionTime == null) return;
|
||||
|
||||
Duration timeout = Duration.ofSeconds(3);
|
||||
Duration sinceAction = Duration.between(lastActionTime, Instant.now());
|
||||
|
||||
if (sinceAction.compareTo(timeout) >= 0) {
|
||||
setActivity(Activity.IDLE);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package io.reisub.openosrs.tempoross;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import net.runelite.api.GameObject;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public class TemporossObject {
|
||||
private GameObject object;
|
||||
private Instant start;
|
||||
private long duration;
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package io.reisub.openosrs.tempoross.tasks;
|
||||
|
||||
import io.reisub.openosrs.tempoross.Activity;
|
||||
import io.reisub.openosrs.tempoross.Tempoross;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class Attack extends Task {
|
||||
@Inject
|
||||
private Tempoross plugin;
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Attacking";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
if (!plugin.isInTemperossArea()) return false;
|
||||
|
||||
return plugin.getCurrentActivity() == Activity.IDLE
|
||||
&& game.npcs().withId().exists();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
game.npcs().withId().findFirst().ifPresent((pool) -> {
|
||||
pool.interact(0);
|
||||
game.waitUntil(() -> plugin.getCurrentActivity() == Activity.ATTACKING, 20);
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package io.reisub.openosrs.tempoross.tasks;
|
||||
|
||||
import io.reisub.openosrs.tempoross.Activity;
|
||||
import io.reisub.openosrs.tempoross.Tempoross;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import net.runelite.api.ItemID;
|
||||
import net.runelite.client.plugins.iutils.game.iObject;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class Cook extends Task {
|
||||
@Inject
|
||||
private Tempoross plugin;
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Cooking";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
if (!plugin.isInTemperossArea()) return false;
|
||||
|
||||
if (!game.inventory().withId(ItemID.RAW_HARPOONFISH).exists()) return false;
|
||||
|
||||
if (plugin.getCurrentActivity() == Activity.IDLE) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
iObject shrine = game.objects().withName("Shrine").nearest();
|
||||
if (shrine == null) return;
|
||||
|
||||
shrine.interact("Cook-at");
|
||||
game.tick();
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package io.reisub.openosrs.tempoross.tasks;
|
||||
|
||||
import io.reisub.openosrs.tempoross.Tempoross;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import net.runelite.api.ItemID;
|
||||
import net.runelite.client.plugins.iutils.game.iObject;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class DouseFire extends Task {
|
||||
@Inject
|
||||
private Tempoross plugin;
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Dousing fire";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
if (!plugin.isInTemperossArea()) return false;
|
||||
|
||||
return game.inventory().withId(ItemID.BUCKET_OF_WATER).exists()
|
||||
&& game.objects().withName("Fire").exists();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
iObject fire = game.objects().withName("Fire").nearest();
|
||||
if (fire == null) return;
|
||||
|
||||
fire.interact("Douse");
|
||||
game.tick();
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package io.reisub.openosrs.tempoross.tasks;
|
||||
|
||||
import io.reisub.openosrs.tempoross.Tempoross;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class EnterBoat extends Task {
|
||||
@Inject
|
||||
private Tempoross plugin;
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Entering boat";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
return plugin.isInDesert()
|
||||
&& plugin.getPlayersReady() == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
game.objects().withName("Rope ladder").findFirst().ifPresent((ladder) -> {
|
||||
ladder.interact("Climb");
|
||||
game.waitUntil(() -> plugin.isOnBoat(), 15);
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package io.reisub.openosrs.tempoross.tasks;
|
||||
|
||||
import io.reisub.openosrs.tempoross.Activity;
|
||||
import io.reisub.openosrs.tempoross.Tempoross;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import net.runelite.api.ItemID;
|
||||
import net.runelite.api.ObjectID;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class FillBuckets extends Task {
|
||||
@Inject
|
||||
private Tempoross plugin;
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Filling buckets";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
if (!game.inventory().withId(ItemID.BUCKET).exists()) return false;
|
||||
|
||||
long filledBuckets = game.inventory().withId(ItemID.BUCKET_OF_WATER).count();
|
||||
// TODO limit to play area
|
||||
long fires = game.objects().withName("Fire").withAction("Douse").count();
|
||||
|
||||
return plugin.isOnBoat() || (plugin.isInTemperossArea() && filledBuckets < fires);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
game.objects().withName("Water pump").findFirst().ifPresent((pump) -> {
|
||||
pump.interact("Use");
|
||||
game.waitUntil(() -> plugin.getCurrentActivity() == Activity.FILLING_BUCKETS, 20);
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
package io.reisub.openosrs.tempoross.tasks;
|
||||
|
||||
import io.reisub.openosrs.tempoross.Activity;
|
||||
import io.reisub.openosrs.tempoross.Tempoross;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import net.runelite.api.ItemID;
|
||||
import net.runelite.api.NpcID;
|
||||
import net.runelite.client.plugins.iutils.game.iNPC;
|
||||
import net.runelite.client.plugins.iutils.game.iObject;
|
||||
import net.runelite.client.plugins.iutils.scene.Position;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class Fish extends Task {
|
||||
@Inject
|
||||
private Tempoross plugin;
|
||||
|
||||
private final int normalSpotID = NpcID.FISHING_SPOT_10565;
|
||||
private final int doubleSpotID = NpcID.FISHING_SPOT_10569;
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Fishing";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
if (!plugin.isInTemperossArea() || game.inventory().full()) return false;
|
||||
|
||||
iNPC normalSpot = game.npcs().withId(normalSpotID).nearest();
|
||||
iNPC doubleSpot = game.npcs().withId(doubleSpotID).nearest();
|
||||
|
||||
// interrupt cooking when double spot exists
|
||||
if (plugin.getCurrentActivity() == Activity.COOKING
|
||||
&& doubleSpot != null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// change from normal spot to double spot
|
||||
Position playerPos = game.localPlayer().position();
|
||||
if (plugin.getCurrentActivity() == Activity.FISHING
|
||||
&& doubleSpot != null
|
||||
&& doubleSpot.position().distanceTo(playerPos) > normalSpot.position().distanceTo(playerPos)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// fish when idle and low on raw harpoonfish
|
||||
if (plugin.getCurrentActivity() == Activity.IDLE
|
||||
&& game.inventory().withId(ItemID.RAW_HARPOONFISH).count() <= 8) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
iObject spot = game.objects().withId(doubleSpotID).nearest();
|
||||
|
||||
if (spot == null) {
|
||||
spot = game.objects().withId(normalSpotID).nearest();
|
||||
}
|
||||
|
||||
if (spot == null) return;
|
||||
|
||||
spot.interact(0);
|
||||
game.waitUntil(() -> plugin.getCurrentActivity() == Activity.FISHING);
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package io.reisub.openosrs.tempoross.tasks;
|
||||
|
||||
import io.reisub.openosrs.tempoross.Tempoross;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class LeaveBoat extends Task {
|
||||
@Inject
|
||||
private Tempoross plugin;
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Leaving boat";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
return plugin.isOnBoat()
|
||||
&& plugin.getPlayersReady() > 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
game.objects().withName("Rope ladder").findFirst().ifPresent((ladder) -> {
|
||||
ladder.interact("Climb");
|
||||
game.waitUntil(() -> plugin.isInDesert(), 15);
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package io.reisub.openosrs.tempoross.tasks;
|
||||
|
||||
import io.reisub.openosrs.tempoross.Activity;
|
||||
import io.reisub.openosrs.tempoross.Tempoross;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import net.runelite.api.NullObjectID;
|
||||
import net.runelite.api.ObjectID;
|
||||
import net.runelite.client.plugins.iutils.game.iObject;
|
||||
import net.runelite.client.plugins.iutils.scene.Position;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class Repair extends Task {
|
||||
@Inject
|
||||
private Tempoross plugin;
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Repairing";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
if (!plugin.isInTemperossArea() || !plugin.isWaveIncoming()) return false;
|
||||
|
||||
iObject tetherPole = game.objects().withId(NullObjectID.NULL_41352, NullObjectID.NULL_41353, NullObjectID.NULL_41354, NullObjectID.NULL_41355).nearest();
|
||||
iObject brokenPole = game.objects().withId(ObjectID.DAMAGED_MAST_40996, ObjectID.DAMAGED_MAST_40997, ObjectID.DAMAGED_TOTEM_POLE, ObjectID.DAMAGED_TOTEM_POLE_41011).nearest();
|
||||
Position playerPos = game.localPlayer().position();
|
||||
|
||||
return playerPos.distanceTo(tetherPole.position()) > playerPos.distanceTo(brokenPole.position());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
iObject brokenPole = game.objects().withId(ObjectID.DAMAGED_MAST_40996, ObjectID.DAMAGED_MAST_40997, ObjectID.DAMAGED_TOTEM_POLE, ObjectID.DAMAGED_TOTEM_POLE_41011).nearest();
|
||||
if (brokenPole == null) return;
|
||||
|
||||
brokenPole.interact(0);
|
||||
game.waitUntil(() -> plugin.getCurrentActivity() == Activity.REPAIRING_MAST, 20);
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package io.reisub.openosrs.tempoross.tasks;
|
||||
|
||||
import io.reisub.openosrs.tempoross.Tempoross;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import net.runelite.api.ItemID;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class Stock extends Task {
|
||||
@Inject
|
||||
private Tempoross plugin;
|
||||
|
||||
private int stocked;
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Stocking cannon";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
if (!plugin.isInTemperossArea()) return false;
|
||||
|
||||
long rawFish = game.inventory().withId(ItemID.RAW_HARPOONFISH).count();
|
||||
long cookedFish = game.inventory().withId(ItemID.HARPOONFISH).count();
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
long crystalFish = game.inventory().withId(ItemID.CRYSTALLISED_HARPOONFISH).count();
|
||||
|
||||
// stock cannon for the first time
|
||||
// bring energy to 4%
|
||||
if (plugin.getPhase() == 1 && cookedFish == 17 && plugin.getEnergy() == 100) return true;
|
||||
|
||||
// stock cannon for the second time
|
||||
// trigger first phase change
|
||||
// bring energy to 4% or as close as possible
|
||||
if (plugin.getPhase() == 1 && plugin.getEnergy() < 100
|
||||
&& (plugin.getStormIntensity() >= 93 || cookedFish == 19)) return true;
|
||||
|
||||
// stock cannon at phase 2
|
||||
// bring energy to 4%
|
||||
if (plugin.getPhase() == 2
|
||||
&& plugin.getEnergy() != 4
|
||||
&& cookedFish >= 19 - stocked) return true;
|
||||
|
||||
// stock cannon at phase 2
|
||||
// trigger second phase change
|
||||
// bring energy to 4%
|
||||
if (plugin.getPhase() == 2
|
||||
&& (plugin.getStormIntensity() >= 93 || cookedFish == 19)) return true;
|
||||
|
||||
// stock cannon at phase 3
|
||||
// trigger third phase change and potentially fourth phase change
|
||||
if (plugin.getPhase() == 3
|
||||
&& (plugin.getStormIntensity() >= 93 || (cookedFish > 0 && rawFish == 0 && game.inventory().full()))) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package io.reisub.openosrs.tempoross.tasks;
|
||||
|
||||
import io.reisub.openosrs.tempoross.Activity;
|
||||
import io.reisub.openosrs.tempoross.Tempoross;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class Tether extends Task {
|
||||
@Inject
|
||||
private Tempoross plugin;
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Tethering";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
if (!plugin.isInTemperossArea()) return false;
|
||||
|
||||
return plugin.isWaveIncoming() && plugin.getCurrentActivity() != Activity.TETHERING_MAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
|
||||
}
|
||||
}
|
52
tempoross/tempoross.gradle.kts
Normal file
52
tempoross/tempoross.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 Tempoross" // This is the name that is used in the external plugin manager panel
|
||||
project.extra["PluginDescription"] = "Plays the Tempoross minigame" // 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"]
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user