Java Code Examples for net.runelite.api.Player#getAnimation()

The following examples show how to use net.runelite.api.Player#getAnimation() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WoodcuttingPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
private void onAnimationChanged(final AnimationChanged event)
{
	Player local = client.getLocalPlayer();

	if (event.getActor() != local)
	{
		return;
	}

	int animId = local.getAnimation();
	Axe axe = Axe.findAxeByAnimId(animId);
	if (axe != null)
	{
		this.axe = axe;
	}
}
 
Example 2
Source File: IdleNotifierPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
private void resetTimers()
{
	final Player local = client.getLocalPlayer();

	// Reset animation idle timer
	lastAnimating = null;
	if (client.getGameState() == GameState.LOGIN_SCREEN || local == null || local.getAnimation() != lastAnimation)
	{
		lastAnimation = IDLE;
	}

	// Reset interaction idle timer
	lastInteracting = null;
	if (client.getGameState() == GameState.LOGIN_SCREEN || local == null || local.getInteracting() != lastInteract)
	{
		lastInteract = null;
	}
}
 
Example 3
Source File: WoodcuttingPlugin.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Subscribe
public void onAnimationChanged(final AnimationChanged event)
{
	Player local = client.getLocalPlayer();

	if (event.getActor() != local)
	{
		return;
	}

	int animId = local.getAnimation();
	Axe axe = Axe.findAxeByAnimId(animId);
	if (axe != null)
	{
		this.axe = axe;
	}
}
 
Example 4
Source File: IdleNotifierPlugin.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void resetTimers()
{
	final Player local = client.getLocalPlayer();

	// Reset animation idle timer
	lastAnimating = null;
	if (client.getGameState() == GameState.LOGIN_SCREEN || local == null || local.getAnimation() != lastAnimation)
	{
		lastAnimation = IDLE;
	}

	// Reset interaction idle timer
	lastInteracting = null;
	if (client.getGameState() == GameState.LOGIN_SCREEN || local == null || local.getInteracting() != lastInteract)
	{
		lastInteract = null;
	}
}
 
Example 5
Source File: CannonPlugin.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Subscribe
public void onGameObjectSpawned(GameObjectSpawned event)
{
	GameObject gameObject = event.getGameObject();

	Player localPlayer = client.getLocalPlayer();
	if (gameObject.getId() == CANNON_BASE && !cannonPlaced)
	{
		if (localPlayer.getWorldLocation().distanceTo(gameObject.getWorldLocation()) <= 2
			&& localPlayer.getAnimation() == AnimationID.BURYING_BONES)
		{
			cannonPosition = gameObject.getWorldLocation();
			cannon = gameObject;
		}
	}
}
 
Example 6
Source File: DevToolsOverlay.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
private void renderPlayers(Graphics2D graphics)
{
	List<Player> players = client.getPlayers();
	Player local = client.getLocalPlayer();

	for (Player p : players)
	{
		String text = p.getName() + " (A: " + p.getAnimation() + ") (P: " + p.getPoseAnimation() + ") (G: " + p.getSpotAnimation() + ") (IDX: " + p.getPlayerId() + ")";
		OverlayUtil.renderActorOverlay(graphics, p, text, p == local ? CYAN : BLUE);
	}

	renderPlayerWireframe(graphics, local, CYAN);
}
 
Example 7
Source File: IdleNotifierPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
void onAnimationChanged(AnimationChanged event)
{
	if (client.getGameState() != GameState.LOGGED_IN)
	{
		return;
	}

	Player localPlayer = client.getLocalPlayer();
	if (localPlayer != event.getActor())
	{
		return;
	}

	int graphic = localPlayer.getSpotAnimation();
	int animation = localPlayer.getAnimation();

	if (nominalAnimations.contains(animation) || (animation == MAGIC_LUNAR_SHARED && graphic == GraphicID.BAKE_PIE))
	{
		resetTimers();
		lastAnimation = animation;
		lastAnimating = Instant.now();
		interactingNotified = false;
	}

	else if (animation == IDLE)
	{
		lastAnimating = Instant.now();
		interactingNotified = false;
	}

	// On unknown animation simply assume the animation is invalid and dont throw notification
	else
	{
		lastAnimation = IDLE;
		lastAnimating = null;
	}
}
 
Example 8
Source File: IdleNotifierPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
private boolean checkAnimationIdle(Duration waitDuration, Player local)
{
	if (lastAnimation == IDLE || interactingNotified)
	{
		return false;
	}

	final int animation = local.getAnimation();

	if (animation == IDLE)
	{
		if (lastAnimating != null && Instant.now().compareTo(lastAnimating.plus(waitDuration)) >= 0)
		{
			lastAnimation = IDLE;
			lastAnimating = null;

			// prevent interaction notifications from firing too
			lastInteract = null;
			lastInteracting = null;

			return true;
		}
	}
	else
	{
		lastAnimating = Instant.now();
	}

	return false;
}
 
