Java Code Examples for net.runelite.api.NPC#isDead()

The following examples show how to use net.runelite.api.NPC#isDead() . 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: SpecialCounterPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
private void onNpcDespawned(NpcDespawned npcDespawned)
{
	NPC actor = npcDespawned.getNpc();
	
	// if the NPC despawns before the hitsplat is shown
	if (lastSpecTarget == actor)
	{
		lastSpecTarget = null;
	}


	if (actor.isDead() && interactedNpcIds.contains(actor.getId()))
	{
		removeCounters();
	}
}
 
Example 2
Source File: TimersPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
private void onNpcDespawned(NpcDespawned npcDespawned)
{
	NPC npc = npcDespawned.getNpc();

	if (!npc.isDead())
	{
		return;
	}

	int npcId = npc.getId();

	if (npcId == NpcID.ZOMBIFIED_SPAWN || npcId == NpcID.ZOMBIFIED_SPAWN_8063)
	{
		removeGameTimer(ICEBARRAGE);
	}
}
 
Example 3
Source File: NpcMinimapOverlay.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
private void renderNpcOverlay(Graphics2D graphics, NPC actor, String name, Color color)
{
	NPCDefinition npcDefinition = actor.getTransformedDefinition();
	if (npcDefinition == null || !npcDefinition.isInteractible()
		|| (actor.isDead() && config.ignoreDeadNpcs()))
	{
		return;
	}

	final Point minimapLocation = actor.getMinimapLocation();

	if (minimapLocation != null)
	{
		OverlayUtil.renderMinimapLocation(graphics, minimapLocation, color.darker());

		if (config.drawMinimapNames())
		{
			OverlayUtil.renderTextLocation(graphics, minimapLocation, name, color);
		}
	}
}
 
Example 4
Source File: XpTrackerPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
private void onNpcDespawned(NpcDespawned event)
{
	final NPC npc = event.getNpc();

	if (!npc.isDead())
	{
		return;
	}

	for (Skill skill : COMBAT)
	{
		final XpUpdateResult updateResult = xpState.updateNpcKills(skill, npc, npcManager.getHealth(npc.getId()));
		final boolean updated = XpUpdateResult.UPDATED.equals(updateResult);
		xpPanel.updateSkillExperience(updated, xpPauseState.isPaused(skill), skill, xpState.getSkillSnapshot(skill));
	}

	xpPanel.updateTotal(xpState.getTotalSnapshot());
}
 
Example 5
Source File: BossTimersPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
private void onNpcDespawned(NpcDespawned npcDespawned)
{
	NPC npc = npcDespawned.getNpc();

	if (!npc.isDead())
	{
		return;
	}

	int npcId = npc.getId();

	Boss boss = Boss.find(npcId);

	if (boss == null)
	{
		return;
	}

	// remove existing timer
	infoBoxManager.removeIf(t -> t instanceof RespawnTimer && ((RespawnTimer) t).getBoss() == boss);

	RespawnTimer timer = new RespawnTimer(boss, itemManager.getImage(boss.getItemSpriteId()), this);
	timer.setTooltip(npc.getName());
	infoBoxManager.addInfoBox(timer);
}
 
Example 6
Source File: TimersPlugin.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Subscribe
public void onNpcDespawned(NpcDespawned npcDespawned)
{
	NPC npc = npcDespawned.getNpc();

	if (!npc.isDead())
	{
		return;
	}

	int npcId = npc.getId();

	if (npcId == NpcID.ZOMBIFIED_SPAWN || npcId == NpcID.ZOMBIFIED_SPAWN_8063)
	{
		removeGameTimer(ICEBARRAGE);
	}
}
 
Example 7
Source File: NpcMinimapOverlay.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void renderNpcOverlay(Graphics2D graphics, NPC actor, String name, Color color)
{
	NPCComposition npcComposition = actor.getTransformedComposition();
	if (npcComposition == null || !npcComposition.isInteractible()
		|| (actor.isDead() && config.ignoreDeadNpcs()))
	{
		return;
	}

	Point minimapLocation = actor.getMinimapLocation();
	if (minimapLocation != null)
	{
		OverlayUtil.renderMinimapLocation(graphics, minimapLocation, color.darker());

		if (config.drawMinimapNames())
		{
			OverlayUtil.renderTextLocation(graphics, minimapLocation, name, color);
		}
	}
}
 
