sword & mould score: sword score = mould score + crucible score - (mistake * 10)

This score is displayed over the title of mould, the mould panel title, and over the preform in stage == 2.

*mistakes are not tracked right now.
This commit is contained in:
Louis Hong
2024-10-28 01:32:24 -07:00
parent 2a821017f2
commit 475cb1c1f0
4 changed files with 126 additions and 5 deletions

View File

@@ -1,6 +1,8 @@
package com.toofifty.easygiantsfoundry;
import com.google.inject.Provides;
import static com.toofifty.easygiantsfoundry.EasyGiantsFoundryClientIDs.VARBIT_GAME_STAGE;
import static com.toofifty.easygiantsfoundry.EasyGiantsFoundryClientIDs.VARBIT_HEAT;
import com.toofifty.easygiantsfoundry.enums.Stage;
@@ -27,6 +29,7 @@ import net.runelite.api.events.NpcSpawned;
import net.runelite.api.events.ScriptPostFired;
import net.runelite.api.events.StatChanged;
import net.runelite.api.events.VarbitChanged;
import net.runelite.api.widgets.Widget;
import net.runelite.client.Notifier;
import net.runelite.client.callback.ClientThread;
import net.runelite.client.config.ConfigManager;
@@ -36,6 +39,7 @@ import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.ui.overlay.OverlayManager;
import java.util.Objects;
import java.util.Set;
@Slf4j
@@ -273,8 +277,12 @@ public class EasyGiantsFoundryPlugin extends Plugin
{
if (event.getMenuOption().equals("Pour"))
{
if (client.getVarbitValue(VARBIT_GAME_STAGE) == 1)
{
state.setLastKnownCrucibleScore((int) state.getCrucibleScore());
}
// add persistent game message of the alloy value so user can reference later.
client.addChatMessage(ChatMessageType.GAMEMESSAGE, "", "The quality of the alloy poured is " + (int) state.getCrucibleQuality(), null);
client.addChatMessage(ChatMessageType.GAMEMESSAGE, "", "The score of the preform is <col=00FFFF>" + ((int) state.getCrucibleScore() + state.getMouldScore()), null);
}
}
@@ -315,6 +323,23 @@ public class EasyGiantsFoundryPlugin extends Plugin
|| event.getScriptId() == MouldHelper.RESET_MOULD_SCRIPT)
{
mouldHelper.selectBest(event.getScriptId());
updateMouldScore();
}
}
private void updateMouldScore() {
state.setMouldScore(mouldHelper.getTotalScore());
// show mould score on Mould UI Title
Widget mouldParent = client.getWidget(47054850);
Integer mouldScore = state.getMouldScore();
if (mouldParent != null && mouldScore != null)
{
Widget title = Objects.requireNonNull(mouldParent.getChild(1));
// not sure why, the ":" character turns into ": ," when rendered; obmitting it.
title.setText("Giants' Foundry Mould Setup <col=FFFFFF>(Score " + mouldScore + ")");
}
}

View File

