net.runelite.api.Actor Java Examples
The following examples show how to use
net.runelite.api.Actor.
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: XpPanel.java From plugins with GNU General Public License v3.0 | 6 votes |
static String buildXpTrackerUrl(final Actor player, final Skill skill) { if (player == null) { return ""; } return new HttpUrl.Builder() .scheme("https") .host("runelite.net") .addPathSegment("xp") .addPathSegment("show") .addPathSegment(skill.getName().toLowerCase()) .addPathSegment(player.getName()) .addPathSegment("1week") .addPathSegment("now") .build() .toString(); }
Example #2
Source File: Anonymizer.java From ExternalPlugins with GNU General Public License v3.0 | 6 votes |
@Subscribe public void onOverheadTextChanged(OverheadTextChanged event) { String oh = event.getOverheadText(); if (!oh.contains(name)) { return; } Actor actor = event.getActor(); if (actor != null) { String text = oh.replace(name, ANON); actor.setOverheadText(text); } }
Example #3
Source File: FishingPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
@Subscribe private void onInteractingChanged(InteractingChanged event) { if (event.getSource() != client.getLocalPlayer()) { return; } final Actor target = event.getTarget(); if (!(target instanceof NPC)) { return; } final NPC npc = (NPC) target; FishingSpot spot = FishingSpot.findSpot(npc.getId()); if (spot == null) { return; } currentSpot = spot; }
Example #4
Source File: IdleNotifierPluginTest.java From plugins with GNU General Public License v3.0 | 6 votes |
@Test public void checkCombatLogout() { plugin.onInteractingChanged(new InteractingChanged(player, monster)); when(player.getInteracting()).thenReturn(mock(Actor.class)); plugin.onGameTick(GameTick.INSTANCE); // Logout when(client.getGameState()).thenReturn(GameState.LOGIN_SCREEN); GameStateChanged gameStateChanged = new GameStateChanged(); gameStateChanged.setGameState(GameState.LOGIN_SCREEN); plugin.onGameStateChanged(gameStateChanged); // Log back in when(client.getGameState()).thenReturn(GameState.LOGGED_IN); gameStateChanged.setGameState(GameState.LOGGED_IN); plugin.onGameStateChanged(gameStateChanged); // Tick plugin.onInteractingChanged(new InteractingChanged(player, null)); plugin.onGameTick(GameTick.INSTANCE); verify(notifier, times(0)).notify(any()); }
Example #5
Source File: IdleNotifierPluginTest.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Test public void checkCombatLogout() { plugin.onInteractingChanged(new InteractingChanged(player, monster)); when(player.getInteracting()).thenReturn(mock(Actor.class)); plugin.onGameTick(new GameTick()); // Logout when(client.getGameState()).thenReturn(GameState.LOGIN_SCREEN); GameStateChanged gameStateChanged = new GameStateChanged(); gameStateChanged.setGameState(GameState.LOGIN_SCREEN); plugin.onGameStateChanged(gameStateChanged); // Log back in when(client.getGameState()).thenReturn(GameState.LOGGED_IN); gameStateChanged.setGameState(GameState.LOGGED_IN); plugin.onGameStateChanged(gameStateChanged); // Tick plugin.onInteractingChanged(new InteractingChanged(player, null)); plugin.onGameTick(new GameTick()); verify(notifier, times(0)).notify(any()); }
Example #6
Source File: OpponentInfoPlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Subscribe public void onInteractingChanged(InteractingChanged event) { if (event.getSource() != client.getLocalPlayer()) { return; } Actor opponent = event.getTarget(); if (opponent == null) { lastTime = Instant.now(); return; } lastOpponent = opponent; }
Example #7
Source File: SlayerPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
@Subscribe private void onInteractingChanged(InteractingChanged event) { if (client.getLocalPlayer() == null) { return; } final Actor interacting = client.getLocalPlayer().getInteracting(); weaknessTask = null; if (!(interacting instanceof NPC)) { return; } final NPC npc = (NPC) interacting; for (Task task : weaknessTasks) { if (isTarget(npc, buildTargetNames(task))) { weaknessTask = task; return; } } }
Example #8
Source File: BarbarianAssaultPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
@Subscribe private void onProjectileSpawned(ProjectileSpawned event) { if (!isInGame()) { return; } Actor target = event.getProjectile().getInteracting(); if (target == null) { return; } String name = target.getName(); if ("Penance Fighter".equals(name) || "Penance Ranger".equals(name)) { projectiles.put(((NPC) target).getIndex(), event.getProjectile()); } }
Example #9
Source File: DriftNetPlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Subscribe public void onChatMessage(ChatMessage event) { if (!inDriftNetArea) { return; } if (event.getType() == ChatMessageType.SPAM && event.getMessage().equals(CHAT_PRODDING_FISH)) { Actor target = client.getLocalPlayer().getInteracting(); if (target instanceof NPC && ((NPC) target).getId() == NpcID.FISH_SHOAL) { tagFish(target); } else { // If the fish is on an adjacent tile, the interaction change happens after // the chat message is sent, so we arm it armInteraction = true; } } }
Example #10
Source File: PlayerIndicatorsPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
/** * Checks if a player is a caller * * @param player The player to check * @return true if they are, false otherwise */ boolean isCaller(Actor player) { if (player == null || player.getName() == null) { return false; } if (callers.size() > 0) { for (String name : callers) { String finalName = Text.standardize(name.trim()); if (Text.standardize(player.getName()).equals(finalName)) { return true; } } } return false; }
Example #11
Source File: PlayerIndicatorsPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
/** * Checks if a player is currently a target of any of the current callers * * @param actor The player to check * @return true if they are a target, false otherwise */ public boolean isPile(Actor actor) { /** if (!(actor instanceof Player)) { return false; } **/ if (actor == null) { return false; } return callerPiles.containsValue(actor); }
Example #12
Source File: StatusBarsPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
private void hideStatusBar() { final Actor interacting = client.getLocalPlayer().getInteracting(); final boolean isNpc = interacting instanceof NPC; final int combatTimeout = config.hideStatusBarDelay(); if (isNpc) { final NPC npc = (NPC) interacting; final NPCDefinition npcComposition = npc.getDefinition(); final List<String> npcMenuActions = Arrays.asList(npcComposition.getActions()); if (npcMenuActions.contains("Attack") && config.toggleRestorationBars()) { updateLastCombatAction(); overlayManager.add(overlay); } } else if (lastCombatAction == null || Duration.between(getLastCombatAction(), Instant.now()).getSeconds() > combatTimeout) { overlayManager.remove(overlay); } }
Example #13
Source File: CorpPlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Subscribe public void onHitsplatApplied(HitsplatApplied hitsplatApplied) { Actor actor = hitsplatApplied.getActor(); if (actor != corp) { return; } int myDamage = client.getVar(Varbits.CORP_DAMAGE); // sometimes hitsplats are applied after the damage counter has been reset if (myDamage > 0) { yourDamage = myDamage; } totalDamage += hitsplatApplied.getHitsplat().getAmount(); }
Example #14
Source File: PoisonActorOverlay.java From plugins with GNU General Public License v3.0 | 6 votes |
private void renderOverlayFor(Graphics2D g, Actor actor, int damage, String timeLeft, boolean venomed) { BufferedImage splat = plugin.getSplat(venomed ? SpriteID.HITSPLAT_DARK_GREEN_VENOM : SpriteID.HITSPLAT_GREEN_POISON, damage); LocalPoint localLocation = actor.getLocalLocation(); if (localLocation == null) { return; } Point overlayLocation = Perspective.getCanvasImageLocation(client, localLocation, splat, 0); if (overlayLocation == null) { return; } int textOffset = splat.getHeight() - (splat.getHeight() - fontSize) / 2; Point textLocation = new Point(overlayLocation.getX() + splat.getWidth() + 3, overlayLocation.getY() + textOffset); g.drawImage(splat, overlayLocation.getX(), overlayLocation.getY(), null); OverlayUtil.renderTextLocation(g, textLocation, timeLeft, Color.WHITE); }
Example #15
Source File: DriftNetPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
@Subscribe public void onChatMessage(ChatMessage event) { if (!inDriftNetArea) { return; } if (event.getType() == ChatMessageType.SPAM && event.getMessage().equals(CHAT_PRODDING_FISH)) { Actor target = client.getLocalPlayer().getInteracting(); if (target instanceof NPC && ((NPC) target).getId() == NpcID.FISH_SHOAL) { tagFish(target); } else { // If the fish is on an adjacent tile, the interaction change happens after // the chat message is sent, so we arm it armInteraction = true; } } }
Example #16
Source File: CorpPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
@Subscribe private void onHitsplatApplied(HitsplatApplied hitsplatApplied) { Actor actor = hitsplatApplied.getActor(); if (actor != corp) { return; } int myDamage = client.getVar(Varbits.CORP_DAMAGE); // sometimes hitsplats are applied after the damage counter has been reset if (myDamage > 0) { yourDamage = myDamage; } totalDamage += hitsplatApplied.getHitsplat().getAmount(); }
Example #17
Source File: OpponentInfoPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
int getMaxHp(Actor actor) { if (actor instanceof NPC) { return npcManager.getHealth(((NPC) actor).getId()); } else { final HiscoreResult hiscoreResult = hiscoreManager.lookupAsync(Text.removeTags(actor.getName()), getHiscoreEndpoint()); if (hiscoreResult != null) { final int hp = hiscoreResult.getHitpoints().getLevel(); if (hp > 0) { return hp; } } return -1; } }
Example #18
Source File: OpponentInfoPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
private String getHpString(Actor actor, boolean withColorTag) { int maxHp = getMaxHp(actor); int health = actor.getHealthScale(); int ratio = actor.getHealthRatio(); final String result; if (maxHp != -1) { final int exactHealth = OpponentInfoOverlay.getExactHp(ratio, health, maxHp); result = "(" + exactHealth + "/" + maxHp + ")"; } else { result = "(" + (100 * ratio) / health + "%)"; } return withColorTag ? ColorUtil.colorStartTag(0xff0000) + result : result; }
Example #19
Source File: TMorph.java From plugins with GNU General Public License v3.0 | 6 votes |
@Subscribe public void onSpotAnimationChanged(SpotAnimationChanged event) { final Actor actor = event.getActor(); if (actor.getSpotAnimation() == -1) { return; } if (config.graphicSwap() <= 0 && config.graphicTarget() <= 0 && config.globalGraphicSwap() > 0) { actor.setSpotAnimation(config.globalGraphicSwap()); } if (config.graphicSwap() > 0 && config.graphicTarget() > 0) { if (actor.getSpotAnimation() == config.graphicTarget()) { actor.setSpotAnimation(config.graphicSwap()); } } }
Example #20
Source File: XpPanel.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
static String buildXpTrackerUrl(final Actor player, final Skill skill) { if (player == null) { return ""; } return new HttpUrl.Builder() .scheme("https") .host("runelite.net") .addPathSegment("xp") .addPathSegment("show") .addPathSegment(skill.getName().toLowerCase()) .addPathSegment(player.getName()) .addPathSegment("1week") .addPathSegment("now") .build() .toString(); }
Example #21
Source File: OpponentInfoPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
@Subscribe private void onInteractingChanged(InteractingChanged event) { if (event.getSource() != client.getLocalPlayer()) { return; } Actor opponent = event.getTarget(); if (opponent == null) { lastTime = Instant.now(); return; } lastOpponent = opponent; }
Example #22
Source File: TMorph.java From plugins with GNU General Public License v3.0 | 6 votes |
@Subscribe public void onAnimationChanged(AnimationChanged event) { final Actor actor = event.getActor(); if (actor.getAnimation() == -1) { return; } if (config.animationTarget() <= 0 && config.animationSwap() <= 0 && config.globalAnimSwap() > 0) { actor.setAnimation(config.globalAnimSwap()); } if (config.animationTarget() > 0 && config.animationSwap() > 0) { if (actor.getAnimation() == config.animationTarget()) { actor.setAnimation(config.animationSwap()); } } }
Example #23
Source File: CombatCounter.java From plugins with GNU General Public License v3.0 | 6 votes |
@Subscribe private void onHitsplatApplied(HitsplatApplied event) { Actor actor = event.getActor(); if (!(actor instanceof NPC)) { return; } NPC npc = (NPC) actor; if (!this.npcDamageMap.containsKey(npc)) { return; } Hitsplat splat = event.getHitsplat(); NPCDamageCounter dc = this.npcDamageMap.get(npc); dc.damage.add(splat.getAmount()); }
Example #24
Source File: XpDropOverlay.java From plugins with GNU General Public License v3.0 | 6 votes |
@Override public Dimension render(Graphics2D graphics) { if (plugin.getTickShow() > 0) { final Actor opponent = plugin.getLastOpponent(); if (opponent != null) { int offset = opponent.getLogicalHeight() + 50; String damageStr = String.valueOf(plugin.getDamage()); Point textLocation = opponent.getCanvasTextLocation(graphics, damageStr, offset); if (textLocation != null && plugin.getDamage() != 0) { OverlayUtil.renderTextLocation(graphics, textLocation, damageStr, config.getDamageColor()); } } } return null; }
Example #25
Source File: FishingPlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Subscribe public void onInteractingChanged(InteractingChanged event) { if (event.getSource() != client.getLocalPlayer()) { return; } final Actor target = event.getTarget(); if (!(target instanceof NPC)) { return; } final NPC npc = (NPC) target; FishingSpot spot = FishingSpot.findSpot(npc.getId()); if (spot == null) { return; } currentSpot = spot; }
Example #26
Source File: XpTrackerPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
@Subscribe void onStatChanged(StatChanged statChanged) { final Skill skill = statChanged.getSkill(); final int currentXp = statChanged.getXp(); final int currentLevel = statChanged.getLevel(); final VarPlayer startGoal = startGoalVarpForSkill(skill); final VarPlayer endGoal = endGoalVarpForSkill(skill); final int startGoalXp = startGoal != null ? client.getVar(startGoal) : -1; final int endGoalXp = endGoal != null ? client.getVar(endGoal) : -1; if (initializeTracker) { // This is the XP sync on login, wait until after login to begin counting return; } if (xpTrackerConfig.hideMaxed() && currentLevel >= Experience.MAX_REAL_LEVEL) { return; } final XpStateSingle state = xpState.getSkill(skill); state.setActionType(XpActionType.EXPERIENCE); final Actor interacting = client.getLocalPlayer().getInteracting(); if (interacting instanceof NPC && COMBAT.contains(skill)) { final NPC npc = (NPC) interacting; xpState.updateNpcExperience(skill, npc, npcManager.getHealth(npc.getId())); } final XpUpdateResult updateResult = xpState.updateSkill(skill, currentXp, startGoalXp, endGoalXp); xpPanel.updateSkillExperience(updateResult == XpUpdateResult.UPDATED, xpPauseState.isPaused(skill), skill, xpState.getSkillSnapshot(skill)); // Also update the total experience xpState.updateSkill(Skill.OVERALL, client.getOverallExperience(), -1, -1); xpPanel.updateTotal(xpState.getTotalSnapshot()); }
Example #27
Source File: PlayerComparisonOverlay.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Override public Dimension render(Graphics2D graphics) { if (!config.lookupOnInteraction()) { return null; } final Actor opponent = opponentInfoPlugin.getLastOpponent(); if (opponent == null) { return null; } // Don't try to look up NPC names if (!(opponent instanceof Player)) { return null; } final String opponentName = Text.removeTags(opponent.getName()); final HiscoreResult hiscoreResult = hiscoreManager.lookupAsync(opponentName, opponentInfoPlugin.getHiscoreEndpoint()); if (hiscoreResult == null) { return null; } panelComponent.getChildren().clear(); generateComparisonTable(panelComponent, hiscoreResult); return panelComponent.render(graphics); }
Example #28
Source File: RandomEventPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
@Subscribe private void onInteractingChanged(InteractingChanged event) { Actor source = event.getSource(); Actor target = event.getTarget(); Player player = client.getLocalPlayer(); // Check that the npc is interacting with the player and the player isn't interacting with the npc, so // that the notification doesn't fire from talking to other user's randoms if (player == null || target != player || player.getInteracting() == source || !(source instanceof NPC) || !EVENT_NPCS.contains(((NPC) source).getId())) { return; } log.debug("Random event spawn: {}", source.getName()); currentRandomEvent = (NPC) source; if (client.getTickCount() - lastNotificationTick > RANDOM_EVENT_TIMEOUT) { lastNotificationTick = client.getTickCount(); if (shouldNotify(currentRandomEvent.getId())) { notifier.notify("Random event spawned: " + currentRandomEvent.getName()); } } }
Example #29
Source File: IdleNotifierPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
private boolean checkInteractionIdle(Duration waitDuration, Player local) { if (lastInteract == null) { return false; } final Actor interact = local.getInteracting(); if (interact == null) { if (lastInteracting != null && Instant.now().compareTo(lastInteracting.plus(waitDuration)) >= 0 && lastCombatCountdown == 0) { lastInteract = null; lastInteracting = null; // prevent animation notifications from firing too lastAnimation = IDLE; lastAnimating = null; return true; } } else { lastInteracting = Instant.now(); } return false; }
Example #30
Source File: SpecialCounterPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Subscribe public void onInteractingChanged(InteractingChanged interactingChanged) { Actor source = interactingChanged.getSource(); Actor target = interactingChanged.getTarget(); if (lastSpecTick != client.getTickCount() || source != client.getLocalPlayer() || target == null) { return; } log.debug("Updating last spec target to {} (was {})", target.getName(), lastSpecTarget); lastSpecTarget = target; }