Example 8
Source File: XpTrackerPlugin.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Subscribe
public void onNpcDespawned(NpcDespawned event)
{
	final NPC npc = event.getNpc();

	if (!npc.isDead())
	{
		return;
	}

	for (Skill skill : COMBAT)
	{
		final XpUpdateResult updateResult = xpState.updateNpcKills(skill, npc, npcManager.getHealth(npc.getId()));
		final boolean updated = XpUpdateResult.UPDATED.equals(updateResult);
		xpPanel.updateSkillExperience(updated, xpPauseState.isPaused(skill), skill, xpState.getSkillSnapshot(skill));
	}

	xpPanel.updateTotal(xpState.getTotalSnapshot());
}
 
Example 9
Source File: CorpPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
private void onNpcDespawned(NpcDespawned npcDespawned)
{
	NPC npc = npcDespawned.getNpc();

	if (npc == corp)
	{
		log.debug("Corporeal beast despawn: {}", npc);
		corp = null;
		players.clear();

		if (npc.isDead())
		{
			// Show kill stats
			String message = new ChatMessageBuilder()
				.append(ChatColorType.NORMAL)
				.append("Corporeal Beast: Your damage: ")
				.append(ChatColorType.HIGHLIGHT)
				.append(Integer.toString(yourDamage))
				.append(ChatColorType.NORMAL)
				.append(", Total damage: ")
				.append(ChatColorType.HIGHLIGHT)
				.append(Integer.toString(totalDamage))
				.build();

			chatMessageManager.queue(QueuedMessage.builder()
				.type(ChatMessageType.CONSOLE)
				.runeLiteFormattedMessage(message)
				.build());
		}
	}
	else if (npc == core)
	{
		core = null;
	}
}
 
Example 10
Source File: DpsCounterPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
public void onNpcDespawned(NpcDespawned npcDespawned)
{
	NPC npc = npcDespawned.getNpc();

	if (npc.isDead() && BOSSES.contains(npc.getId()))
	{
		log.debug("Boss has died!");

		if (dpsConfig.autopause())
		{
			pause();
		}
	}
}
 
Example 11
Source File: SpecialCounterPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Subscribe
public void onNpcDespawned(NpcDespawned npcDespawned)
{
	NPC actor = npcDespawned.getNpc();

	if (lastSpecTarget == actor)
	{
		lastSpecTarget = null;
	}

	if (actor.isDead() && interactedNpcIds.contains(actor.getId()))
	{
		removeCounters();
	}
}
 
Example 12
Source File: CorpPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Subscribe
public void onNpcDespawned(NpcDespawned npcDespawned)
{
	NPC npc = npcDespawned.getNpc();

	if (npc == corp)
	{
		log.debug("Corporeal beast despawn: {}", npc);
		corp = null;
		players.clear();

		if (npc.isDead())
		{
			// Show kill stats
			String message = new ChatMessageBuilder()
				.append(ChatColorType.NORMAL)
				.append("Corporeal Beast: Your damage: ")
				.append(ChatColorType.HIGHLIGHT)
				.append(Integer.toString(yourDamage))
				.append(ChatColorType.NORMAL)
				.append(", Total damage: ")
				.append(ChatColorType.HIGHLIGHT)
				.append(Integer.toString(totalDamage))
				.build();

			chatMessageManager.queue(QueuedMessage.builder()
				.type(ChatMessageType.CONSOLE)
				.runeLiteFormattedMessage(message)
				.build());
		}
	}
	else if (npc == core)
	{
		core = null;
	}
}
 
Example 13
Source File: DpsCounterPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Subscribe
public void onNpcDespawned(NpcDespawned npcDespawned)
{
	NPC npc = npcDespawned.getNpc();

	if (npc.isDead() && BOSSES.contains(npc.getId()))
	{
		log.debug("Boss has died!");

		if (dpsConfig.autopause())
		{
			pause();
		}
	}
}
 
