wave display
This commit is contained in:
@@ -52,4 +52,15 @@ public interface InfernoConfig extends Config
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 2,
|
||||
keyName = "Wave Display",
|
||||
name = "Wave display",
|
||||
description = "Shows monsters that will spawn on the selected wave(s)."
|
||||
)
|
||||
default InfernoWaveDisplayMode waveDisplay()
|
||||
{
|
||||
return InfernoWaveDisplayMode.BOTH;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,6 @@ import net.runelite.api.Perspective;
|
||||
import net.runelite.api.Point;
|
||||
import net.runelite.api.coords.LocalPoint;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
|
||||
import net.runelite.client.ui.overlay.OverlayLayer;
|
||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||
import net.runelite.client.ui.overlay.components.PanelComponent;
|
||||
|
||||
@@ -26,15 +26,22 @@ package net.runelite.client.plugins.inferno;
|
||||
|
||||
import com.google.inject.Provides;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import javax.inject.Inject;
|
||||
import lombok.Getter;
|
||||
import net.runelite.api.ChatMessageType;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.HeadIcon;
|
||||
import net.runelite.api.NPC;
|
||||
import net.runelite.api.NpcID;
|
||||
import net.runelite.api.events.ChatMessage;
|
||||
import net.runelite.api.events.GameStateChanged;
|
||||
import net.runelite.api.events.GameTick;
|
||||
import net.runelite.api.events.NpcDespawned;
|
||||
import net.runelite.api.events.NpcSpawned;
|
||||
@@ -53,6 +60,10 @@ import net.runelite.client.ui.overlay.OverlayManager;
|
||||
)
|
||||
public class InfernoPlugin extends Plugin
|
||||
{
|
||||
|
||||
private static final Pattern WAVE_PATTERN = Pattern.compile(".*Wave: (\\d+).*");
|
||||
private static final int MAX_MONSTERS_OF_TYPE_PER_WAVE = 6;
|
||||
static final int MAX_WAVE = 69;
|
||||
|
||||
@Inject
|
||||
private Client client;
|
||||
@@ -62,6 +73,9 @@ public class InfernoPlugin extends Plugin
|
||||
|
||||
@Inject
|
||||
private InfernoOverlay infernoOverlay;
|
||||
|
||||
@Inject
|
||||
private InfernoWaveOverlay waveOverlay;
|
||||
|
||||
@Inject
|
||||
private InfernoInfobox infernoInfobox;
|
||||
@@ -71,6 +85,12 @@ public class InfernoPlugin extends Plugin
|
||||
|
||||
@Inject
|
||||
private InfernoConfig config;
|
||||
|
||||
@Getter
|
||||
static final List<EnumMap<InfernoWaveMonster, Integer>> WAVES = new ArrayList<>();
|
||||
|
||||
@Getter
|
||||
private int currentWave = -1;
|
||||
|
||||
@Getter
|
||||
private Map<NPC, InfernoNPC> monsters;
|
||||
@@ -83,6 +103,46 @@ public class InfernoPlugin extends Plugin
|
||||
|
||||
@Getter
|
||||
private InfernoNPC[] priorityNPC;
|
||||
|
||||
static
|
||||
{
|
||||
final InfernoWaveMonster[] waveMonsters = InfernoWaveMonster.values();
|
||||
|
||||
// Add wave 1, future waves are derived from its contents
|
||||
final EnumMap<InfernoWaveMonster, Integer> waveOne = new EnumMap<>(InfernoWaveMonster.class);
|
||||
waveOne.put(waveMonsters[0], 1);
|
||||
WAVES.add(waveOne);
|
||||
|
||||
for (int wave = 1; wave < MAX_WAVE; wave++)
|
||||
{
|
||||
final EnumMap<InfernoWaveMonster, Integer> prevWave = WAVES.get(wave - 1).clone();
|
||||
int maxMonsterOrdinal = -1;
|
||||
|
||||
for (int i = 0; i < waveMonsters.length; i++)
|
||||
{
|
||||
final int ordinalMonsterQuantity = prevWave.getOrDefault(waveMonsters[i], 0);
|
||||
|
||||
if (ordinalMonsterQuantity == MAX_MONSTERS_OF_TYPE_PER_WAVE)
|
||||
{
|
||||
maxMonsterOrdinal = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (maxMonsterOrdinal >= 0)
|
||||
{
|
||||
prevWave.remove(waveMonsters[maxMonsterOrdinal]);
|
||||
}
|
||||
|
||||
final int addedMonsterOrdinal = maxMonsterOrdinal >= 0 ? maxMonsterOrdinal + 1 : 0;
|
||||
final InfernoWaveMonster addedMonster = waveMonsters[addedMonsterOrdinal];
|
||||
final int addedMonsterQuantity = prevWave.getOrDefault(addedMonster, 0);
|
||||
|
||||
prevWave.put(addedMonster, addedMonsterQuantity + 1);
|
||||
|
||||
WAVES.add(prevWave);
|
||||
}
|
||||
}
|
||||
|
||||
@Provides
|
||||
InfernoConfig provideConfig(ConfigManager configManager)
|
||||
@@ -96,6 +156,7 @@ public class InfernoPlugin extends Plugin
|
||||
overlayManager.add(infernoOverlay);
|
||||
overlayManager.add(infernoInfobox);
|
||||
overlayManager.add(nibblerOverlay);
|
||||
overlayManager.add(waveOverlay);
|
||||
monsters = new HashMap<>();
|
||||
monsterCurrentAttackMap = new HashMap<>(6);
|
||||
for (int i = 1; i <= 6; i++)
|
||||
@@ -112,6 +173,7 @@ public class InfernoPlugin extends Plugin
|
||||
overlayManager.remove(infernoInfobox);
|
||||
overlayManager.remove(infernoOverlay);
|
||||
overlayManager.remove(nibblerOverlay);
|
||||
overlayManager.remove(waveOverlay);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@@ -148,6 +210,35 @@ public class InfernoPlugin extends Plugin
|
||||
nibblers.remove(npc);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onGameStateChanged(GameStateChanged event)
|
||||
{
|
||||
if (event.getGameState() != GameState.LOGGED_IN)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!inInferno())
|
||||
{
|
||||
currentWave = -1;
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onChatMessage(ChatMessage event)
|
||||
{
|
||||
final Matcher waveMatcher = WAVE_PATTERN.matcher(event.getMessage());
|
||||
|
||||
if (event.getType() != ChatMessageType.GAMEMESSAGE
|
||||
|| !inInferno()
|
||||
|| !waveMatcher.matches())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
currentWave = Integer.parseInt(waveMatcher.group(1));
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onGameTick(GameTick event)
|
||||
@@ -271,5 +362,15 @@ public class InfernoPlugin extends Plugin
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean inInferno()
|
||||
{
|
||||
if (client.getMapRegions()[0] = 9043) return;;
|
||||
}
|
||||
|
||||
}
|
||||
static String formatMonsterQuantity(final InfernoWaveMonster monster, final int quantity)
|
||||
{
|
||||
return String.format("%dx %s", quantity, monster);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Jordan Atwood <jordan.atwood423@gmail.com>
|
||||
* 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.inferno;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public enum InfernoWaveDisplayMode
|
||||
{
|
||||
CURRENT("Current wave"),
|
||||
NEXT("Next wave"),
|
||||
BOTH("Both");
|
||||
|
||||
private final String name;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Jordan Atwood <jordan.atwood423@gmail.com>
|
||||
* 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.inferno;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
@AllArgsConstructor
|
||||
enum InfernoWaveMonster
|
||||
{
|
||||
|
||||
JAL_NIB("Jal-Nib", 32),
|
||||
JAL_MEJRAH("Jal-MejRah", 85),
|
||||
JAL_AK("Jal-Ak", 165),
|
||||
JAL_IMKOT("Jal-ImKot", 240),
|
||||
JAL_XIL("Jal-XIL", 370),
|
||||
JAL_ZEK("Jal-Zek", 490),
|
||||
JALTOK_JAD("JalTok-Jad", 900),
|
||||
TZKAL_ZUK("TzKal-Zuk", 1400);
|
||||
|
||||
private final String name;
|
||||
private final int level;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return String.format("%s - Level %s", name, level);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Jordan Atwood <jordan.atwood423@gmail.com>
|
||||
* 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.inferno;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics2D;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.client.ui.ColorScheme;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||
import net.runelite.client.ui.overlay.components.PanelComponent;
|
||||
import net.runelite.client.ui.overlay.components.TitleComponent;
|
||||
import net.runelite.client.ui.overlay.components.table.TableComponent;
|
||||
|
||||
class WaveOverlay extends Overlay
|
||||
{
|
||||
private static final Color HEADER_COLOR = ColorScheme.BRAND_ORANGE;
|
||||
|
||||
private final InfernoConfig config;
|
||||
private final InfernoPlugin plugin;
|
||||
|
||||
private final PanelComponent panelComponent = new PanelComponent();
|
||||
|
||||
@Inject
|
||||
private WaveOverlay(InfernoConfig config, InfernoPlugin plugin)
|
||||
{
|
||||
setPosition(OverlayPosition.TOP_RIGHT);
|
||||
this.config = config;
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension render(Graphics2D graphics)
|
||||
{
|
||||
if (!plugin.inInferno()
|
||||
|| plugin.getCurrentWave() < 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
panelComponent.getChildren().clear();
|
||||
|
||||
final int currentWave = plugin.getCurrentWave();
|
||||
final int waveIndex = currentWave - 1;
|
||||
|
||||
if (config.waveDisplay() == WaveDisplayMode.CURRENT
|
||||
|| config.waveDisplay() == WaveDisplayMode.BOTH)
|
||||
{
|
||||
final Map<WaveMonster, Integer> waveContents = InfernoPlugin.getWAVES().get(waveIndex);
|
||||
|
||||
addWaveInfo("Wave " + plugin.getCurrentWave(), waveContents);
|
||||
}
|
||||
|
||||
if ((config.waveDisplay() == WaveDisplayMode.NEXT
|
||||
|| config.waveDisplay() == WaveDisplayMode.BOTH)
|
||||
&& currentWave != InfernoPlugin.MAX_WAVE)
|
||||
{
|
||||
final Map<WaveMonster, Integer> waveContents = InfernoPlugin.getWAVES().get(waveIndex + 1);
|
||||
|
||||
addWaveInfo("Next wave", waveContents);
|
||||
}
|
||||
|
||||
return panelComponent.render(graphics);
|
||||
}
|
||||
|
||||
private void addWaveInfo(final String headerText, final Map<WaveMonster, Integer> waveContents)
|
||||
{
|
||||
panelComponent.getChildren().add(TitleComponent.builder()
|
||||
.text(headerText)
|
||||
.color(HEADER_COLOR)
|
||||
.build());
|
||||
|
||||
TableComponent tableComponent = new TableComponent();
|
||||
|
||||
for (String line : buildWaveLines(waveContents))
|
||||
{
|
||||
tableComponent.addRow(line);
|
||||
}
|
||||
|
||||
panelComponent.getChildren().add(tableComponent);
|
||||
}
|
||||
|
||||
private static Collection<String> buildWaveLines(final Map<WaveMonster, Integer> wave)
|
||||
{
|
||||
final List<Map.Entry<WaveMonster, Integer>> monsters = new ArrayList<>(wave.entrySet());
|
||||
monsters.sort(Map.Entry.comparingByKey());
|
||||
final List<String> outputLines = new ArrayList<>();
|
||||
|
||||
for (Map.Entry<WaveMonster, Integer> monsterEntry : monsters)
|
||||
{
|
||||
final WaveMonster monster = monsterEntry.getKey();
|
||||
final int quantity = monsterEntry.getValue();
|
||||
final String line = InfernoPlugin.formatMonsterQuantity(monster, quantity);
|
||||
|
||||
outputLines.add(line);
|
||||
}
|
||||
|
||||
return outputLines;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user