Make monster movement aggression based on monster type.

This commit is contained in:
Oskar Wiksten
2012-08-11 21:26:03 +00:00
parent d84d6e6c12
commit 578c4e55f2
4 changed files with 35 additions and 8 deletions

View File

@@ -15,6 +15,7 @@ import com.gpl.rpg.AndorsTrail.model.AttackResult;
import com.gpl.rpg.AndorsTrail.model.ability.SkillCollection;
import com.gpl.rpg.AndorsTrail.model.actor.Actor;
import com.gpl.rpg.AndorsTrail.model.actor.Monster;
import com.gpl.rpg.AndorsTrail.model.actor.MonsterType;
import com.gpl.rpg.AndorsTrail.model.actor.Player;
import com.gpl.rpg.AndorsTrail.model.item.ItemTraits_OnUse;
import com.gpl.rpg.AndorsTrail.model.item.Loot;
@@ -326,14 +327,14 @@ public final class CombatController implements VisualEffectCompletedCallback {
return true;
}
private static boolean shouldMoveMonsterInCombat(Monster m, MonsterSpawnArea a, Coord playerPosition) {
if (m.aggressionType == Monster.AGGRESSIONTYPE_NONE) return false;
if (m.aggressionType == MonsterType.AGGRESSIONTYPE_NONE) return false;
if (!m.hasAPs(m.actorTraits.moveCost)) return false;
if (m.position.isAdjacentTo(playerPosition)) return false;
if (m.aggressionType == Monster.AGGRESSIONTYPE_PROTECT_SPAWN) {
if (m.aggressionType == MonsterType.AGGRESSIONTYPE_PROTECT_SPAWN) {
if (a.area.contains(playerPosition)) return true;
} else if (m.aggressionType == Monster.AGGRESSIONTYPE_HELP_OTHERS) {
} else if (m.aggressionType == MonsterType.AGGRESSIONTYPE_HELP_OTHERS) {
for (Monster o : a.monsters) {
if (o == m) continue;
if (o.rectPosition.isAdjacentTo(playerPosition)) return true;

View File

@@ -8,6 +8,7 @@ import com.gpl.rpg.AndorsTrail.model.ability.SkillCollection;
import com.gpl.rpg.AndorsTrail.model.actor.Monster;
import com.gpl.rpg.AndorsTrail.model.map.LayeredTileMap;
import com.gpl.rpg.AndorsTrail.model.map.MapObject;
import com.gpl.rpg.AndorsTrail.model.actor.MonsterType;
import com.gpl.rpg.AndorsTrail.model.map.MonsterSpawnArea;
import com.gpl.rpg.AndorsTrail.model.map.PredefinedMap;
import com.gpl.rpg.AndorsTrail.util.Coord;
@@ -102,7 +103,7 @@ public final class MonsterMovementController implements EvaluateWalkable {
}
private void determineMonsterNextPosition(Monster m, MonsterSpawnArea area, Coord playerPosition) {
if (m.aggressionType == Monster.AGGRESSIONTYPE_PROTECT_SPAWN) {
if (m.aggressionType == MonsterType.AGGRESSIONTYPE_PROTECT_SPAWN) {
if (area.area.contains(playerPosition)) {
if (findPathFor(m, playerPosition)) return;
}

View File

@@ -24,10 +24,7 @@ public final class Monster extends Actor {
private boolean forceAggressive = false;
private ItemContainer shopItems = null;
public final int aggressionType = AGGRESSIONTYPE_PROTECT_SPAWN;
public static final int AGGRESSIONTYPE_NONE = 0;
public static final int AGGRESSIONTYPE_HELP_OTHERS = 1; // Will move to help if the player attacks some other monster in the same spawn.
public static final int AGGRESSIONTYPE_PROTECT_SPAWN = 2; // Will move to attack if the player stands inside the spawn.
public final int aggressionType;
private final MonsterType monsterType;
@@ -52,6 +49,7 @@ public final class Monster extends Actor {
this.criticalMultiplier = monsterType.criticalMultiplier;
if (monsterType.damagePotential != null) this.damagePotential.set(monsterType.damagePotential);
else this.damagePotential.set(0, 0);
this.aggressionType = monsterType.aggressionType;
this.blockChance = monsterType.blockChance;
this.damageResistance = monsterType.damageResistance;
this.onHitEffects = monsterType.onHitEffects;
@@ -148,6 +146,7 @@ public final class Monster extends Actor {
this.shopItems = new ItemContainer(src, world, fileversion);
}
}
this.aggressionType = monsterType.aggressionType;
}
public void writeToParcel(DataOutputStream dest, int flags) throws IOException {

View File

@@ -25,6 +25,8 @@ public final class MonsterType {
public final boolean isUnique; // Unique monsters are not respawned.
public final String faction;
public final int monsterClass;
public final int aggressionType;
public final Size tileSize;
public final int iconID;
public final int maxAP;
@@ -84,6 +86,30 @@ public final class MonsterType {
this.blockChance = blockChance;
this.damageResistance = damageResistance;
this.onHitEffects = onHitEffects;
this.aggressionType = getAggressionType(monsterClass);
}
public static final int AGGRESSIONTYPE_NONE = 0;
public static final int AGGRESSIONTYPE_HELP_OTHERS = 1; // Will move to help if the player attacks some other monster in the same spawn.
public static final int AGGRESSIONTYPE_PROTECT_SPAWN = 2; // Will move to attack if the player stands inside the spawn.
private static int getAggressionType(int monsterClass) {
switch (monsterClass) {
case MONSTERCLASS_CONSTRUCT:
case MONSTERCLASS_GIANT:
case MONSTERCLASS_GHOST:
return AGGRESSIONTYPE_NONE;
case MONSTERCLASS_DEMON:
case MONSTERCLASS_ANIMAL:
case MONSTERCLASS_REPTILE:
case MONSTERCLASS_INSECT:
return AGGRESSIONTYPE_PROTECT_SPAWN;
case MONSTERCLASS_UNDEAD:
case MONSTERCLASS_HUMANOID:
return AGGRESSIONTYPE_HELP_OTHERS;
default:
return AGGRESSIONTYPE_NONE;
}
}
public boolean isImmuneToCriticalHits() {