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

The following examples show how to use net.runelite.api.NPC#getId() . 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: 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 2
Source File: CorpPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
private void onNpcSpawned(NpcSpawned npcSpawned)
{
	NPC npc = npcSpawned.getNpc();

	switch (npc.getId())
	{
		case NpcID.CORPOREAL_BEAST:
			log.debug("Corporeal beast spawn: {}", npc);
			corp = npc;
			yourDamage = 0;
			totalDamage = 0;
			players.clear();
			break;
		case NpcID.DARK_ENERGY_CORE:
			core = npc;
			break;
	}
}
 
Example 3
Source File: MemorizedNpc.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
MemorizedNpc(final NPC npc)
{
	this.npcNames = new HashSet<>();
	this.npcNames.add(npc.getName());
	this.npcIndex = npc.getIndex();
	this.npcId = npc.getId();
	this.possibleRespawnLocations = new ArrayList<>();
	this.respawnTime = -1;
	this.diedOnTick = -1;

	final NPCDefinition composition = npc.getTransformedDefinition();

	if (composition != null)
	{
		this.npcSize = composition.getSize();
	}
}
 
Example 4
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 5
Source File: CorpPlugin.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Subscribe
public void onNpcSpawned(NpcSpawned npcSpawned)
{
	NPC npc = npcSpawned.getNpc();

	switch (npc.getId())
	{
		case NpcID.CORPOREAL_BEAST:
			log.debug("Corporeal beast spawn: {}", npc);
			corp = npc;
			yourDamage = 0;
			totalDamage = 0;
			players.clear();
			break;
		case NpcID.DARK_ENERGY_CORE:
			core = npc;
			break;
	}
}
 
Example 6
Source File: BasicBossSwapper.java    From ExternalPlugins with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
public void onNpcSpawned(NpcSpawned event)
{
	final NPC npc = event.getNpc();

	switch (npc.getId())
	{
		case NpcID.NYLOCAS_VASILIAS:
		case NpcID.NYLOCAS_VASILIAS_8355:
		case NpcID.NYLOCAS_VASILIAS_8356:
		case NpcID.NYLOCAS_VASILIAS_8357:
			nylo = npc;
			break;
	}
}
 
Example 7
Source File: DevToolsPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Subscribe
public void onMenuEntryAdded(MenuEntryAdded event)
{
	if (!examine.isActive())
	{
		return;
	}

	MenuAction action = MenuAction.of(event.getType());

	if (EXAMINE_MENU_ACTIONS.contains(action))
	{
		MenuEntry[] entries = client.getMenuEntries();
		MenuEntry entry = entries[entries.length - 1];

		final int identifier = event.getIdentifier();
		String info = "ID: ";

		if (action == MenuAction.EXAMINE_NPC)
		{
			NPC npc = client.getCachedNPCs()[identifier];
			info += npc.getId();
		}
		else
		{
			info += identifier;

			if (action == MenuAction.EXAMINE_OBJECT)
			{
				WorldPoint point = WorldPoint.fromScene(client, entry.getParam0(), entry.getParam1(), client.getPlane());
				info += " X: " + point.getX() + " Y: " + point.getY();
			}
		}

		entry.setTarget(entry.getTarget() + " " + ColorUtil.prependColorTag("(" + info + ")", JagexColors.MENU_TARGET));
		client.setMenuEntries(entries);
	}
}
 
Example 8
Source File: DriftNetPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Subscribe
public void onNpcSpawned(NpcSpawned event)
{
	final NPC npc = event.getNpc();
	if (npc.getId() == NpcID.FISH_SHOAL)
	{
		fish.add(npc);
	}
}
 
Example 9
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 10
Source File: LootManager.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Subscribe
public void onNpcChanged(NpcChanged npcChanged)
{
	final NPC npc = npcChanged.getNpc();
	if (npc.getId() == NpcID.THE_NIGHTMARE_9433)
	{
		delayedLootNpc = npc;
		delayedLootTickLimit = 15;
	}
}
 
Example 11
Source File: LootManager.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Subscribe
public void onAnimationChanged(AnimationChanged e)
{
	if (!(e.getActor() instanceof NPC))
	{
		return;
	}

	final NPC npc = (NPC) e.getActor();
	int id = npc.getId();

	// We only care about certain NPCs
	final Integer deathAnim = NPC_DEATH_ANIMATIONS.get(id);

	// Current animation is death animation?
	if (deathAnim != null && deathAnim == npc.getAnimation())
	{
		if (id == NpcID.CAVE_KRAKEN)
		{
			// Big Kraken drops loot wherever player is standing when animation starts.
			krakenPlayerLocation = client.getLocalPlayer().getWorldLocation();
		}
		else
		{
			// These NPCs drop loot on death animation, which is right now.
			processNpcLoot(npc);
		}
	}
}
 
Example 12
Source File: BasicBossSwapper.java    From ExternalPlugins with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
public void onNpcDespawned(NpcDespawned event)
{
	final NPC npc = event.getNpc();

	if (npc.getId() == NpcID.NYLOCAS_VASILIAS)
	{
		nylo = null;
	}
}
 
Example 13
Source File: DriftNetPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
public void onNpcSpawned(NpcSpawned event)
{
	final NPC npc = event.getNpc();
	if (npc.getId() == NpcID.FISH_SHOAL)
	{
		fish.add(npc);
	}
}
 
