This commit is contained in:
James Munson
2019-04-19 22:41:28 -07:00
12 changed files with 863 additions and 54 deletions

View File

@@ -556,7 +556,7 @@ public class WidgetID
static final int CURRENT_WAVE_WIDGET = 4;
static final int CURRENT_WAVE = 5;
static final int CALL_WIDGET = 6;
static final int CALL_TEXT = 7;
static final int HEARD_CALL = 7;
static final int TO_CALL_WIDGET = 8;
static final int TO_CALL = 9;
static final int ROLE_SPRITE = 10;

View File

@@ -351,6 +351,7 @@ public enum WidgetInfo
BA_COLL_WAVE_TEXT(WidgetID.BA_COLLECTOR_GROUP_ID, WidgetID.BarbarianAssault.CURRENT_WAVE),
BA_COLL_CALL_TEXT(WidgetID.BA_COLLECTOR_GROUP_ID, WidgetID.BarbarianAssault.TO_CALL),
BA_COLL_LISTEN_TEXT(WidgetID.BA_COLLECTOR_GROUP_ID, WidgetID.BarbarianAssault.CORRECT_STYLE),
BA_COLL_HEARD_TEXT(WidgetID.BA_COLLECTOR_GROUP_ID, WidgetID.BarbarianAssault.HEARD_CALL),
BA_COLL_ROLE_TEXT(WidgetID.BA_COLLECTOR_GROUP_ID, WidgetID.BarbarianAssault.ROLE),
BA_COLL_ROLE_SPRITE(WidgetID.BA_COLLECTOR_GROUP_ID, WidgetID.BarbarianAssault.ROLE_SPRITE),

View File

@@ -37,17 +37,52 @@ public interface BarbarianAssaultConfig extends Config
name = "Show call change timer",
description = "Show time to next call change"
)
default boolean showTimer()
{
return true;
}
default boolean showTimer() { return true; }
@ConfigItem(
keyName = "waveTimes",
name = "Show wave and game duration",
description = "Displays wave and game duration"
)
default boolean waveTimes() { return true; }
@ConfigItem(
keyName = "showEggCountMessage",
name = "Show count of eggs collected as collector.",
description = "Display egg count as collector after each wave",
position = 0
)
default boolean showEggCount() { return false; }
@ConfigItem(
keyName = "showEggCountOverlay",
name = "Overlay of eggs counted",
description = "Display current egg count as collector",
position = 1
)
default boolean showEggCountOverlay() { return false; }
@ConfigItem(
keyName = "showHpCountMessage",
name = "Show count of Hp healed as healer.",
description = "Display healed count as healer after each wave",
position = 2
)
default boolean showHpCount() { return false; }
@ConfigItem(
keyName = "showHpCountOverlay",
name = "Overlay of Hp counted",
description = "Display current healed count as healer",
position = 3
)
default boolean showHpCountOverlay() { return false; }
@ConfigItem(
keyName = "highlightCollectorEggs",
name = "Highlight collector eggs",
description = "Highlight called egg colors"
)
default boolean waveTimes()
default boolean highlightCollectorEggs()
{
return true;
}

View File

