use of com.shatteredpixel.shatteredpixeldungeon.items.bags.Bag in project shattered-pixel-dungeon-gdx by 00-Evan.
the class DisintegrationTrap method activate.
@Override
public void activate() {
Char target = Actor.findChar(pos);
// find the closest char that can be aimed at
if (target == null) {
for (Char ch : Actor.chars()) {
Ballistica bolt = new Ballistica(pos, ch.pos, Ballistica.PROJECTILE);
if (bolt.collisionPos == ch.pos && (target == null || Dungeon.level.trueDistance(pos, ch.pos) < Dungeon.level.trueDistance(pos, target.pos))) {
target = ch;
}
}
}
Heap heap = Dungeon.level.heaps.get(pos);
if (heap != null)
heap.explode();
if (target != null) {
if (Dungeon.level.heroFOV[pos] || Dungeon.level.heroFOV[target.pos]) {
Sample.INSTANCE.play(Assets.SND_RAY);
ShatteredPixelDungeon.scene().add(new Beam.DeathRay(DungeonTilemap.tileCenterToWorld(pos), target.sprite.center()));
}
target.damage(Math.max(target.HT / 5, Random.Int(target.HP / 2, 2 * target.HP / 3)), this);
if (target == Dungeon.hero) {
Hero hero = (Hero) target;
if (!hero.isAlive()) {
Dungeon.fail(getClass());
GLog.n(Messages.get(this, "ondeath"));
} else {
Item item = hero.belongings.randomUnequipped();
Bag bag = hero.belongings.backpack;
// bags do not protect against this trap
if (item instanceof Bag) {
bag = (Bag) item;
item = Random.element(bag.items);
}
if (item == null || item.level() > 0 || item.unique)
return;
if (!item.stackable) {
item.detachAll(bag);
GLog.w(Messages.get(this, "one", item.name()));
} else {
int n = Random.NormalIntRange(1, (item.quantity() + 1) / 2);
for (int i = 1; i <= n; i++) item.detach(bag);
GLog.w(Messages.get(this, "some", item.name()));
}
}
}
}
}
use of com.shatteredpixel.shatteredpixeldungeon.items.bags.Bag in project shattered-pixel-dungeon-gdx by 00-Evan.
the class ScrollOfRemoveCurse method uncurse.
public static boolean uncurse(Hero hero, Item... items) {
boolean procced = false;
for (Item item : items) {
if (item != null && item.cursed) {
item.cursed = false;
procced = true;
}
if (item instanceof Weapon) {
Weapon w = (Weapon) item;
if (w.hasCurseEnchant()) {
w.enchant(null);
w.cursed = false;
procced = true;
}
}
if (item instanceof Armor) {
Armor a = (Armor) item;
if (a.hasCurseGlyph()) {
a.inscribe(null);
a.cursed = false;
procced = true;
}
}
if (item instanceof Bag) {
for (Item bagItem : ((Bag) item).items) {
if (bagItem != null && bagItem.cursed) {
bagItem.cursed = false;
procced = true;
}
}
}
}
if (procced) {
hero.sprite.emitter().start(ShadowParticle.UP, 0.05f, 10);
// for ring of might
hero.updateHT(false);
}
return procced;
}
use of com.shatteredpixel.shatteredpixeldungeon.items.bags.Bag in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Belongings method resurrect.
public void resurrect(int depth) {
for (Item item : backpack.items.toArray(new Item[0])) {
if (item instanceof Key) {
if (((Key) item).depth == depth) {
item.detachAll(backpack);
}
} else if (item.unique) {
item.detachAll(backpack);
// you keep the bag itself, not its contents.
if (item instanceof Bag) {
((Bag) item).clear();
}
item.collect();
} else if (!item.isEquipped(owner)) {
item.detachAll(backpack);
}
}
if (weapon != null) {
weapon.cursed = false;
weapon.activate(owner);
}
if (armor != null) {
armor.cursed = false;
armor.activate(owner);
}
if (misc1 != null) {
misc1.cursed = false;
misc1.activate(owner);
}
if (misc2 != null) {
misc2.cursed = false;
misc2.activate(owner);
}
}
Aggregations