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

The following examples show how to use net.runelite.api.NPC#getTransformedComposition() . 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: 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 2
Source File: SlayerPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private boolean isTarget(NPC npc)
{
	if (targetNames.isEmpty())
	{
		return false;
	}

	String name = npc.getName();
	if (name == null)
	{
		return false;
	}

	name = name.toLowerCase();

	for (String target : targetNames)
	{
		if (name.contains(target))
		{
			NPCComposition composition = npc.getTransformedComposition();

			if (composition != null)
			{
				List<String> actions = Arrays.asList(composition.getActions());
				if (actions.contains("Attack") || actions.contains("Pick")) //Pick action is for zygomite-fungi
				{
					return true;
				}
			}
		}
	}
	return false;
}
 
Example 3
Source File: NpcAggroAreaPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private boolean isNpcMatch(NPC npc)
{
	NPCComposition composition = npc.getTransformedComposition();
	if (composition == null)
	{
		return false;
	}

	if (Strings.isNullOrEmpty(composition.getName()))
	{
		return false;
	}

	// Most NPCs stop aggroing when the player has more than double
	// its combat level.
	int playerLvl = client.getLocalPlayer().getCombatLevel();
	int npcLvl = composition.getCombatLevel();
	String npcName = composition.getName().toLowerCase();
	if (npcLvl > 0 && playerLvl > npcLvl * 2 && !isInWilderness(npc.getWorldLocation()))
	{
		return false;
	}

	for (String pattern : npcNamePatterns)
	{
		if (WildcardMatcher.matches(pattern, npcName))
		{
			return true;
		}
	}

	return false;
}
 
Example 4
Source File: MemorizedNpc.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
MemorizedNpc(NPC npc)
{
	this.npcName = npc.getName();
	this.npcIndex = npc.getIndex();
	this.possibleRespawnLocations = new ArrayList<>();
	this.respawnTime = -1;
	this.diedOnTick = -1;

	final NPCComposition composition = npc.getTransformedComposition();

	if (composition != null)
	{
		this.npcSize = composition.getSize();
	}
}