Merge remote-tracking branch 'runelite/master'

This commit is contained in:
Owain van Brakel
2022-06-17 22:21:37 +02:00
10 changed files with 175 additions and 40 deletions

View File

@@ -0,0 +1,85 @@
/*
* Copyright (c) 2022, Jordan Atwood <nightfirecat@nightfirec.at>
* 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 HOLDER 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.game;
import net.runelite.api.NPC;
import net.runelite.api.NpcID;
public class NpcUtil
{
/**
* Returns whether an NPC is dying and can no longer be interacted with, or if it is still alive or in some special
* state where it can be 0hp without dying. (For example, Gargoyles and other slayer monsters with item weaknesses
* are not killed by reaching 0hp, so would not be dead based on that alone.)
*
* @param npc NPC to check whether it is dying
* @return {@code true} if the NPC is dying
*/
public static boolean isDying(final NPC npc)
{
final int id = npc.getId();
switch (id)
{
// These NPCs hit 0hp but don't actually die
case NpcID.GARGOYLE:
case NpcID.GARGOYLE_413:
case NpcID.GARGOYLE_1543:
case NpcID.MARBLE_GARGOYLE:
case NpcID.MARBLE_GARGOYLE_7408:
case NpcID.DAWN:
case NpcID.DAWN_7852:
case NpcID.DAWN_7853:
case NpcID.DAWN_7884:
case NpcID.DAWN_7885:
case NpcID.DUSK:
case NpcID.DUSK_7851:
case NpcID.DUSK_7854:
case NpcID.DUSK_7855:
case NpcID.DUSK_7882:
case NpcID.DUSK_7883:
case NpcID.DUSK_7886:
case NpcID.DUSK_7887:
case NpcID.DUSK_7888:
case NpcID.DUSK_7889:
case NpcID.ZYGOMITE:
case NpcID.ZYGOMITE_1024:
case NpcID.ANCIENT_ZYGOMITE:
case NpcID.ROCKSLUG:
case NpcID.ROCKSLUG_422:
case NpcID.DESERT_LIZARD:
case NpcID.DESERT_LIZARD_460:
case NpcID.DESERT_LIZARD_461:
case NpcID.GROWTHLING:
case NpcID.KALPHITE_QUEEN_963:
case NpcID.KALPHITE_QUEEN_965:
case NpcID.VETION:
case NpcID.VETION_REBORN:
return false;
default:
return npc.isDead();
}
}
}

View File

@@ -43,7 +43,9 @@ public class HighlightedNpc
Color fillColor = new Color(0, 0, 0, 50);
boolean hull;
boolean tile;
boolean trueTile;
boolean swTile;
boolean swTrueTile;
boolean outline;
boolean name;
boolean nameOnMinimap;

View File

@@ -103,7 +103,33 @@ class NpcOverlay extends Overlay
renderPoly(graphics, borderColor, borderWidth, fillColor, tilePoly);
}
if (highlightedNpc.isTrueTile())
{
LocalPoint lp = LocalPoint.fromWorld(client, actor.getWorldLocation()); // centered on sw tile
if (lp != null)
{
final int size = npcComposition.getSize();
final LocalPoint centerLp = new LocalPoint(
lp.getX() + Perspective.LOCAL_TILE_SIZE * (size - 1) / 2,
lp.getY() + Perspective.LOCAL_TILE_SIZE * (size - 1) / 2);
Polygon tilePoly = Perspective.getCanvasTileAreaPoly(client, centerLp, size);
renderPoly(graphics, borderColor, borderWidth, fillColor, tilePoly);
}
}
if (highlightedNpc.isSwTile())
{
int size = npcComposition.getSize();
LocalPoint lp = actor.getLocalLocation();
int x = lp.getX() - ((size - 1) * Perspective.LOCAL_TILE_SIZE / 2);
int y = lp.getY() - ((size - 1) * Perspective.LOCAL_TILE_SIZE / 2);
Polygon southWestTilePoly = Perspective.getCanvasTilePoly(client, new LocalPoint(x, y));
renderPoly(graphics, borderColor, borderWidth, fillColor, southWestTilePoly);
}
if (highlightedNpc.isSwTrueTile())
{
LocalPoint lp = LocalPoint.fromWorld(client, actor.getWorldLocation());
if (lp != null)

View File

@@ -90,7 +90,7 @@ public class PartyService
eventBus.register(this);
}
public String generatePasspharse()
public String generatePassphrase()
{
assert client.isClientThread();

View File

@@ -38,6 +38,7 @@ import net.runelite.client.callback.Hooks;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.events.ConfigChanged;
import net.runelite.client.game.NpcUtil;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
@@ -190,7 +191,7 @@ public class EntityHiderPlugin extends Plugin
}
// dead npcs can also be interacting so prioritize it over the interacting check
if (npc.isDead() && hideDeadNpcs)
if (NpcUtil.isDying(npc) && hideDeadNpcs)
{
return false;
}

