clue plugin: support Prifddinas clues
This adds hotcold solver support in Prifddinas, and allows coordinate clues to be located in the city. Modify coordinate clues to support "real" and "overworld" locations so that regardless of which region you are in, the overlays work for either. Closes #9459
This commit is contained in:
@@ -114,6 +114,13 @@ public class ClueScrollPlugin extends Plugin
|
||||
private static final Color HIGHLIGHT_BORDER_COLOR = Color.ORANGE;
|
||||
private static final Color HIGHLIGHT_HOVER_BORDER_COLOR = HIGHLIGHT_BORDER_COLOR.darker();
|
||||
private static final Color HIGHLIGHT_FILL_COLOR = new Color(0, 255, 0, 20);
|
||||
private static final int[] REGION_MIRRORS = {
|
||||
// Prifddinas
|
||||
12894, 8755,
|
||||
12895, 8756,
|
||||
13150, 9011,
|
||||
13151, 9012
|
||||
};
|
||||
|
||||
@Getter
|
||||
private ClueScroll clue;
|
||||
@@ -374,12 +381,13 @@ public class ClueScrollPlugin extends Plugin
|
||||
|
||||
if (clue instanceof LocationClueScroll)
|
||||
{
|
||||
final WorldPoint location = ((LocationClueScroll) clue).getLocation();
|
||||
final WorldPoint[] locations = ((LocationClueScroll) clue).getLocations();
|
||||
|
||||
if (location != null)
|
||||
for (WorldPoint location : locations)
|
||||
{
|
||||
// Only set the location hint arrow if we do not already have more accurate location
|
||||
if (config.displayHintArrows()
|
||||
if (location.isInScene(client)
|
||||
&& config.displayHintArrows()
|
||||
&& (client.getHintArrowNpc() == null
|
||||
|| !npcsToMark.contains(client.getHintArrowNpc())))
|
||||
{
|
||||
@@ -610,7 +618,11 @@ public class ClueScrollPlugin extends Plugin
|
||||
minX *= -1;
|
||||
}
|
||||
|
||||
return new CoordinateClue(text, coordinatesToWorldPoint(degX, minX, degY, minY));
|
||||
WorldPoint coordinate = coordinatesToWorldPoint(degX, minX, degY, minY);
|
||||
// Convert from overworld to real
|
||||
WorldPoint mirrorPoint = getMirrorPoint(coordinate, false);
|
||||
// Use mirror point as mirrorLocation if there is one
|
||||
return new CoordinateClue(text, coordinate, coordinate == mirrorPoint ? null : mirrorPoint);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -812,4 +824,29 @@ public class ClueScrollPlugin extends Plugin
|
||||
newScroll
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate a coordinate either between overworld and real, or real and overworld
|
||||
*
|
||||
* @param worldPoint
|
||||
* @param toOverworld whether to convert to overworld coordinates, or to real coordinates
|
||||
* @return
|
||||
*/
|
||||
public static WorldPoint getMirrorPoint(WorldPoint worldPoint, boolean toOverworld)
|
||||
{
|
||||
int region = worldPoint.getRegionID();
|
||||
for (int i = 0; i < REGION_MIRRORS.length; i += 2)
|
||||
{
|
||||
int real = REGION_MIRRORS[i];
|
||||
int overworld = REGION_MIRRORS[i + 1];
|
||||
|
||||
// Test against what we are converting from
|
||||
if (region == (toOverworld ? real : overworld))
|
||||
{
|
||||
return WorldPoint.fromRegion(toOverworld ? overworld : real,
|
||||
worldPoint.getRegionX(), worldPoint.getRegionY(), worldPoint.getPlane());
|
||||
}
|
||||
}
|
||||
return worldPoint;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ package net.runelite.client.plugins.cluescrolls.clues;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import javax.annotation.Nullable;
|
||||
import lombok.Getter;
|
||||
import net.runelite.api.coords.LocalPoint;
|
||||
import net.runelite.api.coords.WorldPoint;
|
||||
@@ -198,14 +199,33 @@ public class CoordinateClue extends ClueScroll implements TextClueScroll, Locati
|
||||
|
||||
private final String text;
|
||||
private final WorldPoint location;
|
||||
/**
|
||||
* For regions which are mirrored, the location of the the clue in the mirrored region.
|
||||
*/
|
||||
@Nullable
|
||||
private final WorldPoint mirrorLocation;
|
||||
|
||||
public CoordinateClue(String text, WorldPoint location)
|
||||
public CoordinateClue(String text, WorldPoint location, WorldPoint mirrorLocation)
|
||||
{
|
||||
this.text = text;
|
||||
this.location = location;
|
||||
this.mirrorLocation = mirrorLocation;
|
||||
setRequiresSpade(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldPoint[] getLocations()
|
||||
{
|
||||
if (mirrorLocation != null)
|
||||
{
|
||||
return new WorldPoint[]{location, mirrorLocation};
|
||||
}
|
||||
else
|
||||
{
|
||||
return new WorldPoint[]{location};
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void makeOverlayHint(PanelComponent panelComponent, ClueScrollPlugin plugin)
|
||||
{
|
||||
@@ -229,13 +249,14 @@ public class CoordinateClue extends ClueScroll implements TextClueScroll, Locati
|
||||
@Override
|
||||
public void makeWorldOverlayHint(Graphics2D graphics, ClueScrollPlugin plugin)
|
||||
{
|
||||
LocalPoint localLocation = LocalPoint.fromWorld(plugin.getClient(), getLocation());
|
||||
|
||||
if (localLocation == null)
|
||||
for (WorldPoint worldPoint : getLocations())
|
||||
{
|
||||
return;
|
||||
}
|
||||
LocalPoint localLocation = LocalPoint.fromWorld(plugin.getClient(), worldPoint);
|
||||
|
||||
OverlayUtil.renderTileOverlay(plugin.getClient(), graphics, localLocation, plugin.getSpadeImage(), Color.ORANGE);
|
||||
if (localLocation != null)
|
||||
{
|
||||
OverlayUtil.renderTileOverlay(plugin.getClient(), graphics, localLocation, plugin.getSpadeImage(), Color.ORANGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -292,7 +292,8 @@ public class HotColdClue extends ClueScroll implements LocationClueScroll, Locat
|
||||
return false;
|
||||
}
|
||||
|
||||
final WorldPoint localWorld = plugin.getClient().getLocalPlayer().getWorldLocation();
|
||||
// Convert from real to overworld
|
||||
final WorldPoint localWorld = ClueScrollPlugin.getMirrorPoint(plugin.getClient().getLocalPlayer().getWorldLocation(), true);
|
||||
|
||||
if (localWorld == null)
|
||||
{
|
||||
|
||||
@@ -29,4 +29,10 @@ import net.runelite.api.coords.WorldPoint;
|
||||
public interface LocationClueScroll
|
||||
{
|
||||
WorldPoint getLocation();
|
||||
|
||||
default WorldPoint[] getLocations()
|
||||
{
|
||||
WorldPoint location = getLocation();
|
||||
return location == null ? new WorldPoint[0] : new WorldPoint[]{location};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user