Merging 1.7.5 Source: items/ changes

This commit is contained in:
Evan Debenham 2015-02-03 22:48:13 -05:00
parent a6c89490b0
commit 41e1f20e95
3 changed files with 62 additions and 18 deletions

View File

@ -96,7 +96,7 @@ public abstract class EquipableItem extends Item {
return true;
}
public boolean doUnequip( Hero hero, boolean collect ) {
final public boolean doUnequip( Hero hero, boolean collect ) {
return doUnequip( hero, collect, true );
}
}

View File

@ -22,15 +22,18 @@ import com.shatteredpixel.shatteredpixeldungeon.Badges;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.Statistics;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Burning;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Frost;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mimic;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Wraith;
import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.effects.Splash;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ElmoParticle;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.FlameParticle;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ShadowParticle;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.AlchemistsToolkit;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.Artifact;
import com.shatteredpixel.shatteredpixeldungeon.items.food.Blandfruit;
import com.shatteredpixel.shatteredpixeldungeon.items.food.ChargrilledMeat;
import com.shatteredpixel.shatteredpixeldungeon.items.food.FrozenCarpaccio;
@ -39,8 +42,11 @@ import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfExperience
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfHealing;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll;
import com.shatteredpixel.shatteredpixeldungeon.plants.Plant.Seed;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndTitledMessage;
import com.watabou.noosa.audio.Sample;
import com.watabou.utils.Bundlable;
import com.watabou.utils.Bundle;
@ -52,6 +58,8 @@ import java.util.LinkedList;
public class Heap implements Bundlable {
private static final String TXT_MIMIC = "This is a mimic!";
private static final int SEEDS_TO_POTION = 3;
public enum Type {
@ -62,7 +70,8 @@ public class Heap implements Bundlable {
CRYSTAL_CHEST,
TOMB,
SKELETON,
REMAINS
REMAINS,
MIMIC
}
public Type type = Type.HEAP;
@ -70,7 +79,7 @@ public class Heap implements Bundlable {
public ItemSprite sprite;
protected LinkedList<Item> items = new LinkedList<Item>();
public LinkedList<Item> items = new LinkedList<Item>();
public int image() {
switch (type) {
@ -78,6 +87,7 @@ public class Heap implements Bundlable {
case FOR_SALE:
return size() > 0 ? items.peek().image() : 0;
case CHEST:
case MIMIC:
return ItemSpriteSheet.CHEST;
case LOCKED_CHEST:
return ItemSpriteSheet.LOCKED_CHEST;
@ -100,6 +110,14 @@ public class Heap implements Bundlable {
public void open( Hero hero ) {
switch (type) {
case MIMIC:
if (Mimic.spawnAt(pos, items) != null) {
GLog.n(TXT_MIMIC);
destroy();
} else {
type = Type.CHEST;
}
break;
case TOMB:
Wraith.spawnAround( hero.pos );
break;
@ -119,10 +137,12 @@ public class Heap implements Bundlable {
break;
default:
}
type = Type.HEAP;
sprite.link();
sprite.drop();
if (type != Type.MIMIC) {
type = Type.HEAP;
sprite.link();
sprite.drop();
}
}
public int size() {
@ -180,7 +200,16 @@ public class Heap implements Bundlable {
}
public void burn() {
if (type == Type.MIMIC) {
Mimic m = Mimic.spawnAt( pos, items );
if (m != null) {
Buff.affect( m, Burning.class ).reignite( m );
m.sprite.emitter().burst( FlameParticle.FACTORY, 5 );
destroy();
}
}
if (type != Type.HEAP) {
return;
}
@ -221,7 +250,15 @@ public class Heap implements Bundlable {
}
public void freeze() {
if (type == Type.MIMIC) {
Mimic m = Mimic.spawnAt( pos, items );
if (m != null) {
Buff.prolong( m, Frost.class, Frost.duration( m ) * Random.Float( 1.0f, 1.5f ) );
destroy();
}
}
if (type != Type.HEAP) {
return;
}

View File

@ -270,7 +270,7 @@ public class Item implements Bundlable {
return this;
}
public Item upgrade( int n ) {
final public Item upgrade( int n ) {
for (int i=0; i < n; i++) {
upgrade();
}
@ -285,7 +285,7 @@ public class Item implements Bundlable {
return this;
}
public Item degrade( int n ) {
final public Item degrade( int n ) {
for (int i=0; i < n; i++) {
degrade();
}
@ -454,17 +454,24 @@ public class Item implements Bundlable {
final int cell = Ballistica.cast( user.pos, dst, false, true );
user.sprite.zap( cell );
user.busy();
Sample.INSTANCE.play( Assets.SND_MISS, 0.6f, 0.6f, 1.5f );
Char enemy = Actor.findChar( cell );
QuickSlotButton.target(enemy);
// FIXME!!!
float delay = TIME_TO_THROW;
if (this instanceof MissileWeapon) {
// FIXME
delay *= ((MissileWeapon)this).speedFactor( user );
if (enemy != null && enemy.buff( SnipersMark.class ) != null) {
delay *= 0.5f;
if (enemy != null) {
SnipersMark mark = user.buff( SnipersMark.class );
if (mark != null) {
if (mark.object == enemy.id()) {
delay *= 0.5f;
}
user.remove( mark );
}
}
}
final float finalDelay = delay;