zalcano: add damage counter
Adds a panel which tracks damage dealt to Zalcano's health and shield to make it easier prioritising what to focus on at a low level. Co-authored-by: Adam <Adam@sigterm.info>
This commit is contained in:
@@ -185,7 +185,14 @@ public enum VarPlayer
|
|||||||
/**
|
/**
|
||||||
* 0 = 2 buttons, 1 = 1 button
|
* 0 = 2 buttons, 1 = 1 button
|
||||||
*/
|
*/
|
||||||
MOUSE_BUTTONS(170);
|
MOUSE_BUTTONS(170),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Zalcano's form
|
||||||
|
* -1 : Player is outside or Zalcano is dead i.e. there's no healthbar to show
|
||||||
|
* Anything else : The {@link NpcID} of the current form
|
||||||
|
*/
|
||||||
|
ZALCANO_FORM(1683);
|
||||||
|
|
||||||
private final int id;
|
private final int id;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,85 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2020, dekvall <https://github.com/dekvall>
|
||||||
|
* 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.plugins.zalcano;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import net.runelite.client.ui.overlay.OverlayPanel;
|
||||||
|
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||||
|
import net.runelite.client.ui.overlay.components.LineComponent;
|
||||||
|
|
||||||
|
class ZalcanoPanel extends OverlayPanel
|
||||||
|
{
|
||||||
|
private final ZalcanoPlugin plugin;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public ZalcanoPanel(ZalcanoPlugin plugin)
|
||||||
|
{
|
||||||
|
super(plugin);
|
||||||
|
setPosition(OverlayPosition.ABOVE_CHATBOX_RIGHT);
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Dimension render(Graphics2D g)
|
||||||
|
{
|
||||||
|
if (!plugin.isInCavern())
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
panelComponent.getChildren().add(LineComponent.builder()
|
||||||
|
.left("Health damage:")
|
||||||
|
.leftColor(colorFromCount(plugin.getHealthDamage()))
|
||||||
|
.right(Integer.toString(plugin.getHealthDamage()))
|
||||||
|
.build());
|
||||||
|
|
||||||
|
panelComponent.getChildren().add(LineComponent.builder()
|
||||||
|
.left("Shield damage:")
|
||||||
|
.leftColor(colorFromCount(plugin.getShieldDamage()))
|
||||||
|
.right(Integer.toString(plugin.getShieldDamage()))
|
||||||
|
.build());
|
||||||
|
|
||||||
|
return super.render(g);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Color colorFromCount(int damage)
|
||||||
|
{
|
||||||
|
if (damage >= 50)
|
||||||
|
{
|
||||||
|
// Eligible for uniques/pet
|
||||||
|
return Color.GREEN;
|
||||||
|
}
|
||||||
|
if (damage >= 30)
|
||||||
|
{
|
||||||
|
// Eligible for drops
|
||||||
|
return Color.YELLOW;
|
||||||
|
}
|
||||||
|
return Color.RED;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -28,26 +28,32 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import net.runelite.api.Actor;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.GameObject;
|
import net.runelite.api.GameObject;
|
||||||
import net.runelite.api.GameState;
|
import net.runelite.api.GameState;
|
||||||
import static net.runelite.api.GraphicID.GRAPHICS_OBJECT_ROCKFALL;
|
import static net.runelite.api.GraphicID.GRAPHICS_OBJECT_ROCKFALL;
|
||||||
import net.runelite.api.GraphicsObject;
|
import net.runelite.api.GraphicsObject;
|
||||||
|
import net.runelite.api.Hitsplat;
|
||||||
import net.runelite.api.NPC;
|
import net.runelite.api.NPC;
|
||||||
import net.runelite.api.NpcID;
|
import net.runelite.api.NpcID;
|
||||||
import static net.runelite.api.NpcID.ZALCANO;
|
import static net.runelite.api.NpcID.ZALCANO;
|
||||||
import net.runelite.api.ObjectID;
|
import net.runelite.api.ObjectID;
|
||||||
import net.runelite.api.Projectile;
|
import net.runelite.api.Projectile;
|
||||||
import static net.runelite.api.ProjectileID.ZALCANO_PROJECTILE_FIREBALL;
|
import static net.runelite.api.ProjectileID.ZALCANO_PROJECTILE_FIREBALL;
|
||||||
|
import net.runelite.api.VarPlayer;
|
||||||
import net.runelite.api.coords.LocalPoint;
|
import net.runelite.api.coords.LocalPoint;
|
||||||
import net.runelite.api.coords.WorldPoint;
|
import net.runelite.api.coords.WorldPoint;
|
||||||
import net.runelite.api.events.GameObjectSpawned;
|
import net.runelite.api.events.GameObjectSpawned;
|
||||||
import net.runelite.api.events.GameStateChanged;
|
import net.runelite.api.events.GameStateChanged;
|
||||||
import net.runelite.api.events.GraphicsObjectCreated;
|
import net.runelite.api.events.GraphicsObjectCreated;
|
||||||
|
import net.runelite.api.events.HitsplatApplied;
|
||||||
import net.runelite.api.events.NpcChanged;
|
import net.runelite.api.events.NpcChanged;
|
||||||
import net.runelite.api.events.NpcDespawned;
|
import net.runelite.api.events.NpcDespawned;
|
||||||
import net.runelite.api.events.NpcSpawned;
|
import net.runelite.api.events.NpcSpawned;
|
||||||
import net.runelite.api.events.ProjectileMoved;
|
import net.runelite.api.events.ProjectileMoved;
|
||||||
|
import net.runelite.api.events.VarbitChanged;
|
||||||
|
import net.runelite.client.callback.ClientThread;
|
||||||
import net.runelite.client.eventbus.Subscribe;
|
import net.runelite.client.eventbus.Subscribe;
|
||||||
import net.runelite.client.plugins.Plugin;
|
import net.runelite.client.plugins.Plugin;
|
||||||
import net.runelite.client.plugins.PluginDescriptor;
|
import net.runelite.client.plugins.PluginDescriptor;
|
||||||
@@ -72,6 +78,12 @@ public class ZalcanoPlugin extends Plugin
|
|||||||
@Inject
|
@Inject
|
||||||
private ZalcanoOverlay overlay;
|
private ZalcanoOverlay overlay;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private ZalcanoPanel panel;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private ClientThread clientThread;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private LocalPoint targetedGlowingRock;
|
private LocalPoint targetedGlowingRock;
|
||||||
@Getter
|
@Getter
|
||||||
@@ -81,17 +93,35 @@ public class ZalcanoPlugin extends Plugin
|
|||||||
@Getter
|
@Getter
|
||||||
private final List<GraphicsObject> rocks = new ArrayList<>();
|
private final List<GraphicsObject> rocks = new ArrayList<>();
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private int healthDamage;
|
||||||
|
@Getter
|
||||||
|
private int shieldDamage;
|
||||||
|
@Getter
|
||||||
|
private boolean inCavern;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void startUp()
|
protected void startUp()
|
||||||
{
|
{
|
||||||
overlayManager.add(overlay);
|
overlayManager.add(overlay);
|
||||||
|
overlayManager.add(panel);
|
||||||
rocks.clear();
|
rocks.clear();
|
||||||
|
|
||||||
|
resetDamageCounter();
|
||||||
|
clientThread.invokeLater(() ->
|
||||||
|
{
|
||||||
|
if (client.getGameState() == GameState.LOGGED_IN)
|
||||||
|
{
|
||||||
|
inCavern = isHealthbarActive();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void shutDown()
|
protected void shutDown()
|
||||||
{
|
{
|
||||||
overlayManager.remove(overlay);
|
overlayManager.remove(overlay);
|
||||||
|
overlayManager.remove(panel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
@@ -107,12 +137,25 @@ public class ZalcanoPlugin extends Plugin
|
|||||||
@Subscribe
|
@Subscribe
|
||||||
public void onGameStateChanged(GameStateChanged event)
|
public void onGameStateChanged(GameStateChanged event)
|
||||||
{
|
{
|
||||||
if (event.getGameState() != GameState.LOGGED_IN)
|
GameState gameState = event.getGameState();
|
||||||
|
if (gameState == GameState.LOADING)
|
||||||
{
|
{
|
||||||
rocks.clear();
|
rocks.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onVarbitChanged(VarbitChanged event)
|
||||||
|
{
|
||||||
|
boolean wasInCavern = inCavern;
|
||||||
|
inCavern = isHealthbarActive();
|
||||||
|
|
||||||
|
if (!inCavern && wasInCavern)
|
||||||
|
{
|
||||||
|
resetDamageCounter();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onNpcSpawned(NpcSpawned event)
|
public void onNpcSpawned(NpcSpawned event)
|
||||||
{
|
{
|
||||||
@@ -142,6 +185,12 @@ public class ZalcanoPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void resetDamageCounter()
|
||||||
|
{
|
||||||
|
healthDamage = 0;
|
||||||
|
shieldDamage = 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onGameObjectSpawned(GameObjectSpawned event)
|
public void onGameObjectSpawned(GameObjectSpawned event)
|
||||||
{
|
{
|
||||||
@@ -183,4 +232,39 @@ public class ZalcanoPlugin extends Plugin
|
|||||||
targetedGlowingRockEndCycle = projectile.getEndCycle();
|
targetedGlowingRockEndCycle = projectile.getEndCycle();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onHitsplatApplied(HitsplatApplied event)
|
||||||
|
{
|
||||||
|
final Actor actor = event.getActor();
|
||||||
|
|
||||||
|
if (!(actor instanceof NPC))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int npcId = ((NPC) actor).getId();
|
||||||
|
if (!(npcId == ZALCANO_WEAKENED || npcId == ZALCANO))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Hitsplat hitsplat = event.getHitsplat();
|
||||||
|
int damage = hitsplat.getAmount();
|
||||||
|
|
||||||
|
switch (hitsplat.getHitsplatType())
|
||||||
|
{
|
||||||
|
case DAMAGE_ME:
|
||||||
|
healthDamage += damage;
|
||||||
|
break;
|
||||||
|
case DAMAGE_ME_ORANGE:
|
||||||
|
shieldDamage += damage;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isHealthbarActive()
|
||||||
|
{
|
||||||
|
return client.getVar(VarPlayer.ZALCANO_FORM) != -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user