Example 14
Source File: RunecraftPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
private void onNpcSpawned(NpcSpawned event)
{
	final NPC npc = event.getNpc();

	if (npc.getId() == NpcID.DARK_MAGE)
	{
		darkMage = npc;
	}
}
 
Example 15
Source File: TelekineticRoom.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
private void onNpcSpawned(NpcSpawned event)
{
	NPC npc = event.getNpc();

	if (npc.getId() == NpcID.MAZE_GUARDIAN)
	{
		guardian = npc;
	}
}
 
Example 16
Source File: ZalcanoUtil.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
void manuallyFindZalcano()
{
	for (NPC npc : client.getNpcs())
	{
		if (npc != null)
		{
			if (npc.getId() == NpcID.ZALCANO)
			{
				plugin.setZalcano(npc);
			}
		}
	}
}
 
Example 17
Source File: TelekineticRoom.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Subscribe
public void onNpcSpawned(NpcSpawned event)
{
	NPC npc = event.getNpc();

	if (npc.getId() == NpcID.MAZE_GUARDIAN)
	{
		guardian = npc;
	}
}
 
Example 18
Source File: DevToolsPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
private void onMenuEntryAdded(MenuEntryAdded entry)
{
	if (!examine.isActive())
	{
		return;
	}

	MenuOpcode action = MenuOpcode.of(entry.getOpcode());

	if (EXAMINE_MENU_ACTIONS.contains(action))
	{
		final int identifier = entry.getIdentifier();
		String info = "ID: ";

		if (action == MenuOpcode.EXAMINE_NPC)
		{
			NPC npc = client.getCachedNPCs()[identifier];
			info += npc.getId();
		}
		else
		{
			info += identifier;

			if (action == MenuOpcode.EXAMINE_OBJECT)
			{
				WorldPoint point = WorldPoint.fromScene(client, entry.getParam0(), entry.getParam1(), client.getPlane());
				info += " X: " + point.getX() + " Y: " + point.getY();
			}
		}

		entry.setTarget(entry.getTarget() + " " + ColorUtil.prependColorTag("(" + info + ")", JagexColors.MENU_TARGET));
		entry.setModified();
	}
}
 
Example 19
Source File: SpecialCounterPlugin.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
@Subscribe
public void onHitsplatApplied(HitsplatApplied hitsplatApplied)
{
	Actor target = hitsplatApplied.getActor();
	Hitsplat hitsplat = hitsplatApplied.getHitsplat();
	Hitsplat.HitsplatType hitsplatType = hitsplat.getHitsplatType();
	// Ignore all hitsplats other than mine
	if (!hitsplat.isMine() || target == client.getLocalPlayer())
	{
		return;
	}

	log.debug("Hitsplat target: {} spec target: {}", target, lastSpecTarget);

	// If waiting for a spec, ignore hitsplats not on the actor we specced
	if (lastSpecTarget != null && lastSpecTarget != target)
	{
		return;
	}

	boolean wasSpec = lastSpecTarget != null;
	lastSpecTarget = null;

	if (!(target instanceof NPC))
	{
		return;
	}

	NPC npc = (NPC) target;
	int interactingId = npc.getId();

	// If this is a new NPC reset the counters
	if (!interactedNpcIds.contains(interactingId))
	{
		removeCounters();
		addInteracting(interactingId);
	}

	if (wasSpec && specialWeapon != null && hitsplat.getAmount() > 0)
	{
		int hit = getHit(specialWeapon, hitsplat);

		updateCounter(specialWeapon, null, hit);

		if (!party.getMembers().isEmpty())
		{
			final SpecialCounterUpdate specialCounterUpdate = new SpecialCounterUpdate(interactingId, specialWeapon, hit);
			specialCounterUpdate.setMemberId(party.getLocalMember().getMemberId());
			wsClient.send(specialCounterUpdate);
		}
	}
}
 
Example 20
Source File: SpecialCounterPlugin.java    From runelite with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Subscribe
public void onHitsplatApplied(HitsplatApplied hitsplatApplied)
{
	Actor target = hitsplatApplied.getActor();
	Hitsplat hitsplat = hitsplatApplied.getHitsplat();
	Hitsplat.HitsplatType hitsplatType = hitsplat.getHitsplatType();
	// Ignore all hitsplats other than mine
	if (!hitsplat.isMine() || target == client.getLocalPlayer())
	{
		return;
	}

	log.debug("Hitsplat target: {} spec target: {}", target, lastSpecTarget);

	// If waiting for a spec, ignore hitsplats not on the actor we specced
	if (lastSpecTarget != null && lastSpecTarget != target)
	{
		return;
	}

	boolean wasSpec = lastSpecTarget != null;
	lastSpecTarget = null;

	if (!(target instanceof NPC))
	{
		return;
	}

	NPC npc = (NPC) target;
	int interactingId = npc.getId();

	// If this is a new NPC reset the counters
	if (!interactedNpcIds.contains(interactingId))
	{
		removeCounters();
		addInteracting(interactingId);
	}

	if (wasSpec && specialWeapon != null && hitsplat.getAmount() > 0)
	{
		int hit = getHit(specialWeapon, hitsplat);

		updateCounter(specialWeapon, null, hit);

		if (!party.getMembers().isEmpty())
		{
			final SpecialCounterUpdate specialCounterUpdate = new SpecialCounterUpdate(interactingId, specialWeapon, hit);
			specialCounterUpdate.setMemberId(party.getLocalMember().getMemberId());
			wsClient.send(specialCounterUpdate);
		}
	}
}