@@ -7,3 +7,10 @@ Helpful overlays for the Giant's Foundry minigame
|
||||
- Shows heat and progress as percentages
|
||||
- Shows number of actions required to move to the next stage
|
||||
- Shows number of actions before gaining/losing too much heat
|
||||
- Shows best moulds to use
|
||||
|
||||
|
||||
## Contributors
|
||||
|
||||
- [Patrick](https://github.com/pwatts6060 "Patrick's github")
|
||||
* Best moulds interface feature
|
||||
|
||||
@@ -24,7 +24,7 @@ dependencies {
|
||||
}
|
||||
|
||||
group = 'com.toofifty'
|
||||
version = '1.0.0'
|
||||
version = '1.0.1'
|
||||
sourceCompatibility = '1.8'
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
package com.toofifty.easygiantsfoundry;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.InventoryID;
|
||||
import net.runelite.api.ItemContainer;
|
||||
import net.runelite.api.ItemID;
|
||||
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.client.eventbus.Subscribe;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.ui.overlay.OverlayManager;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@Slf4j
|
||||
@PluginDescriptor(
|
||||
name = "Easy Giant's Foundry",
|
||||
@@ -35,6 +35,9 @@ public class EasyGiantsFoundryPlugin extends Plugin
|
||||
@Inject
|
||||
private EasyGiantsFoundryOverlay overlay;
|
||||
|
||||
@Inject
|
||||
private MouldHelper mouldHelper;
|
||||
|
||||
@Override
|
||||
protected void startUp()
|
||||
{
|
||||
@@ -74,4 +77,16 @@ public class EasyGiantsFoundryPlugin extends Plugin
|
||||
state.reset();
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onScriptPostFired(ScriptPostFired event)
|
||||
{
|
||||
if (event.getScriptId() == MouldHelper.DRAW_MOULD_LIST_SCRIPT
|
||||
|| event.getScriptId() == MouldHelper.REDRAW_MOULD_LIST_SCRIPT
|
||||
|| event.getScriptId() == MouldHelper.SELECT_MOULD_SCRIPT
|
||||
|| event.getScriptId() == MouldHelper.RESET_MOULD_SCRIPT)
|
||||
{
|
||||
mouldHelper.selectBest(event.getScriptId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.toofifty.easygiantsfoundry;
|
||||
|
||||
import com.toofifty.easygiantsfoundry.enums.CommissionType;
|
||||
import com.toofifty.easygiantsfoundry.enums.Mould;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.ScriptID;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
import net.runelite.client.callback.ClientThread;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.*;
|
||||
|
||||
public class MouldHelper
|
||||
{
|
||||
static final int MOULD_LIST_PARENT = 47054857;
|
||||
static final int DRAW_MOULD_LIST_SCRIPT = 6093;
|
||||
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
|
||||
private static final int DISABLED_TEXT_COLOR = 0x9f9f9f;
|
||||
private static final int GREEN = 0xdc10d;
|
||||
|
||||
@Inject
|
||||
private Client client;
|
||||
|
||||
@Inject
|
||||
private ClientThread clientThread;
|
||||
|
||||
public void selectBest(int scriptId)
|
||||
{
|
||||
Widget parent = client.getWidget(MOULD_LIST_PARENT);
|
||||
if (parent == null || parent.getChildren() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Map<Mould, Widget> mouldToChild = getOptions(parent.getChildren());
|
||||
|
||||
int bestScore = -1;
|
||||
Widget bestWidget = null;
|
||||
CommissionType type1 = CommissionType.forVarbit(client.getVarbitValue(SWORD_TYPE_1_VARBIT));
|
||||
CommissionType type2 = CommissionType.forVarbit(client.getVarbitValue(SWORD_TYPE_2_VARBIT));
|
||||
for (Map.Entry<Mould, Widget> entry : mouldToChild.entrySet()) {
|
||||
Mould mould = entry.getKey();
|
||||
int score = mould.getScore(type1, type2);
|
||||
if (score > bestScore) {
|
||||
bestScore = score;
|
||||
bestWidget = entry.getValue();
|
||||
}
|
||||
}
|
||||
if (bestWidget != null) {
|
||||
bestWidget.setTextColor(GREEN);
|
||||
}
|
||||
|
||||
if (scriptId == DRAW_MOULD_LIST_SCRIPT || scriptId == REDRAW_MOULD_LIST_SCRIPT)
|
||||
{
|
||||
Widget scrollBar = client.getWidget(718, 11);
|
||||
Widget scrollList = client.getWidget(718, 9);
|
||||
if (scrollBar != null && scrollList != null)
|
||||
{
|
||||
int height = scrollList.getHeight();
|
||||
int scrollMax = scrollList.getScrollHeight();
|
||||
Widget finalBestWidget = bestWidget;
|
||||
clientThread.invokeLater(() -> {
|
||||
if (finalBestWidget != null) {
|
||||
client.runScript(
|
||||
ScriptID.UPDATE_SCROLLBAR,
|
||||
scrollBar.getId(),
|
||||
scrollList.getId(),
|
||||
Math.min(finalBestWidget.getOriginalY() - 2, scrollMax - height));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Map<Mould, Widget> getOptions(Widget[] children) {
|
||||
Map<Mould, Widget> mouldToChild = new LinkedHashMap<>();
|
||||
for (int i = 2; i < children.length; i += 17)
|
||||
{
|
||||
Widget child = children[i];
|
||||
Mould mould = Mould.forName(child.getText());
|
||||
if (mould != null && child.getTextColor() != DISABLED_TEXT_COLOR) {
|
||||
mouldToChild.put(mould, child);
|
||||
}
|
||||
}
|
||||
return mouldToChild;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.toofifty.easygiantsfoundry.enums;
|
||||
|
||||
public enum CommissionType {
|
||||
NONE,
|
||||
NARROW, // 1
|
||||
LIGHT, // 2
|
||||
FLAT, // 3
|
||||
BROAD, // 4
|
||||
HEAVY, // 5
|
||||
SPIKED, // 6
|
||||
;
|
||||
|
||||
public static final CommissionType[] values = CommissionType.values();
|
||||
|
||||
public static CommissionType forVarbit(int varbitValue) {
|
||||
if (varbitValue < 0 || varbitValue >= values.length) {
|
||||
return NONE;
|
||||
}
|
||||
return CommissionType.values[varbitValue];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.toofifty.easygiantsfoundry.enums;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static com.toofifty.easygiantsfoundry.enums.CommissionType.*;
|
||||
import static com.toofifty.easygiantsfoundry.enums.MouldType.*;
|
||||
|
||||
@AllArgsConstructor
|
||||
public enum Mould {
|
||||
CHOPPER_FORTE("Chopper Forte", FORTE, ImmutableMap.of(BROAD, 4, LIGHT, 4, FLAT, 4)),
|
||||
GALDIUS_RICASSO("Galdius Ricasso", FORTE, ImmutableMap.of(BROAD, 4, HEAVY, 4, FLAT, 4)),
|
||||
DISARMING_FORTE("Disarming Forte", FORTE, ImmutableMap.of(NARROW, 4, LIGHT, 4, SPIKED, 4)),
|
||||
MEDUSA_RICASSO("Medusa Ricasso", FORTE, ImmutableMap.of(BROAD, 8, HEAVY, 6, FLAT, 8)),
|
||||
SERPENT_RICASSO("Serpent Ricasso", FORTE, ImmutableMap.of(NARROW, 6, LIGHT, 8, FLAT, 8)),
|
||||
SERRATED_FORTE("Serrated Forte", FORTE, ImmutableMap.of(NARROW, 8, HEAVY, 8, SPIKED, 6)),
|
||||
STILETTO_FORTE("Stiletto Forte", FORTE, ImmutableMap.of(NARROW, 8, LIGHT, 10, FLAT, 8)),
|
||||
DEFENDER_BASE("Defender Base", FORTE, ImmutableMap.of(BROAD, 8, HEAVY, 10, FLAT, 8)),
|
||||
JUGGERNAUT_FORTE("Juggernaut Forte", FORTE, ImmutableMap.of(BROAD, 4, HEAVY, 4, SPIKED, 16)),
|
||||
CHOPPER_FORTE_1("Chopper Forte +1", FORTE, ImmutableMap.of(BROAD, 3, LIGHT, 4, FLAT, 18)),
|
||||
SPIKER("Spiker!", FORTE, ImmutableMap.of(NARROW, 1, HEAVY, 2, SPIKED, 22)),
|
||||
SAW_BLADE("Saw Blade", BLADE, ImmutableMap.of(BROAD, 4, LIGHT, 4, SPIKED, 4)),
|
||||
DEFENDERS_EDGE("Defenders Edge", BLADE, ImmutableMap.of(BROAD, 4, HEAVY, 4, SPIKED, 4)),
|
||||
FISH_BLADE("Fish Blade", BLADE, ImmutableMap.of(NARROW, 4, LIGHT, 4, FLAT, 4)),
|
||||
MEDUSA_BLADE("Medusa Blade", BLADE, ImmutableMap.of(BROAD, 8, HEAVY, 8, FLAT, 6)),
|
||||
STILETTO_BLADE("Stiletto Blade", BLADE, ImmutableMap.of(NARROW, 8, LIGHT, 6, FLAT, 8)),
|
||||
GLADIUS_EDGE("Gladius Edge", BLADE, ImmutableMap.of(NARROW, 6, HEAVY, 8, FLAT, 8)),
|
||||
FLAMBERGE_BLADE("Flamberge Blade", BLADE, ImmutableMap.of(NARROW, 8, LIGHT, 8, SPIKED, 10)),
|
||||
SERPENT_BLADE("Serpent Blade", BLADE, ImmutableMap.of(NARROW, 10, LIGHT, 8, FLAT, 8)),
|
||||
CLAYMORE_BLADE("Claymore Blade", BLADE, ImmutableMap.of(BROAD, 16, HEAVY, 4, FLAT, 4)),
|
||||
FLEUR_DE_BLADE("Fleur de Blade", BLADE, ImmutableMap.of(BROAD, 4, HEAVY, 18, SPIKED, 1)),
|
||||
CHOPPA("Choppa!", BLADE, ImmutableMap.of(BROAD, 1, LIGHT, 22, FLAT, 2)),
|
||||
PEOPLE_POKER_POINT("People Poker Point", TIP, ImmutableMap.of(NARROW, 4, HEAVY, 4, FLAT, 4)),
|
||||
CHOPPER_TIP("Chopper Tip", TIP, ImmutableMap.of(BROAD, 4, LIGHT, 4, SPIKED, 4)),
|
||||
MEDUSAS_HEAD("Medusa's Head", TIP, ImmutableMap.of(BROAD, 4, HEAVY, 4, SPIKED, 4)),
|
||||
SERPENTS_FANG("Serpent's Fang", TIP, ImmutableMap.of(NARROW, 8, LIGHT, 6, SPIKED, 8)),
|
||||
GLADIUS_POINT("Gladius Point", TIP, ImmutableMap.of(NARROW, 8, HEAVY, 8, FLAT, 6)),
|
||||
SAW_TIP("Saw Tip", TIP, ImmutableMap.of(BROAD, 6, HEAVY, 8, SPIKED, 8)),
|
||||
CORRUPTED_POINT("Corrupted Point", TIP, ImmutableMap.of(NARROW, 8, LIGHT, 10, SPIKED, 8)),
|
||||
DEFENDERS_TIP("Defenders Tip", TIP, ImmutableMap.of(BROAD, 10, HEAVY, 8, SPIKED, 8)),
|
||||
SERRATED_TIPS("Serrated Tips", TIP, ImmutableMap.of(NARROW, 4, LIGHT, 16, SPIKED, 4)),
|
||||
NEEDLE_POINT("Needle Point", TIP, ImmutableMap.of(NARROW, 18, LIGHT, 3, FLAT, 4)),
|
||||
THE_POINT("The Point!", TIP, ImmutableMap.of(BROAD, 2, LIGHT, 1, FLAT, 22)),
|
||||
;
|
||||
|
||||
private final String name;
|
||||
private final MouldType mouldType;
|
||||
private final Map<CommissionType, Integer> typeToScore;
|
||||
|
||||
public static final Mould[] values = Mould.values();
|
||||
|
||||
public static Mould forName(String text) {
|
||||
for (Mould mould : values) {
|
||||
if (mould.name.equalsIgnoreCase(text)) {
|
||||
return mould;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getScore(CommissionType type1, CommissionType type2) {
|
||||
int score = 0;
|
||||
score += typeToScore.getOrDefault(type1, 0);
|
||||
score += typeToScore.getOrDefault(type2, 0);
|
||||
return score;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.toofifty.easygiantsfoundry.enums;
|
||||
|
||||
public enum MouldType {
|
||||
FORTE,
|
||||
BLADE,
|
||||
TIP,
|
||||
}
|
||||
Reference in New Issue
Block a user