v0.4.0: lots of new curse implementation

This commit is contained in:
Evan Debenham 2016-06-09 03:37:53 -04:00 committed by Evan Debenham
parent c90e83f8d6
commit 4988be16fe
15 changed files with 318 additions and 78 deletions

View File

@ -142,12 +142,25 @@ public class ShatteredPixelDungeon extends Game {
com.watabou.utils.Bundle.addAlias( com.watabou.utils.Bundle.addAlias(
com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Chilling.class, com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Chilling.class,
"com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Slow" ); "com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Slow" );
com.watabou.utils.Bundle.addAlias( com.watabou.utils.Bundle.addAlias(
com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.Repulsion.class, com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.Repulsion.class,
"com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.Bounce" ); "com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.Bounce" );
com.watabou.utils.Bundle.addAlias( com.watabou.utils.Bundle.addAlias(
com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.Repulsion.class, com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.Repulsion.class,
"com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.Displacement" ); "com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.Displacement" );
com.watabou.utils.Bundle.addAlias(
com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.Potential.class,
"com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.AntiEntropy" );
com.watabou.utils.Bundle.addAlias(
com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.Entanglement.class,
"com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.Metabolism" );
com.watabou.utils.Bundle.addAlias(
com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.Entanglement.class,
"com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.Multiplicity" );
com.watabou.utils.Bundle.addAlias(
com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.Repulsion.class,
"com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.Stench" );
} }

View File

