From 382da6b45d08e2ecf71faf145d5ec1dcd77730d5 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Thu, 1 Mar 2018 00:30:04 -0500 Subject: [PATCH] v0.6.3b: fixed bugs with berserker, and nerfed him again --- .../actors/buffs/Berserk.java | 30 +++++++++++-------- .../actors/buffs/MagicalSleep.java | 4 +-- .../actors/buffs/Regeneration.java | 8 +++-- 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Berserk.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Berserk.java index b3ebf5607..034991197 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Berserk.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Berserk.java @@ -23,6 +23,7 @@ package com.shatteredpixel.shatteredpixeldungeon.actors.buffs; import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; +import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.effects.SpellSprite; import com.shatteredpixel.shatteredpixeldungeon.items.BrokenSeal.WarriorShield; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; @@ -89,10 +90,12 @@ public class Berserk extends Buff { } } else { - float percentHP = target.HP/(float)target.HT; - - if (percentHP > targetHPPercent()){ - target.HP = (int)Math.max(target.HT*targetHPPercent(), target.HP - pastRages); + if (target.HP > targetHPMax()){ + target.HP = Math.max(targetHPMax(), target.HP - 1); + if (target instanceof Hero){ + ((Hero) target).resting = false; + target.remove(MagicalSleep.class); + } } if (state == State.EXHAUSTED){ @@ -109,19 +112,21 @@ public class Berserk extends Buff { public int damageFactor(int dmg){ float bonus; - - if (state == State.EXHAUSTED) { - bonus = 1f - ((float)Math.sqrt(exhaustion) / 8f); + + if (state == State.BERSERK){ + bonus = 2f; + } else if (state == State.EXHAUSTED) { + bonus = 1f - ((float)Math.sqrt(exhaustion) / 10f); } else { - float percentMissing = 1f - target.HP/(float)target.HT; - bonus = 1f + (float)Math.pow(percentMissing, 3); + float percentMissing = 1f - target.HP/(float)targetHPMax(); + bonus = 1f + (0.5f * (float)Math.pow(percentMissing, 2)); } return Math.round(dmg * bonus); } - public float targetHPPercent(){ - return Math.round(20* Math.pow(0.8f, pastRages))/20f; + public int targetHPMax(){ + return Math.round(target.HT * Math.round(20* Math.pow(0.8f, pastRages))/20f); } public boolean berserking(){ @@ -212,7 +217,8 @@ public class Berserk extends Buff { if (pastRages == 0){ text += "\n\n" + Messages.get(this, "no_rages"); } else { - text += "\n\n" + Messages.get(this, "past_rages", pastRages, (int)(targetHPPercent()*100)); + int dispPercent = (int)(targetHPMax()/(float)target.HT * 100); + text += "\n\n" + Messages.get(this, "past_rages", pastRages, dispPercent); } return text; } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/MagicalSleep.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/MagicalSleep.java index b4d2cf307..47e73d280 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/MagicalSleep.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/MagicalSleep.java @@ -37,7 +37,7 @@ public class MagicalSleep extends Buff { if (!target.isImmune(Sleep.class) && super.attachTo( target )) { if (target instanceof Hero) - if (target.HP == target.HT) { + if (target.HP == target.buff(Regeneration.class).regencap()) { GLog.i(Messages.get(this, "toohealthy")); detach(); return true; @@ -64,7 +64,7 @@ public class MagicalSleep extends Buff { if (target instanceof Hero) { target.HP = Math.min(target.HP+1, target.HT); ((Hero) target).resting = true; - if (target.HP == target.HT) { + if (target.HP == target.buff(Regeneration.class).regencap()) { GLog.p(Messages.get(this, "wakeup")); detach(); } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Regeneration.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Regeneration.java index a578de01a..adff6e7bb 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Regeneration.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Regeneration.java @@ -39,11 +39,11 @@ public class Regeneration extends Buff { public boolean act() { if (target.isAlive()) { - if (target.HP < target.HT && !((Hero)target).isStarving()) { + if (target.HP < regencap() && !((Hero)target).isStarving()) { LockedFloor lock = target.buff(LockedFloor.class); if (target.HP > 0 && (lock == null || lock.regenOn())) { target.HP += 1; - if (target.HP == target.HT) { + if (target.HP == regencap()) { ((Hero) target).resting = false; } } @@ -67,4 +67,8 @@ public class Regeneration extends Buff { return true; } + + public int regencap(){ + return target.buff(Berserk.class) == null ? target.HT : target.buff(Berserk.class).targetHPMax(); + } }