Initial commit
This commit is contained in:
52
consume/consume.gradle.kts
Normal file
52
consume/consume.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 Consume" // This is the name that is used in the external plugin manager panel
|
||||
project.extra["PluginDescription"] = "Eats, drinks, activates items/specials" // 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"]
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
387
consume/src/main/java/io/reisub/openosrs/consume/Config.java
Normal file
387
consume/src/main/java/io/reisub/openosrs/consume/Config.java
Normal file
@ -0,0 +1,387 @@
|
||||
/*
|
||||
* 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.consume;
|
||||
|
||||
import net.runelite.client.config.*;
|
||||
|
||||
@ConfigGroup("ChaosConsumeConfig")
|
||||
|
||||
public interface Config extends net.runelite.client.config.Config {
|
||||
@ConfigSection(
|
||||
keyName = "eatConfig",
|
||||
name = "Eating Configuration",
|
||||
description = "Configure when to eat",
|
||||
position = 1
|
||||
)
|
||||
String eatConfig = "eatConfig";
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "enableEating",
|
||||
name = "Enable eating",
|
||||
description = "Enable automatic eating based on the minimum and maximum values set below.",
|
||||
section = "eatConfig",
|
||||
position = 2
|
||||
)
|
||||
default boolean enableEating() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "minEatHP",
|
||||
name = "Minimum Eat HP",
|
||||
description = "Minimum HP to eat at.",
|
||||
section = "eatConfig",
|
||||
position = 3
|
||||
)
|
||||
default int minEatHP() {
|
||||
return 10;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "maxEatHP",
|
||||
name = "Maximum Eat HP",
|
||||
description = "Highest HP to potentially eat at.",
|
||||
section = "eatConfig",
|
||||
position = 4
|
||||
)
|
||||
default int maxEatHP() {
|
||||
return 20;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "comboEat",
|
||||
name = "Combo eat",
|
||||
description = "Combo karambwan with pot and/or other food.",
|
||||
section = "eatConfig",
|
||||
position = 6
|
||||
)
|
||||
default boolean comboEat() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "eatWarnings",
|
||||
name = "Warnings",
|
||||
description = "Enable warning messages in chat if you don't have any food.",
|
||||
section = "eatConfig",
|
||||
hidden = true,
|
||||
unhide = "enableEating",
|
||||
position = 7
|
||||
)
|
||||
default boolean eatWarnings() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ConfigSection(
|
||||
keyName = "potsConfig",
|
||||
name = "Potions Configuration",
|
||||
description = "Configure when to pot",
|
||||
position = 10
|
||||
)
|
||||
String potsConfig = "potsConfig";
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "drinkAntiPoison",
|
||||
name = "Drink anti-poison",
|
||||
description = "Drink an anti-poison potion when poisoned.",
|
||||
section = "potsConfig",
|
||||
position = 11
|
||||
)
|
||||
default boolean drinkAntiPoison() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "antiPoisonWarnings",
|
||||
name = "Warnings",
|
||||
description = "Enable warning messages in chat if you don't have any anti-poison.",
|
||||
section = "potsConfig",
|
||||
hidden = true,
|
||||
unhide = "drinkAntiPoison",
|
||||
position = 12
|
||||
)
|
||||
default boolean antiPoisonWarnings() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "drinkAntiFire",
|
||||
name = "Drink anti-fire",
|
||||
description = "Drink an anti-fire potion when not under its effect or its effect is running out.",
|
||||
section = "potsConfig",
|
||||
position = 13
|
||||
)
|
||||
default boolean drinkAntiFire() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "antiFireWarnings",
|
||||
name = "Warnings",
|
||||
description = "Enable warning messages in chat if you don't have any anti-fire potions.",
|
||||
section = "potsConfig",
|
||||
hidden = true,
|
||||
unhide = "drinkAntiFire",
|
||||
position = 14
|
||||
)
|
||||
default boolean antiFireWarnings() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "drinkPrayer",
|
||||
name = "Drink prayer potions",
|
||||
description = "Drink a prayer potion when prayer points fall below a threshold.",
|
||||
section = "potsConfig",
|
||||
position = 15
|
||||
)
|
||||
default boolean drinkPrayer() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "minPrayerPoints",
|
||||
name = "Minimum prayer points",
|
||||
description = "Minimum prayer points to drink at.",
|
||||
section = "potsConfig",
|
||||
hidden = true,
|
||||
unhide = "drinkPrayer",
|
||||
position = 16
|
||||
)
|
||||
default int minPrayerPoints() {
|
||||
return 10;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "maxPrayerPoints",
|
||||
name = "Maximum prayer points",
|
||||
description = "Highest prayer points to potentially drink at",
|
||||
section = "potsConfig",
|
||||
hidden = true,
|
||||
unhide = "drinkPrayer",
|
||||
position = 17
|
||||
)
|
||||
default int maxPrayerPoints() {
|
||||
return 20;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "prayerWarnings",
|
||||
name = "Warnings",
|
||||
description = "Enable warning messages in chat if you don't have any prayer potions.",
|
||||
section = "potsConfig",
|
||||
hidden = true,
|
||||
unhide = "drinkPrayer",
|
||||
position = 18
|
||||
)
|
||||
default boolean prayerWarnings() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "drinkStrength",
|
||||
name = "Drink strength pots",
|
||||
description = "Enable to drink pots to boost strength.",
|
||||
section = "potsConfig",
|
||||
position = 19
|
||||
)
|
||||
default boolean drinkStrength() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "strengthLevel",
|
||||
name = "Strength level",
|
||||
description = "Drink strength boosting pot below this level.",
|
||||
section = "potsConfig",
|
||||
position = 20,
|
||||
hidden = true,
|
||||
unhide = "drinkStrength"
|
||||
)
|
||||
default int strengthLevel() {
|
||||
return 100;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "strengthWarnings",
|
||||
name = "Warnings",
|
||||
description = "Enable warning messages in chat if you don't have any strength potions.",
|
||||
section = "potsConfig",
|
||||
hidden = true,
|
||||
unhide = "drinkStrength",
|
||||
position = 21
|
||||
)
|
||||
default boolean strengthWarnings() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "drinkAttack",
|
||||
name = "Drink attack pots",
|
||||
description = "Enable to drink pots to boost attack.",
|
||||
section = "potsConfig",
|
||||
position = 22
|
||||
)
|
||||
default boolean drinkAttack() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "attackLevel",
|
||||
name = "Attack level",
|
||||
description = "Drink attack boosting pot below this level.",
|
||||
section = "potsConfig",
|
||||
position = 23,
|
||||
hidden = true,
|
||||
unhide = "drinkAttack"
|
||||
)
|
||||
default int attackLevel() {
|
||||
return 100;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "attackWarnings",
|
||||
name = "Warnings",
|
||||
description = "Enable warning messages in chat if you don't have any attack potions.",
|
||||
section = "potsConfig",
|
||||
hidden = true,
|
||||
unhide = "drinkAttack",
|
||||
position = 24
|
||||
)
|
||||
default boolean attackWarnings() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "drinkDefence",
|
||||
name = "Drink defence pots",
|
||||
description = "Enable to drink pots to boost defence.",
|
||||
section = "potsConfig",
|
||||
position = 25
|
||||
)
|
||||
default boolean drinkDefence() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "defenceLevel",
|
||||
name = "Defence level",
|
||||
description = "Drink defence boosting pot below this level.",
|
||||
section = "potsConfig",
|
||||
position = 26,
|
||||
hidden = true,
|
||||
unhide = "drinkDefence"
|
||||
)
|
||||
default int defenceLevel() {
|
||||
return 100;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "defenceWarnings",
|
||||
name = "Warnings",
|
||||
description = "Enable warning messages in chat if you don't have any defence potions.",
|
||||
section = "potsConfig",
|
||||
hidden = true,
|
||||
unhide = "drinkDefence",
|
||||
position = 27
|
||||
)
|
||||
default boolean defenceWarnings() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "drinkRanged",
|
||||
name = "Drink ranged pots",
|
||||
description = "Enable to drink pots to boost ranged.",
|
||||
section = "potsConfig",
|
||||
position = 28
|
||||
)
|
||||
default boolean drinkRanged() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "rangedLevel",
|
||||
name = "Ranged level",
|
||||
description = "Drink ranged boosting pot below this level.",
|
||||
section = "potsConfig",
|
||||
position = 29,
|
||||
hidden = true,
|
||||
unhide = "drinkRanged"
|
||||
)
|
||||
default int rangedLevel() {
|
||||
return 100;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "rangedWarnings",
|
||||
name = "Warnings",
|
||||
description = "Enable warning messages in chat if you don't have any ranged potions.",
|
||||
section = "potsConfig",
|
||||
hidden = true,
|
||||
unhide = "drinkRanged",
|
||||
position = 30
|
||||
)
|
||||
default boolean rangedWarnings() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "drinkMagic",
|
||||
name = "Drink magic pots",
|
||||
description = "Enable to drink pots to boost magic.",
|
||||
section = "potsConfig",
|
||||
position = 31
|
||||
)
|
||||
default boolean drinkMagic() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "magicLevel",
|
||||
name = "Magic level",
|
||||
description = "Drink magic boosting pot below this level.",
|
||||
section = "potsConfig",
|
||||
position = 32,
|
||||
hidden = true,
|
||||
unhide = "drinkMagic"
|
||||
)
|
||||
default int magicLevel() {
|
||||
return 100;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "magicWarnings",
|
||||
name = "Warnings",
|
||||
description = "Enable warning messages in chat if you don't have any magic potions.",
|
||||
section = "potsConfig",
|
||||
hidden = true,
|
||||
unhide = "drinkMagic",
|
||||
position = 33
|
||||
)
|
||||
default boolean magicWarnings() {
|
||||
return true;
|
||||
}
|
||||
}
|
386
consume/src/main/java/io/reisub/openosrs/consume/Consume.java
Normal file
386
consume/src/main/java/io/reisub/openosrs/consume/Consume.java
Normal file
@ -0,0 +1,386 @@
|
||||
package io.reisub.openosrs.consume;
|
||||
|
||||
import com.google.inject.Provides;
|
||||
import io.reisub.openosrs.util.Calculations;
|
||||
import io.reisub.openosrs.util.Util;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.ItemID;
|
||||
import net.runelite.api.Skill;
|
||||
import net.runelite.api.VarPlayer;
|
||||
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.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDependency;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.plugins.iutils.game.Game;
|
||||
import net.runelite.client.plugins.iutils.game.InventoryItem;
|
||||
import net.runelite.client.plugins.iutils.iUtils;
|
||||
import org.pf4j.Extension;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.Set;
|
||||
|
||||
@Extension
|
||||
@PluginDependency(Util.class)
|
||||
@PluginDependency(iUtils.class)
|
||||
@PluginDescriptor(
|
||||
name = "Chaos Consume",
|
||||
description = "Eats, drinks, activates items/specials",
|
||||
enabledByDefault = false
|
||||
)
|
||||
@Slf4j
|
||||
public class Consume extends Plugin {
|
||||
@Inject
|
||||
@SuppressWarnings("unused")
|
||||
private Game game;
|
||||
|
||||
@Inject
|
||||
@SuppressWarnings("unused")
|
||||
private Config config;
|
||||
|
||||
@Inject
|
||||
@SuppressWarnings("unused")
|
||||
private Calculations calc;
|
||||
|
||||
private final Set<Integer> IGNORE_FOOD = Set.of(ItemID.DWARVEN_ROCK_CAKE, ItemID.DWARVEN_ROCK_CAKE_7510);
|
||||
private final Set<Integer> DRINK_SET = Set.of(ItemID.JUG_OF_WINE, ItemID.SARADOMIN_BREW1, ItemID.SARADOMIN_BREW2, ItemID.SARADOMIN_BREW3, ItemID.SARADOMIN_BREW4, ItemID.XERICS_AID_1, ItemID.XERICS_AID_2, ItemID.XERICS_AID_3, ItemID.XERICS_AID_4, ItemID.XERICS_AID_1_20977, ItemID.XERICS_AID_2_20978, ItemID.XERICS_AID_3_20979, ItemID.XERICS_AID_4_20980, ItemID.XERICS_AID_1_20981, ItemID.XERICS_AID_2_20982, ItemID.XERICS_AID_3_20983, ItemID.XERICS_AID_4_20984, ItemID.BANDAGES);
|
||||
private final Set<Integer> ANTI_POISON_IDS = Set.of(ItemID.ANTIPOISON1, ItemID.ANTIPOISON2, ItemID.ANTIPOISON3, ItemID.ANTIPOISON4, ItemID.SUPERANTIPOISON1, ItemID.SUPERANTIPOISON2, ItemID.SUPERANTIPOISON3, ItemID.SUPERANTIPOISON4,
|
||||
ItemID.ANTIDOTE1, ItemID.ANTIDOTE2, ItemID.ANTIDOTE3, ItemID.ANTIDOTE4, ItemID.ANTIDOTE1_5958, ItemID.ANTIDOTE2_5956, ItemID.ANTIDOTE3_5954, ItemID.ANTIDOTE4_5952,
|
||||
ItemID.ANTIVENOM1, ItemID.ANTIVENOM2, ItemID.ANTIVENOM3, ItemID.ANTIVENOM4, ItemID.ANTIVENOM4_12913, ItemID.ANTIVENOM3_12915, ItemID.ANTIVENOM2_12917, ItemID.ANTIVENOM1_12919);
|
||||
private final Set<Integer> ANTI_FIRE_IDS = Set.of(ItemID.ANTIFIRE_POTION1, ItemID.ANTIFIRE_POTION2, ItemID.ANTIFIRE_POTION3, ItemID.ANTIFIRE_POTION4, ItemID.SUPER_ANTIFIRE_POTION1, ItemID.SUPER_ANTIFIRE_POTION2, ItemID.SUPER_ANTIFIRE_POTION3, ItemID.SUPER_ANTIFIRE_POTION4,
|
||||
ItemID.EXTENDED_ANTIFIRE1, ItemID.EXTENDED_ANTIFIRE2, ItemID.EXTENDED_ANTIFIRE3, ItemID.EXTENDED_ANTIFIRE4, ItemID.EXTENDED_SUPER_ANTIFIRE1, ItemID.EXTENDED_SUPER_ANTIFIRE2, ItemID.EXTENDED_SUPER_ANTIFIRE3, ItemID.EXTENDED_SUPER_ANTIFIRE4);
|
||||
private final Set<Integer> PRAYER_IDS = Set.of(ItemID.PRAYER_POTION1, ItemID.PRAYER_POTION2, ItemID.PRAYER_POTION3, ItemID.PRAYER_POTION4,
|
||||
ItemID.SUPER_RESTORE1, ItemID.SUPER_RESTORE2, ItemID.SUPER_RESTORE3, ItemID.SUPER_RESTORE4, ItemID.BLIGHTED_SUPER_RESTORE1,
|
||||
ItemID.BLIGHTED_SUPER_RESTORE2, ItemID.BLIGHTED_SUPER_RESTORE3, ItemID.BLIGHTED_SUPER_RESTORE4, ItemID.EGNIOL_POTION_1,
|
||||
ItemID.EGNIOL_POTION_2, ItemID.EGNIOL_POTION_3, ItemID.EGNIOL_POTION_4);
|
||||
private final Set<Integer> STRENGTH_IDS = Set.of(ItemID.STRENGTH_POTION1, ItemID.STRENGTH_POTION2, ItemID.STRENGTH_POTION3, ItemID.STRENGTH_POTION4,
|
||||
ItemID.SUPER_STRENGTH1, ItemID.SUPER_STRENGTH2, ItemID.SUPER_STRENGTH3, ItemID.SUPER_STRENGTH4,
|
||||
ItemID.DIVINE_SUPER_STRENGTH_POTION1, ItemID.DIVINE_SUPER_STRENGTH_POTION2, ItemID.DIVINE_SUPER_STRENGTH_POTION3, ItemID.DIVINE_SUPER_STRENGTH_POTION4,
|
||||
ItemID.DIVINE_SUPER_COMBAT_POTION1, ItemID.DIVINE_SUPER_COMBAT_POTION2, ItemID.DIVINE_SUPER_COMBAT_POTION3, ItemID.DIVINE_SUPER_COMBAT_POTION4,
|
||||
ItemID.COMBAT_POTION1, ItemID.COMBAT_POTION2, ItemID.COMBAT_POTION3, ItemID.COMBAT_POTION4,
|
||||
ItemID.SUPER_COMBAT_POTION1, ItemID.SUPER_COMBAT_POTION2, ItemID.SUPER_COMBAT_POTION3, ItemID.SUPER_COMBAT_POTION4);
|
||||
private final Set<Integer> ATTACK_IDS = Set.of(ItemID.ATTACK_POTION1, ItemID.ATTACK_POTION2, ItemID.ATTACK_POTION3, ItemID.ATTACK_POTION4,
|
||||
ItemID.SUPER_ATTACK1, ItemID.SUPER_ATTACK2, ItemID.SUPER_ATTACK3, ItemID.SUPER_ATTACK4,
|
||||
ItemID.DIVINE_SUPER_ATTACK_POTION1, ItemID.DIVINE_SUPER_ATTACK_POTION2, ItemID.DIVINE_SUPER_ATTACK_POTION3, ItemID.DIVINE_SUPER_ATTACK_POTION4,
|
||||
ItemID.DIVINE_SUPER_COMBAT_POTION1, ItemID.DIVINE_SUPER_COMBAT_POTION2, ItemID.DIVINE_SUPER_COMBAT_POTION3, ItemID.DIVINE_SUPER_COMBAT_POTION4,
|
||||
ItemID.COMBAT_POTION1, ItemID.COMBAT_POTION2, ItemID.COMBAT_POTION3, ItemID.COMBAT_POTION4,
|
||||
ItemID.SUPER_COMBAT_POTION1, ItemID.SUPER_COMBAT_POTION2, ItemID.SUPER_COMBAT_POTION3, ItemID.SUPER_COMBAT_POTION4);
|
||||
private final Set<Integer> DEFENCE_IDS = Set.of(ItemID.DEFENCE_POTION1, ItemID.DEFENCE_POTION2, ItemID.DEFENCE_POTION3, ItemID.DEFENCE_POTION4,
|
||||
ItemID.SUPER_DEFENCE1, ItemID.SUPER_DEFENCE2, ItemID.SUPER_DEFENCE3, ItemID.SUPER_DEFENCE4,
|
||||
ItemID.DIVINE_SUPER_DEFENCE_POTION1, ItemID.DIVINE_SUPER_DEFENCE_POTION2, ItemID.DIVINE_SUPER_DEFENCE_POTION3, ItemID.DIVINE_SUPER_DEFENCE_POTION4,
|
||||
ItemID.DIVINE_SUPER_COMBAT_POTION1, ItemID.DIVINE_SUPER_COMBAT_POTION2, ItemID.DIVINE_SUPER_COMBAT_POTION3, ItemID.DIVINE_SUPER_COMBAT_POTION4,
|
||||
ItemID.SUPER_COMBAT_POTION1, ItemID.SUPER_COMBAT_POTION2, ItemID.SUPER_COMBAT_POTION3, ItemID.SUPER_COMBAT_POTION4);
|
||||
private final Set<Integer> RANGED_IDS = Set.of(ItemID.RANGING_POTION1, ItemID.RANGING_POTION2, ItemID.RANGING_POTION3, ItemID.RANGING_POTION4,
|
||||
ItemID.BASTION_POTION1, ItemID.BASTION_POTION2, ItemID.BASTION_POTION3, ItemID.BASTION_POTION4,
|
||||
ItemID.DIVINE_RANGING_POTION1, ItemID.DIVINE_RANGING_POTION2, ItemID.DIVINE_RANGING_POTION3, ItemID.DIVINE_RANGING_POTION4,
|
||||
ItemID.DIVINE_BASTION_POTION1, ItemID.DIVINE_BASTION_POTION2, ItemID.DIVINE_BASTION_POTION3, ItemID.DIVINE_BASTION_POTION4,
|
||||
ItemID.SUPER_RANGING_1, ItemID.SUPER_RANGING_2, ItemID.SUPER_RANGING_3, ItemID.SUPER_RANGING_4);
|
||||
private final Set<Integer> MAGIC_IDS = Set.of(ItemID.MAGIC_POTION1, ItemID.MAGIC_POTION2, ItemID.MAGIC_POTION3, ItemID.MAGIC_POTION4,
|
||||
ItemID.BATTLEMAGE_POTION1, ItemID.BATTLEMAGE_POTION2, ItemID.BATTLEMAGE_POTION3, ItemID.BATTLEMAGE_POTION4,
|
||||
ItemID.DIVINE_MAGIC_POTION1, ItemID.DIVINE_MAGIC_POTION2, ItemID.DIVINE_MAGIC_POTION3, ItemID.DIVINE_MAGIC_POTION4,
|
||||
ItemID.DIVINE_BATTLEMAGE_POTION1, ItemID.DIVINE_BATTLEMAGE_POTION2, ItemID.DIVINE_BATTLEMAGE_POTION3, ItemID.DIVINE_BATTLEMAGE_POTION4);
|
||||
|
||||
private long lastAte;
|
||||
private long lastPot;
|
||||
private int timeout;
|
||||
private int eatThreshold;
|
||||
private int prayerThreshold;
|
||||
private boolean shouldDrinkAntiPoison;
|
||||
private long lastAntiPoison;
|
||||
private boolean shouldDrinkAntiFire;
|
||||
private long lastAntiFire;
|
||||
private boolean shouldDrinkPrayer;
|
||||
private long lastPrayer;
|
||||
private boolean shouldDrinkStrength;
|
||||
private long lastStrength;
|
||||
private boolean shouldDrinkAttack;
|
||||
private long lastAttack;
|
||||
private boolean shouldDrinkDefence;
|
||||
private long lastDefence;
|
||||
private boolean shouldDrinkRanged;
|
||||
private long lastRanged;
|
||||
private boolean shouldDrinkMagic;
|
||||
private long lastMagic;
|
||||
|
||||
@Provides
|
||||
@SuppressWarnings("unused")
|
||||
Config provideConfig(ConfigManager configManager) {
|
||||
return configManager.getConfig(Config.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void startUp() {
|
||||
log.info("Starting Chaos Consume");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void shutDown() {
|
||||
log.info("Stopping Chaos Consume");
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@SuppressWarnings("unused")
|
||||
private void onGameTick(GameTick event) {
|
||||
if (game.client() == null || game.localPlayer() == null || game.client().getGameState() != GameState.LOGGED_IN) return;
|
||||
|
||||
if (timeout > 0) {
|
||||
timeout--;
|
||||
return;
|
||||
}
|
||||
|
||||
if (eatThreshold == 0) generateNewEatThreshold();
|
||||
if (prayerThreshold == 0) generateNewPrayerThreshold();
|
||||
|
||||
int hp = game.modifiedLevel(Skill.HITPOINTS);
|
||||
|
||||
if (config.enableEating() && hp <= eatThreshold && canEat()) {
|
||||
boolean[] ate = new boolean[1];
|
||||
|
||||
game.inventory().withAction("Eat").withoutId(IGNORE_FOOD).findFirst().ifPresent((food) -> {
|
||||
food.interact(0);
|
||||
lastAte = game.ticks();
|
||||
ate[0] = true;
|
||||
});
|
||||
|
||||
if (!ate[0]) {
|
||||
game.inventory().withId(DRINK_SET).findFirst().ifPresent((drink) -> {
|
||||
drink.interact(0);
|
||||
lastAte = game.ticks();
|
||||
ate[0] = true;
|
||||
});
|
||||
}
|
||||
|
||||
if (!ate[0] && config.eatWarnings()) {
|
||||
game.utils.sendGameMessage("HP below threshold but you don't have any food!");
|
||||
} else {
|
||||
generateNewEatThreshold();
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldDrinkAntiPoison && canPot()) {
|
||||
if (!drinkPotion(ANTI_POISON_IDS) && config.antiPoisonWarnings()) {
|
||||
game.utils.sendGameMessage("Poisoned but you don't have anti-poison!");
|
||||
}
|
||||
|
||||
shouldDrinkAntiPoison = false;
|
||||
lastAntiPoison = game.ticks();
|
||||
}
|
||||
|
||||
if (shouldDrinkAntiFire && canPot()) {
|
||||
if (!drinkPotion(ANTI_FIRE_IDS) && config.antiFireWarnings()) {
|
||||
game.utils.sendGameMessage("Sustaining dragon fire damage but you don't have an anti-dragon fire potion!");
|
||||
}
|
||||
|
||||
shouldDrinkAntiFire = false;
|
||||
lastAntiFire = game.ticks();
|
||||
}
|
||||
|
||||
if (shouldDrinkPrayer && canPot()) {
|
||||
if (!drinkPotion(PRAYER_IDS) && config.prayerWarnings()) {
|
||||
game.utils.sendGameMessage("Prayer points below threshold but you don't have any prayer potions!");
|
||||
}
|
||||
|
||||
shouldDrinkPrayer = false;
|
||||
lastPrayer = game.ticks();
|
||||
}
|
||||
|
||||
if (shouldDrinkStrength && canPot()) {
|
||||
if (!drinkPotion(STRENGTH_IDS) && config.strengthWarnings()) {
|
||||
game.utils.sendGameMessage("Strength below threshold but you don't have any strength potions!");
|
||||
}
|
||||
|
||||
shouldDrinkStrength = false;
|
||||
lastStrength = game.ticks();
|
||||
}
|
||||
|
||||
if (shouldDrinkAttack && canPot()) {
|
||||
if (!drinkPotion(ATTACK_IDS) && config.attackWarnings()) {
|
||||
game.utils.sendGameMessage("Attack below threshold but you don't have any attack potions!");
|
||||
}
|
||||
|
||||
shouldDrinkAttack = false;
|
||||
lastAttack = game.ticks();
|
||||
}
|
||||
|
||||
if (shouldDrinkDefence && canPot()) {
|
||||
if (!drinkPotion(DEFENCE_IDS) && config.defenceWarnings()) {
|
||||
game.utils.sendGameMessage("Defence below threshold but you don't have any defence potions!");
|
||||
}
|
||||
|
||||
shouldDrinkDefence = false;
|
||||
lastDefence = game.ticks();
|
||||
}
|
||||
|
||||
if (shouldDrinkRanged && canPot()) {
|
||||
if (!drinkPotion(RANGED_IDS) && config.rangedWarnings()) {
|
||||
game.utils.sendGameMessage("Ranged below threshold but you don't have any ranged potions!");
|
||||
}
|
||||
|
||||
shouldDrinkRanged = false;
|
||||
lastRanged = game.ticks();
|
||||
}
|
||||
|
||||
if (shouldDrinkMagic && canPot()) {
|
||||
if (!drinkPotion(MAGIC_IDS) && config.magicWarnings()) {
|
||||
game.utils.sendGameMessage("Magic below threshold but you don't have any magic potions!");
|
||||
}
|
||||
|
||||
shouldDrinkMagic = false;
|
||||
lastMagic = game.ticks();
|
||||
}
|
||||
|
||||
if (config.enableEating() && hp < eatThreshold && config.comboEat()) {
|
||||
game.inventory().withId(ItemID.COOKED_KARAMBWAN, ItemID.COOKED_KARAMBWAN_3147, ItemID.COOKED_KARAMBWAN_23533).findFirst().ifPresent((food) -> {
|
||||
food.interact(0);
|
||||
lastAte = game.ticks();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@SuppressWarnings("unused")
|
||||
private void onVarbitChanged(VarbitChanged event) {
|
||||
if (game.client().getGameState() != GameState.LOGGED_IN) return;
|
||||
|
||||
if (config.drinkAntiPoison()
|
||||
&& event.getIndex() == VarPlayer.POISON.getId()
|
||||
&& game.client().getVarpValue(VarPlayer.POISON.getId()) > 0) {
|
||||
shouldDrinkAntiPoison = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@SuppressWarnings("unused")
|
||||
private void onChatMessage(ChatMessage event) {
|
||||
if (game.client().getGameState() != GameState.LOGGED_IN) return;
|
||||
|
||||
String BURN_MESSAGE = ("You're horribly burnt by the dragon fire!");
|
||||
String BURN_EXPIRE = ("antifire potion is about to expire.");
|
||||
|
||||
String message = event.getMessage();
|
||||
|
||||
if (config.drinkAntiFire() && (message.contains(BURN_MESSAGE) || message.contains(BURN_EXPIRE))) {
|
||||
shouldDrinkAntiFire = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@SuppressWarnings("unused")
|
||||
private void onStatChanged(StatChanged event) {
|
||||
if (game.client().getGameState() != GameState.LOGGED_IN || timeout > 0) return;
|
||||
|
||||
Skill skill = event.getSkill();
|
||||
int level = event.getBoostedLevel();
|
||||
|
||||
checkSkill(skill, level);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@SuppressWarnings("unused")
|
||||
private void onGameStateChanged(GameStateChanged event) {
|
||||
if (event.getGameState() == GameState.LOGGED_IN) {
|
||||
timeout = 5;
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@SuppressWarnings("unused")
|
||||
private void onConfigChanged(ConfigChanged event) {
|
||||
switch (event.getKey()) {
|
||||
case "minEatHP":
|
||||
case "maxEatHP":
|
||||
generateNewEatThreshold();
|
||||
break;
|
||||
case "minPrayerPoints":
|
||||
case "maxPrayerPoints":
|
||||
generateNewPrayerThreshold();
|
||||
case "drinkPrayer":
|
||||
checkSkill(Skill.PRAYER);
|
||||
break;
|
||||
case "strengthLevel":
|
||||
checkSkill(Skill.STRENGTH);
|
||||
break;
|
||||
case "attackLevel":
|
||||
checkSkill(Skill.ATTACK);
|
||||
break;
|
||||
case "defenceLevel":
|
||||
checkSkill(Skill.DEFENCE);
|
||||
break;
|
||||
case "rangedLevel":
|
||||
checkSkill(Skill.RANGED);
|
||||
break;
|
||||
case "magicLevel":
|
||||
checkSkill(Skill.MAGIC);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void generateNewEatThreshold() {
|
||||
eatThreshold = calc.random(config.minEatHP(), config.maxEatHP() + 1);
|
||||
}
|
||||
|
||||
private void generateNewPrayerThreshold() {
|
||||
prayerThreshold = calc.random(config.minPrayerPoints(), config.maxPrayerPoints() + 1);
|
||||
}
|
||||
|
||||
private boolean canPot() {
|
||||
return game.ticks() > lastPot + 3;
|
||||
}
|
||||
|
||||
private boolean canEat() {
|
||||
return game.ticks() > lastAte + 3;
|
||||
}
|
||||
|
||||
private void checkSkill(Skill skill) {
|
||||
checkSkill(skill, game.modifiedLevel(skill));
|
||||
}
|
||||
|
||||
private void checkSkill(Skill skill, int level) {
|
||||
if (game.client().getGameState() != GameState.LOGGED_IN) return;
|
||||
|
||||
switch (skill) {
|
||||
case PRAYER:
|
||||
if (config.drinkPrayer() && level <= prayerThreshold && game.ticks() > lastPrayer + 5) {
|
||||
shouldDrinkPrayer = true;
|
||||
}
|
||||
break;
|
||||
case STRENGTH:
|
||||
if (config.drinkStrength() && level <= config.strengthLevel() && game.ticks() > lastStrength + 5) {
|
||||
shouldDrinkStrength = true;
|
||||
}
|
||||
break;
|
||||
case ATTACK:
|
||||
if (config.drinkAttack() && level <= config.attackLevel() && game.ticks() > lastAttack + 5) {
|
||||
shouldDrinkAttack = true;
|
||||
}
|
||||
break;
|
||||
case DEFENCE:
|
||||
if (config.drinkDefence() && level <= config.defenceLevel() && game.ticks() > lastDefence + 5) {
|
||||
shouldDrinkDefence = true;
|
||||
}
|
||||
break;
|
||||
case RANGED:
|
||||
if (config.drinkRanged() && level <= config.rangedLevel() && game.ticks() > lastRanged + 5) {
|
||||
shouldDrinkRanged = true;
|
||||
}
|
||||
break;
|
||||
case MAGIC:
|
||||
if (config.drinkMagic() && level <= config.magicLevel() && game.ticks() > lastMagic + 5) {
|
||||
shouldDrinkMagic = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean drinkPotion(Set<Integer> ids) {
|
||||
InventoryItem potion = game.inventory().withId(ids).first();
|
||||
if (potion == null) return false;
|
||||
|
||||
potion.interact(0);
|
||||
lastPot = game.ticks();
|
||||
return true;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user