From e3a3428f97ea17a3cd425982a12b16f68970bffa Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Fri, 3 Jun 2016 21:47:36 -0400 Subject: [PATCH] v0.4.0: reworked enchants --- .../actors/buffs/Bleeding.java | 2 +- .../actors/buffs/Poison.java | 6 +- .../shatteredpixeldungeon/items/Item.java | 6 +- .../items/KindOfWeapon.java | 3 +- .../items/quest/Pickaxe.java | 3 +- .../items/weapon/Weapon.java | 27 +++++---- .../items/weapon/enchantments/Blazing.java | 11 ++-- .../items/weapon/enchantments/Chilling.java | 25 ++++---- .../items/weapon/enchantments/Dazzling.java | 57 +++++++++++++++++++ .../items/weapon/enchantments/Eldritch.java | 9 ++- .../items/weapon/enchantments/Grim.java | 22 +++---- .../items/weapon/enchantments/Lucky.java | 17 ++---- .../items/weapon/enchantments/Projecting.java | 43 ++++++++++++++ .../items/weapon/enchantments/Shocking.java | 29 ++++++---- .../items/weapon/enchantments/Stunning.java | 15 ++--- .../items/weapon/enchantments/Unstable.java | 10 +++- .../items/weapon/enchantments/Vampiric.java | 16 +++--- .../items/weapon/enchantments/Venomous.java | 13 ++--- .../items/weapon/enchantments/Vorpal.java | 55 ++++++++++++++++++ .../items/weapon/melee/MagesStaff.java | 4 +- .../items/weapon/missiles/Boomerang.java | 4 +- .../items/weapon/missiles/CurareDart.java | 4 +- .../items/weapon/missiles/IncendiaryDart.java | 4 +- .../items/weapon/missiles/Javelin.java | 4 +- .../items/weapon/missiles/MissileWeapon.java | 22 ++++++- .../items/weapon/missiles/Tamahawk.java | 4 +- .../messages/items/items.properties | 8 ++- .../sprites/ItemSprite.java | 2 - 28 files changed, 309 insertions(+), 116 deletions(-) create mode 100644 src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Dazzling.java create mode 100644 src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Projecting.java create mode 100644 src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Vorpal.java diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Bleeding.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Bleeding.java index 612b0a2c1..6fe9a5b82 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Bleeding.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Bleeding.java @@ -53,7 +53,7 @@ public class Bleeding extends Buff { } public void set( int level ) { - this.level = level; + this.level = Math.max(this.level, level); } @Override diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Poison.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Poison.java index e5ea28e3b..4994c7ebd 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Poison.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Poison.java @@ -56,7 +56,11 @@ public class Poison extends Buff implements Hero.Doom { } public void set( float duration ) { - this.left = duration; + this.left = Math.max(duration, left); + } + + public void extend( float duration ) { + this.left += duration; } @Override diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/Item.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/Item.java index 7cda82bb1..d93edfd4c 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/Item.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/Item.java @@ -469,10 +469,14 @@ public class Item implements Bundlable { } } } + + protected int throwPos( Hero user, int dst){ + return new Ballistica( user.pos, dst, Ballistica.PROJECTILE ).collisionPos; + } public void cast( final Hero user, int dst ) { - final int cell = new Ballistica( user.pos, dst, Ballistica.PROJECTILE ).collisionPos; + final int cell = throwPos( user, dst ); user.sprite.zap( cell ); user.busy(); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/KindOfWeapon.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/KindOfWeapon.java index 07f9e9c6f..d60d33265 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/KindOfWeapon.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/KindOfWeapon.java @@ -108,7 +108,8 @@ abstract public class KindOfWeapon extends EquipableItem { return 0; } - public void proc( Char attacker, Char defender, int damage ) { + public int proc( Char attacker, Char defender, int damage ) { + return damage; } } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/quest/Pickaxe.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/quest/Pickaxe.java index 9023a7440..5a99979a3 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/quest/Pickaxe.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/quest/Pickaxe.java @@ -152,11 +152,12 @@ public class Pickaxe extends Weapon { } @Override - public void proc( Char attacker, Char defender, int damage ) { + public int proc( Char attacker, Char defender, int damage ) { if (!bloodStained && defender instanceof Bat && (defender.HP <= damage)) { bloodStained = true; updateQuickslot(); } + return damage; } private static final String BLOODSTAINED = "bloodStained"; diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/Weapon.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/Weapon.java index a1023a5e1..16703423b 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/Weapon.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/Weapon.java @@ -31,14 +31,17 @@ import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfFuror; import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfSharpshooting; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Blazing; 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.Grim; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Lucky; +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.items.weapon.melee.MeleeWeapon; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.MissileWeapon; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; @@ -68,10 +71,10 @@ abstract public class Weapon extends KindOfWeapon { public Enchantment enchantment; @Override - public void proc( Char attacker, Char defender, int damage ) { + public int proc( Char attacker, Char defender, int damage ) { if (enchantment != null) { - enchantment.proc( this, attacker, defender, damage ); + damage = enchantment.proc( this, attacker, defender, damage ); } if (!levelKnown) { @@ -81,6 +84,8 @@ abstract public class Weapon extends KindOfWeapon { Badges.validateItemLevelAquired( this ); } } + + return damage; } private static final String UNFAMILIRIARITY = "unfamiliarity"; @@ -149,7 +154,7 @@ abstract public class Weapon extends KindOfWeapon { @Override public int reachFactor(Hero hero) { - return RCH; + return enchantment instanceof Projecting ? RCH+1 : RCH; } @Override @@ -246,11 +251,15 @@ abstract public class Weapon extends KindOfWeapon { public static abstract class Enchantment implements Bundlable { private static final Class[] enchants = new Class[]{ - Blazing.class, Venomous.class, Grim.class, Stunning.class, Vampiric.class, - Chilling.class, Shocking.class, Unstable.class, Eldritch.class, Lucky.class }; - private static final float[] chances= new float[]{ 10, 10, 1, 2, 1, 2, 6, 3, 2, 2 }; + Blazing.class, Venomous.class, Vorpal.class, Shocking.class, + Chilling.class, Eldritch.class, Lucky.class, Projecting.class, Unstable.class, Dazzling.class, + Grim.class, Stunning.class, Vampiric.class,}; + private static final float[] chances= new float[]{ + 10, 10, 10, 10, + 5, 5, 5, 5, 5, 5, + 2, 2, 2 }; - public abstract boolean proc( Weapon weapon, Char attacker, Char defender, int damage ); + public abstract int proc( Weapon weapon, Char attacker, Char defender, int damage ); public String name( String weaponName ) { return Messages.get(this, "name", weaponName); @@ -264,9 +273,7 @@ abstract public class Weapon extends KindOfWeapon { public void storeInBundle( Bundle bundle ) { } - public ItemSprite.Glowing glowing() { - return ItemSprite.Glowing.WHITE; - } + public abstract ItemSprite.Glowing glowing(); @SuppressWarnings("unchecked") public static Enchantment random() { diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Blazing.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Blazing.java index 7f5f1cb74..74e34c17a 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Blazing.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Blazing.java @@ -34,7 +34,7 @@ public class Blazing extends Weapon.Enchantment { private static ItemSprite.Glowing ORANGE = new ItemSprite.Glowing( 0xFF4400 ); @Override - public boolean 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% @@ -49,13 +49,10 @@ public class Blazing extends Weapon.Enchantment { defender.sprite.emitter().burst( FlameParticle.FACTORY, level + 1 ); - return true; - - } else { - - return false; - } + + return damage; + } @Override diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Chilling.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Chilling.java index 20f607205..53b5f2147 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Chilling.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Chilling.java @@ -30,29 +30,28 @@ import com.watabou.utils.Random; public class Chilling extends Weapon.Enchantment { - private static ItemSprite.Glowing BLUE = new ItemSprite.Glowing( 0x0044FF ); + private static ItemSprite.Glowing TEAL = new ItemSprite.Glowing( 0x00FFFF ); @Override - public boolean proc( Weapon weapon, Char attacker, Char defender, int damage ) { - // lvl 0 - 25% - // lvl 1 - 40% - // lvl 2 - 50% + 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 + 4 ) >= 3) { + if (Random.Int( level + 5 ) >= 4) { - Buff.affect( defender, Chill.class, - Random.Float( 1, 3f ) ); - - return true; - } else { - return false; + Buff.prolong( defender, Chill.class, + Random.Float( 2f, 3f ) ); + } + + return damage; } @Override public Glowing glowing() { - return BLUE; + return TEAL; } } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Dazzling.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Dazzling.java new file mode 100644 index 000000000..0b0664bb5 --- /dev/null +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Dazzling.java @@ -0,0 +1,57 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * Shattered Pixel Dungeon + * Copyright (C) 2014-2016 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.Blindness; +import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; +import com.shatteredpixel.shatteredpixeldungeon.effects.Speck; +import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon; +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 ); + + @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) { + + Buff.prolong( defender, Blindness.class, Random.Float( 1, 1.5f + level ) ); + defender.sprite.emitter().burst(Speck.factory(Speck.LIGHT), 6 ); + + } + + return damage; + } + + @Override + public ItemSprite.Glowing glowing() { + return YELLOW; + } + +} \ No newline at end of file diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Eldritch.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Eldritch.java index e503c3bad..1c8950fa0 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Eldritch.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Eldritch.java @@ -35,7 +35,7 @@ public class Eldritch extends Weapon.Enchantment { private static ItemSprite.Glowing GREY = new ItemSprite.Glowing( 0x222222 ); @Override - public boolean 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% @@ -48,11 +48,10 @@ public class Eldritch extends Weapon.Enchantment { } else { Buff.affect( defender, Terror.class, Terror.DURATION ).object = attacker.id(); } - - return true; - } else { - return false; + } + + return damage; } @Override diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Grim.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Grim.java index a0ad46f37..34a6f53a0 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Grim.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Grim.java @@ -34,13 +34,17 @@ public class Grim extends Weapon.Enchantment { private static ItemSprite.Glowing BLACK = new ItemSprite.Glowing( 0x000000 ); @Override - public boolean proc( Weapon weapon, Char attacker, Char defender, int damage ) { - // lvl 0 - 8% - // lvl 1 ~ 9% - // lvl 2 ~ 10% + public int proc( Weapon weapon, Char attacker, Char defender, int damage ) { + int level = Math.max( 0, weapon.level() ); + + //half of the attack damage is removed from enemy hp for the purpose of calculating proc chance + int enemyHealth = defender.HP - (Math.max(defender.HP/2, damage)); + + //scales from 0 - 20% based on how low hp the enemy is, plus 1% per level + int chance = Math.round(((defender.HT - enemyHealth) / (float)defender.HT)*20 + level); - if (Random.Int( level + 100 ) >= 92) { + if (Random.Int( 100 ) < chance) { defender.damage( defender.HP, this ); defender.sprite.emitter().burst( ShadowParticle.UP, 5 ); @@ -49,13 +53,9 @@ public class Grim extends Weapon.Enchantment { Badges.validateGrimWeapon(); } - return true; - - } else { - - return false; - } + + return damage; } @Override diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Lucky.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Lucky.java index 02ac6e6d0..18cd2a587 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Lucky.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Lucky.java @@ -24,25 +24,20 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.Char; 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 Lucky extends Weapon.Enchantment { private static ItemSprite.Glowing GREEN = new ItemSprite.Glowing( 0x00FF00 ); @Override - public boolean proc( Weapon weapon, Char attacker, Char defender, int damage ) { + public int proc( Weapon weapon, Char attacker, Char defender, int damage ) { int level = Math.max( 0, weapon.level() ); - - int dmg = damage; - for (int i=1; i <= level+1; i++) { - dmg = Math.max( dmg, attacker.damageRoll() - i ); - } - - if (dmg > damage) { - defender.damage( dmg - damage, this ); - return true; + + if (Random.Int(100) < (50 + level)){ + return weapon.max(); } else { - return false; + return weapon.min(); } } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Projecting.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Projecting.java new file mode 100644 index 000000000..0b3177d48 --- /dev/null +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Projecting.java @@ -0,0 +1,43 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * Shattered Pixel Dungeon + * Copyright (C) 2014-2016 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.items.weapon.Weapon; +import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; + +public class Projecting extends Weapon.Enchantment { + + private static ItemSprite.Glowing GREY = new ItemSprite.Glowing( 0x888888 ); + + @Override + public int proc(Weapon weapon, Char attacker, Char defender, int damage) { + //Does nothing as a proc, instead increases weapon range. + //See weapon.reachFactor, and MissileWeapon.throwPos; + return damage; + } + + @Override + public ItemSprite.Glowing glowing() { + return GREY; + } + +} diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Shocking.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Shocking.java index 494a3a81d..03fa61665 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Shocking.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Shocking.java @@ -27,6 +27,7 @@ import com.shatteredpixel.shatteredpixeldungeon.effects.particles.SparkParticle; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon; import com.shatteredpixel.shatteredpixeldungeon.levels.Level; import com.shatteredpixel.shatteredpixeldungeon.levels.traps.LightningTrap; +import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; import com.watabou.utils.Random; import java.util.ArrayList; @@ -34,31 +35,35 @@ import java.util.HashSet; public class Shocking extends Weapon.Enchantment { + private static ItemSprite.Glowing WHITE = new ItemSprite.Glowing( 0xFFFFFF, 0.5f ); + @Override - public boolean proc( Weapon weapon, Char attacker, Char defender, int damage ) { - // lvl 0 - 25% - // lvl 1 - 40% - // lvl 2 - 50% + 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 + 4 ) >= 3) { + if (Random.Int( level + 3 ) >= 2) { affected.clear(); affected.add(attacker); arcs.clear(); arcs.add(new Lightning.Arc(attacker.pos, defender.pos)); - hit(defender, Random.Int(1, damage / 2)); + hit(defender, Random.Int(1, damage / 3)); attacker.sprite.parent.add( new Lightning( arcs, null ) ); - return true; - - } else { - - return false; - } + + return damage; + + } + + @Override + public ItemSprite.Glowing glowing() { + return WHITE; } private ArrayList affected = new ArrayList<>(); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Stunning.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Stunning.java index ca1da9025..86279fc18 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Stunning.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Stunning.java @@ -22,6 +22,8 @@ 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; @@ -32,7 +34,7 @@ public class Stunning extends Weapon.Enchantment { private static ItemSprite.Glowing YELLOW = new ItemSprite.Glowing( 0xCCAA44 ); @Override - public boolean proc( Weapon weapon, Char attacker, Char defender, int damage ) { + public int proc( Weapon weapon, Char attacker, Char defender, int damage ) { // lvl 0 - 13% // lvl 1 - 22% // lvl 2 - 30% @@ -40,13 +42,12 @@ public class Stunning extends Weapon.Enchantment { if (Random.Int( level + 8 ) >= 7) { - Buff.prolong( defender, com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Paralysis.class, - Random.Float( 1, 1.5f + level ) ); - - return true; - } else { - return false; + Buff.prolong( defender, Paralysis.class, Random.Float( 1, 1.5f + level ) ); + defender.sprite.emitter().burst(Speck.factory(Speck.LIGHT), 12 ); + } + + return damage; } @Override diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Unstable.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Unstable.java index 30638560f..43f81f9f8 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Unstable.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Unstable.java @@ -22,11 +22,19 @@ package com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon; +import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; public class Unstable extends Weapon.Enchantment { + + private static ItemSprite.Glowing WHITE = new ItemSprite.Glowing( 0xFFFFFF ); @Override - public boolean proc( Weapon weapon, Char attacker, Char defender, int damage ) { + public int proc( Weapon weapon, Char attacker, Char defender, int damage ) { return random().proc( weapon, attacker, defender, damage ); } + + @Override + public ItemSprite.Glowing glowing() { + return WHITE; + } } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Vampiric.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Vampiric.java index 8acfa62af..038d2b678 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Vampiric.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Vampiric.java @@ -33,14 +33,14 @@ public class Vampiric extends Weapon.Enchantment { private static ItemSprite.Glowing RED = new ItemSprite.Glowing( 0x660022 ); @Override - public boolean proc( Weapon weapon, Char attacker, Char defender, int damage ) { + public int proc( Weapon weapon, Char attacker, Char defender, int damage ) { int level = Math.max( 0, weapon.level() ); - // lvl 0 - 33% - // lvl 1 - 43% - // lvl 2 - 50% - int maxValue = damage * (level + 2) / (level + 6); + // lvl 0 - 20% + // lvl 1 - 21.5% + // lvl 2 - 23% + int maxValue = Math.round(damage * ((level + 10) / (float)(level + 50))); int effValue = Math.min( Random.IntRange( 0, maxValue ), attacker.HT - attacker.HP ); if (effValue > 0) { @@ -49,11 +49,9 @@ public class Vampiric extends Weapon.Enchantment { attacker.sprite.emitter().start( Speck.factory( Speck.HEALING ), 0.4f, 1 ); attacker.sprite.showStatus( CharSprite.POSITIVE, Integer.toString( effValue ) ); - return true; - - } else { - return false; } + + return damage; } @Override diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Venomous.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Venomous.java index d198dbd69..aba45c0ac 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Venomous.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Venomous.java @@ -22,6 +22,7 @@ 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.Poison; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite.Glowing; @@ -32,7 +33,7 @@ public class Venomous extends Weapon.Enchantment { private static ItemSprite.Glowing PURPLE = new ItemSprite.Glowing( 0x4400AA ); @Override - public boolean 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% @@ -40,13 +41,11 @@ public class Venomous extends Weapon.Enchantment { if (Random.Int( level + 3 ) >= 2) { - Buff.affect( defender, com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Poison.class ). - set( com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Poison.durationFactor( defender ) * (level + 1) ); - - return true; - } else { - return false; + Buff.affect( defender, Poison.class ).extend( Poison.durationFactor( defender ) * ((level/2) + 1) ); + } + + return damage; } @Override diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Vorpal.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Vorpal.java new file mode 100644 index 000000000..953589eaa --- /dev/null +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Vorpal.java @@ -0,0 +1,55 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * Shattered Pixel Dungeon + * Copyright (C) 2014-2016 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.Bleeding; +import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; +import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon; +import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; +import com.watabou.utils.Random; + +public class Vorpal extends Weapon.Enchantment { + + private static ItemSprite.Glowing RED = new ItemSprite.Glowing( 0xAA6666 ); + + @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/4); + + } + + return damage; + } + + @Override + public ItemSprite.Glowing glowing() { + return RED; + } + +} diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/MagesStaff.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/MagesStaff.java index 2a044bdad..459fed5b1 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/MagesStaff.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/MagesStaff.java @@ -127,13 +127,13 @@ public class MagesStaff extends MeleeWeapon { } @Override - public void proc(Char attacker, Char defender, int damage) { + public int proc(Char attacker, Char defender, int damage) { if (wand != null && Dungeon.hero.subClass == HeroSubClass.BATTLEMAGE) { if (wand.curCharges < wand.maxCharges) wand.partialCharge += 0.33f; ScrollOfRecharging.charge((Hero)attacker); wand.onHit(this, attacker, defender, damage); } - super.proc(attacker, defender, damage); + return super.proc(attacker, defender, damage); } @Override diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/Boomerang.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/Boomerang.java index ecaea2404..9ef082ebd 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/Boomerang.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/Boomerang.java @@ -93,11 +93,11 @@ public class Boomerang extends MissileWeapon { } @Override - public void proc( Char attacker, Char defender, int damage ) { - super.proc( attacker, defender, damage ); + public int proc( Char attacker, Char defender, int damage ) { if (attacker instanceof Hero && ((Hero)attacker).rangedWeapon == this) { circleBack( defender.pos, (Hero)attacker ); } + return super.proc( attacker, defender, damage ); } @Override diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/CurareDart.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/CurareDart.java index 33685b009..988d1e95e 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/CurareDart.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/CurareDart.java @@ -60,9 +60,9 @@ public class CurareDart extends MissileWeapon { } @Override - public void proc( Char attacker, Char defender, int damage ) { + public int proc( Char attacker, Char defender, int damage ) { Buff.prolong( defender, Paralysis.class, DURATION ); - super.proc( attacker, defender, damage ); + return super.proc( attacker, defender, damage ); } @Override diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/IncendiaryDart.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/IncendiaryDart.java index a25d88d1c..d1a359068 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/IncendiaryDart.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/IncendiaryDart.java @@ -72,9 +72,9 @@ public class IncendiaryDart extends MissileWeapon { } @Override - public void proc( Char attacker, Char defender, int damage ) { + public int proc( Char attacker, Char defender, int damage ) { Buff.affect( defender, Burning.class ).reignite( defender ); - super.proc( attacker, defender, damage ); + return super.proc( attacker, defender, damage ); } @Override diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/Javelin.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/Javelin.java index c5bb551e6..23cf97889 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/Javelin.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/Javelin.java @@ -58,9 +58,9 @@ public class Javelin extends MissileWeapon { } @Override - public void proc( Char attacker, Char defender, int damage ) { - super.proc( attacker, defender, damage ); + public int proc( Char attacker, Char defender, int damage ) { Buff.prolong( defender, Cripple.class, Cripple.DURATION ); + return super.proc( attacker, defender, damage ); } @Override diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/MissileWeapon.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/MissileWeapon.java index cea6e3b71..674e1744c 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/MissileWeapon.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/MissileWeapon.java @@ -30,6 +30,8 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass; import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfSharpshooting; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon; +import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Projecting; +import com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.watabou.utils.Random; @@ -52,6 +54,19 @@ abstract public class MissileWeapon extends Weapon { return actions; } + @Override + protected int throwPos(Hero user, int dst) { + int defaultPos = super.throwPos(user, dst); + if (defaultPos == dst) return dst; + else if (enchantment instanceof Projecting){ + Ballistica ProjectingTrajectory = new Ballistica( user.pos, dst, Ballistica.STOP_TARGET ); + if (ProjectingTrajectory.dist <= 4) return ProjectingTrajectory.collisionPos; + else return super.throwPos(user, dst); + } else { + return super.throwPos(user, dst); + } + } + @Override protected void onThrow( int cell ) { Char enemy = Actor.findChar( cell ); @@ -95,9 +110,7 @@ abstract public class MissileWeapon extends Weapon { } @Override - public void proc( Char attacker, Char defender, int damage ) { - - super.proc( attacker, defender, damage ); + public int proc( Char attacker, Char defender, int damage ) { Hero hero = (Hero)attacker; if (hero.rangedWeapon == null && stackable) { @@ -107,6 +120,9 @@ abstract public class MissileWeapon extends Weapon { detach( null ); } } + + return super.proc( attacker, defender, damage ); + } @Override diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/Tamahawk.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/Tamahawk.java index 1f1ebe790..4a0e12e35 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/Tamahawk.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/Tamahawk.java @@ -59,9 +59,9 @@ public class Tamahawk extends MissileWeapon { } @Override - public void proc( Char attacker, Char defender, int damage ) { - super.proc( attacker, defender, damage ); + public int proc( Char attacker, Char defender, int damage ) { Buff.affect( defender, Bleeding.class ).set( damage ); + return super.proc( attacker, defender, damage ); } @Override diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties b/src/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties index e20c553fd..9d6986e98 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties +++ b/src/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties @@ -663,10 +663,16 @@ items.weapon.enchantments.blazing.name=blazing %s items.weapon.enchantments.chilling.name=chilling %s +items.weapon.enchantments.dazzling.name=dazzling %s + items.weapon.enchantments.eldritch.name=eldritch %s +items.weapon.enchantments.grim.name=grim %s + items.weapon.enchantments.lucky.name=lucky %s +items.weapon.enchantments.projecting.name=projecting %s + items.weapon.enchantments.shocking.name=shocking %s items.weapon.enchantments.stunning.name=stunning %s @@ -677,7 +683,7 @@ items.weapon.enchantments.vampiric.name=vampiric %s items.weapon.enchantments.venomous.name=venomous %s -items.weapon.enchantments.grim.name=grim %s +items.weapon.enchantments.vorpal.name=vorpal %s ###melee weapons diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/sprites/ItemSprite.java b/src/com/shatteredpixel/shatteredpixeldungeon/sprites/ItemSprite.java index f1737d626..aaa134657 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/sprites/ItemSprite.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/sprites/ItemSprite.java @@ -261,8 +261,6 @@ public class ItemSprite extends MovieClip { public static class Glowing { - public static final Glowing WHITE = new Glowing( 0xFFFFFF, 0.6f ); - public int color; public float red; public float green;