v0.3.5: lots of broken sigil implementation
This commit is contained in:
@@ -1,11 +1,72 @@
|
||||
package com.shatteredpixel.shatteredpixeldungeon.items;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag;
|
||||
import com.watabou.noosa.audio.Sample;
|
||||
|
||||
//TODO: add actual item properties here
|
||||
public class BrokenSigil {
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class BrokenSigil extends Item {
|
||||
|
||||
public static final String AC_AFFIX = "AFFIX";
|
||||
|
||||
{
|
||||
image = ItemSpriteSheet.SIGIL;
|
||||
|
||||
cursedKnown = levelKnown = true;
|
||||
unique = true;
|
||||
bones = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> actions(Hero hero) {
|
||||
ArrayList<String> actions = super.actions(hero);
|
||||
actions.add(AC_AFFIX);
|
||||
return actions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Hero hero, String action) {
|
||||
if (action.equals(AC_AFFIX)){
|
||||
curItem = this;
|
||||
GameScene.selectItem(armorSelector, WndBag.Mode.ARMOR, Messages.get(this, "prompt"));
|
||||
} else {
|
||||
super.execute(hero, action);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUpgradable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected static WndBag.Listener armorSelector = new WndBag.Listener() {
|
||||
@Override
|
||||
public void onSelect( Item item ) {
|
||||
if (item != null && item instanceof Armor) {
|
||||
Armor armor = (Armor)item;
|
||||
if (!armor.levelKnown){
|
||||
GLog.w(Messages.get(BrokenSigil.class, "unknown_armor"));
|
||||
} else if (armor.cursed || armor.level() < 0){
|
||||
GLog.w(Messages.get(BrokenSigil.class, "degraded_armor"));
|
||||
} else {
|
||||
GLog.p(Messages.get(BrokenSigil.class, "affix"));
|
||||
Dungeon.hero.sprite.operate(Dungeon.hero.pos);
|
||||
Sample.INSTANCE.play(Assets.SND_UNLOCK);
|
||||
armor.affixSigil((BrokenSigil)curItem);
|
||||
curItem.detach(Dungeon.hero.belongings.backpack);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public static class SigilShield extends Buff {
|
||||
|
||||
@@ -16,10 +77,9 @@ public class BrokenSigil {
|
||||
public boolean act() {
|
||||
if (armor == null) detach();
|
||||
else if (armor.isEquipped((Hero)target)) {
|
||||
//1 + half of your DR, rounded up.
|
||||
int maxShield = (int)(armor.DR()/2f + 1.5f);
|
||||
int maxShield = 1 + armor.tier + armor.level();
|
||||
if (target.SHLD < maxShield){
|
||||
partialShield += (maxShield - target.SHLD)/50f;
|
||||
partialShield += 1/(30*Math.pow(0.9f, (maxShield - target.SHLD)));
|
||||
}
|
||||
}
|
||||
while (partialShield >= 1){
|
||||
|
||||
@@ -117,8 +117,8 @@ public class Item implements Bundlable {
|
||||
Dungeon.level.drop( detachAll( hero.belongings.backpack ), hero.pos ).sprite.drop( hero.pos );
|
||||
}
|
||||
|
||||
//'syncs' an item to be consistent between two separate game instances.
|
||||
public void sync(){
|
||||
//resets an item's properties, to ensure consistency between runs
|
||||
public void reset(){
|
||||
//resets the name incase the language has changed.
|
||||
name = Messages.get(this, "name");
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.BrokenSigil;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem;
|
||||
@@ -49,11 +48,14 @@ import com.watabou.utils.Bundlable;
|
||||
import com.watabou.utils.Bundle;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Armor extends EquipableItem {
|
||||
|
||||
private static final int HITS_TO_KNOW = 10;
|
||||
|
||||
private static final String TXT_TO_STRING = "%s :%d";
|
||||
private static final String AC_DETACH = "DETACH";
|
||||
|
||||
public int tier;
|
||||
|
||||
@@ -73,11 +75,14 @@ public class Armor extends EquipableItem {
|
||||
|
||||
private static final String UNFAMILIRIARITY = "unfamiliarity";
|
||||
private static final String GLYPH = "glyph";
|
||||
private static final String SIGIL = "sigil";
|
||||
|
||||
@Override
|
||||
public void storeInBundle( Bundle bundle ) {
|
||||
super.storeInBundle( bundle );
|
||||
bundle.put( UNFAMILIRIARITY, hitsToKnow );
|
||||
bundle.put( GLYPH, glyph );
|
||||
bundle.put( SIGIL, sigil );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -87,6 +92,44 @@ public class Armor extends EquipableItem {
|
||||
hitsToKnow = HITS_TO_KNOW;
|
||||
}
|
||||
inscribe((Glyph) bundle.get(GLYPH));
|
||||
sigil = bundle.getBoolean(SIGIL);
|
||||
if (sigil) unique = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
super.reset();
|
||||
//armor can be kept in bones between runs, the sigil cannot.
|
||||
sigil = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> actions(Hero hero) {
|
||||
ArrayList<String> actions = super.actions(hero);
|
||||
if (sigil) actions.add(AC_DETACH);
|
||||
return actions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Hero hero, String action) {
|
||||
if (action.equals(AC_DETACH) && sigil){
|
||||
sigil = false;
|
||||
BrokenSigil.SigilShield sigilBuff = hero.buff(BrokenSigil.SigilShield.class);
|
||||
if (sigilBuff != null) sigilBuff.setArmor(null);
|
||||
|
||||
BrokenSigil sigil = new BrokenSigil();
|
||||
if (level() > 0){
|
||||
sigil.upgrade();
|
||||
degrade();
|
||||
}
|
||||
GLog.i( Messages.get(Armor.class, "detach_sigil") );
|
||||
hero.sprite.operate(hero.pos);
|
||||
if (!sigil.collect()){
|
||||
Dungeon.level.drop(sigil, hero.pos);
|
||||
}
|
||||
} else {
|
||||
super.execute(hero, action);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -120,8 +163,18 @@ public class Armor extends EquipableItem {
|
||||
|
||||
@Override
|
||||
public void activate(Char ch) {
|
||||
if (Dungeon.hero.heroClass == HeroClass.WARRIOR)
|
||||
Buff.affect(ch, BrokenSigil.SigilShield.class).setArmor(this);
|
||||
if (sigil) Buff.affect(ch, BrokenSigil.SigilShield.class).setArmor(this);
|
||||
}
|
||||
|
||||
public void affixSigil(BrokenSigil sigil){
|
||||
this.sigil = true;
|
||||
if (sigil.level() > 0){
|
||||
//doesn't override existing glyphs, but doesn't create one either
|
||||
upgrade(glyph != null);
|
||||
}
|
||||
if (isEquipped(Dungeon.hero)){
|
||||
Buff.affect(Dungeon.hero, BrokenSigil.SigilShield.class).setArmor(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -136,8 +189,8 @@ public class Armor extends EquipableItem {
|
||||
hero.belongings.armor = null;
|
||||
((HeroSprite)hero.sprite).updateArmor();
|
||||
|
||||
BrokenSigil.SigilShield sigil = hero.buff(BrokenSigil.SigilShield.class);
|
||||
if (sigil != null) sigil.setArmor(null);
|
||||
BrokenSigil.SigilShield sigilBuff = hero.buff(BrokenSigil.SigilShield.class);
|
||||
if (sigilBuff != null) sigilBuff.setArmor(null);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -247,8 +300,7 @@ public class Armor extends EquipableItem {
|
||||
|
||||
@Override
|
||||
public Emitter emitter() {
|
||||
//if (!sigil) return super.emitter();
|
||||
if (Dungeon.hero.heroClass != HeroClass.WARRIOR) return super.emitter();
|
||||
if (!sigil) return super.emitter();
|
||||
Emitter emitter = new Emitter();
|
||||
emitter.pos(10f, 6f);
|
||||
emitter.fillTarget = false;
|
||||
|
||||
@@ -268,10 +268,6 @@ public class LloydsBeacon extends Artifact {
|
||||
}
|
||||
return desc;
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
returnDepth = -1;
|
||||
}
|
||||
|
||||
private static final Glowing WHITE = new Glowing( 0xFFFFFF );
|
||||
|
||||
|
||||
@@ -20,32 +20,32 @@
|
||||
*/
|
||||
package com.shatteredpixel.shatteredpixeldungeon.items.potions;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
|
||||
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;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Fire;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Burning;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.watabou.noosa.audio.Sample;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Badges;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Splash;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.ItemStatusHandler;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions;
|
||||
import com.watabou.noosa.audio.Sample;
|
||||
import com.watabou.utils.Bundle;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
|
||||
public class Potion extends Item {
|
||||
|
||||
public static final String AC_DRINK = "DRINK";
|
||||
@@ -112,12 +112,12 @@ public class Potion extends Item {
|
||||
|
||||
public Potion() {
|
||||
super();
|
||||
sync();
|
||||
reset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sync(){
|
||||
super.sync();
|
||||
public void reset(){
|
||||
super.reset();
|
||||
image = handler.image( this );
|
||||
color = handler.label( this );
|
||||
};
|
||||
|
||||
@@ -92,11 +92,11 @@ public class Ring extends KindofMisc {
|
||||
|
||||
public Ring() {
|
||||
super();
|
||||
sync();
|
||||
reset();
|
||||
}
|
||||
|
||||
public void sync() {
|
||||
super.sync();
|
||||
public void reset() {
|
||||
super.reset();
|
||||
image = handler.image( this );
|
||||
gem = handler.label( this );
|
||||
}
|
||||
|
||||
@@ -100,12 +100,12 @@ public abstract class Scroll extends Item {
|
||||
|
||||
public Scroll() {
|
||||
super();
|
||||
sync();
|
||||
reset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sync(){
|
||||
super.sync();
|
||||
public void reset(){
|
||||
super.reset();
|
||||
image = handler.image( this );
|
||||
rune = handler.label( this );
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user