v0.6.3: overhauled how the game handles pressing tiles

This commit is contained in:
Evan Debenham 2017-12-23 04:20:07 -05:00
parent cc46684f52
commit acc9fd33d2
23 changed files with 79 additions and 122 deletions

View File

@ -448,6 +448,10 @@ public abstract class Char extends Actor {
if (this != Dungeon.hero) {
sprite.visible = Dungeon.level.heroFOV[pos];
}
if (!flying) {
Dungeon.level.press( pos, this );
}
}
public int distance( Char other ) {

View File

@ -27,7 +27,6 @@ import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
import com.shatteredpixel.shatteredpixeldungeon.effects.Pushing;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
@ -256,12 +255,7 @@ public class Combo extends Buff implements ActionIndicator.Action {
Actor.addDelayed( new Pushing( enemy, enemy.pos, newPos ), -1 );
enemy.pos = newPos;
// FIXME
if (enemy instanceof Mob) {
Dungeon.level.mobPress( (Mob)enemy );
} else {
Dungeon.level.press( newPos, enemy );
}
Dungeon.level.press( newPos, enemy );
}
break;

View File

@ -1424,13 +1424,11 @@ public class Hero extends Char {
super.move( step );
if (!flying) {
if (Dungeon.level.water[pos]) {
Sample.INSTANCE.play( Assets.SND_WATER, 1, 1, Random.Float( 0.8f, 1.25f ) );
} else {
Sample.INSTANCE.play( Assets.SND_STEP );
}
Dungeon.level.press(pos, this);
}
}

View File

@ -96,7 +96,7 @@ public class Guard extends Mob {
Actor.addDelayed(new Pushing(enemy, enemy.pos, newPosFinal, new Callback(){
public void call() {
enemy.pos = newPosFinal;
Dungeon.level.press(newPosFinal, enemy);
Dungeon.level.press(newPosFinal, enemy, true);
Cripple.prolong(enemy, Cripple.class, 4f);
if (enemy == Dungeon.hero) {
Dungeon.hero.interrupt();

View File

@ -127,12 +127,8 @@ public class Mimic extends Mob {
Actor.addDelayed( new Pushing( ch, ch.pos, newPos ), -1 );
ch.pos = newPos;
// FIXME
if (ch instanceof Mob) {
Dungeon.level.mobPress( (Mob)ch );
} else {
Dungeon.level.press( newPos, ch );
}
Dungeon.level.press( newPos, ch );
} else {
return null;
}

View File

@ -426,15 +426,6 @@ public abstract class Mob extends Char {
if (Dungeon.hero.buff(TimekeepersHourglass.timeFreeze.class) != null)
sprite.add( CharSprite.State.PARALYSED );
}
@Override
public void move( int step ) {
super.move( step );
if (!flying) {
Dungeon.level.mobPress( this );
}
}
protected float attackDelay() {
return 1f;

View File

@ -25,7 +25,6 @@ import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
import com.watabou.noosa.Game;
@ -77,18 +76,12 @@ public class Swap extends Actor {
ch2.pos = pos;
if (!ch1.flying) {
if (ch1 instanceof Mob) {
Dungeon.level.mobPress( (Mob)ch1 );
} else {
Dungeon.level.press( ch1.pos, ch1 );
}
Dungeon.level.press( ch1.pos, ch1 );
}
if (!ch2.flying) {
if (ch2 instanceof Mob) {
Dungeon.level.mobPress( (Mob)ch2 );
} else {
Dungeon.level.press( ch2.pos, ch2 );
}
Dungeon.level.press( ch2.pos, ch2 );
}
if (ch1 == Dungeon.hero || ch2 == Dungeon.hero) {

View File

@ -73,7 +73,7 @@ public class WarriorArmor extends ClassArmor {
@Override
public void call() {
curUser.move(dest);
Dungeon.level.press(dest, curUser);
Dungeon.level.press(dest, curUser, true);
Dungeon.observe();
GameScene.updateFog();

View File

@ -166,7 +166,7 @@ public class EtherealChains extends Artifact {
public void call() {
Actor.add(new Pushing(enemy, enemy.pos, pulledPos, new Callback() {
public void call() {
Dungeon.level.press(pulledPos, enemy);
Dungeon.level.press(pulledPos, enemy, true);
}
}));
enemy.pos = pulledPos;

View File

@ -298,7 +298,7 @@ public class TimekeepersHourglass extends Artifact {
private void triggerPresses(){
for (int cell : presses)
Dungeon.level.press(cell, null);
Dungeon.level.press(cell, null, true);
presses = new ArrayList<>();
}

View File

@ -193,7 +193,7 @@ public class Blandfruit extends Food {
potionAttrib instanceof PotionOfLevitation ||
potionAttrib instanceof PotionOfPurity) {
Dungeon.level.press( cell, null );
Dungeon.level.press( cell, null, true );
potionAttrib.shatter( cell );
} else {

View File

@ -220,7 +220,7 @@ public class Potion extends Item {
} else {
Dungeon.level.press( cell, null );
Dungeon.level.press( cell, null, true );
shatter( cell );
}

View File

@ -69,7 +69,7 @@ public class WandOfBlastWave extends DamageWand {
//presses all tiles in the AOE first
for (int i : PathFinder.NEIGHBOURS9){
Dungeon.level.press(bolt.collisionPos+i, Actor.findChar(bolt.collisionPos+i));
Dungeon.level.press(bolt.collisionPos+i, Actor.findChar(bolt.collisionPos+i), true);
}
//throws other chars around the center.
@ -138,7 +138,7 @@ public class WandOfBlastWave extends DamageWand {
ch.damage(Random.NormalIntRange((finalDist + 1) / 2, finalDist), this);
Paralysis.prolong(ch, Paralysis.class, Random.NormalIntRange((finalDist + 1) / 2, finalDist));
}
Dungeon.level.press(ch.pos, ch);
Dungeon.level.press(ch.pos, ch, true);
if (ch == Dungeon.hero){
Dungeon.observe();
}

View File

@ -179,7 +179,7 @@ public class WandOfCorruption extends Wand {
processSoulMark(ch, chargesPerCast());
} else {
Dungeon.level.press(bolt.collisionPos, null);
Dungeon.level.press(bolt.collisionPos, null, true);
}
}

View File

@ -87,7 +87,7 @@ public class WandOfFrost extends DamageWand {
Buff.prolong(ch, Chill.class, 2+level());
}
} else {
Dungeon.level.press(bolt.collisionPos, null);
Dungeon.level.press(bolt.collisionPos, null, true);
}
}

View File

@ -57,7 +57,7 @@ public class WandOfMagicMissile extends DamageWand {
ch.sprite.burst(0xFFFFFFFF, level() / 2 + 2);
} else {
Dungeon.level.press(bolt.collisionPos, null);
Dungeon.level.press(bolt.collisionPos, null, true);
}
}

View File

@ -60,7 +60,7 @@ public class WandOfVenom extends Wand {
}
if (Actor.findChar(bolt.collisionPos) == null){
Dungeon.level.press(bolt.collisionPos, null);
Dungeon.level.press(bolt.collisionPos, null, true);
}
}

View File

@ -695,7 +695,7 @@ public abstract class Level implements Bundlable {
}
if (Dungeon.level != null) {
press( cell, null );
press( cell, null, true );
}
return heap;
@ -767,7 +767,15 @@ public abstract class Level implements Bundlable {
return result;
}
public void press( int cell, Char ch ) {
//characters which are not the hero 'soft' press cells by default
public void press( int cell, Char ch){
press( cell, ch, ch == Dungeon.hero);
}
//a 'soft' press ignores hidden traps
//a 'hard' press triggers all things
//generally a 'hard' press should be forced is something is moving forcefully (e.g. thrown)
public void press( int cell, Char ch, boolean hard ) {
if (ch != null && pit[cell] && !ch.flying) {
if (ch == Dungeon.hero) {
@ -783,7 +791,12 @@ public abstract class Level implements Bundlable {
switch (map[cell]) {
case Terrain.SECRET_TRAP:
GLog.i( Messages.get(Level.class, "hidden_plate") );
if (hard) {
trap = traps.get( cell );
GLog.i(Messages.get(Level.class, "hidden_trap", trap.name));
}
break;
case Terrain.TRAP:
trap = traps.get( cell );
break;
@ -801,13 +814,16 @@ public abstract class Level implements Bundlable {
break;
}
TimekeepersHourglass.timeFreeze timeFreeze = Dungeon.hero.buff(TimekeepersHourglass.timeFreeze.class);
if (trap != null) {
TimekeepersHourglass.timeFreeze timeFreeze =
ch != null ? ch.buff(TimekeepersHourglass.timeFreeze.class) : null;
if (timeFreeze == null) {
if (ch == Dungeon.hero)
if (ch == Dungeon.hero) {
Dungeon.hero.interrupt();
}
trap.trigger();
@ -828,41 +844,6 @@ public abstract class Level implements Bundlable {
}
}
public void mobPress( Mob mob ) {
int cell = mob.pos;
if (pit[cell] && !mob.flying) {
Chasm.mobFall( mob );
return;
}
Trap trap = null;
switch (map[cell]) {
case Terrain.TRAP:
trap = traps.get( cell );
break;
case Terrain.DOOR:
Door.enter( cell );
break;
}
if (trap != null) {
trap.trigger();
}
Plant plant = plants.get( cell );
if (plant != null) {
plant.trigger();
}
if ( map[cell] == Terrain.HIGH_GRASS){
HighGrass.trample( this, cell, mob );
}
}
public void updateFieldOfView( Char c, boolean[] fieldOfView ) {
int cx = c.pos % width();

View File

@ -96,7 +96,7 @@ public class Chasm {
hero.sprite.burst( hero.sprite.blood(), 10 );
Camera.main.shake( 4, 0.2f );
Dungeon.level.press( hero.pos, hero );
Dungeon.level.press( hero.pos, hero, true );
Buff.prolong( hero, Cripple.class, Cripple.DURATION );
//The lower the hero's HP, the more bleed and the less upfront damage.

View File

@ -58,7 +58,7 @@ public class FlockTrap extends Trap {
Sheep sheep = new Sheep();
sheep.lifespan = Random.NormalIntRange(3 + Dungeon.depth/4, 6 + Dungeon.depth/2 );
sheep.pos = i;
Dungeon.level.mobPress(sheep);
Dungeon.level.press(sheep.pos, sheep);
GameScene.add(sheep);
CellEmitter.get(i).burst(Speck.factory(Speck.WOOL), 4);
}

View File

@ -87,7 +87,7 @@ public class SummoningTrap extends Trap {
for (Mob mob : mobs){
ScrollOfTeleportation.appear(mob, mob.pos);
//so hidden traps are triggered as well
Dungeon.level.press(mob.pos, mob);
Dungeon.level.press(mob.pos, mob, true);
}
}

View File

@ -31,7 +31,7 @@ public class WndInfoTrap extends WndTitledMessage {
public WndInfoTrap(Trap trap) {
super(TerrainFeaturesTilemap.tile( trap.pos, Dungeon.level.map[trap.pos]),
trap.name,
Messages.titleCase(trap.name),
(!trap.active ? Messages.get(WndInfoTrap.class, "inactive") + "\n\n" : "") + trap.desc());
}

View File

@ -26,104 +26,104 @@ levels.rooms.special.weakfloorroom$hiddenwell.desc=You can just make out a well
###traps
levels.traps.alarmtrap.name=Alarm trap
levels.traps.alarmtrap.name=alarm trap
levels.traps.alarmtrap.alarm=The trap emits a piercing sound that echoes throughout the dungeon!
levels.traps.alarmtrap.desc=This trap seems to be tied to a loud alarm mechanism. Triggering it will likely alert everything on the level.
levels.traps.blazingtrap.name=Blazing trap
levels.traps.blazingtrap.name=blazing trap
levels.traps.blazingtrap.desc=Stepping on this trap will ignite a powerful chemical mixture, setting a wide area ablaze.
levels.traps.burningtrap.name=Burning trap
levels.traps.burningtrap.name=burning trap
levels.traps.burningtrap.desc=Stepping on this trap will ignite a chemical mixture, setting the surrounding area aflame.
levels.traps.chillingtrap.name=Chilling trap
levels.traps.chillingtrap.name=chilling trap
levels.traps.chillingtrap.desc=When activated, chemicals in this trap will rapidly freeze the air around its location.
levels.traps.confusiontrap.name=Confusion gas trap
levels.traps.confusiontrap.name=confusion gas trap
levels.traps.confusiontrap.desc=Triggering this trap will set a cloud of confusion gas loose within the immediate area.
levels.traps.cursingtrap.name=Cursing trap
levels.traps.cursingtrap.name=cursing trap
levels.traps.cursingtrap.curse=Your worn equipment becomes cursed!
levels.traps.cursingtrap.desc=This trap contains the same malevolent magic found in cursed equipment. Triggering it will curse some items in the immediate area.
levels.traps.disarmingtrap.name=Disarming trap
levels.traps.disarmingtrap.name=disarming trap
levels.traps.disarmingtrap.disarm=Your weapon is teleported away!
levels.traps.disarmingtrap.desc=This trap contains very specific teleportation magic, which will warp the weapon of its victim to some other location.
levels.traps.disintegrationtrap.name=Disintegration trap
levels.traps.disintegrationtrap.name=disintegration trap
levels.traps.disintegrationtrap.one=The trap disintegrates your %s!
levels.traps.disintegrationtrap.some=The trap disintegrates some of your %s!
levels.traps.disintegrationtrap.ondeath=You were killed by the disintegration trap...
levels.traps.disintegrationtrap.desc=When triggered, this trap will lance the nearest target with beams of disintegration, dealing significant damage and destroying items.\n\nThankfully the trigger mechanism isn't hidden.
levels.traps.distortiontrap.name=Distortion trap
levels.traps.distortiontrap.name=distortion trap
levels.traps.distortiontrap.desc=Built from strange magic of unknown origin, this trap will shift and morph the world around you.
levels.traps.explosivetrap.name=Explosive trap
levels.traps.explosivetrap.name=explosive trap
levels.traps.explosivetrap.desc=This trap contains some powdered explosive and a trigger mechanism. Activating it will cause an explosion in the immediate area.
levels.traps.flashingtrap.name=Flashing trap
levels.traps.flashingtrap.name=flashing trap
levels.traps.flashingtrap.desc=On activation, this trap will ignite a potent flashing powder stored within, temporarily blinding, crippling, and injuring its victim.\n\nThe trap must have a large store of powder, as it can activate many times without breaking.
levels.traps.flocktrap.name=Flock trap
levels.traps.flocktrap.name=flock trap
levels.traps.flocktrap.desc=Perhaps a joke from some amateur mage, triggering this trap will create a flock of magical sheep.
levels.traps.frosttrap.name=Frost trap
levels.traps.frosttrap.name=frost trap
levels.traps.frosttrap.desc=When activated, chemicals in this trap will rapidly freeze the air in a wide range around its location.
levels.traps.grimtrap.name=Grim trap
levels.traps.grimtrap.name=grim trap
levels.traps.grimtrap.ondeath=You were killed by the blast of a grim trap...
levels.traps.grimtrap.desc=Extremely powerful destructive magic is stored within this trap, enough to instantly kill all but the healthiest of heroes. Triggering it will send a ranged blast of lethal magic towards the nearest character.\n\nThankfully the trigger mechanism isn't hidden.
levels.traps.grippingtrap.name=Gripping trap
levels.traps.grippingtrap.name=gripping trap
levels.traps.grippingtrap.desc=This trap latches onto the feet of whoever trigger it, damaging them and slowing their movement.\n\nDue to its simple nature, this trap can activate many times without breaking.
levels.traps.guardiantrap.name=Guardian trap
levels.traps.guardiantrap.name=guardian trap
levels.traps.guardiantrap.alarm=The trap emits a piercing sound that echoes throughout the dungeon!
levels.traps.guardiantrap.desc=This trap is tied to a strange magical mechanism, which will summon guardians and alert all enemies on the floor.
levels.traps.guardiantrap$guardian.name=summoned guardian
levels.traps.guardiantrap$guardian.desc=This blue apparition seems to be a summoned echo of one of the dungeon's stone guardians.\n\nWhile the statue itself is almost incorporeal, the _%s,_ it's wielding, looks real.
levels.traps.oozetrap.name=Ooze trap
levels.traps.oozetrap.name=ooze trap
levels.traps.oozetrap.desc=This trap will splash out caustic ooze when activated, which will burn until it is washed away.
levels.traps.pitfalltrap.name=Pitfall trap
levels.traps.pitfalltrap.name=pitfall trap
levels.traps.pitfalltrap.desc=This pressure plate rests atop a fairly weak floor, and will likely collapse into a pit if it is pressed.
levels.traps.poisondarttrap.name=Poison dart trap
levels.traps.poisondarttrap.name=poison dart trap
levels.traps.poisondarttrap.desc=A small dart-blower must be hidden nearby, activating this trap will cause it to shoot a poisoned dart at the nearest target.\n\nThankfully the trigger mechanism isn't hidden.
levels.traps.rockfalltrap.name=Rockfall trap
levels.traps.rockfalltrap.name=rockfall trap
levels.traps.rockfalltrap.ondeath=You were crushed by the rockfall trap...
levels.traps.rockfalltrap.desc=This trap is connected to a series of loose rocks above, triggering it will cause them to come crashing down over the entire room!\n\nThankfully the trigger mechanism isn't hidden.
levels.traps.shockingtrap.name=Shocking trap
levels.traps.shockingtrap.name=shocking trap
levels.traps.shockingtrap.desc=A mechanism with a large amount of energy stored into it. Triggering this trap will discharge that energy into a field around it.
levels.traps.stormtrap.name=Storm trap
levels.traps.stormtrap.name=storm trap
levels.traps.stormtrap.desc=A mechanism with a massive amount of energy stored into it. Triggering this trap will discharge that energy into a large electrical storm.
levels.traps.summoningtrap.name=Summoning trap
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.name=teleportation trap
levels.traps.teleportationtrap.desc=Whatever triggers this trap will be teleported to some other location on this floor.
levels.traps.toxictrap.name=Toxic gas trap
levels.traps.toxictrap.name=toxic gas trap
levels.traps.toxictrap.desc=Triggering this trap will set a cloud of toxic gas loose within the surrounding area.
levels.traps.trap.rankings_desc=Killed by: %s
levels.traps.venomtrap.name=Venom gas trap
levels.traps.venomtrap.name=venom gas trap
levels.traps.venomtrap.desc=Triggering this trap will set a cloud of deadly venom gas loose within the immediate area.
levels.traps.warpingtrap.name=Warping trap
levels.traps.warpingtrap.name=warping trap
levels.traps.warpingtrap.desc=Whatever triggers this trap will be warped to some other location on this floor.
levels.traps.weakeningtrap.name=Weakening trap
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.
levels.traps.worndarttrap.name=Worn dart trap
levels.traps.worndarttrap.name=worn dart trap
levels.traps.worndarttrap.desc=A small dart-blower must be hidden nearby, activating this trap will cause it to shoot at the nearest target.\n\nDue to it's age it's not very harmful though, it isn't even hidden...
@ -155,7 +155,7 @@ levels.hallslevel.water_desc=It looks like lava, but it's cold and probably safe
levels.hallslevel.statue_desc=The pillar is made of real humanoid skulls. Awesome.
levels.hallslevel.bookshelf_desc=Books in ancient languages smoulder in the bookshelf.
levels.level.hidden_plate=A hidden pressure plate clicks!
levels.level.hidden_trap=A hidden %s activates!
levels.level.chasm_name=Chasm
levels.level.floor_name=Floor
levels.level.grass_name=Grass