@@ -24,24 +24,37 @@
*/
package net.runelite.client.plugins.barbarianassault;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Polygon;
import java.awt.Rectangle;
import java.awt.Stroke;
import java.util.Map;
import javax.inject.Inject;
import lombok.Getter;
import lombok.Setter;
import net.runelite.api.Client;
import net.runelite.api.GameState;
import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG;
import net.runelite.api.Perspective;
import net.runelite.api.Player;
import net.runelite.api.Point;
import net.runelite.api.coords.LocalPoint;
import net.runelite.api.coords.WorldPoint;
import net.runelite.api.widgets.Widget;
import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayLayer;
import static net.runelite.client.ui.overlay.OverlayManager.OPTION_CONFIGURE;
import net.runelite.client.ui.overlay.OverlayMenuEntry;
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.OverlayUtil;
class BarbarianAssaultOverlay extends Overlay
{
private static final int MAX_EGG_DISTANCE = 2500;
private final Client client;
private final BarbarianAssaultPlugin plugin;
private final BarbarianAssaultConfig config;
@@ -82,12 +95,95 @@ class BarbarianAssaultOverlay extends Overlay
if (config.showTimer() && roleText != null && roleSprite != null)
{
roleText.setText(String.format("00:%02d", currentRound.getTimeToChange()));
if (config.showEggCountOverlay() && role.equals(Role.COLLECTOR))
{
roleText.setText(String.format("(%d) 00:%02d", plugin.getCollectedEggCount(), currentRound.getTimeToChange()));
}
else if (config.showHpCountOverlay() && role.equals(Role.HEALER))
{
roleText.setText(String.format("(%d) 00:%02d", plugin.getHpHealed(), currentRound.getTimeToChange()));
}
else
{
roleText.setText(String.format("00:%02d", currentRound.getTimeToChange()));
}
Rectangle spriteBounds = roleSprite.getBounds();
roleSprite.setHidden(true);
graphics.drawImage(plugin.getClockImage(), spriteBounds.x, spriteBounds.y, null);
}
if (role == Role.COLLECTOR && config.highlightCollectorEggs())
{
String heardCall = plugin.getCollectorHeardCall();
Color highlightColor;
Map<WorldPoint, Integer> calledEggMap;
Map<WorldPoint, Integer> yellowEggMap = plugin.getYellowEggs();
switch (heardCall)
{
case "Red eggs":
calledEggMap = plugin.getRedEggs();
highlightColor = Color.RED;
break;
case "Green eggs":
calledEggMap = plugin.getGreenEggs();
highlightColor = Color.GREEN;
break;
case "Blue eggs":
calledEggMap = plugin.getBlueEggs();
highlightColor = Color.BLUE;
break;
default:
calledEggMap = null;
highlightColor = null;
}
if (calledEggMap != null)
{
for (WorldPoint worldPoint : calledEggMap.keySet())
{
int quantity = calledEggMap.get(worldPoint);
renderEggLocation(graphics, worldPoint, quantity, highlightColor);
}
}
// Always show yellow eggs
for (WorldPoint worldPoint : yellowEggMap.keySet())
{
int quantity = yellowEggMap.get(worldPoint);
renderEggLocation(graphics, worldPoint, quantity, highlightColor);
}
}
return null;
}
private void renderEggLocation(Graphics2D graphics, WorldPoint location, int quantity, Color color)
{
LocalPoint groundPoint = LocalPoint.fromWorld(client, location);
Player player = client.getLocalPlayer();
if (groundPoint == null || player == null)
{
return;
}
if (player.getLocalLocation().distanceTo(groundPoint) > MAX_EGG_DISTANCE)
{
return;
}
Polygon poly = Perspective.getCanvasTilePoly(client, groundPoint);
final Stroke originalStroke = graphics.getStroke();
graphics.setColor(color);
graphics.setStroke(new BasicStroke(2));
graphics.drawPolygon(poly);
graphics.setStroke(originalStroke);
String quantityText = "x" + quantity;
Point textPoint = Perspective.getCanvasTextLocation(client, graphics, groundPoint, quantityText, 0);
OverlayUtil.renderTextLocation(graphics, textPoint, quantityText, Color.WHITE);
}
}

View File

