forked from runelite/runelite
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request runelite#566 from sethtroll/addcannonspots
Add common cannon spots
- Loading branch information
Showing
4 changed files
with
231 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
runelite-client/src/main/java/net/runelite/client/plugins/cannon/CannonSpotOverlay.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
/* | ||
* Copyright (c) 2018, Seth <https://github.com/sethtroll> | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* | ||
* 1. Redistributions of source code must retain the above copyright notice, this | ||
* list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright notice, | ||
* this list of conditions and the following disclaimer in the documentation | ||
* and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR | ||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
package net.runelite.client.plugins.cannon; | ||
|
||
import java.awt.Color; | ||
import java.awt.Dimension; | ||
import java.awt.Graphics2D; | ||
import java.awt.Polygon; | ||
import java.awt.image.BufferedImage; | ||
import javax.inject.Inject; | ||
import net.runelite.api.Client; | ||
import static net.runelite.api.ItemID.CANNONBALL; | ||
import net.runelite.api.Perspective; | ||
import net.runelite.api.Point; | ||
import net.runelite.api.coords.LocalPoint; | ||
import net.runelite.api.coords.WorldPoint; | ||
import net.runelite.client.game.ItemManager; | ||
import net.runelite.client.ui.overlay.Overlay; | ||
import net.runelite.client.ui.overlay.OverlayPosition; | ||
import net.runelite.client.ui.overlay.OverlayUtil; | ||
|
||
public class CannonSpotOverlay extends Overlay | ||
{ | ||
private static final int MAX_DISTANCE = 2350; | ||
|
||
private final Client client; | ||
private final CannonPlugin plugin; | ||
private final CannonConfig config; | ||
|
||
@Inject | ||
private ItemManager itemManager; | ||
|
||
@Inject | ||
CannonSpotOverlay(Client client, CannonPlugin plugin, CannonConfig config) | ||
{ | ||
setPosition(OverlayPosition.DYNAMIC); | ||
this.client = client; | ||
this.plugin = plugin; | ||
this.config = config; | ||
} | ||
|
||
@Override | ||
public Dimension render(Graphics2D graphics, java.awt.Point parent) | ||
{ | ||
if (!config.showCannonSpots() || plugin.isCannonPlaced()) | ||
{ | ||
return null; | ||
} | ||
|
||
for (WorldPoint spot : plugin.getSpotPoints()) | ||
{ | ||
if (spot.getPlane() != client.getPlane()) | ||
{ | ||
continue; | ||
} | ||
|
||
LocalPoint spotPoint = LocalPoint.fromWorld(client, spot); | ||
LocalPoint localLocation = client.getLocalPlayer().getLocalLocation(); | ||
|
||
if (spotPoint != null && localLocation.distanceTo(spotPoint) <= MAX_DISTANCE) | ||
{ | ||
renderCannonSpot(graphics, client, spotPoint, itemManager.getImage(CANNONBALL), Color.RED); | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
private void renderCannonSpot(Graphics2D graphics, Client client, LocalPoint point, BufferedImage image, Color color) | ||
{ | ||
//Render tile | ||
Polygon poly = Perspective.getCanvasTilePoly(client, point); | ||
|
||
if (poly != null) | ||
{ | ||
OverlayUtil.renderPolygon(graphics, poly, color); | ||
} | ||
|
||
//Render icon | ||
Point imageLoc = Perspective.getCanvasImageLocation(client, graphics, point, image, 0); | ||
|
||
if (imageLoc != null) | ||
{ | ||
OverlayUtil.renderImageLocation(graphics, imageLoc, image); | ||
} | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
runelite-client/src/main/java/net/runelite/client/plugins/cannon/CannonSpots.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* Copyright (c) 2018, Seth <https://github.com/sethtroll> | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* | ||
* 1. Redistributions of source code must retain the above copyright notice, this | ||
* list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright notice, | ||
* this list of conditions and the following disclaimer in the documentation | ||
* and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR | ||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
package net.runelite.client.plugins.cannon; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import lombok.Getter; | ||
import net.runelite.api.coords.WorldPoint; | ||
|
||
public enum CannonSpots | ||
{ | ||
|
||
BLOODVELDS(new WorldPoint(2439, 9821, 0), new WorldPoint(2448, 9821, 0), new WorldPoint(2472, 9833, 0), new WorldPoint(2453, 9817, 0)), | ||
FIRE_GIANTS(new WorldPoint(2393, 9782, 0), new WorldPoint(2412, 9776, 0), new WorldPoint(2401, 9780, 0)), | ||
ABBERANT_SPECTRES(new WorldPoint(2456, 9791, 0)), | ||
HELLHOUNDS(new WorldPoint(2431, 9776, 0), new WorldPoint(2413, 9786, 0), new WorldPoint(2783, 9686, 0)), | ||
BLACK_DEMONS(new WorldPoint(2859, 9778, 0), new WorldPoint(2841, 9791, 0)), | ||
ELVES(new WorldPoint(2044, 4635, 0)), | ||
SUQAHS(new WorldPoint(2114, 3943, 0)), | ||
TROLLS(new WorldPoint(2405, 3857, 0)), | ||
GREATER_DEMONS(new WorldPoint(1438, 10089, 2)), | ||
BRINE_RAT(new WorldPoint(2707, 10132, 0)), | ||
DAGGANOTH(new WorldPoint(2524, 10020, 0)), | ||
DARK_BEAST(new WorldPoint(1992, 4655, 0)), | ||
DUST_DEVIL(new WorldPoint(3218, 9366, 0)), | ||
KALPHITE(new WorldPoint(3307, 9528, 0)), | ||
LESSER_DEMON(new WorldPoint(2838, 9559, 0)), | ||
LIZARDMEN(new WorldPoint(1500, 3703, 1)), | ||
MINIONS_OF_SCARABAS(new WorldPoint(3297, 9252, 0)), | ||
SMOKE_DEVIL(new WorldPoint(2398, 9444, 0)); | ||
|
||
@Getter | ||
private static final List<WorldPoint> cannonSpots = new ArrayList<>(); | ||
|
||
static | ||
{ | ||
for (CannonSpots cannonSpot : values()) | ||
{ | ||
for (WorldPoint spot : cannonSpot.spots) | ||
{ | ||
cannonSpots.add(spot); | ||
} | ||
} | ||
} | ||
|
||
private final WorldPoint[] spots; | ||
|
||
CannonSpots(WorldPoint... spots) | ||
{ | ||
this.spots = spots; | ||
} | ||
} |