v0.7.2: overhauled how items are IDed through use.
This commit is contained in:
parent
836782a0fc
commit
247cfc1f97
|
@ -79,6 +79,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.keys.IronKey;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.items.keys.Key;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.keys.SkeletonKey;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfExperience;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfStrength;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfAccuracy;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfEvasion;
|
||||
|
@ -1210,7 +1211,7 @@ public class Hero extends Char {
|
|||
return true;
|
||||
}
|
||||
|
||||
public void earnExp( int exp ) {
|
||||
public void earnExp( int exp, Class source ) {
|
||||
|
||||
this.exp += exp;
|
||||
float percent = exp/(float)maxExp();
|
||||
|
@ -1227,6 +1228,12 @@ public class Hero extends Char {
|
|||
Berserk berserk = buff(Berserk.class);
|
||||
if (berserk != null) berserk.recover(percent);
|
||||
|
||||
if (source != PotionOfExperience.class) {
|
||||
for (Item i : belongings) {
|
||||
i.onHeroGainExp(percent, this);
|
||||
}
|
||||
}
|
||||
|
||||
boolean levelUp = false;
|
||||
while (this.exp >= maxExp()) {
|
||||
this.exp -= maxExp();
|
||||
|
|
|
@ -584,7 +584,7 @@ public abstract class Mob extends Char {
|
|||
if (exp > 0) {
|
||||
Dungeon.hero.sprite.showStatus(CharSprite.POSITIVE, Messages.get(this, "exp", exp));
|
||||
}
|
||||
Dungeon.hero.earnExp(exp);
|
||||
Dungeon.hero.earnExp(exp, getClass());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -367,6 +367,10 @@ public class Item implements Bundlable {
|
|||
return this;
|
||||
}
|
||||
|
||||
public void onHeroGainExp( float levelPercent, Hero hero ){
|
||||
//do nothing by default
|
||||
}
|
||||
|
||||
public static void evoke( Hero hero ) {
|
||||
hero.sprite.emitter().burst( Speck.factory( Speck.EVOKE ), 5 );
|
||||
}
|
||||
|
|
|
@ -71,8 +71,6 @@ import java.util.Arrays;
|
|||
|
||||
public class Armor extends EquipableItem {
|
||||
|
||||
private static final int HITS_TO_KNOW = 10;
|
||||
|
||||
protected static final String AC_DETACH = "DETACH";
|
||||
|
||||
public enum Augment {
|
||||
|
@ -103,13 +101,13 @@ public class Armor extends EquipableItem {
|
|||
|
||||
public int tier;
|
||||
|
||||
private int hitsToKnow = HITS_TO_KNOW;
|
||||
private float levelsToID = 1;
|
||||
|
||||
public Armor( int tier ) {
|
||||
this.tier = tier;
|
||||
}
|
||||
|
||||
private static final String UNFAMILIRIARITY = "unfamiliarity";
|
||||
private static final String LEVELS_TO_ID = "levels_to_ID";
|
||||
private static final String GLYPH = "glyph";
|
||||
private static final String SEAL = "seal";
|
||||
private static final String AUGMENT = "augment";
|
||||
|
@ -117,7 +115,7 @@ public class Armor extends EquipableItem {
|
|||
@Override
|
||||
public void storeInBundle( Bundle bundle ) {
|
||||
super.storeInBundle( bundle );
|
||||
bundle.put( UNFAMILIRIARITY, hitsToKnow );
|
||||
bundle.put( LEVELS_TO_ID, levelsToID );
|
||||
bundle.put( GLYPH, glyph );
|
||||
bundle.put( SEAL, seal);
|
||||
bundle.put( AUGMENT, augment);
|
||||
|
@ -126,9 +124,15 @@ public class Armor extends EquipableItem {
|
|||
@Override
|
||||
public void restoreFromBundle( Bundle bundle ) {
|
||||
super.restoreFromBundle(bundle);
|
||||
hitsToKnow = bundle.getInt( UNFAMILIRIARITY );
|
||||
levelsToID = bundle.getFloat( LEVELS_TO_ID );
|
||||
inscribe((Glyph) bundle.get(GLYPH));
|
||||
seal = (BrokenSeal)bundle.get(SEAL);
|
||||
|
||||
//pre-0.7.2 saves
|
||||
if (bundle.contains( "unfamiliarity" )){
|
||||
levelsToID = bundle.getInt( "unfamiliarity" ) / 10f;
|
||||
}
|
||||
|
||||
//pre-0.6.5 saves
|
||||
if (bundle.contains(AUGMENT)) augment = bundle.getEnum(AUGMENT, Augment.class);
|
||||
}
|
||||
|
@ -358,18 +362,26 @@ public class Armor extends EquipableItem {
|
|||
damage = glyph.proc( this, attacker, defender, damage );
|
||||
}
|
||||
|
||||
if (!levelKnown && defender instanceof Hero) {
|
||||
if (--hitsToKnow <= 0) {
|
||||
return damage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHeroGainExp(float levelPercent, Hero hero) {
|
||||
if (levelKnown || !isEquipped(hero)) return;
|
||||
levelsToID -= levelPercent;
|
||||
if (levelsToID <= 0){
|
||||
identify();
|
||||
GLog.w( Messages.get(Armor.class, "identify") );
|
||||
GLog.p( Messages.get(Armor.class, "identify") );
|
||||
Badges.validateItemLevelAquired( this );
|
||||
}
|
||||
}
|
||||
|
||||
return damage;
|
||||
@Override
|
||||
public Item identify() {
|
||||
levelsToID = 0;
|
||||
return super.identify();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return glyph != null && (cursedKnown || !glyph.curse()) ? glyph.name( super.name() ) : super.name();
|
||||
|
|
|
@ -34,7 +34,7 @@ public class PotionOfExperience extends Potion {
|
|||
@Override
|
||||
public void apply( Hero hero ) {
|
||||
setKnown();
|
||||
hero.earnExp( hero.maxExp() );
|
||||
hero.earnExp( hero.maxExp(), getClass() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -81,7 +81,7 @@ public class Ring extends KindofMisc {
|
|||
|
||||
private String gem;
|
||||
|
||||
private int ticksToKnow = TICKS_TO_KNOW;
|
||||
private float levelsToID = 1;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void initGems() {
|
||||
|
@ -211,6 +211,7 @@ public class Ring extends KindofMisc {
|
|||
@Override
|
||||
public Item identify() {
|
||||
setKnown();
|
||||
levelsToID = 0;
|
||||
return super.identify();
|
||||
}
|
||||
|
||||
|
@ -271,19 +272,22 @@ public class Ring extends KindofMisc {
|
|||
return null;
|
||||
}
|
||||
|
||||
private static final String UNFAMILIRIARITY = "unfamiliarity";
|
||||
private static final String LEVELS_TO_ID = "levels_to_ID";
|
||||
|
||||
@Override
|
||||
public void storeInBundle( Bundle bundle ) {
|
||||
super.storeInBundle( bundle );
|
||||
bundle.put( UNFAMILIRIARITY, ticksToKnow );
|
||||
bundle.put( LEVELS_TO_ID, levelsToID );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreFromBundle( Bundle bundle ) {
|
||||
super.restoreFromBundle( bundle );
|
||||
if ((ticksToKnow = bundle.getInt( UNFAMILIRIARITY )) == 0) {
|
||||
ticksToKnow = TICKS_TO_KNOW;
|
||||
levelsToID = bundle.getFloat( LEVELS_TO_ID );
|
||||
|
||||
//pre-0.7.2 saves
|
||||
if (bundle.contains( "unfamiliarity" )){
|
||||
levelsToID = bundle.getInt( "unfamiliarity" ) / 200f;
|
||||
}
|
||||
|
||||
//pre-0.6.1 saves
|
||||
|
@ -292,6 +296,16 @@ public class Ring extends KindofMisc {
|
|||
}
|
||||
}
|
||||
|
||||
public void onHeroGainExp( float levelPercent, Hero hero ){
|
||||
if (!isIdentified() || !isEquipped(hero)) return;
|
||||
levelsToID -= levelPercent;
|
||||
if (levelsToID <= 0){
|
||||
identify();
|
||||
GLog.p( Messages.get(Ring.class, "identify", toString()) );
|
||||
Badges.validateItemLevelAquired( this );
|
||||
}
|
||||
}
|
||||
|
||||
public static int getBonus(Char target, Class<?extends RingBuff> type){
|
||||
int bonus = 0;
|
||||
for (RingBuff buff : target.buffs(type)) {
|
||||
|
@ -313,12 +327,6 @@ public class Ring extends KindofMisc {
|
|||
@Override
|
||||
public boolean act() {
|
||||
|
||||
if (!isIdentified() && --ticksToKnow <= 0) {
|
||||
identify();
|
||||
GLog.w( Messages.get(Ring.class, "identify", Ring.this.toString()) );
|
||||
Badges.validateItemLevelAquired( Ring.this );
|
||||
}
|
||||
|
||||
spend( TICK );
|
||||
|
||||
return true;
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
package com.shatteredpixel.shatteredpixeldungeon.items.wands;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Badges;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
|
@ -71,6 +72,10 @@ public abstract class Wand extends Item {
|
|||
private boolean curChargeKnown = false;
|
||||
|
||||
protected int usagesToKnow = USAGES_TO_KNOW;
|
||||
private float levelsToID = 1;
|
||||
//wands can't be equipped, so the player needs to use them in addition to gaining exp
|
||||
//takes 5 charges spent, giving 15% exp gain each, plus 25% given right away
|
||||
private float levelsToIDAvailable = 0.25f;
|
||||
|
||||
protected int collisionProperties = Ballistica.MAGIC_BOLT;
|
||||
|
||||
|
@ -171,6 +176,7 @@ public abstract class Wand extends Item {
|
|||
@Override
|
||||
public Item identify() {
|
||||
|
||||
levelsToID = levelsToIDAvailable = 0;
|
||||
curChargeKnown = true;
|
||||
super.identify();
|
||||
|
||||
|
@ -179,6 +185,17 @@ public abstract class Wand extends Item {
|
|||
return this;
|
||||
}
|
||||
|
||||
public void onHeroGainExp( float levelPercent, Hero hero ){
|
||||
if (isIdentified()) return;
|
||||
levelsToID -= Math.min(levelsToIDAvailable, levelPercent);
|
||||
levelsToIDAvailable = Math.max(0, levelsToIDAvailable - levelPercent);
|
||||
if (levelsToID <= 0){
|
||||
identify();
|
||||
GLog.p( Messages.get(Wand.class, "identify", name()) );
|
||||
Badges.validateItemLevelAquired( this );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String info() {
|
||||
String desc = desc();
|
||||
|
@ -269,15 +286,12 @@ public abstract class Wand extends Item {
|
|||
}
|
||||
|
||||
protected void wandUsed() {
|
||||
usagesToKnow -= cursed ? 1 : chargesPerCast();
|
||||
if (!isIdentified()) levelsToIDAvailable += 0.15f * (cursed ? 1 : chargesPerCast());
|
||||
|
||||
curCharges -= cursed ? 1 : chargesPerCast();
|
||||
if (!isIdentified() && usagesToKnow <= 0) {
|
||||
identify();
|
||||
GLog.w( Messages.get(Wand.class, "identify", name()) );
|
||||
} else {
|
||||
|
||||
if (curUser.heroClass == HeroClass.MAGE) levelKnown = true;
|
||||
updateQuickslot();
|
||||
}
|
||||
|
||||
curUser.spendAndNext( TIME_TO_ZAP );
|
||||
}
|
||||
|
@ -323,7 +337,8 @@ public abstract class Wand extends Item {
|
|||
return price;
|
||||
}
|
||||
|
||||
private static final String UNFAMILIRIARITY = "unfamiliarity";
|
||||
private static final String LEVELS_TO_ID = "levels_to_ID";
|
||||
private static final String LEVELS_TO_ID_AVA = "levels_to_ID_available";
|
||||
private static final String CUR_CHARGES = "curCharges";
|
||||
private static final String CUR_CHARGE_KNOWN = "curChargeKnown";
|
||||
private static final String PARTIALCHARGE = "partialCharge";
|
||||
|
@ -331,7 +346,8 @@ public abstract class Wand extends Item {
|
|||
@Override
|
||||
public void storeInBundle( Bundle bundle ) {
|
||||
super.storeInBundle( bundle );
|
||||
bundle.put( UNFAMILIRIARITY, usagesToKnow );
|
||||
bundle.put( LEVELS_TO_ID, levelsToID );
|
||||
bundle.put( LEVELS_TO_ID_AVA, levelsToIDAvailable );
|
||||
bundle.put( CUR_CHARGES, curCharges );
|
||||
bundle.put( CUR_CHARGE_KNOWN, curChargeKnown );
|
||||
bundle.put( PARTIALCHARGE , partialCharge );
|
||||
|
@ -340,8 +356,13 @@ public abstract class Wand extends Item {
|
|||
@Override
|
||||
public void restoreFromBundle( Bundle bundle ) {
|
||||
super.restoreFromBundle( bundle );
|
||||
if ((usagesToKnow = bundle.getInt( UNFAMILIRIARITY )) == 0) {
|
||||
usagesToKnow = USAGES_TO_KNOW;
|
||||
levelsToID = bundle.getFloat( LEVELS_TO_ID );
|
||||
levelsToIDAvailable = bundle.getFloat( LEVELS_TO_ID_AVA );
|
||||
|
||||
//pre-0.7.2 saves
|
||||
if (bundle.contains( "unfamiliarity" )){
|
||||
levelsToID = bundle.getInt( "unfamiliarity" ) / 20f;
|
||||
levelsToIDAvailable = levelsToID;
|
||||
}
|
||||
curCharges = bundle.getInt( CUR_CHARGES );
|
||||
curChargeKnown = bundle.getBoolean( CUR_CHARGE_KNOWN );
|
||||
|
|
|
@ -233,9 +233,9 @@ public class WandOfCorruption extends Wand {
|
|||
Statistics.qualifiedForNoKilling = false;
|
||||
if (enemy.EXP > 0 && curUser.lvl <= enemy.maxLvl) {
|
||||
curUser.sprite.showStatus(CharSprite.POSITIVE, Messages.get(enemy, "exp", enemy.EXP));
|
||||
curUser.earnExp(enemy.EXP);
|
||||
curUser.earnExp(enemy.EXP, enemy.getClass());
|
||||
} else {
|
||||
curUser.earnExp(0);
|
||||
curUser.earnExp(0, enemy.getClass());
|
||||
}
|
||||
enemy.rollToDropLoot();
|
||||
} else {
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
package com.shatteredpixel.shatteredpixeldungeon.items.weapon;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Badges;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.MagicImmune;
|
||||
|
@ -93,7 +92,7 @@ abstract public class Weapon extends KindOfWeapon {
|
|||
|
||||
public Augment augment = Augment.NONE;
|
||||
|
||||
private int hitsToKnow = HITS_TO_KNOW;
|
||||
private float levelsToID = 1;
|
||||
|
||||
public Enchantment enchantment;
|
||||
|
||||
|
@ -104,25 +103,33 @@ abstract public class Weapon extends KindOfWeapon {
|
|||
damage = enchantment.proc( this, attacker, defender, damage );
|
||||
}
|
||||
|
||||
if (!levelKnown && attacker == Dungeon.hero) {
|
||||
if (--hitsToKnow <= 0) {
|
||||
return damage;
|
||||
}
|
||||
|
||||
public void onHeroGainExp( float levelPercent, Hero hero ){
|
||||
if (levelKnown || !isEquipped(hero)) return;
|
||||
levelsToID -= levelPercent;
|
||||
if (levelsToID <= 0){
|
||||
identify();
|
||||
GLog.i( Messages.get(Weapon.class, "identify") );
|
||||
GLog.p( Messages.get(Weapon.class, "identify") );
|
||||
Badges.validateItemLevelAquired( this );
|
||||
}
|
||||
}
|
||||
|
||||
return damage;
|
||||
@Override
|
||||
public Item identify() {
|
||||
levelsToID = 0;
|
||||
return super.identify();
|
||||
}
|
||||
|
||||
private static final String UNFAMILIRIARITY = "unfamiliarity";
|
||||
private static final String LEVELS_TO_ID = "levels_to_ID";
|
||||
private static final String ENCHANTMENT = "enchantment";
|
||||
private static final String AUGMENT = "augment";
|
||||
|
||||
@Override
|
||||
public void storeInBundle( Bundle bundle ) {
|
||||
super.storeInBundle( bundle );
|
||||
bundle.put( UNFAMILIRIARITY, hitsToKnow );
|
||||
bundle.put( LEVELS_TO_ID, levelsToID );
|
||||
bundle.put( ENCHANTMENT, enchantment );
|
||||
bundle.put( AUGMENT, augment );
|
||||
}
|
||||
|
@ -130,9 +137,14 @@ abstract public class Weapon extends KindOfWeapon {
|
|||
@Override
|
||||
public void restoreFromBundle( Bundle bundle ) {
|
||||
super.restoreFromBundle( bundle );
|
||||
hitsToKnow = bundle.getInt( UNFAMILIRIARITY );
|
||||
levelsToID = bundle.getFloat( LEVELS_TO_ID );
|
||||
enchantment = (Enchantment)bundle.get( ENCHANTMENT );
|
||||
|
||||
//pre-0.7.2 saves
|
||||
if (bundle.contains( "unfamiliarity" )){
|
||||
levelsToID = bundle.getInt( "unfamiliarity" ) / 20f;
|
||||
}
|
||||
|
||||
//pre-0.6.5 saves
|
||||
if (bundle.contains( "imbue" )){
|
||||
String imbue = bundle.getString( "imbue" );
|
||||
|
|
Loading…
Reference in New Issue
Block a user