Example 9
Source File: IdleNotifierPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
private boolean checkMovementIdle(Duration waitDuration, Player local)
{
	if (lastPosition == null)
	{
		lastPosition = local.getWorldLocation();
		return false;
	}

	WorldPoint position = local.getWorldLocation();

	if (lastPosition.equals(position))
	{
		if (notifyPosition
			&& local.getAnimation() == IDLE
			&& Instant.now().compareTo(lastMoving.plus(waitDuration)) >= 0)
		{
			notifyPosition = false;
			// Return true only if we weren't just breaking out of an animation
			return lastAnimation == IDLE;
		}
	}
	else
	{
		notifyPosition = true;
		lastPosition = position;
		lastMoving = Instant.now();
	}
	return false;
}
 
Example 10
Source File: IdleNotifierPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private boolean checkAnimationIdle(Duration waitDuration, Player local)
{
	if (lastAnimation == IDLE)
	{
		return false;
	}

	final int animation = local.getAnimation();

	if (animation == IDLE)
	{
		if (lastAnimating != null && Instant.now().compareTo(lastAnimating.plus(waitDuration)) >= 0)
		{
			lastAnimation = IDLE;
			lastAnimating = null;

			// prevent interaction notifications from firing too
			lastInteract = null;
			lastInteracting = null;

			return true;
		}
	}
	else
	{
		lastAnimating = Instant.now();
	}

	return false;
}
 
Example 11
Source File: IdleNotifierPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private boolean checkMovementIdle(Duration waitDuration, Player local)
{
	if (lastPosition == null)
	{
		lastPosition = local.getWorldLocation();
		return false;
	}

	WorldPoint position = local.getWorldLocation();

	if (lastPosition.equals(position))
	{
		if (notifyPosition
			&& local.getAnimation() == IDLE
			&& Instant.now().compareTo(lastMoving.plus(waitDuration)) >= 0)
		{
			notifyPosition = false;
			// Return true only if we weren't just breaking out of an animation
			return lastAnimation == IDLE;
		}
	}
	else
	{
		notifyPosition = true;
		lastPosition = position;
		lastMoving = Instant.now();
	}

	return false;
}
 
Example 12
Source File: TimersPlugin.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
@Subscribe
private void onAnimationChanged(AnimationChanged event)
{
	Actor actor = event.getActor();

	if (config.showAbyssalSireStun()
		&& actor instanceof NPC)
	{
		int npcId = ((NPC) actor).getId();

		switch (npcId)
		{
			// Show the countdown when the Sire enters the stunned state.
			case NpcID.ABYSSAL_SIRE_5887:
				createGameTimer(ABYSSAL_SIRE_STUN);
				break;

			// Hide the countdown if the Sire isn't in the stunned state.
			// This is necessary because the Sire leaves the stunned
			// state early once all all four respiratory systems are killed.
			case NpcID.ABYSSAL_SIRE:
			case NpcID.ABYSSAL_SIRE_5888:
			case NpcID.ABYSSAL_SIRE_5889:
			case NpcID.ABYSSAL_SIRE_5890:
			case NpcID.ABYSSAL_SIRE_5891:
			case NpcID.ABYSSAL_SIRE_5908:
				removeGameTimer(ABYSSAL_SIRE_STUN);
				break;
		}
	}

	Player player = client.getLocalPlayer();

	if (player == null || actor != player)
	{
		return;
	}

	if (config.showHomeMinigameTeleports()
		&& player.getAnimation() == AnimationID.IDLE
		&& (lastAnimation == AnimationID.BOOK_HOME_TELEPORT_5
		|| lastAnimation == AnimationID.COW_HOME_TELEPORT_6))
	{
		if (lastTeleportClicked == TeleportWidget.HOME_TELEPORT)
		{
			createGameTimer(HOME_TELEPORT);
		}
		else if (lastTeleportClicked == TeleportWidget.MINIGAME_TELEPORT)
		{
			createGameTimer(MINIGAME_TELEPORT);
		}
	}

	if (config.showDFSSpecial() && lastAnimation == AnimationID.DRAGONFIRE_SHIELD_SPECIAL)
	{
		createGameTimer(DRAGON_FIRE_SHIELD);
	}

	lastAnimation = player.getAnimation();
}
 
Example 13
Source File: SuppliesTrackerPlugin.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
@Subscribe
private void onGameTick(GameTick tick)
{
	Player player = client.getLocalPlayer();
	if (player.getAnimation() == BLOWPIPE_ATTACK)
	{
		ticks++;
	}
	if (ticks == ticksInAnimation &&
		(player.getAnimation() == BLOWPIPE_ATTACK))
	{
		double ava_percent = getAccumulatorPercent();
		// randomize the usage of supplies since we CANNOT actually get real supplies used
		if (random.nextDouble() <= ava_percent)
		{
			buildEntries(config.blowpipeAmmo().getDartID());
		}
		if (random.nextDouble() <= SCALES_PERCENT)
		{
			buildEntries(ZULRAHS_SCALES);
		}
		ticks = 0;
	}

	//reset skip bone for dark altar
	skipBone = false;

	//Waits to reset prayer animation check. needed for 1 ticking or
	//in case animation gets interrupted
	if (longTickWait > 0)
	{
		longTickWait = longTickWait - 1;
	}
	else if (prayerAltarAnimationCheck)
	{
		prayerAltarAnimationCheck = false;
	}


	if (skipTick)
	{
		skipTick = false;
		return;
	}
	else if (magicXpChanged)
	{
		checkUsedRunePouch();
		magicXpChanged = false;
		noXpCast = false;
	}
	else if (noXpCast)
	{
		checkUsedRunePouch();
		noXpCast = false;
	}

	amountused1 = 0;
	amountused2 = 0;
	amountused3 = 0;
}
 
