Java Code Examples for net.runelite.api.NPC#getTransformedDefinition()
The following examples show how to use
net.runelite.api.NPC#getTransformedDefinition() .
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 plugins with GNU General Public License v3.0 | 6 votes |
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 2
Source File: MemorizedNpc.java From plugins with GNU General Public License v3.0 | 6 votes |
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 3
Source File: CombatCounter.java From plugins with GNU General Public License v3.0 | 5 votes |
private int calculateDistance(Player p, NPC npc) { int size = 1; NPCDefinition comp = npc.getTransformedDefinition(); if (comp != null) { size = comp.getSize(); } WorldPoint wpPlayer = p.getWorldLocation(); WorldPoint wpNPC = npc.getWorldLocation(); int distance = wpNPC.distanceTo(wpPlayer); if (size > 1) { for (int x = 0; x < size; x++) { for (int y = 0; y < size; y++) { WorldPoint wpNPCB = WorldPoint.fromRegion(wpNPC.getRegionID(), wpNPC.getRegionX() + x, wpNPC.getRegionY() + y, wpNPC.getPlane()); int distB = wpNPCB.distanceTo(wpPlayer); if (distB >= 1 && distB < distance) { distance = distB; } } } } return distance; }
Example 4
Source File: NpcAggroAreaPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
private boolean isNpcMatch(NPC npc) { NPCDefinition composition = npc.getTransformedDefinition(); 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. final Player localPlayer = client.getLocalPlayer(); if (localPlayer == null) { return false; } final int playerLvl = localPlayer.getCombatLevel(); final int npcLvl = composition.getCombatLevel(); final 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 5
Source File: WikiPlugin.java From plugins with GNU General Public License v3.0 | 4 votes |
@Subscribe private void onMenuOptionClicked(MenuOptionClicked ev) { if (ev.getMenuOpcode() == MenuOpcode.RUNELITE) { checkQuestClicked(ev); } if (!wikiSelected) { return; } onDeselect(); client.setSpellSelected(false); ev.consume(); String type; int id; String name; WorldPoint location; switch (ev.getMenuOpcode()) { case RUNELITE: case CANCEL: return; case ITEM_USE_ON_WIDGET: case SPELL_CAST_ON_GROUND_ITEM: { type = "item"; id = itemManager.canonicalize(ev.getIdentifier()); name = itemManager.getItemDefinition(id).getName(); location = null; break; } case SPELL_CAST_ON_NPC: { type = "npc"; NPC npc = client.getCachedNPCs()[ev.getIdentifier()]; NPCDefinition nc = npc.getTransformedDefinition(); id = nc.getId(); name = nc.getName(); location = npc.getWorldLocation(); break; } case SPELL_CAST_ON_GAME_OBJECT: { type = "object"; ObjectDefinition lc = client.getObjectDefinition(ev.getIdentifier()); if (lc.getImpostorIds() != null) { lc = lc.getImpostor(); } id = lc.getId(); name = lc.getName(); location = WorldPoint.fromScene(client, ev.getParam0(), ev.getParam1(), client.getPlane()); break; } case SPELL_CAST_ON_WIDGET: { Widget w = getWidget(ev.getParam1(), ev.getParam0()); if (w.getType() == WidgetType.GRAPHIC && w.getItemId() != -1) { type = "item"; id = itemManager.canonicalize(w.getItemId()); name = itemManager.getItemDefinition(id).getName(); location = null; break; } } // fallthrough default: log.info("Unknown menu option: {} {} {}", ev, ev.getMenuOpcode(), ev.getMenuOpcode() == MenuOpcode.CANCEL); return; } name = Text.removeTags(name); HttpUrl.Builder urlBuilder = WIKI_BASE.newBuilder(); urlBuilder.addPathSegments("w/Special:Lookup") .addQueryParameter("type", type) .addQueryParameter("id", "" + id) .addQueryParameter("name", name) .addQueryParameter(UTM_SOURCE_KEY, UTM_SOURCE_VALUE); if (location != null) { urlBuilder.addQueryParameter("x", "" + location.getX()) .addQueryParameter("y", "" + location.getY()) .addQueryParameter("plane", "" + location.getPlane()); } HttpUrl url = urlBuilder.build(); LinkBrowser.browse(url.toString()); }
Example 6
Source File: TargetClickboxOverlay.java From plugins with GNU General Public License v3.0 | 4 votes |
private void renderNpcOverlay(Graphics2D graphics, NPC actor, Color color) { switch (config.renderStyle()) { case SOUTH_WEST_TILE: LocalPoint lp1 = LocalPoint.fromWorld(client, actor.getWorldLocation()); if (lp1 == null) { return; } Polygon tilePoly1 = Perspective.getCanvasTilePoly(client, lp1); OverlayUtil.renderPolygon(graphics, tilePoly1, color); break; case TILE: int size = 1; NPCDefinition composition = actor.getTransformedDefinition(); if (composition != null) { size = composition.getSize(); } LocalPoint lp = actor.getLocalLocation(); Polygon tilePoly = Perspective.getCanvasTileAreaPoly(client, lp, size); OverlayUtil.renderPolygon(graphics, tilePoly, color); break; case HULL: Shape objectClickbox = actor.getConvexHull(); if (objectClickbox == null) { return; } OverlayUtil.renderPolygon(graphics, objectClickbox, color); break; case THIN_OUTLINE: modelOutliner.drawOutline(actor, 1, color); break; case OUTLINE: modelOutliner.drawOutline(actor, 2, color); break; case THIN_GLOW: modelOutliner.drawOutline(actor, 4, color, TRANSPARENT); break; case GLOW: modelOutliner.drawOutline(actor, 8, color, TRANSPARENT); break; case TRUE_LOCATIONS: size = 1; composition = actor.getTransformedDefinition(); if (composition != null) { size = composition.getSize(); } WorldPoint wp = actor.getWorldLocation(); getSquare(wp, size).forEach(square -> drawTile(graphics, square, color, 1, 255, 50)); break; } if (config.drawNames()) { String npcName = Text.removeTags(actor.getName()); Point textLocation = actor.getCanvasTextLocation(graphics, npcName, actor.getLogicalHeight() + 40); if (textLocation != null) { OverlayUtil.renderTextLocation(graphics, textLocation, npcName, color); } } }