From 96c9ca6de439b9a70ab5b859630cbf46d3ccd5b4 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Wed, 11 May 2016 04:54:55 -0400 Subject: [PATCH] v0.4.0: Refactored strength requirements, also changed how they scale Also refactored class armor a bit so that it is upgradeable --- .../actors/hero/Hero.java | 4 +- .../items/Generator.java | 4 +- .../items/armor/Armor.java | 41 ++++++----------- .../items/armor/ClassArmor.java | 45 +++++++++++-------- .../items/quest/Pickaxe.java | 8 +++- .../items/weapon/Weapon.java | 17 ++++--- .../items/weapon/melee/MagesStaff.java | 4 -- .../items/weapon/melee/MeleeWeapon.java | 29 ++++-------- .../items/weapon/missiles/Boomerang.java | 8 +++- .../items/weapon/missiles/CurareDart.java | 7 ++- .../items/weapon/missiles/Dart.java | 5 +++ .../items/weapon/missiles/IncendiaryDart.java | 7 ++- .../items/weapon/missiles/Javelin.java | 7 ++- .../items/weapon/missiles/MissileWeapon.java | 2 +- .../items/weapon/missiles/Shuriken.java | 7 ++- .../items/weapon/missiles/Tamahawk.java | 8 +++- .../shatteredpixeldungeon/ui/ItemSlot.java | 6 +-- 17 files changed, 111 insertions(+), 98 deletions(-) diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java index 6a6646b4c..b7adfc7e4 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java @@ -280,7 +280,7 @@ public class Hero extends Char { evasion /= 2; } - int aEnc = belongings.armor != null ? belongings.armor.STR - STR() : 9 - STR(); + int aEnc = belongings.armor != null ? belongings.armor.STRReq() - STR() : 9 - STR(); if (aEnc > 0) { return (int)(defenseSkill * evasion / Math.pow( 1.5, aEnc )); @@ -342,7 +342,7 @@ public class Hero extends Char { if (hasteLevel != 0) speed *= Math.pow(1.2, hasteLevel); - int aEnc = belongings.armor != null ? belongings.armor.STR - STR() : 0; + int aEnc = belongings.armor != null ? belongings.armor.STRReq() - STR() : 0; if (aEnc > 0) { return (float)(speed * Math.pow( 1.3, -aEnc )); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/Generator.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/Generator.java index aeee42824..a52c1693f 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/Generator.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/Generator.java @@ -375,7 +375,7 @@ public class Generator { a1.random(); a2.random(); - return Math.abs(targetStr - a1.STR) < Math.abs(targetStr - a2.STR) ? a1 : a2; + return Math.abs(targetStr - a1.STRReq()) < Math.abs(targetStr - a2.STRReq()) ? a1 : a2; } catch (Exception e) { return null; } @@ -398,7 +398,7 @@ public class Generator { w1.random(); w2.random(); - return Math.abs( targetStr - w1.STR ) < Math.abs( targetStr - w2.STR ) ? w1 : w2; + return Math.abs( targetStr - w1.STRReq() ) < Math.abs( targetStr - w2.STRReq() ) ? w1 : w2; } catch (Exception e) { return null; } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/Armor.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/Armor.java index 7be4b56a3..ac5e3f9b2 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/Armor.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/Armor.java @@ -59,18 +59,13 @@ public class Armor extends EquipableItem { public int tier; - public int STR; - private int hitsToKnow = HITS_TO_KNOW; public Glyph glyph; private BrokenSeal seal; public Armor( int tier ) { - this.tier = tier; - - STR = typicalSTR(); } private static final String UNFAMILIRIARITY = "unfamiliarity"; @@ -92,12 +87,7 @@ public class Armor extends EquipableItem { hitsToKnow = HITS_TO_KNOW; } inscribe((Glyph) bundle.get(GLYPH)); - //TODO holdover from beta releases, remove in 0.4.0 - if (bundle.getBoolean(SEAL)){ - seal = new BrokenSeal(); - if (level() > 0) seal.level(1); - } else - seal = (BrokenSeal)bundle.get(SEAL); + seal = (BrokenSeal)bundle.get(SEAL); } @Override @@ -238,18 +228,9 @@ public class Armor extends EquipableItem { if (seal != null && seal.level() == 0) seal.upgrade(); - STR--; - return super.upgrade(); } - @Override - public Item degrade() { - STR++; - - return super.degrade(); - } - public int proc( Char attacker, Char defender, int damage ) { if (glyph != null) { @@ -269,7 +250,7 @@ public class Armor extends EquipableItem { @Override public String toString() { - return levelKnown ? Messages.format( TXT_TO_STRING, super.toString(), STR ) : super.toString(); + return levelKnown ? Messages.format( TXT_TO_STRING, super.toString(), STRReq() ) : super.toString(); } @Override @@ -284,13 +265,13 @@ public class Armor extends EquipableItem { if (levelKnown) { info += "\n\n" + Messages.get(Armor.class, "curr_absorb", Math.max( DR(), 0 )); - if (STR > Dungeon.hero.STR()) { + if (STRReq() > Dungeon.hero.STR()) { info += "\n\n" + Messages.get(Armor.class, "too_heavy"); } } else { - info += "\n\n" + Messages.get(Armor.class, "avg_absorb", typicalDR(), typicalSTR()); + info += "\n\n" + Messages.get(Armor.class, "avg_absorb", typicalDR(), STRReq(0)); - if (typicalSTR() > Dungeon.hero.STR()) { + if (STRReq(0) > Dungeon.hero.STR()) { info += "\n\n" + Messages.get(Armor.class, "probably_too_heavy"); } } @@ -344,9 +325,15 @@ public class Armor extends EquipableItem { return this; } - - public int typicalSTR() { - return 7 + tier * 2; + + public int STRReq(){ + return STRReq(level()); + } + + public int STRReq(int lvl){ + lvl = Math.max(0, lvl); + //strength req decreases at +1,+3,+6,+10,etc. + return (7 + tier * 2) - (int)(Math.sqrt(8 * lvl + 1) - 1)/2; } public int typicalDR() { diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/ClassArmor.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/ClassArmor.java index 635f35cfa..c1ec178e6 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/ClassArmor.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/ClassArmor.java @@ -42,7 +42,7 @@ abstract public class ClassArmor extends Armor { bones = false; } - private int DR; + private int armorTier; public ClassArmor() { super( 6 ); @@ -72,29 +72,37 @@ abstract public class ClassArmor extends Armor { } classArmor.level(armor.level()); - classArmor.STR = armor.STR; - classArmor.DR = armor.DR(); - + classArmor.armorTier = armor.tier; classArmor.inscribe( armor.glyph ); return classArmor; } - - private static final String ARMOR_STR = "STR"; - private static final String ARMOR_DR = "DR"; - + + private static final String ARMOR_TIER = "armortier"; + @Override public void storeInBundle( Bundle bundle ) { super.storeInBundle( bundle ); - bundle.put( ARMOR_STR, STR ); - bundle.put( ARMOR_DR, DR ); + bundle.put( ARMOR_TIER, armorTier ); } - + @Override public void restoreFromBundle( Bundle bundle ) { super.restoreFromBundle( bundle ); - STR = bundle.getInt( ARMOR_STR ); - DR = bundle.getInt( ARMOR_DR ); + //logic for pre-0.4.0 saves + if (bundle.contains( "DR" )){ + //we just assume tier-4 or tier-5 armor was used. + int DR = bundle.getInt( "DR" ); + if (DR % 5 == 0){ + level((DR - 10)/5); + armorTier = 5; + } else { + level((DR - 8)/4); + armorTier = 4; + } + } else { + armorTier = bundle.getInt( ARMOR_TIER ); + } } @Override @@ -130,13 +138,14 @@ abstract public class ClassArmor extends Armor { abstract public void doSpecial(); @Override - public int DR(){ - return DR; + public int STRReq(int lvl) { + lvl = Math.max(0, lvl); + return (7 + armorTier * 2) - (int)(Math.sqrt(8 * lvl + 1) - 1)/2; } - + @Override - public boolean isUpgradable() { - return false; + public int DR(){ + return armorTier * (2 + level() + (glyph == null ? 0 : 1)); } @Override diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/quest/Pickaxe.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/quest/Pickaxe.java index e2ef5e9d4..45f3c22d7 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/quest/Pickaxe.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/quest/Pickaxe.java @@ -57,8 +57,7 @@ public class Pickaxe extends Weapon { unique = true; defaultAction = AC_MINE; - - STR = 14; + } public boolean bloodStained = false; @@ -73,6 +72,11 @@ public class Pickaxe extends Weapon { return 12; } + @Override + public int STRReq(int lvl) { + return 14; + } + @Override public ArrayList actions( Hero hero ) { ArrayList actions = super.actions( hero ); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/Weapon.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/Weapon.java index 3500cc9da..153134514 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/Weapon.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/Weapon.java @@ -53,8 +53,7 @@ abstract public class Weapon extends KindOfWeapon { private static final int HITS_TO_KNOW = 20; private static final String TXT_TO_STRING = "%s :%d"; - - public int STR = 10; + public float ACU = 1; // Accuracy modifier public float DLY = 1f; // Speed modifier @@ -108,7 +107,7 @@ abstract public class Weapon extends KindOfWeapon { @Override public float acuracyFactor( Hero hero ) { - int encumbrance = STR - hero.STR(); + int encumbrance = STRReq() - hero.STR(); float ACU = this.ACU; @@ -129,7 +128,7 @@ abstract public class Weapon extends KindOfWeapon { @Override public float speedFactor( Hero hero ) { - int encumrance = STR - hero.STR(); + int encumrance = STRReq() - hero.STR(); if (this instanceof MissileWeapon && hero.heroClass == HeroClass.HUNTRESS) { encumrance -= 2; } @@ -153,7 +152,7 @@ abstract public class Weapon extends KindOfWeapon { int damage = super.damageRoll( hero ); if (this instanceof MeleeWeapon || (this instanceof MissileWeapon && hero.heroClass == HeroClass.HUNTRESS)) { - int exStr = hero.STR() - STR; + int exStr = hero.STR() - STRReq(); if (exStr > 0) { damage += Random.IntRange( 0, exStr ); } @@ -161,6 +160,12 @@ abstract public class Weapon extends KindOfWeapon { return Math.round(damage * (imbue == Imbue.LIGHT ? 0.7f : (imbue == Imbue.HEAVY ? 1.5f : 1f))); } + + public int STRReq(){ + return STRReq(level()); + } + + public abstract int STRReq(int lvl); public Item upgrade( boolean enchant ) { if (enchantment != null) { @@ -179,7 +184,7 @@ abstract public class Weapon extends KindOfWeapon { @Override public String toString() { - return levelKnown ? Messages.format( TXT_TO_STRING, super.toString(), STR ) : super.toString(); + return levelKnown ? Messages.format( TXT_TO_STRING, super.toString(), STRReq() ) : super.toString(); } @Override diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/MagesStaff.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/MagesStaff.java index 7a4c4943a..84d2df1a2 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/MagesStaff.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/MagesStaff.java @@ -196,8 +196,6 @@ public class MagesStaff extends MeleeWeapon { @Override public Item upgrade(boolean enchant) { super.upgrade( enchant ); - STR = 10; - //does not lose strength requirement if (wand != null) { int curCharges = wand.curCharges; @@ -215,8 +213,6 @@ public class MagesStaff extends MeleeWeapon { public Item degrade() { super.degrade(); - STR = 10; - if (wand != null) { int curCharges = wand.curCharges; wand.degrade(); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/MeleeWeapon.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/MeleeWeapon.java index 9815f4bdd..5cfca6651 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/MeleeWeapon.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/MeleeWeapon.java @@ -37,9 +37,6 @@ public class MeleeWeapon extends Weapon { ACU = acu; DLY = dly; - - STR = typicalSTR(); - } protected int minBase() { @@ -65,24 +62,14 @@ public class MeleeWeapon extends Weapon { return upgrade( false ); } - public Item upgrade( boolean enchant ) { - STR--; - - return super.upgrade( enchant ); - } - public Item safeUpgrade() { return upgrade( enchantment != null ); } - - @Override - public Item degrade() { - STR++; - return super.degrade(); - } - - public int typicalSTR() { - return 8 + tier * 2; + + public int STRReq(int lvl){ + lvl = Math.max(0, lvl); + //strength req decreases at +1,+3,+6,+10,etc. + return (8 + tier * 2) - (int)(Math.sqrt(8 * lvl + 1) - 1)/2; } @Override @@ -101,8 +88,8 @@ public class MeleeWeapon extends Weapon { } else { int min = minBase(); int max = maxBase(); - info += " " + Messages.get(MeleeWeapon.class, "unknown", (min + (max - min) / 2), typicalSTR()); - if (typicalSTR() > Dungeon.hero.STR()) { + info += " " + Messages.get(MeleeWeapon.class, "unknown", (min + (max - min) / 2), STRReq(0)); + if (STRReq(0) > Dungeon.hero.STR()) { info += " " + Messages.get(MeleeWeapon.class, "probably_too_heavy"); } } @@ -120,7 +107,7 @@ public class MeleeWeapon extends Weapon { String stats_desc = Messages.get(this, "stats_desc"); if (!stats_desc.equals("")) info+= "\n\n" + stats_desc; - if (levelKnown && STR > Dungeon.hero.STR()) { + if (levelKnown && STRReq() > Dungeon.hero.STR()) { info += "\n\n" + Messages.get(Weapon.class, "too_heavy"); } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/Boomerang.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/Boomerang.java index d4a321b94..71aad8516 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/Boomerang.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/Boomerang.java @@ -35,8 +35,6 @@ public class Boomerang extends MissileWeapon { { image = ItemSpriteSheet.BOOMERANG; - - STR = 10; stackable = false; @@ -61,6 +59,12 @@ public class Boomerang extends MissileWeapon { return 5 + 2 * level(); } + @Override + public int STRReq(int lvl) { + lvl = Math.max(0, lvl); + return 10 - (int)(Math.sqrt(8 * lvl + 1) - 1)/2; + } + @Override public boolean isUpgradable() { return true; diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/CurareDart.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/CurareDart.java index 76c57baea..633faa5ba 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/CurareDart.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/CurareDart.java @@ -33,8 +33,6 @@ public class CurareDart extends MissileWeapon { { image = ItemSpriteSheet.CURARE_DART; - - STR = 14; } @Override @@ -47,6 +45,11 @@ public class CurareDart extends MissileWeapon { return 3; } + @Override + public int STRReq(int lvl) { + return 14; + } + public CurareDart() { this( 1 ); } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/Dart.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/Dart.java index c2d30a22f..93383526d 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/Dart.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/Dart.java @@ -42,6 +42,11 @@ public class Dart extends MissileWeapon { return 4; } + @Override + public int STRReq(int lvl) { + return 10; + } + public Dart() { this( 1 ); } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/IncendiaryDart.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/IncendiaryDart.java index 8aa231a87..79900e42d 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/IncendiaryDart.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/IncendiaryDart.java @@ -36,8 +36,6 @@ public class IncendiaryDart extends MissileWeapon { { image = ItemSpriteSheet.INCENDIARY_DART; - - STR = 12; } @Override @@ -50,6 +48,11 @@ public class IncendiaryDart extends MissileWeapon { return 2; } + @Override + public int STRReq(int lvl) { + return 12; + } + public IncendiaryDart() { this( 1 ); } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/Javelin.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/Javelin.java index 022e05d9d..6c2104572 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/Javelin.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/Javelin.java @@ -31,8 +31,6 @@ public class Javelin extends MissileWeapon { { image = ItemSpriteSheet.JAVELIN; - - STR = 15; } @Override @@ -45,6 +43,11 @@ public class Javelin extends MissileWeapon { return 15; } + @Override + public int STRReq(int lvl) { + return 15; + } + public Javelin() { this( 1 ); } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/MissileWeapon.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/MissileWeapon.java index ed946005b..cea6e3b71 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/MissileWeapon.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/MissileWeapon.java @@ -131,7 +131,7 @@ abstract public class MissileWeapon extends Weapon { info += "\n\n" + Messages.get( Weapon.class, "avg_dmg",(min() + (max() - min()) / 2)); - if (STR > Dungeon.hero.STR()) { + if (STRReq() > Dungeon.hero.STR()) { info += Messages.get(Weapon.class, "too_heavy"); } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/Shuriken.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/Shuriken.java index 057564c8d..930113101 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/Shuriken.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/Shuriken.java @@ -28,8 +28,6 @@ public class Shuriken extends MissileWeapon { { image = ItemSpriteSheet.SHURIKEN; - - STR = 13; DLY = 0.5f; } @@ -44,6 +42,11 @@ public class Shuriken extends MissileWeapon { return 6; } + @Override + public int STRReq(int lvl) { + return 13; + } + public Shuriken() { this( 1 ); } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/Tamahawk.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/Tamahawk.java index 59c2fb18e..93bbe71c6 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/Tamahawk.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/Tamahawk.java @@ -31,8 +31,7 @@ public class Tamahawk extends MissileWeapon { { image = ItemSpriteSheet.TOMAHAWK; - - STR = 17; + } @Override @@ -45,6 +44,11 @@ public class Tamahawk extends MissileWeapon { return 20; } + @Override + public int STRReq(int lvl) { + return 17; + } + public Tamahawk() { this( 1 ); } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/ui/ItemSlot.java b/src/com/shatteredpixel/shatteredpixeldungeon/ui/ItemSlot.java index f37746b0c..656516d5f 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/ui/ItemSlot.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/ui/ItemSlot.java @@ -165,7 +165,7 @@ public class ItemSlot extends Button { if (item.levelKnown || (isWeapon && !(item instanceof MeleeWeapon))) { - int str = isArmor ? ((Armor)item).STR : ((Weapon)item).STR; + int str = isArmor ? ((Armor)item).STRReq() : ((Weapon)item).STRReq(); topRight.text( Messages.format( TXT_STRENGTH, str ) ); if (str > Dungeon.hero.STR()) { topRight.hardlight( DEGRADED ); @@ -176,8 +176,8 @@ public class ItemSlot extends Button { } else { topRight.text( Messages.format( TXT_TYPICAL_STR, isArmor ? - ((Armor)item).typicalSTR() : - ((MeleeWeapon)item).typicalSTR() ) ); + ((Armor)item).STRReq(0) : + ((Weapon)item).STRReq(0) ) ); topRight.hardlight( WARNING ); }