@@ -9,10 +9,8 @@ import static com.toofifty.easygiantsfoundry.enums.Stage.GRINDSTONE;
import static com.toofifty.easygiantsfoundry.enums.Stage.POLISHING_WHEEL;
import static com.toofifty.easygiantsfoundry.enums.Stage.TRIP_HAMMER;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import lombok.Value;
import net.runelite.api.Client;
import net.runelite.api.widgets.Widget;
@@ -40,6 +38,14 @@ public class EasyGiantsFoundryState
@Setter
private int smithsOutfitPieces;
@Setter
@Getter
private Integer mouldScore;
@Setter
@Getter
private Integer lastKnownCrucibleScore;
private final List<Stage> stages = new ArrayList<>();
private double heatRangeRatio = 0;
@@ -223,7 +229,7 @@ public class EasyGiantsFoundryState
return bronze + iron + steel + mithril + adamant + rune;
}
public double getCrucibleQuality()
public double getCrucibleScore()
{
// https://oldschool.runescape.wiki/w/Giants%27_Foundry#Metal_score

View File

@@ -119,7 +119,11 @@ public class FoundryOverlay3D extends Overlay
if (config.highlightCrucible())
{
drawCrucibleIfMouldSet(graphics);
drawMouldScoreIfMouldSet(graphics);
}
drawPreformScoreIfPoured(graphics);
return null;
}
@@ -269,7 +273,7 @@ public class FoundryOverlay3D extends Overlay
{
return;
}
String text = String.format("%d/%d metal score: %d", state.getCrucibleCount(), CRUCIBLE_CAPACITY, (int)state.getCrucibleQuality());
String text = String.format("%d/%d score: %d", state.getCrucibleCount(), CRUCIBLE_CAPACITY, (int)state.getCrucibleScore());
LocalPoint crucibleLoc = crucible.getLocalLocation();
crucibleLoc = new LocalPoint(crucibleLoc.getX() - 100, crucibleLoc.getY());
@@ -287,6 +291,48 @@ public class FoundryOverlay3D extends Overlay
OverlayUtil.renderTextLocation(graphics, pos, text, color);
}
private void drawMouldScoreIfMouldSet(Graphics2D graphics) {
if (client.getVarbitValue(SWORD_TYPE_1_VARBIT) == 0)
{
return;
}
if (client.getVarbitValue(VARBIT_GAME_STAGE) != 1)
{
return;
}
if (state.getMouldScore() == null)
{
return;
}
String text = String.format("score: %d", state.getMouldScore());
LocalPoint mouldLoc = mouldJig.getLocalLocation();
Point pos = Perspective.getCanvasTextLocation(client, graphics, mouldLoc, text, 115);
Color color = config.generalHighlight();
OverlayUtil.renderTextLocation(graphics, pos, text, color);
}
private void drawPreformScoreIfPoured(Graphics2D graphics) {
if (client.getVarbitValue(VARBIT_GAME_STAGE) != 2)
{
return;
}
if (state.getMouldScore() == null || state.getLastKnownCrucibleScore() == null)
{
return;
}
int preformScore = state.getLastKnownCrucibleScore() + state.getMouldScore();
String text = String.format("score: %d", preformScore);
LocalPoint mouldLoc = mouldJig.getLocalLocation();
Point pos = Perspective.getCanvasTextLocation(client, graphics, mouldLoc, text, 115);
Color color = config.generalHighlight();
OverlayUtil.renderTextLocation(graphics, pos, text, color);
}
private void drawCrucibleIfMouldSet(Graphics2D graphics)
{

View File

@@ -23,6 +23,9 @@ public class MouldHelper
static final int SWORD_TYPE_2_VARBIT = 13908; // 3=Flat
private static final int DISABLED_TEXT_COLOR = 0x9f9f9f;
private static final int SCORE_TYPE1_SCORE_WIDGET = 47054876;
private static final int SCORE_TYPE2_SCORE_WIDGET = 47054878;
@Inject
private Client client;
@@ -32,6 +35,47 @@ public class MouldHelper
@Inject
private EasyGiantsFoundryConfig config;
public Integer getTotalScore()
{
Widget type1Widget = client.getWidget(SCORE_TYPE1_SCORE_WIDGET);
Widget type2Widget = client.getWidget(SCORE_TYPE2_SCORE_WIDGET);
if (type1Widget == null || type2Widget == null)
{
return null;
}
String type1Str = type1Widget.getText();
String type2Str = type2Widget.getText();
// (+6) 6
// ^ space seperated
// or
// 6
if (type1Str.contains(" "))
{
type1Str = type1Str.substring(type1Str.lastIndexOf(' ') + 1);
}
if (type2Str.contains(" "))
{
type2Str = type2Str.substring(type2Str.lastIndexOf(' ') + 1);
}
int type1Score;
int type2Score;
try
{
type1Score = Integer.parseInt(type1Str);
type2Score = Integer.parseInt(type2Str);
} catch (NumberFormatException e)
{
return null;
}
return type1Score + type2Score;
}
public void selectBest(int scriptId)
{
Widget parent = client.getWidget(MOULD_LIST_PARENT);