Add highlights for mould, crucible, and kovac when relevant

This commit is contained in:
Patrick
2022-06-11 01:36:54 +04:00
parent ac7c764645
commit 7f03681768
4 changed files with 139 additions and 18 deletions

View File

@@ -2,11 +2,9 @@ package com.toofifty.easygiantsfoundry;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.GameObject;
import net.runelite.api.GameState;
import net.runelite.api.InventoryID;
import net.runelite.api.events.GameObjectDespawned;
import net.runelite.api.events.GameObjectSpawned;
import net.runelite.api.events.ItemContainerChanged;
import net.runelite.api.events.ScriptPostFired;
import net.runelite.api.events.*;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
@@ -24,8 +22,15 @@ public class EasyGiantsFoundryPlugin extends Plugin
private static final int TRIP_HAMMER = 44619;
private static final int GRINDSTONE = 44620;
private static final int POLISHING_WHEEL = 44621;
private static final int LAVA_POOL = 44631;
private static final int WATERFALL = 44632;
private static final int CRUCIBLE = 44776;
private static final int MOULD_JIG = 44777;
private static final int KOVAC_NPC = 11472;
private static final int PREFORM = 27010;
@Inject
@@ -82,6 +87,21 @@ public class EasyGiantsFoundryPlugin extends Plugin
case TRIP_HAMMER:
overlay3d.tripHammer = gameObject;
break;
case MOULD_JIG:
overlay3d.mouldJig = gameObject;
break;
case CRUCIBLE:
overlay3d.crucible = gameObject;
break;
}
}
@Subscribe
public void onGameStateChanged(GameStateChanged event)
{
if (event.getGameState().equals(GameState.LOADING))
{
state.setEnabled(false);
}
}
@@ -107,6 +127,30 @@ public class EasyGiantsFoundryPlugin extends Plugin
case TRIP_HAMMER:
overlay3d.tripHammer = null;
break;
case MOULD_JIG:
overlay3d.mouldJig = null;
break;
case CRUCIBLE:
overlay3d.crucible = null;
break;
}
}
@Subscribe
public void onNpcSpawned(NpcSpawned event)
{
if (event.getNpc().getId() == KOVAC_NPC)
{
overlay3d.kovac = event.getNpc();
}
}
@Subscribe
public void onNpcDespawned(NpcDespawned event)
{
if (event.getNpc().getId() == KOVAC_NPC)
{
overlay3d.kovac = null;
}
}

View File

