From e951b7aad805f0d9bd49d9be37b1ae00ca712524 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Sun, 1 Feb 2015 21:21:28 -0500 Subject: [PATCH] Merging 1.7.5 Source: actors/hero changes --- .../actors/hero/Belongings.java | 2 +- .../actors/hero/Hero.java | 66 ++++++++++++++----- 2 files changed, 51 insertions(+), 17 deletions(-) diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Belongings.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Belongings.java index 97662f066..ff64da7a0 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Belongings.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Belongings.java @@ -173,7 +173,7 @@ public class Belongings implements Iterable { item.detachAll( backpack ); } } else if (item.unique) { - + // Keep unique items } else if (!item.isEquipped( owner )) { item.detachAll( backpack ); } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java index 814edd441..51f88300d 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java @@ -71,6 +71,8 @@ import com.shatteredpixel.shatteredpixeldungeon.items.keys.GoldenKey; import com.shatteredpixel.shatteredpixeldungeon.items.keys.IronKey; import com.shatteredpixel.shatteredpixeldungeon.items.keys.Key; import com.shatteredpixel.shatteredpixeldungeon.items.keys.SkeletonKey; +import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion; +import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfMight; import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfStrength; import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfElements; import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfEvasion; @@ -79,9 +81,11 @@ import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfFuror; import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfHaste; import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfMight; import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfTenacity; +import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfMagicMapping; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfRecharging; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfUpgrade; +import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfWeaponUpgrade; import com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MeleeWeapon; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.MissileWeapon; @@ -89,6 +93,7 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.Level; import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; import com.shatteredpixel.shatteredpixeldungeon.levels.features.AlchemyPot; import com.shatteredpixel.shatteredpixeldungeon.levels.features.Chasm; +import com.shatteredpixel.shatteredpixeldungeon.levels.features.Sign; import com.shatteredpixel.shatteredpixeldungeon.plants.Earthroot; import com.shatteredpixel.shatteredpixeldungeon.plants.Sungrass; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; @@ -110,6 +115,7 @@ import com.watabou.utils.Bundle; import com.watabou.utils.Random; import java.util.ArrayList; +import java.util.Collections; import java.util.HashSet; public class Hero extends Char { @@ -508,7 +514,7 @@ public class Hero extends Char { } public void interrupt() { - if (curAction != null && curAction.dst != pos) { + if (isAlive() && curAction != null && curAction.dst != pos) { lastAction = curAction; } curAction = null; @@ -529,9 +535,10 @@ public class Hero extends Char { } else { if (Dungeon.level.map[pos] == Terrain.SIGN) { - GameScene.show( new WndMessage( Dungeon.tip() ) ); + Sign.read(pos); } ready(); + return false; } } @@ -614,11 +621,13 @@ public class Hero extends Char { if (item instanceof Dewdrop || item instanceof TimekeepersHourglass.sandBag || item instanceof DriedRose.Petal) { - + //Do Nothing } else { - if ((item instanceof ScrollOfUpgrade && ((ScrollOfUpgrade)item).isKnown()) || - (item instanceof PotionOfStrength && ((PotionOfStrength)item).isKnown())) { + boolean important = + ((item instanceof ScrollOfUpgrade || item instanceof ScrollOfWeaponUpgrade) && ((Scroll)item).isKnown()) || + ((item instanceof PotionOfStrength || item instanceof PotionOfMight) && ((Potion)item).isKnown()); + if (important) { GLog.p( TXT_YOU_NOW_HAVE, item.name() ); } else { GLog.i( TXT_YOU_NOW_HAVE, item.name() ); @@ -660,10 +669,8 @@ public class Hero extends Char { if (Level.adjacent( pos, dst ) || pos == dst) { Heap heap = Dungeon.level.heaps.get( dst ); - if (heap != null && - (heap.type == Type.CHEST || heap.type == Type.TOMB || heap.type == Type.SKELETON || - heap.type == Type.REMAINS || heap.type == Type.LOCKED_CHEST || heap.type == Type.CRYSTAL_CHEST)) { - + if (heap != null && (heap.type != Type.HEAP && heap.type != Type.FOR_SALE)) { + theKey = null; if (heap.type == Type.LOCKED_CHEST || heap.type == Type.CRYSTAL_CHEST) { @@ -831,7 +838,7 @@ public class Hero extends Char { enemy = action.target; - if (Level.adjacent( pos, enemy.pos ) && enemy.isAlive() && !pacified) { + if (Level.adjacent( pos, enemy.pos ) && enemy.isAlive() && !isCharmedBy( enemy )) { spend( attackDelay() ); sprite.attack( enemy.pos ); @@ -888,7 +895,7 @@ public class Hero extends Char { } case SNIPER: if (rangedWeapon != null) { - Buff.prolong( enemy, SnipersMark.class, attackDelay() * 1.1f ); + Buff.prolong( this, SnipersMark.class, attackDelay() * 1.1f ).object = enemy.id(); } break; default: @@ -985,6 +992,7 @@ public class Hero extends Char { private boolean getCloser( final int target ) { if (rooted) { + Camera.main.shake( 1, 1f ); return false; } @@ -1047,9 +1055,8 @@ public class Hero extends Char { curAction = new HeroAction.Cook( cell ); - } else - if (Level.fieldOfView[cell] && (ch = Actor.findChar( cell )) instanceof Mob) { - + } else if (Level.fieldOfView[cell] && (ch = Actor.findChar( cell )) instanceof Mob) { + if (ch instanceof NPC) { curAction = new HeroAction.Interact( (NPC)ch ); } else { @@ -1299,7 +1306,29 @@ public class Hero extends Char { Dungeon.observe(); Dungeon.hero.belongings.identify(); - + + int pos = Dungeon.hero.pos; + + ArrayList passable = new ArrayList(); + for (Integer ofs : Level.NEIGHBOURS8) { + int cell = pos + ofs; + if ((Level.passable[cell] || Level.avoid[cell]) && Dungeon.level.heaps.get( cell ) == null) { + passable.add( cell ); + } + } + Collections.shuffle( passable ); + + ArrayList items = new ArrayList( Dungeon.hero.belongings.backpack.items ); + for (Integer cell : passable) { + if (items.isEmpty()) { + break; + } + + Item item = Random.element( items ); + Dungeon.level.drop( item, cell ).sprite.drop( pos ); + items.remove( item ); + } + GameScene.gameOver(); if (cause instanceof Hero.Doom) { @@ -1498,7 +1527,12 @@ public class Hero extends Char { } return immunities; } - + + @Override + public void next() { + super.next(); + } + public static interface Doom { public void onDeath(); }