From f4c8a5336d1e53d71d4a0ae992dfaaa74ab17b8a Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Sun, 3 Mar 2019 13:42:32 -0500 Subject: [PATCH] v0.7.2: reworked enchantments! Still need to implement swift and a curse --- .../ShatteredPixelDungeon.java | 18 ++++ .../actors/buffs/Burning.java | 6 +- .../actors/hero/Hero.java | 22 +++- .../actors/mobs/Mob.java | 15 ++- .../actors/mobs/Statue.java | 13 +++ .../items/artifacts/DriedRose.java | 15 +++ .../items/wands/WandOfBlastWave.java | 13 +-- .../items/wands/WandOfRegrowth.java | 16 +-- .../items/weapon/Weapon.java | 20 ++-- .../curses/{Elastic.java => Shifting.java} | 17 +-- .../items/weapon/enchantments/Blazing.java | 8 +- .../items/weapon/enchantments/Blocking.java | 101 ++++++++++++++++++ .../{Venomous.java => Blooming.java} | 55 +++++++--- .../items/weapon/enchantments/Chilling.java | 10 +- .../{Dazzling.java => Elastic.java} | 36 +++---- .../items/weapon/enchantments/Eldritch.java | 63 ----------- .../items/weapon/enchantments/Grim.java | 12 ++- .../items/weapon/enchantments/Lucky.java | 75 +++++-------- .../{Stunning.java => Precise.java} | 32 +++--- .../items/weapon/enchantments/Projecting.java | 4 +- .../items/weapon/enchantments/Shocking.java | 37 ++++--- .../enchantments/{Vorpal.java => Swift.java} | 36 ++----- .../items/weapon/enchantments/Unstable.java | 23 ++-- .../items/weapon/enchantments/Vampiric.java | 18 ++-- .../messages/items/items.properties | 26 ++--- 25 files changed, 386 insertions(+), 305 deletions(-) rename core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/curses/{Elastic.java => Shifting.java} (72%) create mode 100644 core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Blocking.java rename core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/{Venomous.java => Blooming.java} (51%) rename core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/{Dazzling.java => Elastic.java} (65%) delete mode 100644 core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Eldritch.java rename core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/{Stunning.java => Precise.java} (64%) rename core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/{Vorpal.java => Swift.java} (60%) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ShatteredPixelDungeon.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ShatteredPixelDungeon.java index 17b78fedc..d89de42bc 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ShatteredPixelDungeon.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ShatteredPixelDungeon.java @@ -122,6 +122,24 @@ public class ShatteredPixelDungeon extends Game { com.shatteredpixel.shatteredpixeldungeon.items.stones.StoneOfDisarming.class, "com.shatteredpixel.shatteredpixeldungeon.items.stones.StoneOfDetectCurse" ); + com.watabou.utils.Bundle.addAlias( + com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Elastic.class, + "com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.curses.Elastic" ); + com.watabou.utils.Bundle.addAlias( + com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Elastic.class, + "com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Dazzling" ); + com.watabou.utils.Bundle.addAlias( + com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Elastic.class, + "com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Eldritch" ); + com.watabou.utils.Bundle.addAlias( + com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Grim.class, + "com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Stunning" ); + com.watabou.utils.Bundle.addAlias( + com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Chilling.class, + "com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Venomous" ); + com.watabou.utils.Bundle.addAlias( + com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Precise.class, + "com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Vorpal" ); } @Override diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Burning.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Burning.java index f28974e3a..b6ec19399 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Burning.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Burning.java @@ -170,7 +170,11 @@ public class Burning extends Buff implements Hero.Doom { } public void reignite( Char ch ) { - left = DURATION; + reignite( ch, DURATION ); + } + + public void reignite( Char ch, float duration ) { + left = duration; } @Override 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 df6a84b27..a1ff5192a 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 @@ -94,6 +94,9 @@ import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfMagicMappi import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfUpgrade; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.SpiritBow; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon; +import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Blocking; +import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Precise; +import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Unstable; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Flail; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.MissileWeapon; import com.shatteredpixel.shatteredpixeldungeon.journal.Notes; @@ -313,6 +316,18 @@ public class Hero extends Char { public int attackSkill( Char target ) { KindOfWeapon wep = belongings.weapon; + if (wep instanceof Weapon + && (((Weapon) wep).hasEnchant(Precise.class, this) + || (((Weapon) wep).hasEnchant(Unstable.class, this) && Random.Int(11) == 0))){ + if (Precise.rollToGuaranteeHit((Weapon) wep)){ + target.sprite.emitter().start( Speck.factory(Speck.LIGHT), 0.05f, 5 ); + return Integer.MAX_VALUE; + } + if (((Weapon) wep).hasEnchant(Unstable.class, this)){ + Unstable.justRolledPrecise = true; + } + } + float accuracy = 1; accuracy *= RingOfAccuracy.accuracyMultiplier( this ); @@ -352,7 +367,6 @@ public class Hero extends Char { @Override public int drRoll() { int dr = 0; - Barkskin bark = buff(Barkskin.class); if (belongings.armor != null) { int armDr = Random.NormalIntRange( belongings.armor.DRMin(), belongings.armor.DRMax()); @@ -368,8 +382,12 @@ public class Hero extends Char { } if (wepDr > 0) dr += wepDr; } + Barkskin bark = buff(Barkskin.class); if (bark != null) dr += Random.NormalIntRange( 0 , bark.level() ); - + + Blocking.BlockBuff block = buff(Blocking.BlockBuff.class); + if (block != null) dr += block.blockingRoll(); + return dr; } 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 4b3f2d413..f0326b5d0 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 @@ -50,6 +50,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.TimekeepersHourg import com.shatteredpixel.shatteredpixeldungeon.items.rings.Ring; import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfWealth; import com.shatteredpixel.shatteredpixeldungeon.items.stones.StoneOfAggression; +import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Lucky; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.MissileWeapon; import com.shatteredpixel.shatteredpixeldungeon.levels.features.Chasm; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; @@ -612,8 +613,6 @@ public abstract class Mob extends Char { if (EXP % 2 == 1) EXP += Random.Int(2); EXP /= 2; } - - super.die( cause ); if (alignment == Alignment.ENEMY){ rollToDropLoot(); @@ -622,6 +621,8 @@ public abstract class Mob extends Char { if (Dungeon.hero.isAlive() && !Dungeon.level.heroFOV[pos]) { GLog.i( Messages.get(this, "died") ); } + + super.die( cause ); } public void rollToDropLoot(){ @@ -646,13 +647,19 @@ public abstract class Mob extends Char { if (bonus != null && !bonus.isEmpty()) { for (Item b : bonus) Dungeon.level.drop(b, pos).sprite.drop(); if (RingOfWealth.latestDropWasRare){ - new Flare(8, 48).color(0xAA00FF, true).show(sprite, 2f); + new Flare(8, 48).color(0xAA00FF, true).show(sprite, 3f); RingOfWealth.latestDropWasRare = false; } else { - new Flare(8, 24).color(0xFFFFFF, true).show(sprite, 2f); + new Flare(8, 24).color(0xFFFFFF, true).show(sprite, 3f); } } } + + //lucky enchant logic + if (Dungeon.hero.lvl <= maxLvl && buff(Lucky.LuckProc.class) != null){ + new Flare(8, 24).color(0x00FF00, true).show(sprite, 3f); + Dungeon.level.drop(Lucky.genLoot(), pos).sprite.drop(); + } } protected Object loot = null; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Statue.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Statue.java index 58daaa02c..20579fc95 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Statue.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Statue.java @@ -23,10 +23,13 @@ package com.shatteredpixel.shatteredpixeldungeon.actors.mobs; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; +import com.shatteredpixel.shatteredpixeldungeon.effects.Speck; import com.shatteredpixel.shatteredpixeldungeon.items.Generator; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon.Enchantment; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Grim; +import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Precise; +import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Unstable; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MeleeWeapon; import com.shatteredpixel.shatteredpixeldungeon.journal.Notes; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; @@ -89,6 +92,16 @@ public class Statue extends Mob { @Override public int attackSkill( Char target ) { + if (weapon.hasEnchant(Precise.class, this) + || (weapon.hasEnchant(Unstable.class, this) && Random.Int(11) == 0)){ + if (Precise.rollToGuaranteeHit(weapon)){ + target.sprite.emitter().start( Speck.factory(Speck.LIGHT), 0.05f, 5 ); + return Integer.MAX_VALUE; + } + if (weapon.hasEnchant(Unstable.class, this)){ + Unstable.justRolledPrecise = true; + } + } return (int)((9 + Dungeon.depth) * weapon.accuracyFactor(this)); } 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 52f4eb52d..8485a50e0 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 @@ -43,6 +43,8 @@ import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor; import com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.AntiMagic; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfRetribution; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.exotic.ScrollOfPsionicBlast; +import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Precise; +import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Unstable; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MeleeWeapon; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.Boomerang; import com.shatteredpixel.shatteredpixeldungeon.levels.Level; @@ -492,6 +494,19 @@ public class DriedRose extends Artifact { @Override public int attackSkill(Char target) { + + if (rose != null && rose.weapon != null + && (rose.weapon.hasEnchant(Precise.class, this) + || rose.weapon.hasEnchant(Unstable.class, this) && Random.Int(11) == 0)){ + if (Precise.rollToGuaranteeHit(rose.weapon)){ + target.sprite.emitter().start( Speck.factory(Speck.LIGHT), 0.05f, 5 ); + return Integer.MAX_VALUE; + } + if (rose.weapon.hasEnchant(Unstable.class, this)){ + Unstable.justRolledPrecise = true; + } + } + //same accuracy as the hero. int acc = Dungeon.hero.lvl + 9; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfBlastWave.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfBlastWave.java index e1d4c4787..41ee068f1 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfBlastWave.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfBlastWave.java @@ -29,6 +29,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Paralysis; import com.shatteredpixel.shatteredpixeldungeon.effects.Effects; import com.shatteredpixel.shatteredpixeldungeon.effects.MagicMissile; import com.shatteredpixel.shatteredpixeldungeon.effects.Pushing; +import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Elastic; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MagesStaff; import com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; @@ -147,18 +148,8 @@ public class WandOfBlastWave extends DamageWand { } @Override - //behaves just like glyph of Repulsion public void onHit(MagesStaff staff, Char attacker, Char defender, int damage) { - int level = Math.max(0, staff.level()); - - // lvl 0 - 25% - // lvl 1 - 40% - // lvl 2 - 50% - if (Random.Int( level + 4 ) >= 3){ - int oppositeHero = defender.pos + (defender.pos - attacker.pos); - Ballistica trajectory = new Ballistica(defender.pos, oppositeHero, Ballistica.MAGIC_BOLT); - throwChar(defender, trajectory, 2); - } + new Elastic().proc(staff, attacker, defender, damage); } @Override diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfRegrowth.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfRegrowth.java index 7ec3b865c..cf2b3f5c3 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfRegrowth.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfRegrowth.java @@ -27,17 +27,16 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob; import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Regrowth; -import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; import com.shatteredpixel.shatteredpixeldungeon.effects.MagicMissile; import com.shatteredpixel.shatteredpixeldungeon.items.Dewdrop; import com.shatteredpixel.shatteredpixeldungeon.items.Generator; +import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Blooming; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MagesStaff; import com.shatteredpixel.shatteredpixeldungeon.levels.Level; import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; import com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica; import com.shatteredpixel.shatteredpixeldungeon.plants.Plant; import com.shatteredpixel.shatteredpixeldungeon.plants.Starflower; -import com.shatteredpixel.shatteredpixeldungeon.plants.Sungrass; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; import com.watabou.noosa.audio.Sample; @@ -193,18 +192,7 @@ public class WandOfRegrowth extends Wand { @Override public void onHit(MagesStaff staff, Char attacker, Char defender, int damage) { - //like pre-nerf vampiric enchantment, except with herbal healing buff - - int level = Math.max( 0, staff.level() ); - - // lvl 0 - 33% - // lvl 1 - 43% - // lvl 2 - 50% - int maxValue = damage * (level + 2) / (level + 6); - int effValue = Math.min( Random.IntRange(0, maxValue), attacker.HT - attacker.HP ); - - Buff.affect(attacker, Sungrass.Health.class).boost( effValue ); - + new Blooming().proc(staff, attacker, defender, damage); } protected void fx( Ballistica bolt, Callback callback ) { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/Weapon.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/Weapon.java index 44b030bf5..6df06ee26 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/Weapon.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/Weapon.java @@ -32,25 +32,23 @@ import com.shatteredpixel.shatteredpixeldungeon.items.KindOfWeapon; import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfFuror; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.curses.Annoying; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.curses.Displacing; -import com.shatteredpixel.shatteredpixeldungeon.items.weapon.curses.Elastic; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.curses.Exhausting; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.curses.Fragile; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.curses.Friendly; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.curses.Sacrificial; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.curses.Wayward; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Blazing; +import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Blocking; +import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Blooming; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Chilling; -import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Dazzling; -import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Eldritch; +import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Elastic; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Grim; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Lucky; +import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Precise; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Projecting; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Shocking; -import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Stunning; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Unstable; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Vampiric; -import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Venomous; -import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Vorpal; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; @@ -297,14 +295,14 @@ abstract public class Weapon extends KindOfWeapon { public static abstract class Enchantment implements Bundlable { private static final Class[] common = new Class[]{ - Blazing.class, Venomous.class, Vorpal.class, Shocking.class}; + Blazing.class, Chilling.class, Shocking.class, Blooming.class}; private static final Class[] uncommon = new Class[]{ - Chilling.class, Eldritch.class, Lucky.class, - Projecting.class, Unstable.class, Dazzling.class}; + /*Swift.class,*/ Elastic.class, Projecting.class, + Unstable.class, Precise.class, Blocking.class}; private static final Class[] rare = new Class[]{ - Grim.class, Stunning.class, Vampiric.class}; + Grim.class, Vampiric.class, Lucky.class}; private static final float[] typeChances = new float[]{ 50, //12.5% each @@ -314,7 +312,7 @@ abstract public class Weapon extends KindOfWeapon { private static final Class[] curses = new Class[]{ Annoying.class, Displacing.class, Exhausting.class, Fragile.class, - Sacrificial.class, Wayward.class, Elastic.class, Friendly.class + Sacrificial.class, Wayward.class, /*Shifting.class,*/ Friendly.class }; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/curses/Elastic.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/curses/Shifting.java similarity index 72% rename from core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/curses/Elastic.java rename to core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/curses/Shifting.java index 2c80969ce..959cf8cc7 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/curses/Elastic.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/curses/Shifting.java @@ -3,7 +3,7 @@ * Copyright (C) 2012-2015 Oleg Dolya * * Shattered Pixel Dungeon - * Copyright (C) 2014-2019 Evan Debenham + * Copyright (C) 2014-2018 Evan Debenham * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,23 +22,17 @@ package com.shatteredpixel.shatteredpixeldungeon.items.weapon.curses; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; -import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfBlastWave; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon; -import com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; -public class Elastic extends Weapon.Enchantment { +public class Shifting extends Weapon.Enchantment { private static ItemSprite.Glowing BLACK = new ItemSprite.Glowing( 0x000000 ); @Override - public int proc(Weapon weapon, Char attacker, Char defender, int damage ) { - - int oppositeDefender = defender.pos + (defender.pos - attacker.pos); - Ballistica trajectory = new Ballistica(defender.pos, oppositeDefender, Ballistica.MAGIC_BOLT); - WandOfBlastWave.throwChar(defender, trajectory, 2); - - return 0; + public int proc(Weapon weapon, Char attacker, Char defender, int damage) { + //TODO implement + return damage; } @Override @@ -50,5 +44,4 @@ public class Elastic extends Weapon.Enchantment { public ItemSprite.Glowing glowing() { return BLACK; } - } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Blazing.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Blazing.java index 12c482b7a..a4071688d 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Blazing.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Blazing.java @@ -21,6 +21,7 @@ package com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments; +import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Burning; @@ -43,10 +44,11 @@ public class Blazing extends Weapon.Enchantment { if (Random.Int( level + 3 ) >= 2) { - if (Random.Int( 2 ) == 0) { - Buff.affect( defender, Burning.class ).reignite( defender ); + if (defender.buff(Burning.class) != null || Dungeon.level.flamable[defender.pos]){ + Buff.affect(defender, Burning.class).reignite(defender, 8f); + } else { + Buff.affect(defender, Burning.class).reignite(defender, 4f); } - defender.damage( Random.Int( 1, level + 2 ), this ); defender.sprite.emitter().burst( FlameParticle.FACTORY, level + 1 ); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Blocking.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Blocking.java new file mode 100644 index 000000000..20bad2d02 --- /dev/null +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Blocking.java @@ -0,0 +1,101 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * Shattered Pixel Dungeon + * Copyright (C) 2014-2018 Evan Debenham + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see + */ + +package com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments; + +import com.shatteredpixel.shatteredpixeldungeon.actors.Char; +import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; +import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.FlavourBuff; +import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon; +import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; +import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; +import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator; +import com.watabou.noosa.Image; +import com.watabou.utils.Bundle; +import com.watabou.utils.Random; + +public class Blocking extends Weapon.Enchantment { + + private static ItemSprite.Glowing BLUE = new ItemSprite.Glowing( 0x0000FF ); + + @Override + public int proc(Weapon weapon, Char attacker, Char defender, int damage) { + + int level = Math.max( 0, weapon.level() ); + + Buff.prolong(attacker, BlockBuff.class, 1 + level/2).setBlocking(level + 1); + + return damage; + } + + @Override + public ItemSprite.Glowing glowing() { + return BLUE; + } + + public static class BlockBuff extends FlavourBuff { + + private int blocking = 0; + + public void setBlocking( int blocking ){ + this.blocking = blocking; + } + + public int blockingRoll(){ + return Random.NormalIntRange(0, blocking); + } + + @Override + public int icon() { + return BuffIndicator.ARMOR; + } + + @Override + public void tintIcon(Image icon) { + icon.tint(0, 0.5f, 1, 0.5f); + } + + @Override + public String toString() { + return Messages.get(this, "name"); + } + + @Override + public String desc() { + return Messages.get(this, "desc", blocking, dispTurns()); + } + + private static final String BLOCKING = "blocking"; + + @Override + public void storeInBundle(Bundle bundle) { + super.storeInBundle(bundle); + bundle.put(BLOCKING, blocking); + } + + @Override + public void restoreFromBundle(Bundle bundle) { + super.restoreFromBundle(bundle); + blocking = bundle.getInt(BLOCKING); + } + + } +} diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Venomous.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Blooming.java similarity index 51% rename from core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Venomous.java rename to core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Blooming.java index 7f265f32e..c1eb8167c 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Venomous.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Blooming.java @@ -3,7 +3,7 @@ * Copyright (C) 2012-2015 Oleg Dolya * * Shattered Pixel Dungeon - * Copyright (C) 2014-2019 Evan Debenham + * Copyright (C) 2014-2018 Evan Debenham * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,22 +21,27 @@ package com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments; +import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; -import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; -import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Poison; import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter; -import com.shatteredpixel.shatteredpixeldungeon.effects.particles.PoisonParticle; +import com.shatteredpixel.shatteredpixeldungeon.effects.particles.LeafParticle; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon; +import com.shatteredpixel.shatteredpixeldungeon.levels.Level; +import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; +import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; -import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite.Glowing; +import com.watabou.utils.PathFinder; import com.watabou.utils.Random; -public class Venomous extends Weapon.Enchantment { +import java.util.ArrayList; - private static ItemSprite.Glowing PURPLE = new ItemSprite.Glowing( 0x4400AA ); +public class Blooming extends Weapon.Enchantment { + + private static ItemSprite.Glowing DARK_GREEN = new ItemSprite.Glowing( 0x008800 ); @Override - public int proc( Weapon weapon, Char attacker, Char defender, int damage ) { + public int proc(Weapon weapon, Char attacker, Char defender, int damage) { + // lvl 0 - 33% // lvl 1 - 50% // lvl 2 - 60% @@ -44,16 +49,38 @@ public class Venomous extends Weapon.Enchantment { if (Random.Int( level + 3 ) >= 2) { - Buff.affect( defender, Poison.class ).extend( ((level/2) + 1) ); - CellEmitter.center(defender.pos).burst( PoisonParticle.SPLASH, 5 ); - + if (!plantGrass(defender.pos)){ + ArrayList positions = new ArrayList<>(); + for (int i : PathFinder.NEIGHBOURS8){ + positions.add(i); + } + Random.shuffle( positions ); + for (int i : positions){ + if (plantGrass(defender.pos + i)){ + break; + } + } + } + } - + return damage; } + private boolean plantGrass(int cell){ + int c = Dungeon.level.map[cell]; + if ( c == Terrain.EMPTY || c == Terrain.EMPTY_DECO + || c == Terrain.EMBERS || c == Terrain.GRASS){ + Level.set(cell, Terrain.HIGH_GRASS); + GameScene.updateMap(cell); + CellEmitter.get( cell ).burst( LeafParticle.LEVEL_SPECIFIC, 4 ); + return true; + } + return false; + } + @Override - public Glowing glowing() { - return PURPLE; + public ItemSprite.Glowing glowing() { + return DARK_GREEN; } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Chilling.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Chilling.java index a882e0d26..acc51406b 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Chilling.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Chilling.java @@ -36,15 +36,15 @@ public class Chilling extends Weapon.Enchantment { @Override public int proc( Weapon weapon, Char attacker, Char defender, int damage ) { - // lvl 0 - 20% - // lvl 1 - 33% - // lvl 2 - 43% + // lvl 0 - 33% + // lvl 1 - 50% + // lvl 2 - 60% int level = Math.max( 0, weapon.level() ); - if (Random.Int( level + 5 ) >= 4) { + if (Random.Int( level + 3 ) >= 2) { //FIXME this should probably stack chilled - Buff.prolong( defender, Chill.class, Random.Float( 2f, 3f ) ); + Buff.affect( defender, Chill.class, 3f + level/4f ); Splash.at( defender.sprite.center(), 0xFFB2D6FF, 5); } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Dazzling.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Elastic.java similarity index 65% rename from core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Dazzling.java rename to core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Elastic.java index 21bba8290..566d1caa0 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Dazzling.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Elastic.java @@ -3,7 +3,7 @@ * Copyright (C) 2012-2015 Oleg Dolya * * Shattered Pixel Dungeon - * Copyright (C) 2014-2019 Evan Debenham + * Copyright (C) 2014-2018 Evan Debenham * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,39 +22,35 @@ package com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; -import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Blindness; -import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; -import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Cripple; -import com.shatteredpixel.shatteredpixeldungeon.effects.Speck; +import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfBlastWave; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon; +import com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; import com.watabou.utils.Random; -public class Dazzling extends Weapon.Enchantment { - - private static ItemSprite.Glowing YELLOW = new ItemSprite.Glowing( 0xFFFF00 ); - +public class Elastic extends Weapon.Enchantment { + + private static ItemSprite.Glowing PINK = new ItemSprite.Glowing( 0xFF00FF ); + @Override - public int proc(Weapon weapon, Char attacker, Char defender, int damage) { + public int proc(Weapon weapon, Char attacker, Char defender, int damage ) { // lvl 0 - 20% // lvl 1 - 33% // lvl 2 - 43% int level = Math.max( 0, weapon.level() ); - + if (Random.Int( level + 5 ) >= 4) { - - Buff.prolong( defender, Blindness.class, Random.Float( 1f, 1f + level ) ); - Buff.prolong( defender, Cripple.class, Random.Float( 1f, 1f + level/2f ) ); - defender.sprite.emitter().burst(Speck.factory(Speck.LIGHT), 6 ); - + int oppositeDefender = defender.pos + (defender.pos - attacker.pos); + Ballistica trajectory = new Ballistica(defender.pos, oppositeDefender, Ballistica.MAGIC_BOLT); + WandOfBlastWave.throwChar(defender, trajectory, 2); } - + return damage; } - + @Override public ItemSprite.Glowing glowing() { - return YELLOW; + return PINK; } -} \ No newline at end of file +} diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Eldritch.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Eldritch.java deleted file mode 100644 index c57a98638..000000000 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Eldritch.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Pixel Dungeon - * Copyright (C) 2012-2015 Oleg Dolya - * - * Shattered Pixel Dungeon - * Copyright (C) 2014-2019 Evan Debenham - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see - */ - -package com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments; - -import com.shatteredpixel.shatteredpixeldungeon.Dungeon; -import com.shatteredpixel.shatteredpixeldungeon.actors.Char; -import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; -import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Terror; -import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Vertigo; -import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon; -import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; -import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite.Glowing; -import com.watabou.utils.Random; - -public class Eldritch extends Weapon.Enchantment { - - private static ItemSprite.Glowing GREY = new ItemSprite.Glowing( 0x222222 ); - - @Override - public int proc( Weapon weapon, Char attacker, Char defender, int damage ) { - // lvl 0 - 20% - // lvl 1 - 33% - // lvl 2 - 43% - int level = Math.max( 0, weapon.level() ); - - if (Random.Int( level + 5 ) >= 4) { - - if (defender == Dungeon.hero) { - Buff.affect( defender, Vertigo.class, Vertigo.DURATION ); - } else { - //damage will reduce by 5 turns, so effectively 10 turns of terror - Buff.affect( defender, Terror.class, 10f + 5f ).object = attacker.id(); - } - - } - - return damage; - } - - @Override - public Glowing glowing() { - return GREY; - } -} diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Grim.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Grim.java index 5a1c299df..c8a74da3c 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Grim.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Grim.java @@ -42,15 +42,19 @@ public class Grim extends Weapon.Enchantment { int enemyHealth = defender.HP - damage; if (enemyHealth == 0) return damage; //no point in proccing if they're already dead. - //scales from 0 - 30% based on how low hp the enemy is, plus 1% per level - int chance = Math.round(((defender.HT - enemyHealth) / (float)defender.HT)*30 + level); + //scales from 0 - 40% based on how low hp the enemy is, plus 2% per level + float maxChance = 0.4f + .02f*level; + float chanceMulti = (float)Math.pow( ((defender.HT - enemyHealth) / (float)defender.HT), 2); + float chance = maxChance * chanceMulti; - if (Random.Int( 100 ) < chance) { + if (Random.Float() < chance) { defender.damage( defender.HP, this ); defender.sprite.emitter().burst( ShadowParticle.UP, 5 ); - if (!defender.isAlive() && attacker instanceof Hero) { + if (!defender.isAlive() && attacker instanceof Hero + //this prevents unstable from triggering grim achievement + && weapon.hasEnchant(Grim.class, attacker)) { Badges.validateGrimWeapon(); } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Lucky.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Lucky.java index 3354c5211..6b1afb504 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Lucky.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Lucky.java @@ -23,10 +23,12 @@ package com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; +import com.shatteredpixel.shatteredpixeldungeon.items.Generator; +import com.shatteredpixel.shatteredpixeldungeon.items.Gold; +import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite.Glowing; -import com.watabou.utils.Bundle; import com.watabou.utils.Random; public class Lucky extends Weapon.Enchantment { @@ -37,68 +39,45 @@ public class Lucky extends Weapon.Enchantment { public int proc( Weapon weapon, Char attacker, Char defender, int damage ) { int level = Math.max( 0, weapon.level() ); - float zeroChance = 0.5f; - - Luck buff = attacker.buff(Luck.class); - if (buff != null){ - zeroChance = buff.zeroChance; + //5% chance, + 1% per weapon level + if (defender.HP <= damage && Random.Float() < (0.05f + .01f*level)){ + Buff.affect(defender, LuckProc.class); } - if (Random.Float() >= zeroChance){ - - if (buff != null) { - buff.detach(); - } - - return 2*damage; - } else { - - buff = Buff.affect(attacker, Luck.class); - buff.zeroChance = zeroChance * (0.5f - (0.01f*level)); - - return 0; - } + return damage; } + + public static Item genLoot(){ + float roll = Random.Float(); + if (roll < 0.6f){ + Item result = new Gold().random(); + result.quantity(Math.round(result.quantity() * 0.5f)); + return result; + } else if (roll < 0.9f){ + return Random.Int(2) == 0 + ? Generator.random(Generator.Category.SEED) + : Generator.random(Generator.Category.STONE); + } else { + return Random.Int(2) == 0 + ? Generator.random(Generator.Category.POTION) + : Generator.random(Generator.Category.SCROLL); + } + } @Override public Glowing glowing() { return GREEN; } - - public static class Luck extends Buff { - - float zeroChance; + //used to keep track of whether a luck proc is incoming. see Mob.die() + public static class LuckProc extends Buff { @Override public boolean act() { - - zeroChance += 0.01f; - - if (zeroChance >= 0.5f){ - detach(); - } else { - spend(TICK); - } - + detach(); return true; } - - private static final String CHANCE = "chance"; - - @Override - public void restoreFromBundle(Bundle bundle) { - super.restoreFromBundle(bundle); - zeroChance = bundle.getFloat(CHANCE); - } - - @Override - public void storeInBundle(Bundle bundle) { - super.storeInBundle(bundle); - bundle.put(CHANCE, zeroChance); - } - } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Stunning.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Precise.java similarity index 64% rename from core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Stunning.java rename to core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Precise.java index 4d0757cdb..1186672b9 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Stunning.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Precise.java @@ -3,7 +3,7 @@ * Copyright (C) 2012-2015 Oleg Dolya * * Shattered Pixel Dungeon - * Copyright (C) 2014-2019 Evan Debenham + * Copyright (C) 2014-2018 Evan Debenham * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,37 +22,35 @@ package com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; -import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; -import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Paralysis; -import com.shatteredpixel.shatteredpixeldungeon.effects.Speck; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; -import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite.Glowing; import com.watabou.utils.Random; -public class Stunning extends Weapon.Enchantment { +public class Precise extends Weapon.Enchantment { - private static ItemSprite.Glowing YELLOW = new ItemSprite.Glowing( 0xCCAA44 ); + private static ItemSprite.Glowing WHITE = new ItemSprite.Glowing( 0xFFFFFF ); @Override - public int proc( Weapon weapon, Char attacker, Char defender, int damage ) { + public int proc( Weapon weapon, Char attacker, Char defender, int damage) { + return damage; + } + + //called from attackSkill in Hero, Statue, and GhostHero + public static boolean rollToGuaranteeHit( Weapon weapon ){ // lvl 0 - 13% // lvl 1 - 22% // lvl 2 - 30% int level = Math.max( 0, weapon.level() ); - if (Random.Int( level + 8 ) >= 7) { - - Buff.prolong( defender, Paralysis.class, Random.Float( 1, 1.5f + level ) ); - defender.sprite.emitter().burst(Speck.factory(Speck.LIGHT), 12 ); - + if (Random.Int( level + 80 ) >= 7) { + return true; } - - return damage; + + return false; } @Override - public Glowing glowing() { - return YELLOW; + public ItemSprite.Glowing glowing() { + return WHITE; } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Projecting.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Projecting.java index 46e6af9b7..f836956c8 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Projecting.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Projecting.java @@ -27,7 +27,7 @@ import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; public class Projecting extends Weapon.Enchantment { - private static ItemSprite.Glowing GREY = new ItemSprite.Glowing( 0x888888 ); + private static ItemSprite.Glowing PURPLE = new ItemSprite.Glowing( 0x8844CC ); @Override public int proc(Weapon weapon, Char attacker, Char defender, int damage) { @@ -38,7 +38,7 @@ public class Projecting extends Weapon.Enchantment { @Override public ItemSprite.Glowing glowing() { - return GREY; + return PURPLE; } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Shocking.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Shocking.java index d515b2316..3f64f1318 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Shocking.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Shocking.java @@ -28,6 +28,7 @@ import com.shatteredpixel.shatteredpixeldungeon.effects.Lightning; import com.shatteredpixel.shatteredpixeldungeon.effects.particles.SparkParticle; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; +import com.shatteredpixel.shatteredpixeldungeon.utils.BArray; import com.watabou.utils.PathFinder; import com.watabou.utils.Random; @@ -35,7 +36,7 @@ import java.util.ArrayList; public class Shocking extends Weapon.Enchantment { - private static ItemSprite.Glowing WHITE = new ItemSprite.Glowing( 0xFFFFFF, 0.6f ); + private static ItemSprite.Glowing WHITE = new ItemSprite.Glowing( 0xFFFFFF, 0.5f ); @Override public int proc( Weapon weapon, Char attacker, Char defender, int damage ) { @@ -47,11 +48,15 @@ public class Shocking extends Weapon.Enchantment { if (Random.Int( level + 3 ) >= 2) { affected.clear(); - affected.add(attacker); arcs.clear(); arcs.add(new Lightning.Arc(attacker.sprite.center(), defender.sprite.center())); - hit(defender, Random.Int(1, damage / 3)); + arc(attacker, defender, 2); + + affected.remove(defender); //defender isn't hurt by lightning + for (Char ch : affected) { + ch.damage((int)Math.ceil(damage/3f), this); + } attacker.sprite.parent.addToFront( new Lightning( arcs, null ) ); @@ -70,23 +75,21 @@ public class Shocking extends Weapon.Enchantment { private ArrayList arcs = new ArrayList<>(); - private void hit( Char ch, int damage ) { + private void arc( Char attacker, Char defender, int dist ) { - if (damage < 1) { - return; - } + affected.add(defender); - affected.add(ch); - ch.damage(Dungeon.level.water[ch.pos] && !ch.flying ? 2*damage : damage, this); + defender.sprite.centerEmitter().burst(SparkParticle.FACTORY, 3); + defender.sprite.flash(); - ch.sprite.centerEmitter().burst(SparkParticle.FACTORY, 3); - ch.sprite.flash(); - - for (int i = 0; i < PathFinder.NEIGHBOURS8.length; i++) { - Char n = Actor.findChar( ch.pos + PathFinder.NEIGHBOURS8[i] ); - if (n != null && !affected.contains( n )) { - arcs.add(new Lightning.Arc(ch.sprite.center(), n.sprite.center())); - hit(n, Random.Int(damage / 2, damage)); + PathFinder.buildDistanceMap( defender.pos, BArray.not( Dungeon.level.solid, null ), dist ); + for (int i = 0; i < PathFinder.distance.length; i++) { + if (PathFinder.distance[i] < Integer.MAX_VALUE) { + Char n = Actor.findChar(i); + if (n != null && n != attacker && !affected.contains(n)) { + arcs.add(new Lightning.Arc(defender.sprite.center(), n.sprite.center())); + arc(attacker, n, (Dungeon.level.water[n.pos] && !n.flying) ? 2 : 1); + } } } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Vorpal.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Swift.java similarity index 60% rename from core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Vorpal.java rename to core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Swift.java index be5e51bd9..72f107fc3 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Vorpal.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Swift.java @@ -3,7 +3,7 @@ * Copyright (C) 2012-2015 Oleg Dolya * * Shattered Pixel Dungeon - * Copyright (C) 2014-2019 Evan Debenham + * Copyright (C) 2014-2018 Evan Debenham * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,39 +22,23 @@ package com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; -import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Bleeding; -import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; -import com.shatteredpixel.shatteredpixeldungeon.effects.Splash; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; -import com.watabou.utils.PointF; -import com.watabou.utils.Random; - -public class Vorpal extends Weapon.Enchantment { - - private static ItemSprite.Glowing RED = new ItemSprite.Glowing( 0xAA6666 ); +public class Swift extends Weapon.Enchantment { + + private static ItemSprite.Glowing YELLOW = new ItemSprite.Glowing( 0xFFFF00 ); + @Override public int proc(Weapon weapon, Char attacker, Char defender, int damage) { - // lvl 0 - 33% - // lvl 1 - 50% - // lvl 2 - 60% - int level = Math.max( 0, weapon.level() ); - - if (Random.Int( level + 3 ) >= 2) { - - Buff.affect(defender, Bleeding.class).set(damage/5f); - Splash.at( defender.sprite.center(), -PointF.PI / 2, PointF.PI / 6, - defender.sprite.blood(), 10 ); - - } - + + + return damage; } - + @Override public ItemSprite.Glowing glowing() { - return RED; + return YELLOW; } - } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Unstable.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Unstable.java index c006222f8..a3a60b86c 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Unstable.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Unstable.java @@ -29,25 +29,32 @@ import com.watabou.utils.Random; public class Unstable extends Weapon.Enchantment { - private static ItemSprite.Glowing WHITE = new ItemSprite.Glowing( 0xFFFFFF ); + private static ItemSprite.Glowing GREY = new ItemSprite.Glowing( 0x999999 ); private static Class[] randomEnchants = new Class[]{ Blazing.class, + Blocking.class, + Blooming.class, Chilling.class, - Dazzling.class, - Eldritch.class, + Elastic.class, Grim.class, Lucky.class, + //precise also not included here, is manually check in attackSkill //projecting not included, no on-hit effect Shocking.class, - Stunning.class, - Vampiric.class, - Venomous.class, - Vorpal.class + //Swift.class, + Vampiric.class }; + + public static boolean justRolledPrecise; @Override public int proc( Weapon weapon, Char attacker, Char defender, int damage ) { + if (justRolledPrecise){ + justRolledPrecise = false; + return damage; + } + try { return Random.oneOf(randomEnchants).newInstance().proc( weapon, attacker, defender, damage ); } catch (Exception e) { @@ -58,6 +65,6 @@ public class Unstable extends Weapon.Enchantment { @Override public ItemSprite.Glowing glowing() { - return WHITE; + return GREY; } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Vampiric.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Vampiric.java index 81cc47803..bdc318a7d 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Vampiric.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Vampiric.java @@ -27,7 +27,6 @@ import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon; import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite.Glowing; -import com.watabou.utils.Random; public class Vampiric extends Weapon.Enchantment { @@ -36,19 +35,16 @@ public class Vampiric extends Weapon.Enchantment { @Override public int proc( Weapon weapon, Char attacker, Char defender, int damage ) { - int level = Math.max( 0, weapon.level() ); + //heals for 0-10% of damage dealt, based on missing HP + float missingPercent = (attacker.HT - attacker.HP) / (float)defender.HT; + float healValue = missingPercent * 0.1f; + int healAmt = Math.round(healValue * damage); - // lvl 0 - 16% - // lvl 1 - 17.65% - // lvl 2 - 19.23% - int maxValue = Math.round(damage * ((level + 8) / (float)(level + 50))); - int effValue = Math.min( Random.IntRange( 0, maxValue ), attacker.HT - attacker.HP ); + if (healAmt > 0) { - if (effValue > 0) { - - attacker.HP += effValue; + attacker.HP += healAmt; attacker.sprite.emitter().start( Speck.factory( Speck.HEALING ), 0.4f, 1 ); - attacker.sprite.showStatus( CharSprite.POSITIVE, Integer.toString( effValue ) ); + attacker.sprite.showStatus( CharSprite.POSITIVE, Integer.toString( healAmt ) ); } diff --git a/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties b/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties index 93901e3c0..ccfed7ac0 100644 --- a/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties +++ b/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties @@ -1143,9 +1143,6 @@ items.weapon.curses.annoying.desc=Annoying weapons are capable of speech, but th items.weapon.curses.displacing.name=displacing %s items.weapon.curses.displacing.desc=Displacing weapons are infused with chaotic teleportation magic, possessing the ability to warp enemies around the floor randomly. -items.weapon.curses.elastic.name=elastic %s -items.weapon.curses.elastic.desc=Elastic weapons aren't able to deal any damage, but can send enemies flying back short distances. - items.weapon.curses.exhausting.name=exhausting %s items.weapon.curses.exhausting.desc=Exhausting weapons take great effort to use, and will periodically weaken the wearer as a result. @@ -1166,20 +1163,28 @@ items.weapon.curses.wayward.desc=A wayward weapon has a very hard time finding i items.weapon.enchantments.blazing.name=blazing %s items.weapon.enchantments.blazing.desc=This enchantment causes flames to spit forth from a weapon, burning enemies and terrain alike. +items.weapon.enchantments.blocking.name=blocking %s +items.weapon.enchantments.blocking.desc=This enchantment will enhance your ability to defend yourself after attacking with this weapon. +items.weapon.enchantments.blocking$blockbuff.name=Blocking +items.weapon.enchantments.blocking$blockbuff.desc=Your weapon's blocking enchantment has given you a short boost of defensive power!\n\nBlocking boost: 0-%d\n\nTurns remaining: %s. + +items.weapon.enchantments.blooming.name=blooming %s +items.weapon.enchantments.blooming.desc=Blooming weapons contain magic which will cause vegetation to sprout on or around those struck by it. + items.weapon.enchantments.chilling.name=chilling %s items.weapon.enchantments.chilling.desc=Enemies struck with this enchantment are chilled, slowing their movement and attacks. -items.weapon.enchantments.dazzling.name=dazzling %s -items.weapon.enchantments.dazzling.desc=This enchantment dazes enemies when they are struck, rendering them blind for a short time. - -items.weapon.enchantments.eldritch.name=eldritch %s -items.weapon.enchantments.eldritch.desc=Eldritch weapons strike fear into enemies, causing them to flee from the attacker. +items.weapon.enchantments.elastic.name=elastic %s +items.weapon.enchantments.elastic.desc=Elastic weapons have a chance to send enemies flying back short distances. items.weapon.enchantments.grim.name=grim %s items.weapon.enchantments.grim.desc=This powerful enchantment possesses the power to instantly execute an enemy. The effect is more likely to occur the weaker the enemy is. items.weapon.enchantments.lucky.name=lucky %s -items.weapon.enchantments.lucky.desc=A lucky weapon will deal either double damage or no damage. The odds become tipped in your favour every time an attack deals no damage. +items.weapon.enchantments.lucky.desc=This powerful enchantment increases the fortune of whoever wields it. Enemies which are killed with a lucky weapon have a chance to drop extra loot. + +items.weapon.enchantments.precise.name=precise %s +items.weapon.enchantments.precise.desc=A precise weapon has a chance to guarantee a hit on an enemy, regardless of the circumstances. items.weapon.enchantments.projecting.name=projecting %s items.weapon.enchantments.projecting.desc=With this enchantment melee weapons will gain extra reach. Ranged weapons will be able to penetrate nearby walls. @@ -1187,9 +1192,6 @@ items.weapon.enchantments.projecting.desc=With this enchantment melee weapons wi items.weapon.enchantments.shocking.name=shocking %s items.weapon.enchantments.shocking.desc=Electricity arcs from a shocking weapon, dealing extra damage to all nearby enemies. -items.weapon.enchantments.stunning.name=stunning %s -items.weapon.enchantments.stunning.desc=This powerful enchantment immobilizes enemies when they are struck, rendering them helpless against further attacks. - items.weapon.enchantments.unstable.name=unstable %s items.weapon.enchantments.unstable.desc=This enchantment radiates chaotic energy, acting as a different enchantment with each hit.