Aggressive NPCs ignore players that have been incapacitated recently #3

This commit is contained in:
Ziggy
2020-11-29 13:09:21 +01:00
parent a601a0387b
commit c8bc5c84d3

View File

@@ -32,6 +32,7 @@ import com.projectswg.holocore.intents.support.npc.ai.StartNpcCombatIntent;
import com.projectswg.holocore.resources.support.npc.spawn.Spawner;
import com.projectswg.holocore.resources.support.objects.ObjectCreator;
import com.projectswg.holocore.resources.support.objects.swg.SWGObject;
import com.projectswg.holocore.resources.support.objects.swg.creature.CreatureDifficulty;
import com.projectswg.holocore.resources.support.objects.swg.creature.CreatureObject;
import com.projectswg.holocore.resources.support.objects.swg.creature.CreatureState;
import com.projectswg.holocore.resources.support.objects.swg.tangible.OptionFlag;
@@ -132,7 +133,7 @@ public class AIObject extends CreatureObject {
}
private void checkAwareAttack(CreatureObject player) {
if (isAttackable(player)) {
if (isAttackable(player) && !isPlayerIgnored(player)) {
double distance = getLocation().flatDistanceTo(player.getLocation());
double maxAggroDistance;
if (player.isLoggedInPlayer())
@@ -253,4 +254,19 @@ public class AIObject extends CreatureObject {
}
}
private boolean isPlayerIgnored(CreatureObject player) {
CreatureDifficulty difficulty = getDifficulty();
if (difficulty == CreatureDifficulty.NORMAL) {
// Normal difficulty NPCs will let the player escape if the player has recently been incapacitated
return isPlayerRecentlyIncapacitated(player);
}
return false;
}
private boolean isPlayerRecentlyIncapacitated(CreatureObject player) {
return player.hasBuff("incapWeaken");
}
}