V0.1.0 Partial Commit

changed package and application names to differentiate from main PD
release
This commit is contained in:
Evan Debenham
2014-08-03 14:46:22 -04:00
parent 65dd9c2dc0
commit aed303672a
474 changed files with 3468 additions and 3458 deletions
@@ -0,0 +1,376 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* 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.armor;
import java.util.ArrayList;
import com.shatteredpixel.shatteredpixeldungeon.Badges;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.*;
import com.shatteredpixel.shatteredpixeldungeon.sprites.HeroSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
import com.watabou.utils.Bundlable;
import com.watabou.utils.Bundle;
import com.watabou.utils.Random;
public class Armor extends EquipableItem {
private static final String TXT_EQUIP_CURSED = "your %s constricts around you painfully";
private static final String TXT_UNEQUIP_CURSED = "You can't remove cursed %s!";
private static final String TXT_IDENTIFY = "you are now familiar enough with your %s to identify it. It is %s.";
private static final String TXT_TO_STRING = "%s :%d";
private static final String TXT_INCOMPATIBLE =
"Interaction of different types of magic has erased the glyph on this armor!";
public int tier;
public int STR;
public int DR;
private int hitsToKnow = 10;
public Glyph glyph;
public Armor( int tier ) {
this.tier = tier;
STR = typicalSTR();
DR = typicalDR();
}
private static final String GLYPH = "glyph";
@Override
public void storeInBundle( Bundle bundle ) {
super.storeInBundle( bundle );
bundle.put( GLYPH, glyph );
}
@Override
public void restoreFromBundle( Bundle bundle ) {
super.restoreFromBundle( bundle );
glyph = (Glyph)bundle.get( GLYPH );
}
@Override
public ArrayList<String> actions( Hero hero ) {
ArrayList<String> actions = super.actions( hero );
actions.add( isEquipped( hero ) ? AC_UNEQUIP : AC_EQUIP );
return actions;
}
@Override
public boolean doEquip( Hero hero ) {
detach( hero.belongings.backpack );
if (hero.belongings.armor == null || hero.belongings.armor.doUnequip( hero, true )) {
hero.belongings.armor = this;
cursedKnown = true;
if (cursed) {
equipCursed( hero );
GLog.n( TXT_EQUIP_CURSED, toString() );
}
((HeroSprite)hero.sprite).updateArmor();
hero.spendAndNext( 2 * hero.speed() );
return true;
} else {
collect( hero.belongings.backpack );
return false;
}
}
@Override
public boolean doUnequip( Hero hero, boolean collect ) {
if (cursed) {
GLog.w( TXT_UNEQUIP_CURSED, name() );
return false;
} else {
hero.belongings.armor = null;
hero.spendAndNext( hero.speed() );
((HeroSprite)hero.sprite).updateArmor();
if (collect && !collect( hero.belongings.backpack )) {
Dungeon.level.drop( this, hero.pos );
}
return true;
}
}
@Override
public boolean isEquipped( Hero hero ) {
return hero.belongings.armor == this;
}
@Override
public Item upgrade() {
return upgrade( false );
}
public Item upgrade( boolean inscribe ) {
if (glyph != null) {
if (!inscribe && Random.Int( level ) > 0) {
GLog.w( TXT_INCOMPATIBLE );
inscribe( null );
}
} else {
if (inscribe) {
inscribe( Glyph.random() );
}
};
DR += tier;
STR--;
return super.upgrade();
}
public Item safeUpgrade() {
return upgrade( glyph != null );
}
@Override
public Item degrade() {
DR -= tier;
STR++;
return super.degrade();
}
public int proc( Char attacker, Char defender, int damage ) {
if (glyph != null) {
damage = glyph.proc( this, attacker, defender, damage );
}
if (!levelKnown) {
if (--hitsToKnow <= 0) {
levelKnown = true;
GLog.w( TXT_IDENTIFY, name(), toString() );
Badges.validateItemLevelAquired( this );
}
}
return damage;
}
@Override
public String toString() {
return levelKnown ? Utils.format( TXT_TO_STRING, super.toString(), STR ) : super.toString();
}
@Override
public String name() {
return glyph == null ? super.name() : glyph.name( super.name() );
}
@Override
public String info() {
String name = name();
StringBuilder info = new StringBuilder( desc() );
if (levelKnown) {
info.append(
"\n\nThis " + name + " provides damage absorption up to " +
"" + Math.max( DR, 0 ) + " points per attack. " );
if (STR > Dungeon.hero.STR()) {
if (isEquipped( Dungeon.hero )) {
info.append(
"\n\nBecause of your inadequate strength your " +
"movement speed and defense skill is decreased. " );
} else {
info.append(
"\n\nBecause of your inadequate strength wearing this armor " +
"will decrease your movement speed and defense skill. " );
}
}
} else {
info.append(
"\n\nTypical " + name + " provides damage absorption up to " + typicalDR() + " points per attack " +
" and requires " + typicalSTR() + " points of strength. " );
if (typicalSTR() > Dungeon.hero.STR()) {
info.append( "Probably this armor is too heavy for you. " );
}
}
if (glyph != null) {
info.append( "It is inscribed." );
}
if (isEquipped( Dungeon.hero )) {
info.append( "\n\nYou are wearing the " + name +
(cursed ? ", and because it is cursed, you are powerless to remove it." : ".") );
} else {
if (cursedKnown && cursed) {
info.append( "\n\nYou can feel a malevolent magic lurking within the " + name + "." );
}
}
return info.toString();
}
@Override
public Item random() {
if (Random.Float() < 0.4) {
int n = 1;
if (Random.Int( 3 ) == 0) {
n++;
if (Random.Int( 3 ) == 0) {
n++;
}
}
if (Random.Int( 2 ) == 0) {
upgrade( n );
} else {
degrade( n );
cursed = true;
}
}
if (Random.Int( 10 ) == 0) {
inscribe( Glyph.random() );
}
return this;
}
public int typicalSTR() {
return 7 + tier * 2;
}
public int typicalDR() {
return tier * 2;
}
@Override
public int price() {
int price = 10 * (1 << (tier - 1));
if (glyph != null) {
price *= 1.5;
}
if (cursed && cursedKnown) {
price /= 2;
}
if (levelKnown) {
if (level > 0) {
price *= (level + 1);
} else if (level < 0) {
price /= (1 - level);
}
}
if (price < 1) {
price = 1;
}
return price;
}
public Armor inscribe( Glyph glyph ) {
this.glyph = glyph;
return this;
}
public boolean isInscribed() {
return glyph != null;
}
@Override
public ItemSprite.Glowing glowing() {
return glyph != null ? glyph.glowing() : null;
}
public static abstract class Glyph implements Bundlable {
private static final Class<?>[] glyphs = new Class<?>[]{
Bounce.class, Affection.class, AntiEntropy.class, Multiplicity.class,
Potential.class, Metabolism.class, Stench.class, Viscosity.class,
Displacement.class, Entanglement.class };
private static final float[] chances= new float[]{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
public abstract int proc( Armor armor, Char attacker, Char defender, int damage );
public String name() {
return name( "glyph" );
}
public String name( String armorName ) {
return armorName;
}
@Override
public void restoreFromBundle( Bundle bundle ) {
}
@Override
public void storeInBundle( Bundle bundle ) {
}
public ItemSprite.Glowing glowing() {
return ItemSprite.Glowing.WHITE;
}
public boolean checkOwner( Char owner ) {
if (!owner.isAlive() && owner instanceof Hero) {
((Hero)owner).killerGlyph = this;
Badges.validateDeathFromGlyph();
return true;
} else {
return false;
}
}
@SuppressWarnings("unchecked")
public static Glyph random() {
try {
return ((Class<Glyph>)glyphs[ Random.chances( chances ) ]).newInstance();
} catch (Exception e) {
return null;
}
}
}
}
@@ -0,0 +1,134 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* 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.armor;
import java.util.ArrayList;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.watabou.utils.Bundle;
abstract public class ClassArmor extends Armor {
private static final String TXT_LOW_HEALTH = "Your health is too low!";
private static final String TXT_NOT_EQUIPPED = "You need to be wearing this armor to use its special power!";
{
levelKnown = true;
cursedKnown = true;
defaultAction = special();
}
public ClassArmor() {
super( 6 );
}
public static ClassArmor upgrade ( Hero owner, Armor armor ) {
ClassArmor classArmor = null;
switch (owner.heroClass) {
case WARRIOR:
classArmor = new WarriorArmor();
break;
case ROGUE:
classArmor = new RogueArmor();
break;
case MAGE:
classArmor = new MageArmor();
break;
case HUNTRESS:
classArmor = new HuntressArmor();
break;
}
classArmor.STR = armor.STR;
classArmor.DR = armor.DR;
classArmor.inscribe( armor.glyph );
return classArmor;
}
private static final String ARMOR_STR = "STR";
private static final String ARMOR_DR = "DR";
@Override
public void storeInBundle( Bundle bundle ) {
super.storeInBundle( bundle );
bundle.put( ARMOR_STR, STR );
bundle.put( ARMOR_DR, DR );
}
@Override
public void restoreFromBundle( Bundle bundle ) {
super.restoreFromBundle( bundle );
STR = bundle.getInt( ARMOR_STR );
DR = bundle.getInt( ARMOR_DR );
}
@Override
public ArrayList<String> actions( Hero hero ) {
ArrayList<String> actions = super.actions( hero );
if (hero.HP >= 2 && isEquipped( hero )) {
actions.add( special() );
}
return actions;
}
@Override
public void execute( Hero hero, String action ) {
if (action == special()) {
if (hero.HP < 2) {
GLog.w( TXT_LOW_HEALTH );
} else if (!isEquipped( hero )) {
GLog.w( TXT_NOT_EQUIPPED );
} else {
curUser = hero;
doSpecial();
}
} else {
super.execute( hero, action );
}
}
abstract public String special();
abstract public void doSpecial();
@Override
public boolean isUpgradable() {
return false;
}
@Override
public boolean isIdentified() {
return true;
}
@Override
public int price() {
return 0;
}
@Override
public String desc() {
return "The thing looks awesome!";
}
}
@@ -0,0 +1,38 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* 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.armor;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
public class ClothArmor extends Armor {
{
name = "cloth armor";
image = ItemSpriteSheet.ARMOR_CLOTH;
}
public ClothArmor() {
super( 1 );
}
@Override
public String desc() {
return "This lightweight armor offers basic protection.";
}
}
@@ -0,0 +1,107 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* 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.armor;
import java.util.HashMap;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.Shuriken;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.sprites.MissileSprite;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.watabou.utils.Callback;
public class HuntressArmor extends ClassArmor {
private static final String TXT_NO_ENEMIES = "No enemies in sight";
private static final String TXT_NOT_HUNTRESS = "Only huntresses can use this armor!";
private static final String AC_SPECIAL = "SPECTRAL BLADES";
{
name = "huntress cloak";
image = ItemSpriteSheet.ARMOR_HUNTRESS;
}
private HashMap<Callback, Mob> targets = new HashMap<Callback, Mob>();
@Override
public String special() {
return AC_SPECIAL;
}
@Override
public void doSpecial() {
Item proto = new Shuriken();
for (Mob mob : Dungeon.level.mobs) {
if (Level.fieldOfView[mob.pos]) {
Callback callback = new Callback() {
@Override
public void call() {
curUser.attack( targets.get( this ) );
targets.remove( this );
if (targets.isEmpty()) {
curUser.spendAndNext( curUser.attackDelay() );
}
}
};
((MissileSprite)curUser.sprite.parent.recycle( MissileSprite.class )).
reset( curUser.pos, mob.pos, proto, callback );
targets.put( callback, mob );
}
}
if (targets.size() == 0) {
GLog.w( TXT_NO_ENEMIES );
return;
}
curUser.HP /= 2;
curUser.sprite.zap( curUser.pos );
curUser.busy();
}
@Override
public boolean doEquip( Hero hero ) {
if (hero.heroClass == HeroClass.HUNTRESS) {
return super.doEquip( hero );
} else {
GLog.w( TXT_NOT_HUNTRESS );
return false;
}
}
@Override
public String desc() {
return
"A huntress in such cloak can create a fan of spectral blades. Each of these blades " +
"will target a single enemy in the huntress's field of view, inflicting damage depending " +
"on her currently equipped melee weapon.";
}
}
@@ -0,0 +1,38 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* 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.armor;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
public class LeatherArmor extends Armor {
{
name = "leather armor";
image = ItemSpriteSheet.ARMOR_LEATHER;
}
public LeatherArmor() {
super( 2 );
}
@Override
public String desc() {
return "Armor made from tanned monster hide. Not as light as cloth armor but provides better protection.";
}
}
@@ -0,0 +1,87 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* 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.armor;
import com.watabou.noosa.audio.Sample;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Burning;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Roots;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ElmoParticle;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
public class MageArmor extends ClassArmor {
private static final String AC_SPECIAL = "MOLTEN EARTH";
private static final String TXT_NOT_MAGE = "Only mages can use this armor!";
{
name = "mage robe";
image = ItemSpriteSheet.ARMOR_MAGE;
}
@Override
public String special() {
return AC_SPECIAL;
}
@Override
public String desc() {
return
"Wearing this gorgeous robe, a mage can cast a spell of molten earth: all the enemies " +
"in his field of view will be set on fire and unable to move at the same time.";
}
@Override
public void doSpecial() {
for (Mob mob : Dungeon.level.mobs) {
if (Level.fieldOfView[mob.pos]) {
Buff.affect( mob, Burning.class ).reignite( mob );
Buff.prolong( mob, Roots.class, 3 );
}
}
curUser.HP /= 2;
curUser.spend( Actor.TICK );
curUser.sprite.operate( curUser.pos );
curUser.busy();
curUser.sprite.centerEmitter().start( ElmoParticle.FACTORY, 0.15f, 4 );
Sample.INSTANCE.play( Assets.SND_READ );
}
@Override
public boolean doEquip( Hero hero ) {
if (hero.heroClass == HeroClass.MAGE) {
return super.doEquip( hero );
} else {
GLog.w( TXT_NOT_MAGE );
return false;
}
}
}
@@ -0,0 +1,39 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* 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.armor;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
public class MailArmor extends Armor {
{
name = "mail armor";
image = ItemSpriteSheet.ARMOR_MAIL;
}
public MailArmor() {
super( 3 );
}
@Override
public String desc() {
return
"Interlocking metal links make for a tough but flexible suit of armor.";
}
}
@@ -0,0 +1,40 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* 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.armor;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
public class PlateArmor extends Armor {
{
name = "plate armor";
image = ItemSpriteSheet.ARMOR_PLATE;
}
public PlateArmor() {
super( 5 );
}
@Override
public String desc() {
return
"Enormous plates of metal are joined together into a suit that provides " +
"unmatched protection to any adventurer strong enough to bear its staggering weight.";
}
}
@@ -0,0 +1,117 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* 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.armor;
import com.watabou.noosa.audio.Sample;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Blindness;
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.actors.mobs.Mob;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob.State;
import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfBlink;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.scenes.CellSelector;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
public class RogueArmor extends ClassArmor {
private static final String TXT_FOV = "You can only jump to an empty location in your field of view";
private static final String TXT_NOT_ROGUE = "Only rogues can use this armor!";
private static final String AC_SPECIAL = "SMOKE BOMB";
{
name = "rogue garb";
image = ItemSpriteSheet.ARMOR_ROGUE;
}
@Override
public String special() {
return AC_SPECIAL;
}
@Override
public void doSpecial() {
GameScene.selectCell( teleporter );
}
@Override
public boolean doEquip( Hero hero ) {
if (hero.heroClass == HeroClass.ROGUE) {
return super.doEquip( hero );
} else {
GLog.w( TXT_NOT_ROGUE );
return false;
}
}
@Override
public String desc() {
return
"Wearing this dark garb, a rogue can perform a trick, that is called \"smoke bomb\" " +
"(though no real explosives are used): he blinds enemies who could see him and jumps aside.";
}
protected static CellSelector.Listener teleporter = new CellSelector.Listener() {
@Override
public void onSelect( Integer target ) {
if (target != null) {
if (!Level.fieldOfView[target] ||
!(Level.passable[target] || Level.avoid[target]) ||
Actor.findChar( target ) != null) {
GLog.w( TXT_FOV );
return;
}
curUser.HP /= 2;
for (Mob mob : Dungeon.level.mobs) {
if (Level.fieldOfView[mob.pos]) {
Buff.prolong( mob, Blindness.class, 2 );
mob.state = State.WANDERING;
mob.sprite.emitter().burst( Speck.factory( Speck.LIGHT ), 4 );
}
}
WandOfBlink.appear( curUser, target );
CellEmitter.get( target ).burst( Speck.factory( Speck.WOOL ), 10 );
Sample.INSTANCE.play( Assets.SND_PUFF );
Dungeon.level.press( target, curUser );
Dungeon.observe();
curUser.spendAndNext( Actor.TICK );
}
}
@Override
public String prompt() {
return "Choose a location to jump to";
}
};
}
@@ -0,0 +1,39 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* 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.armor;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
public class ScaleArmor extends Armor {
{
name = "scale armor";
image = ItemSpriteSheet.ARMOR_SCALE;
}
public ScaleArmor() {
super( 4 );
}
@Override
public String desc() {
return
"The metal scales sewn onto a leather vest create a flexible, yet protective armor.";
}
}
@@ -0,0 +1,129 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* 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.armor;
import com.watabou.noosa.Camera;
import com.watabou.noosa.tweeners.PosTweener;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Fury;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Invisibility;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Paralysis;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroSubClass;
import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica;
import com.shatteredpixel.shatteredpixeldungeon.scenes.CellSelector;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.watabou.utils.PointF;
public class WarriorArmor extends ClassArmor {
private static int LEAP_TIME = 1;
private static int SHOCK_TIME = 3;
private static final String AC_SPECIAL = "HEROIC LEAP";
private static final String TXT_NOT_WARRIOR = "Only warriors can use this armor!";
{
name = "warrior suit of armor";
image = ItemSpriteSheet.ARMOR_WARRIOR;
}
@Override
public String special() {
return AC_SPECIAL;
}
@Override
public void doSpecial() {
GameScene.selectCell( leaper );
}
@Override
public boolean doEquip( Hero hero ) {
if (hero.heroClass == HeroClass.WARRIOR) {
return super.doEquip( hero );
} else {
GLog.w( TXT_NOT_WARRIOR );
return false;
}
}
@Override
public String desc() {
return
"While this armor looks heavy, it allows a warrior to perform heroic leap towards " +
"a targeted location, slamming down to stun all neighbouring enemies.";
}
protected static CellSelector.Listener leaper = new CellSelector.Listener() {
@Override
public void onSelect( Integer target ) {
if (target != null && target != curUser.pos) {
int cell = Ballistica.cast( curUser.pos, target, false, true );
if (Actor.findChar( cell ) != null && cell != curUser.pos) {
cell = Ballistica.trace[Ballistica.distance - 2];
}
curUser.HP /= 2;
if (curUser.subClass == HeroSubClass.BERSERKER && curUser.HP <= curUser.HT * Fury.LEVEL) {
Buff.affect( curUser, Fury.class );
}
Invisibility.dispel();
curUser.move( cell );
curUser.sprite.place( cell );
Dungeon.level.press( target, curUser );
Dungeon.observe();
for (int i=0; i < Level.NEIGHBOURS8.length; i++) {
Char mob = Actor.findChar( curUser.pos + Level.NEIGHBOURS8[i] );
if (mob != null && mob != curUser) {
Buff.prolong( mob, Paralysis.class, SHOCK_TIME );
}
}
PointF pos = curUser.sprite.point();
Camera.main.target = null;
curUser.sprite.y -= 16;
curUser.sprite.parent.add( new PosTweener( curUser.sprite, pos, 0.1f ) );
CellEmitter.center( cell ).burst( Speck.factory( Speck.DUST ), 10 );
curUser.spendAndNext( LEAP_TIME );
}
}
@Override
public String prompt() {
return "Choose direction to leap";
}
};
}
@@ -0,0 +1,66 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* 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.armor.glyphs;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Charm;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
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.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite.Glowing;
import com.watabou.utils.GameMath;
import com.watabou.utils.Random;
public class Affection extends Glyph {
private static final String TXT_AFFECTION = "%s of affection";
private static ItemSprite.Glowing PINK = new ItemSprite.Glowing( 0xFF4488 );
@Override
public int proc( Armor armor, Char attacker, Char defender, int damage) {
int level = (int)GameMath.gate( 0, armor.level, 6 );
if (Level.adjacent( attacker.pos, defender.pos ) && Random.Int( level / 2 + 5 ) >= 4) {
int duration = Random.IntRange( 2, 5 );
Buff.affect( attacker, Charm.class, Charm.durationFactor( attacker ) * duration );
attacker.sprite.centerEmitter().start( Speck.factory( Speck.HEART ), 0.2f, 5 );
Buff.affect( defender, Charm.class, Random.Float( Charm.durationFactor( defender ) * duration / 2, duration ) );
defender.sprite.centerEmitter().start( Speck.factory( Speck.HEART ), 0.2f, 5 );
}
return damage;
}
@Override
public String name( String weaponName) {
return String.format( TXT_AFFECTION, weaponName );
}
@Override
public Glowing glowing() {
return PINK;
}
}
@@ -0,0 +1,67 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* 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.armor.glyphs;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Burning;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Frost;
import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.FlameParticle;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.SnowParticle;
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.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite.Glowing;
import com.watabou.utils.Random;
public class AntiEntropy extends Glyph {
private static final String TXT_ANTI_ENTROPY = "%s of anti-entropy";
private static ItemSprite.Glowing BLUE = new ItemSprite.Glowing( 0x0000FF );
@Override
public int proc( Armor armor, Char attacker, Char defender, int damage) {
int level = Math.max( 0, armor.level );
if (Level.adjacent( attacker.pos, defender.pos ) && Random.Int( level + 6 ) >= 5) {
Buff.prolong( attacker, Frost.class, Frost.duration( attacker ) * Random.Float( 1f, 1.5f ));
CellEmitter.get( attacker.pos ).start( SnowParticle.FACTORY, 0.2f, 6 );
Buff.affect( defender, Burning.class ).reignite( defender );
defender.sprite.emitter().burst( FlameParticle.FACTORY, 5 );
}
return damage;
}
@Override
public String name( String weaponName) {
return String.format( TXT_ANTI_ENTROPY, weaponName );
}
@Override
public Glowing glowing() {
return BLUE;
}
}
@@ -0,0 +1,72 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* 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.armor.glyphs;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
import com.shatteredpixel.shatteredpixeldungeon.effects.Pushing;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor.Glyph;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.watabou.utils.Random;
public class Bounce extends Glyph {
private static final String TXT_BOUNCE = "%s of bounce";
@Override
public int proc( Armor armor, Char attacker, Char defender, int damage) {
int level = Math.max( 0, armor.level );
if (Level.adjacent( attacker.pos, defender.pos ) && Random.Int( level + 5) >= 4) {
for (int i=0; i < Level.NEIGHBOURS8.length; i++) {
int ofs = Level.NEIGHBOURS8[i];
if (attacker.pos - defender.pos == ofs) {
int newPos = attacker.pos + ofs;
if ((Level.passable[newPos] || Level.avoid[newPos]) && Actor.findChar( newPos ) == null) {
Actor.addDelayed( new Pushing( attacker, attacker.pos, newPos ), -1 );
attacker.pos = newPos;
// :(
if (attacker instanceof Mob) {
Dungeon.level.mobPress( (Mob)attacker );
} else {
Dungeon.level.press( newPos, attacker );
}
}
break;
}
}
}
return damage;
}
@Override
public String name( String weaponName) {
return String.format( TXT_BOUNCE, weaponName );
}
}
@@ -0,0 +1,69 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* 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.armor.glyphs;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor.Glyph;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfBlink;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite.Glowing;
import com.watabou.utils.Random;
public class Displacement extends Glyph {
private static final String TXT_DISPLACEMENT = "%s of displacement";
private static ItemSprite.Glowing BLUE = new ItemSprite.Glowing( 0x66AAFF );
@Override
public int proc( Armor armor, Char attacker, Char defender, int damage ) {
if (Dungeon.bossLevel()) {
return damage;
}
int nTries = (armor.level < 0 ? 1 : armor.level + 1) * 5;
for (int i=0; i < nTries; i++) {
int pos = Random.Int( Level.LENGTH );
if (Dungeon.visible[pos] && Level.passable[pos] && Actor.findChar( pos ) == null) {
WandOfBlink.appear( defender, pos );
Dungeon.level.press( pos, defender );
Dungeon.observe();
break;
}
}
return damage;
}
@Override
public String name( String weaponName) {
return String.format( TXT_DISPLACEMENT, weaponName );
}
@Override
public Glowing glowing() {
return BLUE;
}
}
@@ -0,0 +1,66 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* 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.armor.glyphs;
import com.watabou.noosa.Camera;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Roots;
import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.EarthParticle;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor.Glyph;
import com.shatteredpixel.shatteredpixeldungeon.plants.Earthroot;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite.Glowing;
import com.watabou.utils.Random;
public class Entanglement extends Glyph {
private static final String TXT_ENTANGLEMENT = "%s of entanglement";
private static ItemSprite.Glowing GREEN = new ItemSprite.Glowing( 0x448822 );
@Override
public int proc( Armor armor, Char attacker, Char defender, int damage ) {
int level = Math.max( 0, armor.level );
if (Random.Int( 4 ) == 0) {
Buff.prolong( defender, Roots.class, 5 - level / 5 );
Buff.affect( defender, Earthroot.Armor.class ).level( 5 * (level + 1) );
CellEmitter.bottom( defender.pos ).start( EarthParticle.FACTORY, 0.05f, 8 );
Camera.main.shake( 1, 0.4f );
}
return damage;
}
@Override
public String name( String weaponName) {
return String.format( TXT_ENTANGLEMENT, weaponName );
}
@Override
public Glowing glowing() {
return GREEN;
}
}
@@ -0,0 +1,74 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* 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.armor.glyphs;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Hunger;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor.Glyph;
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite.Glowing;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.watabou.utils.Random;
public class Metabolism extends Glyph {
private static final String TXT_METABOLISM = "%s of metabolism";
private static ItemSprite.Glowing RED = new ItemSprite.Glowing( 0xCC0000 );
@Override
public int proc( Armor armor, Char attacker, Char defender, int damage) {
int level = Math.max( 0, armor.level );
if (Random.Int( level / 2 + 5 ) >= 4) {
int healing = Math.min( defender.HT - defender.HP, Random.Int( 1, defender.HT / 5 ) );
if (healing > 0) {
Hunger hunger = defender.buff( Hunger.class );
if (hunger != null && !hunger.isStarving()) {
hunger.satisfy( -Hunger.STARVING / 10 );
BuffIndicator.refreshHero();
defender.HP += healing;
defender.sprite.emitter().burst( Speck.factory( Speck.HEALING ), 1 );
defender.sprite.showStatus( CharSprite.POSITIVE, Integer.toString( healing ) );
}
}
}
return damage;
}
@Override
public String name( String weaponName) {
return String.format( TXT_METABOLISM, weaponName );
}
@Override
public Glowing glowing() {
return RED;
}
}
@@ -0,0 +1,81 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* 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.armor.glyphs;
import java.util.ArrayList;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.MirrorImage;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor.Glyph;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfBlink;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite.Glowing;
import com.watabou.utils.Random;
public class Multiplicity extends Glyph {
private static final String TXT_MULTIPLICITY = "%s of multiplicity";
private static ItemSprite.Glowing PINK = new ItemSprite.Glowing( 0xCCAA88 );
@Override
public int proc( Armor armor, Char attacker, Char defender, int damage) {
int level = Math.max( 0, armor.level );
if (Random.Int( level / 2 + 6 ) >= 5) {
ArrayList<Integer> respawnPoints = new ArrayList<Integer>();
for (int i=0; i < Level.NEIGHBOURS8.length; i++) {
int p = defender.pos + Level.NEIGHBOURS8[i];
if (Actor.findChar( p ) == null && (Level.passable[p] || Level.avoid[p])) {
respawnPoints.add( p );
}
}
if (respawnPoints.size() > 0) {
MirrorImage mob = new MirrorImage();
mob.duplicate( (Hero)defender );
GameScene.add( mob );
WandOfBlink.appear( mob, Random.element( respawnPoints ) );
defender.damage( Random.IntRange( 1, defender.HT / 6 ), /*attacker*/ this );
checkOwner( defender );
}
}
return damage;
}
@Override
public String name( String weaponName) {
return String.format( TXT_MULTIPLICITY, weaponName );
}
@Override
public Glowing glowing() {
return PINK;
}
}
@@ -0,0 +1,72 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* 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.armor.glyphs;
import com.watabou.noosa.Camera;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.effects.Lightning;
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.levels.traps.LightningTrap;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite.Glowing;
import com.watabou.utils.Random;
public class Potential extends Glyph {
private static final String TXT_POTENTIAL = "%s of potential";
private static ItemSprite.Glowing BLUE = new ItemSprite.Glowing( 0x66CCEE );
@Override
public int proc( Armor armor, Char attacker, Char defender, int damage) {
int level = Math.max( 0, armor.level );
if (Level.adjacent( attacker.pos, defender.pos ) && Random.Int( level + 7 ) >= 6) {
int dmg = Random.IntRange( 1, damage );
attacker.damage( dmg, LightningTrap.LIGHTNING );
dmg = Random.IntRange( 1, dmg );
defender.damage( dmg, LightningTrap.LIGHTNING );
checkOwner( defender );
if (defender == Dungeon.hero) {
Camera.main.shake( 2, 0.3f );
}
int[] points = {attacker.pos, defender.pos};
attacker.sprite.parent.add( new Lightning( points, 2, null ) );
}
return damage;
}
@Override
public String name( String weaponName) {
return String.format( TXT_POTENTIAL, weaponName );
}
@Override
public Glowing glowing() {
return BLUE;
}
}
@@ -0,0 +1,61 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* 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.armor.glyphs;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.ToxicGas;
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.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite.Glowing;
import com.watabou.utils.Random;
public class Stench extends Glyph {
private static final String TXT_STENCH = "%s of stench";
private static ItemSprite.Glowing GREEN = new ItemSprite.Glowing( 0x22CC44 );
@Override
public int proc( Armor armor, Char attacker, Char defender, int damage) {
int level = Math.max( 0, armor.level );
if (Level.adjacent( attacker.pos, defender.pos ) && Random.Int( level + 5 ) >= 4) {
GameScene.add( Blob.seed( attacker.pos, 20, ToxicGas.class ) );
}
return damage;
}
@Override
public String name( String weaponName) {
return String.format( TXT_STENCH, weaponName );
}
@Override
public Glowing glowing() {
return GREEN;
}
}
@@ -0,0 +1,150 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* 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.armor.glyphs;
import com.shatteredpixel.shatteredpixeldungeon.Badges;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.ResultDescriptions;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor.Glyph;
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite.Glowing;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
import com.watabou.utils.Bundle;
import com.watabou.utils.Random;
public class Viscosity extends Glyph {
private static final String TXT_VISCOSITY = "%s of viscosity";
private static ItemSprite.Glowing PURPLE = new ItemSprite.Glowing( 0x8844CC );
@Override
public int proc( Armor armor, Char attacker, Char defender, int damage ) {
if (damage == 0) {
return 0;
}
int level = Math.max( 0, armor.level );
if (Random.Int( level + 7 ) >= 6) {
DeferedDamage debuff = defender.buff( DeferedDamage.class );
if (debuff == null) {
debuff = new DeferedDamage();
debuff.attachTo( defender );
}
debuff.prolong( damage );
defender.sprite.showStatus( CharSprite.WARNING, "deferred %d", damage );
return 0;
} else {
return damage;
}
}
@Override
public String name( String weaponName) {
return String.format( TXT_VISCOSITY, weaponName );
}
@Override
public Glowing glowing() {
return PURPLE;
}
public static class DeferedDamage extends Buff {
protected int damage = 0;
private static final String DAMAGE = "damage";
@Override
public void storeInBundle( Bundle bundle ) {
super.storeInBundle( bundle );
bundle.put( DAMAGE, damage );
}
@Override
public void restoreFromBundle( Bundle bundle ) {
super.restoreFromBundle( bundle );
damage = bundle.getInt( DAMAGE );
}
@Override
public boolean attachTo( Char target ) {
if (super.attachTo( target )) {
postpone( TICK );
return true;
} else {
return false;
}
}
public void prolong( int damage ) {
this.damage += damage;
};
@Override
public int icon() {
return BuffIndicator.DEFERRED;
}
@Override
public String toString() {
return Utils.format( "Defered damage (%d)", damage );
}
@Override
public boolean act() {
if (target.isAlive()) {
target.damage( 1, this );
if (target == Dungeon.hero && !target.isAlive()) {
// Refactoring needed!
Glyph glyph = new Viscosity();
Dungeon.fail( Utils.format( ResultDescriptions.GLYPH, glyph.name(), Dungeon.depth ) );
GLog.n( "%s killed you...", glyph.name() );
Badges.validateDeathFromGlyph();
}
spend( TICK );
if (--damage <= 0) {
detach();
}
} else {
detach();
}
return true;
}
}
}