Delete safespot plugin. (#1637)
It was only useful for pvp. For NPC's, the plugin never worked because they use a reverse LoS algorithm. Only in very rare cases, a 1-way safespot exists but noe of them are implemented in this plugin.
This commit is contained in:
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2019. PKLite
|
||||
* Redistributions and modifications of this software are permitted as long as this notice remains in its original unmodified state at the top of this file. If there are any questions, comments, or feedback about this software, please direct all inquiries directly to the following authors.
|
||||
* PKLite discord: https://discord.gg/Dp3HuFM
|
||||
* Written by PKLite(ST0NEWALL, others) <stonewall@stonewall@pklite.xyz>, 2019
|
||||
*
|
||||
*/
|
||||
|
||||
package net.runelite.client.plugins.safespot;
|
||||
|
||||
import java.awt.Color;
|
||||
import net.runelite.client.config.Config;
|
||||
import net.runelite.client.config.ConfigGroup;
|
||||
import net.runelite.client.config.ConfigItem;
|
||||
|
||||
@ConfigGroup("safespot")
|
||||
public interface SafeSpotConfig extends Config
|
||||
{
|
||||
@ConfigItem(
|
||||
position = 1,
|
||||
keyName = "npcSafeSpots",
|
||||
name = "Render for NPCs",
|
||||
description = "Renders 1 way safe spots vs NPCs"
|
||||
)
|
||||
default boolean npcSafeSpots()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 2,
|
||||
keyName = "tileColor",
|
||||
name = "Tile Color",
|
||||
description = "Color of safe spot tile"
|
||||
)
|
||||
default Color tileColor()
|
||||
{
|
||||
return Color.MAGENTA;
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2019. PKLite
|
||||
* Redistributions and modifications of this software are permitted as long as this notice remains in its original unmodified state at the top of this file. If there are any questions, comments, or feedback about this software, please direct all inquiries directly to the following authors.
|
||||
* PKLite discord: https://discord.gg/Dp3HuFM
|
||||
* Written by PKLite(ST0NEWALL, others) <stonewall@stonewall@pklite.xyz>, 2019
|
||||
*
|
||||
*/
|
||||
|
||||
package net.runelite.client.plugins.safespot;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Polygon;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.Perspective;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.ui.overlay.OverlayLayer;
|
||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||
import net.runelite.client.ui.overlay.OverlayPriority;
|
||||
import net.runelite.client.ui.overlay.OverlayUtil;
|
||||
|
||||
@Singleton
|
||||
public class SafeSpotOverlay extends Overlay
|
||||
{
|
||||
|
||||
private final Client client;
|
||||
private final SafeSpotPlugin safeSpotPlugin;
|
||||
|
||||
@Inject
|
||||
public SafeSpotOverlay(final Client client, final SafeSpotPlugin safeSpotPlugin)
|
||||
{
|
||||
this.client = client;
|
||||
this.safeSpotPlugin = safeSpotPlugin;
|
||||
setPosition(OverlayPosition.DYNAMIC);
|
||||
setPriority(OverlayPriority.LOW);
|
||||
setLayer(OverlayLayer.ABOVE_SCENE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension render(Graphics2D graphics)
|
||||
{
|
||||
if (safeSpotPlugin.isSafeSpotsRenderable() && safeSpotPlugin.getSafeSpotList() != null && safeSpotPlugin.getSafeSpotList().size() > 0)
|
||||
{
|
||||
safeSpotPlugin.getSafeSpotList().forEach(tile ->
|
||||
{
|
||||
if (tile != null && tile.getLocalLocation() != null)
|
||||
{
|
||||
final Polygon poly = Perspective.getCanvasTilePoly(client, tile.getLocalLocation());
|
||||
if (poly != null)
|
||||
{
|
||||
OverlayUtil.renderPolygon(graphics, poly, safeSpotPlugin.getTileColor());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,214 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019. PKLite
|
||||
* Redistributions and modifications of this software are permitted as long as this notice remains in its original unmodified state at the top of this file. If there are any questions, comments, or feedback about this software, please direct all inquiries directly to the following authors.
|
||||
* PKLite discord: https://discord.gg/Dp3HuFM
|
||||
* Written by PKLite(ST0NEWALL, others) <stonewall@stonewall@pklite.xyz>, 2019
|
||||
*
|
||||
*/
|
||||
|
||||
package net.runelite.client.plugins.safespot;
|
||||
|
||||
import com.google.inject.Provides;
|
||||
import java.awt.Color;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import net.runelite.api.Actor;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.CollisionDataFlag;
|
||||
import net.runelite.api.NPC;
|
||||
import net.runelite.api.Tile;
|
||||
import net.runelite.api.coords.LocalPoint;
|
||||
import net.runelite.api.coords.WorldArea;
|
||||
import net.runelite.api.coords.WorldPoint;
|
||||
import net.runelite.api.events.ConfigChanged;
|
||||
import net.runelite.api.events.GameTick;
|
||||
import net.runelite.api.events.InteractingChanged;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.eventbus.EventBus;
|
||||
import net.runelite.client.game.NPCManager;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.plugins.PluginType;
|
||||
import net.runelite.client.ui.overlay.OverlayManager;
|
||||
|
||||
@PluginDescriptor(
|
||||
name = "NPC Safe Spots",
|
||||
description = "Renders tile overlays for one way safe spots",
|
||||
tags = {"safe spot", "safespots", "pvm"},
|
||||
type = PluginType.PVM,
|
||||
enabledByDefault = false
|
||||
)
|
||||
@Singleton
|
||||
public class SafeSpotPlugin extends Plugin
|
||||
{
|
||||
@Inject
|
||||
private Client client;
|
||||
|
||||
@Inject
|
||||
OverlayManager overlayManager;
|
||||
|
||||
@Inject
|
||||
private SafeSpotConfig config;
|
||||
|
||||
@Inject
|
||||
private EventBus eventBus;
|
||||
|
||||
@Inject
|
||||
private NPCManager npcManager;
|
||||
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private List<Tile> safeSpotList;
|
||||
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private boolean safeSpotsRenderable = false;
|
||||
|
||||
private SafeSpotOverlay safeSpotOverlay;
|
||||
private int tickCount = 0;
|
||||
|
||||
private boolean npcSafeSpots;
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private Color tileColor;
|
||||
|
||||
@Provides
|
||||
SafeSpotConfig config(ConfigManager configManager)
|
||||
{
|
||||
return configManager.getConfig(SafeSpotConfig.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void startUp() throws Exception
|
||||
{
|
||||
updateConfig();
|
||||
addSubscriptions();
|
||||
|
||||
safeSpotOverlay = new SafeSpotOverlay(client, this);
|
||||
overlayManager.add(safeSpotOverlay);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void shutDown() throws Exception
|
||||
{
|
||||
eventBus.unregister(this);
|
||||
|
||||
overlayManager.remove(safeSpotOverlay);
|
||||
}
|
||||
|
||||
private void addSubscriptions()
|
||||
{
|
||||
eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
|
||||
eventBus.subscribe(InteractingChanged.class, this, this::onInteractingChanged);
|
||||
eventBus.subscribe(GameTick.class, this, this::onGameTick);
|
||||
}
|
||||
|
||||
private void onInteractingChanged(InteractingChanged event)
|
||||
{
|
||||
if (event.getSource() != client.getLocalPlayer())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (event.getTarget() == null && this.npcSafeSpots)
|
||||
{
|
||||
tickCount = 10;
|
||||
}
|
||||
}
|
||||
|
||||
private void onGameTick(GameTick event)
|
||||
{
|
||||
if (client.getLocalPlayer().getInteracting() != null)
|
||||
{
|
||||
if (client.getLocalPlayer().getInteracting() instanceof NPC && this.npcSafeSpots)
|
||||
{
|
||||
if (npcManager.getStats(((NPC) client.getLocalPlayer().getInteracting()).getId()) != null)
|
||||
{
|
||||
safeSpotsRenderable = true;
|
||||
updateSafeSpots();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (tickCount > 0)
|
||||
{
|
||||
tickCount--;
|
||||
}
|
||||
else
|
||||
{
|
||||
safeSpotsRenderable = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this method to update the ArrayList of safespot tiles
|
||||
*/
|
||||
private void updateSafeSpots()
|
||||
{
|
||||
if (client.getLocalPlayer().getInteracting() != null)
|
||||
{
|
||||
Actor enemy = client.getLocalPlayer().getInteracting();
|
||||
WorldArea worldArea = new WorldArea(enemy.getWorldLocation().getX() - 12,
|
||||
enemy.getWorldLocation().getY() - 12, 24, 24, client.getPlane());
|
||||
List<WorldPoint> worldPoints = worldArea.toWorldPointList();
|
||||
safeSpotList = getSafeSpotList(enemy, worldPoints);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The ArrayList of 1-way safe spots
|
||||
*
|
||||
* @param actor - The Actor that the tiles are a safe spot against
|
||||
* @param worldPoints - Worldpoints in the current scene
|
||||
* @return an ArrayList of Tiles where current player can attack actor but actor cannot attack local player
|
||||
*/
|
||||
private List<Tile> getSafeSpotList(Actor actor, List<WorldPoint> worldPoints)
|
||||
{
|
||||
List<Tile> safeSpotList = new ArrayList<>();
|
||||
Tile[][][] tiles = client.getScene().getTiles();
|
||||
for (WorldPoint w : worldPoints)
|
||||
{
|
||||
LocalPoint toPoint = LocalPoint.fromWorld(client, w);
|
||||
Tile fromTile = tiles[client.getPlane()][actor.getLocalLocation().getSceneX()]
|
||||
[actor.getLocalLocation().getSceneY()];
|
||||
Tile toTile = null;
|
||||
if (toPoint != null)
|
||||
{
|
||||
toTile = tiles[client.getPlane()][toPoint.getSceneX()]
|
||||
[toPoint.getSceneY()];
|
||||
}
|
||||
final int plane = client.getLocalPlayer().getWorldArea().getPlane();
|
||||
int bit = 0;
|
||||
if (toPoint != null)
|
||||
{
|
||||
bit = Objects.requireNonNull(client.getCollisionMaps())[plane].getFlags()[toPoint.getSceneX()][toPoint.getSceneY()];
|
||||
}
|
||||
if (toTile != null && toTile.hasLineOfSightTo(fromTile) && !fromTile.hasLineOfSightTo(toTile) &&
|
||||
(!((bit & CollisionDataFlag.BLOCK_MOVEMENT_OBJECT) == CollisionDataFlag.BLOCK_MOVEMENT_OBJECT ||
|
||||
(bit & CollisionDataFlag.BLOCK_MOVEMENT_FLOOR_DECORATION)
|
||||
== CollisionDataFlag.BLOCK_MOVEMENT_FLOOR_DECORATION ||
|
||||
(bit & CollisionDataFlag.BLOCK_MOVEMENT_FLOOR) == CollisionDataFlag.BLOCK_MOVEMENT_FLOOR ||
|
||||
(bit & CollisionDataFlag.BLOCK_MOVEMENT_FULL) == CollisionDataFlag.BLOCK_MOVEMENT_FULL)))
|
||||
{
|
||||
safeSpotList.add(toTile);
|
||||
}
|
||||
}
|
||||
return safeSpotList;
|
||||
}
|
||||
|
||||
private void onConfigChanged(ConfigChanged event)
|
||||
{
|
||||
if (!event.getGroup().equals("safespot"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
updateConfig();
|
||||
}
|
||||
|
||||
private void updateConfig()
|
||||
{
|
||||
this.npcSafeSpots = config.npcSafeSpots();
|
||||
this.tileColor = config.tileColor();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user