Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ nbactions.xml
nb-configuration.xml
nbproject/
.DS_Store
out/
out/
bin
20 changes: 16 additions & 4 deletions src/main/java/com/zulrahhelper/ZulrahHelperConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,26 @@ public interface ZulrahHelperConfig extends Config
)
String SECTION_MISC = ZulrahHelperPlugin.SECTION_MISC;

@ConfigItem(
keyName = ZulrahHelperPlugin.USING_MELEE_KEY,
section = ZulrahHelperPlugin.SECTION_IMAGE_OPTIONS,
name = "Using Melee",
description = "Show melee-optimized stand positions (closer to Zulrah spawn) instead of ranged positions",
position = 0
)
default boolean usingMelee()
{
return false;
}

@ConfigItem(
keyName = ZulrahHelperPlugin.DISPLAY_PRAYER_KEY,
section = ZulrahHelperPlugin.SECTION_IMAGE_OPTIONS,
name = "Prayer Icons",
description = "Set phase images to use prayer icons, " +
"denoting what overhead prayer to use per phase. " +
"No prayer icon means the phase is safe to turn overheads off.",
position = 0
position = 1
)
default boolean displayPrayerIcons()
{
Expand All @@ -50,7 +62,7 @@ default boolean displayPrayerIcons()
section = ZulrahHelperPlugin.SECTION_IMAGE_OPTIONS,
name = "Attack Icons",
description = "Display number of Zulrah attacks",
position = 1
position = 2
)
default boolean displayAttackIcons()
{
Expand All @@ -62,7 +74,7 @@ default boolean displayAttackIcons()
section = ZulrahHelperPlugin.SECTION_IMAGE_OPTIONS,
name = "Venom Icons",
description = "Display number of venom attacks",
position = 1
position = 2
)
default boolean displayVenom()
{
Expand All @@ -74,7 +86,7 @@ default boolean displayVenom()
section = ZulrahHelperPlugin.SECTION_IMAGE_OPTIONS,
name = "Snakeling Icons",
description = "Display snakeling spawns",
position = 1
position = 2
)
default boolean displaySnakelings()
{
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/zulrahhelper/ZulrahHelperPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class ZulrahHelperPlugin extends Plugin
static final String SECTION_HOTKEYS = "Hotkeys";
static final String SECTION_MISC = "Miscellaneous";

static final String USING_MELEE_KEY = "usingMelee";
static final String DARK_MODE_KEY = "darkMode";
static final String DISPLAY_PRAYER_KEY = "displayPrayer";
static final String DISPLAY_ATTACK_KEY = "displayAttack";
Expand All @@ -57,6 +58,7 @@ public class ZulrahHelperPlugin extends Plugin
private static final int ZULRAH_REGION_ID = 9008;

private static final List<String> OPTION_KEYS = Arrays.asList(
USING_MELEE_KEY,
DARK_MODE_KEY,
DISPLAY_PRAYER_KEY,
DISPLAY_ATTACK_KEY,
Expand Down
105 changes: 105 additions & 0 deletions src/main/java/com/zulrahhelper/options/ArrowDirection.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/*
* Copyright (c) 2024, Ron Young <https://github.com/raiyni>
* 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 com.zulrahhelper.options;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.geom.QuadCurve2D;

public enum ArrowDirection
{
NONE,
UP,
DOWN,
LEFT,
RIGHT,
UP_LEFT,
UP_RIGHT,
DOWN_LEFT,
DOWN_RIGHT;

private static final int ARROWHEAD_SIZE = 5;
private static final double ARROWHEAD_SPREAD = Math.toRadians(60);
private static final int TIP_GAP = 6;
private static final int ARC_CONTROL_SHIFT = 6;

public void drawArrow(Graphics2D g, int x1, int y1, int x2, int y2)
{
if (this == NONE)
{
return;
}

g.setColor(Color.WHITE);
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

if (!isDiagonal())
{
double angle = Math.atan2(y2 - y1, x2 - x1);
int tipX = (int) Math.round(x2 - TIP_GAP * Math.cos(angle));
int tipY = (int) Math.round(y2 - TIP_GAP * Math.sin(angle));
g.drawLine(x1, y1, tipX, tipY);
drawArrowhead(g, tipX, tipY, angle);
}
else
{
// Bow the curve perpendicular to the travel direction (CW = right of travel)
double dx = x2 - x1;
double dy = y2 - y1;
double len = Math.sqrt(dx * dx + dy * dy);
double perpX = dy / len;
double perpY = -dx / len;

int cx = (int) Math.round((x1 + x2) / 2.0 + perpX * ARC_CONTROL_SHIFT);
int cy = (int) Math.round((y1 + y2) / 2.0 + perpY * ARC_CONTROL_SHIFT);

// Tangent at the end of the bezier: direction from control point to endpoint
double tangentAngle = Math.atan2(y2 - cy, x2 - cx);
int tipX = (int) Math.round(x2 - TIP_GAP * Math.cos(tangentAngle));
int tipY = (int) Math.round(y2 - TIP_GAP * Math.sin(tangentAngle));

g.setStroke(new BasicStroke(1));
g.draw(new QuadCurve2D.Float(x1, y1, cx, cy, tipX, tipY));
drawArrowhead(g, tipX, tipY, tangentAngle);
}
}

private boolean isDiagonal()
{
return this == UP_LEFT || this == UP_RIGHT || this == DOWN_LEFT || this == DOWN_RIGHT;
}

private void drawArrowhead(Graphics2D g, int tipX, int tipY, double angle)
{
int bx1 = (int) Math.round(tipX - ARROWHEAD_SIZE * Math.cos(angle - ARROWHEAD_SPREAD / 2));
int by1 = (int) Math.round(tipY - ARROWHEAD_SIZE * Math.sin(angle - ARROWHEAD_SPREAD / 2));
int bx2 = (int) Math.round(tipX - ARROWHEAD_SIZE * Math.cos(angle + ARROWHEAD_SPREAD / 2));
int by2 = (int) Math.round(tipY - ARROWHEAD_SIZE * Math.sin(angle + ARROWHEAD_SPREAD / 2));
g.fillPolygon(new int[]{tipX, bx1, bx2}, new int[]{tipY, by1, by2}, 3);
}
}
73 changes: 73 additions & 0 deletions src/main/java/com/zulrahhelper/options/MeleeStandLocation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* Copyright (c) 2024, Ron Young <https://github.com/raiyni>
* 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 com.zulrahhelper.options;

import java.awt.Color;
import java.awt.Graphics;
import lombok.RequiredArgsConstructor;

@RequiredArgsConstructor
public enum MeleeStandLocation
{
START(19, 52),
START_MAGMA(9, 47),
MID_LEFT(9, 32),
PILLAR_LEFT(19, 23),
TOP_LEFT(29, 5),
TOP_RIGHT(49, 5),
PILLAR_RIGHT(62, 23),
MID_RIGHT(69, 30);

private static final int WIDTH = 6;
private static final int HEIGHT = 6;

private final int x;
private final int y;

public void drawX(Graphics g, int px, int py)
{
var x = px + this.x - WIDTH / 2;
var y = py + this.y - HEIGHT / 2;

g.setColor(Color.WHITE);

g.drawLine(x, y, x + WIDTH, y + HEIGHT);
g.drawLine(x, y + HEIGHT, x + WIDTH, y);

g.drawLine(x - 1, y, x + WIDTH - 1, y + HEIGHT);
g.drawLine(x - 1, y + HEIGHT, x + WIDTH - 1, y);
}

public int getX()
{
return x;
}

public int getY()
{
return y;
}
}
46 changes: 46 additions & 0 deletions src/main/java/com/zulrahhelper/options/MeleeStep.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright (c) 2024, Ron Young <https://github.com/raiyni>
* 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 com.zulrahhelper.options;

import lombok.Value;

@Value
public class MeleeStep
{
MeleeStandLocation location;
ArrowDirection arrow;

public MeleeStep(MeleeStandLocation location)
{
this(location, ArrowDirection.NONE);
}

public MeleeStep(MeleeStandLocation location, ArrowDirection arrow)
{
this.location = location;
this.arrow = arrow;
}
}
Loading