Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions src/main/java/com/deeme/modules/SentinelModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,10 @@ private GameMap getWorkingMap() {

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

if (sConfig.humanizer.addRandomTime) {
Expand All @@ -373,11 +376,32 @@ private boolean isAttacking() {
target = SharedFunctions.getAttacker(heroapi, npcs, heroapi);
}

if (target == null) {
clearAttackTargets();
return false;
}

changeTarget(target);

this.oldTarget = target;

return target != null;
return true;
}

private boolean shouldKeepOldTarget() {
if (this.oldTarget == null || !this.oldTarget.isValid() || this.sentinel == null) {
return false;
}

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

private void clearAttackTargets() {
this.oldTarget = null;
this.isNpc = false;
this.attacker.setTarget(null);
this.shipAttacker.resetDefenseData();
}

private void changeTarget(Entity target) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "DmPlugin",
"author": "Dm94Dani",
"version": "2.11.1 beta 4",
"version": "2.11.1 beta 5",
"minVersion": "1.131.6 beta 3",
"supportedVersion": "1.132.0",
"basePackage": "com.deeme",
Expand Down
Loading