Initial commit + 1.0.0
This commit is contained in:
11
README.md
11
README.md
@@ -1,2 +1,9 @@
|
||||
# Example
|
||||
An example greeter plugin
|
||||
# Easy Giant's Foundry
|
||||
|
||||
Helpful overlays for the Giant's Foundry minigame
|
||||
|
||||
## Features
|
||||
|
||||
- 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
|
||||
@@ -10,7 +10,7 @@ repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
def runeLiteVersion = '1.8.11'
|
||||
def runeLiteVersion = '1.8.22-SNAPSHOT'
|
||||
|
||||
dependencies {
|
||||
compileOnly group: 'net.runelite', name:'client', version: runeLiteVersion
|
||||
@@ -23,8 +23,8 @@ dependencies {
|
||||
testImplementation group: 'net.runelite', name:'jshell', version: runeLiteVersion
|
||||
}
|
||||
|
||||
group = 'com.example'
|
||||
version = '1.0-SNAPSHOT'
|
||||
group = 'com.toofifty'
|
||||
version = '1.0.0'
|
||||
sourceCompatibility = '1.8'
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
displayName=Example
|
||||
author=Nobody
|
||||
support=
|
||||
description=An example greeter plugin
|
||||
tags=
|
||||
plugins=com.example.ExamplePlugin
|
||||
displayName=Easy Giant's Foundry
|
||||
author=Toofifty
|
||||
support=https://github.com/Toofifty/easy-giantsfoundry
|
||||
description=Helpful overlays for the Giant's Foundry minigame
|
||||
tags=smithing,giant,foundry,giantsfoundry,minigame
|
||||
plugins=com.toofifty.easygiantsfoundry.EasyGiantsFoundryPlugin
|
||||
@@ -1 +1 @@
|
||||
rootProject.name = 'example'
|
||||
rootProject.name = 'easy-giantsfoundry'
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.example;
|
||||
|
||||
import net.runelite.client.config.Config;
|
||||
import net.runelite.client.config.ConfigGroup;
|
||||
import net.runelite.client.config.ConfigItem;
|
||||
|
||||
@ConfigGroup("example")
|
||||
public interface ExampleConfig extends Config
|
||||
{
|
||||
@ConfigItem(
|
||||
keyName = "greeting",
|
||||
name = "Welcome Greeting",
|
||||
description = "The message to show to the user when they login"
|
||||
)
|
||||
default String greeting()
|
||||
{
|
||||
return "Hello";
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
package com.example;
|
||||
|
||||
import com.google.inject.Provides;
|
||||
import javax.inject.Inject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.ChatMessageType;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.events.GameStateChanged;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.eventbus.Subscribe;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
|
||||
@Slf4j
|
||||
@PluginDescriptor(
|
||||
name = "Example"
|
||||
)
|
||||
public class ExamplePlugin extends Plugin
|
||||
{
|
||||
@Inject
|
||||
private Client client;
|
||||
|
||||
@Inject
|
||||
private ExampleConfig config;
|
||||
|
||||
@Override
|
||||
protected void startUp() throws Exception
|
||||
{
|
||||
log.info("Example started!");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void shutDown() throws Exception
|
||||
{
|
||||
log.info("Example stopped!");
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onGameStateChanged(GameStateChanged gameStateChanged)
|
||||
{
|
||||
if (gameStateChanged.getGameState() == GameState.LOGGED_IN)
|
||||
{
|
||||
client.addChatMessage(ChatMessageType.GAMEMESSAGE, "", "Example says " + config.greeting(), null);
|
||||
}
|
||||
}
|
||||
|
||||
@Provides
|
||||
ExampleConfig provideConfig(ConfigManager configManager)
|
||||
{
|
||||
return configManager.getConfig(ExampleConfig.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.toofifty.easygiantsfoundry;
|
||||
|
||||
import com.toofifty.easygiantsfoundry.enums.Heat;
|
||||
import com.toofifty.easygiantsfoundry.enums.Stage;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public class EasyGiantsFoundryHelper
|
||||
{
|
||||
// heat lowers every 2 ticks
|
||||
|
||||
// seems to be between 7-11 per
|
||||
private static final int HEAT_LAVA_HEAT = 8;
|
||||
private static final int COOL_WATERFALL_HEAT = -8;
|
||||
|
||||
// 27-37
|
||||
private static final int DUNK_LAVA_HEAT = 32;
|
||||
private static final int QUENCH_WATERFALL_HEAT = -32;
|
||||
|
||||
@Inject
|
||||
private EasyGiantsFoundryState state;
|
||||
|
||||
/**
|
||||
* Get the amount of progress each stage needs
|
||||
*/
|
||||
public double getProgressPerStage()
|
||||
{
|
||||
return 1000d / state.getStages().size();
|
||||
}
|
||||
|
||||
public int getActionsLeftInStage()
|
||||
{
|
||||
int progress = state.getProgressAmount();
|
||||
double progressPerStage = getProgressPerStage();
|
||||
double progressTillNext = progressPerStage - progress % progressPerStage;
|
||||
|
||||
Stage current = state.getCurrentStage();
|
||||
return (int) Math.ceil(progressTillNext / current.getProgressPerAction());
|
||||
}
|
||||
|
||||
public int[] getCurrentHeatRange()
|
||||
{
|
||||
switch (state.getCurrentStage())
|
||||
{
|
||||
case POLISHING_WHEEL:
|
||||
return state.getLowHeatRange();
|
||||
case GRINDSTONE:
|
||||
return state.getMedHeatRange();
|
||||
case TRIP_HAMMER:
|
||||
return state.getHighHeatRange();
|
||||
default:
|
||||
return new int[]{0, 0};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the amount of current stage actions that can be
|
||||
* performed before the heat drops too high or too low to
|
||||
* continue
|
||||
*/
|
||||
public int getActionsForHeatLevel()
|
||||
{
|
||||
Heat heatStage = state.getCurrentHeat();
|
||||
Stage stage = state.getCurrentStage();
|
||||
if (heatStage.getColor() != stage.getColor())
|
||||
{
|
||||
// not the right heat to start with
|
||||
return 0;
|
||||
}
|
||||
|
||||
int[] range = getCurrentHeatRange();
|
||||
int actions = 0;
|
||||
int heat = state.getHeatAmount();
|
||||
while (heat > range[0] && heat < range[1])
|
||||
{
|
||||
actions++;
|
||||
heat += stage.getHeatChange();
|
||||
}
|
||||
|
||||
return actions;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.toofifty.easygiantsfoundry;
|
||||
|
||||
import com.toofifty.easygiantsfoundry.enums.Heat;
|
||||
import com.toofifty.easygiantsfoundry.enums.Stage;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics2D;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import net.runelite.client.ui.ColorScheme;
|
||||
import net.runelite.client.ui.overlay.OverlayPanel;
|
||||
import net.runelite.client.ui.overlay.components.LineComponent;
|
||||
import net.runelite.client.ui.overlay.components.TitleComponent;
|
||||
|
||||
@Singleton
|
||||
public class EasyGiantsFoundryOverlay extends OverlayPanel
|
||||
{
|
||||
@Inject
|
||||
private EasyGiantsFoundryState state;
|
||||
|
||||
@Inject
|
||||
private EasyGiantsFoundryHelper helper;
|
||||
|
||||
private Color getHeatColor(int actions, int heat)
|
||||
{
|
||||
if (heat >= actions)
|
||||
{
|
||||
return ColorScheme.PROGRESS_COMPLETE_COLOR;
|
||||
}
|
||||
|
||||
if (heat > 0)
|
||||
{
|
||||
return ColorScheme.PROGRESS_INPROGRESS_COLOR;
|
||||
}
|
||||
|
||||
return ColorScheme.PROGRESS_ERROR_COLOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension render(Graphics2D graphics)
|
||||
{
|
||||
if (!state.isEnabled() || state.getCurrentStage() == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
Heat heat = state.getCurrentHeat();
|
||||
Stage stage = state.getCurrentStage();
|
||||
|
||||
panelComponent.getChildren().add(TitleComponent.builder().text("Easy Giant's Foundry").build());
|
||||
panelComponent.getChildren().add(
|
||||
LineComponent.builder().left("Heat").right(heat.getName() + " (" + state.getHeatAmount() / 10 + "%)").rightColor(heat.getColor()).build()
|
||||
);
|
||||
panelComponent.getChildren().add(
|
||||
LineComponent.builder().left("Stage").right(stage.getName() + " (" + state.getProgressAmount() / 10 + "%)").rightColor(stage.getColor()).build()
|
||||
);
|
||||
|
||||
int actionsLeft = helper.getActionsLeftInStage();
|
||||
int heatLeft = helper.getActionsForHeatLevel();
|
||||
|
||||
panelComponent.getChildren().add(
|
||||
LineComponent.builder().left("Actions left").right(actionsLeft + "").build()
|
||||
);
|
||||
panelComponent.getChildren().add(
|
||||
LineComponent.builder().left("Heat left").right(heatLeft + "").rightColor(getHeatColor(actionsLeft, heatLeft)).build()
|
||||
);
|
||||
|
||||
return super.render(graphics);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
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.client.eventbus.Subscribe;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.ui.overlay.OverlayManager;
|
||||
|
||||
@Slf4j
|
||||
@PluginDescriptor(
|
||||
name = "Easy Giant's Foundry",
|
||||
description = "Helpful overlays for the Giant's Foundry minigame"
|
||||
)
|
||||
public class EasyGiantsFoundryPlugin extends Plugin
|
||||
{
|
||||
private static final int POLISHING_WHEEL = 44621;
|
||||
private static final int PREFORM = 27010;
|
||||
|
||||
@Inject
|
||||
private EasyGiantsFoundryState state;
|
||||
|
||||
@Inject
|
||||
private EasyGiantsFoundryHelper helper;
|
||||
|
||||
@Inject
|
||||
private OverlayManager overlayManager;
|
||||
|
||||
@Inject
|
||||
private EasyGiantsFoundryOverlay overlay;
|
||||
|
||||
@Override
|
||||
protected void startUp()
|
||||
{
|
||||
overlayManager.add(overlay);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void shutDown()
|
||||
{
|
||||
overlayManager.remove(overlay);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onGameObjectSpawned(GameObjectSpawned event)
|
||||
{
|
||||
if (event.getGameObject().getId() == POLISHING_WHEEL)
|
||||
{
|
||||
state.setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onGameObjectDespawned(GameObjectDespawned event)
|
||||
{
|
||||
if (event.getGameObject().getId() == POLISHING_WHEEL)
|
||||
{
|
||||
state.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onItemContainerChanged(ItemContainerChanged event)
|
||||
{
|
||||
if (event.getContainerId() == InventoryID.EQUIPMENT.getId()
|
||||
&& event.getItemContainer().count(PREFORM) == 0)
|
||||
{
|
||||
state.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
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;
|
||||
|
||||
@Singleton
|
||||
public class EasyGiantsFoundryState
|
||||
{
|
||||
// heat and progress are from 0-1000
|
||||
private static final int VARBIT_HEAT = 13948;
|
||||
private static final int VARBIT_PROGRESS = 13949;
|
||||
|
||||
private static final int VARBIT_ORE_COUNT = 13934;
|
||||
private static final int VARBIT_FORTE_SELECTED = 13910;
|
||||
private static final int VARBIT_BLADE_SELECTED = 13911;
|
||||
private static final int VARBIT_TIP_SELECTED = 13912;
|
||||
|
||||
// 0 - load bars
|
||||
// 1 - set mould
|
||||
// 2 - collect preform
|
||||
// 3 -
|
||||
private 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;
|
||||
// children with type 3 are stage boxes
|
||||
// every 11th child is a sprite
|
||||
|
||||
private static final int SPRITE_ID_TRIP_HAMMER = 4442;
|
||||
private static final int SPRITE_ID_GRINDSTONE = 4443;
|
||||
private static final int SPRITE_ID_POLISHING_WHEEL = 4444;
|
||||
|
||||
@Inject
|
||||
private Client client;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
private boolean enabled;
|
||||
|
||||
private final List<Stage> stages = new ArrayList<>();
|
||||
private double heatRangeRatio = 0;
|
||||
|
||||
public void reset()
|
||||
{
|
||||
stages.clear();
|
||||
heatRangeRatio = 0;
|
||||
}
|
||||
|
||||
public int getHeatAmount()
|
||||
{
|
||||
return client.getVarbitValue(VARBIT_HEAT);
|
||||
}
|
||||
|
||||
public int getProgressAmount()
|
||||
{
|
||||
return client.getVarbitValue(VARBIT_PROGRESS);
|
||||
}
|
||||
|
||||
public double getHeatRangeRatio()
|
||||
{
|
||||
if (heatRangeRatio == 0)
|
||||
{
|
||||
Widget heatWidget = client.getWidget(WIDGET_HEAT_PARENT);
|
||||
Widget medHeat = client.getWidget(WIDGET_MED_HEAT_PARENT);
|
||||
if (medHeat == null || heatWidget == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
heatRangeRatio = medHeat.getWidth() /(double) heatWidget.getWidth();
|
||||
}
|
||||
|
||||
return heatRangeRatio;
|
||||
}
|
||||
|
||||
public int[] getLowHeatRange()
|
||||
{
|
||||
return new int[]{
|
||||
(int) ((1 / 6d - getHeatRangeRatio() / 2) * 1000),
|
||||
(int) ((1 / 6d + getHeatRangeRatio() / 2) * 1000),
|
||||
};
|
||||
}
|
||||
|
||||
public int[] getMedHeatRange()
|
||||
{
|
||||
return new int[]{
|
||||
(int) ((3 / 6d - getHeatRangeRatio() / 2) * 1000),
|
||||
(int) ((3 / 6d + getHeatRangeRatio() / 2) * 1000),
|
||||
};
|
||||
}
|
||||
|
||||
public int[] getHighHeatRange()
|
||||
{
|
||||
return new int[]{
|
||||
(int) ((5 / 6d - getHeatRangeRatio() / 2) * 1000),
|
||||
(int) ((5 / 6d + getHeatRangeRatio() / 2) * 1000),
|
||||
};
|
||||
}
|
||||
|
||||
public List<Stage> getStages()
|
||||
{
|
||||
if (stages.isEmpty())
|
||||
{
|
||||
Widget progressParent = client.getWidget(WIDGET_PROGRESS_PARENT);
|
||||
if (progressParent == null || progressParent.getChildren() == null)
|
||||
{
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
for (Widget child : progressParent.getChildren())
|
||||
{
|
||||
switch (child.getSpriteId())
|
||||
{
|
||||
case SPRITE_ID_TRIP_HAMMER:
|
||||
stages.add(Stage.TRIP_HAMMER);
|
||||
break;
|
||||
case SPRITE_ID_GRINDSTONE:
|
||||
stages.add(Stage.GRINDSTONE);
|
||||
break;
|
||||
case SPRITE_ID_POLISHING_WHEEL:
|
||||
stages.add(Stage.POLISHING_WHEEL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return stages;
|
||||
}
|
||||
|
||||
public Stage getCurrentStage()
|
||||
{
|
||||
int index = (int) (getProgressAmount() / 1000d * getStages().size());
|
||||
if (index < 0 || index > getStages().size() - 1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return getStages().get(index);
|
||||
}
|
||||
|
||||
public Heat getCurrentHeat()
|
||||
{
|
||||
int heat = getHeatAmount();
|
||||
|
||||
int[] low = getLowHeatRange();
|
||||
if (heat > low[0] && heat < low[1])
|
||||
{
|
||||
return Heat.LOW;
|
||||
}
|
||||
|
||||
int[] med = getMedHeatRange();
|
||||
if (heat > med[0] && heat < med[1])
|
||||
{
|
||||
return Heat.MED;
|
||||
}
|
||||
|
||||
int[] high = getHighHeatRange();
|
||||
if (heat > high[0] && heat < high[1])
|
||||
{
|
||||
return Heat.HIGH;
|
||||
}
|
||||
|
||||
return Heat.NONE;
|
||||
}
|
||||
}
|
||||
19
src/main/java/com/toofifty/easygiantsfoundry/enums/Heat.java
Normal file
19
src/main/java/com/toofifty/easygiantsfoundry/enums/Heat.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package com.toofifty.easygiantsfoundry.enums;
|
||||
|
||||
import java.awt.Color;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import net.runelite.client.ui.ColorScheme;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum Heat
|
||||
{
|
||||
LOW("Low", ColorScheme.PROGRESS_COMPLETE_COLOR),
|
||||
MED("Medium", ColorScheme.PROGRESS_INPROGRESS_COLOR),
|
||||
HIGH("High", ColorScheme.PROGRESS_ERROR_COLOR),
|
||||
NONE("Not in range", ColorScheme.LIGHT_GRAY_COLOR);
|
||||
|
||||
private final String name;
|
||||
private final Color color;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.toofifty.easygiantsfoundry.enums;
|
||||
|
||||
import java.awt.Color;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import net.runelite.client.ui.ColorScheme;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum Stage
|
||||
{
|
||||
TRIP_HAMMER("Hammer", ColorScheme.PROGRESS_ERROR_COLOR, 20, -25),
|
||||
GRINDSTONE("Grind", ColorScheme.PROGRESS_INPROGRESS_COLOR, 10, 15),
|
||||
POLISHING_WHEEL("Polish", ColorScheme.PROGRESS_COMPLETE_COLOR, 10, -17);
|
||||
|
||||
private final String name;
|
||||
private final Color color;
|
||||
private final int progressPerAction;
|
||||
private final int heatChange;
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.example;
|
||||
|
||||
import net.runelite.client.RuneLite;
|
||||
import net.runelite.client.externalplugins.ExternalPluginManager;
|
||||
|
||||
public class ExamplePluginTest
|
||||
{
|
||||
public static void main(String[] args) throws Exception
|
||||
{
|
||||
ExternalPluginManager.loadBuiltin(ExamplePlugin.class);
|
||||
RuneLite.main(args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.toofifty.easygiantsfoundry;
|
||||
|
||||
import net.runelite.client.RuneLite;
|
||||
import net.runelite.client.externalplugins.ExternalPluginManager;
|
||||
|
||||
public class EasyGiantsFoundryPluginTest
|
||||
{
|
||||
public static void main(String[] args) throws Exception
|
||||
{
|
||||
ExternalPluginManager.loadBuiltin(EasyGiantsFoundryPlugin.class);
|
||||
RuneLite.main(args);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user