Jump to content

Prayer flicking (NPC Animations)


Ateria

Recommended Posts

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
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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