From 84b7a6bbb606e09c94597c1eabf5b475a02c77c3 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Wed, 14 Jun 2017 02:39:18 -0400 Subject: [PATCH] v0.6.1: large ring refactor, moved functionality to within their class --- .../actors/buffs/Burning.java | 5 ++- .../actors/buffs/Charm.java | 5 ++- .../actors/buffs/Frost.java | 5 ++- .../actors/buffs/Paralysis.java | 5 ++- .../actors/buffs/Poison.java | 5 ++- .../actors/buffs/Slow.java | 5 ++- .../actors/buffs/Vertigo.java | 5 ++- .../actors/buffs/Weakness.java | 5 ++- .../actors/hero/Hero.java | 35 ++++++------------- .../actors/mobs/Mob.java | 7 ++-- .../items/rings/RingOfAccuracy.java | 8 +++++ .../items/rings/RingOfElements.java | 22 +++++++----- .../items/rings/RingOfEvasion.java | 10 ++++++ .../items/rings/RingOfForce.java | 19 ++++++++-- .../items/rings/RingOfFuror.java | 7 ++++ .../items/rings/RingOfHaste.java | 6 ++++ .../items/rings/RingOfMight.java | 5 +++ .../items/rings/RingOfSharpshooting.java | 6 ++++ .../items/rings/RingOfTenacity.java | 7 ++++ .../items/rings/RingOfWealth.java | 15 ++++++++ .../items/weapon/Weapon.java | 7 ++-- .../shatteredpixeldungeon/levels/Level.java | 8 ++--- .../levels/RegularLevel.java | 7 ++-- 23 files changed, 130 insertions(+), 79 deletions(-) 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 98f3905b0..f8f14b4c0 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 @@ -34,7 +34,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.Brimstone; import com.shatteredpixel.shatteredpixeldungeon.items.food.ChargrilledMeat; import com.shatteredpixel.shatteredpixeldungeon.items.food.MysteryMeat; -import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfElements.Resistance; +import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfElements; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfMagicalInfusion; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfUpgrade; @@ -183,8 +183,7 @@ public class Burning extends Buff implements Hero.Doom { } public static float duration( Char ch ) { - Resistance r = ch.buff( Resistance.class ); - return r != null ? r.durationFactor() * DURATION : DURATION; + return DURATION * RingOfElements.durationFactor( ch ); } @Override diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Charm.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Charm.java index a2418e1dd..7b5b726c8 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Charm.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Charm.java @@ -22,7 +22,7 @@ package com.shatteredpixel.shatteredpixeldungeon.actors.buffs; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; -import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfElements.Resistance; +import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfElements; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator; import com.watabou.utils.Bundle; @@ -60,8 +60,7 @@ public class Charm extends FlavourBuff { } public static float durationFactor( Char ch ) { - Resistance r = ch.buff( Resistance.class ); - return r != null ? r.durationFactor() : 1; + return RingOfElements.durationFactor( ch ); } @Override diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Frost.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Frost.java index dae4fad18..71acfba96 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Frost.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Frost.java @@ -31,7 +31,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.food.MysteryMeat; import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion; import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfMight; import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfStrength; -import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfElements.Resistance; +import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfElements; import com.shatteredpixel.shatteredpixeldungeon.levels.Level; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite; @@ -123,7 +123,6 @@ public class Frost extends FlavourBuff { } public static float duration( Char ch ) { - Resistance r = ch.buff( Resistance.class ); - return r != null ? r.durationFactor() * DURATION : DURATION; + return DURATION * RingOfElements.durationFactor( ch ); } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Paralysis.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Paralysis.java index 9d2e0780a..f3910e474 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Paralysis.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Paralysis.java @@ -22,7 +22,7 @@ package com.shatteredpixel.shatteredpixeldungeon.actors.buffs; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; -import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfElements.Resistance; +import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfElements; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite; import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator; @@ -79,7 +79,6 @@ public class Paralysis extends FlavourBuff { } public static float duration( Char ch ) { - Resistance r = ch.buff( Resistance.class ); - return r != null ? r.durationFactor() * DURATION : DURATION; + return DURATION * RingOfElements.durationFactor( ch ); } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Poison.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Poison.java index 2b441ff99..962cff165 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Poison.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Poison.java @@ -27,7 +27,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter; import com.shatteredpixel.shatteredpixeldungeon.effects.particles.PoisonParticle; -import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfElements.Resistance; +import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfElements; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; @@ -114,8 +114,7 @@ public class Poison extends Buff implements Hero.Doom { } public static float durationFactor( Char ch ) { - Resistance r = ch.buff( Resistance.class ); - return r != null ? r.durationFactor() : 1; + return RingOfElements.durationFactor( ch ); } @Override diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Slow.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Slow.java index ad9e14dbe..4785a9c02 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Slow.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Slow.java @@ -22,7 +22,7 @@ package com.shatteredpixel.shatteredpixeldungeon.actors.buffs; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; -import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfElements.Resistance; +import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfElements; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator; @@ -50,7 +50,6 @@ public class Slow extends FlavourBuff { } public static float duration( Char ch ) { - Resistance r = ch.buff( Resistance.class ); - return r != null ? r.durationFactor() * DURATION : DURATION; + return DURATION * RingOfElements.durationFactor( ch ); } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Vertigo.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Vertigo.java index d281f0c45..bfe6b1fc9 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Vertigo.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Vertigo.java @@ -22,7 +22,7 @@ package com.shatteredpixel.shatteredpixeldungeon.actors.buffs; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; -import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfElements.Resistance; +import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfElements; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator; @@ -50,7 +50,6 @@ public class Vertigo extends FlavourBuff { } public static float duration( Char ch ) { - Resistance r = ch.buff( Resistance.class ); - return r != null ? r.durationFactor() * DURATION : DURATION; + return DURATION * RingOfElements.durationFactor( ch ); } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Weakness.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Weakness.java index 6c639c88a..3981dac4b 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Weakness.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Weakness.java @@ -23,7 +23,7 @@ package com.shatteredpixel.shatteredpixeldungeon.actors.buffs; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; -import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfElements.Resistance; +import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfElements; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator; @@ -64,8 +64,7 @@ public class Weakness extends FlavourBuff { } public static float duration( Char ch ) { - Resistance r = ch.buff( Resistance.class ); - return r != null ? r.durationFactor() * DURATION : DURATION; + return DURATION * RingOfElements.durationFactor( ch ); } @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 60f71398c..ea138f94a 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 @@ -183,7 +183,7 @@ public class Hero extends Char { public int STR() { int STR = this.STR; - STR += RingOfMight.getBonus(this, RingOfMight.Might.class); + STR += RingOfMight.strengthBonus( this ); return weakened ? STR - 2 : STR; } @@ -281,9 +281,8 @@ public class Hero extends Char { @Override public int defenseSkill( Char enemy ) { - int bonus = RingOfEvasion.getBonus(this, RingOfEvasion.Evasion.class); - - float evasion = (float)Math.pow( 1.125, bonus ); + float evasion = 1f * RingOfEvasion.evasionMultiplier( this ); + if (paralysed > 0) { evasion /= 2; } @@ -294,7 +293,7 @@ public class Hero extends Char { return (int)(defenseSkill * evasion / Math.pow( 1.5, aEnc )); } else { - bonus = 0; + int bonus = 0; if (heroClass == HeroClass.ROGUE) bonus += -aEnc; if (belongings.armor != null && belongings.armor.hasGlyph(Swiftness.class)) @@ -326,16 +325,11 @@ public class Hero extends Char { public int damageRoll() { KindOfWeapon wep = rangedWeapon != null ? rangedWeapon : belongings.weapon; int dmg; - int bonus = RingOfForce.getBonus(this, RingOfForce.Force.class); if (wep != null) { - dmg = wep.damageRoll( this ) + bonus; + dmg = wep.damageRoll( this ) + RingOfForce.armedDamageBonus(this); } else { - if (bonus != 0){ - dmg = RingOfForce.damageRoll(this); - } else { - dmg = Random.NormalIntRange(1, Math.max(STR()-8, 1)); - } + dmg = RingOfForce.damageRoll(this); } if (dmg < 0) dmg = 0; if (subClass == HeroSubClass.BERSERKER){ @@ -350,10 +344,7 @@ public class Hero extends Char { float speed = super.speed(); - int hasteLevel = RingOfHaste.getBonus(this, RingOfHaste.Haste.class); - - if (hasteLevel != 0) - speed *= Math.pow(1.2, hasteLevel); + speed *= RingOfHaste.speedMultiplier(this); Armor armor = belongings.armor; @@ -430,8 +421,7 @@ public class Hero extends Char { //Normally putting furor speed on unarmed attacks would be unnecessary //But there's going to be that one guy who gets a furor+force ring combo //This is for that one guy, you shall get your fists of fury! - int bonus = RingOfFuror.getBonus(this, RingOfFuror.Furor.class); - return (float)(0.2 + (1 - 0.2)*Math.pow(0.85, bonus)); + return RingOfFuror.modifyAttackDelay(1f, this); } } @@ -958,9 +948,7 @@ public class Hero extends Char { dmg = thorns.proc(dmg, (src instanceof Char ? (Char)src : null), this); } - int tenacity = RingOfTenacity.getBonus(this, RingOfTenacity.Tenacity.class); - if (tenacity != 0) //(HT - HP)/HT = heroes current % missing health. - dmg = (int)Math.ceil((float)dmg * Math.pow(0.85, tenacity*((float)(HT - HP)/HT))); + dmg = (int)Math.ceil(dmg * RingOfTenacity.damageMultiplier( this )); //TODO improve this when I have proper damage source logic if (belongings.armor != null && belongings.armor.hasGlyph(AntiMagic.class) @@ -1280,7 +1268,7 @@ public class Hero extends Char { public int stealth() { int stealth = super.stealth(); - stealth += RingOfEvasion.getBonus(this, RingOfEvasion.Evasion.class); + stealth += RingOfEvasion.stealthBonus( this ); if (belongings.armor != null && belongings.armor.hasGlyph(Obfuscation.class)){ stealth += belongings.armor.level(); @@ -1594,8 +1582,7 @@ public class Hero extends Char { @Override public HashSet> resistances() { - RingOfElements.Resistance r = buff( RingOfElements.Resistance.class ); - return r == null ? super.resistances() : r.resistances(); + return RingOfElements.resistances( this ); } @Override 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 a12c94d4d..b9159ee21 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 @@ -443,9 +443,7 @@ public abstract class Mob extends Char { boolean seen = enemySeen || (enemy == Dungeon.hero && !Dungeon.hero.canSurpriseAttack()); if (seen && paralysed == 0) { int defenseSkill = this.defenseSkill; - int penalty = RingOfAccuracy.getBonus(enemy, RingOfAccuracy.Accuracy.class); - if (penalty != 0 && enemy == Dungeon.hero) - defenseSkill *= Math.pow(0.75, penalty); + defenseSkill *= RingOfAccuracy.enemyEvasionMultiplier( enemy ); return defenseSkill; } else { return 0; @@ -546,8 +544,7 @@ public abstract class Mob extends Char { super.die( cause ); float lootChance = this.lootChance; - int bonus = RingOfWealth.getBonus(Dungeon.hero, RingOfWealth.Wealth.class); - lootChance *= Math.pow(1.15, bonus); + lootChance *= RingOfWealth.dropChanceMultiplier( Dungeon.hero ); if (Random.Float() < lootChance && Dungeon.hero.lvl <= maxLvl + 2) { Item loot = createLoot(); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfAccuracy.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfAccuracy.java index 57823aeae..12d2dbb5e 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfAccuracy.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfAccuracy.java @@ -21,6 +21,8 @@ package com.shatteredpixel.shatteredpixeldungeon.items.rings; +import com.shatteredpixel.shatteredpixeldungeon.actors.Char; + public class RingOfAccuracy extends Ring { @Override @@ -28,6 +30,12 @@ public class RingOfAccuracy extends Ring { return new Accuracy(); } + //The ring of accuracy reduces enemy evasion + // this makes it more powerful against more evasive enemies + public static float enemyEvasionMultiplier( Char target ){ + return (float)Math.pow(0.75, getBonus(target, Accuracy.class)); + } + public class Accuracy extends RingBuff { } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfElements.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfElements.java index feabb8b93..a6113b7f0 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfElements.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfElements.java @@ -21,6 +21,7 @@ package com.shatteredpixel.shatteredpixeldungeon.items.rings; +import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.ToxicGas; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Burning; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Poison; @@ -54,15 +55,20 @@ public class RingOfElements extends Ring { FULL.add( Yog.BurningFist.class ); } - public class Resistance extends RingBuff { - - public HashSet> resistances() { - if (Random.Int( level() + 2 ) >= 2) { - return FULL; - } else { - return EMPTY; - } + public static HashSet> resistances( Char target ){ + if (Random.Int( getBonus(target, Resistance.class) + 2 ) >= 2) { + return FULL; + } else { + return EMPTY; } + } + + public static float durationFactor( Char target ){ + int level = getBonus( target, Resistance.class); + return level <= 0 ? 1 : (1 + 0.5f * level) / (1 + level); + } + + public class Resistance extends RingBuff { public float durationFactor() { return level() < 0 ? 1 : (1 + 0.5f * level()) / (1 + level()); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfEvasion.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfEvasion.java index 8e50bc444..151e15a7f 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfEvasion.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfEvasion.java @@ -21,12 +21,22 @@ package com.shatteredpixel.shatteredpixeldungeon.items.rings; +import com.shatteredpixel.shatteredpixeldungeon.actors.Char; + public class RingOfEvasion extends Ring { @Override protected RingBuff buff( ) { return new Evasion(); } + + public static float evasionMultiplier( Char target ){ + return (float) Math.pow( 1.15, getBonus(target, Evasion.class)); + } + + public static int stealthBonus( Char target ){ + return getBonus( target, Evasion.class ); + } public class Evasion extends RingBuff { } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfForce.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfForce.java index 4c48ce4e3..a21923628 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfForce.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfForce.java @@ -22,6 +22,7 @@ package com.shatteredpixel.shatteredpixeldungeon.items.rings; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; +import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.watabou.utils.Random; @@ -32,6 +33,13 @@ public class RingOfForce extends Ring { protected RingBuff buff( ) { return new Force(); } + + public static int armedDamageBonus( Char ch ){ + return getBonus( ch, Force.class); + } + + + // *** Weapon-like properties *** private static float tier(int str){ float tier = Math.max(1, (str - 8)/2f); @@ -43,9 +51,14 @@ public class RingOfForce extends Ring { } public static int damageRoll( Hero hero ){ - int level = getBonus(hero, Force.class); - float tier = tier(hero.STR()); - return Random.NormalIntRange(min(level, tier), max(level, tier)); + if (hero.buff(Force.class) != null) { + int level = getBonus(hero, Force.class); + float tier = tier(hero.STR()); + return Random.NormalIntRange(min(level, tier), max(level, tier)); + } else { + //attack without any ring of force influence + return Random.NormalIntRange(1, Math.max(hero.STR()-8, 1)); + } } //same as equivalent tier weapon diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfFuror.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfFuror.java index 21edcf2a6..d82b03a67 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfFuror.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfFuror.java @@ -21,12 +21,19 @@ package com.shatteredpixel.shatteredpixeldungeon.items.rings; +import com.shatteredpixel.shatteredpixeldungeon.actors.Char; + public class RingOfFuror extends Ring { @Override protected RingBuff buff( ) { return new Furor(); } + + public static float modifyAttackDelay( float delay, Char target){ + //furor bonus only affects delay after 0.2 + return (float)(0.2 + (delay - 0.2)*Math.pow(0.85, getBonus(target, Furor.class))); + } public class Furor extends RingBuff { } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfHaste.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfHaste.java index afcf51467..a67c5c815 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfHaste.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfHaste.java @@ -21,6 +21,8 @@ package com.shatteredpixel.shatteredpixeldungeon.items.rings; +import com.shatteredpixel.shatteredpixeldungeon.actors.Char; + public class RingOfHaste extends Ring { @Override @@ -28,6 +30,10 @@ public class RingOfHaste extends Ring { return new Haste(); } + public static float speedMultiplier( Char target ){ + return (float)Math.pow(1.2, getBonus(target, Haste.class)); + } + public class Haste extends RingBuff { } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfMight.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfMight.java index eb8a4eb36..a15dbd3b5 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfMight.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfMight.java @@ -22,6 +22,7 @@ package com.shatteredpixel.shatteredpixeldungeon.items.rings; +import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.items.Item; @@ -75,6 +76,10 @@ public class RingOfMight extends Ring { protected RingBuff buff( ) { return new Might(); } + + public static int strengthBonus( Char target ){ + return getBonus( target, Might.class ); + } public class Might extends RingBuff { } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfSharpshooting.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfSharpshooting.java index 3afd58046..ef48a92a7 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfSharpshooting.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfSharpshooting.java @@ -21,12 +21,18 @@ package com.shatteredpixel.shatteredpixeldungeon.items.rings; +import com.shatteredpixel.shatteredpixeldungeon.actors.Char; + public class RingOfSharpshooting extends Ring { @Override protected RingBuff buff( ) { return new Aim(); } + + public static float accuracyMultiplier( Char target ){ + return (float)(Math.pow(1.2, getBonus(target, Aim.class))); + } public class Aim extends RingBuff { } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfTenacity.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfTenacity.java index 6951e6118..d5adf380f 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfTenacity.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfTenacity.java @@ -21,12 +21,19 @@ package com.shatteredpixel.shatteredpixeldungeon.items.rings; +import com.shatteredpixel.shatteredpixeldungeon.actors.Char; + public class RingOfTenacity extends Ring { @Override protected RingBuff buff( ) { return new Tenacity(); } + + public static float damageMultiplier( Char t ){ + //(HT - HP)/HT = heroes current % missing health. + return (float)Math.pow(0.85, getBonus( t, Tenacity.class)*((float)(t.HT - t.HP)/t.HT)); + } public class Tenacity extends RingBuff { } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfWealth.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfWealth.java index 11fccc874..68ec3c233 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfWealth.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfWealth.java @@ -21,12 +21,27 @@ package com.shatteredpixel.shatteredpixeldungeon.items.rings; +import com.shatteredpixel.shatteredpixeldungeon.actors.Char; + public class RingOfWealth extends Ring { @Override protected RingBuff buff( ) { return new Wealth(); } + + public static float dropChanceMultiplier( Char target ){ + return (float)Math.pow(1.15, getBonus(target, Wealth.class)); + } + + //caps at a 50% bonus + public static float regularLootChanceBonus( Char target ){ + return Math.min(0.5f, 0.05f* getBonus(target, Wealth.class)); + } + + public static float specialLootChance( Char target ){ + return 1f - (float)Math.pow(0.925, getBonus(target, Wealth.class)); + } public class Wealth extends RingBuff { } 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 b5d49b01f..c0b76df3c 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 @@ -146,8 +146,7 @@ abstract public class Weapon extends KindOfWeapon { float ACC = this.ACC; if (this instanceof MissileWeapon) { - int bonus = RingOfSharpshooting.getBonus(hero, RingOfSharpshooting.Aim.class); - ACC *= (float)(Math.pow(1.2, bonus)); + ACC *= RingOfSharpshooting.accuracyMultiplier( hero ); } return encumbrance > 0 ? (float)(ACC / Math.pow( 1.5, encumbrance )) : ACC; @@ -163,9 +162,7 @@ abstract public class Weapon extends KindOfWeapon { float DLY = imbue.delayFactor(this.DLY); - int bonus = RingOfFuror.getBonus(hero, RingOfFuror.Furor.class); - - DLY = (float)(0.2 + (DLY - 0.2)*Math.pow(0.85, bonus)); + DLY = RingOfFuror.modifyAttackDelay(DLY, hero); return (encumrance > 0 ? (float)(DLY * Math.pow( 1.2, encumrance )) : DLY); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java index 9d6470f06..528608235 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java @@ -178,24 +178,22 @@ public abstract class Level implements Bundlable { if (!(Dungeon.bossLevel() || Dungeon.depth == 21) /*final shop floor*/) { addItemToSpawn( Generator.random( Generator.Category.FOOD ) ); - int bonus = RingOfWealth.getBonus(Dungeon.hero, RingOfWealth.Wealth.class); - if (Dungeon.posNeeded()) { - if (Random.Float() > Math.pow(0.925, bonus)) + if (Random.Float() < RingOfWealth.specialLootChance( Dungeon.hero )) addItemToSpawn( new PotionOfMight() ); else addItemToSpawn( new PotionOfStrength() ); Dungeon.limitedDrops.strengthPotions.count++; } if (Dungeon.souNeeded()) { - if (Random.Float() > Math.pow(0.925, bonus)) + if (Random.Float() < RingOfWealth.specialLootChance( Dungeon.hero )) addItemToSpawn( new ScrollOfMagicalInfusion() ); else addItemToSpawn( new ScrollOfUpgrade() ); Dungeon.limitedDrops.upgradeScrolls.count++; } if (Dungeon.asNeeded()) { - if (Random.Float() > Math.pow(0.925, bonus)) + if (Random.Float() < RingOfWealth.specialLootChance( Dungeon.hero )) addItemToSpawn( new Stylus() ); addItemToSpawn( new Stylus() ); Dungeon.limitedDrops.arcaneStyli.count++; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/RegularLevel.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/RegularLevel.java index b66ea4d7a..8776c8911 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/RegularLevel.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/RegularLevel.java @@ -312,11 +312,8 @@ public abstract class RegularLevel extends Level { protected void createItems() { int nItems = 3; - int bonus = RingOfWealth.getBonus(Dungeon.hero, RingOfWealth.Wealth.class); - - //just incase someone gets a ridiculous ring, cap this at 80% - bonus = Math.min(bonus, 10); - while (Random.Float() < (0.3f + bonus*0.05f)) { + + while (Random.Float() < (0.3f + RingOfWealth.regularLootChanceBonus( Dungeon.hero ))) { nItems++; }