From ae3f37e0d179435d84c0fe9160e96bb23516c360 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Mon, 22 Aug 2022 13:22:12 -0400 Subject: [PATCH] v1.4.0: adjusted code for several plant effects, added a rotberry effect --- .../assets/messages/plants/plants.properties | 8 ++--- .../shatteredpixeldungeon/actors/Actor.java | 6 ++-- .../shatteredpixeldungeon/actors/Char.java | 30 +++++++++++++++++-- .../actors/hero/Hero.java | 18 +---------- .../actors/mobs/ArmoredStatue.java | 4 +-- .../actors/mobs/Mob.java | 2 +- .../actors/mobs/npcs/PrismaticImage.java | 6 ++-- .../items/artifacts/TimekeepersHourglass.java | 1 + .../plants/Earthroot.java | 7 +++-- .../plants/Rotberry.java | 5 ++++ .../plants/Sungrass.java | 4 +-- .../plants/Swiftthistle.java | 6 ++-- 12 files changed, 57 insertions(+), 40 deletions(-) diff --git a/core/src/main/assets/messages/plants/plants.properties b/core/src/main/assets/messages/plants/plants.properties index 39859e063..159123e1f 100644 --- a/core/src/main/assets/messages/plants/plants.properties +++ b/core/src/main/assets/messages/plants/plants.properties @@ -18,7 +18,7 @@ plants.earthroot.desc=When a creature touches an earthroot, its roots create a k plants.earthroot.warden_desc=The roots of an earthroot plant will move with _the Warden_, providing her mobile barkskin armor. plants.earthroot$seed.name=seed of earthroot plants.earthroot$armor.name=herbal armor -plants.earthroot$armor.desc=A kind of natural, immobile armor is protecting you. The armor forms plates of bark and twine, wrapping around your body.\n\nThis herbal armor will block %d damage from any physical hit you take, until it eventually runs out of durability and collapses.\n\nAs the armor is immobile, if you attempt to move it will break apart and be lost.\n\nArmor remaining: %d. +plants.earthroot$armor.desc=A kind of natural, immobile armor made of bark and twine.\n\nThis herbal armor will block %d damage from any physical hit, until it eventually runs out of durability and collapses.\n\nAs the armor is immobile, moving will cause it to break apart and be lost.\n\nArmor remaining: %d. plants.fadeleaf.name=fadeleaf plants.fadeleaf.desc=Touching a fadeleaf will teleport any creature to a random place on the current level. @@ -43,7 +43,7 @@ plants.plant$seed$placeholder.name=seed plants.rotberry.name=rotberry plants.rotberry.desc=The berries of a young rotberry shrub taste like sweet, sweet death. Over a few years, this rotberry shrub will grow into another rot heart. -plants.rotberry.warden_desc=Normally a rotberry bush has no effect when trampled, but _the Warden_ is able to harness energy from it to temporarily boost her strength! +plants.rotberry.warden_desc=Normally a rotberry bush only produces a little gas when trampled, but _the Warden_ is able to harness energy from it to temporarily boost her strength! plants.rotberry$seed.name=seed of rotberry plants.sorrowmoss.name=sorrowmoss @@ -66,11 +66,11 @@ plants.sungrass.desc=Sungrass is renowned for its sap's slow but effective heali plants.sungrass.warden_desc=_The Warden_ can receive healing from trampled sungrass even if she moves away from it. plants.sungrass$seed.name=seed of sungrass plants.sungrass$health.name=herbal healing -plants.sungrass$health.desc=Sungrass possesses excellent healing properties, though it is much slower than a potion of healing.\n\nYou are currently slowly regenerating health from the sungrass plant. Moving off the plant will break the healing effect.\n\nHealing remaining: %d. +plants.sungrass$health.desc=Sungrass possesses excellent healing properties, though it is much slower than a potion of healing.\n\nMoving off the plant will break the healing effect.\n\nHealing remaining: %d. plants.swiftthistle.name=swiftthistle plants.swiftthistle.desc=When trampled, swiftthistle will briefly accelerate the flow of time around it, allowing the trampler to perform several actions instantly. plants.swiftthistle.warden_desc=In addition to gaining instantaneous actions, _the Warden_ will also get a brief haste boost when trampling swiftthistle. plants.swiftthistle$seed.name=seed of swiftthistle plants.swiftthistle$timebubble.name=time bubble -plants.swiftthistle$timebubble.desc=You are in a small bubble of accelerated time, allowing you to perform actions instantly. Attacking or using magic will break this effect however.\n\nTurns remaining: %s. +plants.swiftthistle$timebubble.desc=A small bubble of accelerated time, allowing actions to be performed instantly. Attacking or using magic will break this effect however.\n\nTurns remaining: %s. diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/Actor.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/Actor.java index 3a5328315..d39028126 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/Actor.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/Actor.java @@ -55,8 +55,8 @@ public abstract class Actor implements Bundlable { protected abstract boolean act(); - //Always spends exactly one tick, regardless of time-influencing factors - protected final void spendConstant( float time ){ + //Always spends exactly the specified amount of time, regardless of time-influencing factors + protected void spendConstant( float time ){ this.time += time; //if time is very close to a whole number, round to a whole number to fix errors float ex = Math.abs(this.time % 1f); @@ -65,7 +65,7 @@ public abstract class Actor implements Bundlable { } } - //can be overridden for time to be affected by various factors + //sends time, but the amount can be influenced protected void spend( float time ) { spendConstant( time ); } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/Char.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/Char.java index 57baa5a6a..107044816 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/Char.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/Char.java @@ -80,6 +80,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Heap; import com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.AntiMagic; import com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.Potential; import com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.Viscosity; +import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.TimekeepersHourglass; import com.shatteredpixel.shatteredpixeldungeon.items.potions.exotic.PotionOfCleansing; import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfArcana; import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfElements; @@ -104,6 +105,8 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.features.Chasm; import com.shatteredpixel.shatteredpixeldungeon.levels.features.Door; import com.shatteredpixel.shatteredpixeldungeon.levels.traps.GrimTrap; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; +import com.shatteredpixel.shatteredpixeldungeon.plants.Earthroot; +import com.shatteredpixel.shatteredpixeldungeon.plants.Swiftthistle; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite; import com.shatteredpixel.shatteredpixeldungeon.utils.BArray; @@ -540,6 +543,12 @@ public abstract class Char extends Actor { } public int defenseProc( Char enemy, int damage ) { + + Earthroot.Armor armor = buff( Earthroot.Armor.class ); + if (armor != null) { + damage = armor.absorb( damage ); + } + return damage; } @@ -728,10 +737,27 @@ public abstract class Char extends Actor { public boolean isAlive() { return HP > 0 || deathMarked; } - + + @Override + protected void spendConstant(float time) { + TimekeepersHourglass.timeFreeze freeze = buff(TimekeepersHourglass.timeFreeze.class); + if (freeze != null) { + freeze.processTime(time); + return; + } + + Swiftthistle.TimeBubble bubble = buff(Swiftthistle.TimeBubble.class); + if (bubble != null){ + bubble.processTime(time); + return; + } + + super.spendConstant(time); + } + @Override protected void spend( float time ) { - + float timeScale = 1f; if (buff( Slow.class ) != null) { timeScale *= 0.5f; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java index 5b92a555b..bfc81d42d 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java @@ -627,17 +627,6 @@ public class Hero extends Char { @Override public void spend( float time ) { justMoved = false; - TimekeepersHourglass.timeFreeze freeze = buff(TimekeepersHourglass.timeFreeze.class); - if (freeze != null) { - freeze.processTime(time); - return; - } - - Swiftthistle.TimeBubble bubble = buff(Swiftthistle.TimeBubble.class); - if (bubble != null){ - bubble.processTime(time); - return; - } super.spend(time); } @@ -1212,18 +1201,13 @@ public class Hero extends Char { if (belongings.armor() != null) { damage = belongings.armor().proc( enemy, this, damage ); } - - Earthroot.Armor armor = buff( Earthroot.Armor.class ); - if (armor != null) { - damage = armor.absorb( damage ); - } WandOfLivingEarth.RockArmor rockArmor = buff(WandOfLivingEarth.RockArmor.class); if (rockArmor != null) { damage = rockArmor.absorb(damage); } - return damage; + return super.defenseProc( enemy, damage ); } @Override diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/ArmoredStatue.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/ArmoredStatue.java index 6eb903e39..8c2683a8a 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/ArmoredStatue.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/ArmoredStatue.java @@ -91,8 +91,8 @@ public class ArmoredStatue extends Statue { @Override public int defenseProc(Char enemy, int damage) { - damage = super.defenseProc(enemy, damage); - return armor.proc(enemy, this, damage); + damage = armor.proc(enemy, this, damage); + return super.defenseProc(enemy, damage); } @Override diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mob.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mob.java index 889164c71..498ad57fb 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mob.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mob.java @@ -650,7 +650,7 @@ public abstract class Mob extends Char { } } - return damage; + return super.defenseProc(enemy, damage); } @Override diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/PrismaticImage.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/PrismaticImage.java index f143fbfe6..e049e4f90 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/PrismaticImage.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/PrismaticImage.java @@ -185,12 +185,10 @@ public class PrismaticImage extends NPC { @Override public int defenseProc(Char enemy, int damage) { - damage = super.defenseProc(enemy, damage); if (hero != null && hero.belongings.armor() != null){ - return hero.belongings.armor().proc( enemy, this, damage ); - } else { - return damage; + damage = hero.belongings.armor().proc( enemy, this, damage ); } + return super.defenseProc(enemy, damage); } @Override diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/TimekeepersHourglass.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/TimekeepersHourglass.java index 1b8497ccd..0c47ed954 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/TimekeepersHourglass.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/TimekeepersHourglass.java @@ -382,6 +382,7 @@ public class TimekeepersHourglass extends Artifact { @Override public void fx(boolean on) { + if (!(target instanceof Hero)) return; Emitter.freezeEmitters = on; if (on){ for (Mob mob : Dungeon.level.mobs.toArray(new Mob[0])) { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Earthroot.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Earthroot.java index 699470819..42367caa5 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Earthroot.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Earthroot.java @@ -25,6 +25,7 @@ import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Barkskin; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; +import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroSubClass; import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter; import com.shatteredpixel.shatteredpixeldungeon.effects.particles.EarthParticle; @@ -43,9 +44,9 @@ public class Earthroot extends Plant { @Override public void activate( Char ch ) { - - if (ch == Dungeon.hero) { - if (Dungeon.hero.subClass == HeroSubClass.WARDEN){ + + if (ch != null){ + if (ch instanceof Hero && ((Hero) ch).subClass == HeroSubClass.WARDEN) { Buff.affect(ch, Barkskin.class).set(Dungeon.hero.lvl + 5, 5); } else { Buff.affect(ch, Armor.class).level(ch.HT); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Rotberry.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Rotberry.java index a3d6854d5..6e16af1a0 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Rotberry.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Rotberry.java @@ -23,12 +23,15 @@ 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.ToxicGas; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.AdrenalineSurge; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroSubClass; import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter; import com.shatteredpixel.shatteredpixeldungeon.effects.particles.LeafParticle; +import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; public class Rotberry extends Plant { @@ -42,6 +45,8 @@ public class Rotberry extends Plant { public void activate( Char ch ) { if (ch instanceof Hero && ((Hero) ch).subClass == HeroSubClass.WARDEN){ Buff.affect(ch, AdrenalineSurge.class).reset(1, AdrenalineSurge.DURATION); + } else { + GameScene.add( Blob.seed( pos, 100, ToxicGas.class ) ); } Dungeon.level.drop( new Seed(), pos ).sprite.drop(); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Sungrass.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Sungrass.java index 8c99f1e41..620a4e731 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Sungrass.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Sungrass.java @@ -45,8 +45,8 @@ public class Sungrass extends Plant { @Override public void activate( Char ch ) { - if (ch == Dungeon.hero) { - if (Dungeon.hero.subClass == HeroSubClass.WARDEN) { + if (ch != null){ + if (ch instanceof Hero && ((Hero) ch).subClass == HeroSubClass.WARDEN) { Buff.affect(ch, Healing.class).setHeal(ch.HT, 0, 1); } else { Buff.affect(ch, Health.class).boost(ch.HT); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Swiftthistle.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Swiftthistle.java index 3a9270604..f389fcf7f 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Swiftthistle.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Swiftthistle.java @@ -25,6 +25,7 @@ import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Haste; +import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroSubClass; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob; import com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap; @@ -47,9 +48,9 @@ public class Swiftthistle extends Plant { @Override public void activate( Char ch ) { - if (ch == Dungeon.hero) { + if (ch != null) { Buff.affect(ch, TimeBubble.class).reset(); - if (Dungeon.hero.subClass == HeroSubClass.WARDEN){ + if (ch instanceof Hero && ((Hero) ch).subClass == HeroSubClass.WARDEN){ Buff.affect(ch, Haste.class, 1f); } } @@ -146,6 +147,7 @@ public class Swiftthistle extends Plant { @Override public void fx(boolean on) { + if (!(target instanceof Hero)) return; Emitter.freezeEmitters = on; if (on){ for (Mob mob : Dungeon.level.mobs.toArray(new Mob[0])) {