-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update to api v0.9.7, implement fake NPC api
- Loading branch information
1 parent
377b65b
commit b7de0bf
Showing
14 changed files
with
288 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
src/main/java/com/github/manolo8/darkbot/core/entities/fake/FakeEntities.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.github.manolo8.darkbot.core.entities.fake; | ||
|
||
public class FakeEntities { | ||
private static int CURR_ID = Integer.MIN_VALUE; | ||
|
||
public static int allocateFakeId() { | ||
return CURR_ID++; | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
src/main/java/com/github/manolo8/darkbot/core/entities/fake/FakeExtension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package com.github.manolo8.darkbot.core.entities.fake; | ||
|
||
import com.github.manolo8.darkbot.Main; | ||
import com.github.manolo8.darkbot.core.entities.Entity; | ||
import com.github.manolo8.darkbot.core.objects.LocationInfo; | ||
import eu.darkbot.api.game.entities.FakeEntity; | ||
import eu.darkbot.api.game.other.Location; | ||
import eu.darkbot.util.Timer; | ||
|
||
public interface FakeExtension extends FakeEntity { | ||
|
||
FakeExtension.Data getFakeData(); | ||
|
||
@Override | ||
default void setRemoveOnSelect(boolean remove) { | ||
getFakeData().removeOnSelect = remove; | ||
} | ||
|
||
@Override | ||
default void setRemoveDistance(long removeDistance) { | ||
getFakeData().removeDistance = removeDistance; | ||
} | ||
|
||
@Override | ||
default void setLocation(Location location) { | ||
((LocationInfo) getLocationInfo()).updatePosition(location.x(), location.y()); | ||
} | ||
|
||
@Override | ||
default void setTimeout(long keepAlive) { | ||
getFakeData().setTimeout(keepAlive); | ||
} | ||
|
||
class Data { | ||
private final Entity entity; | ||
private Timer timeout; | ||
private long removeDistance; | ||
private boolean removeOnSelect; | ||
|
||
public Data(Entity entity) { | ||
this.entity = entity; | ||
this.entity.main = Main.INSTANCE; | ||
this.entity.removed = false; | ||
} | ||
|
||
private void setTimeout(long keepAlive) { | ||
if (keepAlive != -1) { | ||
timeout = Timer.get(keepAlive); | ||
timeout.activate(); | ||
} | ||
else timeout = null; | ||
} | ||
|
||
public boolean isInvalid() { | ||
if (timeout != null && timeout.isInactive()) return true; | ||
return removeDistance == -1 || entity.main.hero.distanceTo(entity) < removeDistance; | ||
} | ||
|
||
public boolean trySelect(boolean tryAttack) { | ||
if (removeOnSelect) entity.removed(); | ||
return false; | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.