v0.9.4: teleportation and warping traps now trigger in a 3x3 AOE
This commit is contained in:
parent
bac067163f
commit
21de6d3886
|
@ -104,7 +104,7 @@ levels.traps.summoningtrap.name=summoning trap
|
|||
levels.traps.summoningtrap.desc=Triggering this trap will summon a number of this area's monsters to this location.
|
||||
|
||||
levels.traps.teleportationtrap.name=teleportation trap
|
||||
levels.traps.teleportationtrap.desc=Whatever triggers this trap will be teleported to some other location on this floor.
|
||||
levels.traps.teleportationtrap.desc=Whenever this trap is triggered, everything around it will be teleported to random locations on this floor.
|
||||
|
||||
levels.traps.tengudarttrap.desc=Tengu has clearly been preparing for a fight. This trap will activate a hidden dart blower which will shoot a poison dart at the nearest thing that isn't Tengu.\n\nThe trap is so well made that the trigger mechanism is impossible to detect without magical aid. However the trap is visible for a moment when it is being set.
|
||||
|
||||
|
@ -117,7 +117,7 @@ levels.traps.corrosiontrap.name=corrosive gas trap
|
|||
levels.traps.corrosiontrap.desc=Triggering this trap will set a cloud of deadly acidic gas loose within the immediate area.
|
||||
|
||||
levels.traps.warpingtrap.name=warping trap
|
||||
levels.traps.warpingtrap.desc=Whatever triggers this trap will be warped to some other location on this floor, and lose its knowledge of the floor's layout!
|
||||
levels.traps.warpingtrap.desc=This trap is similar to a teleportation trap, but will also cause the hero to lose their knowledge of the floor's layout!
|
||||
|
||||
levels.traps.weakeningtrap.name=weakening trap
|
||||
levels.traps.weakeningtrap.desc=Dark magic in this trap sucks the energy out of anything that comes into contact with it. Powerful enemies may resist the effect, however.
|
||||
|
|
|
@ -64,31 +64,36 @@ public class ScrollOfTeleportation extends Scroll {
|
|||
}
|
||||
}
|
||||
|
||||
public static void teleportToLocation(Hero hero, int pos){
|
||||
public static boolean teleportToLocation(Char ch, int pos){
|
||||
PathFinder.buildDistanceMap(pos, BArray.or(Dungeon.level.passable, Dungeon.level.avoid, null));
|
||||
if (PathFinder.distance[hero.pos] == Integer.MAX_VALUE
|
||||
if (PathFinder.distance[ch.pos] == Integer.MAX_VALUE
|
||||
|| (!Dungeon.level.passable[pos] && !Dungeon.level.avoid[pos])
|
||||
|| Actor.findChar(pos) != null){
|
||||
GLog.w( Messages.get(ScrollOfTeleportation.class, "cant_reach") );
|
||||
return;
|
||||
if (ch == Dungeon.hero){
|
||||
GLog.w( Messages.get(ScrollOfTeleportation.class, "cant_reach") );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
appear( hero, pos );
|
||||
Dungeon.level.occupyCell(hero );
|
||||
Dungeon.observe();
|
||||
GameScene.updateFog();
|
||||
appear( ch, pos );
|
||||
Dungeon.level.occupyCell( ch );
|
||||
if (ch == Dungeon.hero) {
|
||||
Dungeon.observe();
|
||||
GameScene.updateFog();
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public static void teleportHero( Hero hero ) {
|
||||
teleportChar( hero );
|
||||
public static boolean teleportHero( Hero hero ) {
|
||||
return teleportChar( hero );
|
||||
}
|
||||
|
||||
public static void teleportChar( Char ch ) {
|
||||
public static boolean teleportChar( Char ch ) {
|
||||
|
||||
if (Dungeon.bossLevel()){
|
||||
GLog.w( Messages.get(ScrollOfTeleportation.class, "no_tele") );
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
int count = 20;
|
||||
|
@ -103,6 +108,7 @@ public class ScrollOfTeleportation extends Scroll {
|
|||
if (pos == -1) {
|
||||
|
||||
GLog.w( Messages.get(ScrollOfTeleportation.class, "no_tele") );
|
||||
return false;
|
||||
|
||||
} else {
|
||||
|
||||
|
@ -116,6 +122,7 @@ public class ScrollOfTeleportation extends Scroll {
|
|||
GameScene.updateFog();
|
||||
Dungeon.hero.interrupt();
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTeleportat
|
|||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
||||
import com.watabou.noosa.audio.Sample;
|
||||
import com.watabou.utils.PathFinder;
|
||||
|
||||
public class TeleportationTrap extends Trap {
|
||||
|
||||
|
@ -46,52 +47,29 @@ public class TeleportationTrap extends Trap {
|
|||
@Override
|
||||
public void activate() {
|
||||
|
||||
CellEmitter.get(pos).start(Speck.factory(Speck.LIGHT), 0.2f, 3);
|
||||
Sample.INSTANCE.play( Assets.Sounds.TELEPORT );
|
||||
|
||||
Char ch = Actor.findChar( pos);
|
||||
if (ch != null && !ch.flying) {
|
||||
if (ch instanceof Hero) {
|
||||
ScrollOfTeleportation.teleportHero((Hero) ch);
|
||||
} else {
|
||||
int count = 20;
|
||||
int pos;
|
||||
do {
|
||||
pos = Dungeon.level.randomRespawnCell( ch );
|
||||
if (count-- <= 0) {
|
||||
break;
|
||||
}
|
||||
} while (pos == -1 || Dungeon.level.secret[pos]);
|
||||
|
||||
if (pos == -1 || Dungeon.bossLevel()) {
|
||||
|
||||
GLog.w(Messages.get(ScrollOfTeleportation.class, "no_tele"));
|
||||
|
||||
} else {
|
||||
|
||||
ch.pos = pos;
|
||||
for (int i : PathFinder.NEIGHBOURS9){
|
||||
Char ch = Actor.findChar(pos + i);
|
||||
if (ch != null){
|
||||
if (ScrollOfTeleportation.teleportChar(ch)) {
|
||||
if (ch instanceof Mob && ((Mob) ch).state == ((Mob) ch).HUNTING) {
|
||||
((Mob) ch).state = ((Mob) ch).WANDERING;
|
||||
}
|
||||
ch.sprite.place(ch.pos);
|
||||
ch.sprite.visible = Dungeon.level.heroFOV[pos];
|
||||
|
||||
}
|
||||
}
|
||||
Heap heap = Dungeon.level.heaps.get(pos + i);
|
||||
if (heap != null){
|
||||
int cell = Dungeon.level.randomRespawnCell( null );
|
||||
|
||||
Item item = heap.pickUp();
|
||||
|
||||
if (cell != -1) {
|
||||
Heap dropped = Dungeon.level.drop( item, cell );
|
||||
dropped.type = heap.type;
|
||||
dropped.sprite.view( dropped );
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Heap heap = Dungeon.level.heaps.get(pos);
|
||||
|
||||
if (heap != null){
|
||||
int cell = Dungeon.level.randomRespawnCell( null );
|
||||
|
||||
Item item = heap.pickUp();
|
||||
|
||||
if (cell != -1) {
|
||||
Heap dropped = Dungeon.level.drop( item, cell );
|
||||
dropped.type = heap.type;
|
||||
dropped.sprite.view( dropped );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ import com.shatteredpixel.shatteredpixeldungeon.utils.BArray;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
||||
import com.watabou.noosa.audio.Sample;
|
||||
|
||||
public class WarpingTrap extends Trap {
|
||||
public class WarpingTrap extends TeleportationTrap {
|
||||
|
||||
{
|
||||
color = TEAL;
|
||||
|
@ -47,56 +47,15 @@ public class WarpingTrap extends Trap {
|
|||
|
||||
@Override
|
||||
public void activate() {
|
||||
CellEmitter.get(pos).start(Speck.factory(Speck.LIGHT), 0.2f, 3);
|
||||
Sample.INSTANCE.play(Assets.Sounds.TELEPORT);
|
||||
|
||||
Char ch = Actor.findChar(pos);
|
||||
if (ch != null && !ch.flying) {
|
||||
if (ch instanceof Hero) {
|
||||
ScrollOfTeleportation.teleportHero((Hero) ch);
|
||||
BArray.setFalse(Dungeon.level.visited);
|
||||
BArray.setFalse(Dungeon.level.mapped);
|
||||
GameScene.updateFog();
|
||||
Dungeon.observe();
|
||||
|
||||
} else {
|
||||
int count = 20;
|
||||
int pos;
|
||||
do {
|
||||
pos = Dungeon.level.randomRespawnCell( ch );
|
||||
if (count-- <= 0) {
|
||||
break;
|
||||
}
|
||||
} while (pos == -1 || Dungeon.level.secret[pos]);
|
||||
|
||||
if (pos == -1 || Dungeon.bossLevel()) {
|
||||
|
||||
GLog.w(Messages.get(ScrollOfTeleportation.class, "no_tele"));
|
||||
|
||||
} else {
|
||||
|
||||
ch.pos = pos;
|
||||
if (ch instanceof Mob && ((Mob) ch).state == ((Mob) ch).HUNTING) {
|
||||
((Mob) ch).state = ((Mob) ch).WANDERING;
|
||||
}
|
||||
ch.sprite.place(ch.pos);
|
||||
ch.sprite.visible = Dungeon.level.heroFOV[pos];
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Heap heap = Dungeon.level.heaps.get(pos);
|
||||
|
||||
if (heap != null){
|
||||
int cell = Dungeon.level.randomRespawnCell( null );
|
||||
|
||||
Item item = heap.pickUp();
|
||||
|
||||
if (cell != -1) {
|
||||
Dungeon.level.drop( item, cell );
|
||||
}
|
||||
if (Dungeon.level.distance(Dungeon.hero.pos, pos) <= 1){
|
||||
BArray.setFalse(Dungeon.level.visited);
|
||||
BArray.setFalse(Dungeon.level.mapped);
|
||||
}
|
||||
|
||||
super.activate();
|
||||
|
||||
GameScene.updateFog(); //just in case hero wasn't moved
|
||||
Dungeon.observe();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user