Skip to content

Commit

Permalink
Merge pull request open-osrs#3020 from open-osrs/upstream-1108
Browse files Browse the repository at this point in the history
  • Loading branch information
Owain94 authored Aug 11, 2021
2 parents e97b21c + e6729de commit c288e2e
Show file tree
Hide file tree
Showing 24 changed files with 800 additions and 250 deletions.
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

object ProjectVersions {
const val launcherVersion = "2.2.0"
const val rlVersion = "1.7.19"
const val rlVersion = "1.7.20-SNAPSHOT"

const val openosrsVersion = "4.9.10"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
@Value
public class ItemStats
{
private boolean quest;
private boolean equipable;
private double weight;
@SerializedName("ge_limit")
Expand Down Expand Up @@ -79,7 +78,7 @@ public ItemStats subtract(ItemStats other)
newEquipment = equipment;
}

return new ItemStats(quest, equipable, newWeight, 0, newEquipment);
return new ItemStats(equipable, newWeight, 0, newEquipment);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,7 @@ static class ArceuusSpellBook
static class Pvp
{
static final int KILLDEATH_RATIO = 26;
static final int WILDERNESS_SKULL_CONTAINER = 44;
static final int SKULL_CONTAINER = 45;
static final int SAFE_ZONE = 47;
static final int WILDERNESS_LEVEL = 50; // this can also be the Deadman Mode "Protection" text
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,7 @@ public enum WidgetInfo
SPELL_ARCEUUS_HOME_TELEPORT(WidgetID.SPELLBOOK_GROUP_ID, WidgetID.ArceuusSpellBook.ARCEUUS_HOME_TELEPORT),
SPELL_KOUREND_HOME_TELEPORT(WidgetID.SPELLBOOK_GROUP_ID, WidgetID.StandardSpellBook.KOUREND_HOME_TELEPORT),

PVP_WILDERNESS_SKULL_CONTAINER(WidgetID.PVP_GROUP_ID, WidgetID.Pvp.WILDERNESS_SKULL_CONTAINER),
PVP_SKULL_CONTAINER(WidgetID.PVP_GROUP_ID, WidgetID.Pvp.SKULL_CONTAINER),
PVP_WORLD_SAFE_ZONE(WidgetID.PVP_GROUP_ID, WidgetID.Pvp.SAFE_ZONE),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ public void start() throws Exception
if (!isOutdated)
{
// Add core overlays
WidgetOverlay.createOverlays(client).forEach(overlayManager::add);
WidgetOverlay.createOverlays(overlayManager, client).forEach(overlayManager::add);
overlayManager.add(worldMapOverlay.get());
eventBus.register(worldMapOverlay.get());
overlayManager.add(tooltipOverlay.get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ private InteractHighlightOverlay(Client client, InteractHighlightPlugin plugin,
this.modelOutlineRenderer = modelOutlineRenderer;
setPosition(OverlayPosition.DYNAMIC);
setLayer(OverlayLayer.ABOVE_SCENE);
setPriority(OverlayPriority.LOW);
setPriority(OverlayPriority.HIGH);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class ItemStatOverlay extends Overlay
{
// Unarmed attack speed is 4
@VisibleForTesting
static final ItemStats UNARMED = new ItemStats(false, true, 0, 0,
static final ItemStats UNARMED = new ItemStats(true, 0, 0,
ItemEquipmentStats.builder()
.aspeed(4)
.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ public class LootTrackerPlugin extends Plugin

// Chest loot handling
private static final String CHEST_LOOTED_MESSAGE = "You find some treasure in the chest!";
private static final Pattern ROGUES_CHEST_PATTERN = Pattern.compile("You find (a|some)([a-z\\s]*) inside.");
private static final Pattern LARRAN_LOOTED_PATTERN = Pattern.compile("You have opened Larran's (big|small) chest .*");
// Used by Stone Chest, Isle of Souls chest, Dark Chest
private static final String OTHER_CHEST_LOOTED_MESSAGE = "You steal some loot from the chest.";
Expand All @@ -167,6 +168,7 @@ public class LootTrackerPlugin extends Plugin
put(7323, "Grubby Chest").
put(8593, "Isle of Souls Chest").
put(7827, "Dark Chest").
put(13117, "Rogues' Chest").
build();

// Shade chest loot handling
Expand Down Expand Up @@ -646,7 +648,7 @@ public void onChatMessage(ChatMessage event)

if (message.equals(CHEST_LOOTED_MESSAGE) || message.equals(OTHER_CHEST_LOOTED_MESSAGE)
|| message.equals(DORGESH_KAAN_CHEST_LOOTED_MESSAGE) || message.startsWith(GRUBBY_CHEST_LOOTED_MESSAGE)
|| LARRAN_LOOTED_PATTERN.matcher(message).matches())
|| LARRAN_LOOTED_PATTERN.matcher(message).matches() || ROGUES_CHEST_PATTERN.matcher(message).matches())
{
final int regionID = client.getLocalPlayer().getWorldLocation().getRegionID();
if (!CHEST_EVENT_TYPES.containsKey(regionID))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Binder;
import com.google.inject.Provides;
import java.awt.Color;
import java.time.Instant;
Expand All @@ -38,6 +39,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Predicate;
import javax.inject.Inject;
import lombok.AccessLevel;
import lombok.Getter;
Expand Down Expand Up @@ -77,7 +79,7 @@
tags = {"highlight", "minimap", "npcs", "overlay", "respawn", "tags"}
)
@Slf4j
public class NpcIndicatorsPlugin extends Plugin
public class NpcIndicatorsPlugin extends Plugin implements NpcIndicatorsService
{
private static final int MAX_ACTOR_VIEW_RANGE = 15;

Expand Down Expand Up @@ -173,12 +175,20 @@ public class NpcIndicatorsPlugin extends Plugin
*/
private boolean skipNextSpawnCheck = false;

private final List<Predicate<NPC>> higlightPredicates = new ArrayList<>();

@Provides
NpcIndicatorsConfig provideConfig(ConfigManager configManager)
{
return configManager.getConfig(NpcIndicatorsConfig.class);
}

@Override
public void configure(Binder binder)
{
binder.bind(NpcIndicatorsService.class).toInstance(this);
}

@Override
protected void startUp() throws Exception
{
Expand All @@ -187,7 +197,7 @@ protected void startUp() throws Exception
clientThread.invoke(() ->
{
skipNextSpawnCheck = true;
rebuildAllNpcs();
rebuild();
});
}

Expand Down Expand Up @@ -230,7 +240,7 @@ public void onConfigChanged(ConfigChanged configChanged)
return;
}

clientThread.invoke(this::rebuildAllNpcs);
clientThread.invoke(this::rebuild);
}

@Subscribe
Expand Down Expand Up @@ -394,7 +404,23 @@ public void onNpcSpawned(NpcSpawned npcSpawned)
memorizeNpc(npc);
spawnedNpcsThisTick.add(npc);
}
return;
}

for (Predicate<NPC> predicate : higlightPredicates)
{
if (predicate.test(npc))
{
highlightedNpcs.add(npc);
if (!client.isInInstancedRegion())
{
memorizeNpc(npc);
spawnedNpcsThisTick.add(npc);
}
return;
}
}

}

@Subscribe
Expand Down Expand Up @@ -534,8 +560,8 @@ List<String> getHighlights()
return Text.fromCSV(configNpcs);
}

@VisibleForTesting
void rebuildAllNpcs()
@Override
public void rebuild()
{
highlights = getHighlights();
highlightedNpcs.clear();
Expand All @@ -548,6 +574,7 @@ void rebuildAllNpcs()
return;
}

outer:
for (NPC npc : client.getNpcs())
{
final String npcName = npc.getName();
Expand All @@ -573,6 +600,19 @@ void rebuildAllNpcs()
continue;
}

for (Predicate<NPC> predicate : higlightPredicates)
{
if (predicate.test(npc))
{
if (!client.isInInstancedRegion())
{
memorizeNpc(npc);
}
highlightedNpcs.add(npc);
continue outer;
}
}

// NPC is not highlighted
memorizedNpcs.remove(npc.getIndex());
}
Expand Down Expand Up @@ -680,4 +720,16 @@ private void validateSpawnedNpcs()
despawnedNpcsThisTick.clear();
teleportGraphicsObjectSpawnedThisTick.clear();
}

@Override
public void registerHighlighter(Predicate<NPC> p)
{
higlightPredicates.add(p);
}

@Override
public void unregisterHighlighter(Predicate<NPC> p)
{
higlightPredicates.remove(p);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright (c) 2021, Adam <[email protected]>
* 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.npchighlight;

import java.util.function.Predicate;
import net.runelite.api.NPC;

public interface NpcIndicatorsService
{
void registerHighlighter(Predicate<NPC> p);
void unregisterHighlighter(Predicate<NPC> p);
void rebuild();
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
*/
package net.runelite.client.plugins.slayer;

import java.awt.Color;
import net.runelite.client.config.Alpha;
import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem;
Expand Down Expand Up @@ -101,18 +99,6 @@ default boolean highlightTargets()
return false;
}

@Alpha
@ConfigItem(
position = 6,
keyName = "targetColor",
name = "Target Color",
description = "Color of the highlighted targets"
)
default Color getTargetColor()
{
return Color.RED;
}

@ConfigItem(
position = 7,
keyName = "weaknessPrompt",
Expand Down
Loading

0 comments on commit c288e2e

Please sign in to comment.