v0.4.0: lots more curse implementation

This commit is contained in:
Evan Debenham
2016-06-09 08:58:58 -04:00
committed by Evan Debenham
parent 909e3bc445
commit b8f6881830
12 changed files with 240 additions and 46 deletions
@@ -46,13 +46,13 @@ import java.util.HashMap;
public class Generator {
public static enum Category {
WEAPON ( 150, Weapon.class ),
WEAPON ( 100, Weapon.class ),
WEP_T1 ( 0, Weapon.class),
WEP_T2 ( 0, Weapon.class),
WEP_T3 ( 0, Weapon.class),
WEP_T4 ( 0, Weapon.class),
WEP_T5 ( 0, Weapon.class),
ARMOR ( 100, Armor.class ),
ARMOR ( 60, Armor.class ),
POTION ( 500, Potion.class ),
SCROLL ( 400, Scroll.class ),
WAND ( 40, Wand.class ),
@@ -31,6 +31,9 @@ import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ShadowParticle
import com.shatteredpixel.shatteredpixeldungeon.items.BrokenSeal;
import com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.curses.AntiEntropy;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.curses.Displacement;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.curses.Metabolism;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.curses.Stench;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.Affection;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.AntiMagic;
@@ -422,7 +425,7 @@ public class Armor extends EquipableItem {
2, 2, 2 };
private static final Class<?>[] curses = new Class<?>[]{
Stench.class
AntiEntropy.class, Displacement.class, Metabolism.class, Stench.class
};
public abstract int proc( Armor armor, Char attacker, Char defender, int damage );
@@ -18,7 +18,7 @@
* 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;
package com.shatteredpixel.shatteredpixeldungeon.items.armor.curses;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
@@ -35,18 +35,18 @@ import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite.Glowing;
import com.watabou.utils.Random;
public class AntiEntropy extends Glyph {
private static ItemSprite.Glowing BLUE = new ItemSprite.Glowing( 0x0000FF );
private static ItemSprite.Glowing BLACK = new ItemSprite.Glowing( 0x000000 );
@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 );
if (Random.Int( 8 ) == 0) {
if (Level.adjacent( attacker.pos, defender.pos )) {
Buff.prolong(attacker, Frost.class, Frost.duration(attacker) * Random.Float(0.5f, 1f));
CellEmitter.get(attacker.pos).start(SnowParticle.FACTORY, 0.2f, 6);
}
Buff.affect( defender, Burning.class ).reignite( defender );
defender.sprite.emitter().burst( FlameParticle.FACTORY, 5 );
@@ -58,6 +58,11 @@ public class AntiEntropy extends Glyph {
@Override
public Glowing glowing() {
return BLUE;
return BLACK;
}
@Override
public boolean curse() {
return true;
}
}
@@ -0,0 +1,54 @@
/*
* 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.armor.curses;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTeleportation;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.watabou.utils.Random;
public class Displacement extends Armor.Glyph {
private static ItemSprite.Glowing BLACK = new ItemSprite.Glowing( 0x000000 );
@Override
public int proc(Armor armor, Char attacker, Char defender, int damage ) {
if (defender == Dungeon.hero && Random.Int(20) == 0){
ScrollOfTeleportation.teleportHero(Dungeon.hero);
return 0;
}
return damage;
}
@Override
public ItemSprite.Glowing glowing() {
return BLACK;
}
@Override
public boolean curse() {
return true;
}
}
@@ -18,7 +18,7 @@
* 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;
package com.shatteredpixel.shatteredpixeldungeon.items.armor.curses;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Hunger;
@@ -32,16 +32,16 @@ import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.watabou.utils.Random;
public class Metabolism extends Glyph {
private static ItemSprite.Glowing RED = new ItemSprite.Glowing( 0xCC0000 );
private static ItemSprite.Glowing BLACK = new ItemSprite.Glowing( 0x000000 );
@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 (Random.Int( 6 ) == 0) {
//assumes using up 10% of starving, and healing of 1 hp per 10 turns;
int healing = Math.min((int)Hunger.STARVING/100, defender.HT - defender.HP);
if (healing > 0) {
@@ -49,7 +49,7 @@ public class Metabolism extends Glyph {
if (hunger != null && !hunger.isStarving()) {
hunger.reduceHunger( -Hunger.STARVING / 10 );
hunger.reduceHunger( healing * -10 );
BuffIndicator.refreshHero();
defender.HP += healing;
@@ -65,6 +65,11 @@ public class Metabolism extends Glyph {
@Override
public Glowing glowing() {
return RED;
return BLACK;
}
@Override
public boolean curse() {
return true;
}
}
@@ -35,7 +35,7 @@ public class Stench extends Armor.Glyph {
@Override
public int proc(Armor armor, Char attacker, Char defender, int damage) {
if ( Random.Int( 6 ) == 0) {
if ( Random.Int( 8 ) == 0) {
GameScene.add( Blob.seed( attacker.pos, 250, ToxicGas.class ) );
@@ -31,6 +31,8 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.KindOfWeapon;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfFuror;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfSharpshooting;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.curses.Annoying;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.curses.Exhausting;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.curses.Fragile;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.curses.Wayward;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Blazing;
@@ -274,7 +276,7 @@ abstract public class Weapon extends KindOfWeapon {
2, 2, 2 };
private static final Class<?>[] curses = new Class<?>[]{
Fragile.class, Wayward.class
Annoying.class, Exhausting.class, Fragile.class, Wayward.class
};
public abstract int proc( Weapon weapon, Char attacker, Char defender, int damage );
@@ -0,0 +1,66 @@
/*
* 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.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Invisibility;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.watabou.noosa.audio.Sample;
import com.watabou.utils.Random;
public class Annoying extends Weapon.Enchantment {
private static ItemSprite.Glowing BLACK = new ItemSprite.Glowing( 0x000000 );
@Override
public int proc( Weapon weapon, Char attacker, Char defender, int damage ) {
if (Random.Int(20) == 0) {
for (Mob mob : Dungeon.level.mobs.toArray(new Mob[0])) {
mob.beckon(attacker.pos);
}
attacker.sprite.centerEmitter().start(Speck.factory(Speck.SCREAM), 0.3f, 3);
Sample.INSTANCE.play(Assets.SND_MIMIC);
Invisibility.dispel();
GLog.n(Messages.get(this, "msg_" + (Random.Int(5)+1)));
}
return damage;
}
@Override
public boolean curse() {
return true;
}
@Override
public ItemSprite.Glowing glowing() {
return BLACK;
}
}
@@ -0,0 +1,54 @@
/*
* 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.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Weakness;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.watabou.utils.Random;
public class Exhausting extends Weapon.Enchantment {
private static ItemSprite.Glowing BLACK = new ItemSprite.Glowing( 0x000000 );
@Override
public int proc(Weapon weapon, Char attacker, Char defender, int damage ) {
if (attacker == Dungeon.hero && Random.Int(20) == 0) {
Buff.affect(attacker, Weakness.class, Random.Float(5f, 25f));
}
return damage;
}
@Override
public boolean curse() {
return true;
}
@Override
public ItemSprite.Glowing glowing() {
return BLACK;
}
}
@@ -77,8 +77,7 @@ public class MeleeWeapon extends Weapon {
}
}
//defense-granting weapons include the DR amount, otherwise the value is discarded.
String stats_desc = Messages.get(this, "stats_desc", defenceFactor(Dungeon.hero));
String stats_desc = Messages.get(this, "stats_desc");
if (!stats_desc.equals("")) info+= "\n\n" + stats_desc;
switch (imbue) {