@@ -28,13 +28,21 @@ package net.runelite.client.plugins.barbarianassault;
import com.google.inject.Provides;
import java.awt.Font;
import java.awt.Image;
import java.util.HashMap;
import javax.inject.Inject;
import lombok.AccessLevel;
import lombok.Getter;
import net.runelite.api.ChatMessageType;
import net.runelite.api.Client;
import net.runelite.api.ItemID;
import net.runelite.api.Player;
import net.runelite.api.Tile;
import net.runelite.api.Varbits;
import net.runelite.api.coords.WorldPoint;
import net.runelite.api.events.ChatMessage;
import net.runelite.api.events.GameTick;
import net.runelite.api.events.ItemDespawned;
import net.runelite.api.events.ItemSpawned;
import net.runelite.api.events.VarbitChanged;
import net.runelite.api.events.WidgetLoaded;
import net.runelite.api.kit.KitType;
@@ -58,18 +66,42 @@ import net.runelite.client.util.ImageUtil;
description = "Show a timer to the next call change and game/wave duration in chat.",
tags = {"minigame", "overlay", "timer"}
)
public class BarbarianAssaultPlugin extends Plugin
{
public class BarbarianAssaultPlugin extends Plugin {
private static final int BA_WAVE_NUM_INDEX = 2;
private static final String START_WAVE = "1";
private static final String ENDGAME_REWARD_NEEDLE_TEXT = "<br>5";
@Getter
private int collectedEggCount = 0;
@Getter
private int positiveEggCount = 0;
@Getter
private int wrongEggs = 0;
@Getter
private int HpHealed = 0;
@Getter
private int totalCollectedEggCount = 0;
@Getter
private int totalHpHealed = 0;
private Font font;
private Image clockImage;
private int inGameBit = 0;
private String currentWave = START_WAVE;
private GameTimer gameTime;
@Getter(AccessLevel.PACKAGE)
private HashMap<WorldPoint, Integer> redEggs;
@Getter(AccessLevel.PACKAGE)
private HashMap<WorldPoint, Integer> greenEggs;
@Getter(AccessLevel.PACKAGE)
private HashMap<WorldPoint, Integer> blueEggs;
@Getter(AccessLevel.PACKAGE)
private HashMap<WorldPoint, Integer> yellowEggs;
@Inject
private Client client;
@@ -86,45 +118,69 @@ public class BarbarianAssaultPlugin extends Plugin
private BarbarianAssaultOverlay overlay;
@Provides
BarbarianAssaultConfig provideConfig(ConfigManager configManager)
{
BarbarianAssaultConfig provideConfig(ConfigManager configManager) {
return configManager.getConfig(BarbarianAssaultConfig.class);
}
@Override
protected void startUp() throws Exception
{
protected void startUp() throws Exception {
overlayManager.add(overlay);
font = FontManager.getRunescapeFont()
.deriveFont(Font.BOLD, 24);
.deriveFont(Font.BOLD, 24);
clockImage = ImageUtil.getResourceStreamFromClass(getClass(), "clock.png");
redEggs = new HashMap<>();
greenEggs = new HashMap<>();
blueEggs = new HashMap<>();
yellowEggs = new HashMap<>();
}
@Override
protected void shutDown() throws Exception
{
protected void shutDown() throws Exception {
overlayManager.remove(overlay);
gameTime = null;
currentWave = START_WAVE;
inGameBit = 0;
collectedEggCount = 0;
positiveEggCount = 0;
wrongEggs = 0;
HpHealed = 0;
}
@Subscribe
public void onWidgetLoaded(WidgetLoaded event)
{
if (event.getGroupId() == WidgetID.BA_REWARD_GROUP_ID)
{
public void onWidgetLoaded(WidgetLoaded event) {
if (event.getGroupId() == WidgetID.BA_REWARD_GROUP_ID) {
Widget rewardWidget = client.getWidget(WidgetInfo.BA_REWARD_TEXT);
String amt,type,totalMsg,total;
amt=type=totalMsg=total="";
if (config.waveTimes() && rewardWidget != null && rewardWidget.getText().contains(ENDGAME_REWARD_NEEDLE_TEXT) && gameTime != null) {
if (config.showHpCount() && HpHealed > 0) {
totalMsg = "; Total Healed: ";
total = ""+totalHpHealed;
if (HpHealed > 504)
{
total = ""+504;
}
}
else if (config.showEggCount() && collectedEggCount > 0) {
collectedEggCount -= wrongEggs; //true positive egg count
if (collectedEggCount > 60)
{
collectedEggCount = 60;
}
collectedEggCount -= wrongEggs; //true positive - negative egg count\
totalMsg = "; Total Collected: ";
total = "" + totalCollectedEggCount;
if (config.waveTimes() && rewardWidget != null && rewardWidget.getText().contains(ENDGAME_REWARD_NEEDLE_TEXT) && gameTime != null)
{
announceTime("Game finished, duration: ", gameTime.getTime(false));
}
announceTime("Game finished, duration: ", gameTime.getTime(false),type, amt, totalMsg, total);
}
}
}
@Subscribe
public void onChatMessage(ChatMessage event)
{
if (event.getType() == ChatMessageType.GAMEMESSAGE
@@ -132,28 +188,36 @@ public class BarbarianAssaultPlugin extends Plugin
{
String[] message = event.getMessage().split(" ");
currentWave = message[BA_WAVE_NUM_INDEX];
collectedEggCount = 0;
HpHealed = 0;
if (currentWave.equals(START_WAVE))
{
if (currentWave.equals(START_WAVE)) {
gameTime = new GameTimer();
}
else if (gameTime != null)
{
totalHpHealed = 0;
totalCollectedEggCount = 0;
} else if (gameTime != null) {
gameTime.setWaveStartTime();
}
} else if (event.getType() == ChatMessageType.GAMEMESSAGE
&& event.getMessage().contains("egg explode")) {
wrongEggs --;
} else if (event.getType() == ChatMessageType.GAMEMESSAGE
&& event.getMessage().contains("healed")) {
String message = event.getMessage();
String[] tokens = message.split(" ");
if (Integer.parseInt(tokens[2]) > 0) {
int Hp = Integer.parseInt(tokens[2]);
HpHealed += Hp;
}
}
}
@Subscribe
public void onGameTick(GameTick event)
{
if (client.getVar(Varbits.IN_GAME_BA) == 0 || client.getLocalPlayer() == null || overlay.getCurrentRound() != null)
{
public void onGameTick(GameTick event) {
if (client.getVar(Varbits.IN_GAME_BA) == 0 || client.getLocalPlayer() == null || overlay.getCurrentRound() != null) {
return;
}
switch (client.getLocalPlayer().getPlayerComposition().getEquipmentId(KitType.CAPE))
{
switch (client.getLocalPlayer().getPlayerComposition().getEquipmentId(KitType.CAPE)) {
case ItemID.ATTACKER_ICON:
overlay.setCurrentRound(new Round(Role.ATTACKER));
break;
@@ -170,39 +234,159 @@ public class BarbarianAssaultPlugin extends Plugin
}
@Subscribe
public void onVarbitChanged(VarbitChanged event)
{
public void onVarbitChanged(VarbitChanged event) {
int inGame = client.getVar(Varbits.IN_GAME_BA);
if (inGameBit != inGame)
{
if (inGameBit == 1)
{
String amt,type,totalMsg,total;
amt=type=totalMsg=total="";
if (inGameBit != inGame) {
if (inGameBit == 1) {
overlay.setCurrentRound(null);
if (config.waveTimes() && gameTime != null)
{
announceTime("Wave " + currentWave + " duration: ", gameTime.getTime(true));
if (config.waveTimes() && gameTime != null) {
totalCollectedEggCount += collectedEggCount;
totalHpHealed += HpHealed;
if (config.showHpCount() && HpHealed > 0) {
amt = "" + HpHealed;
type = "; Healed: ";
totalMsg = "; Total Healed: ";
total = ""+totalHpHealed;
}
else if (config.showEggCount() && collectedEggCount > 0) {
amt = "" + collectedEggCount;
type = "; Collected: ";
totalMsg = "; Total Collected: ";
total = ""+totalCollectedEggCount;
}
if (currentWave.equals("10"))
{
totalMsg=total="";
}
announceTime("Wave " + currentWave + " duration: ", gameTime.getTime(true), type, amt, totalMsg, total);
}
}
}
inGameBit = inGame;
}
private void announceTime(String preText, String time)
@Subscribe
public void onItemSpawned(ItemSpawned itemSpawned)
{
int itemId = itemSpawned.getItem().getId();
WorldPoint worldPoint = itemSpawned.getTile().getWorldLocation();
HashMap<WorldPoint, Integer> eggMap = getEggMap(itemId);
if (eggMap != null)
{
Integer existingQuantity = eggMap.putIfAbsent(worldPoint, 1);
if (existingQuantity != null)
{
eggMap.put(worldPoint, existingQuantity + 1);
}
}
}
@Subscribe
public void onItemDespawned(ItemDespawned itemDespawned)
{
int itemId = itemDespawned.getItem().getId();
WorldPoint worldPoint = itemDespawned.getTile().getWorldLocation();
HashMap<WorldPoint, Integer> eggMap = getEggMap(itemId);
if (eggMap != null && eggMap.containsKey(worldPoint))
{
int quantity = eggMap.get(worldPoint);
if (quantity > 1)
{
eggMap.put(worldPoint, quantity - 1);
}
else
{
eggMap.remove(worldPoint);
}
}
if (client.getVar(Varbits.IN_GAME_BA) == 0 || !isEgg(itemDespawned.getItem().getId()))
{
return;
}
if (isUnderPlayer(itemDespawned.getTile()))
{
collectedEggCount++;
}
}
String getCollectorHeardCall()
{
Widget widget = client.getWidget(WidgetInfo.BA_COLL_HEARD_TEXT);
String call = null;
if (widget != null)
{
call = widget.getText();
}
return call;
}
private HashMap<WorldPoint, Integer> getEggMap(int itemID)
{
switch (itemID)
{
case ItemID.RED_EGG:
return redEggs;
case ItemID.GREEN_EGG:
return greenEggs;
case ItemID.BLUE_EGG:
return blueEggs;
case ItemID.YELLOW_EGG:
return yellowEggs;
default:
return null;
}
}
private void announceTime(String preText, String time, String type, String amt, String totalMsg, String total) {
final String chatMessage = new ChatMessageBuilder()
.append(ChatColorType.NORMAL)
.append(preText)
.append(ChatColorType.HIGHLIGHT)
.append(time)
.build();
.append(ChatColorType.NORMAL)
.append(preText)
.append(ChatColorType.HIGHLIGHT)
.append(time)
.append(ChatColorType.NORMAL)
.append(type)
.append(ChatColorType.HIGHLIGHT)
.append(amt)
.append(ChatColorType.NORMAL)
.append(totalMsg)
.append(ChatColorType.HIGHLIGHT)
.append(total)
.build();
chatMessageManager.queue(QueuedMessage.builder()
.type(ChatMessageType.CONSOLE)
.runeLiteFormattedMessage(chatMessage)
.build());
.type(ChatMessageType.CONSOLE)
.runeLiteFormattedMessage(chatMessage)
.build());
}
private boolean isEgg(int itemID)
{
if (itemID == ItemID.RED_EGG || itemID == ItemID.GREEN_EGG
|| itemID == ItemID.BLUE_EGG || itemID == ItemID.YELLOW_EGG)
{
return true;
}
return false;
}
private boolean isUnderPlayer(Tile tile) {
Player local = client.getLocalPlayer();
if (local == null)
{
return false;
}
return (tile.getWorldLocation().equals(local.getWorldLocation()));
}
public Font getFont()

View File

@@ -0,0 +1,83 @@
/*
* Copyright (c) 2018, Cameron <https://github.com/noremac201>
* 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.barbarianassault;
import java.util.HashMap;
import java.util.Map;
public enum Calls
{ //Attacker Calls
RED_EGG("Red egg", "Tell-red"),
GREEN_EGG("Green egg", "Tell-green"),
BLUE_EGG("Blue egg", "Tell-blue"),
//Collector Calls
CONTROLLED("Controlled/Bullet/Wind", "Tell-controlled"),
ACCURATE("Accurate/Field/Water", "Tell-accurate"),
AGGRESSIVE("Aggressive/Blunt/Earth", "Tell-aggressive"),
DEFENSIVE("Defensive/Barbed/Fire", "Tell-defensive"),
//Healer Calls
TOFU("Tofu", "Tell-tofu"),
CRACKERS("Crackers", "Tell-crackers"),
WORMS("Worms", "Tell-worms"),
//Defender Calls
POIS_WORMS("Pois. Worms", "Tell-worms"),
POIS_TOFU("Pois. Tofu", "Tell-tofu"),
POIS_MEAT("Pois. Meat", "Tell-meat");
private final String call;
private final String option;
private static final Map<String, String> CALL_MENU = new HashMap<>();
static
{
for (Calls s : values())
{
CALL_MENU.put(s.getCall(), s.getOption());
}
}
Calls(String call, String option)
{
this.call = call;
this.option = option;
}
public String getCall()
{
return call;
}
public String getOption()
{
return option;
}
public static String getOption(String call)
{
return CALL_MENU.get(call);
}
}

View File

@@ -0,0 +1,34 @@
package net.runelite.client.plugins.whalewatchers;
import java.awt.*;
import net.runelite.client.config.*;
@ConfigGroup("WhaleWatchers")
public interface WhaleWatchersConfig extends Config
{
@ConfigItem(position = 1, keyName = "protectItemWarning", name = "Protect Item Warning", description = "Warns you when you are skulled and don't have protect item turned on.")
default boolean protectItemWarning() {
return false;
}
@ConfigItem(position = 2, keyName = "showDamageCounter", name = "Damage Counter", description = "Shows damage you've done and damage your opponent has done to you while in a fight")
default boolean showDamageCounter() {
return true;
}
@Alpha
@ConfigItem(position = 3, keyName = "damageBackgroundColor", name = "Counter Background Color", description = "The background color for the damage counter overlay")
default Color damageBackgroundColor() {
return Color.darkGray;
}
@ConfigItem(position = 4, keyName = "smiteableWarning", name = "Smite Warning", description = "Displays a warning overlay when your prayer is at a smiteable level")
default boolean smiteableWarning() {
return true;
}
@ConfigItem(position = 5, keyName = "gloryWarning", name = "Glory Warning", description = "Displays a warning box while you are wearing an uncharged glory")
default boolean gloryWarning() {
return true;
}
}

View File

@@ -0,0 +1,48 @@
package net.runelite.client.plugins.whalewatchers;
import net.runelite.api.*;
import javax.inject.*;
import net.runelite.client.ui.overlay.*;
import net.runelite.api.kit.*;
import java.awt.*;
import net.runelite.client.ui.overlay.components.*;
import java.awt.image.*;
import net.runelite.client.game.*;
public class WhaleWatchersGloryOverlay extends Overlay
{
private Client client;
private final WhaleWatchersConfig config;
private WhaleWatchersPlugin plugin;
private PanelComponent panelComponent;
@Inject
private ItemManager itemManager;
@Inject
public WhaleWatchersGloryOverlay(final WhaleWatchersConfig config, final Client client, final WhaleWatchersPlugin plugin) {
this.client = client;
this.config = config;
this.plugin = plugin;
this.setLayer(OverlayLayer.ABOVE_WIDGETS);
this.setPriority(OverlayPriority.HIGH);
this.setPosition(OverlayPosition.DETACHED);
this.panelComponent = new PanelComponent();
}
@Override
public Dimension render(final Graphics2D graphics) {
this.panelComponent.getChildren().clear();
int amuletID = 0;
try {
amuletID = this.client.getLocalPlayer().getPlayerComposition().getEquipmentId(KitType.AMULET);
}
catch (NullPointerException ex) {}
if (this.config.gloryWarning() && amuletID == 1704) {
this.panelComponent.setBackgroundColor(Color.lightGray);
final AsyncBufferedImage gloryImage = this.itemManager.getImage(1704);
this.panelComponent.getChildren().add(TitleComponent.builder().text("Uncharged Glory").color(Color.BLACK).build());
this.panelComponent.getChildren().add(new ImageComponent(gloryImage));
}
return this.panelComponent.render(graphics);
}
}

View File

@@ -0,0 +1,51 @@
package net.runelite.client.plugins.whalewatchers;
import net.runelite.api.*;
import net.runelite.client.ui.overlay.*;
import javax.inject.*;
import net.runelite.client.ui.overlay.components.*;
import java.awt.*;
public class WhaleWatchersOverlay extends Overlay
{
private Client client;
private final WhaleWatchersConfig config;
private WhaleWatchersPlugin plugin;
private PanelComponent panelComponent;
private String lastOpponent;
@Inject
public WhaleWatchersOverlay(final WhaleWatchersConfig config, final Client client, final WhaleWatchersPlugin plugin) {
this.lastOpponent = "-";
this.client = client;
this.config = config;
this.plugin = plugin;
this.setLayer(OverlayLayer.ABOVE_WIDGETS);
this.setPriority(OverlayPriority.HIGH);
this.setPosition(OverlayPosition.DETACHED);
this.panelComponent = new PanelComponent();
}
@Override
public Dimension render(final Graphics2D graphics) {
this.panelComponent.getChildren().clear();
if (this.plugin.inCombat && this.config.showDamageCounter()) {
this.panelComponent.setBackgroundColor(this.config.damageBackgroundColor());
final String opp = (this.client.getLocalPlayer().getInteracting() != null) ? this.client.getLocalPlayer().getInteracting().getName() : this.lastOpponent;
if (this.client.getLocalPlayer().getInteracting() != null) {
this.lastOpponent = this.client.getLocalPlayer().getInteracting().getName();
}
final String opponent = "Fight vs " + opp;
final String damageTaken = "Damage Taken: " + this.plugin.damageTaken;
final String damageDealt = "Damage Dealt: " + this.plugin.damageDone;
this.panelComponent.getChildren().add(TitleComponent.builder().text(opponent).color(Color.BLACK).build());
this.panelComponent.getChildren().add(TitleComponent.builder().text(damageDealt).color(Color.BLACK).build());
this.panelComponent.getChildren().add(TitleComponent.builder().text(damageTaken).color(Color.BLACK).build());
this.panelComponent.setPreferredSize(new Dimension(graphics.getFontMetrics().stringWidth(damageDealt) + graphics.getFontMetrics().stringWidth(opponent) + 10, 0));
}
else {
this.panelComponent.getChildren().clear();
}
return this.panelComponent.render(graphics);
}
}

View File

@@ -0,0 +1,194 @@
package net.runelite.client.plugins.whalewatchers;
import org.jetbrains.annotations.*;
import net.runelite.client.plugins.*;
import net.runelite.client.game.*;
import net.runelite.client.config.*;
import com.google.inject.*;
import net.runelite.client.ui.overlay.*;
import net.runelite.client.eventbus.*;
import net.runelite.api.kit.*;
import org.apache.commons.lang3.*;
import net.runelite.api.*;
import net.runelite.api.events.*;
import java.util.*;
@PluginDescriptor(name = "<font color=\"aqua\">!Whale Watchers</font>", description = "A Plugin to save help whales in the wild", tags = { "whale watchers", "whale", "protect item", "warning", "pklite" }, enabledByDefault = true, hidden = false, developerPlugin = false, loadWhenOutdated = false)
public class WhaleWatchersPlugin extends Plugin
{
@Inject
private Client client;
@Inject
private WhaleWatchersConfig config;
@Inject
private WhaleWatchersOverlay overlay;
@Inject
private WhaleWatchersProtOverlay whaleWatchersProtOverlay;
@Inject
private WhaleWatchersSmiteableOverlay whaleWatchersSmiteableOverlay;
@Inject
private WhaleWatchersGloryOverlay whaleWatchersGloryOverlay;
@Inject
private OverlayManager overlayManager;
@Inject
private ItemManager itemManager;
public boolean enableOverlay;
private int lastXP;
public int damageDone;
public int damageTaken;
public boolean inCombat;
private int tickCountdown;
private boolean displaySmiteOverlay;
private boolean displayGloryOverlay;
public WhaleWatchersPlugin() {
this.enableOverlay = false;
this.lastXP = 0;
this.damageDone = 0;
this.damageTaken = 0;
this.inCombat = false;
this.tickCountdown = 0;
}
@Provides
WhaleWatchersConfig getConfig(final ConfigManager configManager) {
return configManager.getConfig(WhaleWatchersConfig.class);
}
@Override
protected void startUp() throws Exception {
this.overlayManager.add(this.overlay);
this.overlayManager.add(this.whaleWatchersProtOverlay);
this.overlayManager.add(this.whaleWatchersSmiteableOverlay);
this.overlayManager.add(this.whaleWatchersGloryOverlay);
}
@Override
protected void shutDown() throws Exception {
this.overlayManager.remove(this.overlay);
this.overlayManager.remove(this.whaleWatchersProtOverlay);
this.overlayManager.remove(this.whaleWatchersSmiteableOverlay);
this.overlayManager.remove(this.whaleWatchersGloryOverlay);
}
@Subscribe
public void onHitsplatApplied(final HitsplatApplied event) {
if (this.config.showDamageCounter()) {
if (!(event.getActor() == this.client.getLocalPlayer() | event.getActor() == this.client.getLocalPlayer().getInteracting())) {
return;
}
if (this.isAttackingPlayer(this.client) || this.inCombat) {
this.inCombat = true;
if (event.getActor() == this.client.getLocalPlayer()) {
this.damageTaken += event.getHitsplat().getAmount();
}
if (event.getActor() == this.client.getLocalPlayer().getInteracting()) {
this.damageDone += event.getHitsplat().getAmount();
}
}
}
}
@Subscribe
public void onItemContainerChanged(final ItemContainerChanged event) {
if (this.config.gloryWarning() && event.getItemContainer().equals(InventoryID.EQUIPMENT)) {
final int amuletID = ObjectUtils.defaultIfNull(this.client.getLocalPlayer().getPlayerComposition().getEquipmentId(KitType.AMULET), 0);
if (amuletID == 1704) {
this.displayGloryOverlay = true;
}
else {
this.displayGloryOverlay = false;
}
}
else {
this.displayGloryOverlay = false;
}
}
@Subscribe
public void onExperienceChanged(final ExperienceChanged event) {
final Skill skill = event.getSkill();
final Player player = this.client.getLocalPlayer();
if (skill.equals(Skill.HITPOINTS) && player.getInteracting() instanceof Player) {
this.lastXP = this.client.getSkillExperience(skill);
}
}
@Subscribe
public void onMenuOptionClicked(final MenuOptionClicked event) {
if (this.config.showDamageCounter() && event.getMenuAction().equals(MenuAction.SPELL_CAST_ON_PLAYER)) {
this.inCombat = true;
}
}
@Subscribe
public void onVarbitChanged(final VarbitChanged event) {
if (this.config.showDamageCounter() && this.client.getVar(VarPlayer.ATTACKING_PLAYER) == -1 && this.inCombat) {
this.tickCountdown = 10;
}
if (this.config.protectItemWarning()) {
try {
if (this.client.getLocalPlayer().getSkullIcon() == SkullIcon.SKULL) {
if ((this.client.getVar(Varbits.PRAYER_PROTECT_ITEM) == 0 && this.client.getVar(Varbits.IN_WILDERNESS) == 1) || this.client.getWorldType().contains(WorldType.PVP)) {
this.enableOverlay = true;
}
if (this.client.getVar(Varbits.PRAYER_PROTECT_ITEM) == 1 || this.client.getVar(Varbits.IN_WILDERNESS) == 0 || this.client.getWorldType().contains(WorldType.PVP_HIGH_RISK) || this.client.getWorld() == 365) {
this.enableOverlay = false;
}
}
else {
this.enableOverlay = false;
}
}
catch (NullPointerException ex) {}
}
}
@Subscribe
public void onGameTick(final GameTick event) {
if (this.tickCountdown > 0 && this.tickCountdown < 11) {
--this.tickCountdown;
if (this.tickCountdown == 1 && !this.isAttackingPlayer(this.client)) {
this.inCombat = false;
this.damageDone = 0;
this.damageTaken = 0;
return;
}
}
if (this.config.smiteableWarning() && (this.client.getVar(Varbits.IN_WILDERNESS) == 1 || WorldType.isPvpWorld(this.client.getWorldType()))) {
if (this.client.getLocalPlayer().getSkullIcon() != null && this.client.getLocalPlayer().getSkullIcon().equals(SkullIcon.SKULL)) {
final int currentHealth = this.client.getLocalPlayer().getHealth();
final int currentPrayer = this.client.getBoostedSkillLevel(Skill.PRAYER);
if (currentPrayer <= Math.ceil(currentHealth / 4)) {
this.displaySmiteOverlay = true;
}
else {
this.displaySmiteOverlay = false;
}
}
else {
this.displaySmiteOverlay = false;
}
}
else {
this.displaySmiteOverlay = false;
}
}
public boolean isAttackingPlayer(@NotNull final Client c) {
if (this.client.getVar(Varbits.IN_WILDERNESS) == 1 && this.client.getLocalPlayer().getInteracting() != null) {
return true;
}
final int varp = c.getVar(VarPlayer.ATTACKING_PLAYER);
return varp != -1;
}
public boolean isDisplaySmiteOverlay() {
return this.displaySmiteOverlay;
}
public boolean isDisplayGloryOverlay() {
return this.displayGloryOverlay;
}
}

View File

@@ -0,0 +1,44 @@
package net.runelite.client.plugins.whalewatchers;
import javax.inject.*;
import net.runelite.api.Point;
import net.runelite.client.ui.*;
import net.runelite.api.*;
import net.runelite.client.ui.overlay.*;
import java.awt.*;
public class WhaleWatchersProtOverlay extends Overlay
{
private Client client;
private final WhaleWatchersConfig config;
private WhaleWatchersPlugin plugin;
@Inject
public WhaleWatchersProtOverlay(final WhaleWatchersConfig config, final Client client, final WhaleWatchersPlugin plugin) {
this.client = client;
this.config = config;
this.plugin = plugin;
this.setLayer(OverlayLayer.ABOVE_WIDGETS);
this.setPriority(OverlayPriority.HIGH);
this.setPosition(OverlayPosition.DYNAMIC);
}
@Override
public Dimension render(final Graphics2D graphics) {
if (this.plugin.enableOverlay && this.config.protectItemWarning()) {
final Rectangle rectangle = new Rectangle();
rectangle.setBounds(this.client.getCanvas().getBounds());
rectangle.setLocation(this.client.getCanvas().getLocation());
final Stroke oldStroke = graphics.getStroke();
graphics.setStroke(new BasicStroke(10.0f));
graphics.setColor(Color.RED);
graphics.draw(rectangle);
final Font font = FontManager.getRunescapeBoldFont().deriveFont(1, 72.0f);
graphics.setFont(font);
OverlayUtil.renderTextLocation(graphics, new Point((int)rectangle.getCenterX() - 50, font.getSize()), "Protect item prayer disabled!!!", Color.red);
graphics.setStroke(oldStroke);
}
return null;
}
}

View File

@@ -0,0 +1,39 @@
package net.runelite.client.plugins.whalewatchers;
import net.runelite.api.*;
import net.runelite.client.ui.overlay.*;
import javax.inject.*;
import java.awt.*;
import net.runelite.client.ui.overlay.components.*;
public class WhaleWatchersSmiteableOverlay extends Overlay
{
private Client client;
private WhaleWatchersPlugin plugin;
private PanelComponent panelComponent;
@Inject
public WhaleWatchersSmiteableOverlay(final WhaleWatchersPlugin plugin) {
this.plugin = plugin;
this.setLayer(OverlayLayer.ABOVE_WIDGETS);
this.setPriority(OverlayPriority.HIGH);
this.setPosition(OverlayPosition.BOTTOM_RIGHT);
this.panelComponent = new PanelComponent();
}
@Override
public Dimension render(final Graphics2D graphics) {
final String subText = "You could be smited in 1 tick";
this.panelComponent.getChildren().clear();
if (this.plugin.isDisplaySmiteOverlay()) {
this.panelComponent.setBackgroundColor(Color.WHITE);
this.panelComponent.getChildren().add(TitleComponent.builder().text("LOW PRAYER WARNING").color(Color.BLACK).build());
this.panelComponent.getChildren().add(TitleComponent.builder().text(subText).color(Color.BLACK).build());
this.panelComponent.setPreferredSize(new Dimension(graphics.getFontMetrics().stringWidth(subText) + 20, 0));
}
else {
this.panelComponent.getChildren().clear();
}
return this.panelComponent.render(graphics);
}
}