Search in sources :

Example 1 with Player

use of net.runelite.api.Player in project runelite by runelite.

the class CannonPlugin method onGameObjectSpawned.

@Subscribe
public void onGameObjectSpawned(GameObjectSpawned event) {
    GameObject gameObject = event.getGameObject();
    Player localPlayer = client.getLocalPlayer();
    if (gameObject.getId() == CANNON_BASE && !cannonPlaced) {
        if (localPlayer.getWorldLocation().distanceTo(gameObject.getWorldLocation()) <= 2 && localPlayer.getAnimation() == AnimationID.BURYING_BONES) {
            cannonPosition = gameObject.getWorldLocation();
            cannon = gameObject;
        }
    }
}
Also used : Player(net.runelite.api.Player) GameObject(net.runelite.api.GameObject) Subscribe(com.google.common.eventbus.Subscribe)

Example 2 with Player

use of net.runelite.api.Player in project runelite by runelite.

the class DevToolsOverlay method renderPlayers.

private void renderPlayers(Graphics2D graphics) {
    List<Player> players = client.getPlayers();
    Player local = client.getLocalPlayer();
    for (Player p : players) {
        if (p != local) {
            String text = p.getName() + " (A: " + p.getAnimation() + ") (G: " + p.getGraphic() + ")";
            OverlayUtil.renderActorOverlay(graphics, p, text, BLUE);
        }
    }
    String text = local.getName() + " (A: " + local.getAnimation() + ") (G: " + local.getGraphic() + ")";
    OverlayUtil.renderActorOverlay(graphics, local, text, CYAN);
    renderPlayerWireframe(graphics, local, CYAN);
}
Also used : Player(net.runelite.api.Player)

Example 3 with Player

use of net.runelite.api.Player in project runelite by runelite.

the class BarrowsOverlay method render.

@Override
public Dimension render(Graphics2D graphics) {
    Player local = client.getLocalPlayer();
    // tunnels are only on z=0
    if (!plugin.getWalls().isEmpty() && client.getPlane() == 0 && config.showMinimap()) {
        // NPC yellow dot
        List<NPC> npcs = client.getNpcs();
        for (NPC npc : npcs) {
            net.runelite.api.Point minimapLocation = npc.getMinimapLocation();
            if (minimapLocation != null) {
                graphics.setColor(Color.yellow);
                graphics.fillOval(minimapLocation.getX(), minimapLocation.getY(), 4, 4);
            }
        }
        // Render barrows walls/doors
        renderObjects(graphics, local);
        // Player white dot
        graphics.setColor(Color.white);
        graphics.fillRect(local.getMinimapLocation().getX(), local.getMinimapLocation().getY(), 3, 3);
    } else if (config.showBrotherLoc()) {
        renderBarrowsBrothers(graphics);
    }
    return null;
}
Also used : NPC(net.runelite.api.NPC) Player(net.runelite.api.Player)

Example 4 with Player

use of net.runelite.api.Player in project runelite by runelite.

the class XpTrackerPlugin method onGameStateChanged.

@Subscribe
public void onGameStateChanged(GameStateChanged event) {
    if (event.getGameState() == GameState.LOGGED_IN) {
        // LOGGED_IN is triggered between region changes too.
        // Check that the username changed or the world type changed.
        World world = worlds.findWorld(client.getWorld());
        if (world == null) {
            log.warn("Logged into nonexistent world {}?", client.getWorld());
            return;
        }
        XpWorldType type = worldSetToType(world.getTypes());
        if (!Objects.equals(client.getUsername(), lastUsername) || lastWorldType != type) {
            // Reset
            log.debug("World change: {} -> {}, {} -> {}", lastUsername, client.getUsername(), lastWorldType, type);
            lastUsername = client.getUsername();
            lastWorldType = type;
            xpPanel.resetAllInfoBoxes();
        }
    } else if (event.getGameState() == GameState.LOGIN_SCREEN) {
        Player local = client.getLocalPlayer();
        String username = local != null ? local.getName() : null;
        if (username != null) {
            log.debug("Submitting xp track for {}", username);
            executor.submit(() -> {
                try {
                    xpClient.update(username);
                } catch (IOException ex) {
                    log.warn("error submitting xp track", ex);
                }
            });
        }
    }
}
Also used : Player(net.runelite.api.Player) IOException(java.io.IOException) World(net.runelite.http.api.worlds.World) Subscribe(com.google.common.eventbus.Subscribe)

