mirror of
https://github.com/OMGeeky/andors-trail.git
synced 2026-02-23 15:38:29 +01:00
Faction-related agressivenes of each monster is now dynamic, not a
one-way flag.
This commit is contained in:
@@ -84,7 +84,7 @@ public final class CombatController implements VisualEffectCompletedCallback {
|
||||
}
|
||||
public void setCombatSelection(Monster selectedMonster, Coord selectedPosition) {
|
||||
if (selectedMonster != null) {
|
||||
if (!selectedMonster.isAgressive()) return;
|
||||
if (!selectedMonster.isAgressive(world.model.player)) return;
|
||||
}
|
||||
Coord previousSelection = world.model.uiSelections.selectedPosition;
|
||||
if (previousSelection != null) {
|
||||
@@ -321,12 +321,12 @@ public final class CombatController implements VisualEffectCompletedCallback {
|
||||
|
||||
for (MonsterSpawnArea a : world.model.currentMap.spawnAreas) {
|
||||
for (Monster m : a.monsters) {
|
||||
if (!m.isAgressive()) continue;
|
||||
if (!m.isAgressive(world.model.player)) continue;
|
||||
|
||||
if (shouldAttackWithMonsterInCombat(m, playerPosition)) {
|
||||
currentActiveMonster = m;
|
||||
return MonsterAction.attack;
|
||||
} else if (shouldMoveMonsterInCombat(m, a, playerPosition)) {
|
||||
} else if (shouldMoveMonsterInCombat(m, a, world.model.player, playerPosition)) {
|
||||
currentActiveMonster = m;
|
||||
return MonsterAction.move;
|
||||
}
|
||||
@@ -340,13 +340,13 @@ public final class CombatController implements VisualEffectCompletedCallback {
|
||||
if (!m.rectPosition.isAdjacentTo(playerPosition)) return false;
|
||||
return true;
|
||||
}
|
||||
private static boolean shouldMoveMonsterInCombat(Monster m, MonsterSpawnArea a, Coord playerPosition) {
|
||||
private static boolean shouldMoveMonsterInCombat(Monster m, MonsterSpawnArea a, Player p, Coord playerPosition) {
|
||||
final MonsterType.AggressionType movementAggressionType = m.getMovementAggressionType();
|
||||
if (movementAggressionType == MonsterType.AggressionType.none) return false;
|
||||
|
||||
if (!m.hasAPs(m.getMoveCost())) return false;
|
||||
if (m.position.isAdjacentTo(playerPosition)) return false;
|
||||
if (!m.isAgressive()) return false;
|
||||
if (!m.isAgressive(p)) return false;
|
||||
|
||||
if (movementAggressionType == MonsterType.AggressionType.protectSpawn) {
|
||||
if (a.area.contains(playerPosition)) return true;
|
||||
|
||||
@@ -105,7 +105,7 @@ public final class MapController {
|
||||
}
|
||||
|
||||
public void steppedOnMonster(Monster m, Coord p) {
|
||||
if (m.isAgressive()) {
|
||||
if (m.isAgressive(world.model.player)) {
|
||||
controllers.combatController.setCombatSelection(m, p);
|
||||
if (controllers.preferences.confirmAttack) {
|
||||
worldEventListeners.onPlayerSteppedOnMonster(m);
|
||||
|
||||
@@ -39,7 +39,7 @@ public final class MonsterMovementController implements EvaluateWalkable {
|
||||
public void attackWithAgressiveMonsters() {
|
||||
for (MonsterSpawnArea a : world.model.currentMap.spawnAreas) {
|
||||
for (Monster m : a.monsters) {
|
||||
if (!m.isAgressive()) continue;
|
||||
if (!m.isAgressive(world.model.player)) continue;
|
||||
if (!m.isAdjacentTo(world.model.player)) continue;
|
||||
|
||||
int aggressionChanceBias = world.model.player.getSkillLevel(SkillCollection.SkillID.evasion) * SkillCollection.PER_SKILLPOINT_INCREASE_EVASION_MONSTER_ATTACK_CHANCE_PERCENTAGE;
|
||||
@@ -89,7 +89,7 @@ public final class MonsterMovementController implements EvaluateWalkable {
|
||||
return;
|
||||
}
|
||||
if (m.nextPosition.contains(world.model.player.position)) {
|
||||
if (!m.isAgressive()) {
|
||||
if (!m.isAgressive(world.model.player)) {
|
||||
cancelCurrentMonsterMovement(m);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ public final class MovementController implements TimedMessageTask.Callback {
|
||||
if (aggressiveness == AndorsTrailPreferences.MOVEMENTAGGRESSIVENESS_NORMAL) return true;
|
||||
|
||||
Monster m = world.model.currentMap.getMonsterAt(player.nextPosition);
|
||||
if (m != null && !m.isAgressive()) return true; // avoid MOVEMENTAGGRESSIVENESS settings for NPCs
|
||||
if (m != null && !m.isAgressive(player)) return true; // avoid MOVEMENTAGGRESSIVENESS settings for NPCs
|
||||
|
||||
if (aggressiveness == AndorsTrailPreferences.MOVEMENTAGGRESSIVENESS_AGGRESSIVE && m == null) return false;
|
||||
if (aggressiveness == AndorsTrailPreferences.MOVEMENTAGGRESSIVENESS_DEFENSIVE && m != null) return false;
|
||||
@@ -346,13 +346,14 @@ public final class MovementController implements TimedMessageTask.Callback {
|
||||
}
|
||||
|
||||
public static void refreshMonsterAggressiveness(final PredefinedMap map, final Player player) {
|
||||
for(MonsterSpawnArea a : map.spawnAreas) {
|
||||
for (Monster m : a.monsters) {
|
||||
String faction = m.getFaction();
|
||||
if (faction == null) continue;
|
||||
if (player.getAlignment(faction) < 0) m.forceAggressive();
|
||||
}
|
||||
}
|
||||
// Faction-related agressiveness now dynamic, and unrelated to "forceAgressive".
|
||||
// for(MonsterSpawnArea a : map.spawnAreas) {
|
||||
// for (Monster m : a.monsters) {
|
||||
// String faction = m.getFaction();
|
||||
// if (faction == null) continue;
|
||||
// if (player.getAlignment(faction) < 0) m.forceAggressive();
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
public static boolean hasAdjacentAggressiveMonster(PredefinedMap map, Player player) {
|
||||
@@ -361,7 +362,7 @@ public final class MovementController implements TimedMessageTask.Callback {
|
||||
public static Monster getAdjacentAggressiveMonster(PredefinedMap map, Player player) {
|
||||
for (MonsterSpawnArea a : map.spawnAreas) {
|
||||
for (Monster m : a.monsters) {
|
||||
if (!m.isAgressive()) continue;
|
||||
if (!m.isAgressive(player)) continue;
|
||||
if (m.isAdjacentTo(player)) return m;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,8 +87,8 @@ public final class Monster extends Actor {
|
||||
return this.rectPosition.isAdjacentTo(p.position);
|
||||
}
|
||||
|
||||
public boolean isAgressive() {
|
||||
return getPhraseID() == null || forceAggressive;
|
||||
public boolean isAgressive(Player p) {
|
||||
return getPhraseID() == null || forceAggressive || (p != null && getFaction() != null && p.getAlignment(getFaction()) < 0);
|
||||
}
|
||||
|
||||
public void forceAggressive() {
|
||||
|
||||
Reference in New Issue
Block a user