@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, https://runelitepl.us
|
||||
* 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 net.runelite.client.plugins.autoprayerswitch;
|
||||
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
|
||||
public enum Prayer
|
||||
{
|
||||
PROTECT_FROM_MELEE(net.runelite.api.Prayer.PROTECT_FROM_MELEE, "Protect from Melee", WidgetInfo.PRAYER_PROTECT_FROM_MELEE.getId()), PROTECT_FROM_MAGIC(net.runelite.api.Prayer.PROTECT_FROM_MAGIC, "Protect from Magic", WidgetInfo.PRAYER_PROTECT_FROM_MAGIC.getId()), PROTECT_FROM_MISSILES(net.runelite.api.Prayer.PROTECT_FROM_MISSILES, "Protect from Missiles", WidgetInfo.PRAYER_PROTECT_FROM_MISSILES.getId());
|
||||
|
||||
private final net.runelite.api.Prayer prayer;
|
||||
private final String name;
|
||||
private final int widgetId;
|
||||
|
||||
private Prayer(net.runelite.api.Prayer prayer, String name, int widgetId)
|
||||
{
|
||||
this.prayer = prayer;this.name = name;this.widgetId = widgetId;
|
||||
}
|
||||
|
||||
public net.runelite.api.Prayer getPrayer()
|
||||
{
|
||||
return this.prayer;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public int getWidgetId()
|
||||
{
|
||||
return this.widgetId;
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, https://runelitepl.us
|
||||
* 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 net.runelite.client.plugins.autoprayerswitch;
|
||||
|
||||
import net.runelite.client.config.Config;
|
||||
import net.runelite.client.config.ConfigGroup;
|
||||
|
||||
@ConfigGroup("switch")
|
||||
public abstract interface SwitchConfig
|
||||
extends Config
|
||||
{}
|
||||
@@ -1,151 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, https://runelitepl.us
|
||||
* 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 net.runelite.client.plugins.autoprayerswitch;
|
||||
|
||||
import net.runelite.client.plugins.PluginType;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import net.runelite.api.MenuAction;
|
||||
import net.runelite.api.Actor;
|
||||
import net.runelite.api.events.InteractingChanged;
|
||||
import net.runelite.api.kit.KitType;
|
||||
import net.runelite.api.events.GameTick;
|
||||
import net.runelite.client.eventbus.Subscribe;
|
||||
import net.runelite.api.events.PlayerDespawned;
|
||||
import com.google.inject.Provides;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.api.Player;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.Client;
|
||||
import org.slf4j.Logger;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
|
||||
@PluginDescriptor(
|
||||
name="Switch Plugin",
|
||||
description="Automatically switches prayers based on opponents equipment",
|
||||
tags={"loudpacks", "prayer", "switches", "auto"},
|
||||
type = PluginType.PVP
|
||||
)
|
||||
public class SwitchPlugin
|
||||
extends Plugin
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(SwitchPlugin.class);
|
||||
@Inject
|
||||
private Client client;
|
||||
@Inject
|
||||
private SwitchConfig config;
|
||||
private Player opponent;
|
||||
private Prayer prayer;
|
||||
|
||||
@Provides
|
||||
SwitchConfig provideConfig(ConfigManager configManager)
|
||||
{
|
||||
return (SwitchConfig)configManager.getConfig(SwitchConfig.class);
|
||||
}
|
||||
|
||||
protected void startUp() {}
|
||||
|
||||
protected void shutDown()
|
||||
{
|
||||
if (this.prayer != null) {
|
||||
deactivatePrayer(this.prayer);
|
||||
}
|
||||
this.opponent = null;
|
||||
this.prayer = null;
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onPlayerDespawned(PlayerDespawned event)
|
||||
{
|
||||
if (this.opponent == null) {
|
||||
return;
|
||||
}
|
||||
Player player = event.getPlayer();
|
||||
if (player.equals(this.opponent))
|
||||
{
|
||||
this.opponent = null;
|
||||
if (this.prayer != null) {
|
||||
deactivatePrayer(this.prayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onGameTick(GameTick event)
|
||||
{
|
||||
if (this.opponent == null) {
|
||||
return;
|
||||
}
|
||||
int weapon = this.opponent.getPlayerComposition().getEquipmentId(KitType.WEAPON);
|
||||
Prayer counterPrayer = WeaponMap.getMappingForID(weapon);
|
||||
if (counterPrayer != null) {
|
||||
activatePrayer(counterPrayer);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onInteractingChanged(InteractingChanged event)
|
||||
{
|
||||
boolean inPvp = false;
|
||||
for (String option : this.client.getPlayerOptions()) {
|
||||
if ((option != null) && ((option.equals("Attack")) || (option.equals("Fight")))) {
|
||||
inPvp = true;
|
||||
}
|
||||
}
|
||||
if (!inPvp) {
|
||||
return;
|
||||
}
|
||||
Actor source = event.getSource();
|
||||
if (!(source instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
Actor target = event.getTarget();
|
||||
if (!(target instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
if (target != this.client.getLocalPlayer()) {
|
||||
return;
|
||||
}
|
||||
this.opponent = ((Player)source);
|
||||
}
|
||||
|
||||
private void activatePrayer(Prayer prayer)
|
||||
{
|
||||
if (!this.client.isPrayerActive(prayer.getPrayer()))
|
||||
{
|
||||
// client.invokeMenuAction(-1, prayer.getWidgetId(), MenuAction.WIDGET_DEFAULT.getId(), 1, "Activate", "<col=ff9040>" + prayer.getName() + "</col>", 50, 50);
|
||||
this.prayer = prayer;
|
||||
}
|
||||
}
|
||||
|
||||
private void deactivatePrayer(Prayer prayer)
|
||||
{
|
||||
if (this.client.isPrayerActive(prayer.getPrayer()))
|
||||
{
|
||||
//client.invokeMenuAction(-1, prayer.getWidgetId(), MenuAction.WIDGET_DEFAULT.getId(), 1, "Deactivate", "<col=ff9040>" + prayer.getName() + "</col>", 50, 50);
|
||||
this.prayer = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,135 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, https://runelitepl.us
|
||||
* 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 net.runelite.client.plugins.autoprayerswitch;
|
||||
|
||||
public enum WeaponMap
|
||||
{
|
||||
NONE(-1, Prayer.PROTECT_FROM_MELEE),
|
||||
DDS(5698, Prayer.PROTECT_FROM_MELEE),
|
||||
DDP(5680, Prayer.PROTECT_FROM_MELEE),
|
||||
DD(1215, Prayer.PROTECT_FROM_MELEE),
|
||||
DDPP(1231, Prayer.PROTECT_FROM_MELEE),
|
||||
WHIP(4151, Prayer.PROTECT_FROM_MELEE),
|
||||
D_SCIM(4587, Prayer.PROTECT_FROM_MELEE),
|
||||
TENTACLE(12006, Prayer.PROTECT_FROM_MELEE),
|
||||
AGS(11802, Prayer.PROTECT_FROM_MELEE),
|
||||
G_MAUL(4153, Prayer.PROTECT_FROM_MELEE),
|
||||
DWH(13576, Prayer.PROTECT_FROM_MELEE),
|
||||
D_CLAWS(13652, Prayer.PROTECT_FROM_MELEE),
|
||||
STAT_WH(22622, Prayer.PROTECT_FROM_MELEE),
|
||||
VEST_LS(22613, Prayer.PROTECT_FROM_MELEE),
|
||||
VEST_SPEAR(22610, Prayer.PROTECT_FROM_MELEE),
|
||||
BGS(11804, Prayer.PROTECT_FROM_MELEE),
|
||||
ZGS(11808, Prayer.PROTECT_FROM_MELEE),
|
||||
SGS(11806, Prayer.PROTECT_FROM_MELEE),
|
||||
RAPIER(22324, Prayer.PROTECT_FROM_MELEE),
|
||||
DMACE(1434, Prayer.PROTECT_FROM_MELEE),
|
||||
D2H(7158, Prayer.PROTECT_FROM_MELEE),
|
||||
DHAL(3204, Prayer.PROTECT_FROM_MELEE),
|
||||
DSPEAR(1249, Prayer.PROTECT_FROM_MELEE),
|
||||
DSPEARPP(5716, Prayer.PROTECT_FROM_MELEE),
|
||||
DSPEARP(1263, Prayer.PROTECT_FROM_MELEE),
|
||||
DSPEARPPP(5730, Prayer.PROTECT_FROM_MELEE),
|
||||
ELDER(21003, Prayer.PROTECT_FROM_MELEE),
|
||||
ELDER_2(21205, Prayer.PROTECT_FROM_MELEE),
|
||||
LEAF(20727, Prayer.PROTECT_FROM_MELEE),
|
||||
RUNE_CBOW(9185, Prayer.PROTECT_FROM_MISSILES),
|
||||
HEAVY_BAL(19481, Prayer.PROTECT_FROM_MISSILES),
|
||||
LIGHT_BAL(19478, Prayer.PROTECT_FROM_MISSILES),
|
||||
DRAG_CBOW(21902, Prayer.PROTECT_FROM_MISSILES),
|
||||
ACB(11785, Prayer.PROTECT_FROM_MISSILES),
|
||||
MOR_JAV(22636, Prayer.PROTECT_FROM_MISSILES),
|
||||
MOR_TA(22634, Prayer.PROTECT_FROM_MISSILES),
|
||||
DARK_BOW(11235, Prayer.PROTECT_FROM_MISSILES),
|
||||
DARK_BOW2(12765, Prayer.PROTECT_FROM_MISSILES),
|
||||
DARK_BOW3(12766, Prayer.PROTECT_FROM_MISSILES),
|
||||
DARK_BOW4(12767, Prayer.PROTECT_FROM_MISSILES),
|
||||
DARK_BOW5(12768, Prayer.PROTECT_FROM_MISSILES),
|
||||
BLOW_PIPE(12926, Prayer.PROTECT_FROM_MISSILES),
|
||||
MSB(861, Prayer.PROTECT_FROM_MISSILES),
|
||||
MSB2(20558, Prayer.PROTECT_FROM_MISSILES),
|
||||
MSB3(12788, Prayer.PROTECT_FROM_MISSILES),
|
||||
DK(22804, Prayer.PROTECT_FROM_MISSILES),
|
||||
DK2(22812, Prayer.PROTECT_FROM_MISSILES),
|
||||
DK3(22814, Prayer.PROTECT_FROM_MISSILES),
|
||||
DKP(22806, Prayer.PROTECT_FROM_MISSILES),
|
||||
DKP2(22808, Prayer.PROTECT_FROM_MISSILES),
|
||||
DKP3(22810, Prayer.PROTECT_FROM_MISSILES),
|
||||
RK(868, Prayer.PROTECT_FROM_MISSILES),
|
||||
RKP(876, Prayer.PROTECT_FROM_MISSILES),
|
||||
RKP2(5660, Prayer.PROTECT_FROM_MISSILES),
|
||||
RKP3(5667, Prayer.PROTECT_FROM_MISSILES),
|
||||
ANCIENT_STAFF(4675, Prayer.PROTECT_FROM_MAGIC),
|
||||
ZURIEL(22647, Prayer.PROTECT_FROM_MAGIC),
|
||||
MASTER_WAND(6914, Prayer.PROTECT_FROM_MAGIC),
|
||||
AHRIM(4710, Prayer.PROTECT_FROM_MAGIC),
|
||||
AHRIM_25(4865, Prayer.PROTECT_FROM_MAGIC),
|
||||
AHRIM_50(4864, Prayer.PROTECT_FROM_MAGIC),
|
||||
AHRIM_75(4863, Prayer.PROTECT_FROM_MAGIC),
|
||||
AHRIM_100(4862, Prayer.PROTECT_FROM_MAGIC),
|
||||
KODAI(21006, Prayer.PROTECT_FROM_MAGIC),
|
||||
TOXIC(12904, Prayer.PROTECT_FROM_MAGIC),
|
||||
STAFF_OF_DEAD(11791, Prayer.PROTECT_FROM_MAGIC),
|
||||
TOXIC_TRIDENT_U(12900, Prayer.PROTECT_FROM_MAGIC),
|
||||
TRIDENT_U(11908, Prayer.PROTECT_FROM_MAGIC),
|
||||
STAFF_LIGHT(22296, Prayer.PROTECT_FROM_MAGIC),
|
||||
WATER_BSTAFF(1395, Prayer.PROTECT_FROM_MAGIC),
|
||||
WATER_STAFF(1383, Prayer.PROTECT_FROM_MAGIC),
|
||||
WATER_MSTAFF(1403, Prayer.PROTECT_FROM_MAGIC),
|
||||
MUD(6562, Prayer.PROTECT_FROM_MAGIC),
|
||||
MUD2(6563, Prayer.PROTECT_FROM_MAGIC),
|
||||
MUD3(11998, Prayer.PROTECT_FROM_MAGIC),
|
||||
MUD4(12000, Prayer.PROTECT_FROM_MAGIC),
|
||||
MUD5(772, Prayer.PROTECT_FROM_MAGIC),
|
||||
MUD6(20736, Prayer.PROTECT_FROM_MAGIC),
|
||||
MUD7(20739, Prayer.PROTECT_FROM_MAGIC),
|
||||
MUD8(20736, Prayer.PROTECT_FROM_MAGIC),
|
||||
MUD9(20736, Prayer.PROTECT_FROM_MAGIC),
|
||||
MUD10(20736, Prayer.PROTECT_FROM_MAGIC),
|
||||
ZAM(2417, Prayer.PROTECT_FROM_MAGIC),
|
||||
GUTH(2416, Prayer.PROTECT_FROM_MAGIC),
|
||||
SARA(2415, Prayer.PROTECT_FROM_MAGIC),
|
||||
TOX(22292, Prayer.PROTECT_FROM_MAGIC),
|
||||
TOX2(12899, Prayer.PROTECT_FROM_MAGIC),
|
||||
TOX3(11907, Prayer.PROTECT_FROM_MAGIC),
|
||||
TOX4(22288, Prayer.PROTECT_FROM_MAGIC);
|
||||
|
||||
private final int id;
|
||||
private final Prayer prayer;
|
||||
|
||||
public static Prayer getMappingForID(final int id) {
|
||||
for (final WeaponMap map : values()) {
|
||||
if (map.id == id) {
|
||||
return map.prayer;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private WeaponMap(final int id, final Prayer prayer) {
|
||||
this.id = id;
|
||||
this.prayer = prayer;
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, https://runelitepl.us
|
||||
* 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 net.runelite.client.plugins.autospec;
|
||||
|
||||
import net.runelite.client.config.Config;
|
||||
import net.runelite.client.config.ConfigGroup;
|
||||
import net.runelite.client.config.ConfigItem;
|
||||
|
||||
@ConfigGroup("autospecs")
|
||||
public abstract interface SpecConfig
|
||||
extends Config
|
||||
{
|
||||
@ConfigItem(keyName="toggle", name="Continuous Toggle", description="Continuously enabled special attack when supported weapons are equipped.")
|
||||
default boolean continuousToggle()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, https://runelitepl.us
|
||||
* 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 net.runelite.client.plugins.autospec;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableMap.Builder;
|
||||
import com.google.inject.Provides;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.MenuAction;
|
||||
import net.runelite.api.Player;
|
||||
import net.runelite.api.PlayerComposition;
|
||||
import net.runelite.api.VarPlayer;
|
||||
import net.runelite.api.events.GameTick;
|
||||
import net.runelite.api.events.MenuOptionClicked;
|
||||
import net.runelite.api.kit.KitType;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.eventbus.Subscribe;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.plugins.PluginType;
|
||||
|
||||
|
||||
@PluginDescriptor(
|
||||
name="Auto Spec",
|
||||
description="Automatically enables special attack when supported weapons are equipped",
|
||||
tags={"special", "pvp", "attack"},
|
||||
type = PluginType.PVP,
|
||||
enabledByDefault=false
|
||||
)
|
||||
@Slf4j
|
||||
@Singleton
|
||||
public class SpecPlugin
|
||||
extends Plugin
|
||||
{
|
||||
private static final ImmutableMap WEAPONS = ImmutableMap.builder().put(4153, 50).put(5698, 25).put(13652, 50).put(11802, 50).put(11806, 50).put(11804, 50).put(10887, 50).put(11235, 55).build();
|
||||
@Inject
|
||||
private Client client;
|
||||
@Inject
|
||||
private SpecConfig config;
|
||||
|
||||
@Provides
|
||||
SpecConfig getConfig(ConfigManager configManager)
|
||||
{
|
||||
return (SpecConfig)configManager.getConfig(SpecConfig.class);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onGameTick(GameTick event)
|
||||
{
|
||||
if (this.client.getGameState() != GameState.LOGGED_IN) {
|
||||
return;
|
||||
}
|
||||
if (!this.config.continuousToggle()) {
|
||||
return;
|
||||
}
|
||||
PlayerComposition composition = this.client.getLocalPlayer().getPlayerComposition();
|
||||
Integer cost = (Integer)WEAPONS.get(Integer.valueOf(composition.getEquipmentId(KitType.WEAPON)));
|
||||
if ((cost != null) && (!specialEnabled()) && (this.client.getVar(VarPlayer.SPECIAL_ATTACK_PERCENT) >= cost.intValue() * 10)) {
|
||||
enableSpecial();
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onMenuOptionClicked(MenuOptionClicked event)
|
||||
{
|
||||
if (this.client.getGameState() != GameState.LOGGED_IN) {
|
||||
return;
|
||||
}
|
||||
boolean equipped = event.getMenuOption().equals("Wield");
|
||||
if (!equipped) {
|
||||
return;
|
||||
}
|
||||
Integer cost = (Integer)WEAPONS.get(Integer.valueOf(event.getId()));
|
||||
if ((cost != null) && (!specialEnabled()) && (this.client.getVar(VarPlayer.SPECIAL_ATTACK_PERCENT) >= cost.intValue() * 10)) {
|
||||
enableSpecial();
|
||||
}
|
||||
}
|
||||
|
||||
private void enableSpecial()
|
||||
{
|
||||
//this.client.invokeMenuAction(-1, 38862883, MenuAction.WIDGET_DEFAULT.getId(), 1, "Use <col=00ff00>Special Attack</col>", "", 50, 50);
|
||||
}
|
||||
|
||||
private boolean specialEnabled()
|
||||
{
|
||||
return this.client.getVar(VarPlayer.SPECIAL_ATTACK_ENABLED) == 1;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user