Jump to content

Prayer flicking (NPC Animations)


Recommended Posts

Posted (edited)

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?

Edited by Ateria
Posted
2 minutes ago, FrostBug said:

If you timestamp any one attack animation from the NPC, you can predict the timestamps of their next attacks based on their attackspeed

I was going to do that, but it's for a slayer script and with the amount of tasks there are, i'd have to go through enum and add attack animations one by one after getting them in-game which'd take a long time. Is it not possible to do it another way?

Posted
3 minutes ago, Ateria said:

I was going to do that, but it's for a slayer script and with the amount of tasks there are, i'd have to go through enum and add attack animations one by one after getting them in-game which'd take a long time. Is it not possible to do it another way?

There's probably a fixed relation between the animations if I had to guess.. like the defence animation always being a higher or lower ID than the attack animation

  • Like 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...