update exp every now and then.

This commit is contained in:
RedSparr0w
2019-10-27 17:29:07 +13:00
parent 541d1cc08d
commit db777a0ae0
4 changed files with 29 additions and 1 deletions
+1
View File
@@ -35,6 +35,7 @@ public class Main extends Script implements MessageListener, Paintable {
Variables.setBaseExp(); Variables.setBaseExp();
strategies.add(new UpdateExperience());
strategies.add(new ScriptState()); strategies.add(new ScriptState());
if(Variables.skill_to_train == Skill.WOODCUTTING) { if(Variables.skill_to_train == Skill.WOODCUTTING) {
strategies.add(new MakeArrowShafts()); strategies.add(new MakeArrowShafts());
@@ -13,6 +13,7 @@ public class Variables {
public static int items_gained = 0; public static int items_gained = 0;
public static double base_experience = 0; public static double base_experience = 0;
public static double exp_gained = 0; public static double exp_gained = 0;
public static int update_experience_tick = 0;
// Login Panel // Login Panel
private static String username = ""; private static String username = "";
@@ -32,14 +32,17 @@ public class Fish implements Strategy {
if (Variables.shouldDropItems()) { if (Variables.shouldDropItems()) {
if (Inventory.getCount(441) >= 1) Inventory.getItem(441).interact(Items.Option.DROP); if (Inventory.getCount(441) >= 1) Inventory.getItem(441).interact(Items.Option.DROP);
} }
for (int item_id: items) for (int item_id: items)
if (Inventory.getItem(item_id + 1) != null) if (Inventory.getItem(item_id + 1) != null)
Menu.sendAction(431, item_id, Inventory.getItem(item_id + 1).getSlot(), 5064, 3); Menu.sendAction(431, item_id, Inventory.getItem(item_id + 1).getSlot(), 5064, 3);
fishingSpot.interact(Variables.fishing_type_selected); fishingSpot.interact(Variables.fishing_type_selected);
Time.sleep(1000); Time.sleep(1000);
// Wait for the Player to finish fishing (max 60 seconds) // Wait for the Player to finish fishing (max 60 seconds)
Time.sleep(() -> Players.getMyPlayer().getAnimation() == -1, 60000); Time.sleep(() -> Players.getMyPlayer().getAnimation() == -1, 60000);
} catch (Exception err){ } catch (Exception ಠ_ಠ){
System.out.println("Fishing error: ¯\\_(ツ)_/¯"); System.out.println("Fishing error: ¯\\_(ツ)_/¯");
} }
} }
@@ -0,0 +1,23 @@
package ParaScript.strategies;
import ParaScript.data.Variables;
import org.parabot.environment.api.utils.Time;
import org.parabot.environment.scripts.framework.Strategy;
public class UpdateExperience implements Strategy {
@Override
public boolean activate() {
if (++Variables.update_experience_tick >= 1000) {
return true;
}
return false;
}
@Override
public void execute() {
Variables.updateExpGained();
Variables.update_experience_tick = 0;
Time.sleep(500);
}
}