v0.6.3: improved actor priority logic
This commit is contained in:
parent
bfa96703aa
commit
2009095a66
|
@ -42,9 +42,18 @@ public abstract class Actor implements Bundlable {
|
|||
|
||||
private int id = 0;
|
||||
|
||||
//used to determine what order actors act in.
|
||||
//hero should always act on 0, therefore negative is before hero, positive is after hero
|
||||
protected int actPriority = Integer.MAX_VALUE;
|
||||
//default priority values for general actor categories
|
||||
//note that some specific actors pick more specific values
|
||||
//e.g. a buff acting after all normal buffs might have priority BUFF_PRIO + 1
|
||||
protected final int VFX_PRIO = 100; //visual effects take priority
|
||||
protected final int HERO_PRIO = 0; //positive priority is before hero, negative after
|
||||
protected final int BLOB_PRIO = -10; //blobs act after hero, before mobs
|
||||
protected final int MOB_PRIO = -20; //mobs act between buffs and blobd
|
||||
protected final int BUFF_PRIO = -30; //buffs act last in a turn
|
||||
private final int DEFAULT = -100; //if no priority is given, act after all else
|
||||
|
||||
//used to determine what order actors act in if their time is equal. Higher values act earlier.
|
||||
protected int actPriority = DEFAULT;
|
||||
|
||||
protected abstract boolean act();
|
||||
|
||||
|
@ -187,7 +196,7 @@ public abstract class Actor implements Bundlable {
|
|||
|
||||
//some actors will always go before others if time is equal.
|
||||
if (actor.time < now ||
|
||||
actor.time == now && (current == null || actor.actPriority < current.actPriority)) {
|
||||
actor.time == now && (current == null || actor.actPriority > current.actPriority)) {
|
||||
now = actor.time;
|
||||
current = actor;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ import com.watabou.utils.Rect;
|
|||
public class Blob extends Actor {
|
||||
|
||||
{
|
||||
actPriority = 1; //take priority over mobs, but not the hero
|
||||
actPriority = BLOB_PRIO;
|
||||
}
|
||||
|
||||
public int volume = 0;
|
||||
|
|
|
@ -34,7 +34,7 @@ public class GooWarn extends Blob {
|
|||
|
||||
{
|
||||
//this one needs to act after the Goo
|
||||
actPriority = 3;
|
||||
actPriority = MOB_PRIO - 1;
|
||||
}
|
||||
|
||||
protected int pos;
|
||||
|
|
|
@ -35,7 +35,7 @@ public class Buff extends Actor {
|
|||
public Char target;
|
||||
|
||||
{
|
||||
actPriority = 3; //low priority, at the end of a turn
|
||||
actPriority = BUFF_PRIO; //low priority, towards the end of a turn
|
||||
}
|
||||
|
||||
//determines how the buff is announced when it is shown.
|
||||
|
|
|
@ -34,9 +34,9 @@ public class Healing extends Buff {
|
|||
private int flatHealPerTick;
|
||||
|
||||
{
|
||||
//unlike other buffs, this one acts after the hero and takes priority against enemies
|
||||
//healing is much more useful if you get some of it off before enemies attack
|
||||
actPriority = 1;
|
||||
//unlike other buffs, this one acts after the hero and takes priority against other effects
|
||||
//healing is much more useful if you get some of it off before taking damage
|
||||
actPriority = HERO_PRIO - 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -48,7 +48,7 @@ public class Preparation extends Buff implements ActionIndicator.Action {
|
|||
|
||||
{
|
||||
//always acts after other buffs, so invisibility effects can process first
|
||||
actPriority = 4;
|
||||
actPriority = BUFF_PRIO - 1;
|
||||
}
|
||||
|
||||
public enum AttackLevel{
|
||||
|
|
|
@ -130,7 +130,7 @@ import java.util.Collections;
|
|||
public class Hero extends Char {
|
||||
|
||||
{
|
||||
actPriority = 0; //acts at priority 0, baseline for the rest of behaviour.
|
||||
actPriority = HERO_PRIO;
|
||||
|
||||
alignment = Alignment.ALLY;
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ public abstract class Mob extends Char {
|
|||
|
||||
{
|
||||
name = Messages.get(this, "name");
|
||||
actPriority = 2; //hero gets priority over mobs.
|
||||
actPriority = MOB_PRIO;
|
||||
|
||||
alignment = Alignment.ENEMY;
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ public class Pushing extends Actor {
|
|||
private Callback callback;
|
||||
|
||||
{
|
||||
actPriority = Integer.MIN_VALUE; //it's a visual effect, gets priority no matter what
|
||||
actPriority = VFX_PRIO;
|
||||
}
|
||||
|
||||
public Pushing( Char ch, int from, int to ) {
|
||||
|
|
|
@ -218,7 +218,7 @@ public class Bomb extends Item {
|
|||
public static class Fuse extends Actor{
|
||||
|
||||
{
|
||||
actPriority = 3; //as if it were a buff
|
||||
actPriority = BUFF_PRIO; //as if it were a buff
|
||||
}
|
||||
|
||||
private Bomb bomb;
|
||||
|
|
|
@ -383,8 +383,8 @@ public class DriedRose extends Artifact {
|
|||
|
||||
state = HUNTING;
|
||||
|
||||
//after hero, but before mobs
|
||||
actPriority = 1;
|
||||
//before other mobs
|
||||
actPriority = MOB_PRIO + 1;
|
||||
}
|
||||
|
||||
private DriedRose rose = null;
|
||||
|
|
|
@ -107,7 +107,7 @@ public class WandOfFrost extends DamageWand {
|
|||
if (chill != null && Random.IntRange(2, 10) > chill.cooldown()){
|
||||
//need to delay this through an actor so that the freezing isn't broken by taking damage from the staff hit.
|
||||
new FlavourBuff(){
|
||||
{actPriority = Integer.MIN_VALUE;}
|
||||
{actPriority = VFX_PRIO;}
|
||||
public boolean act() {
|
||||
Buff.affect(target, Frost.class, Frost.duration(target) * Random.Float(1f, 2f));
|
||||
return super.act();
|
||||
|
|
|
@ -494,7 +494,7 @@ public abstract class Level implements Bundlable {
|
|||
return new Actor() {
|
||||
|
||||
{
|
||||
actPriority = 1; //as if it were a buff.
|
||||
actPriority = BUFF_PRIO; //as if it were a buff.
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -46,7 +46,7 @@ public class FlockTrap extends Trap {
|
|||
//use an actor as we want to put this on a slight delay so all chars get a chance to act this turn first.
|
||||
Actor.add(new Actor() {
|
||||
|
||||
{ actPriority = 3; }
|
||||
{ actPriority = BUFF_PRIO; }
|
||||
|
||||
protected boolean act() {
|
||||
PathFinder.buildDistanceMap( pos, BArray.not( Dungeon.level.solid, null ), 2 );
|
||||
|
|
|
@ -82,7 +82,7 @@ public class GrimTrap extends Trap {
|
|||
|
||||
{
|
||||
//it's a visual effect, gets priority no matter what
|
||||
actPriority = Integer.MIN_VALUE;
|
||||
actPriority = VFX_PRIO;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -70,7 +70,7 @@ public class PoisonDartTrap extends Trap {
|
|||
|
||||
{
|
||||
//it's a visual effect, gets priority no matter what
|
||||
actPriority = Integer.MIN_VALUE;
|
||||
actPriority = VFX_PRIO;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -68,7 +68,7 @@ public class WornDartTrap extends Trap {
|
|||
|
||||
{
|
||||
//it's a visual effect, gets priority no matter what
|
||||
actPriority = Integer.MIN_VALUE;
|
||||
actPriority = VFX_PRIO;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue
Block a user