@ -278,7 +278,6 @@ public class Item implements Bundlable {
public Item upgrade() { public Item upgrade() {
cursed = false; cursed = false;
cursedKnown = true;
this.level++; this.level++;
updateQuickslot(); updateQuickslot();

View File

@ -27,9 +27,11 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck; import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ShadowParticle;
import com.shatteredpixel.shatteredpixeldungeon.items.BrokenSeal; import com.shatteredpixel.shatteredpixeldungeon.items.BrokenSeal;
import com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem; import com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem;
import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.curses.Stench;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.Affection; import com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.Affection;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.AntiMagic; import com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.AntiMagic;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.Brimstone; import com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.Brimstone;
@ -222,9 +224,19 @@ public class Armor extends EquipableItem {
public Item upgrade( boolean inscribe ) { public Item upgrade( boolean inscribe ) {
if (glyph != null) { if (glyph != null) {
if (!inscribe && Random.Float() > Math.pow(0.9, level())) { if (inscribe && glyph.curse()){
GLog.w( Messages.get(Armor.class, "incompatible") ); inscribe( Glyph.random() );
} else if (!inscribe && Random.Float() > Math.pow(0.9, level())) {
if (!glyph.curse())
GLog.w( Messages.get(Armor.class, "incompatible") );
else if (cursedKnown) {
GLog.p(Messages.get(Item.class, "remove_curse"));
Dungeon.hero.sprite.emitter().start( ShadowParticle.UP, 0.05f, 10 );
}
inscribe( null ); inscribe( null );
} else if (!inscribe && glyph.curse() && cursed && cursedKnown){
GLog.p( Messages.get(Item.class, "weaken_curse") );
Dungeon.hero.sprite.emitter().start( ShadowParticle.UP, 0.05f, 10 );
} }
} else { } else {
if (inscribe) { if (inscribe) {
@ -258,7 +270,7 @@ public class Armor extends EquipableItem {
@Override @Override
public String name() { public String name() {
return glyph == null ? super.name() : glyph.name( super.name() ); return glyph != null && (cursedKnown || !glyph.curse()) ? glyph.name( super.name() ) : super.name();
} }
@Override @Override
@ -281,7 +293,7 @@ public class Armor extends EquipableItem {
} }
} }
if (glyph != null) { if (glyph != null && (cursedKnown || !glyph.curse())) {
info += "\n\n" + Messages.get(Armor.class, "inscribed", glyph.name()); info += "\n\n" + Messages.get(Armor.class, "inscribed", glyph.name());
info += " " + glyph.desc(); info += " " + glyph.desc();
} }
@ -309,25 +321,25 @@ public class Armor extends EquipableItem {
@Override @Override
public Item random() { public Item random() {
if (Random.Float() < 0.4) { float roll = Random.Float();
int n = 1; if (roll < 0.3f){
if (Random.Int( 3 ) == 0) { //30% chance to be level 0 and cursed
n++; inscribe(Glyph.randomCurse());
if (Random.Int( 5 ) == 0) { cursed = true;
n++; return this;
} } else if (roll < 0.75f){
} //45% chance to be level 0
if (Random.Int( 2 ) == 0) { } else if (roll < 0.95f){
upgrade( n ); //15% chance to be +1
} else { upgrade(0);
degrade( n ); } else {
cursed = true; //5% chance to be +2
} upgrade(2);
} }
if (Random.Int( 10 ) == 0) { //if not cursed, 16.67% chance to be inscribed (11.67% overall)
if (Random.Int(6) == 0)
inscribe(); inscribe();
}
return this; return this;
} }
@ -395,7 +407,7 @@ public class Armor extends EquipableItem {
@Override @Override
public ItemSprite.Glowing glowing() { public ItemSprite.Glowing glowing() {
return glyph != null ? glyph.glowing() : null; return glyph != null && (cursedKnown || !glyph.curse()) ? glyph.glowing() : null;
} }
public static abstract class Glyph implements Bundlable { public static abstract class Glyph implements Bundlable {
@ -404,16 +416,22 @@ public class Armor extends EquipableItem {
Obfuscation.class, Swiftness.class, Stone.class, Potential.class, Obfuscation.class, Swiftness.class, Stone.class, Potential.class,
Brimstone.class, Viscosity.class, Entanglement.class, Repulsion.class, Camouflage.class, Flow.class, Brimstone.class, Viscosity.class, Entanglement.class, Repulsion.class, Camouflage.class, Flow.class,
Affection.class, AntiMagic.class, Thorns.class }; Affection.class, AntiMagic.class, Thorns.class };
private static final float[] chances= new float[]{ private static final float[] chances= new float[]{
10, 10, 10, 10, 10, 10, 10, 10,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
2, 2, 2 }; 2, 2, 2 };
private static final Class<?>[] curses = new Class<?>[]{
Stench.class
};
public abstract int proc( Armor armor, Char attacker, Char defender, int damage ); public abstract int proc( Armor armor, Char attacker, Char defender, int damage );
public String name() { public String name() {
return name( Messages.get(this, "glyph") ); if (!curse())
return name( Messages.get(this, "glyph") );
else
return name( Messages.get(Item.class, "curse"));
} }
public String name( String armorName ) { public String name( String armorName ) {
@ -424,6 +442,10 @@ public class Armor extends EquipableItem {
return Messages.get(this, "desc"); return Messages.get(this, "desc");
} }
public boolean curse() {
return false;
}
@Override @Override
public void restoreFromBundle( Bundle bundle ) { public void restoreFromBundle( Bundle bundle ) {
} }
@ -465,5 +487,14 @@ public class Armor extends EquipableItem {
} }
} }
@SuppressWarnings("unchecked")
public static Glyph randomCurse(){
try {
return ((Class<Glyph>)Random.oneOf(curses)).newInstance();
} catch (Exception e) {
return null;
}
}
} }
} }

View File

@ -18,31 +18,26 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/> * along with this program. If not, see <http://www.gnu.org/licenses/>
*/ */
package com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs; package com.shatteredpixel.shatteredpixeldungeon.items.armor.curses;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob; import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.ToxicGas; import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.ToxicGas;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor; import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor.Glyph;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite.Glowing;
import com.watabou.utils.Random; import com.watabou.utils.Random;
public class Stench extends Glyph { public class Stench extends Armor.Glyph {
private static ItemSprite.Glowing GREEN = new ItemSprite.Glowing( 0x22CC44 ); private static ItemSprite.Glowing BLACK = new ItemSprite.Glowing( 0x000000 );
@Override @Override
public int proc( Armor armor, Char attacker, Char defender, int damage) { public int proc(Armor armor, Char attacker, Char defender, int damage) {
int level = Math.max( 0, armor.level() ); if ( Random.Int( 6 ) == 0) {
if (Level.adjacent( attacker.pos, defender.pos ) && Random.Int( level + 5 ) >= 4) { GameScene.add( Blob.seed( attacker.pos, 250, ToxicGas.class ) );
GameScene.add( Blob.seed( attacker.pos, 20, ToxicGas.class ) );
} }
@ -50,8 +45,12 @@ public class Stench extends Glyph {
} }
@Override @Override
public Glowing glowing() { public ItemSprite.Glowing glowing() {
return GREEN; return BLACK;
} }
@Override
public boolean curse() {
return true;
}
} }

View File

@ -26,6 +26,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ShadowParticle;
import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.ItemStatusHandler; import com.shatteredpixel.shatteredpixeldungeon.items.ItemStatusHandler;
import com.shatteredpixel.shatteredpixeldungeon.items.KindofMisc; import com.shatteredpixel.shatteredpixeldungeon.items.KindofMisc;
@ -129,6 +130,11 @@ public class Ring extends KindofMisc {
@Override @Override
public Item upgrade() { public Item upgrade() {
if (cursed && cursedKnown) {
GLog.p( Messages.get(Item.class, "weaken_curse") );
Dungeon.hero.sprite.emitter().start( ShadowParticle.UP, 0.05f, 10 );
}
super.upgrade(); super.upgrade();
if (buff != null) { if (buff != null) {

View File

@ -43,7 +43,6 @@ public class ScrollOfMagicalInfusion extends InventoryScroll {
@Override @Override
protected void onItemSelected( Item item ) { protected void onItemSelected( Item item ) {
ScrollOfRemoveCurse.uncurse(Dungeon.hero, item);
if (item instanceof Weapon) if (item instanceof Weapon)
((Weapon)item).upgrade(true); ((Weapon)item).upgrade(true);
else else

View File

@ -27,7 +27,9 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.effects.Flare; import com.shatteredpixel.shatteredpixeldungeon.effects.Flare;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ShadowParticle; import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ShadowParticle;
import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor;
import com.shatteredpixel.shatteredpixeldungeon.items.bags.Bag; import com.shatteredpixel.shatteredpixeldungeon.items.bags.Bag;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.watabou.noosa.audio.Sample; import com.watabou.noosa.audio.Sample;
@ -73,6 +75,22 @@ public class ScrollOfRemoveCurse extends Scroll {
item.cursed = false; item.cursed = false;
procced = true; procced = true;
} }
if (item instanceof Weapon){
Weapon w = (Weapon) item;
if (w.enchantment != null && w.enchantment.curse()){
w.enchant(null);
w.cursed = false;
procced = true;
}
}
if (item instanceof Armor){
Armor a = (Armor) item;
if (a.glyph != null && a.glyph.curse()){
a.inscribe(null);
a.cursed = false;
procced = true;
}
}
if (item instanceof Bag){ if (item instanceof Bag){
for (Item bagItem : ((Bag)item).items){ for (Item bagItem : ((Bag)item).items){
if (bagItem != null && bagItem.cursed) { if (bagItem != null && bagItem.cursed) {

View File

@ -21,7 +21,6 @@
package com.shatteredpixel.shatteredpixeldungeon.items.scrolls; package com.shatteredpixel.shatteredpixeldungeon.items.scrolls;
import com.shatteredpixel.shatteredpixeldungeon.Badges; import com.shatteredpixel.shatteredpixeldungeon.Badges;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck; import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.Item;
@ -41,7 +40,6 @@ public class ScrollOfUpgrade extends InventoryScroll {
@Override @Override
protected void onItemSelected( Item item ) { protected void onItemSelected( Item item ) {
ScrollOfRemoveCurse.uncurse( Dungeon.hero, item );
item.upgrade(); item.upgrade();
upgrade( curUser ); upgrade( curUser );

View File

@ -33,6 +33,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroSubClass; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroSubClass;
import com.shatteredpixel.shatteredpixeldungeon.effects.MagicMissile; import com.shatteredpixel.shatteredpixeldungeon.effects.MagicMissile;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ShadowParticle;
import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.bags.Bag; import com.shatteredpixel.shatteredpixeldungeon.items.bags.Bag;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MagesStaff; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MagesStaff;
@ -185,6 +186,11 @@ public abstract class Wand extends Item {
@Override @Override
public Item upgrade() { public Item upgrade() {
if (cursed && cursedKnown) {
GLog.p( Messages.get(Item.class, "remove_curse") );
Dungeon.hero.sprite.emitter().start( ShadowParticle.UP, 0.05f, 10 );
}
super.upgrade(); super.upgrade();
updateLevel(); updateLevel();

View File

@ -21,14 +21,18 @@
package com.shatteredpixel.shatteredpixeldungeon.items.weapon; package com.shatteredpixel.shatteredpixeldungeon.items.weapon;
import com.shatteredpixel.shatteredpixeldungeon.Badges; import com.shatteredpixel.shatteredpixeldungeon.Badges;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ShadowParticle;
import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.KindOfWeapon; import com.shatteredpixel.shatteredpixeldungeon.items.KindOfWeapon;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfFuror; import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfFuror;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfSharpshooting; import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfSharpshooting;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.curses.Fragile;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.curses.Wayward;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Blazing; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Blazing;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Chilling; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Chilling;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Dazzling; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Dazzling;
@ -115,12 +119,12 @@ abstract public class Weapon extends KindOfWeapon {
int encumbrance = STRReq() - hero.STR(); int encumbrance = STRReq() - hero.STR();
if (enchantment instanceof Wayward)
encumbrance = Math.max(3, encumbrance+3);
float ACC = this.ACC; float ACC = this.ACC;
if (this instanceof MissileWeapon) { if (this instanceof MissileWeapon) {
if (hero.heroClass == HeroClass.HUNTRESS) {
encumbrance -= 2;
}
int bonus = 0; int bonus = 0;
for (Buff buff : hero.buffs(RingOfSharpshooting.Aim.class)) { for (Buff buff : hero.buffs(RingOfSharpshooting.Aim.class)) {
bonus += ((RingOfSharpshooting.Aim)buff).level; bonus += ((RingOfSharpshooting.Aim)buff).level;
@ -180,9 +184,19 @@ abstract public class Weapon extends KindOfWeapon {
public Item upgrade( boolean enchant ) { public Item upgrade( boolean enchant ) {
if (enchantment != null) { if (enchantment != null) {
if (!enchant && Random.Float() > Math.pow(0.9, level())) { if (enchant && enchantment.curse()){
GLog.w( Messages.get(Weapon.class, "incompatible") ); enchant( Enchantment.random() );
} else if (!enchant && Random.Float() > Math.pow(0.9, level())) {
if (!enchantment.curse())
GLog.w( Messages.get(Weapon.class, "incompatible") );
else {
GLog.p(Messages.get(Item.class, "remove_curse"));
Dungeon.hero.sprite.emitter().start( ShadowParticle.UP, 0.05f, 10 );
}
enchant( null ); enchant( null );
} else if (!enchant && enchantment.curse() && cursed && cursedKnown){
GLog.p( Messages.get(Item.class, "weaken_curse") );
Dungeon.hero.sprite.emitter().start( ShadowParticle.UP, 0.05f, 10 );
} }
} else { } else {
if (enchant) { if (enchant) {
@ -195,26 +209,31 @@ abstract public class Weapon extends KindOfWeapon {
@Override @Override
public String name() { public String name() {
return enchantment == null ? super.name() : enchantment.name( super.name() ); return enchantment != null && (cursedKnown || !enchantment.curse()) ? enchantment.name( super.name() ) : super.name;
} }
@Override @Override
public Item random() { public Item random() {
if (Random.Float() < 0.4) { float roll = Random.Float();
int n = 1; if (roll < 0.3f){
if (Random.Int( 3 ) == 0) { //30% chance to be level 0 and cursed
n++; enchant(Enchantment.randomCurse());
if (Random.Int( 5 ) == 0) { cursed = true;
n++; return this;
} } else if (roll < 0.75f){
} //45% chance to be level 0
if (Random.Int( 2 ) == 0) { } else if (roll < 0.95f){
upgrade( n ); //15% chance to be +1
} else { upgrade(0);
degrade( n ); } else {
cursed = true; //5% chance to be +2
} upgrade(2);
} }
//if not cursed, 10% chance to be enchanted (7% overall)
if (Random.Int(10) == 0)
enchant();
return this; return this;
} }
@ -240,7 +259,7 @@ abstract public class Weapon extends KindOfWeapon {
@Override @Override
public ItemSprite.Glowing glowing() { public ItemSprite.Glowing glowing() {
return enchantment != null ? enchantment.glowing() : null; return enchantment != null && (cursedKnown || !enchantment.curse()) ? enchantment.glowing() : null;
} }
public static abstract class Enchantment implements Bundlable { public static abstract class Enchantment implements Bundlable {
@ -254,10 +273,17 @@ abstract public class Weapon extends KindOfWeapon {
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
2, 2, 2 }; 2, 2, 2 };
private static final Class<?>[] curses = new Class<?>[]{
Fragile.class, Wayward.class
};
public abstract int proc( Weapon weapon, Char attacker, Char defender, int damage ); public abstract int proc( Weapon weapon, Char attacker, Char defender, int damage );
public String name() { public String name() {
return name( Messages.get(this, "enchant")); if (!curse())
return name( Messages.get(this, "enchant"));
else
return name( Messages.get(Item.class, "curse"));
} }
public String name( String weaponName ) { public String name( String weaponName ) {
@ -268,6 +294,10 @@ abstract public class Weapon extends KindOfWeapon {
return Messages.get(this, "desc"); return Messages.get(this, "desc");
} }
public boolean curse() {
return false;
}
@Override @Override
public void restoreFromBundle( Bundle bundle ) { public void restoreFromBundle( Bundle bundle ) {
} }
@ -287,5 +317,14 @@ abstract public class Weapon extends KindOfWeapon {
} }
} }
@SuppressWarnings("unchecked")
public static Enchantment randomCurse(){
try {
return ((Class<Enchantment>)Random.oneOf(curses)).newInstance();
} catch (Exception e) {
return null;
}
}
} }
} }

View File

@ -0,0 +1,63 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2016 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.curses;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.watabou.utils.Bundle;
public class Fragile extends Weapon.Enchantment {
private static ItemSprite.Glowing BLACK = new ItemSprite.Glowing( 0x000000 );
private int hits = 0;
@Override
public int proc( Weapon weapon, Char attacker, Char defender, int damage ) {
//degrades from 100% to 25% damage over 150 hits
damage *= (1f - hits*0.005f);
if (hits < 150) hits++;
return damage;
}
@Override
public boolean curse() {
return true;
}
@Override
public ItemSprite.Glowing glowing() {
return BLACK;
}
private static final String HITS = "hits";
@Override
public void restoreFromBundle( Bundle bundle ) {
hits = bundle.getInt(HITS);
}
@Override
public void storeInBundle( Bundle bundle ) {
bundle.put(HITS, hits);
}
}

View File

@ -0,0 +1,47 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2016 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.curses;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
public class Wayward extends Weapon.Enchantment {
private static ItemSprite.Glowing BLACK = new ItemSprite.Glowing( 0x000000 );
@Override
public int proc( Weapon weapon, Char attacker, Char defender, int damage ) {
//no proc effect, see weapon.accuracyFactor for effect
return damage;
}
@Override
public boolean curse() {
return true;
}
@Override
public ItemSprite.Glowing glowing() {
return BLACK;
}
}

View File

@ -91,7 +91,7 @@ public class MeleeWeapon extends Weapon {
case NONE: case NONE:
} }
if (enchantment != null){ if (enchantment != null && (cursedKnown || !enchantment.curse())){
info += "\n\n" + Messages.get(Weapon.class, "enchanted", enchantment.name()); info += "\n\n" + Messages.get(Weapon.class, "enchanted", enchantment.name());
info += " " + Messages.get(enchantment, "desc"); info += " " + Messages.get(enchantment, "desc");
} }

View File

@ -153,7 +153,7 @@ abstract public class MissileWeapon extends Weapon {
info += " " + Messages.get(Weapon.class, "excess_str", Dungeon.hero.STR() - STRReq()); info += " " + Messages.get(Weapon.class, "excess_str", Dungeon.hero.STR() - STRReq());
} }
if (enchantment != null){ if (enchantment != null && (cursedKnown || !enchantment.curse())){
info += "\n\n" + Messages.get(Weapon.class, "enchanted", enchantment.name()); info += "\n\n" + Messages.get(Weapon.class, "enchanted", enchantment.name());
info += " " + Messages.get(enchantment, "desc"); info += " " + Messages.get(enchantment, "desc");
} }

View File

@ -1,3 +1,9 @@
###armor curses
items.armor.curses.stench.name=%s of stench
items.armor.curses.stench.desc=
###glyphs ###glyphs
items.armor.glyphs.affection.name=%s of affection items.armor.glyphs.affection.name=%s of affection
items.armor.glyphs.affection.desc=This powerful glyph manipulates the mind of attackers, charming them temporarily. items.armor.glyphs.affection.desc=This powerful glyph manipulates the mind of attackers, charming them temporarily.
@ -37,9 +43,6 @@ items.armor.glyphs.potential.desc=This glyph releases energy when struck. This i
items.armor.glyphs.repulsion.name=%s of repulsion items.armor.glyphs.repulsion.name=%s of repulsion
items.armor.glyphs.repulsion.desc=This glyph rebounds force against attackers, sending them flying back. items.armor.glyphs.repulsion.desc=This glyph rebounds force against attackers, sending them flying back.
items.armor.glyphs.stench.name=%s of stench
items.armor.glyphs.stench.desc=
items.armor.glyphs.stone.name=%s of stone items.armor.glyphs.stone.name=%s of stone
items.armor.glyphs.stone.desc=This glyph increases both the weight and defensive strength of armor it is attached to. items.armor.glyphs.stone.desc=This glyph increases both the weight and defensive strength of armor it is attached to.
@ -612,7 +615,7 @@ items.scrolls.scrollofterror.desc=A flash of red light will overwhelm all creatu
items.scrolls.scrollofupgrade.name=scroll of upgrade items.scrolls.scrollofupgrade.name=scroll of upgrade
items.scrolls.scrollofupgrade.inv_title=Select an item to upgrade items.scrolls.scrollofupgrade.inv_title=Select an item to upgrade
items.scrolls.scrollofupgrade.looks_better=your %s certainly looks better now items.scrolls.scrollofupgrade.looks_better=Your %s certainly looks better now
items.scrolls.scrollofupgrade.desc=This scroll will upgrade a single item, improving its quality. A wand will increase in power and in number of charges; a weapon will inflict more damage; a suit of armor will better absorb damage; the effect of a ring on its wearer will intensify. Weapons and armor will also require less strength to use, and any curses on the item will be lifted. items.scrolls.scrollofupgrade.desc=This scroll will upgrade a single item, improving its quality. A wand will increase in power and in number of charges; a weapon will inflict more damage; a suit of armor will better absorb damage; the effect of a ring on its wearer will intensify. Weapons and armor will also require less strength to use, and any curses on the item will be lifted.
@ -690,6 +693,22 @@ items.wands.wandofvenom.desc=This wand has a purple body which opens to a brilli
###weapon curses
items.weapon.curses.annoying.name=annoying %s
items.weapon.curses.annoying.msg_1=
items.weapon.curses.annoying.msg_2=
items.weapon.curses.annoying.msg_3=
items.weapon.curses.annoying.msg_4=
items.weapon.curses.annoying.msg_5=
items.weapon.curses.annoying.desc=
items.weapon.curses.fragile.name=fragile %s
items.weapon.curses.fragile.desc=
items.weapon.curses.wayward.name=wayward %s
items.weapon.curses.wayward.desc=
###enchantments ###enchantments
items.weapon.enchantments.blazing.name=blazing %s items.weapon.enchantments.blazing.name=blazing %s
items.weapon.enchantments.blazing.desc=This enchantment causes flames to spit forth from a weapon, burning enemies and terrain alike. items.weapon.enchantments.blazing.desc=This enchantment causes flames to spit forth from a weapon, burning enemies and terrain alike.
@ -964,6 +983,9 @@ items.item.prompt=Choose direction of throw
items.item.ac_drop=DROP items.item.ac_drop=DROP
items.item.ac_throw=THROW items.item.ac_throw=THROW
items.item.rankings_desc=Killed by: %s items.item.rankings_desc=Killed by: %s
items.item.curse=curse
items.item.weaken_curse=The curse on your item has been weakened.
items.item.remove_curse=The curse on your item has been erased!
items.kindofmisc.unequip_title=Unequip one item items.kindofmisc.unequip_title=Unequip one item
items.kindofmisc.unequip_message=You can only wear two misc items at a time. items.kindofmisc.unequip_message=You can only wear two misc items at a time.