Example 14
Source File: WintertodtPlugin.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
@Subscribe
private void onAnimationChanged(final AnimationChanged event)
{
	if (!isInWintertodt)
	{
		return;
	}

	final Player local = client.getLocalPlayer();

	if (event.getActor() != local)
	{
		return;
	}

	final int animId = local.getAnimation();
	switch (animId)
	{
		case WOODCUTTING_BRONZE:
		case WOODCUTTING_IRON:
		case WOODCUTTING_STEEL:
		case WOODCUTTING_BLACK:
		case WOODCUTTING_MITHRIL:
		case WOODCUTTING_ADAMANT:
		case WOODCUTTING_RUNE:
		case WOODCUTTING_GILDED:
		case WOODCUTTING_DRAGON:
		case WOODCUTTING_INFERNAL:
		case WOODCUTTING_3A_AXE:
		case WOODCUTTING_CRYSTAL:
			setActivity(WintertodtActivity.WOODCUTTING);
			break;

		case FLETCHING_BOW_CUTTING:
			setActivity(WintertodtActivity.FLETCHING);
			break;

		case LOOKING_INTO:
			setActivity(WintertodtActivity.FEEDING_BRAZIER);
			break;

		case FIREMAKING:
			setActivity(WintertodtActivity.LIGHTING_BRAZIER);
			break;

		case CONSTRUCTION:
			setActivity(WintertodtActivity.FIXING_BRAZIER);
			break;
	}
}
 
Example 15
Source File: MotherlodePlugin.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
@Subscribe
private void onAnimationChanged(AnimationChanged event)
{
	if (!inMlm)
	{
		return;
	}

	Player localPlayer = client.getLocalPlayer();
	if (localPlayer != event.getActor())
	{
		return;
	}

	int animation = localPlayer.getAnimation();

	switch (animation)
	{
		case MINING_MOTHERLODE_BRONZE:
		case MINING_MOTHERLODE_IRON:
		case MINING_MOTHERLODE_STEEL:
		case MINING_MOTHERLODE_BLACK:
		case MINING_MOTHERLODE_MITHRIL:
		case MINING_MOTHERLODE_ADAMANT:
		case MINING_MOTHERLODE_RUNE:
		case MINING_MOTHERLODE_GILDED:
		case MINING_MOTHERLODE_DRAGON:
		case MINING_MOTHERLODE_DRAGON_UPGRADED:
		case MINING_MOTHERLODE_DRAGON_OR:
		case MINING_MOTHERLODE_CRYSTAL:
		case MINING_MOTHERLODE_INFERNAL:
		case MINING_MOTHERLODE_3A:
			lastAnimation = animation;
			lastAnimating = Instant.now();
			break;
		case IDLE:
			lastAnimating = Instant.now();
			break;
		default:
			// On unknown animation simply assume the animation is invalid
			lastAnimation = IDLE;
			lastAnimating = null;
	}
}
 
Example 16
Source File: WintertodtPlugin.java    From runelite with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Subscribe
public void onAnimationChanged(final AnimationChanged event)
{
	if (!isInWintertodt)
	{
		return;
	}

	final Player local = client.getLocalPlayer();

	if (event.getActor() != local)
	{
		return;
	}

	final int animId = local.getAnimation();
	switch (animId)
	{
		case WOODCUTTING_BRONZE:
		case WOODCUTTING_IRON:
		case WOODCUTTING_STEEL:
		case WOODCUTTING_BLACK:
		case WOODCUTTING_MITHRIL:
		case WOODCUTTING_ADAMANT:
		case WOODCUTTING_RUNE:
		case WOODCUTTING_GILDED:
		case WOODCUTTING_DRAGON:
		case WOODCUTTING_INFERNAL:
		case WOODCUTTING_3A_AXE:
		case WOODCUTTING_CRYSTAL:
			setActivity(WintertodtActivity.WOODCUTTING);
			break;

		case FLETCHING_BOW_CUTTING:
			setActivity(WintertodtActivity.FLETCHING);
			break;

		case LOOKING_INTO:
			setActivity(WintertodtActivity.FEEDING_BRAZIER);
			break;

		case FIREMAKING:
			setActivity(WintertodtActivity.LIGHTING_BRAZIER);
			break;

		case CONSTRUCTION:
			setActivity(WintertodtActivity.FIXING_BRAZIER);
			break;
	}
}