@@ -65,6 +65,9 @@ public class GiantsFoundryHelper {
6565 private static final int SPRITE_ID_GRINDSTONE = 4443 ;
6666 private static final int SPRITE_ID_POLISHING_WHEEL = 4444 ;
6767
68+ public static final int LAVA_POOL = 44631 ;
69+ public static final int WATERFALL = 44632 ;
70+
6871 public Heat getCurrentHeat () {
6972 int heat = getHeatAmount ();
7073
@@ -110,38 +113,59 @@ public enum Activity {
110113 NONE
111114 }
112115
113- public boolean isOperatingMachine (){
114- return getOperatingMachine () != Activity .NONE ;
116+ public boolean isOperatingMachine () {
117+ Activity activity = getActivity ();
118+ if (activity == Activity .HAMMERING ) {
119+ return true ;
120+ }
121+ if (activity == Activity .POLISHING ) {
122+ return true ;
123+ }
124+ if (activity == Activity .GRINDING ) {
125+ return true ;
126+ }
127+ return false ;
115128 }
116129
117- public Activity getOperatingMachine () {
130+ public boolean isModifyingTemperature () {
131+ Activity activity = getActivity ();
132+ if (activity == Activity .COOLING ) {
133+ return true ;
134+ }
135+ if (activity == Activity .HEATING ) {
136+ return true ;
137+ }
138+ return false ;
139+ }
140+
141+ public Activity getActivity () {
118142 if (!tracker .isAnimating ()) {
119143 return Activity .NONE ;
120144 }
121145 int anim = tracker .getLastAnimationId ();
122- if (anim == 827 ){
146+ if (anim == 827 ) {
123147 return Activity .HEATING ;
124148 }
125- if (anim == 832 ){
149+ if (anim == 832 ) {
126150 return Activity .COOLING ;
127151 }
128- if (anim == 9455 || anim ==9453 ){
152+ if (anim == 9455 || anim == 9453 ) {
129153 return Activity .HAMMERING ;
130154 }
131- if (anim != 9454 && anim != 9452 ){
155+ if (anim != 9454 && anim != 9452 ) {
132156 return Activity .NONE ;
133157 }
134158 GameObject polishWheel = gameObjects .closest (POLISHING_WHEEL );
135159 GameObject grindingWheel = gameObjects .closest (GRINDSTONE );
136- if (polishWheel == null || grindingWheel == null ){
160+ if (polishWheel == null || grindingWheel == null ) {
137161 log .info ("Cannot find objects." );
138162 return Activity .NONE ;
139163 }
140164
141165 WorldPoint myLocation = client .getLocalPlayer ().getWorldLocation ();
142166 double polishWheelDistance = myLocation .distanceTo (polishWheel .getWorldLocation ());
143167 double grindingWheelDistance = myLocation .distanceTo (grindingWheel .getWorldLocation ());
144- if (polishWheelDistance < grindingWheelDistance ){
168+ if (polishWheelDistance < grindingWheelDistance ) {
145169 return Activity .POLISHING ;
146170 }
147171 return Activity .GRINDING ;
@@ -243,6 +267,9 @@ public int getActionsLeftInStage() {
243267 double progressTillNext = progressPerStage - progress % progressPerStage ;
244268
245269 Stage current = getCurrentStage ();
270+ if (current == null ) {
271+ return -1 ;
272+ }
246273 return (int ) Math .ceil (progressTillNext / current .getProgressPerAction ());
247274 }
248275
@@ -263,6 +290,20 @@ public Stage getCurrentStage() {
263290 return getStages ().get (index );
264291 }
265292
293+ public Stage getNextStage () {
294+ List <Stage > stages = getStages ();
295+ int index = (int ) (getProgressAmount () / 1000d * getStages ().size ());
296+ if (index < 0 || index > stages .size () - 1 ) {
297+ return Stage .NONE ;
298+ }
299+
300+ if (index > stages .size () - 2 ) {
301+ return Stage .NONE ;
302+ }
303+
304+ return getStages ().get (index + 1 );
305+ }
306+
266307 public List <Stage > getStages () {
267308 if (stages .isEmpty ()) {
268309 Widget progressParent = client .getWidget (WIDGET_PROGRESS_PARENT );
@@ -342,14 +383,14 @@ public enum Stage {
342383
343384 TRIP_HAMMER ("Hammer" , Heat .HIGH , 20 , -25 , GiantsFoundryHelper .TRIP_HAMMER ),
344385 GRINDSTONE ("Grind" , Heat .MED , 10 , 15 , GiantsFoundryHelper .GRINDSTONE ),
345- POLISHING_WHEEL ("Polish" , Heat .LOW , 10 , -17 , GiantsFoundryHelper .POLISHING_WHEEL );
346- // NONE("None", Heat.NONE, -1, -1, -1);
386+ POLISHING_WHEEL ("Polish" , Heat .LOW , 10 , -17 , GiantsFoundryHelper .POLISHING_WHEEL ),
387+ NONE ("None" , Heat .NONE , -1 , -1 , -1 );
347388
348389
349390 private final String name ;
350391 private final Heat heat ;
351392 private final int progressPerAction ;
352393 private final int heatChange ;
353394 private final int objectId ;
354- }
395+ }
355396}
0 commit comments