@@ -2,17 +2,16 @@ package com.toofifty.easygiantsfoundry;
import com.toofifty.easygiantsfoundry.enums.Heat;
import com.toofifty.easygiantsfoundry.enums.Stage;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Singleton;
import lombok.Getter;
import lombok.Setter;
import net.runelite.api.Client;
import net.runelite.api.Player;
import net.runelite.api.coords.WorldPoint;
import net.runelite.api.widgets.Widget;
import javax.inject.Inject;
import javax.inject.Singleton;
import java.util.ArrayList;
import java.util.List;
@Singleton
public class EasyGiantsFoundryState
{
@@ -29,14 +28,14 @@ public class EasyGiantsFoundryState
// 1 - set mould
// 2 - collect preform
// 3 -
private static final int VARBIT_GAME_STAGE = 13914;
static final int VARBIT_GAME_STAGE = 13914;
private static final int WIDGET_HEAT_PARENT = 49414153;
private static final int WIDGET_LOW_HEAT_PARENT = 49414163;
private static final int WIDGET_MED_HEAT_PARENT = 49414164;
private static final int WIDGET_HIGH_HEAT_PARENT = 49414165;
private static final int WIDGET_PROGRESS_PARENT = 49414219;
static final int WIDGET_PROGRESS_PARENT = 49414219;
// children with type 3 are stage boxes
// every 11th child is a sprite

View File

@@ -4,6 +4,7 @@ import com.toofifty.easygiantsfoundry.enums.Heat;
import com.toofifty.easygiantsfoundry.enums.Stage;
import net.runelite.api.Client;
import net.runelite.api.GameObject;
import net.runelite.api.NPC;
import net.runelite.api.Point;
import net.runelite.api.widgets.Widget;
import net.runelite.client.ui.ColorScheme;
@@ -18,11 +19,17 @@ public class FoundryOverlay3D extends Overlay {
private static final int BONUS_COLOR = 0xfcd703;
private static final int BONUS_WIDGET = 49414148;
private static final int HAND_IN_WIDGET = 49414221;
private static final int FINISH_ANIM = 9457;
GameObject tripHammer;
GameObject grindstone;
GameObject polishingWheel;
GameObject lavaPool;
GameObject waterfall;
GameObject mouldJig;
GameObject crucible;
NPC kovac;
private final Client client;
private final EasyGiantsFoundryState state;
@@ -37,7 +44,8 @@ public class FoundryOverlay3D extends Overlay {
this.helper = helper;
}
private Color getObjectColor(Stage stage, Heat heat) {
private Color getObjectColor(Stage stage, Heat heat)
{
if (stage.getHeat() != heat)
{
return ColorScheme.PROGRESS_ERROR_COLOR;
@@ -77,9 +85,19 @@ public class FoundryOverlay3D extends Overlay {
}
@Override
public Dimension render(Graphics2D graphics) {
if (!state.isEnabled() || state.getCurrentStage() == null)
public Dimension render(Graphics2D graphics)
{
if (!state.isEnabled())
{
return null;
}
drawKovacIfHandIn(graphics);
if (state.getCurrentStage() == null)
{
drawMouldIfNotSet(graphics);
drawCrucibleIfMouldSet(graphics);
return null;
}
@@ -110,4 +128,63 @@ public class FoundryOverlay3D extends Overlay {
return null;
}
private void drawCrucibleIfMouldSet(Graphics2D graphics)
{
if (client.getVarbitValue(MouldHelper.SWORD_TYPE_1_VARBIT) == 0)
{
return;
}
if (client.getVarbitValue(EasyGiantsFoundryState.VARBIT_GAME_STAGE) != 1)
{
return;
}
Shape shape = crucible.getConvexHull();
if (shape != null)
{
Color color = Color.CYAN;
graphics.setColor(color);
graphics.draw(shape);
graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), 20));
graphics.fill(shape);
}
}
private void drawMouldIfNotSet(Graphics2D graphics)
{
if (client.getWidget(EasyGiantsFoundryState.WIDGET_PROGRESS_PARENT) != null
|| client.getVarbitValue(MouldHelper.SWORD_TYPE_1_VARBIT) == 0
|| (client.getVarbitValue(EasyGiantsFoundryState.VARBIT_GAME_STAGE) != 0
&& client.getVarbitValue(EasyGiantsFoundryState.VARBIT_GAME_STAGE) != 2))
{
return;
}
Shape shape = mouldJig.getConvexHull();
if (shape != null)
{
Color color = Color.CYAN;
graphics.setColor(color);
graphics.draw(shape);
graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), 20));
graphics.fill(shape);
}
}
private void drawKovacIfHandIn(Graphics2D graphics)
{
Widget handInWidget = client.getWidget(HAND_IN_WIDGET);
if (handInWidget != null && !handInWidget.isHidden()
&& client.getLocalPlayer().getAnimation() != FINISH_ANIM)
{
Shape shape = kovac.getConvexHull();
if (shape != null)
{
Color color = Color.CYAN;
graphics.setColor(color);
graphics.draw(shape);
graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), 20));
graphics.fill(shape);
}
}
}
}

View File

@@ -8,7 +8,8 @@ import net.runelite.api.widgets.Widget;
import net.runelite.client.callback.ClientThread;
import javax.inject.Inject;
import java.util.*;
import java.util.LinkedHashMap;
import java.util.Map;
public class MouldHelper
{
@@ -17,8 +18,8 @@ public class MouldHelper
static final int REDRAW_MOULD_LIST_SCRIPT = 6095;
static final int RESET_MOULD_SCRIPT = 6108;
public static final int SELECT_MOULD_SCRIPT = 6098;
private static final int SWORD_TYPE_1_VARBIT = 13907; // 4=Broad
private static final int SWORD_TYPE_2_VARBIT = 13908; // 3=Flat
static final int SWORD_TYPE_1_VARBIT = 13907; // 4=Broad
static final int SWORD_TYPE_2_VARBIT = 13908; // 3=Flat
private static final int DISABLED_TEXT_COLOR = 0x9f9f9f;
private static final int GREEN = 0xdc10d;