V0.1.0 Partial Commit
changed package and application names to differentiate from main PD release
This commit is contained in:
@@ -0,0 +1,221 @@
|
||||
/*
|
||||
* 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.weapon;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Badges;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.KindOfWeapon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.*;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.MissileWeapon;
|
||||
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 Weapon extends KindOfWeapon {
|
||||
|
||||
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_INCOMPATIBLE =
|
||||
"Interaction of different types of magic has negated the enchantment on this weapon!";
|
||||
private static final String TXT_TO_STRING = "%s :%d";
|
||||
|
||||
public int STR = 10;
|
||||
public float ACU = 1; // Accuracy modifier
|
||||
public float DLY = 1f; // Speed modifier
|
||||
|
||||
private int hitsToKnow = 20;
|
||||
|
||||
protected Enchantment enchantment;
|
||||
|
||||
@Override
|
||||
public void proc( Char attacker, Char defender, int damage ) {
|
||||
|
||||
if (enchantment != null) {
|
||||
enchantment.proc( this, attacker, defender, damage );
|
||||
}
|
||||
|
||||
if (!levelKnown) {
|
||||
if (--hitsToKnow <= 0) {
|
||||
levelKnown = true;
|
||||
GLog.i( TXT_IDENTIFY, name(), toString() );
|
||||
Badges.validateItemLevelAquired( this );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static final String ENCHANTMENT = "enchantment";
|
||||
|
||||
@Override
|
||||
public void storeInBundle( Bundle bundle ) {
|
||||
super.storeInBundle( bundle );
|
||||
bundle.put( ENCHANTMENT, enchantment );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreFromBundle( Bundle bundle ) {
|
||||
super.restoreFromBundle( bundle );
|
||||
enchantment = (Enchantment)bundle.get( ENCHANTMENT );
|
||||
}
|
||||
|
||||
@Override
|
||||
public float acuracyFactor( Hero hero ) {
|
||||
|
||||
int encumbrance = STR - hero.STR();
|
||||
|
||||
if (this instanceof MissileWeapon) {
|
||||
switch (hero.heroClass) {
|
||||
case WARRIOR:
|
||||
encumbrance += 3;
|
||||
break;
|
||||
case HUNTRESS:
|
||||
encumbrance -= 2;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
return encumbrance > 0 ? (float)(ACU / Math.pow( 1.5, encumbrance )) : ACU;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float speedFactor( Hero hero ) {
|
||||
|
||||
int encumrance = STR - hero.STR();
|
||||
if (this instanceof MissileWeapon && hero.heroClass == HeroClass.HUNTRESS) {
|
||||
encumrance -= 2;
|
||||
}
|
||||
|
||||
return encumrance > 0 ? (float)(DLY * Math.pow( 1.2, encumrance )) : DLY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageRoll( Hero hero ) {
|
||||
|
||||
int damage = super.damageRoll( hero );
|
||||
|
||||
if (hero.usingRanged == (hero.heroClass == HeroClass.HUNTRESS)) {
|
||||
int exStr = hero.STR() - STR;
|
||||
if (exStr > 0) {
|
||||
damage += Random.IntRange( 0, exStr );
|
||||
}
|
||||
}
|
||||
|
||||
return damage;
|
||||
}
|
||||
|
||||
public Item upgrade( boolean enchant ) {
|
||||
if (enchantment != null) {
|
||||
if (!enchant && Random.Int( level ) > 0) {
|
||||
GLog.w( TXT_INCOMPATIBLE );
|
||||
enchant( null );
|
||||
}
|
||||
} else {
|
||||
if (enchant) {
|
||||
enchant( Enchantment.random() );
|
||||
}
|
||||
}
|
||||
|
||||
return super.upgrade();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return levelKnown ? Utils.format( TXT_TO_STRING, super.toString(), STR ) : super.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return enchantment == null ? super.name() : enchantment.name( super.name() );
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public Weapon enchant( Enchantment ench ) {
|
||||
this.enchantment = ench;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isEnchanted() {
|
||||
return enchantment != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemSprite.Glowing glowing() {
|
||||
return enchantment != null ? enchantment.glowing() : null;
|
||||
}
|
||||
|
||||
public static abstract class Enchantment implements Bundlable {
|
||||
|
||||
private static final Class<?>[] enchants = new Class<?>[]{
|
||||
Fire.class, Poison.class, Death.class, Paralysis.class, Leech.class,
|
||||
Slow.class, Swing.class, Piercing.class, Instability.class, Horror.class, Luck.class };
|
||||
private static final float[] chances= new float[]{ 10, 10, 1, 2, 1, 2, 3, 3, 3, 2, 2 };
|
||||
|
||||
public abstract boolean proc( Weapon weapon, Char attacker, Char defender, int damage );
|
||||
|
||||
public String name( String weaponName ) {
|
||||
return weaponName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreFromBundle( Bundle bundle ) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void storeInBundle( Bundle bundle ) {
|
||||
}
|
||||
|
||||
public ItemSprite.Glowing glowing() {
|
||||
return ItemSprite.Glowing.WHITE;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Enchantment random() {
|
||||
try {
|
||||
return ((Class<Enchantment>)enchants[ Random.chances( chances ) ]).newInstance();
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* 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.weapon.enchantments;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Badges;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ShadowParticle;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite.Glowing;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
public class Death extends Weapon.Enchantment {
|
||||
|
||||
private static final String TXT_GRIM = "Grim %s";
|
||||
|
||||
private static ItemSprite.Glowing BLACK = new ItemSprite.Glowing( 0x000000 );
|
||||
|
||||
@Override
|
||||
public boolean proc( Weapon weapon, Char attacker, Char defender, int damage ) {
|
||||
// lvl 0 - 8%
|
||||
// lvl 1 ~ 9%
|
||||
// lvl 2 ~ 10%
|
||||
int level = Math.max( 0, weapon.level );
|
||||
|
||||
if (Random.Int( level + 100 ) >= 92) {
|
||||
|
||||
defender.damage( defender.HP, this );
|
||||
defender.sprite.emitter().burst( ShadowParticle.UP, 5 );
|
||||
|
||||
if (!defender.isAlive() && attacker instanceof Hero) {
|
||||
Badges.validateGrimWeapon();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
} else {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Glowing glowing() {
|
||||
return BLACK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String name( String weaponName) {
|
||||
return String.format( TXT_GRIM, weaponName );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* 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.weapon.enchantments;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Burning;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.FlameParticle;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite.Glowing;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
public class Fire extends Weapon.Enchantment {
|
||||
|
||||
private static final String TXT_BLAZING = "Blazing %s";
|
||||
|
||||
private static ItemSprite.Glowing ORANGE = new ItemSprite.Glowing( 0xFF4400 );
|
||||
|
||||
@Override
|
||||
public boolean proc( Weapon weapon, Char attacker, Char defender, int damage ) {
|
||||
// lvl 0 - 33%
|
||||
// lvl 1 - 50%
|
||||
// lvl 2 - 60%
|
||||
int level = Math.max( 0, weapon.level );
|
||||
|
||||
if (Random.Int( level + 3 ) >= 2) {
|
||||
|
||||
if (Random.Int( 2 ) == 0) {
|
||||
Buff.affect( defender, Burning.class ).reignite( defender );
|
||||
}
|
||||
defender.damage( Random.Int( 1, level + 2 ), this );
|
||||
|
||||
defender.sprite.emitter().burst( FlameParticle.FACTORY, level + 1 );
|
||||
|
||||
return true;
|
||||
|
||||
} else {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Glowing glowing() {
|
||||
return ORANGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String name( String weaponName ) {
|
||||
return String.format( TXT_BLAZING, weaponName );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* 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.weapon.enchantments;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Terror;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite.Glowing;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
public class Horror extends Weapon.Enchantment {
|
||||
|
||||
private static final String TXT_ELDRITCH = "Eldritch %s";
|
||||
|
||||
private static ItemSprite.Glowing GREY = new ItemSprite.Glowing( 0x222222 );
|
||||
|
||||
@Override
|
||||
public boolean proc( Weapon weapon, Char attacker, Char defender, int damage ) {
|
||||
// lvl 0 - 20%
|
||||
// lvl 1 - 33%
|
||||
// lvl 2 - 43%
|
||||
int level = Math.max( 0, weapon.level );
|
||||
|
||||
if (Random.Int( level + 5 ) >= 4) {
|
||||
|
||||
Terror terror = Buff.affect( defender, Terror.class, Terror.DURATION );
|
||||
terror.source = attacker;
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Glowing glowing() {
|
||||
return GREY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String name( String weaponName) {
|
||||
return String.format( TXT_ELDRITCH, weaponName );
|
||||
}
|
||||
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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.weapon.enchantments;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon.Enchantment;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.Boomerang;
|
||||
|
||||
public class Instability extends Weapon.Enchantment {
|
||||
|
||||
private static final String TXT_UNSTABLE = "Unstable %s";
|
||||
|
||||
@Override
|
||||
public boolean proc( Weapon weapon, Char attacker, Char defender, int damage ) {
|
||||
Enchantment ench = random();
|
||||
if (weapon instanceof Boomerang) {
|
||||
while (ench instanceof Piercing || ench instanceof Swing) {
|
||||
ench = Enchantment.random();
|
||||
}
|
||||
}
|
||||
return ench.proc( weapon, attacker, defender, damage );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String name( String weaponName) {
|
||||
return String.format( TXT_UNSTABLE, weaponName );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* 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.weapon.enchantments;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite.Glowing;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
public class Leech extends Weapon.Enchantment {
|
||||
|
||||
private static final String TXT_VAMPIRIC = "Vampiric %s";
|
||||
|
||||
private static ItemSprite.Glowing RED = new ItemSprite.Glowing( 0x660022 );
|
||||
|
||||
@Override
|
||||
public boolean proc( Weapon weapon, Char attacker, Char defender, int damage ) {
|
||||
|
||||
int level = Math.max( 0, weapon.level );
|
||||
|
||||
// lvl 0 - 33%
|
||||
// lvl 1 - 43%
|
||||
// lvl 2 - 50%
|
||||
int maxValue = damage * (level + 2) / (level + 6);
|
||||
int effValue = Math.min( Random.IntRange( 0, maxValue ), attacker.HT - attacker.HP );
|
||||
|
||||
if (effValue > 0) {
|
||||
|
||||
attacker.HP += effValue;
|
||||
attacker.sprite.emitter().start( Speck.factory( Speck.HEALING ), 0.4f, 1 );
|
||||
attacker.sprite.showStatus( CharSprite.POSITIVE, Integer.toString( effValue ) );
|
||||
|
||||
return true;
|
||||
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Glowing glowing() {
|
||||
return RED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String name( String weaponName ) {
|
||||
return String.format( TXT_VAMPIRIC, weaponName );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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.weapon.enchantments;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite.Glowing;
|
||||
|
||||
public class Luck extends Weapon.Enchantment {
|
||||
|
||||
private static final String TXT_LUCKY = "Lucky %s";
|
||||
|
||||
private static ItemSprite.Glowing GREEN = new ItemSprite.Glowing( 0x00FF00 );
|
||||
|
||||
@Override
|
||||
public boolean proc( Weapon weapon, Char attacker, Char defender, int damage ) {
|
||||
int level = Math.max( 0, weapon.level );
|
||||
|
||||
int dmg = damage;
|
||||
for (int i=1; i <= level+1; i++) {
|
||||
dmg = Math.max( dmg, attacker.damageRoll() - i );
|
||||
}
|
||||
|
||||
if (dmg > damage) {
|
||||
defender.damage( dmg - damage, this );
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String name( String weaponName) {
|
||||
return String.format( TXT_LUCKY, weaponName );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Glowing glowing() {
|
||||
return GREEN;
|
||||
}
|
||||
}
|
||||
@@ -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.weapon.enchantments;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite.Glowing;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
public class Paralysis extends Weapon.Enchantment {
|
||||
|
||||
private static final String TXT_STUNNING = "Stunning %s";
|
||||
|
||||
private static ItemSprite.Glowing YELLOW = new ItemSprite.Glowing( 0xCCAA44 );
|
||||
|
||||
@Override
|
||||
public boolean proc( Weapon weapon, Char attacker, Char defender, int damage ) {
|
||||
// lvl 0 - 13%
|
||||
// lvl 1 - 22%
|
||||
// lvl 2 - 30%
|
||||
int level = Math.max( 0, weapon.level );
|
||||
|
||||
if (Random.Int( level + 8 ) >= 7) {
|
||||
|
||||
Buff.prolong( defender, com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Paralysis.class,
|
||||
Random.Float( 1, 1.5f + level ) );
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Glowing glowing() {
|
||||
return YELLOW;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String name( String weaponName) {
|
||||
return String.format( TXT_STUNNING, weaponName );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* 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.weapon.enchantments;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon.Enchantment;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
public class Piercing extends Enchantment {
|
||||
|
||||
private static final String TXT_PIERCING = "Piercing %s";
|
||||
|
||||
@Override
|
||||
public boolean proc( Weapon weapon, Char attacker, Char defender, int damage ) {
|
||||
|
||||
int level = Math.max( 0, weapon.level );
|
||||
|
||||
int maxDamage = (int)(damage * Math.pow( 2, -1d / (level + 1) ));
|
||||
if (maxDamage >= 1) {
|
||||
|
||||
int d = defender.pos - attacker.pos;
|
||||
int pos = defender.pos + d;
|
||||
|
||||
do {
|
||||
|
||||
Char ch = Actor.findChar( pos );
|
||||
if (ch == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
int dr = Random.IntRange( 0, ch.dr() );
|
||||
int dmg = Random.Int( 1, maxDamage );
|
||||
int effectiveDamage = Math.max( dmg - dr, 0 );
|
||||
|
||||
ch.damage( effectiveDamage, this );
|
||||
|
||||
ch.sprite.bloodBurstA( attacker.sprite.center(), effectiveDamage );
|
||||
ch.sprite.flash();
|
||||
|
||||
pos += d;
|
||||
} while (pos >= 0 && pos < Level.LENGTH);
|
||||
|
||||
return true;
|
||||
|
||||
} else {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String name( String weaponName) {
|
||||
return String.format( TXT_PIERCING, weaponName );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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.weapon.enchantments;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite.Glowing;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
public class Poison extends Weapon.Enchantment {
|
||||
|
||||
private static final String TXT_VENOMOUS = "Venomous %s";
|
||||
|
||||
private static ItemSprite.Glowing PURPLE = new ItemSprite.Glowing( 0x4400AA );
|
||||
|
||||
@Override
|
||||
public boolean proc( Weapon weapon, Char attacker, Char defender, int damage ) {
|
||||
// lvl 0 - 33%
|
||||
// lvl 1 - 50%
|
||||
// lvl 2 - 60%
|
||||
int level = Math.max( 0, weapon.level );
|
||||
|
||||
if (Random.Int( level + 3 ) >= 2) {
|
||||
|
||||
Buff.affect( defender, com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Poison.class ).
|
||||
set( com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Poison.durationFactor( defender ) * (level + 1) );
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Glowing glowing() {
|
||||
return PURPLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String name( String weaponName) {
|
||||
return String.format( TXT_VENOMOUS, weaponName );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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.weapon.enchantments;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite.Glowing;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
public class Slow extends Weapon.Enchantment {
|
||||
|
||||
private static final String TXT_CHILLING = "Chilling %s";
|
||||
|
||||
private static ItemSprite.Glowing BLUE = new ItemSprite.Glowing( 0x0044FF );
|
||||
|
||||
@Override
|
||||
public boolean proc( Weapon weapon, Char attacker, Char defender, int damage ) {
|
||||
// lvl 0 - 25%
|
||||
// lvl 1 - 40%
|
||||
// lvl 2 - 50%
|
||||
int level = Math.max( 0, weapon.level );
|
||||
|
||||
if (Random.Int( level + 4 ) >= 3) {
|
||||
|
||||
Buff.prolong( defender, com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Slow.class,
|
||||
Random.Float( 1, 1.5f + level ) );
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Glowing glowing() {
|
||||
return BLUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String name( String weaponName) {
|
||||
return String.format( TXT_CHILLING, weaponName );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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.weapon.enchantments;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon.Enchantment;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
public class Swing extends Enchantment {
|
||||
|
||||
private static final String TXT_WILD = "Wild %s";
|
||||
|
||||
@Override
|
||||
public boolean proc( Weapon weapon, Char attacker, Char defender, int damage ) {
|
||||
|
||||
int level = Math.max( 0, weapon.level );
|
||||
|
||||
int maxDamage = (int)(damage * Math.pow( 2, -1d / (level + 1) ));
|
||||
if (maxDamage >= 1) {
|
||||
|
||||
int p = attacker.pos;
|
||||
int[] neighbours = {
|
||||
p+1, p-1, p+Level.WIDTH, p-Level.WIDTH,
|
||||
p+1+Level.WIDTH, p+1-Level.WIDTH, p-1+Level.WIDTH, p-1-Level.WIDTH};
|
||||
|
||||
for (int n : neighbours) {
|
||||
Char ch = Actor.findChar( n );
|
||||
if (ch != null && ch != defender && ch.isAlive()) {
|
||||
|
||||
int dr = Random.IntRange( 0, ch.dr() );
|
||||
int dmg = Random.Int( 1, maxDamage );
|
||||
int effectiveDamage = Math.max( dmg - dr, 0 );
|
||||
|
||||
ch.damage( effectiveDamage, this );
|
||||
|
||||
ch.sprite.bloodBurstA( attacker.sprite.center(), effectiveDamage );
|
||||
ch.sprite.flash();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
} else {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String name( String weaponName) {
|
||||
return String.format( TXT_WILD, weaponName );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.weapon.melee;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||
|
||||
public class BattleAxe extends MeleeWeapon {
|
||||
|
||||
{
|
||||
name = "battle axe";
|
||||
image = ItemSpriteSheet.BATTLE_AXE;
|
||||
}
|
||||
|
||||
public BattleAxe() {
|
||||
super( 4, 1.2f, 1f );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String desc() {
|
||||
return "The enormous steel head of this battle axe puts considerable heft behind each stroke.";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.weapon.melee;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||
|
||||
public class Dagger extends MeleeWeapon {
|
||||
|
||||
{
|
||||
name = "dagger";
|
||||
image = ItemSpriteSheet.DAGGER;
|
||||
}
|
||||
|
||||
public Dagger() {
|
||||
super( 1, 1.2f, 1f );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String desc() {
|
||||
return "A simple iron dagger with a well worn wooden handle.";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.weapon.melee;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||
|
||||
public class Glaive extends MeleeWeapon {
|
||||
|
||||
{
|
||||
name = "glaive";
|
||||
image = ItemSpriteSheet.GLAIVE;
|
||||
}
|
||||
|
||||
public Glaive() {
|
||||
super( 5, 1f, 1f );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String desc() {
|
||||
return "A polearm consisting of a sword blade on the end of a pole.";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.weapon.melee;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||
|
||||
public class Knuckles extends MeleeWeapon {
|
||||
|
||||
{
|
||||
name = "knuckleduster";
|
||||
image = ItemSpriteSheet.KNUCKLEDUSTER;
|
||||
}
|
||||
|
||||
public Knuckles() {
|
||||
super( 1, 1f, 0.5f );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String desc() {
|
||||
return "A piece of iron shaped to fit around the knuckles.";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.weapon.melee;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||
|
||||
public class Longsword extends MeleeWeapon {
|
||||
|
||||
{
|
||||
name = "longsword";
|
||||
image = ItemSpriteSheet.LONG_SWORD;
|
||||
}
|
||||
|
||||
public Longsword() {
|
||||
super( 4, 1f, 1f );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String desc() {
|
||||
return "This towering blade inflicts heavy damage by investing its heft into every cut.";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.weapon.melee;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||
|
||||
public class Mace extends MeleeWeapon {
|
||||
|
||||
{
|
||||
name = "mace";
|
||||
image = ItemSpriteSheet.MACE;
|
||||
}
|
||||
|
||||
public Mace() {
|
||||
super( 3, 1f, 0.8f );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String desc() {
|
||||
return "The iron head of this weapon inflicts substantial damage.";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
/*
|
||||
* 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.weapon.melee;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
public class MeleeWeapon extends Weapon {
|
||||
|
||||
private int tier;
|
||||
|
||||
public MeleeWeapon( int tier, float acu, float dly ) {
|
||||
super();
|
||||
|
||||
this.tier = tier;
|
||||
|
||||
ACU = acu;
|
||||
DLY = dly;
|
||||
|
||||
STR = typicalSTR();
|
||||
|
||||
MIN = min();
|
||||
MAX = max();
|
||||
}
|
||||
|
||||
private int min() {
|
||||
return tier;
|
||||
}
|
||||
|
||||
private int max() {
|
||||
return (int)((tier * tier - tier + 10) / ACU * DLY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item upgrade() {
|
||||
return upgrade( false );
|
||||
}
|
||||
|
||||
public Item upgrade( boolean enchant ) {
|
||||
STR--;
|
||||
MIN++;
|
||||
MAX += tier;
|
||||
|
||||
return super.upgrade( enchant );
|
||||
}
|
||||
|
||||
public Item safeUpgrade() {
|
||||
return upgrade( enchantment != null );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item degrade() {
|
||||
STR++;
|
||||
MIN--;
|
||||
MAX -= tier;
|
||||
return super.degrade();
|
||||
}
|
||||
|
||||
public int typicalSTR() {
|
||||
return 8 + tier * 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String info() {
|
||||
|
||||
final String p = "\n\n";
|
||||
|
||||
StringBuilder info = new StringBuilder( desc() );
|
||||
|
||||
String quality = levelKnown && level != 0 ? (level > 0 ? "upgraded" : "degraded") : "";
|
||||
info.append( p );
|
||||
info.append( "This " + name + " is " + Utils.indefinite( quality ) );
|
||||
info.append( " tier-" + tier + " melee weapon. " );
|
||||
|
||||
if (levelKnown) {
|
||||
info.append( "Its average damage is " + (MIN + (MAX - MIN) / 2) + " points per hit. " );
|
||||
} else {
|
||||
info.append(
|
||||
"Its typical average damage is " + (min() + (max() - min()) / 2) + " points per hit " +
|
||||
"and usually it requires " + typicalSTR() + " points of strength. " );
|
||||
if (typicalSTR() > Dungeon.hero.STR()) {
|
||||
info.append( "Probably this weapon is too heavy for you. " );
|
||||
}
|
||||
}
|
||||
|
||||
if (DLY != 1f) {
|
||||
info.append( "This is a rather " + (DLY < 1f ? "fast" : "slow") );
|
||||
if (ACU != 1f) {
|
||||
if ((ACU > 1f) == (DLY < 1f)) {
|
||||
info.append( " and ");
|
||||
} else {
|
||||
info.append( " but ");
|
||||
}
|
||||
info.append( ACU > 1f ? "accurate" : "inaccurate" );
|
||||
}
|
||||
info.append( " weapon. ");
|
||||
} else if (ACU != 1f) {
|
||||
info.append( "This is a rather " + (ACU > 1f ? "accurate" : "inaccurate") + " weapon. " );
|
||||
}
|
||||
|
||||
if (enchantment != null) {
|
||||
info.append( "It is enchanted." );
|
||||
}
|
||||
|
||||
if (levelKnown && Dungeon.hero.belongings.backpack.items.contains( this )) {
|
||||
if (STR > Dungeon.hero.STR()) {
|
||||
info.append( p );
|
||||
info.append(
|
||||
"Because of your inadequate strength the accuracy and speed " +
|
||||
"of your attack with this " + name + " is decreased." );
|
||||
}
|
||||
if (STR < Dungeon.hero.STR()) {
|
||||
info.append( p );
|
||||
info.append(
|
||||
"Because of your excess strength the damage " +
|
||||
"of your attack with this " + name + " is increased." );
|
||||
}
|
||||
}
|
||||
|
||||
if (isEquipped( Dungeon.hero )) {
|
||||
info.append( p );
|
||||
info.append( "You hold the " + name + " at the ready" +
|
||||
(cursed ? ", and because it is cursed, you are powerless to let go." : ".") );
|
||||
} else {
|
||||
if (cursedKnown && cursed) {
|
||||
info.append( p );
|
||||
info.append( "You can feel a malevolent magic lurking within " + name +"." );
|
||||
}
|
||||
}
|
||||
|
||||
return info.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int price() {
|
||||
int price = 20 * (1 << (tier - 1));
|
||||
if (enchantment != 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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item random() {
|
||||
super.random();
|
||||
|
||||
if (Random.Int( 10 + level ) == 0) {
|
||||
enchant( Enchantment.random() );
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -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.weapon.melee;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||
|
||||
public class Quarterstaff extends MeleeWeapon {
|
||||
|
||||
{
|
||||
name = "quarterstaff";
|
||||
image = ItemSpriteSheet.QUARTERSTAFF;
|
||||
}
|
||||
|
||||
public Quarterstaff() {
|
||||
super( 2, 1f, 1f );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String desc() {
|
||||
// TODO Auto-generated method stub
|
||||
return "A staff of hardwood, its ends are shod with iron.";
|
||||
}
|
||||
}
|
||||
@@ -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.weapon.melee;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.watabou.noosa.audio.Sample;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Badges;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfUpgrade;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.Boomerang;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag;
|
||||
|
||||
public class ShortSword extends MeleeWeapon {
|
||||
|
||||
public static final String AC_REFORGE = "REFORGE";
|
||||
|
||||
private static final String TXT_SELECT_WEAPON = "Select a weapon to upgrade";
|
||||
|
||||
private static final String TXT_REFORGED =
|
||||
"you reforged the short sword to upgrade your %s";
|
||||
private static final String TXT_NOT_BOOMERANG =
|
||||
"you can't upgrade a boomerang this way";
|
||||
|
||||
private static final float TIME_TO_REFORGE = 2f;
|
||||
|
||||
private boolean equipped;
|
||||
|
||||
{
|
||||
name = "short sword";
|
||||
image = ItemSpriteSheet.SHORT_SWORD;
|
||||
}
|
||||
|
||||
public ShortSword() {
|
||||
super( 1, 1f, 1f );
|
||||
|
||||
STR = 11;
|
||||
MAX = 12;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> actions( Hero hero ) {
|
||||
ArrayList<String> actions = super.actions( hero );
|
||||
if (level > 0) {
|
||||
actions.add( AC_REFORGE );
|
||||
}
|
||||
return actions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute( Hero hero, String action ) {
|
||||
if (action == AC_REFORGE) {
|
||||
|
||||
if (hero.belongings.weapon == this) {
|
||||
equipped = true;
|
||||
hero.belongings.weapon = null;
|
||||
} else {
|
||||
equipped = false;
|
||||
detach( hero.belongings.backpack );
|
||||
}
|
||||
|
||||
curUser = hero;
|
||||
|
||||
GameScene.selectItem( itemSelector, WndBag.Mode.WEAPON, TXT_SELECT_WEAPON );
|
||||
|
||||
} else {
|
||||
|
||||
super.execute( hero, action );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String desc() {
|
||||
return
|
||||
"It is indeed quite short, just a few inches longer, than a dagger.";
|
||||
}
|
||||
|
||||
private final WndBag.Listener itemSelector = new WndBag.Listener() {
|
||||
@Override
|
||||
public void onSelect( Item item ) {
|
||||
if (item != null && !(item instanceof Boomerang)) {
|
||||
|
||||
Sample.INSTANCE.play( Assets.SND_EVOKE );
|
||||
ScrollOfUpgrade.upgrade( curUser );
|
||||
evoke( curUser );
|
||||
|
||||
GLog.w( TXT_REFORGED, item.name() );
|
||||
|
||||
((MeleeWeapon)item).safeUpgrade();
|
||||
curUser.spendAndNext( TIME_TO_REFORGE );
|
||||
|
||||
Badges.validateItemLevelAquired( item );
|
||||
|
||||
} else {
|
||||
|
||||
if (item instanceof Boomerang) {
|
||||
GLog.w( TXT_NOT_BOOMERANG );
|
||||
}
|
||||
|
||||
if (equipped) {
|
||||
curUser.belongings.weapon = ShortSword.this;
|
||||
} else {
|
||||
collect( curUser.belongings.backpack );
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.weapon.melee;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||
|
||||
public class Spear extends MeleeWeapon {
|
||||
|
||||
{
|
||||
name = "spear";
|
||||
image = ItemSpriteSheet.SPEAR;
|
||||
}
|
||||
|
||||
public Spear() {
|
||||
super( 2, 1f, 1.5f );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String desc() {
|
||||
return "A slender wooden rod tipped with sharpened iron.";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.weapon.melee;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||
|
||||
public class Sword extends MeleeWeapon {
|
||||
|
||||
{
|
||||
name = "sword";
|
||||
image = ItemSpriteSheet.SWORD;
|
||||
}
|
||||
|
||||
public Sword() {
|
||||
super( 3, 1f, 1f );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String desc() {
|
||||
return "The razor-sharp length of steel blade shines reassuringly.";
|
||||
}
|
||||
}
|
||||
@@ -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.weapon.melee;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||
|
||||
public class WarHammer extends MeleeWeapon {
|
||||
|
||||
{
|
||||
name = "war hammer";
|
||||
image = ItemSpriteSheet.WAR_HAMMER;
|
||||
}
|
||||
|
||||
public WarHammer() {
|
||||
super( 5, 1.2f, 1f );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String desc() {
|
||||
return
|
||||
"Few creatures can withstand the crushing blow of this towering mass of lead and steel, " +
|
||||
"but only the strongest of adventurers can use it effectively.";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* 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.weapon.missiles;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Piercing;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Swing;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.MissileSprite;
|
||||
|
||||
public class Boomerang extends MissileWeapon {
|
||||
|
||||
{
|
||||
name = "boomerang";
|
||||
image = ItemSpriteSheet.BOOMERANG;
|
||||
|
||||
STR = 10;
|
||||
|
||||
MIN = 1;
|
||||
MAX = 4;
|
||||
|
||||
stackable = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUpgradable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item upgrade() {
|
||||
return upgrade( false );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item upgrade( boolean enchant ) {
|
||||
MIN += 1;
|
||||
MAX += 2;
|
||||
super.upgrade( enchant );
|
||||
|
||||
updateQuickslot();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item degrade() {
|
||||
MIN -= 1;
|
||||
MAX -= 2;
|
||||
return super.degrade();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Weapon enchant( Enchantment ench ) {
|
||||
while (ench instanceof Piercing || ench instanceof Swing) {
|
||||
ench = Enchantment.random();
|
||||
}
|
||||
|
||||
return super.enchant( ench );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void proc( Char attacker, Char defender, int damage ) {
|
||||
super.proc( attacker, defender, damage );
|
||||
if (attacker instanceof Hero && ((Hero)attacker).usingRanged) {
|
||||
circleBack( defender.pos, (Hero)attacker );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void miss( int cell ) {
|
||||
circleBack( cell, curUser );
|
||||
}
|
||||
|
||||
private void circleBack( int from, Hero owner ) {
|
||||
if (!collect( curUser.belongings.backpack )) {
|
||||
Dungeon.level.drop( this, owner.pos ).sprite.drop();
|
||||
}
|
||||
((MissileSprite)curUser.sprite.parent.recycle( MissileSprite.class )).
|
||||
reset( from, curUser.pos, curItem, null );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String desc() {
|
||||
return
|
||||
"Thrown to the enemy this flat curved wooden missile will return to the hands of its thrower.";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* 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.weapon.missiles;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Paralysis;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
public class CurareDart extends MissileWeapon {
|
||||
|
||||
public static final float DURATION = 3f;
|
||||
|
||||
{
|
||||
name = "curare dart";
|
||||
image = ItemSpriteSheet.CURARE_DART;
|
||||
|
||||
STR = 14;
|
||||
|
||||
MIN = 1;
|
||||
MAX = 3;
|
||||
}
|
||||
|
||||
public CurareDart() {
|
||||
this( 1 );
|
||||
}
|
||||
|
||||
public CurareDart( int number ) {
|
||||
super();
|
||||
quantity = number;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void proc( Char attacker, Char defender, int damage ) {
|
||||
Buff.prolong( defender, Paralysis.class, DURATION );
|
||||
super.proc( attacker, defender, damage );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String desc() {
|
||||
return
|
||||
"These little evil darts don't do much damage but they can paralyze " +
|
||||
"the target leaving it helpless and motionless for some time.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item random() {
|
||||
quantity = Random.Int( 2, 5 );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int price() {
|
||||
return 12 * quantity;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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.weapon.missiles;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
public class Dart extends MissileWeapon {
|
||||
|
||||
{
|
||||
name = "dart";
|
||||
image = ItemSpriteSheet.DART;
|
||||
|
||||
MIN = 1;
|
||||
MAX = 4;
|
||||
}
|
||||
|
||||
public Dart() {
|
||||
this( 1 );
|
||||
}
|
||||
|
||||
public Dart( int number ) {
|
||||
super();
|
||||
quantity = number;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String desc() {
|
||||
return
|
||||
"These simple metal spikes are weighted to fly true and " +
|
||||
"sting their prey with a flick of the wrist.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item random() {
|
||||
quantity = Random.Int( 5, 15 );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int price() {
|
||||
return quantity * 2;
|
||||
}
|
||||
}
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* 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.weapon.missiles;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Fire;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Burning;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
public class IncendiaryDart extends MissileWeapon {
|
||||
|
||||
{
|
||||
name = "incendiary dart";
|
||||
image = ItemSpriteSheet.INCENDIARY_DART;
|
||||
|
||||
STR = 12;
|
||||
|
||||
MIN = 1;
|
||||
MAX = 2;
|
||||
}
|
||||
|
||||
public IncendiaryDart() {
|
||||
this( 1 );
|
||||
}
|
||||
|
||||
public IncendiaryDart( int number ) {
|
||||
super();
|
||||
quantity = number;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onThrow( int cell ) {
|
||||
Char enemy = Actor.findChar( cell );
|
||||
if (enemy == null || enemy == curUser) {
|
||||
if (Level.flamable[cell]) {
|
||||
GameScene.add( Blob.seed( cell, 4, Fire.class ) );
|
||||
} else {
|
||||
super.onThrow( cell );
|
||||
}
|
||||
} else {
|
||||
if (!curUser.shoot( enemy, this )) {
|
||||
Dungeon.level.drop( this, cell ).sprite.drop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void proc( Char attacker, Char defender, int damage ) {
|
||||
Buff.affect( defender, Burning.class ).reignite( defender );
|
||||
super.proc( attacker, defender, damage );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String desc() {
|
||||
return
|
||||
"The spike on each of these darts is designed to pin it to its target " +
|
||||
"while the unstable compounds strapped to its length burst into brilliant flames.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item random() {
|
||||
quantity = Random.Int( 3, 6 );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int price() {
|
||||
return 10 * quantity;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* 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.weapon.missiles;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Cripple;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
public class Javelin extends MissileWeapon {
|
||||
|
||||
{
|
||||
name = "javelin";
|
||||
image = ItemSpriteSheet.JAVELIN;
|
||||
|
||||
STR = 15;
|
||||
|
||||
MIN = 2;
|
||||
MAX = 15;
|
||||
}
|
||||
|
||||
public Javelin() {
|
||||
this( 1 );
|
||||
}
|
||||
|
||||
public Javelin( int number ) {
|
||||
super();
|
||||
quantity = number;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void proc( Char attacker, Char defender, int damage ) {
|
||||
super.proc( attacker, defender, damage );
|
||||
Buff.prolong( defender, Cripple.class, Cripple.DURATION );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String desc() {
|
||||
return
|
||||
"This length of metal is weighted to keep the spike " +
|
||||
"at its tip foremost as it sails through the air.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item random() {
|
||||
quantity = Random.Int( 5, 15 );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int price() {
|
||||
return 15 * quantity;
|
||||
}
|
||||
}
|
||||
+144
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
* 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.weapon.missiles;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions;
|
||||
|
||||
public class MissileWeapon extends Weapon {
|
||||
|
||||
private static final String TXT_MISSILES = "Missile weapon";
|
||||
private static final String TXT_YES = "Yes, I know what I'm doing";
|
||||
private static final String TXT_NO = "No, I changed my mind";
|
||||
private static final String TXT_R_U_SURE =
|
||||
"Do you really want to equip it as a melee weapon?";
|
||||
|
||||
{
|
||||
stackable = true;
|
||||
levelKnown = true;
|
||||
defaultAction = AC_THROW;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> actions( Hero hero ) {
|
||||
ArrayList<String> actions = super.actions( hero );
|
||||
if (hero.heroClass != HeroClass.HUNTRESS && hero.heroClass != HeroClass.ROGUE) {
|
||||
actions.remove( AC_EQUIP );
|
||||
actions.remove( AC_UNEQUIP );
|
||||
}
|
||||
return actions;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onThrow( int cell ) {
|
||||
Char enemy = Actor.findChar( cell );
|
||||
if (enemy == null || enemy == curUser) {
|
||||
super.onThrow( cell );
|
||||
} else {
|
||||
if (!curUser.shoot( enemy, this )) {
|
||||
miss( cell );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void miss( int cell ) {
|
||||
super.onThrow( cell );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void proc( Char attacker, Char defender, int damage ) {
|
||||
|
||||
super.proc( attacker, defender, damage );
|
||||
|
||||
Hero hero = (Hero)attacker;
|
||||
if (!hero.usingRanged && stackable) {
|
||||
if (quantity == 1) {
|
||||
doUnequip( hero, false );
|
||||
} else {
|
||||
detach( null );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doEquip( final Hero hero ) {
|
||||
GameScene.show(
|
||||
new WndOptions( TXT_MISSILES, TXT_R_U_SURE, TXT_YES, TXT_NO ) {
|
||||
@Override
|
||||
protected void onSelect(int index) {
|
||||
if (index == 0) {
|
||||
MissileWeapon.super.doEquip( hero );
|
||||
}
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item random() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUpgradable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIdentified() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String info() {
|
||||
|
||||
StringBuilder info = new StringBuilder( desc() );
|
||||
|
||||
info.append( "\n\nAverage damage of this weapon equals to " + (MIN + (MAX - MIN) / 2) + " points per hit. " );
|
||||
|
||||
if (Dungeon.hero.belongings.backpack.items.contains( this )) {
|
||||
if (STR > Dungeon.hero.STR()) {
|
||||
info.append(
|
||||
"Because of your inadequate strength the accuracy and speed " +
|
||||
"of your attack with this " + name + " is decreased." );
|
||||
}
|
||||
if (STR < Dungeon.hero.STR()) {
|
||||
info.append(
|
||||
"Because of your excess strength the damage " +
|
||||
"of your attack with this " + name + " is increased." );
|
||||
}
|
||||
}
|
||||
|
||||
if (isEquipped( Dungeon.hero )) {
|
||||
info.append( "\n\nYou hold the " + name + " at the ready." );
|
||||
}
|
||||
|
||||
return info.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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.weapon.missiles;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
public class Shuriken extends MissileWeapon {
|
||||
|
||||
{
|
||||
name = "shuriken";
|
||||
image = ItemSpriteSheet.SHURIKEN;
|
||||
|
||||
STR = 13;
|
||||
|
||||
MIN = 2;
|
||||
MAX = 6;
|
||||
|
||||
DLY = 0.5f;
|
||||
}
|
||||
|
||||
public Shuriken() {
|
||||
this( 1 );
|
||||
}
|
||||
|
||||
public Shuriken( int number ) {
|
||||
super();
|
||||
quantity = number;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String desc() {
|
||||
return
|
||||
"Star-shaped pieces of metal with razor-sharp blades do significant damage " +
|
||||
"when they hit a target. They can be thrown at very high rate.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item random() {
|
||||
quantity = Random.Int( 5, 15 );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int price() {
|
||||
return 15 * quantity;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* 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.weapon.missiles;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Bleeding;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
public class Tamahawk extends MissileWeapon {
|
||||
|
||||
{
|
||||
name = "tomahawk";
|
||||
image = ItemSpriteSheet.TOMAHAWK;
|
||||
|
||||
STR = 17;
|
||||
|
||||
MIN = 4;
|
||||
MAX = 20;
|
||||
}
|
||||
|
||||
public Tamahawk() {
|
||||
this( 1 );
|
||||
}
|
||||
|
||||
public Tamahawk( int number ) {
|
||||
super();
|
||||
quantity = number;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void proc( Char attacker, Char defender, int damage ) {
|
||||
super.proc( attacker, defender, damage );
|
||||
Buff.affect( defender, Bleeding.class ).set( damage );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String desc() {
|
||||
return
|
||||
"This throwing axe is not that heavy, but it still " +
|
||||
"requires significant strength to be used effectively.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item random() {
|
||||
quantity = Random.Int( 5, 12 );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int price() {
|
||||
return 20 * quantity;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user