From 7c2e5e92052e5911e8315157b04b0481c65cff08 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Sun, 22 May 2022 21:32:15 -0400 Subject: [PATCH] v1.3.0: reworked the wayward curse --- .../assets/messages/items/items.properties | 5 +- .../items/weapon/Weapon.java | 7 +-- .../items/weapon/curses/Wayward.java | 52 ++++++++++++++++++- 3 files changed, 58 insertions(+), 6 deletions(-) diff --git a/core/src/main/assets/messages/items/items.properties b/core/src/main/assets/messages/items/items.properties index e720e3435..dfdefe6fc 100644 --- a/core/src/main/assets/messages/items/items.properties +++ b/core/src/main/assets/messages/items/items.properties @@ -1371,8 +1371,9 @@ items.weapon.curses.sacrificial.name=sacrificial %s items.weapon.curses.sacrificial.desc=Sacrificial weapons will demand blood from the wearer in return for attacking foes. The more healthy the wearer is, the more blood the curse will take. items.weapon.curses.wayward.name=wayward %s -items.weapon.curses.wayward.desc=A wayward weapon has a very hard time finding its mark, making it extremely inaccurate unless the attack is guaranteed to succeed. - +items.weapon.curses.wayward.desc=Wayward weapons will sometimes become extremely inaccurate. This magic lasts for a little while when it activates, but can be dispelled by landing a blow with the wayward weapon. +items.weapon.curses.wayward$waywardbuff.name=Wayward +items.weapon.curses.wayward$waywardbuff.desc=Your wayward weapon's magic has activated, making it extremely inaccurate for a short time. Note that this does not affect attacks which are guaranteed to hit, such as surprise attacks. Successfully attacking with the wayward weapon will clear this effect immediately.\n\nTurns remaining: %s. ###enchantments items.weapon.enchantments.blazing.name=blazing %s 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 ae9079e9b..c1510c933 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 @@ -176,11 +176,12 @@ abstract public class Weapon extends KindOfWeapon { encumbrance = STRReq() - ((Hero)owner).STR(); } - if (hasEnchant(Wayward.class, owner)) - encumbrance = Math.max(2, encumbrance+2); - float ACC = this.ACC; + if (owner.buff(Wayward.WaywardBuff.class) != null && enchantment instanceof Wayward){ + ACC /= 5; + } + return encumbrance > 0 ? (float)(ACC / Math.pow( 1.5, encumbrance )) : ACC; } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/curses/Wayward.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/curses/Wayward.java index be8135833..e8617b5e5 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/curses/Wayward.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/curses/Wayward.java @@ -22,8 +22,14 @@ package com.shatteredpixel.shatteredpixeldungeon.items.weapon.curses; 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.Random; public class Wayward extends Weapon.Enchantment { @@ -31,7 +37,14 @@ public class Wayward extends Weapon.Enchantment { @Override public int proc( Weapon weapon, Char attacker, Char defender, int damage ) { - //no proc effect, see weapon.accuracyFactor for effect + float procChance = 1/4f * procChanceMultiplier(attacker); + + if (attacker.buff(WaywardBuff.class) != null){ + Buff.detach(attacker, WaywardBuff.class); + } else if (Random.Float() < procChance){ + Buff.prolong(attacker, WaywardBuff.class, WaywardBuff.DURATION); + } + return damage; } @@ -45,4 +58,41 @@ public class Wayward extends Weapon.Enchantment { return BLACK; } + //see weapon.accuracyFactor for effect + public static class WaywardBuff extends FlavourBuff { + + { + type = buffType.NEGATIVE; + announced = true; + } + + public static final float DURATION = 10f; + + @Override + public int icon() { + return BuffIndicator.WEAKNESS; + } + + @Override + public void tintIcon(Image icon) { + icon.hardlight(1, 1, 0); + } + + @Override + public float iconFadePercent() { + return Math.max(0, (DURATION - visualcooldown()) / DURATION); + } + + @Override + public String toString() { + return Messages.get(this, "name"); + } + + @Override + public String desc() { + return Messages.get(this, "desc", dispTurns()); + } + + } + }