From 039dc4eba5bc71604691423a8f05c3618630b524 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Sat, 23 Oct 2021 18:28:56 -0400 Subject: [PATCH] v1.1.0: fixed some cases of glyphs not working for the ghost or statues --- .../actors/mobs/ArmoredStatue.java | 33 +++++++++++++++++++ .../items/armor/glyphs/AntiMagic.java | 2 +- .../items/armor/glyphs/Brimstone.java | 2 +- .../items/armor/glyphs/Camouflage.java | 12 +++++++ .../items/artifacts/DriedRose.java | 11 ++++++- .../levels/features/HighGrass.java | 21 ++++++++---- 6 files changed, 72 insertions(+), 9 deletions(-) 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 740e0ce2f..723d2bc53 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 @@ -23,8 +23,12 @@ package com.shatteredpixel.shatteredpixeldungeon.actors.mobs; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; +import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Burning; import com.shatteredpixel.shatteredpixeldungeon.items.Generator; +import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor; +import com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.AntiMagic; +import com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.Brimstone; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite; import com.shatteredpixel.shatteredpixeldungeon.sprites.StatueSprite; @@ -70,11 +74,40 @@ public class ArmoredStatue extends Statue { return super.drRoll() + Random.NormalIntRange( armor.DRMin(), armor.DRMax()); } + //used in some glyph calculations + public Armor armor(){ + return armor; + } + + @Override + public boolean isImmune(Class effect) { + if (effect == Burning.class + && armor != null + && armor.hasGlyph(Brimstone.class, this)){ + return true; + } + return super.isImmune(effect); + } + @Override public int defenseProc(Char enemy, int damage) { return armor.proc(enemy, this, damage); } + @Override + public void damage(int dmg, Object src) { + //TODO improve this when I have proper damage source logic + if (armor != null && armor.hasGlyph(AntiMagic.class, this) + && AntiMagic.RESISTS.contains(src.getClass())){ + dmg -= AntiMagic.drRoll(armor.buffedLvl()); + } + + super.damage( dmg, src ); + + //for the rose status indicator + Item.updateQuickslot(); + } + @Override public CharSprite sprite() { CharSprite sprite = super.sprite(); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/armor/glyphs/AntiMagic.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/armor/glyphs/AntiMagic.java index ad3e0fe9d..8bf7b3e5a 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/armor/glyphs/AntiMagic.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/armor/glyphs/AntiMagic.java @@ -91,7 +91,7 @@ public class AntiMagic extends Armor.Glyph { @Override public int proc(Armor armor, Char attacker, Char defender, int damage) { - //no proc effect, see Hero.damage + //no proc effect, see Hero.damage and GhostHero.damage and ArmoredStatue.damage return damage; } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/armor/glyphs/Brimstone.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/armor/glyphs/Brimstone.java index ad4ec9c49..7dcb311c3 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/armor/glyphs/Brimstone.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/armor/glyphs/Brimstone.java @@ -31,7 +31,7 @@ public class Brimstone extends Armor.Glyph { @Override public int proc(Armor armor, Char attacker, Char defender, int damage) { - //no proc effect, see Hero.isImmune and GhostHero.isImmune + //no proc effect, see Hero.isImmune and GhostHero.isImmune and ArmoredStatue.isImmune return damage; } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/armor/glyphs/Camouflage.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/armor/glyphs/Camouflage.java index 950ec69cf..efa6d38b8 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/armor/glyphs/Camouflage.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/armor/glyphs/Camouflage.java @@ -21,9 +21,14 @@ package com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs; +import com.shatteredpixel.shatteredpixeldungeon.Assets; +import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; +import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; +import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Invisibility; import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; +import com.watabou.noosa.audio.Sample; public class Camouflage extends Armor.Glyph { @@ -35,6 +40,13 @@ public class Camouflage extends Armor.Glyph { return damage; } + public static void activate(Char ch, int level){ + Buff.prolong(ch, Invisibility.class, 3 + level/2); + if ( Dungeon.level.heroFOV[ch.pos] ) { + Sample.INSTANCE.play( Assets.Sounds.MELD ); + } + } + @Override public ItemSprite.Glowing glowing() { return GREEN; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/DriedRose.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/DriedRose.java index 2a9f89ee3..79660c09f 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/DriedRose.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/DriedRose.java @@ -627,7 +627,7 @@ public class DriedRose extends Artifact { //TODO improve this when I have proper damage source logic if (rose != null && rose.armor != null && rose.armor.hasGlyph(AntiMagic.class, this) && AntiMagic.RESISTS.contains(src.getClass())){ - dmg -= AntiMagic.drRoll(rose.armor.level()); + dmg -= AntiMagic.drRoll(rose.armor.buffedLvl()); } super.damage( dmg, src ); @@ -686,6 +686,15 @@ public class DriedRose extends Artifact { return block; } + //used in some glyph calculations + public Armor armor(){ + if (rose != null){ + return rose.armor; + } else { + return null; + } + } + @Override public boolean isImmune(Class effect) { if (effect == Burning.class diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/features/HighGrass.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/features/HighGrass.java index 73b47bb3a..aa35adaa0 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/features/HighGrass.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/features/HighGrass.java @@ -31,11 +31,13 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Invisibility; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Talent; +import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.ArmoredStatue; import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter; import com.shatteredpixel.shatteredpixeldungeon.effects.particles.LeafParticle; import com.shatteredpixel.shatteredpixeldungeon.items.Dewdrop; import com.shatteredpixel.shatteredpixeldungeon.items.Generator; import com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.Camouflage; +import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.DriedRose; import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.SandalsOfNature; import com.shatteredpixel.shatteredpixeldungeon.items.food.Berry; import com.shatteredpixel.shatteredpixeldungeon.levels.Level; @@ -120,15 +122,22 @@ public class HighGrass { level.drop(new Dewdrop(), pos).sprite.drop(); } } - + + //Camouflage if (ch instanceof Hero) { Hero hero = (Hero) ch; - - //Camouflage - //FIXME doesn't work with sad ghost if (hero.belongings.armor() != null && hero.belongings.armor().hasGlyph(Camouflage.class, hero)) { - Buff.prolong(hero, Invisibility.class, 3 + hero.belongings.armor.buffedLvl()/2); - Sample.INSTANCE.play( Assets.Sounds.MELD ); + Camouflage.activate(hero, hero.belongings.armor.buffedLvl()); + } + } else if (ch instanceof DriedRose.GhostHero){ + DriedRose.GhostHero ghost = (DriedRose.GhostHero) ch; + if (ghost.armor() != null && ghost.armor().hasGlyph(Camouflage.class, ghost)){ + Camouflage.activate(ghost, ghost.armor().buffedLvl()); + } + } else if (ch instanceof ArmoredStatue){ + ArmoredStatue statue = (ArmoredStatue) ch; + if (statue.armor() != null && statue.armor().hasGlyph(Camouflage.class, statue)){ + Camouflage.activate(statue, statue.armor().buffedLvl()); } }