v0.7.5: added new properties for traps

This commit is contained in:
Evan Debenham 2019-09-22 23:40:47 -04:00
parent 8e4e8f495c
commit 59186a3840
8 changed files with 32 additions and 36 deletions
core/src/main/java/com/shatteredpixel/shatteredpixeldungeon

View File

@ -106,6 +106,7 @@ import com.shatteredpixel.shatteredpixeldungeon.journal.Notes;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
import com.shatteredpixel.shatteredpixeldungeon.levels.features.Chasm;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.plants.Earthroot;
import com.shatteredpixel.shatteredpixeldungeon.plants.Swiftthistle;
@ -1646,6 +1647,11 @@ public class Hero extends Char {
if (Dungeon.level.secret[p]){
Trap trap = Dungeon.level.traps.get( p );
if (trap != null && !trap.canBeSearched){
continue;
}
float chance;
//intentional searches always succeed
if (intentional){

View File

@ -182,8 +182,11 @@ public class TalismanOfForesight extends Artifact {
if (Dungeon.level.heroFOV[p]
&& Dungeon.level.secret[p]
&& Dungeon.level.map[p] != Terrain.SECRET_DOOR)
&& Dungeon.level.map[p] != Terrain.SECRET_DOOR) {
if (Dungeon.level.traps.get(p) == null || Dungeon.level.traps.get(p).canBeSearched) {
smthFound = true;
}
}
}
}

View File

@ -43,12 +43,8 @@ public class DisintegrationTrap extends Trap {
{
color = VIOLET;
shape = CROSSHAIR;
}
@Override
public Trap hide() {
//this one can't be hidden
return reveal();
canBeHidden = false;
}
@Override

View File

@ -40,12 +40,8 @@ public class GrimTrap extends Trap {
{
color = GREY;
shape = LARGE_DOT;
}
@Override
public Trap hide() {
//cannot hide this trap
return reveal();
canBeHidden = false;
}
@Override

View File

@ -40,12 +40,12 @@ public class PoisonDartTrap extends Trap {
{
color = GREEN;
shape = CROSSHAIR;
canBeHidden = false;
}
@Override
public Trap hide() {
//this one can't be hidden
return reveal();
protected int poisonAmount(){
return 8 + Math.round(2*Dungeon.depth / 3f);
}
@Override
@ -85,8 +85,7 @@ public class PoisonDartTrap extends Trap {
if (finalTarget == Dungeon.hero && !finalTarget.isAlive()){
Dungeon.fail( trap.getClass() );
}
Buff.affect( finalTarget, Poison.class )
.set( 8 + Math.round(2*Dungeon.depth / 3f) );
Buff.affect( finalTarget, Poison.class ).set( poisonAmount() );
Sample.INSTANCE.play(Assets.SND_HIT, 1, 1, Random.Float(0.8f, 1.25f));
finalTarget.sprite.bloodBurstA(finalTarget.sprite.center(), dmg);
finalTarget.sprite.flash();
@ -99,8 +98,7 @@ public class PoisonDartTrap extends Trap {
});
} else {
finalTarget.damage(Random.NormalIntRange(1, 4) - finalTarget.drRoll(), trap);
Buff.affect( finalTarget, Poison.class )
.set( 8 + Math.round(2*Dungeon.depth / 3f) );
Buff.affect( finalTarget, Poison.class ).set( poisonAmount() );
}
}
}

View File

@ -47,12 +47,8 @@ public class RockfallTrap extends Trap {
{
color = GREY;
shape = DIAMOND;
}
@Override
public Trap hide() {
//this one can't be hidden
return reveal();
canBeHidden = false;
}
@Override

View File

@ -60,6 +60,9 @@ public abstract class Trap implements Bundlable {
public boolean visible;
public boolean active = true;
public boolean canBeHidden = true;
public boolean canBeSearched = true;
public Trap set(int pos){
this.pos = pos;
@ -73,9 +76,13 @@ public abstract class Trap implements Bundlable {
}
public Trap hide() {
visible = false;
GameScene.updateMap(pos);
return this;
if (canBeHidden) {
visible = false;
GameScene.updateMap(pos);
return this;
} else {
return reveal();
}
}
public void trigger() {

View File

@ -40,12 +40,6 @@ public class WornDartTrap extends Trap {
shape = CROSSHAIR;
}
@Override
public Trap hide() {
//this one can't be hidden
return reveal();
}
@Override
public void activate() {
Char target = Actor.findChar(pos);