Skip to content

Commit

Permalink
Merge branch 'master' into feat/autobestability-all
Browse files Browse the repository at this point in the history
  • Loading branch information
dm94 authored Nov 23, 2024
2 parents 35c3a4e + c3bbc95 commit 373be26
Show file tree
Hide file tree
Showing 32 changed files with 182 additions and 199 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ hs_err_pid*
.idea/*
.gradle/
build/
bin/
out/*
DmPlugin.iml
dmplugin.properties
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/deeme/behaviours/ProfileChanger.java
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@ private boolean isReadyTimeCondition() {

LocalDateTime da = LocalDateTime.now();

return da.getHour() > config.timeCondition.hour
|| (config.timeCondition.hour == da.getHour() && da.getMinute() >= config.timeCondition.minute);
return config.timeCondition.hour == da.getHour()
&& (da.getMinute() >= config.timeCondition.minute && config.timeCondition.minute <= da.getMinute() + 5);
}

private boolean isReadyKeyCondition() {
Expand Down
28 changes: 0 additions & 28 deletions src/main/java/com/deeme/behaviours/UrgentDetectorDummy.java

This file was deleted.

43 changes: 0 additions & 43 deletions src/main/java/com/deeme/behaviours/aitrainer/AiTrainerDummy.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class ProfileChangerConfig {

@Option("general.bot_profile")
@Dropdown(options = ProfileNames.class)
public String BOT_PROFILE = "";
public String BOT_PROFILE = "config";

@Option("profile_changer.close_bot")
public boolean closeBot = false;
Expand Down
37 changes: 0 additions & 37 deletions src/main/java/com/deeme/behaviours/pvplog/PVPLogDummy.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ public class UrgentDetectorConfig {

@Option("urgent_detector.bot_profile")
@Dropdown(options = ProfileNames.class)
public String botProfile = "";
public String botProfile = "config";
}
31 changes: 24 additions & 7 deletions src/main/java/com/deeme/modules/SentinelModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@

import java.util.Arrays;
import java.util.Collection;
import java.util.Random;

import javax.swing.JComponent;
import javax.swing.JLabel;
Expand Down Expand Up @@ -89,6 +90,8 @@ public class SentinelModule implements Module, Configurable<SentinelConfig>, Ins
private int groupLeaderID = 0;

private long randomWaitTime = 0;
private Random rnd;
private Entity oldTarget;

private Location lastSentinelLocation = null;

Expand Down Expand Up @@ -162,6 +165,8 @@ public SentinelModule(Main main, PluginAPI api, AuthAPI auth, SafetyFinder safet
this.runConfigInCircle = configApi.requireConfig("loot.run_config_in_circle");
this.configRun = configApi.requireConfig("general.run");
this.configRoam = configApi.requireConfig("general.roam");
this.rnd = new Random();
this.oldTarget = null;

setup();
}
Expand Down Expand Up @@ -288,6 +293,7 @@ private boolean followByPortals() {
if (!sConfig.followByPortals || lastSentinelLocation == null) {
return false;
}

Portal portal = getNearestPortal(lastSentinelLocation);
if (portal != null) {
if (group.hasGroup() && masterID != 0) {
Expand Down Expand Up @@ -322,6 +328,14 @@ private GameMap getWorkingMap() {
}

private boolean isAttacking() {
if (this.randomWaitTime > System.currentTimeMillis()) {
return this.oldTarget != null;
}

if (sConfig.humanizer.addRandomTime) {
this.randomWaitTime = System.currentTimeMillis() + (rnd.nextInt(sConfig.humanizer.maxRandomTime) * 1000);
}

Entity target = getSentinelTarget();

if (target == null) {
Expand All @@ -337,34 +351,37 @@ private boolean isAttacking() {
}

if (target == null && sConfig.autoAttack.autoAttackEnemies) {
target = shipAttacker.getEnemy(sConfig.autoAttack.rangeForEnemies);
target = this.shipAttacker.getEnemy(sConfig.autoAttack.rangeForEnemies);
}
if (target == null && sConfig.autoAttack.defendFromNPCs) {
target = SharedFunctions.getAttacker(heroapi, npcs, heroapi);
}

if (target != null) {
setMode(extraConfigChangerLogic.getShipMode());
if (target instanceof Npc) {
isNpc = true;
this.isNpc = true;
attacker.setTarget((Npc) target);
attacker.tryLockAndAttack();
} else {
isNpc = false;
this.isNpc = false;
shipAttacker.setTarget((Ship) target);
shipAttacker.tryLockAndAttack();
}
}

this.oldTarget = target;

return target != null;
}

private Entity getSentinelTarget() {
if (randomWaitTime > System.currentTimeMillis()) {
return null;
}

Entity target = null;
if (sentinel.getTarget() != null) {
if (this.oldTarget != null && this.oldTarget.getId() == sentinel.getTarget().getId()) {
return this.oldTarget;
}

if (sConfig.autoAttack.helpAttackPlayers || sConfig.autoAttack.helpAttackEnemyPlayers) {
target = players.stream()
.filter(s -> (sentinel.getTarget().getId() == s.getId())
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/deeme/modules/astral/AstralConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
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.Percentage;
import eu.darkbot.api.config.annotations.Table;

@Configuration("astral")
Expand All @@ -36,6 +37,10 @@ public class AstralConfig {
@Option("astral.attack_closest")
public boolean alwaysTheClosestNPC = false;

@Option("astral.min_shield_to_repair")
@Percentage
public double minShieldToRepair = 0.2;

@Option("astral.best_ammo")
@Dropdown
public BestAmmoConfig useBestAmmoLogic = BestAmmoConfig.ONLY_MARKED;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/deeme/modules/astral/AstralGate.java
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public void onTickModule() {
if (astralPlus.isValidShip()) {
activeAutoRocketCPU();
repairShield = repairShield && heroapi.getHealth().shieldPercent() < 0.9
|| heroapi.getHealth().shieldPercent() < 0.2;
|| heroapi.getHealth().shieldPercent() < astralConfig.minShieldToRepair;
if (findTarget()) {
waveLogic();
} else if (npcs.isEmpty() || !portals.isEmpty()) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/deeme/tasks/WeeklySchedule.java
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ private void setProfile() {
}

private boolean isRunningPalladiumModule() {
return botApi.getModule().getClass() == PalladiumHangar.class;
return botApi.getModule() != null && botApi.getModule().getClass() == PalladiumHangar.class;
}

private void tryUpdateHangarList() {
Expand Down
11 changes: 6 additions & 5 deletions src/main/java/com/deeme/types/ShipAttacker.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public class ShipAttacker {
private Random rnd;

private int lastAttacked;
private static final int MIN_CLICK_DELAY = 250;

private boolean firstAttack;
private long isAttacking;
Expand Down Expand Up @@ -110,9 +111,10 @@ private void tryLockTarget() {
lastAttacked = target.getId();
firstAttack = true;

clickDelay = System.currentTimeMillis();
if (humanizerConfig.addRandomTime) {
clickDelay = System.currentTimeMillis() + (rnd.nextInt(humanizerConfig.maxRandomTime) * 1000);
} else {
clickDelay = System.currentTimeMillis() + MIN_CLICK_DELAY;
}
}

Expand All @@ -124,7 +126,7 @@ private void tryLockTarget() {
if (System.currentTimeMillis() > clickDelay) {
heroapi.setLocalTarget(target);
target.trySelect(false);
clickDelay = System.currentTimeMillis();
clickDelay = System.currentTimeMillis() + MIN_CLICK_DELAY;
}
} else {
movement.moveTo(target.getDestination().orElse(target.getLocationInfo()));
Expand Down Expand Up @@ -285,11 +287,10 @@ public Ship getEnemy(int maxDistance, List<Integer> playersToIgnore, boolean ign
&& (ableToAttack || s.isAttacking())
&& !s.hasEffect(290)
&& !(s instanceof Pet)
&& !(ignoreInvisible && s.isInvisible())
&& !inGroup(s.getId())
&& !(ignoreInvisible && s.isInvisible()))
.filter(s -> !inGroup(s.getId())
&& movement.canMove(s)
&& s.getLocationInfo().distanceTo(heroapi) <= maxDistance)

.sorted(Comparator.comparingDouble(s -> s.getLocationInfo().distanceTo(heroapi))).findAny()
.orElse(null);
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/deeme/types/backpage/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static synchronized void discordCheck(FeatureInfo<?> featureInfo, String
if (!Backpage.isInDiscord(authID)) {
String discordTag = Backpage.getDiscordTagExternal(authID);
featureInfo
.addFailure("To use this option you need to be on my discord",
.addFailure("To use this option you need to be on the plugin discord",
"ID: " + discordTag);
}
}
Expand All @@ -32,8 +32,8 @@ public static synchronized void discordDonorCheck(FeatureInfo<?> featureInfo, St
if (!Backpage.isDonor(authID, featureInfo.getPluginInfo().getVersion().toString().trim())) {
String discordTag = Backpage.getDiscordTagExternal(authID);
featureInfo
.addFailure("[PLUS] Only some people can use this feature.",
"ID: " + discordTag);
.addFailure("[PLUS] You need to have a specific role to use this",
"Read the FAQs in discord. ID: " + discordTag);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/deeme/types/config/Profile.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ public class Profile {

@Option("general.bot_profile")
@Dropdown(options = ProfileNames.class)
public String BOT_PROFILE = "";
public String BOT_PROFILE = "config";
}
4 changes: 4 additions & 0 deletions src/main/resources/com/deeme/lang/strings_bg.properties
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ astral.portal_table.ignore_limit=Ignore Limit
astral.portal_table.ignore_limit.desc=It will enter the portal even if you have the maximum of those items.
astral.custom_item_priority=Custom priority for items
astral.extra_options=Additional options
astral.min_shield_to_repair=Minimum shield to start repairing
astral.min_shield_to_repair.desc=When it is below that shield percentage it goes into repair mode
ambulance.ship_type=Type of ship
ambulance.ship_type.desc=Also works with the plus versions
Expand Down Expand Up @@ -370,6 +372,8 @@ buy_item_conditions.quantity=Quantity
quantity_condition=Quantity condition
quantity_condition.min_quantity=Buy if less than
quantity_condition.min_quantity.desc=When the quantity of the item is below the marked quantity, the condition is activated.
quantity_condition.item_to_control=Item to use to check
quantity_condition.item_to_control.desc=This is the item that the bot will use to check the amount it has and activate the condition if it is below that amount.

anti_train=Anti Train
anti_train.max_enemies=Enemies to consider a train
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/com/deeme/lang/strings_cs.properties
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ astral.portal_table.ignore_limit=Ignore Limit
astral.portal_table.ignore_limit.desc=It will enter the portal even if you have the maximum of those items.
astral.custom_item_priority=Custom priority for items
astral.extra_options=Additional options
astral.min_shield_to_repair=Minimum shield to start repairing
astral.min_shield_to_repair.desc=When it is below that shield percentage it goes into repair mode

ambulance.ship_type=Druh lodi
ambulance.ship_type.desc=Pracuje také s verzemi plus
Expand Down Expand Up @@ -370,6 +372,8 @@ buy_item_conditions.quantity=Quantity
quantity_condition=Quantity condition
quantity_condition.min_quantity=Buy if less than
quantity_condition.min_quantity.desc=When the quantity of the item is below the marked quantity, the condition is activated.
quantity_condition.item_to_control=Item to use to check
quantity_condition.item_to_control.desc=This is the item that the bot will use to check the amount it has and activate the condition if it is below that amount.
anti_train=Anti Train
anti_train.max_enemies=Enemies to consider a train
Expand Down
Loading

0 comments on commit 373be26

Please sign in to comment.