Here's the current code I have for prayer flicking:
private void handlePrayerFlicking() {
if (getSkills().getStatic(Skill.PRAYER) >= 37 && !canFlickMage)
canFlickMage = true;
if (getSkills().getStatic(Skill.PRAYER) >= 40 && !canFlickRange)
canFlickRange = true;
if (getSkills().getStatic(Skill.PRAYER) >= 43 && !canFlickMelee)
canFlickMelee = true;
if (myPlayer().getInteracting() != null && myPlayer().getInteracting() instanceof NPC) {
NPC npc = ((NPC) myPlayer().getInteracting());
if (npc.getHealthPercent() > 0 && npc.exists()) {
if (!npc.isAnimating() && !getPrayer()
.isActivated(currentNPCAttackStyle.equalsIgnoreCase("mage") ? PrayerButton.PROTECT_FROM_MAGIC
: currentNPCAttackStyle.equalsIgnoreCase("range") ? PrayerButton.PROTECT_FROM_MISSILES
: PrayerButton.PROTECT_FROM_MELEE)) {
if ((canFlickMage && currentNPCAttackStyle.equalsIgnoreCase("mage"))
|| (canFlickRange && currentNPCAttackStyle.equalsIgnoreCase("range"))
|| (canFlickMelee && currentNPCAttackStyle.equalsIgnoreCase("melee"))) {
if (getPrayer()
.set(currentNPCAttackStyle.equalsIgnoreCase("mage") ? PrayerButton.PROTECT_FROM_MAGIC
: currentNPCAttackStyle.equalsIgnoreCase("range")
? PrayerButton.PROTECT_FROM_MISSILES
: PrayerButton.PROTECT_FROM_MELEE,
true)) {
} else {
}
}
} else {
if (getPrayer().isActivated(
currentNPCAttackStyle.equalsIgnoreCase("mage") ? PrayerButton.PROTECT_FROM_MAGIC
: currentNPCAttackStyle.equalsIgnoreCase("range")
? PrayerButton.PROTECT_FROM_MISSILES
: PrayerButton.PROTECT_FROM_MELEE)) {
Sleep.waitCondition(() -> npc.isAnimating() || npc.getHealthPercent() == 0, 300, 1500);
if (getPrayer()
.set(currentNPCAttackStyle.equalsIgnoreCase("mage") ? PrayerButton.PROTECT_FROM_MAGIC
: currentNPCAttackStyle.equalsIgnoreCase("range")
? PrayerButton.PROTECT_FROM_MISSILES
: PrayerButton.PROTECT_FROM_MELEE,
false)) {
} else {
}
}
}
}
}
}
This works fine with most npcs, other than those that have longer attack delays, like hill giants. Whenever the npc performs their defense animation, prayer will still flick as they're 'animating'. I only want the prayer to flick off if it's their attack animation.
Is it possible to determine if the current animation an npc is performing is their defense animation or is there a better way to add prayer flicking?