v0.7.3: darts no longer require alchemy to be tipped

This commit is contained in:
Evan Debenham 2019-05-11 16:51:58 -04:00
parent ee7b5d6a6d
commit 4ea4d1ddf0
5 changed files with 195 additions and 81 deletions

View File

@ -177,7 +177,6 @@ public abstract class Recipe {
private static Recipe[] twoIngredientRecipes = new Recipe[]{ private static Recipe[] twoIngredientRecipes = new Recipe[]{
new Blandfruit.CookFruit(), new Blandfruit.CookFruit(),
new TippedDart.TipDart(),
new Bomb.EnhanceBomb(), new Bomb.EnhanceBomb(),
new AlchemicalCatalyst.Recipe(), new AlchemicalCatalyst.Recipe(),
new ArcaneCatalyst.Recipe(), new ArcaneCatalyst.Recipe(),

View File

@ -24,9 +24,18 @@ package com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.darts;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.MagicImmune; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.MagicImmune;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Crossbow; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Crossbow;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.MissileWeapon; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.MissileWeapon;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.plants.Plant;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions;
import java.util.ArrayList;
public class Dart extends MissileWeapon { public class Dart extends MissileWeapon {
@ -39,6 +48,24 @@ public class Dart extends MissileWeapon {
baseUses = 1000; baseUses = 1000;
} }
protected static final String AC_TIP = "TIP";
@Override
public ArrayList<String> actions(Hero hero) {
ArrayList<String> actions = super.actions( hero );
actions.add( AC_TIP );
return actions;
}
@Override
public void execute(Hero hero, String action) {
if (action.equals(AC_TIP)){
GameScene.selectItem(itemSelector, WndBag.Mode.SEED, "select a seed");
}
super.execute(hero, action);
}
@Override @Override
public int min(int lvl) { public int min(int lvl) {
if (bow != null){ if (bow != null){
@ -106,4 +133,91 @@ public class Dart extends MissileWeapon {
public boolean isUpgradable() { public boolean isUpgradable() {
return false; return false;
} }
@Override
public int price() {
return super.price()/2; //half normal value
}
private final WndBag.Listener itemSelector = new WndBag.Listener() {
@Override
public void onSelect(final Item item) {
if (item == null) return;
final int maxToTip = Math.min(curItem.quantity(), item.quantity()*2);
final int maxSeedsToUse = (maxToTip+1)/2;
final int singleSeedDarts;
final String[] options;
if (curItem.quantity() == 1){
singleSeedDarts = 1;
options = new String[]{
Messages.get(Dart.class, "tip_one"),
Messages.get(Dart.class, "tip_cancel")};
} else {
singleSeedDarts = 2;
if (maxToTip <= 2){
options = new String[]{
Messages.get(Dart.class, "tip_two"),
Messages.get(Dart.class, "tip_cancel")};
} else {
options = new String[]{
Messages.get(Dart.class, "tip_all", maxToTip, maxSeedsToUse),
Messages.get(Dart.class, "tip_two"),
Messages.get(Dart.class, "tip_cancel")};
}
}
TippedDart tipResult = TippedDart.getTipped((Plant.Seed) item, 1);
GameScene.show(new WndOptions(Messages.get(Dart.class, "tip_title"),
Messages.get(Dart.class, "tip_desc", tipResult.name()) + "\n\n" + tipResult.desc(),
options){
@Override
protected void onSelect(int index) {
super.onSelect(index);
if (index == 0 && options.length == 3){
if (item.quantity() <= maxSeedsToUse){
item.detachAll( curUser.belongings.backpack );
} else {
item.quantity(item.quantity() - maxSeedsToUse);
}
curItem.detachAll( curUser.belongings.backpack );
TippedDart newDart = TippedDart.getTipped((Plant.Seed) item, maxToTip);
if (!newDart.collect()) Dungeon.level.drop(newDart, curUser.pos).sprite.drop();
curUser.spend( 1f );
curUser.busy();
curUser.sprite.operate(curUser.pos);
} else if ((index == 1 && options.length == 3) || (index == 0 && options.length == 2)){
item.detach( curUser.belongings.backpack );
if (curItem.quantity() <= singleSeedDarts){
curItem.detachAll( curUser.belongings.backpack );
} else {
curItem.quantity(curItem.quantity() - singleSeedDarts);
}
TippedDart newDart = TippedDart.getTipped((Plant.Seed) item, singleSeedDarts);
if (!newDart.collect()) Dungeon.level.drop(newDart, curUser.pos).sprite.drop();
curUser.spend( 1f );
curUser.busy();
curUser.sprite.operate(curUser.pos);
}
}
});
}
};
} }

View File

@ -23,13 +23,16 @@ package com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.darts;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.PinCushion; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.PinCushion;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroSubClass; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroSubClass;
import com.shatteredpixel.shatteredpixeldungeon.items.Generator; import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.Recipe; import com.shatteredpixel.shatteredpixeldungeon.items.Recipe;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.plants.Blindweed; import com.shatteredpixel.shatteredpixeldungeon.plants.Blindweed;
import com.shatteredpixel.shatteredpixeldungeon.plants.Dreamfoil; import com.shatteredpixel.shatteredpixeldungeon.plants.Dreamfoil;
import com.shatteredpixel.shatteredpixeldungeon.plants.Earthroot; import com.shatteredpixel.shatteredpixeldungeon.plants.Earthroot;
@ -43,6 +46,8 @@ import com.shatteredpixel.shatteredpixeldungeon.plants.Starflower;
import com.shatteredpixel.shatteredpixeldungeon.plants.Stormvine; import com.shatteredpixel.shatteredpixeldungeon.plants.Stormvine;
import com.shatteredpixel.shatteredpixeldungeon.plants.Sungrass; import com.shatteredpixel.shatteredpixeldungeon.plants.Sungrass;
import com.shatteredpixel.shatteredpixeldungeon.plants.Swiftthistle; import com.shatteredpixel.shatteredpixeldungeon.plants.Swiftthistle;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
@ -56,6 +61,49 @@ public abstract class TippedDart extends Dart {
baseUses = 0.65f; baseUses = 0.65f;
} }
private static final String AC_CLEAN = "CLEAN";
@Override
public ArrayList<String> actions(Hero hero) {
ArrayList<String> actions = super.actions( hero );
actions.remove( AC_TIP );
actions.add( AC_CLEAN );
return actions;
}
@Override
public void execute(final Hero hero, String action) {
if (action.equals( AC_CLEAN )){
GameScene.show(new WndOptions(Messages.get(this, "clean_title"),
Messages.get(this, "clean_desc"),
Messages.get(this, "clean_all"),
Messages.get(this, "clean_one"),
Messages.get(this, "cancel")){
@Override
protected void onSelect(int index) {
if (index == 0){
detachAll(hero.belongings.backpack);
new Dart().quantity(quantity).collect();
hero.spend( 1f );
hero.busy();
hero.sprite.operate(hero.pos);
} else if (index == 1){
detach(hero.belongings.backpack);
if (!new Dart().collect()) Dungeon.level.drop(new Dart(), hero.pos).sprite.drop();
hero.spend( 1f );
hero.busy();
hero.sprite.operate(hero.pos);
}
}
});
}
super.execute(hero, action);
}
//exact same damage as regular darts, despite being higher tier. //exact same damage as regular darts, despite being higher tier.
@Override @Override
@ -88,6 +136,12 @@ public abstract class TippedDart extends Dart {
return use; return use;
} }
@Override
public int price() {
//value of regular dart plus half of the seed
return 8 * quantity;
}
private static HashMap<Class<?extends Plant.Seed>, Class<?extends TippedDart>> types = new HashMap<>(); private static HashMap<Class<?extends Plant.Seed>, Class<?extends TippedDart>> types = new HashMap<>();
static { static {
types.put(Blindweed.Seed.class, BlindingDart.class); types.put(Blindweed.Seed.class, BlindingDart.class);
@ -104,89 +158,23 @@ public abstract class TippedDart extends Dart {
types.put(Swiftthistle.Seed.class, AdrenalineDart.class); types.put(Swiftthistle.Seed.class, AdrenalineDart.class);
} }
public static TippedDart randomTipped(){ public static TippedDart getTipped( Plant.Seed s, int quantity ){
try {
return (TippedDart) types.get(s.getClass()).newInstance().quantity(quantity);
} catch (Exception e){
ShatteredPixelDungeon.reportException(e);
return null;
}
}
public static TippedDart randomTipped( int quantity ){
Plant.Seed s; Plant.Seed s;
do{ do{
s = (Plant.Seed) Generator.random(Generator.Category.SEED); s = (Plant.Seed) Generator.random(Generator.Category.SEED);
} while (!types.containsKey(s.getClass())); } while (!types.containsKey(s.getClass()));
try{ return getTipped(s, quantity );
return (TippedDart) types.get(s.getClass()).newInstance().quantity(2);
} catch (Exception e) {
ShatteredPixelDungeon.reportException(e);
return null;
}
} }
public static class TipDart extends Recipe{
@Override
//also sorts ingredients if it can
public boolean testIngredients(ArrayList<Item> ingredients) {
if (ingredients.size() != 2) return false;
if (ingredients.get(0).getClass() == Dart.class){
if (!(ingredients.get(1) instanceof Plant.Seed)){
return false;
}
} else if (ingredients.get(0) instanceof Plant.Seed){
if (ingredients.get(1).getClass() == Dart.class){
Item temp = ingredients.get(0);
ingredients.set(0, ingredients.get(1));
ingredients.set(1, temp);
} else {
return false;
}
} else {
return false;
}
Plant.Seed seed = (Plant.Seed) ingredients.get(1);
if (ingredients.get(0).quantity() >= 1
&& seed.quantity() >= 1
&& types.containsKey(seed.getClass())){
return true;
}
return false;
}
@Override
public int cost(ArrayList<Item> ingredients) {
return 0;
}
@Override
public Item brew(ArrayList<Item> ingredients) {
if (!testIngredients(ingredients)) return null;
int produced = Math.min(2, ingredients.get(0).quantity());
ingredients.get(0).quantity(ingredients.get(0).quantity() - produced);
ingredients.get(1).quantity(ingredients.get(1).quantity() - 1);
try{
return types.get(ingredients.get(1).getClass()).newInstance().quantity(produced);
} catch (Exception e) {
ShatteredPixelDungeon.reportException(e);
return null;
}
}
@Override
public Item sampleOutput(ArrayList<Item> ingredients) {
if (!testIngredients(ingredients)) return null;
try{
int produced = Math.min(2, ingredients.get(0).quantity());
return types.get(ingredients.get(1).getClass()).newInstance().quantity( produced );
} catch (Exception e) {
ShatteredPixelDungeon.reportException(e);
return null;
}
}
}
} }

View File

@ -204,7 +204,7 @@ public class ShopRoom extends SpecialRoom {
break; break;
} }
itemsToSpawn.add( TippedDart.randomTipped() ); itemsToSpawn.add( TippedDart.randomTipped(2) );
itemsToSpawn.add( new MerchantsBeacon() ); itemsToSpawn.add( new MerchantsBeacon() );

View File

@ -1339,7 +1339,14 @@ items.weapon.missiles.darts.chillingdart.name=chilling dart
items.weapon.missiles.darts.chillingdart.desc=These darts are tipped with an icecap-based compound which will significantly chill their target. items.weapon.missiles.darts.chillingdart.desc=These darts are tipped with an icecap-based compound which will significantly chill their target.
items.weapon.missiles.darts.dart.name=dart items.weapon.missiles.darts.dart.name=dart
items.weapon.missiles.darts.dart.desc=These simple shafts of spike-tipped wood are weighted to fly true and sting their prey with a flick of the wrist. items.weapon.missiles.darts.dart.ac_tip=TIP
items.weapon.missiles.darts.dart.tip_title=Tip Darts
items.weapon.missiles.darts.dart.tip_desc=A seed can be combined with one or two darts to tip them. Each type of seed produces its own type of tipped dart, with a unique single-use effect.\n\nTipping a dart with these seeds will produce a _%s._
items.weapon.missiles.darts.dart.tip_all=tip %d darts with %d seeds
items.weapon.missiles.darts.dart.tip_two=tip 2 darts with 1 seed
items.weapon.missiles.darts.dart.tip_one=tip 1 dart with 1 seed
items.weapon.missiles.darts.dart.tip_cancel=cancel
items.weapon.missiles.darts.dart.desc=These simple shafts of spike-tipped wood are weighted to fly true and sting their prey with a flick of the wrist. They can tipped with seeds to gain bonus effects when thrown.
items.weapon.missiles.darts.dart.unlimited_uses=However, due to their simple construction darts will effectively last forever. items.weapon.missiles.darts.dart.unlimited_uses=However, due to their simple construction darts will effectively last forever.
items.weapon.missiles.darts.displacingdart.name=displacing dart items.weapon.missiles.darts.displacingdart.name=displacing dart
@ -1369,6 +1376,12 @@ items.weapon.missiles.darts.shockingdart.desc=These darts are tipped with a stor
items.weapon.missiles.darts.sleepdart.name=sleep dart items.weapon.missiles.darts.sleepdart.name=sleep dart
items.weapon.missiles.darts.sleepdart.desc=These darts are tipped with a dreamfoil-based compound which will instantly put their target into a light sleep. items.weapon.missiles.darts.sleepdart.desc=These darts are tipped with a dreamfoil-based compound which will instantly put their target into a light sleep.
items.weapon.missiles.darts.tippeddart.ac_clean=CLEAN
items.weapon.missiles.darts.tippeddart.clean_title=Clean Darts
items.weapon.missiles.darts.tippeddart.clean_desc=This action will remove the seed tipping on your darts, reverting them back to regular darts.
items.weapon.missiles.darts.tippeddart.clean_all=clean all
items.weapon.missiles.darts.tippeddart.clean_one=clean one
items.weapon.missiles.darts.tippeddart.cancel=cancel
items.weapon.missiles.darts.tippeddart.durability=Tipped darts will lose their tips and become regular darts when used. items.weapon.missiles.darts.tippeddart.durability=Tipped darts will lose their tips and become regular darts when used.
items.weapon.missiles.darts.tippeddart.uses_left=This stack of darts has _%d/%d_ uses left before one tip wears off. items.weapon.missiles.darts.tippeddart.uses_left=This stack of darts has _%d/%d_ uses left before one tip wears off.
items.weapon.missiles.darts.tippeddart.unlimited_uses=_But these are of such high quality that they will effectively last forever._ items.weapon.missiles.darts.tippeddart.unlimited_uses=_But these are of such high quality that they will effectively last forever._