From b1bccdbc33800bb8b65d3f2210daf33d924bf993 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=ADn?= Date: Mon, 21 Aug 2023 16:01:25 +0200 Subject: [PATCH] By when v1.127 is released (#75) * v2.1.0 (#70) * Astral Gate: Manual interaction is no longer required * Astral Gate: Will now use the best ammunition it has on the boss. * Astral Gate: Priority can now be configured for each portal * Updated the version * Updated the version * Updated useItem --- pom.xml | 4 +- .../behaviours/ambulance/AmbulanceModule.java | 8 +- .../behaviours/ambulance/AvailableShips.java | 8 - .../bestability/AutoBestAbility.java | 8 +- .../deeme/modules/astral/AstralConfig.java | 23 +- .../com/deeme/modules/astral/AstralGate.java | 323 +++++++----------- .../modules/astral/AstralPortalSupplier.java | 111 ------ .../com/deeme/modules/astral/AstralShip.java | 92 ----- .../deeme/modules/astral/AvailableShips.java | 22 ++ .../com/deeme/types/ConditionsManagement.java | 2 +- src/main/resources/plugin.json | 6 +- 11 files changed, 170 insertions(+), 437 deletions(-) delete mode 100644 src/main/java/com/deeme/behaviours/ambulance/AvailableShips.java delete mode 100644 src/main/java/com/deeme/modules/astral/AstralPortalSupplier.java delete mode 100644 src/main/java/com/deeme/modules/astral/AstralShip.java create mode 100644 src/main/java/com/deeme/modules/astral/AvailableShips.java diff --git a/pom.xml b/pom.xml index e1b420ef..95958025 100644 --- a/pom.xml +++ b/pom.xml @@ -23,12 +23,12 @@ eu.darkbot DarkBot - master-a5fa9a8a26-1 + 6d026357cb eu.darkbot DarkBotAPI - 0.7.0 + 0.7.8 com.deemetool diff --git a/src/main/java/com/deeme/behaviours/ambulance/AmbulanceModule.java b/src/main/java/com/deeme/behaviours/ambulance/AmbulanceModule.java index 986ca9ad..43748cb0 100644 --- a/src/main/java/com/deeme/behaviours/ambulance/AmbulanceModule.java +++ b/src/main/java/com/deeme/behaviours/ambulance/AmbulanceModule.java @@ -186,13 +186,7 @@ private void useAbilityReadyWhenReady() { return; } - if (items.getItem(abilityToUse, ItemFlag.USABLE, ItemFlag.READY).isPresent()) { - if (items.useItem(abilityToUse).isSuccessful()) { - abilityUsed = true; - } - } else { - abilityUsed = true; - } + abilityUsed = items.useItem(abilityToUse, 500, ItemFlag.USABLE, ItemFlag.READY).isSuccessful(); } private GroupMember getMember() { diff --git a/src/main/java/com/deeme/behaviours/ambulance/AvailableShips.java b/src/main/java/com/deeme/behaviours/ambulance/AvailableShips.java deleted file mode 100644 index 6932a4c8..00000000 --- a/src/main/java/com/deeme/behaviours/ambulance/AvailableShips.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.deeme.behaviours.ambulance; - -import eu.darkbot.api.config.annotations.Configuration; - -@Configuration("ambulance.ship_type.list") -public enum AvailableShips { - AEGIS, HAMMERCLAW, SOLACE; -} \ No newline at end of file diff --git a/src/main/java/com/deeme/behaviours/bestability/AutoBestAbility.java b/src/main/java/com/deeme/behaviours/bestability/AutoBestAbility.java index 2a731241..409af45e 100644 --- a/src/main/java/com/deeme/behaviours/bestability/AutoBestAbility.java +++ b/src/main/java/com/deeme/behaviours/bestability/AutoBestAbility.java @@ -290,7 +290,7 @@ private boolean shouldFocusHealth(boolean needLock) { } private boolean shouldFocusHelpTank() { - if (heroapi.getHealth().shieldPercent() < 0.5) { + if (heroapi.getHealth().shieldPercent() <= this.config.minHealthToUseHealth) { return false; } else if (group.hasGroup()) { for (GroupMember member : group.getMembers()) { @@ -304,12 +304,12 @@ private boolean shouldFocusHelpTank() { } private boolean shouldFocusShield() { - if (heroapi.getHealth().shieldPercent() < 0.5) { + if (heroapi.getHealth().shieldPercent() <= this.config.minHealthToUseHealth) { return true; } else if (group.hasGroup()) { for (GroupMember member : group.getMembers()) { if (!member.isDead() && member.isAttacked() && member.isLocked() - && member.getMemberInfo().shieldPercent() < 0.5) { + && member.getMemberInfo().shieldPercent() <= this.config.minHealthToUseHealth) { return true; } } @@ -326,7 +326,7 @@ private boolean shouldUseOrcusAssimilate() { return false; } - if (heroapi.getHealth().hpPercent() > 0.8) { + if (heroapi.getHealth().hpPercent() > this.config.minHealthToUseHealth) { return false; } diff --git a/src/main/java/com/deeme/modules/astral/AstralConfig.java b/src/main/java/com/deeme/modules/astral/AstralConfig.java index b7e883d1..5d84d9d0 100644 --- a/src/main/java/com/deeme/modules/astral/AstralConfig.java +++ b/src/main/java/com/deeme/modules/astral/AstralConfig.java @@ -1,11 +1,17 @@ package com.deeme.modules.astral; +import java.util.HashMap; +import java.util.Map; + import com.deeme.behaviours.bestrocket.RocketSupplier; +import com.deemetool.gui.suppliers.LaserSupplier; +import com.deemetool.modules.astral.PortalInfo; import eu.darkbot.api.config.annotations.Configuration; import eu.darkbot.api.config.annotations.Dropdown; import eu.darkbot.api.config.annotations.Number; import eu.darkbot.api.config.annotations.Option; +import eu.darkbot.api.config.annotations.Table; @Configuration("astral") public class AstralConfig { @@ -18,11 +24,12 @@ public class AstralConfig { public int minCPUs = 0; @Option("general.default_ammo") - public Character ammoKey; + @Dropdown(options = LaserSupplier.class) + public String defaultLaser = "ammunition_laser_lcb-10"; @Option("general.default_rocket") @Dropdown(options = RocketSupplier.class) - public String defaultRocket = ""; + public String defaultRocket = "ammunition_rocket_plt-2026"; @Option("astral.attack_closest") public boolean alwaysTheClosestNPC = false; @@ -31,12 +38,12 @@ public class AstralConfig { @Dropdown public BestAmmoConfig useBestAmmoLogic = BestAmmoConfig.ONLY_MARKED; - @Option("astral.choose_portal") - public boolean autoChoosePortal = false; + @Option("astral.ship_to_choose") + @Dropdown + public AvailableShips shipType = AvailableShips.ZEPHYR; - @Option("astral.choose_item") - public boolean autoChooseItem = false; + @Option("astral.auto_choose") + public boolean autoChoose = false; - @Option("astral.display_warning") - public boolean displayWarning = false; + public @Option @Table Map portalInfos = new HashMap<>(); } \ No newline at end of file diff --git a/src/main/java/com/deeme/modules/astral/AstralGate.java b/src/main/java/com/deeme/modules/astral/AstralGate.java index 5f030d3f..2c262659 100644 --- a/src/main/java/com/deeme/modules/astral/AstralGate.java +++ b/src/main/java/com/deeme/modules/astral/AstralGate.java @@ -3,6 +3,8 @@ import com.deeme.types.SharedFunctions; import com.deeme.types.VerifierChecker; import com.deeme.types.backpage.Utils; +import com.deemetool.modules.astral.AstralPlus; +import com.deemetool.modules.astral.PortalInfo; import com.github.manolo8.darkbot.config.NpcExtraFlag; import com.github.manolo8.darkbot.core.itf.NpcExtraProvider; @@ -17,14 +19,13 @@ import eu.darkbot.api.game.entities.Npc; import eu.darkbot.api.game.entities.Portal; import eu.darkbot.api.game.enums.EntityEffect; +import eu.darkbot.api.game.enums.PortalType; import eu.darkbot.api.game.items.Item; import eu.darkbot.api.game.items.ItemCategory; import eu.darkbot.api.game.items.ItemFlag; import eu.darkbot.api.game.items.SelectableItem; import eu.darkbot.api.game.items.SelectableItem.Cpu; -import eu.darkbot.api.game.items.SelectableItem.Laser; import eu.darkbot.api.game.other.GameMap; -import eu.darkbot.api.game.other.Gui; import eu.darkbot.api.game.other.Locatable; import eu.darkbot.api.game.other.Location; import eu.darkbot.api.game.other.Lockable; @@ -35,7 +36,6 @@ import eu.darkbot.api.managers.ConfigAPI; import eu.darkbot.api.managers.EntitiesAPI; import eu.darkbot.api.managers.ExtensionsAPI; -import eu.darkbot.api.managers.GameScreenAPI; import eu.darkbot.api.managers.HeroAPI; import eu.darkbot.api.managers.HeroItemsAPI; import eu.darkbot.api.managers.MovementAPI; @@ -45,11 +45,13 @@ import eu.darkbot.shared.modules.MapModule; import eu.darkbot.shared.utils.SafetyFinder; import eu.darkbot.util.Popups; +import eu.darkbot.util.SystemUtils; import java.util.Arrays; import java.util.Collection; import java.util.Comparator; -import java.util.Random; +import java.util.HashMap; +import java.util.Map; import javax.swing.JButton; import javax.swing.JOptionPane; @@ -65,11 +67,12 @@ public class AstralGate implements Module, InstructionProvider, Configurable maxCircleIterations; protected ConfigSetting runConfigInCircle; protected final ConfigSetting ammoKey; - private Gui astralGui; + protected final AstralPlus astralPlus; protected Collection portals; protected Collection npcs; @@ -77,27 +80,21 @@ public class AstralGate implements Module, InstructionProvider, Configurable devStuff = configApi.requireConfig("bot_settings.other.dev_stuff"); + this.rocketSupplier = new RocketSupplier(heroapi, items); this.ammoSupplier = new AmmoSupplier(items); - this.astralPortalSupplier = new AstralPortalSupplier(api, astralShip); + this.astralPlus = new AstralPlus(api, devStuff.getValue()); this.currentStatus = State.WAIT; this.showDialog = false; @@ -168,6 +164,7 @@ public AstralGate(PluginAPI api, AuthAPI auth, SafetyFinder safety) { @Override public void setConfig(ConfigSetting arg0) { this.astralConfig = arg0.getValue(); + fillPortalInfo(); } @Override @@ -182,23 +179,21 @@ public boolean canRefresh() { @Override public String getStatus() { - return "Astral | " + currentStatus.message + " | " + npcs.size() + " | " + attacker.getStatus() + "\nRadius: " - + lastRadius; + return "Astral | " + currentStatus.message + " | " + npcs.size() + " | " + attacker.getStatus() + " | Radius: " + + lastRadius + " | " + astralPlus.getStatus(); } @Override public String getStoppedStatus() { - return (astralShip != null ? astralShip.getStatus() - : "") - + " | Ammo: " + astralPortalSupplier.getAmmoCount() - + "\nAstral GUI: " + (astralGui != null && astralGui.isVisible()); + return getStatus(); } @Override public String instructions() { - return "You need to manually enter the gate and select the ship. \n" + - "Place the quick bar with everything you want to be used. \n" + - "The bot will wait until you choose an item and portal. He does not jump through the gates."; + return "Instructions for those who do not have access to PLUS functions: \n" + + "- You need to manually select the ship. \n" + + "- Place the quick bar with everything you want to be used. \n" + + "- The bot will wait until you choose an item and portal. He does not jump through the gates!!"; } @Override @@ -206,20 +201,17 @@ public void onTickModule() { pet.setEnabled(false); showWarningDialog(); if (isAstral() || heroapi.getMap().isGG()) { - if (astralShip == null) { - astralShip = new AstralShip(heroapi.getShipType()); - } - if (astralShip.isValid(heroapi.getShipType())) { + if (astralPlus.isValidShip()) { activeAutoRocketCPU(); repairShield = repairShield && heroapi.getHealth().shieldPercent() < 0.9 || heroapi.getHealth().shieldPercent() < 0.2; if (findTarget()) { waveLogic(); - } else if (npcs.isEmpty() && nextWaveCheck < System.currentTimeMillis()) { + } else if (npcs.isEmpty() || !portals.isEmpty()) { preparingWaveLogic(); } - } else { - stopBot(); + } else if (!astralPlus.autoChooseShip(astralConfig.shipType.getId())) { + stopBot(State.WAITING_SHIP); } } else { goToAstral(); @@ -230,119 +222,66 @@ public void onTickModule() { public void onTickStopped() { if (isAstral()) { showWarningDialog(); - countItems(); } } + private void fillPortalInfo() { + if (astralConfig.portalInfos.size() > 0) { + return; + } + Map defaultPortals = new HashMap<>(); + defaultPortals.put(PortalType.ROUGE_LITE_HP_RECOVER.name(), new PortalInfo(0)); + defaultPortals.put(PortalType.ROUGE_LITE_AMMUNITION.name(), new PortalInfo(1)); + defaultPortals.put(PortalType.ROUGE_LITE_MODULE.name(), new PortalInfo(2)); + defaultPortals.put(PortalType.ROUGE_LITE_GENERATOR.name(), new PortalInfo(3)); + defaultPortals.put(PortalType.ROUGE_LITE_WEAPON.name(), new PortalInfo(4)); + defaultPortals.put(PortalType.ROUGE_LITE_RESOURCE.name(), new PortalInfo(5)); + defaultPortals.put(PortalType.ROUGE_LITE_AMMUNITION_BRUTAL.name(), new PortalInfo(6)); + defaultPortals.put(PortalType.ROUGE_LITE_MODULE_BRUTAL.name(), new PortalInfo(7)); + defaultPortals.put(PortalType.ROUGE_LITE_GENERATOR_BRUTAL.name(), new PortalInfo(8)); + defaultPortals.put(PortalType.ROUGE_LITE_WEAPON_BRUTAL.name(), new PortalInfo(9)); + defaultPortals.put(PortalType.ROUGE_LITE_RESOURCE_BRUTAL.name(), new PortalInfo(10)); + + astralConfig.portalInfos.putAll(defaultPortals); + } + private void waveLogic() { - nextWaveCheck = System.currentTimeMillis() + 30000; - waitingSign = false; + nextWaveCheck = System.currentTimeMillis() + waitTime; + waveHasBeenAwaited = false; this.currentStatus = State.DO; - if (astralGui != null && astralGui.isVisible()) { - astralGui.setVisible(false); - } + attacker.tryLockAndAttack(); npcMove(); changeAmmo(); } private void preparingWaveLogic() { - if (waitingSign) { - nextWaveCheck = System.currentTimeMillis() + 30000; - goToTheMiddle(); - - if (astralConfig.autoChoosePortal || astralConfig.autoChooseItem) { - autoChooseLogic(); - } else if (!portals.isEmpty() || (astralGui != null && astralGui.isVisible())) { - this.currentStatus = State.WAITING_HUMAN; - this.showDialog = true; - this.bot.setRunning(false); - } else { - this.currentStatus = State.WAITING_WAVE; - } - } - waitingSign = true; - } - - private void stopBot() { - if (astralConfig.displayWarning) { - this.showDialog = true; - } - - this.currentStatus = State.WAITING_SHIP; - this.astralShip = null; - this.bot.setRunning(false); - } - - private void autoChooseLogic() { - if (!astralGui.isVisible()) { - chooseClickDelay = System.currentTimeMillis() + 10000; - } - if (portals.isEmpty()) { - if (astralGui.isVisible()) { - chooseItem(); - } else { - if (this.currentStatus == State.WAITING_SIGN && maximumWaitingTime < System.currentTimeMillis()) { - astralGui.setVisible(true); - } else { - this.currentStatus = State.WAITING_SIGN; - maximumWaitingTime = System.currentTimeMillis() + 20000; - } - } - } else if (astralConfig.autoChoosePortal) { - jumpToTheBestPortal(); + if (astralPlus.allowedToEquip()) { + nextWaveCheck = 0; } - } - - private void jumpToTheBestPortal() { - this.currentStatus = State.CHOOSING_PORTAL; - if (astralGui != null && astralGui.isVisible()) { - astralGui.setVisible(false); + if (nextWaveCheck > System.currentTimeMillis()) { + return; } - - astralPortalSupplier.setAstralShip(astralShip); - Portal portal = astralPortalSupplier.get(); - - if (portal == null) { - portal = portals.stream().filter(p -> p.getTypeId() == 1).findFirst().orElse(null); + if (!waveHasBeenAwaited) { + waveHasBeenAwaited = true; + nextWaveCheck = System.currentTimeMillis() + waitTime; } - if (portal != null) { - lastPortal = portal.getTypeId(); - if (heroapi.distanceTo(portal) < 200) { - movement.jumpPortal(portal); - } else { - movement.moveTo(portal); - } - } - } + goToTheMiddle(); - private void chooseItem() { - if (astralGui.isVisible() && chooseClickDelay < System.currentTimeMillis() && astralShip != null) { - chooseClickDelay = System.currentTimeMillis() + 20000; - if (lastPortal == 87 || lastPortal == 88) { - astralShip.setWeapons(astralShip.getWeapons() + 1); - } else if (lastPortal == 89 || lastPortal == 90) { - astralShip.setGenerators(astralShip.getGenerators() + 1); - } else if (lastPortal == 95 || lastPortal == 96) { - astralShip.setModules(astralShip.getModules() + 1); - } - randomChoose(); - lastPortal = 0; - astralGui.setVisible(false); + if (astralConfig.autoChoose && astralPlus.autoChoose(astralConfig.portalInfos)) { + this.currentStatus = State.CHOOSING_BEST_OPTION; + } else if (!portals.isEmpty() || astralPlus.hasOptionsToChoose()) { + stopBot(State.WAITING_HUMAN); + } else { + this.currentStatus = State.WAITING_WAVE; } } - private void randomChoose() { - if (!astralConfig.autoChooseItem) { - return; - } - - this.currentStatus = State.CHOOSING_ITEM; - Integer xPoint = rand.nextInt((int) astralGui.getWidth() - guiOffset) + guiOffset + (int) astralGui.getX(); - Integer yPoint = (int) ((astralGui.getHeight() / 2) + astralGui.getY()); - astralGui.click(xPoint, yPoint); - + private void stopBot(State stateToSet) { + this.showDialog = true; + this.currentStatus = stateToSet; + this.bot.setRunning(false); } private boolean isAstral() { @@ -351,10 +290,6 @@ private boolean isAstral() { } private boolean changeAmmo() { - if (System.currentTimeMillis() < laserTime) { - return false; - } - if (astralConfig.useBestAmmoLogic == BestAmmoConfig.ALWAYS || attacker.hasExtraFlag(ExtraNpcFlags.BEST_AMMO) || useSpecialLogic()) { changeLaser(true); @@ -371,15 +306,17 @@ private boolean changeAmmo() { return true; } - if (astralConfig.ammoKey == null) { - astralConfig.ammoKey = ammoKey.getValue(); - } - if (!ammoKey.getValue().equals(astralConfig.ammoKey)) { - ammoKey.setValue(astralConfig.ammoKey); + Item currentRocket = items.getItems(ItemCategory.ROCKETS).stream().filter(Item::isSelected).findFirst() + .orElse(null); + if (currentRocket == null || currentRocket.getQuantity() <= 2) { + changeRocket(false); } - Item defaultLaser = items.getItem(ammoKey.getValue()); - if (defaultLaser == null || defaultLaser.getQuantity() > 100) { - changeLaser(false); + + Item defaultLaser = items.getItems(ItemCategory.LASERS).stream() + .filter(i -> i.getId().equals(astralConfig.defaultLaser)).findFirst() + .orElse(null); + if (defaultLaser != null && defaultLaser.getQuantity() > 100) { + changeLaser(defaultLaser); } return false; @@ -532,22 +469,37 @@ protected double score(Locatable loc) { } public void changeRocket(boolean bestRocket) { - if (System.currentTimeMillis() < rocketTime) { - return; - } SelectableItem rocket = null; if (bestRocket) { rocket = rocketSupplier.get(); } else { rocket = SharedFunctions.getItemById(astralConfig.defaultRocket); - if (rocket == null || items.getItem(rocket, ItemFlag.USABLE, ItemFlag.READY).isEmpty()) { + if (rocket == null + || items.getItem(rocket, ItemFlag.USABLE, ItemFlag.READY, ItemFlag.POSITIVE_QUANTITY).isEmpty()) { rocket = rocketSupplier.getReverse(); } } - if (rocket != null && heroapi.getRocket() != null && !heroapi.getRocket().getId().equals(rocket.getId()) - && useSelectableReadyWhenReady(rocket)) { - rocketTime = System.currentTimeMillis() + 2000; + if (rocket != null && heroapi.getRocket() != null && !heroapi.getRocket().getId().equals(rocket.getId())) { + useSelectableReadyWhenReady(rocket); + } + } + + private void changeLaser(SelectableItem laser) { + try { + if (laser != null && heroapi.getLaser() != null && !heroapi.getLaser().getId().equals(laser.getId()) + && items.useItem(laser, 250, ItemFlag.USABLE, ItemFlag.READY).isSuccessful()) { + changeAmmoKey(laser); + } + } catch (Exception e) { + // HeroApi getLaser Error + } + } + + private void changeAmmoKey(SelectableItem laser) { + Character key = items.getKeyBind(laser); + if (ammoKey.getValue() != key) { + ammoKey.setValue(key); } } @@ -560,28 +512,21 @@ public void changeLaser(boolean bestLaser) { } if (laser == null) { - return; - } - - Laser currentLaser = heroapi.getLaser(); - if (currentLaser != null && !currentLaser.getId().equals(laser.getId()) - && useSelectableReadyWhenReady(laser)) { - Character key = items.getKeyBind(laser); - if (key != null && !ammoKey.getValue().equals(key)) { - ammoKey.setValue(key); - } - laserTime = System.currentTimeMillis() + 500; + laser = SharedFunctions.getItemById(astralConfig.defaultLaser); } + changeLaser(laser); } public boolean useSelectableReadyWhenReady(SelectableItem selectableItem) { - if (System.currentTimeMillis() - clickDelay < 1000) + if (System.currentTimeMillis() - clickDelay < 1000) { return false; - if (selectableItem == null) + } + if (selectableItem == null) { return false; + } - if (items.useItem(selectableItem, ItemFlag.USABLE, ItemFlag.READY).isSuccessful()) { + if (items.useItem(selectableItem, 250, ItemFlag.USABLE, ItemFlag.READY).isSuccessful()) { clickDelay = System.currentTimeMillis(); return true; } @@ -594,7 +539,7 @@ private void goToAstral() { return; } - GameMap map = starSystem.getByName("GG Astral"); + GameMap map = starSystem.findMap("GG Astral").orElse(null); if (map == null || map == starSystem.getCurrentMap()) { return; } @@ -628,6 +573,10 @@ private boolean useSpecialLogic() { return false; } + if (astralPlus.getRift() >= 15) { + return true; + } + if (heroapi.getHealth().hpPercent() <= 0.20) { return true; } @@ -655,44 +604,10 @@ private void goToTheMiddle() { private void activeAutoRocketCPU() { if (nextCPUCheck < System.currentTimeMillis()) { nextCPUCheck = System.currentTimeMillis() + 300000; - items.useItem(SelectableItem.Cpu.AROL_X, ItemFlag.NOT_SELECTED); + items.useItem(SelectableItem.Cpu.AROL_X, 500, ItemFlag.NOT_SELECTED); } } - private void countItems() { - if (portals == null) { - return; - } - - if (portals.isEmpty()) { - if (lastPortal != 0 && astralShip != null) { - switch (lastPortal) { - case 87: - case 88: - astralShip.setWeapons(astralShip.getWeapons() + 1); - break; - case 89: - case 90: - astralShip.setGenerators(astralShip.getGenerators() + 1); - break; - case 95: - case 96: - astralShip.setModules(astralShip.getModules() + 1); - break; - default: - lastPortal = 0; - } - } - lastPortal = 0; - } else { - Portal portal = portals.stream().filter(Portal::isJumping).findFirst().orElse(null); - if (portal != null) { - lastPortal = portal.getTypeId(); - } - } - - } - private void showWarningDialog() { if (!showDialog || warningDisplayed) { return; @@ -706,11 +621,17 @@ private void showWarningDialog() { warningDisplayed = false; showDialog = false; }); + + JButton discordBtn = new JButton("+Info"); + discordBtn.addActionListener(e -> { + SystemUtils.openUrl(Utils.DISCORD_URL); + }); + Popups.of("Astral Gate", new JOptionPane( - "Manual action is needed", + "Manual action is needed. \n With the PLUS functions the bot will not need manual actions.", JOptionPane.INFORMATION_MESSAGE, - JOptionPane.DEFAULT_OPTION, null, new Object[] { closeBtn })) + JOptionPane.DEFAULT_OPTION, null, new Object[] { discordBtn, closeBtn })) .showAsync(); } } diff --git a/src/main/java/com/deeme/modules/astral/AstralPortalSupplier.java b/src/main/java/com/deeme/modules/astral/AstralPortalSupplier.java deleted file mode 100644 index 059db04b..00000000 --- a/src/main/java/com/deeme/modules/astral/AstralPortalSupplier.java +++ /dev/null @@ -1,111 +0,0 @@ -package com.deeme.modules.astral; - -import java.util.Collection; - -import eu.darkbot.api.PluginAPI; -import eu.darkbot.api.extensions.selectors.PrioritizedSupplier; -import eu.darkbot.api.game.entities.Portal; -import eu.darkbot.api.game.items.ItemCategory; -import eu.darkbot.api.managers.EntitiesAPI; -import eu.darkbot.api.managers.HeroAPI; -import eu.darkbot.api.managers.HeroItemsAPI; - -public class AstralPortalSupplier implements PrioritizedSupplier { - protected HeroAPI heroapi; - protected HeroItemsAPI items; - protected Collection portals; - protected AstralShip astralShip; - - private boolean focusDamage = false; - private boolean focusAmmo = false; - private boolean focusGenerators = false; - private boolean focusModules = false; - - private long nextAmmoCheck = 0; - private double lastAmmoCount = 0; - - /* - * 1 - Base - * 87 - Weapon - * 88 - Weapon (Hard) - * 89 - Generator - * 90 - Generator (Hard) - * 91 - Ammo - * 92 - Ammo (Hard) - * 95 - Module - * 96 - Module (Hard) - * 99 - PV - */ - - public AstralPortalSupplier(PluginAPI api, AstralShip astralShip) { - this.heroapi = api.getAPI(HeroAPI.class); - this.items = api.getAPI(HeroItemsAPI.class); - this.astralShip = astralShip; - - EntitiesAPI entities = api.getAPI(EntitiesAPI.class); - this.portals = entities.getPortals(); - } - - public void setAstralShip(AstralShip astralShip) { - this.astralShip = astralShip; - } - - public Portal get() { - Portal target = null; - if (heroapi.getHealth().hpPercent() < 0.9) { - target = portals.stream().filter(portal -> portal.getTypeId() == 99).findFirst().orElse(null); - } - if (getAmmoCount() <= 100000 && target == null) { - this.focusAmmo = true; - target = portals.stream().filter(portal -> portal.getTypeId() == 91).findFirst().orElse(null); - } - if (astralShip != null) { - if (astralShip.getMaxModules() > astralShip.getModules() && target == null) { - this.focusModules = true; - target = portals.stream().filter(portal -> portal.getTypeId() == 89).findFirst().orElse(null); - } - if (target == null && (astralShip.getMaxGenerators() > astralShip.getGenerators() - || heroapi.getSpeed() < 370)) { - this.focusGenerators = true; - target = portals.stream().filter(portal -> portal.getTypeId() == 95).findFirst().orElse(null); - } - if (astralShip.getMaxWeapons() > astralShip.getWeapons() && target == null) { - this.focusDamage = true; - target = portals.stream().filter(portal -> portal.getTypeId() == 87).findFirst().orElse(null); - } - } - - if (target == null) { - target = getHardPortals(); - } - - return target; - } - - public Portal getHardPortals() { - Portal target = null; - - if (focusAmmo) { - target = portals.stream().filter(portal -> portal.getTypeId() == 92).findFirst().orElse(null); - } - if (focusModules && target == null) { - target = portals.stream().filter(portal -> portal.getTypeId() == 96).findFirst().orElse(null); - } - if (focusGenerators && target == null) { - target = portals.stream().filter(portal -> portal.getTypeId() == 90).findFirst().orElse(null); - } - if (focusDamage && target == null) { - target = portals.stream().filter(portal -> portal.getTypeId() == 88).findFirst().orElse(null); - } - - return target; - } - - public double getAmmoCount() { - if (nextAmmoCheck < System.currentTimeMillis()) { - lastAmmoCount = items.getItems(ItemCategory.LASERS).stream().mapToDouble(ammo -> ammo.getQuantity()).sum(); - nextAmmoCheck = System.currentTimeMillis() + 60000; - } - return lastAmmoCount; - } -} \ No newline at end of file diff --git a/src/main/java/com/deeme/modules/astral/AstralShip.java b/src/main/java/com/deeme/modules/astral/AstralShip.java deleted file mode 100644 index c563a8f1..00000000 --- a/src/main/java/com/deeme/modules/astral/AstralShip.java +++ /dev/null @@ -1,92 +0,0 @@ -package com.deeme.modules.astral; - -public class AstralShip { - - private Integer maxModules = 3; - private Integer maxWeapons = 15; - private Integer maxGenerators = 15; - - private Integer modules = 0; - private Integer weapons = 12; - private Integer generators = 11; - - private ShipType shipType = null; - - public enum ShipType { - SENTINEL, - DIMINISHER, - ZEPHIR, - PUSAT; - } - - public AstralShip(String shipType) { - if (shipType.equals("ship_sentinel")) { - this.shipType = ShipType.SENTINEL; - this.maxWeapons = 15; - this.maxGenerators = 15; - } else if (shipType.equals("ship_diminisher")) { - this.shipType = ShipType.DIMINISHER; - this.maxWeapons = 15; - this.maxGenerators = 15; - } else if (shipType.equals("ship_zephyr")) { - this.shipType = ShipType.ZEPHIR; - this.maxWeapons = 12; - this.maxGenerators = 16; - } else if (shipType.equals("ship_pusat")) { - this.shipType = ShipType.PUSAT; - this.maxWeapons = 12; - this.maxGenerators = 11; - } - } - - public String getStatus() { - return getShipType() + " | M:" + getModules() + "/" + getMaxModules() + " | W:" + getWeapons() + "/" - + getMaxWeapons() + " | G: " + getGenerators() + "/" + getMaxGenerators(); - } - - public boolean isValid(String ship) { - return this.shipType != null - && (ship.equals("ship_sentinel") || ship.equals("ship_diminisher") || ship.equals("ship_zephyr") - || ship.equals("ship_pusat")); - } - - public ShipType getShipType() { - return shipType; - } - - public Integer getGenerators() { - return generators; - } - - public Integer getMaxGenerators() { - return maxGenerators; - } - - public Integer getModules() { - return modules; - } - - public Integer getMaxModules() { - return maxModules; - } - - public Integer getWeapons() { - return weapons; - } - - public Integer getMaxWeapons() { - return maxWeapons; - } - - public void setGenerators(Integer generators) { - this.generators = generators; - } - - public void setModules(Integer modules) { - this.modules = modules; - } - - public void setWeapons(Integer weapons) { - this.weapons = weapons; - } -} diff --git a/src/main/java/com/deeme/modules/astral/AvailableShips.java b/src/main/java/com/deeme/modules/astral/AvailableShips.java new file mode 100644 index 00000000..f312db28 --- /dev/null +++ b/src/main/java/com/deeme/modules/astral/AvailableShips.java @@ -0,0 +1,22 @@ +package com.deeme.modules.astral; + +import eu.darkbot.api.config.annotations.Configuration; + +@Configuration("astral.ship_type.list") + +public enum AvailableShips { + ZEPHYR("zephyr"), + DIMINISHER("diminisher"), + SENTINEL("sentinel"), + PUSAT("pusat"); + + private final String id; + + AvailableShips(String id) { + this.id = "ship_" + id.toLowerCase(); + } + + public String getId() { + return id; + } +} \ No newline at end of file diff --git a/src/main/java/com/deeme/types/ConditionsManagement.java b/src/main/java/com/deeme/types/ConditionsManagement.java index dfda76ee..bf88d3b1 100644 --- a/src/main/java/com/deeme/types/ConditionsManagement.java +++ b/src/main/java/com/deeme/types/ConditionsManagement.java @@ -47,6 +47,6 @@ public boolean useSelectableReadyWhenReady(SelectableItem selectableItem) { return false; } - return items.useItem(selectableItem, ItemFlag.USABLE, ItemFlag.READY, ItemFlag.AVAILABLE).isSuccessful(); + return items.useItem(selectableItem, 250, ItemFlag.USABLE, ItemFlag.READY, ItemFlag.AVAILABLE).isSuccessful(); } } diff --git a/src/main/resources/plugin.json b/src/main/resources/plugin.json index b0be6d18..7656137a 100644 --- a/src/main/resources/plugin.json +++ b/src/main/resources/plugin.json @@ -1,8 +1,8 @@ { "name": "DmPlugin", "author": "Dm94Dani", - "version": "2.0.8", - "minVersion": "1.126", + "version": "2.1.3", + "minVersion": "1.127", "supportedVersion": "1.127", "basePackage": "com.deeme", "features": [ @@ -34,6 +34,6 @@ ], "donation": "https://ko-fi.com/deeme", "discord": "https://discord.gg/GPRTRRZJPw", - "download": "https://github.com/darkbot-reloaded/DmPlugin/releases/download/v2.0.8/DmPlugin.jar", + "download": "https://github.com/darkbot-reloaded/DmPlugin/releases/download/v2.1.3/DmPlugin.jar", "update": "https://raw.githubusercontent.com/darkbot-reloaded/DmPlugin/master/src/main/resources/plugin.json" }