v0.7.1a: traps now check if chars on them are flying when appropriate

This commit is contained in:
Evan Debenham
2018-12-20 21:19:29 -05:00
parent 51be374f75
commit 5b6bacc627
8 changed files with 66 additions and 60 deletions
@@ -65,7 +65,7 @@ public class CursingTrap extends Trap {
} }
} }
if (Dungeon.hero.pos == pos){ if (Dungeon.hero.pos == pos && !Dungeon.hero.flying){
curse(Dungeon.hero); curse(Dungeon.hero);
} }
} }
@@ -61,7 +61,7 @@ public class DisarmingTrap extends Trap{
} }
} }
if (Dungeon.hero.pos == pos){ if (Dungeon.hero.pos == pos && !Dungeon.hero.flying){
Hero hero = Dungeon.hero; Hero hero = Dungeon.hero;
KindOfWeapon weapon = hero.belongings.weapon; KindOfWeapon weapon = hero.belongings.weapon;
@@ -56,7 +56,7 @@ public class GrippingTrap extends Trap {
Char c = Actor.findChar( pos ); Char c = Actor.findChar( pos );
if (c != null) { if (c != null && !c.flying) {
int damage = Math.max( 0, (2 + Dungeon.depth) - c.drRoll() ); int damage = Math.max( 0, (2 + Dungeon.depth) - c.drRoll() );
Buff.affect( c, Bleeding.class ).set( damage ); Buff.affect( c, Bleeding.class ).set( damage );
Buff.prolong( c, Cripple.class, Cripple.DURATION); Buff.prolong( c, Cripple.class, Cripple.DURATION);
@@ -38,7 +38,7 @@ public class OozeTrap extends Trap {
public void activate() { public void activate() {
Char ch = Actor.findChar( pos ); Char ch = Actor.findChar( pos );
if (ch != null){ if (ch != null && !ch.flying){
Buff.affect(ch, Ooze.class).set( 20f ); Buff.affect(ch, Ooze.class).set( 20f );
Splash.at( pos, 0x000000, 5); Splash.at( pos, 0x000000, 5);
} }
@@ -52,10 +52,12 @@ public class PitfallTrap extends Trap {
Char ch = Actor.findChar( pos ); Char ch = Actor.findChar( pos );
if (ch == Dungeon.hero){ if (ch != null && !ch.flying) {
Chasm.heroFall( pos ); if (ch == Dungeon.hero) {
} else if (ch != null){ Chasm.heroFall(pos);
Chasm.mobFall((Mob)ch); } else {
Chasm.mobFall((Mob) ch);
}
} }
} }
@@ -50,9 +50,10 @@ public class TeleportationTrap extends Trap {
Sample.INSTANCE.play( Assets.SND_TELEPORT ); Sample.INSTANCE.play( Assets.SND_TELEPORT );
Char ch = Actor.findChar( pos); Char ch = Actor.findChar( pos);
if (ch instanceof Hero){ if (ch != null && !ch.flying) {
ScrollOfTeleportation.teleportHero( (Hero)ch); if (ch instanceof Hero) {
} else if (ch != null){ ScrollOfTeleportation.teleportHero((Hero) ch);
} else {
int count = 10; int count = 10;
int pos; int pos;
do { do {
@@ -64,12 +65,12 @@ public class TeleportationTrap extends Trap {
if (pos == -1 || Dungeon.bossLevel()) { if (pos == -1 || Dungeon.bossLevel()) {
GLog.w( Messages.get(ScrollOfTeleportation.class, "no_tele") ); GLog.w(Messages.get(ScrollOfTeleportation.class, "no_tele"));
} else { } else {
ch.pos = pos; ch.pos = pos;
if (ch instanceof Mob && ((Mob) ch).state == ((Mob) ch).HUNTING){ if (ch instanceof Mob && ((Mob) ch).state == ((Mob) ch).HUNTING) {
((Mob) ch).state = ((Mob) ch).WANDERING; ((Mob) ch).state = ((Mob) ch).WANDERING;
} }
ch.sprite.place(ch.pos); ch.sprite.place(ch.pos);
@@ -77,6 +78,7 @@ public class TeleportationTrap extends Trap {
} }
} }
}
Heap heap = Dungeon.level.heaps.get(pos); Heap heap = Dungeon.level.heaps.get(pos);
@@ -48,17 +48,18 @@ public class WarpingTrap extends Trap {
@Override @Override
public void activate() { public void activate() {
CellEmitter.get(pos).start(Speck.factory(Speck.LIGHT), 0.2f, 3); CellEmitter.get(pos).start(Speck.factory(Speck.LIGHT), 0.2f, 3);
Sample.INSTANCE.play( Assets.SND_TELEPORT ); Sample.INSTANCE.play(Assets.SND_TELEPORT);
Char ch = Actor.findChar( pos); Char ch = Actor.findChar(pos);
if (ch instanceof Hero){ if (ch != null && !ch.flying) {
ScrollOfTeleportation.teleportHero( (Hero)ch); if (ch instanceof Hero) {
ScrollOfTeleportation.teleportHero((Hero) ch);
BArray.setFalse(Dungeon.level.visited); BArray.setFalse(Dungeon.level.visited);
BArray.setFalse(Dungeon.level.mapped); BArray.setFalse(Dungeon.level.mapped);
GameScene.updateFog(); GameScene.updateFog();
Dungeon.observe(); Dungeon.observe();
} else if (ch != null){ } else {
int count = 10; int count = 10;
int pos; int pos;
do { do {
@@ -70,12 +71,12 @@ public class WarpingTrap extends Trap {
if (pos == -1 || Dungeon.bossLevel()) { if (pos == -1 || Dungeon.bossLevel()) {
GLog.w( Messages.get(ScrollOfTeleportation.class, "no_tele") ); GLog.w(Messages.get(ScrollOfTeleportation.class, "no_tele"));
} else { } else {
ch.pos = pos; ch.pos = pos;
if (ch instanceof Mob && ((Mob) ch).state == ((Mob) ch).HUNTING){ if (ch instanceof Mob && ((Mob) ch).state == ((Mob) ch).HUNTING) {
((Mob) ch).state = ((Mob) ch).WANDERING; ((Mob) ch).state = ((Mob) ch).WANDERING;
} }
ch.sprite.place(ch.pos); ch.sprite.place(ch.pos);
@@ -83,6 +84,7 @@ public class WarpingTrap extends Trap {
} }
} }
}
Heap heap = Dungeon.level.heaps.get(pos); Heap heap = Dungeon.level.heaps.get(pos);
@@ -43,7 +43,7 @@ public class WeakeningTrap extends Trap{
} }
Char ch = Actor.findChar( pos ); Char ch = Actor.findChar( pos );
if (ch == Dungeon.hero){ if (ch != null && !ch.flying){
Buff.prolong( ch, Weakness.class, Weakness.DURATION*2f ); Buff.prolong( ch, Weakness.class, Weakness.DURATION*2f );
} }
} }