Add quickprayer support for buff prayers
This commit is contained in:
@ -84,11 +84,41 @@ public interface Config extends net.runelite.client.config.Config {
|
||||
return new Keybind(KeyEvent.VK_3, InputEvent.CTRL_DOWN_MASK);
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "hotkeyMeleeBuff",
|
||||
name = "Melee buff hotkey",
|
||||
description = "When you press this key melee buff(s) will be set as quickprayer",
|
||||
position = 23
|
||||
)
|
||||
default Keybind hotkeyMeleeBuff() {
|
||||
return new Keybind(KeyEvent.VK_Q, InputEvent.CTRL_DOWN_MASK);
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "hotkeyRangedBuff",
|
||||
name = "Ranged buff hotkey",
|
||||
description = "When you press this key ranged buff will be set as quickprayer",
|
||||
position = 24
|
||||
)
|
||||
default Keybind hotkeyRangedBuff() {
|
||||
return new Keybind(KeyEvent.VK_W, InputEvent.CTRL_DOWN_MASK);
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "hotkeyMagicBuff",
|
||||
name = "Magic buff hotkey",
|
||||
description = "When you press this key magic buff will be set as quickprayer",
|
||||
position = 25
|
||||
)
|
||||
default Keybind hotkeyMagicBuff() {
|
||||
return new Keybind(KeyEvent.VK_E, InputEvent.CTRL_DOWN_MASK);
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "openInventory",
|
||||
name = "Open inventory",
|
||||
description = "Open inventory after swapping quickprayers",
|
||||
position = 23
|
||||
position = 26
|
||||
)
|
||||
default boolean openInventory() { return true; }
|
||||
|
||||
@ -96,7 +126,7 @@ public interface Config extends net.runelite.client.config.Config {
|
||||
keyName = "allowToggleOff",
|
||||
name = "Allow toggling off",
|
||||
description = "Will allow turning the protect prayer off when pressing the hotkey for the current one.",
|
||||
position = 24
|
||||
position = 27
|
||||
)
|
||||
default boolean allowToggleOff() { return true; }
|
||||
|
||||
@ -104,7 +134,7 @@ public interface Config extends net.runelite.client.config.Config {
|
||||
keyName = "jadPrayerFlick",
|
||||
name = "Jad Auto Prayer Flick",
|
||||
description = "Automatically swap prayers against Jad.",
|
||||
position = 30
|
||||
position = 40
|
||||
)
|
||||
default boolean jadPrayerFlick() { return true; }
|
||||
|
||||
@ -112,7 +142,7 @@ public interface Config extends net.runelite.client.config.Config {
|
||||
keyName = "hesporiPrayerFlick",
|
||||
name = "Hespori Auto Prayer Flick",
|
||||
description = "Automatically swap prayers against Hespori.",
|
||||
position = 31
|
||||
position = 41
|
||||
)
|
||||
default boolean hesporiPrayerFlick() { return true; }
|
||||
|
||||
|
@ -7,7 +7,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.*;
|
||||
import net.runelite.api.events.AnimationChanged;
|
||||
import net.runelite.api.events.GameTick;
|
||||
import net.runelite.api.events.VarbitChanged;
|
||||
import net.runelite.api.widgets.WidgetID;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.client.callback.ClientThread;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
@ -17,6 +17,7 @@ import net.runelite.client.input.KeyManager;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDependency;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.plugins.iutils.api.Prayers;
|
||||
import net.runelite.client.plugins.iutils.game.Game;
|
||||
import net.runelite.client.plugins.iutils.game.iWidget;
|
||||
import net.runelite.client.plugins.iutils.iUtils;
|
||||
@ -70,7 +71,8 @@ public class Prayerflick extends Plugin implements KeyListener {
|
||||
private boolean toggleFlicking;
|
||||
private boolean firstFlick;
|
||||
private boolean toggledOff;
|
||||
private volatile ProtectFrom currently;
|
||||
private volatile QuickPrayer currentOverhead;
|
||||
private int level;
|
||||
|
||||
@Override
|
||||
protected void startUp() {
|
||||
@ -124,12 +126,12 @@ public class Prayerflick extends Plugin implements KeyListener {
|
||||
switch (actor.getAnimation()) {
|
||||
case AnimationID.TZTOK_JAD_MAGIC_ATTACK:
|
||||
case JALTOK_JAD_MAGE_ATTACK:
|
||||
setPrayer(ProtectFrom.MAGIC, false);
|
||||
setPrayer(false, QuickPrayer.PROTECT_FROM_MAGIC);
|
||||
game.utils.sendGameMessage("Pray against magic!");
|
||||
break;
|
||||
case AnimationID.TZTOK_JAD_RANGE_ATTACK:
|
||||
case JALTOK_JAD_RANGE_ATTACK:
|
||||
setPrayer(ProtectFrom.MISSILES, false);
|
||||
setPrayer(false, QuickPrayer.PROTECT_FROM_MISSILES);
|
||||
game.utils.sendGameMessage("Pray against missiles!");
|
||||
break;
|
||||
}
|
||||
@ -138,10 +140,10 @@ public class Prayerflick extends Plugin implements KeyListener {
|
||||
if (config.hesporiPrayerFlick()) {
|
||||
switch (actor.getAnimation()) {
|
||||
case HESPORI_MAGE_ATTACK:
|
||||
setPrayer(ProtectFrom.MAGIC, false);
|
||||
setPrayer(false, QuickPrayer.PROTECT_FROM_MAGIC);
|
||||
break;
|
||||
case HESPORI_RANGE_ATTACK:
|
||||
setPrayer(ProtectFrom.MISSILES, false);
|
||||
setPrayer(false, QuickPrayer.PROTECT_FROM_MISSILES);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -158,6 +160,8 @@ public class Prayerflick extends Plugin implements KeyListener {
|
||||
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
level = game.baseLevel(Skill.PRAYER);
|
||||
|
||||
if (config.prayerFlickHotkey().matches(e)) {
|
||||
if (toggleFlicking) {
|
||||
toggledOff = true;
|
||||
@ -167,42 +171,52 @@ public class Prayerflick extends Plugin implements KeyListener {
|
||||
|
||||
toggleFlicking = !toggleFlicking;
|
||||
} else if (config.hotkeyMelee().matches(e)) {
|
||||
setPrayer(ProtectFrom.MELEE, config.allowToggleOff());
|
||||
setPrayer(config.allowToggleOff(), QuickPrayer.PROTECT_FROM_MELEE);
|
||||
} else if (config.hotkeyMissiles().matches(e)) {
|
||||
setPrayer(ProtectFrom.MISSILES, config.allowToggleOff());
|
||||
setPrayer(config.allowToggleOff(), QuickPrayer.PROTECT_FROM_MISSILES);
|
||||
} else if (config.hotkeyMagic().matches(e)) {
|
||||
setPrayer(ProtectFrom.MAGIC, config.allowToggleOff());
|
||||
setPrayer(config.allowToggleOff(), QuickPrayer.PROTECT_FROM_MAGIC);
|
||||
} else if (config.hotkeyMeleeBuff().matches(e)) {
|
||||
setPrayer(config.allowToggleOff(), QuickPrayer.getBestMeleeBuff(level));
|
||||
} else if (config.hotkeyRangedBuff().matches(e)) {
|
||||
setPrayer(config.allowToggleOff(), QuickPrayer.getBestRangedBuff(level));
|
||||
} else if (config.hotkeyMagicBuff().matches(e)) {
|
||||
setPrayer(config.allowToggleOff(), QuickPrayer.getBestMagicBuff(level));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {}
|
||||
|
||||
private void setPrayer(ProtectFrom protectFrom, boolean allowToggleOff) {
|
||||
if (!allowToggleOff && protectFrom == currently) return;
|
||||
private void setPrayer(boolean allowToggleOff, QuickPrayer... quickPrayers) {
|
||||
if (!allowToggleOff && quickPrayers[0] == currentOverhead) return;
|
||||
|
||||
if (currently == protectFrom) {
|
||||
currently = ProtectFrom.NONE;
|
||||
} else {
|
||||
currently = protectFrom;
|
||||
if (currentOverhead == quickPrayers[0]) {
|
||||
currentOverhead = QuickPrayer.NONE;
|
||||
} else if (quickPrayers[0] == QuickPrayer.PROTECT_FROM_MAGIC
|
||||
|| quickPrayers[0] == QuickPrayer.PROTECT_FROM_MISSILES
|
||||
|| quickPrayers[0] == QuickPrayer.PROTECT_FROM_MELEE) {
|
||||
currentOverhead = quickPrayers[0];
|
||||
}
|
||||
|
||||
executor.schedule(() -> {
|
||||
iWidget quickPrayers = game.widget(WidgetInfo.MINIMAP_QUICK_PRAYER_ORB);
|
||||
if (quickPrayers == null) return;
|
||||
iWidget quickPrayersWidget = game.widget(WidgetInfo.MINIMAP_QUICK_PRAYER_ORB);
|
||||
if (quickPrayersWidget == null) return;
|
||||
|
||||
quickPrayers.interact(1);
|
||||
quickPrayersWidget.interact(1);
|
||||
game.waitUntil(() -> {
|
||||
iWidget w = game.widget(77, 4);
|
||||
iWidget w = game.widget(WidgetID.QUICK_PRAYERS_GROUP_ID, 4);
|
||||
return w != null && !w.hidden();
|
||||
});
|
||||
|
||||
iWidget protection = game.widget(77, 4, protectFrom.getChildId());
|
||||
for (QuickPrayer quickPrayer : quickPrayers) {
|
||||
iWidget protection = game.widget(WidgetID.QUICK_PRAYERS_GROUP_ID, 4, quickPrayer.getChildId());
|
||||
if (protection == null) return;
|
||||
|
||||
protection.interact(0);
|
||||
}
|
||||
|
||||
iWidget update = game.widget(77, 5);
|
||||
iWidget update = game.widget(WidgetID.QUICK_PRAYERS_GROUP_ID, 5);
|
||||
if (update == null) return;
|
||||
|
||||
update.interact(0);
|
||||
|
@ -1,15 +0,0 @@
|
||||
package io.reisub.openosrs.prayerflick;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum ProtectFrom {
|
||||
NONE(0),
|
||||
MAGIC(12),
|
||||
MISSILES(13),
|
||||
MELEE(14);
|
||||
|
||||
private final int childId;
|
||||
}
|
@ -0,0 +1,132 @@
|
||||
package io.reisub.openosrs.prayerflick;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import net.runelite.api.widgets.WidgetID;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum QuickPrayer {
|
||||
NONE(0, 0),
|
||||
THICK_SKIN(WidgetID.QuickPrayer.THICK_SKIN_CHILD_ID, 1),
|
||||
BURST_OF_STRENGTH(WidgetID.QuickPrayer.BURST_OF_STRENGTH_CHILD_ID, 4),
|
||||
CLARITY_OF_THOUGHT(WidgetID.QuickPrayer.CLARITY_OF_THOUGHT_CHILD_ID, 7),
|
||||
SHARP_EYE(WidgetID.QuickPrayer.SHARP_EYE_CHILD_ID, 8),
|
||||
MYSTIC_WILL(WidgetID.QuickPrayer.MYSTIC_WILL_CHILD_ID, 9),
|
||||
ROCK_SKIN(WidgetID.QuickPrayer.ROCK_SKIN_CHILD_ID, 10),
|
||||
SUPERHUMAN_STRENGTH(WidgetID.QuickPrayer.SUPERHUMAN_STRENGTH_CHILD_ID, 13),
|
||||
IMPROVED_REFLEXES(WidgetID.QuickPrayer.IMPROVED_REFLEXES_CHILD_ID, 16),
|
||||
RAPID_RESTORE(WidgetID.QuickPrayer.RAPID_RESTORE_CHILD_ID, 19),
|
||||
RAPID_HEAL(WidgetID.QuickPrayer.RAPID_HEAL_CHILD_ID, 22),
|
||||
PROTECT_ITEM(WidgetID.QuickPrayer.PROTECT_ITEM_CHILD_ID, 25),
|
||||
HAWK_EYE(WidgetID.QuickPrayer.HAWK_EYE_CHILD_ID, 26),
|
||||
MYSTIC_LORE(WidgetID.QuickPrayer.MYSTIC_LORE_CHILD_ID, 27),
|
||||
STEEL_SKIN(WidgetID.QuickPrayer.STEEL_SKIN_CHILD_ID, 28),
|
||||
ULTIMATE_STRENGTH(WidgetID.QuickPrayer.ULTIMATE_STRENGTH_CHILD_ID, 31),
|
||||
INCREDIBLE_REFLEXES(WidgetID.QuickPrayer.INCREDIBLE_REFLEXES_CHILD_ID, 34),
|
||||
PROTECT_FROM_MAGIC(WidgetID.QuickPrayer.PROTECT_FROM_MAGIC_CHILD_ID, 37),
|
||||
PROTECT_FROM_MISSILES(WidgetID.QuickPrayer.PROTECT_FROM_MISSILES_CHILD_ID, 40),
|
||||
PROTECT_FROM_MELEE(WidgetID.QuickPrayer.PROTECT_FROM_MELEE_CHILD_ID, 43),
|
||||
EAGLE_EYE(WidgetID.QuickPrayer.EAGLE_EYE_CHILD_ID, 44),
|
||||
MYSTIC_MIGHT(WidgetID.QuickPrayer.MYSTIC_MIGHT_CHILD_ID, 45),
|
||||
RETRIBUTION(WidgetID.QuickPrayer.RETRIBUTION_CHILD_ID, 46),
|
||||
REDEMPTION(WidgetID.QuickPrayer.REDEMPTION_CHILD_ID, 49),
|
||||
SMITE(WidgetID.QuickPrayer.SMITE_CHILD_ID, 52),
|
||||
PRESERVE(WidgetID.QuickPrayer.PRESERVE_CHILD_ID, 55),
|
||||
CHIVALRY(WidgetID.QuickPrayer.CHIVALRY_CHILD_ID, 60),
|
||||
PIETY(WidgetID.QuickPrayer.PIETY_CHILD_ID, 70),
|
||||
RIGOUR(WidgetID.QuickPrayer.RIGOUR_CHILD_ID, 74),
|
||||
AUGURY(WidgetID.QuickPrayer.AUGURY_CHILD_ID, 77);
|
||||
|
||||
private final int childId;
|
||||
private final int level;
|
||||
|
||||
public static QuickPrayer[] getBestMeleeBuff(int level) {
|
||||
if (level >= PIETY.level) {
|
||||
return new QuickPrayer[] { PIETY };
|
||||
} else if (level >= CHIVALRY.level) {
|
||||
return new QuickPrayer[] { CHIVALRY };
|
||||
} else {
|
||||
QuickPrayer[] quickPrayers;
|
||||
if (level >= 7) {
|
||||
quickPrayers = new QuickPrayer[3];
|
||||
quickPrayers[0] = getBestDefence(level);
|
||||
quickPrayers[1] = getBestStrength(level);
|
||||
quickPrayers[2] = getBestAttack(level);
|
||||
} else if (level >= 4) {
|
||||
quickPrayers = new QuickPrayer[2];
|
||||
quickPrayers[0] = getBestDefence(level);
|
||||
quickPrayers[1] = getBestStrength(level);
|
||||
} else {
|
||||
quickPrayers = new QuickPrayer[1];
|
||||
quickPrayers[0] = getBestDefence(level);
|
||||
}
|
||||
|
||||
return quickPrayers;
|
||||
}
|
||||
}
|
||||
|
||||
private static QuickPrayer getBestAttack(int level) {
|
||||
if (level >= INCREDIBLE_REFLEXES.level) {
|
||||
return INCREDIBLE_REFLEXES;
|
||||
} else if (level >= IMPROVED_REFLEXES.level) {
|
||||
return IMPROVED_REFLEXES;
|
||||
} else if (level >= CLARITY_OF_THOUGHT.level) {
|
||||
return CLARITY_OF_THOUGHT;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static QuickPrayer getBestStrength(int level) {
|
||||
if (level >= ULTIMATE_STRENGTH.level) {
|
||||
return ULTIMATE_STRENGTH;
|
||||
} else if (level >= SUPERHUMAN_STRENGTH.level) {
|
||||
return SUPERHUMAN_STRENGTH;
|
||||
} else if (level >= BURST_OF_STRENGTH.level) {
|
||||
return BURST_OF_STRENGTH;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static QuickPrayer getBestDefence(int level) {
|
||||
if (level >= STEEL_SKIN.level) {
|
||||
return STEEL_SKIN;
|
||||
} else if (level >= ROCK_SKIN.level) {
|
||||
return ROCK_SKIN;
|
||||
} else if (level >= THICK_SKIN.level) {
|
||||
return THICK_SKIN;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static QuickPrayer[] getBestRangedBuff(int level) {
|
||||
if (level >= RIGOUR.level) {
|
||||
return new QuickPrayer[] { RIGOUR };
|
||||
} else if (level >= EAGLE_EYE.level) {
|
||||
return new QuickPrayer[] { EAGLE_EYE };
|
||||
} else if (level >= HAWK_EYE.level) {
|
||||
return new QuickPrayer[] { HAWK_EYE };
|
||||
} else if (level >= SHARP_EYE.level) {
|
||||
return new QuickPrayer[] { SHARP_EYE };
|
||||
}
|
||||
|
||||
return new QuickPrayer[]{};
|
||||
}
|
||||
|
||||
public static QuickPrayer[] getBestMagicBuff(int level) {
|
||||
if (level >= AUGURY.level) {
|
||||
return new QuickPrayer[] { AUGURY };
|
||||
} else if (level >= MYSTIC_MIGHT.level) {
|
||||
return new QuickPrayer[] { MYSTIC_MIGHT };
|
||||
} else if (level >= MYSTIC_LORE.level) {
|
||||
return new QuickPrayer[] { MYSTIC_LORE };
|
||||
} else if (level >= MYSTIC_WILL.level) {
|
||||
return new QuickPrayer[] { MYSTIC_WILL };
|
||||
}
|
||||
|
||||
return new QuickPrayer[]{};
|
||||
}
|
||||
}
|
Binary file not shown.
Reference in New Issue
Block a user