v0.3.3: added char properties, starting with IMMOVABLE implementation

This commit is contained in:
Evan Debenham 2015-12-16 04:47:34 -05:00
parent 30404257df
commit e09f40378d
12 changed files with 32 additions and 16 deletions

View File

@ -447,4 +447,16 @@ public abstract class Char extends Actor {
public HashSet<Class<?>> immunities() { public HashSet<Class<?>> immunities() {
return EMPTY; return EMPTY;
} }
protected HashSet<Property> properties = new HashSet<>();
public HashSet<Property> properties() { return properties; }
public enum Property{
BOSS,
MINIBOSS,
UNDEAD,
EVIL,
IMMOVABLE
}
} }

View File

@ -82,7 +82,7 @@ public class Guard extends Mob {
} }
private boolean chain(int target){ private boolean chain(int target){
if (chainsUsed) if (chainsUsed || enemy.properties().contains(Property.IMMOVABLE))
return false; return false;
Ballistica chain = new Ballistica(pos, target, Ballistica.PROJECTILE); Ballistica chain = new Ballistica(pos, target, Ballistica.PROJECTILE);

View File

@ -43,6 +43,8 @@ public class RotHeart extends Mob {
EXP = 4; EXP = 4;
state = PASSIVE; state = PASSIVE;
properties.add(Property.IMMOVABLE);
} }
@Override @Override

View File

@ -49,6 +49,8 @@ public class RotLasher extends Mob {
lootChance = 1f; lootChance = 1f;
state = WANDERING = new Waiting(); state = WANDERING = new Waiting();
properties.add(Property.IMMOVABLE);
} }
@Override @Override

View File

@ -70,6 +70,8 @@ public class Yog extends Mob {
EXP = 50; EXP = 50;
state = PASSIVE; state = PASSIVE;
properties.add(Property.IMMOVABLE);
} }
private static final String TXT_DESC = private static final String TXT_DESC =

View File

@ -40,18 +40,13 @@ public class Shopkeeper extends NPC {
{ {
name = "shopkeeper"; name = "shopkeeper";
spriteClass = ShopkeeperSprite.class; spriteClass = ShopkeeperSprite.class;
properties.add(Property.IMMOVABLE);
} }
@Override @Override
protected boolean act() { protected boolean act() {
if (startPos == -1) startPos = pos;
if (startPos != pos){
flee();
return true;
}
throwItem(); throwItem();
sprite.turnTo( pos, Dungeon.hero.pos ); sprite.turnTo( pos, Dungeon.hero.pos );

View File

@ -39,7 +39,9 @@ public class Bounce extends Glyph {
int level = Math.max( 0, armor.level() ); int level = Math.max( 0, armor.level() );
if (Level.adjacent( attacker.pos, defender.pos ) && Random.Int( level + 5) >= 4) { if (Level.adjacent( attacker.pos, defender.pos )
&& !defender.properties().contains(Char.Property.IMMOVABLE)
&& Random.Int( level + 5) >= 4) {
for (int i=0; i < Level.NEIGHBOURS8.length; i++) { for (int i=0; i < Level.NEIGHBOURS8.length; i++) {
int ofs = Level.NEIGHBOURS8[i]; int ofs = Level.NEIGHBOURS8[i];

View File

@ -110,9 +110,12 @@ public class EtherealChains extends Artifact {
final int newMobPos = newPos; final int newMobPos = newPos;
final Char affected = Actor.findChar( chain.collisionPos ); final Char affected = Actor.findChar( chain.collisionPos );
int chargeUse = Level.distance(affected.pos, newMobPos); int chargeUse = Level.distance(affected.pos, newMobPos);
if (chargeUse > charge){ if (chargeUse > charge) {
GLog.w("Your chains do not have enough charge."); GLog.w("Your chains do not have enough charge.");
return; return;
} else if (affected.properties().contains(Char.Property.IMMOVABLE)) {
GLog.w("Your chains cannot pull that target");
return;
} else { } else {
charge -= chargeUse; charge -= chargeUse;
updateQuickslot(); updateQuickslot();

View File

@ -241,9 +241,7 @@ public class LloydsBeacon extends Artifact {
GLog.w(ScrollOfTeleportation.TXT_NO_TELEPORT); GLog.w(ScrollOfTeleportation.TXT_NO_TELEPORT);
//FIXME: sloppy, fix when adding mob properties } else if (ch.properties().contains(Char.Property.IMMOVABLE)) {
} else if (ch instanceof RotLasher || ch instanceof RotHeart
|| ch instanceof Shopkeeper || ch instanceof Wandmaker) {
GLog.w("The teleportation magic fails."); GLog.w("The teleportation magic fails.");

View File

@ -155,7 +155,7 @@ public class CursedWand {
cursedFX(user, bolt, new Callback() { cursedFX(user, bolt, new Callback() {
public void call() { public void call() {
Char ch = Actor.findChar( bolt.collisionPos ); Char ch = Actor.findChar( bolt.collisionPos );
if (ch != null) { if (ch != null && !ch.properties().contains(Char.Property.IMMOVABLE)) {
int count = 10; int count = 10;
int pos; int pos;
do { do {

View File

@ -112,7 +112,7 @@ public class WandOfBlastWave extends Wand {
if ((ch instanceof King) || (ch instanceof Golem) || (ch instanceof Yog.RottingFist)) if ((ch instanceof King) || (ch instanceof Golem) || (ch instanceof Yog.RottingFist))
dist /= 2; dist /= 2;
if (dist == 0 || ch instanceof Yog || ch instanceof RotLasher || ch instanceof RotHeart) return; if (dist == 0 || ch.properties().contains(Char.Property.IMMOVABLE)) return;
if (Actor.findChar(trajectory.path.get(dist)) != null){ if (Actor.findChar(trajectory.path.get(dist)) != null){
dist--; dist--;

View File

@ -51,7 +51,7 @@ public class Fadeleaf extends Plant {
ScrollOfTeleportation.teleportHero( (Hero)ch ); ScrollOfTeleportation.teleportHero( (Hero)ch );
((Hero)ch).curAction = null; ((Hero)ch).curAction = null;
} else if (ch instanceof Mob) { } else if (ch instanceof Mob && !ch.properties().contains(Char.Property.IMMOVABLE)) {
int count = 10; int count = 10;
int newPos; int newPos;