Example 5 with Player

use of net.runelite.api.Player in project runelite by runelite.

the class HunterPlugin method onGameObjectSpawned.

@Subscribe
public void onGameObjectSpawned(GameObjectSpawned event) {
    final GameObject gameObject = event.getGameObject();
    final HunterTrap myTrap = traps.get(gameObject.getWorldLocation());
    final Player localPlayer = client.getLocalPlayer();
    switch(gameObject.getId()) {
        // Deadfall trap placed
        case ObjectID.DEADFALL:
        case // Maniacal monkey trap placed
        ObjectID.MONKEY_TRAP:
            // If player is right next to "object" trap assume that player placed the trap
            if (localPlayer.getWorldLocation().distanceTo(gameObject.getWorldLocation()) <= 1) {
                log.debug("Trap placed by \"{}\" on {}", localPlayer.getName(), gameObject.getWorldLocation());
                traps.put(gameObject.getWorldLocation(), new HunterTrap(gameObject));
                lastActionTime = Instant.now();
            }
            break;
        // Imp box placed
        case ObjectID.MAGIC_BOX:
        // Box trap placed
        case ObjectID.BOX_TRAP_9380:
        // Bird snare placed
        case ObjectID.BIRD_SNARE_9345:
        // Net trap placed at green sallys
        case ObjectID.NET_TRAP_9343:
        // Net trap placed at orange sallys
        case ObjectID.NET_TRAP:
        // Net trap placed at red sallys
        case ObjectID.NET_TRAP_8992:
        case // Net trap placed at black sallys
        ObjectID.NET_TRAP_9002:
            // Look for players that are on the same tile
            final PlayerQuery playerQuery = new PlayerQuery().atLocalLocation(gameObject.getLocalLocation());
            final List<Player> possiblePlayers = Arrays.asList(queryRunner.runQuery(playerQuery));
            // If the player is on that tile, assume he is the one that placed the trap
            if (possiblePlayers.contains(localPlayer)) {
                log.debug("Trap placed by \"{}\" on {}", localPlayer.getName(), localPlayer.getWorldLocation());
                traps.put(gameObject.getWorldLocation(), new HunterTrap(gameObject));
                lastActionTime = Instant.now();
            }
            break;
        // Imp caught
        case ObjectID.MAGIC_BOX_19226:
        // Black chinchompa caught
        case ObjectID.SHAKING_BOX:
        // Grey chinchompa caught
        case ObjectID.SHAKING_BOX_9382:
        // Red chinchompa caught
        case ObjectID.SHAKING_BOX_9383:
        // Prickly kebbit caught
        case ObjectID.BOULDER_20648:
        // Sabre-tooth kebbit caught
        case ObjectID.BOULDER_20649:
        // Barb-tailed kebbit caught
        case ObjectID.BOULDER_20650:
        // Wild kebbit caught
        case ObjectID.BOULDER_20651:
        // Crimson swift caught
        case ObjectID.BIRD_SNARE_9373:
        // Cerulean twitch caught
        case ObjectID.BIRD_SNARE_9375:
        // Golden warbler caught
        case ObjectID.BIRD_SNARE_9377:
        // Copper longtail caught
        case ObjectID.BIRD_SNARE_9379:
        // Tropical wagtail caught
        case ObjectID.BIRD_SNARE_9348:
        // Green sally caught
        case ObjectID.NET_TRAP_9004:
        // Red sally caught
        case ObjectID.NET_TRAP_8986:
        // Orange sally caught
        case ObjectID.NET_TRAP_8734:
        // Black sally caught
        case ObjectID.NET_TRAP_8996:
        // Maniacal monkey tail obtained
        case ObjectID.LARGE_BOULDER_28830:
        case // Maniacal monkey tail obtained
        ObjectID.LARGE_BOULDER_28831:
            if (myTrap != null) {
                myTrap.setState(HunterTrap.State.FULL);
                myTrap.resetTimer();
                lastActionTime = Instant.now();
                if (config.maniacalMonkeyNotify() && myTrap.getObjectId() == ObjectID.MONKEY_TRAP) {
                    notifier.notify("You've caught part of a monkey's tail.");
                }
            }
            break;
        // Empty imp box
        case ObjectID.MAGIC_BOX_FAILED:
        // Empty box trap
        case ObjectID.BOX_TRAP_9385:
        case // Empty box trap
        ObjectID.BIRD_SNARE:
            if (myTrap != null) {
                myTrap.setState(HunterTrap.State.EMPTY);
                myTrap.resetTimer();
                lastActionTime = Instant.now();
            }
            break;
        // Imp entering box
        case ObjectID.MAGIC_BOX_19225:
        // Black chin shaking box
        case ObjectID.BOX_TRAP:
        case ObjectID.BOX_TRAP_2026:
        case ObjectID.BOX_TRAP_2028:
        case ObjectID.BOX_TRAP_2029:
        // Red chin shaking box
        case ObjectID.BOX_TRAP_9381:
        case ObjectID.BOX_TRAP_9390:
        case ObjectID.BOX_TRAP_9391:
        case ObjectID.BOX_TRAP_9392:
        case ObjectID.BOX_TRAP_9393:
        // Grey chin shaking box
        case ObjectID.BOX_TRAP_9386:
        case ObjectID.BOX_TRAP_9387:
        case ObjectID.BOX_TRAP_9388:
        // Bird traps
        case ObjectID.BIRD_SNARE_9346:
        case ObjectID.BIRD_SNARE_9347:
        case ObjectID.BIRD_SNARE_9349:
        case ObjectID.BIRD_SNARE_9374:
        case ObjectID.BIRD_SNARE_9376:
        case ObjectID.BIRD_SNARE_9378:
        // Deadfall trap
        case ObjectID.DEADFALL_19218:
        case ObjectID.DEADFALL_19851:
        case ObjectID.DEADFALL_20128:
        case ObjectID.DEADFALL_20129:
        case ObjectID.DEADFALL_20130:
        case ObjectID.DEADFALL_20131:
        // Net trap
        case ObjectID.NET_TRAP_9003:
        case ObjectID.NET_TRAP_9005:
        case ObjectID.NET_TRAP_8972:
        case ObjectID.NET_TRAP_8974:
        case ObjectID.NET_TRAP_8985:
        case ObjectID.NET_TRAP_8987:
        case ObjectID.NET_TRAP_8993:
        case ObjectID.NET_TRAP_8997:
        // Maniacal monkey boulder trap
        case ObjectID.MONKEY_TRAP_28828:
        case ObjectID.MONKEY_TRAP_28829:
            if (myTrap != null) {
                myTrap.setState(HunterTrap.State.TRANSITION);
            }
            break;
    }
}
Also used : Player(net.runelite.api.Player) GameObject(net.runelite.api.GameObject) PlayerQuery(net.runelite.api.queries.PlayerQuery) Subscribe(com.google.common.eventbus.Subscribe)

Aggregations

Player (net.runelite.api.Player)17 Subscribe (com.google.common.eventbus.Subscribe)6 LocalPoint (net.runelite.api.coords.LocalPoint)6 Point (net.runelite.api.Point)4 Color (java.awt.Color)3 WorldPoint (net.runelite.api.coords.WorldPoint)3 FontMetrics (java.awt.FontMetrics)2 GameObject (net.runelite.api.GameObject)2 NPC (net.runelite.api.NPC)2 Region (net.runelite.api.Region)2 Tile (net.runelite.api.Tile)2 Inject (net.runelite.api.mixins.Inject)2 Inject (com.google.inject.Inject)1 Dimension (java.awt.Dimension)1 Graphics2D (java.awt.Graphics2D)1 Polygon (java.awt.Polygon)1 Rectangle (java.awt.Rectangle)1 Rectangle2D (java.awt.geom.Rectangle2D)1 IOException (java.io.IOException)1 Duration (java.time.Duration)1