Example 14
Source File: BossTimersPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Subscribe
public void onNpcDespawned(NpcDespawned npcDespawned)
{
	NPC npc = npcDespawned.getNpc();

	if (!npc.isDead())
	{
		return;
	}

	int npcId = npc.getId();

	Boss boss = Boss.find(npcId);

	if (boss == null)
	{
		return;
	}

	// remove existing timer
	infoBoxManager.removeIf(t -> t instanceof RespawnTimer && ((RespawnTimer) t).getBoss() == boss);

	log.debug("Creating spawn timer for {} ({} seconds)", npc.getName(), boss.getSpawnTime());

	RespawnTimer timer = new RespawnTimer(boss, itemManager.getImage(boss.getItemSpriteId()), this);
	timer.setTooltip(npc.getName());
	infoBoxManager.addInfoBox(timer);
}
 
Example 15
Source File: NpcIndicatorsPlugin.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
@Subscribe
void onMenuEntryAdded(MenuEntryAdded event)
{
	int type = event.getOpcode();

	if (type >= MENU_ACTION_DEPRIORITIZE_OFFSET)
	{
		type -= MENU_ACTION_DEPRIORITIZE_OFFSET;
	}

	final MenuOpcode menuOpcode = MenuOpcode.of(type);

	if (NPC_MENU_ACTIONS.contains(menuOpcode))
	{
		NPC npc = client.getCachedNPCs()[event.getIdentifier()];

		Color color = null;
		if (npc.isDead())
		{
			color = config.deadNpcMenuColor();
		}

		if (color == null && highlightedNpcs.contains(npc) && config.highlightMenuNames() && (!npc.isDead() || !config.ignoreDeadNpcs()))
		{
			color = config.getHighlightColor();
		}

		if (color != null)
		{
			final String target = ColorUtil.prependColorTag(Text.removeTags(event.getTarget()), color);
			event.setTarget(target);
			event.setModified();
		}
	}
	else if (type == MenuOpcode.EXAMINE_NPC.getId() && client.isKeyPressed(KeyCode.KC_SHIFT))
	{
		// Add tag option
		client.insertMenuItem(
			highlightedNpcs.stream().anyMatch(npc -> npc.getIndex() == event.getIdentifier()) ? UNTAG : TAG,
			event.getTarget(),
			MenuOpcode.RUNELITE.getId(),
			event.getIdentifier(),
			event.getParam0(),
			event.getParam1(),
			false
		);
	}
}
 
Example 16
Source File: LootManager.java    From runelite with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Subscribe
public void onNpcDespawned(NpcDespawned npcDespawned)
{
	final NPC npc = npcDespawned.getNpc();

	if (npc == delayedLootNpc)
	{
		delayedLootNpc = null;
		delayedLootTickLimit = 0;
	}

	if (!npc.isDead())
	{
		int id = npc.getId();
		switch (id)
		{
			case NpcID.GARGOYLE:
			case NpcID.GARGOYLE_413:
			case NpcID.GARGOYLE_1543:
			case NpcID.MARBLE_GARGOYLE:
			case NpcID.MARBLE_GARGOYLE_7408:
			case NpcID.DUSK_7888:
			case NpcID.DUSK_7889:

			case NpcID.ROCKSLUG:
			case NpcID.ROCKSLUG_422:
			case NpcID.GIANT_ROCKSLUG:

			case NpcID.SMALL_LIZARD:
			case NpcID.SMALL_LIZARD_463:
			case NpcID.DESERT_LIZARD:
			case NpcID.DESERT_LIZARD_460:
			case NpcID.DESERT_LIZARD_461:
			case NpcID.LIZARD:

			case NpcID.ZYGOMITE:
			case NpcID.ZYGOMITE_1024:
			case NpcID.ANCIENT_ZYGOMITE:

				// these monsters die with >0 hp, so we just look for coincident
				// item spawn with despawn
				break;
			default:
				return;
		}
	}

	processNpcLoot(npc);
}