Aggressive NPCs will no longer always attack the last player to enter the area
This commit is contained in:
@@ -132,9 +132,9 @@ public class AggressiveBehavior {
|
|||||||
*/
|
*/
|
||||||
public Entity getLogicalTarget(Entity entity, List<Entity> possibleTargets) {
|
public Entity getLogicalTarget(Entity entity, List<Entity> possibleTargets) {
|
||||||
Entity target = null;
|
Entity target = null;
|
||||||
int comparingFlag = Integer.MAX_VALUE;
|
double comparingFlag = Double.MAX_VALUE;
|
||||||
for (Entity e : possibleTargets) {
|
for (Entity e : possibleTargets) {
|
||||||
int flag = getPriorityFlag(e);
|
double flag = (double)getPriorityFlag(e) + Math.random();
|
||||||
if (flag <= comparingFlag) {
|
if (flag <= comparingFlag) {
|
||||||
comparingFlag = flag;
|
comparingFlag = flag;
|
||||||
target = e;
|
target = e;
|
||||||
|
|||||||
Reference in New Issue
Block a user