v0.3.5: beginnings of warrior rework (needs lots of polish)
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package com.shatteredpixel.shatteredpixeldungeon.items;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor;
|
||||
|
||||
//TODO: add actual item properties here
|
||||
public class BrokenSigil {
|
||||
|
||||
public static class SigilShield extends Buff {
|
||||
|
||||
private Armor armor;
|
||||
private float partialShield;
|
||||
|
||||
@Override
|
||||
public boolean act() {
|
||||
if (armor == null) detach();
|
||||
else if (armor.isEquipped((Hero)target)) {
|
||||
//1 + half of your DR, rounded up.
|
||||
int maxShield = (int)(armor.DR()/2f + 1.5f);
|
||||
if (target.SHLD < maxShield){
|
||||
partialShield += (maxShield - target.SHLD)/50f;
|
||||
}
|
||||
}
|
||||
while (partialShield >= 1){
|
||||
target.SHLD++;
|
||||
partialShield--;
|
||||
}
|
||||
spend(TICK);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setArmor(Armor arm){
|
||||
armor = arm;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,11 @@ package com.shatteredpixel.shatteredpixeldungeon.items.armor;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Badges;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.BrokenSigil;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.Affection;
|
||||
@@ -40,6 +44,7 @@ import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.HeroSprite;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
||||
import com.watabou.noosa.particles.Emitter;
|
||||
import com.watabou.utils.Bundlable;
|
||||
import com.watabou.utils.Bundle;
|
||||
import com.watabou.utils.Random;
|
||||
@@ -57,6 +62,7 @@ public class Armor extends EquipableItem {
|
||||
private int hitsToKnow = HITS_TO_KNOW;
|
||||
|
||||
public Glyph glyph;
|
||||
private boolean sigil;
|
||||
|
||||
public Armor( int tier ) {
|
||||
|
||||
@@ -99,6 +105,7 @@ public class Armor extends EquipableItem {
|
||||
}
|
||||
|
||||
((HeroSprite)hero.sprite).updateArmor();
|
||||
activate(hero);
|
||||
|
||||
hero.spendAndNext( 2 * time2equip( hero ) );
|
||||
return true;
|
||||
@@ -111,6 +118,12 @@ public class Armor extends EquipableItem {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void activate(Char ch) {
|
||||
if (Dungeon.hero.heroClass == HeroClass.WARRIOR)
|
||||
Buff.affect(ch, BrokenSigil.SigilShield.class).setArmor(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float time2equip( Hero hero ) {
|
||||
return hero.speed();
|
||||
@@ -123,6 +136,9 @@ public class Armor extends EquipableItem {
|
||||
hero.belongings.armor = null;
|
||||
((HeroSprite)hero.sprite).updateArmor();
|
||||
|
||||
BrokenSigil.SigilShield sigil = hero.buff(BrokenSigil.SigilShield.class);
|
||||
if (sigil != null) sigil.setArmor(null);
|
||||
|
||||
return true;
|
||||
|
||||
} else {
|
||||
@@ -228,7 +244,18 @@ public class Armor extends EquipableItem {
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Emitter emitter() {
|
||||
//if (!sigil) return super.emitter();
|
||||
if (Dungeon.hero.heroClass != HeroClass.WARRIOR) return super.emitter();
|
||||
Emitter emitter = new Emitter();
|
||||
emitter.pos(10f, 6f);
|
||||
emitter.fillTarget = false;
|
||||
emitter.pour(Speck.factory( Speck.LIGHT ), 1f);
|
||||
return emitter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item random() {
|
||||
if (Random.Float() < 0.4) {
|
||||
|
||||
@@ -113,14 +113,8 @@ abstract public class Weapon extends KindOfWeapon {
|
||||
float ACU = this.ACU;
|
||||
|
||||
if (this instanceof MissileWeapon) {
|
||||
switch (hero.heroClass) {
|
||||
case WARRIOR:
|
||||
encumbrance += 3;
|
||||
break;
|
||||
case HUNTRESS:
|
||||
if (hero.heroClass == HeroClass.HUNTRESS) {
|
||||
encumbrance -= 2;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
int bonus = 0;
|
||||
for (Buff buff : hero.buffs(RingOfSharpshooting.Aim.class)) {
|
||||
|
||||
@@ -20,113 +20,16 @@
|
||||
*/
|
||||
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee;
|
||||
|
||||
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;
|
||||
import com.watabou.noosa.audio.Sample;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
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;
|
||||
|
||||
{
|
||||
image = ItemSpriteSheet.SHORT_SWORD;
|
||||
|
||||
unique = true;
|
||||
bones = false;
|
||||
}
|
||||
|
||||
public ShortSword() {
|
||||
super( 1, 1f, 1f );
|
||||
|
||||
STR = 11;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int maxBase() {
|
||||
return 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 );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user