v0.2.3: quickslot refactoring for artifacts

This commit is contained in:
Evan Debenham 2014-12-09 16:40:36 -05:00
parent 8dba48813d
commit b851be162e
6 changed files with 94 additions and 76 deletions

View File

@ -57,7 +57,10 @@ public class CloakOfShadows extends Artifact {
if (action.equals( AC_STEALTH )) {
if (!stealthed){
if (cooldown <= 0 && charge >= 2 && isEquipped(hero)) {
if (!isEquipped(hero)) GLog.i("You need to equip your cloak to do that.");
else if (cooldown > 0) GLog.i("Your cloak needs " + cooldown + " more rounds to re-energize.");
else if (charge <= 1) GLog.i("Your cloak hasn't recharged enough to be usable yet.");
else {
stealthed = true;
hero.spend( 1f );
hero.busy();
@ -71,12 +74,6 @@ public class CloakOfShadows extends Artifact {
}
hero.sprite.operate(hero.pos);
GLog.i("Your cloak blends you into the shadows.");
} else if (!isEquipped(hero)) {
GLog.i("You need to equip your cloak to do that.");
} else if (cooldown > 0) {
GLog.i("Your cloak needs " + cooldown + " more rounds to re-energize.");
} else if (charge <= 1){
GLog.i("Your cloak hasn't recharged enough to be usable yet.");
}
} else {
stealthed = false;

View File

@ -9,16 +9,13 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.NPC;
import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.Pushing;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.GhostSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.sprites.WraithSprite;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndQuest;
import com.watabou.noosa.audio.Sample;
import com.watabou.utils.Random;
@ -59,26 +56,30 @@ public class DriedRose extends Artifact {
public void execute( Hero hero, String action ) {
if (action.equals(AC_SUMMON)) {
ArrayList<Integer> spawnPoints = new ArrayList<Integer>();
for (int i=0; i < Level.NEIGHBOURS8.length; i++) {
int p = hero.pos + Level.NEIGHBOURS8[i];
if (Actor.findChar(p) == null && (Level.passable[p] || Level.avoid[p])) {
spawnPoints.add( p );
if (!isEquipped( hero )) GLog.i("You need to equip your rose to do that.");
else if (charge != chargeCap) GLog.i("Your rose isn't fully charged yet.");
else {
ArrayList<Integer> spawnPoints = new ArrayList<Integer>();
for (int i = 0; i < Level.NEIGHBOURS8.length; i++) {
int p = hero.pos + Level.NEIGHBOURS8[i];
if (Actor.findChar(p) == null && (Level.passable[p] || Level.avoid[p])) {
spawnPoints.add(p);
}
}
}
if (spawnPoints.size() > 0) {
GhostHero ghost = new GhostHero();
ghost.pos = Random.element(spawnPoints);
if (spawnPoints.size() > 0) {
GhostHero ghost = new GhostHero();
ghost.pos = Random.element(spawnPoints);
GameScene.add( ghost, 1f );
CellEmitter.get(ghost.pos).start(Speck.factory(Speck.LIGHT), 0.2f, 3);
GameScene.add(ghost, 1f);
CellEmitter.get(ghost.pos).start(Speck.factory(Speck.LIGHT), 0.2f, 3);
hero.spend( 1f );
hero.busy();
hero.sprite.operate(hero.pos);
hero.spend(1f);
hero.busy();
hero.sprite.operate(hero.pos);
}
}
} else{

View File

@ -34,6 +34,8 @@ public class HornOfPlenty extends Artifact {
levelCap = 30;
charge = 0;
chargeCap = 10;
defaultAction = AC_EAT;
}
private static final float TIME_TO_EAT = 3f;
@ -63,41 +65,46 @@ public class HornOfPlenty extends Artifact {
super.execute(hero, action);
if (action.equals(AC_EAT)){
((Hunger)hero.buff( Hunger.class )).satisfy( energy*charge );
//if you get at least 100 food energy from the horn
if (charge >= 3){
switch (hero.heroClass) {
case WARRIOR:
if (hero.HP < hero.HT) {
hero.HP = Math.min( hero.HP + 5, hero.HT );
hero.sprite.emitter().burst( Speck.factory(Speck.HEALING), 1 );
}
break;
case MAGE:
hero.belongings.charge( false );
ScrollOfRecharging.charge(hero);
break;
case ROGUE:
case HUNTRESS:
break;
if (!isEquipped(hero)) GLog.i("You need to equip your horn to do that.");
else if (charge == 0) GLog.i("Your horn has no food in it to eat!");
else {
((Hunger) hero.buff(Hunger.class)).satisfy(energy * charge);
//if you get at least 100 food energy from the horn
if (charge >= 3) {
switch (hero.heroClass) {
case WARRIOR:
if (hero.HP < hero.HT) {
hero.HP = Math.min(hero.HP + 5, hero.HT);
hero.sprite.emitter().burst(Speck.factory(Speck.HEALING), 1);
}
break;
case MAGE:
hero.belongings.charge(false);
ScrollOfRecharging.charge(hero);
break;
case ROGUE:
case HUNTRESS:
break;
}
Statistics.foodEaten++;
}
charge = 0;
Statistics.foodEaten++;
hero.sprite.operate(hero.pos);
hero.busy();
SpellSprite.show(hero, SpellSprite.FOOD);
Sample.INSTANCE.play(Assets.SND_EAT);
GLog.i("You eat from the horn.");
hero.spend(TIME_TO_EAT);
Badges.validateFoodEaten();
image = ItemSpriteSheet.ARTIFACT_HORN1;
}
charge = 0;
hero.sprite.operate( hero.pos );
hero.busy();
SpellSprite.show(hero, SpellSprite.FOOD);
Sample.INSTANCE.play( Assets.SND_EAT );
GLog.i("You eat from the horn.");
hero.spend( TIME_TO_EAT );
Badges.validateFoodEaten();
image = ItemSpriteSheet.ARTIFACT_HORN1;
} else if (action.equals(AC_STORE)){

View File

@ -32,6 +32,8 @@ public class SandalsOfNature extends Artifact {
levelCap = 3;
charge = 0;
//partialcharge, chargeCap and exp are unused
defaultAction = AC_ROOT;
}
public static final String[] NAMES = {"Sandals of Nature", "Shoes of Nature",
@ -60,12 +62,15 @@ public class SandalsOfNature extends Artifact {
super.execute(hero, action);
if (action.equals(AC_FEED)){
GameScene.selectItem(itemSelector, mode, inventoryTitle);
} else if (action.equals(AC_ROOT)){
if (charge > 0){
Buff.prolong( hero, Roots.class, 5);
Buff.affect( hero, Earthroot.Armor.class ).level( charge );
} else if (action.equals(AC_ROOT) && level > 0){
if (!isEquipped( hero )) GLog.i("You need to equip them to do that.");
else if (charge == 0) GLog.i("They have no energy right now.");
else {
Buff.prolong(hero, Roots.class, 5);
Buff.affect(hero, Earthroot.Armor.class).level(charge);
CellEmitter.bottom(hero.pos).start(EarthParticle.FACTORY, 0.05f, 8);
Camera.main.shake( 1, 0.4f );
Camera.main.shake(1, 0.4f);
charge = 0;
}
}

View File

@ -30,6 +30,8 @@ public class TalismanOfForesight extends Artifact {
exp = 0;
partialCharge = 0;
chargeCap = 100;
defaultAction = AC_SCRY;
}
public static final String AC_SCRY = "SCRY";
@ -46,28 +48,32 @@ public class TalismanOfForesight extends Artifact {
public void execute( Hero hero, String action ) {
super.execute(hero, action);
if (action.equals(AC_SCRY)){
hero.sprite.operate( hero.pos );
hero.busy();
Sample.INSTANCE.play( Assets.SND_BEACON );
charge = 0;
for (int i=0; i < Level.LENGTH; i++) {
int terr = Dungeon.level.map[i];
if ((Terrain.flags[terr] & Terrain.SECRET) != 0) {
if (!isEquipped(hero)) GLog.i("You need to equip your talisman to do that.");
else if (charge != chargeCap) GLog.i("Your talisman isn't full charged yet.");
else {
hero.sprite.operate(hero.pos);
hero.busy();
Sample.INSTANCE.play(Assets.SND_BEACON);
charge = 0;
for (int i = 0; i < Level.LENGTH; i++) {
GameScene.updateMap( i );
int terr = Dungeon.level.map[i];
if ((Terrain.flags[terr] & Terrain.SECRET) != 0) {
if (Dungeon.visible[i]) {
GameScene.discoverTile( i, terr );
GameScene.updateMap(i);
if (Dungeon.visible[i]) {
GameScene.discoverTile(i, terr);
}
}
}
GLog.p("The Talisman floods your mind with knowledge about the current floor.");
Buff.affect(hero, Awareness.class, Awareness.DURATION);
Dungeon.observe();
}
GLog.p ("The Talisman floods your mind with knowledge about the current floor.");
Buff.affect(hero, Awareness.class, Awareness.DURATION);
Dungeon.observe();
}
}

View File

@ -75,6 +75,8 @@ public class UnstableSpellbook extends Artifact {
if (action.equals( AC_READ )) {
if (hero.buff( Blindness.class ) != null) GLog.w("You cannot read from the book while blinded.");
else if (!isEquipped( hero )) GLog.i("You need to equip your spellbook to do that.");
else if (charge == 0) GLog.i("Your spellbook is out of energy for now.");
else {
charge--;