From c601027f27d197529306fe4696ff7d6dd1c017dd Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Sat, 6 Jun 2015 16:00:50 -0400 Subject: [PATCH] v0.3.0c: refactored plants to match the structure of new traps. --- .../actors/mobs/npcs/Wandmaker.java | 4 ++-- .../items/wands/WandOfRegrowth.java | 6 ++---- .../shatteredpixeldungeon/levels/Level.java | 4 ++-- .../plants/BlandfruitBush.java | 5 +++-- .../shatteredpixeldungeon/plants/Blindweed.java | 5 +++-- .../shatteredpixeldungeon/plants/Dreamfoil.java | 5 +++-- .../shatteredpixeldungeon/plants/Earthroot.java | 5 +++-- .../shatteredpixeldungeon/plants/Fadeleaf.java | 5 +++-- .../shatteredpixeldungeon/plants/Firebloom.java | 4 +--- .../shatteredpixeldungeon/plants/Icecap.java | 4 +--- .../shatteredpixeldungeon/plants/Plant.java | 16 +++++++++++----- .../shatteredpixeldungeon/plants/Sorrowmoss.java | 5 +++-- .../shatteredpixeldungeon/plants/Starflower.java | 5 +++-- .../shatteredpixeldungeon/plants/Stormvine.java | 5 +++-- .../shatteredpixeldungeon/plants/Sungrass.java | 5 +++-- 15 files changed, 46 insertions(+), 37 deletions(-) diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Wandmaker.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Wandmaker.java index a46866109..74eb86905 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Wandmaker.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Wandmaker.java @@ -290,8 +290,8 @@ public class Wandmaker extends NPC { } @Override - public void activate( Char ch ) { - super.activate( ch ); + public void activate() { + Char ch = Actor.findChar(pos); GameScene.add( Blob.seed( pos, 100, ToxicGas.class ) ); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfRegrowth.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfRegrowth.java index 31550840e..f1db0d40b 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfRegrowth.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfRegrowth.java @@ -253,8 +253,7 @@ public class WandOfRegrowth extends Wand { } @Override - public void activate(Char ch) { - super.activate( ch ); + public void activate() { int nDrops = Random.NormalIntRange(2, 8); @@ -295,8 +294,7 @@ public class WandOfRegrowth extends Wand { } @Override - public void activate(Char ch) { - super.activate( ch ); + public void activate() { int nSeeds = Random.NormalIntRange(1, 5); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java b/src/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java index 26e4db527..2e77573e9 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java @@ -819,7 +819,7 @@ public abstract class Level implements Bundlable { Plant plant = plants.get( cell ); if (plant != null) { - plant.activate( ch ); + plant.trigger(); } } @@ -850,7 +850,7 @@ public abstract class Level implements Bundlable { Plant plant = plants.get( cell ); if (plant != null) { - plant.activate( mob ); + plant.trigger(); } } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/plants/BlandfruitBush.java b/src/com/shatteredpixel/shatteredpixeldungeon/plants/BlandfruitBush.java index 8e8e4e5e2..3bba516ab 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/plants/BlandfruitBush.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/plants/BlandfruitBush.java @@ -1,6 +1,7 @@ package com.shatteredpixel.shatteredpixeldungeon.plants; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; +import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.items.food.Blandfruit; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; @@ -20,8 +21,8 @@ public class BlandfruitBush extends Plant { } @Override - public void activate( Char ch ) { - super.activate( ch ); + public void activate() { + Char ch = Actor.findChar(pos); Dungeon.level.drop( new Blandfruit(), pos ).sprite.drop(); } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/plants/Blindweed.java b/src/com/shatteredpixel/shatteredpixeldungeon/plants/Blindweed.java index af681633e..35f68ca4f 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/plants/Blindweed.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/plants/Blindweed.java @@ -18,6 +18,7 @@ package com.shatteredpixel.shatteredpixeldungeon.plants; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; +import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Blindness; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Cripple; @@ -41,8 +42,8 @@ public class Blindweed extends Plant { } @Override - public void activate( Char ch ) { - super.activate( ch ); + public void activate() { + Char ch = Actor.findChar(pos); if (ch != null) { int len = Random.Int( 5, 10 ); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/plants/Dreamfoil.java b/src/com/shatteredpixel/shatteredpixeldungeon/plants/Dreamfoil.java index 723c95a0e..d56344983 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/plants/Dreamfoil.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/plants/Dreamfoil.java @@ -17,6 +17,7 @@ */ package com.shatteredpixel.shatteredpixeldungeon.plants; +import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Bleeding; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; @@ -46,8 +47,8 @@ public class Dreamfoil extends Plant { } @Override - public void activate( Char ch ) { - super.activate( ch ); + public void activate() { + Char ch = Actor.findChar(pos); if (ch != null) { if (ch instanceof Mob) diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/plants/Earthroot.java b/src/com/shatteredpixel/shatteredpixeldungeon/plants/Earthroot.java index 08b202f8a..116ad7962 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/plants/Earthroot.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/plants/Earthroot.java @@ -17,6 +17,7 @@ */ package com.shatteredpixel.shatteredpixeldungeon.plants; +import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; import com.watabou.noosa.Camera; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; @@ -41,8 +42,8 @@ public class Earthroot extends Plant { } @Override - public void activate( Char ch ) { - super.activate( ch ); + public void activate() { + Char ch = Actor.findChar(pos); if (ch == Dungeon.hero) { Buff.affect( ch, Armor.class ).level = ch.HT; diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/plants/Fadeleaf.java b/src/com/shatteredpixel/shatteredpixeldungeon/plants/Fadeleaf.java index 51777dbb6..1e09d316e 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/plants/Fadeleaf.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/plants/Fadeleaf.java @@ -18,6 +18,7 @@ package com.shatteredpixel.shatteredpixeldungeon.plants; 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; @@ -39,8 +40,8 @@ public class Fadeleaf extends Plant { } @Override - public void activate( Char ch ) { - super.activate( ch ); + public void activate() { + Char ch = Actor.findChar(pos); if (ch instanceof Hero) { diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/plants/Firebloom.java b/src/com/shatteredpixel/shatteredpixeldungeon/plants/Firebloom.java index e0d9a70bc..44591e170 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/plants/Firebloom.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/plants/Firebloom.java @@ -18,7 +18,6 @@ package com.shatteredpixel.shatteredpixeldungeon.plants; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; -import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob; import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Fire; import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter; @@ -37,8 +36,7 @@ public class Firebloom extends Plant { } @Override - public void activate( Char ch ) { - super.activate( ch ); + public void activate() { GameScene.add( Blob.seed( pos, 2, Fire.class ) ); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/plants/Icecap.java b/src/com/shatteredpixel/shatteredpixeldungeon/plants/Icecap.java index b594528b2..ea2d6a365 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/plants/Icecap.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/plants/Icecap.java @@ -18,7 +18,6 @@ package com.shatteredpixel.shatteredpixeldungeon.plants; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; -import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Fire; import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Freezing; import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfFrost; @@ -39,8 +38,7 @@ public class Icecap extends Plant { } @Override - public void activate( Char ch ) { - super.activate( ch ); + public void activate() { PathFinder.buildDistanceMap( pos, BArray.not( Level.losBlocking, null ), 1 ); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/plants/Plant.java b/src/com/shatteredpixel/shatteredpixeldungeon/plants/Plant.java index 921c03648..c657fea35 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/plants/Plant.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/plants/Plant.java @@ -19,6 +19,7 @@ package com.shatteredpixel.shatteredpixeldungeon.plants; import java.util.ArrayList; +import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.SandalsOfNature; import com.watabou.noosa.audio.Sample; import com.shatteredpixel.shatteredpixeldungeon.Assets; @@ -41,7 +42,7 @@ import com.watabou.utils.Bundlable; import com.watabou.utils.Bundle; import com.watabou.utils.Random; -public class Plant implements Bundlable { +public abstract class Plant implements Bundlable { public String plantName; @@ -49,16 +50,21 @@ public class Plant implements Bundlable { public int pos; public PlantSprite sprite; - - public void activate( Char ch ) { - + + public void trigger(){ + + Char ch = Actor.findChar(pos); + if (ch instanceof Hero && ((Hero)ch).subClass == HeroSubClass.WARDEN) { Buff.affect( ch, Barkskin.class ).level( ch.HT / 3 ); } - + + activate(); wither(); } + public abstract void activate(); + public void wither() { Dungeon.level.uproot( pos ); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/plants/Sorrowmoss.java b/src/com/shatteredpixel/shatteredpixeldungeon/plants/Sorrowmoss.java index a95b3f134..2dec65c13 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/plants/Sorrowmoss.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/plants/Sorrowmoss.java @@ -18,6 +18,7 @@ package com.shatteredpixel.shatteredpixeldungeon.plants; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; +import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Poison; @@ -37,8 +38,8 @@ public class Sorrowmoss extends Plant { } @Override - public void activate( Char ch ) { - super.activate( ch ); + public void activate() { + Char ch = Actor.findChar(pos); if (ch != null) { Buff.affect( ch, Poison.class ).set( Poison.durationFactor( ch ) * (4 + Dungeon.depth / 2) ); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/plants/Starflower.java b/src/com/shatteredpixel/shatteredpixeldungeon/plants/Starflower.java index 82d20483a..a4b57e04f 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/plants/Starflower.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/plants/Starflower.java @@ -1,6 +1,7 @@ package com.shatteredpixel.shatteredpixeldungeon.plants; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; +import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Bless; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; @@ -20,8 +21,8 @@ public class Starflower extends Plant { } @Override - public void activate(Char ch) { - super.activate( ch ); + public void activate() { + Char ch = Actor.findChar(pos); if (ch != null) Buff.prolong(ch, Bless.class, 30f); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/plants/Stormvine.java b/src/com/shatteredpixel/shatteredpixeldungeon/plants/Stormvine.java index 3433f32c9..3202ee74b 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/plants/Stormvine.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/plants/Stormvine.java @@ -1,5 +1,6 @@ package com.shatteredpixel.shatteredpixeldungeon.plants; +import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Vertigo; @@ -21,8 +22,8 @@ public class Stormvine extends Plant { } @Override - public void activate( Char ch ) { - super.activate( ch ); + public void activate() { + Char ch = Actor.findChar(pos); if (ch != null) { Buff.affect(ch, Vertigo.class, Vertigo.duration( ch ) ); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/plants/Sungrass.java b/src/com/shatteredpixel/shatteredpixeldungeon/plants/Sungrass.java index d994e8790..b85d016aa 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/plants/Sungrass.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/plants/Sungrass.java @@ -18,6 +18,7 @@ package com.shatteredpixel.shatteredpixeldungeon.plants; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; +import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter; @@ -39,8 +40,8 @@ public class Sungrass extends Plant { } @Override - public void activate( Char ch ) { - super.activate( ch ); + public void activate() { + Char ch = Actor.findChar(pos); if (ch == Dungeon.hero) { Buff.affect( ch, Health.class ).level = ch.HT;