View File

@@ -151,7 +151,7 @@ public interface MenuEntrySwapperConfig extends Config
}
@ConfigItem(
position = -2,
position = -3,
keyName = "npcLeftClickCustomization",
name = "Customizable left-click",
description = "Allows customization of left-clicks on NPCs",
@@ -162,6 +162,18 @@ public interface MenuEntrySwapperConfig extends Config
return true;
}
@ConfigItem(
position = -2,
keyName = "npcShiftClickWalkHere",
name = "Shift click Walk here",
description = "Swaps Walk here on shift click on all NPCs",
section = npcSection
)
default boolean npcShiftClickWalkHere()
{
return true;
}
@ConfigItem(
keyName = "swapAdmire",
name = "Admire",

View File

@@ -56,7 +56,6 @@ import net.runelite.api.MenuAction;
import net.runelite.api.MenuEntry;
import net.runelite.api.NPC;
import net.runelite.api.NPCComposition;
import net.runelite.api.NpcID;
import net.runelite.api.ObjectComposition;
import net.runelite.api.ParamID;
import net.runelite.api.events.ClientTick;
@@ -74,6 +73,7 @@ import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.events.ConfigChanged;
import net.runelite.client.game.ItemManager;
import net.runelite.client.game.ItemVariationMapping;
import net.runelite.client.game.NpcUtil;
import net.runelite.client.menus.MenuManager;
import net.runelite.client.menus.WidgetMenuOption;
import net.runelite.client.plugins.Plugin;
@@ -1184,9 +1184,18 @@ public class MenuEntrySwapperPlugin extends Plugin
final NPC npc = menuEntry.getNpc();
assert npc != null;
final NPCComposition composition = npc.getTransformedComposition();
assert composition != null;
Integer customOption = getNpcSwapConfig(shiftModifier(), composition.getId());
if (customOption != null)
if (customOption == null)
{
if (shiftModifier() && config.npcShiftClickWalkHere())
{
// we can achieve this by just deprioritizing the normal npc menus
menuEntry.setDeprioritized(true);
}
}
else
{
// Walk here swap
if (customOption == -1)
@@ -1276,33 +1285,7 @@ public class MenuEntrySwapperPlugin extends Plugin
.filter(e ->
{
final NPC npc = e.getNpc();
if (npc == null)
{
return true;
}
final int id = npc.getId();
switch (id)
{
// These NPCs hit 0hp but don't actually die
case NpcID.GARGOYLE:
case NpcID.GARGOYLE_413:
case NpcID.GARGOYLE_1543:
case NpcID.ZYGOMITE:
case NpcID.ZYGOMITE_1024:
case NpcID.ANCIENT_ZYGOMITE:
case NpcID.ROCKSLUG:
case NpcID.ROCKSLUG_422:
case NpcID.DESERT_LIZARD:
case NpcID.DESERT_LIZARD_460:
case NpcID.DESERT_LIZARD_461:
case NpcID.ICE_DEMON:
case NpcID.ICE_DEMON_7585:
return true;
default:
return !npc.isDead();
}
return npc == null || !NpcUtil.isDying(npc);
})
.toArray(MenuEntry[]::new);
if (oldEntries.length != newEntries.length)
@@ -1401,11 +1384,11 @@ public class MenuEntrySwapperPlugin extends Plugin
// Item op4 and op5 are CC_OP_LOW_PRIORITY so they get added underneath Use,
// but this also causes them to get sorted after client tick. Change them to
// CC_OP to avoid this.
if (entry1.isItemOp() && entry1.getType() == MenuAction.CC_OP_LOW_PRIORITY)
if (entry1.getType() == MenuAction.CC_OP_LOW_PRIORITY)
{
entry1.setType(MenuAction.CC_OP);
}
if (entry2.isItemOp() && entry2.getType() == MenuAction.CC_OP_LOW_PRIORITY)
if (entry2.getType() == MenuAction.CC_OP_LOW_PRIORITY)
{
entry2.setType(MenuAction.CC_OP);
}

View File

@@ -68,6 +68,18 @@ public interface NpcIndicatorsConfig extends Config
@ConfigItem(
position = 2,
keyName = "highlightTrueTile",
name = "Highlight true tile",
description = "Configures whether or not NPC should be highlighted by true tile",
section = renderStyleSection
)
default boolean highlightTrueTile()
{
return false;
}
@ConfigItem(
position = 3,
keyName = "highlightSouthWestTile",
name = "Highlight south west tile",
description = "Configures whether or not NPC should be highlighted by south western tile",
@@ -79,7 +91,19 @@ public interface NpcIndicatorsConfig extends Config
}
@ConfigItem(
position = 3,
position = 4,
keyName = "highlightSouthWestTrueTile",
name = "Highlight south west true tile",
description = "Configures whether or not NPC should be highlighted by south western true tile",
section = renderStyleSection
)
default boolean highlightSouthWestTrueTile()
{
return false;
}
@ConfigItem(
position = 5,
keyName = "highlightOutline",
name = "Highlight outline",
description = "Configures whether or not the model of the NPC should be highlighted by outline",
@@ -92,7 +116,7 @@ public interface NpcIndicatorsConfig extends Config
@Alpha
@ConfigItem(
position = 4,
position = 10,
keyName = "npcColor",
name = "Highlight Color",
description = "Color of the NPC highlight border, menu, and text",
@@ -105,7 +129,7 @@ public interface NpcIndicatorsConfig extends Config
@Alpha
@ConfigItem(
position = 5,
position = 11,
keyName = "fillColor",
name = "Fill Color",
description = "Color of the NPC highlight fill",
@@ -117,7 +141,7 @@ public interface NpcIndicatorsConfig extends Config
}
@ConfigItem(
position = 6,
position = 12,
keyName = "borderWidth",
name = "Border Width",
description = "Width of the highlighted NPC border",
@@ -129,7 +153,7 @@ public interface NpcIndicatorsConfig extends Config
}
@ConfigItem(
position = 7,
position = 13,
keyName = "outlineFeather",
name = "Outline feather",
description = "Specify between 0-4 how much of the model outline should be faded",

View File

@@ -660,7 +660,9 @@ public class NpcIndicatorsPlugin extends Plugin
.fillColor(config.fillColor())
.hull(config.highlightHull())
.tile(config.highlightTile())
.trueTile(config.highlightTrueTile())
.swTile(config.highlightSouthWestTile())
.swTrueTile(config.highlightSouthWestTrueTile())
.outline(config.highlightOutline())
.name(config.drawNames())
.nameOnMinimap(config.drawMinimapNames())

View File

@@ -144,7 +144,7 @@ class PartyPanel extends PluginPanel
else
{
// Create party
clientThread.invokeLater(() -> party.changeParty(party.generatePasspharse()));
clientThread.invokeLater(() -> party.changeParty(party.generatePassphrase()));
}
});