From 9b70be38becff91a1670cbc1606bb49211c3da2e Mon Sep 17 00:00:00 2001 From: Sollace Date: Sun, 6 Aug 2023 18:28:30 +0100 Subject: [PATCH] Added disloyal mobs --- .../minelittlepony/unicopia/entity/Creature.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/minelittlepony/unicopia/entity/Creature.java b/src/main/java/com/minelittlepony/unicopia/entity/Creature.java index 77f87250..e4af6537 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/Creature.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/Creature.java @@ -56,10 +56,10 @@ public class Creature extends Living implements WeaklyOwned.Mutabl private boolean discordedChanged = true; - private final Predicate targetPredicate = TargetSelecter.notOwnerOrFriend(this, this).and(e -> { + private final Predicate targetPredicate = TargetSelecter.notOwnerOrFriend(() -> getOriginatingCaster().getAffinity(), this).and(e -> { return Equine.of(e) .filter(eq -> eq instanceof Creature) - .filter(eq -> ((Creature)eq).hasCommonOwner(this)) + .filter(eq -> isDiscorded() != ((Creature)eq).hasCommonOwner(this)) .isEmpty(); }); @@ -162,6 +162,9 @@ public class Creature extends Living implements WeaklyOwned.Mutabl } private void initDiscordedAi() { + if (getMasterReference().isSet()) { + return; + } targets.ifPresent(this::clearGoals); // the brain drain entity.getBrain().clear(); @@ -269,7 +272,11 @@ public class Creature extends Living implements WeaklyOwned.Mutabl @Override public Affinity getAffinity() { if (getMaster() instanceof Affine) { - return ((Affine)getMaster()).getAffinity(); + Affinity affinity = ((Affine)getMaster()).getAffinity(); + if (isDiscorded()) { + return affinity == Affinity.BAD ? Affinity.GOOD : affinity == Affinity.GOOD ? Affinity.BAD : affinity; + } + return affinity; } return Affinity.NEUTRAL; }