From d8f906308cbfa16cd21bdde35f606b6af28f9bbb Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Sun, 7 Feb 2021 14:49:30 -0500 Subject: [PATCH] v0.9.2: implemented the shared enchantment talent --- .../assets/messages/actors/actors.properties | 2 ++ .../actors/hero/Talent.java | 4 ++-- .../items/weapon/missiles/MissileWeapon.java | 21 ++++++++++++++++++- .../items/weapon/missiles/darts/Dart.java | 6 +++++- 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/core/src/main/assets/messages/actors/actors.properties b/core/src/main/assets/messages/actors/actors.properties index 6ea712fa4..882e105d8 100644 --- a/core/src/main/assets/messages/actors/actors.properties +++ b/core/src/main/assets/messages/actors/actors.properties @@ -417,6 +417,8 @@ actors.hero.talent.point_blank.title=point blank actors.hero.talent.point_blank.desc=_+1:_ When the Huntress uses a thrown weapon at melee range it has _-30% accuracy,_ instead of -50%.\n\n_+2:_ When the Huntress uses a thrown weapon at melee range it has _-10% accuracy,_ instead of -50%.\n\n_+3:_ When the Huntress uses a thrown weapon at melee range it has _+10% accuracy,_ instead of -50%.\n\nNote that thrown weapons always have +50% accuracy when used at a distance. actors.hero.talent.farsight.title=farsight actors.hero.talent.farsight.desc=_+1:_ The Sniper's vision range is _increased by 25%_\n\n_+2:_ The Sniper's vision range is _increased by 50%_\n\n_+3:_ The Sniper's vision range is _increased by 75%_ +actors.hero.talent.shared_enchantment.title=shared enchantment +actors.hero.talent.shared_enchantment.desc=_+1:_ Thrown weapons have a _33% chance_ to use the enchantment on the Sniper's bow.\n\n_+2:_ Thrown weapons have a _67% chance_ to use the enchantment on the Sniper's bow.\n\n_+3:_ Thrown weapons have a _100% chance_ to use the enchantment on the Sniper's bow.\n\nThis talent does not apply to darts shot from an enchanted crossbow, they already trigger the crossbow's enchantment. actors.hero.talent.durable_tips.title=durable tips actors.hero.talent.durable_tips.desc=_+1:_ Tipped darts have _2x durability_ when the Warden uses them.\n\n_+2:_ Tipped darts have _3x durability_ when the Warden uses them.\n\n_+3:_ Tipped darts have _4x durability_ when the Warden uses them. actors.hero.talent.barkskin.title=barkskin diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Talent.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Talent.java index 21661ef3a..5af491ed5 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Talent.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Talent.java @@ -106,7 +106,7 @@ public enum Talent { //Huntress T3 POINT_BLANK(105, 3), HUNTRESS_T3_2(106, 3), //Sniper T3 - FARSIGHT(107, 3), SNIPER_T3_2(108, 3), SNIPER_T3_3(109, 3), + FARSIGHT(107, 3), SHARED_ENCHANTMENT(108, 3), SNIPER_T3_3(109, 3), //Warden T3 DURABLE_TIPS(110, 3), BARKSKIN(111, 3), WARDEN_T3_3(112, 3); @@ -476,7 +476,7 @@ public enum Talent { Collections.addAll(tierTalents, EVASIVE_ARMOR, PROJECTILE_MOMENTUM, FREERUNNER_T3_3); break; case SNIPER: - Collections.addAll(tierTalents, FARSIGHT, SNIPER_T3_2, SNIPER_T3_3); + Collections.addAll(tierTalents, FARSIGHT, SHARED_ENCHANTMENT, SNIPER_T3_3); break; case WARDEN: Collections.addAll(tierTalents, DURABLE_TIPS, BARKSKIN, WARDEN_T3_3); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/MissileWeapon.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/MissileWeapon.java index 704341010..13562f55e 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/MissileWeapon.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/MissileWeapon.java @@ -26,6 +26,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Corruption; +import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.MagicImmune; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Momentum; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.PinCushion; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; @@ -34,8 +35,10 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.bags.Bag; import com.shatteredpixel.shatteredpixeldungeon.items.bags.MagicalHolster; import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfSharpshooting; +import com.shatteredpixel.shatteredpixeldungeon.items.weapon.SpiritBow; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Projecting; +import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.darts.Dart; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; import com.watabou.utils.Bundle; @@ -182,7 +185,23 @@ abstract public class MissileWeapon extends Weapon { } } } - + + @Override + public int proc(Char attacker, Char defender, int damage) { + if (attacker == Dungeon.hero && Random.Int(3) < Dungeon.hero.pointsInTalent(Talent.SHARED_ENCHANTMENT)){ + if (this instanceof Dart && ((Dart) this).crossbowHasEnchant(Dungeon.hero)){ + //do nothing + } else { + SpiritBow bow = Dungeon.hero.belongings.getItem(SpiritBow.class); + if (bow != null && bow.enchantment != null && Dungeon.hero.buff(MagicImmune.class) == null) { + damage = bow.enchantment.proc(this, attacker, defender, damage); + } + } + } + + return super.proc(attacker, defender, damage); + } + @Override public Item random() { if (!stackable) return this; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/darts/Dart.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/darts/Dart.java index 90d4407c6..e9a589542 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/darts/Dart.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/darts/Dart.java @@ -101,6 +101,10 @@ public class Dart extends MissileWeapon { bow = null; } } + + public boolean crossbowHasEnchant( Char owner ){ + return bow != null && bow.enchantment != null && owner.buff(MagicImmune.class) == null; + } @Override public boolean hasEnchant(Class type, Char owner) { @@ -115,7 +119,7 @@ public class Dart extends MissileWeapon { public int proc(Char attacker, Char defender, int damage) { if (bow != null && bow.enchantment != null && attacker.buff(MagicImmune.class) == null){ level(bow.level()); - damage = bow.enchantment.proc(this, attacker, defender, damage); + damage = bow.enchantment.proc(bow, attacker, defender, damage); level(0); } return super.proc(attacker, defender, damage);