Search in sources :

Example 11 with Item

use of com.shatteredpixel.shatteredpixeldungeon.items.Item in project shattered-pixel-dungeon-gdx by 00-Evan.

the class WarpingTrap method activate.

@Override
public void activate() {
    CellEmitter.get(pos).start(Speck.factory(Speck.LIGHT), 0.2f, 3);
    Sample.INSTANCE.play(Assets.SND_TELEPORT);
    Char ch = Actor.findChar(pos);
    if (ch instanceof Hero) {
        ScrollOfTeleportation.teleportHero((Hero) ch);
        BArray.setFalse(Dungeon.level.visited);
        BArray.setFalse(Dungeon.level.mapped);
        GameScene.updateFog();
        Dungeon.observe();
    } else if (ch != null) {
        int count = 10;
        int pos;
        do {
            pos = Dungeon.level.randomRespawnCell();
            if (count-- <= 0) {
                break;
            }
        } while (pos == -1);
        if (pos == -1 || Dungeon.bossLevel()) {
            GLog.w(Messages.get(ScrollOfTeleportation.class, "no_tele"));
        } else {
            ch.pos = pos;
            if (ch instanceof Mob && ((Mob) ch).state == ((Mob) ch).HUNTING) {
                ((Mob) ch).state = ((Mob) ch).WANDERING;
            }
            ch.sprite.place(ch.pos);
            ch.sprite.visible = Dungeon.level.heroFOV[pos];
        }
    }
    Heap heap = Dungeon.level.heaps.get(pos);
    if (heap != null) {
        int cell = Dungeon.level.randomRespawnCell();
        Item item = heap.pickUp();
        if (cell != -1) {
            Dungeon.level.drop(item, cell);
        }
    }
}
Also used : Mob(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob) Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char) Hero(com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero) Heap(com.shatteredpixel.shatteredpixeldungeon.items.Heap)

Example 12 with Item

use of com.shatteredpixel.shatteredpixeldungeon.items.Item in project shattered-pixel-dungeon-gdx by 00-Evan.

the class Plant method wither.

public void wither() {
    Dungeon.level.uproot(pos);
    if (Dungeon.level.heroFOV[pos]) {
        CellEmitter.get(pos).burst(LeafParticle.GENERAL, 6);
    }
    if (Dungeon.hero.subClass == HeroSubClass.WARDEN) {
        int naturalismLevel = 0;
        SandalsOfNature.Naturalism naturalism = Dungeon.hero.buff(SandalsOfNature.Naturalism.class);
        if (naturalism != null) {
            naturalismLevel = naturalism.itemLevel() + 1;
        }
        if (Random.Int(5 - (naturalismLevel / 2)) == 0) {
            Item seed = Generator.random(Generator.Category.SEED);
            if (seed instanceof BlandfruitBush.Seed) {
                if (Random.Int(3) - Dungeon.LimitedDrops.BLANDFRUIT_SEED.count >= 0) {
                    Dungeon.level.drop(seed, pos).sprite.drop();
                    Dungeon.LimitedDrops.BLANDFRUIT_SEED.count++;
                }
            } else
                Dungeon.level.drop(seed, pos).sprite.drop();
        }
        if (Random.Int(5 - naturalismLevel) == 0) {
            Dungeon.level.drop(new Dewdrop(), pos).sprite.drop();
        }
    }
}
Also used : Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Dewdrop(com.shatteredpixel.shatteredpixeldungeon.items.Dewdrop) SandalsOfNature(com.shatteredpixel.shatteredpixeldungeon.items.artifacts.SandalsOfNature)

Example 13 with Item

use of com.shatteredpixel.shatteredpixeldungeon.items.Item in project shattered-pixel-dungeon-gdx by 00-Evan.

the class Dungeon method loadGame.

public static void loadGame(int save, boolean fullLoad) throws IOException {
    Bundle bundle = FileUtils.bundleFromFile(GamesInProgress.gameFile(save));
    version = bundle.getInt(VERSION);
    seed = bundle.contains(SEED) ? bundle.getLong(SEED) : DungeonSeed.randomSeed();
    Actor.restoreNextID(bundle);
    quickslot.reset();
    QuickSlotButton.reset();
    Dungeon.challenges = bundle.getInt(CHALLENGES);
    Dungeon.level = null;
    Dungeon.depth = -1;
    Scroll.restore(bundle);
    Potion.restore(bundle);
    Ring.restore(bundle);
    quickslot.restorePlaceholders(bundle);
    if (fullLoad) {
        // pre-0.6.1
        if (bundle.contains("limiteddrops")) {
            LimitedDrops.legacyRestore(bundle.getIntArray("limiteddrops"));
        } else {
            LimitedDrops.restore(bundle.getBundle(LIMDROPS));
        }
        chapters = new HashSet<Integer>();
        int[] ids = bundle.getIntArray(CHAPTERS);
        if (ids != null) {
            for (int id : ids) {
                chapters.add(id);
            }
        }
        Bundle quests = bundle.getBundle(QUESTS);
        if (!quests.isNull()) {
            Ghost.Quest.restoreFromBundle(quests);
            Wandmaker.Quest.restoreFromBundle(quests);
            Blacksmith.Quest.restoreFromBundle(quests);
            Imp.Quest.restoreFromBundle(quests);
        } else {
            Ghost.Quest.reset();
            Wandmaker.Quest.reset();
            Blacksmith.Quest.reset();
            Imp.Quest.reset();
        }
        SpecialRoom.restoreRoomsFromBundle(bundle);
        SecretRoom.restoreRoomsFromBundle(bundle);
    }
    Bundle badges = bundle.getBundle(BADGES);
    if (!badges.isNull()) {
        Badges.loadLocal(badges);
    } else {
        Badges.reset();
    }
    Notes.restoreFromBundle(bundle);
    hero = null;
    hero = (Hero) bundle.get(HERO);
    WndAlchemy.restoreFromBundle(bundle, hero);
    gold = bundle.getInt(GOLD);
    depth = bundle.getInt(DEPTH);
    Statistics.restoreFromBundle(bundle);
    Generator.restoreFromBundle(bundle);
    droppedItems = new SparseArray<>();
    for (int i = 2; i <= Statistics.deepestFloor + 1; i++) {
        ArrayList<Item> dropped = new ArrayList<Item>();
        if (bundle.contains(Messages.format(DROPPED, i)))
            for (Bundlable b : bundle.getCollection(Messages.format(DROPPED, i))) {
                dropped.add((Item) b);
            }
        if (!dropped.isEmpty()) {
            droppedItems.put(i, dropped);
        }
    }
}
Also used : Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Bundlable(com.watabou.utils.Bundlable) Bundle(com.watabou.utils.Bundle) ArrayList(java.util.ArrayList)

Example 14 with Item

use of com.shatteredpixel.shatteredpixeldungeon.items.Item in project shattered-pixel-dungeon-gdx by 00-Evan.

the class Burning method act.

@Override
public boolean act() {
    if (target.isAlive()) {
        int damage = Random.NormalIntRange(1, 3 + target.HT / 40);
        Buff.detach(target, Chill.class);
        if (target instanceof Hero) {
            Hero hero = (Hero) target;
            if (hero.belongings.armor != null && hero.belongings.armor.hasGlyph(Brimstone.class)) {
                Buff.affect(target, Brimstone.BrimstoneShield.class);
            } else {
                hero.damage(damage, this);
                burnIncrement++;
                // at 4+ turns, there is a (turns-3)/3 chance an item burns
                if (Random.Int(3) < (burnIncrement - 3)) {
                    burnIncrement = 0;
                    ArrayList<Item> burnable = new ArrayList<>();
                    // does not reach inside of containers
                    for (Item i : hero.belongings.backpack.items) {
                        if ((i instanceof Scroll && !(i instanceof ScrollOfUpgrade || i instanceof ScrollOfMagicalInfusion)) || i instanceof MysteryMeat) {
                            burnable.add(i);
                        }
                    }
                    if (!burnable.isEmpty()) {
                        Item toBurn = Random.element(burnable).detach(hero.belongings.backpack);
                        if (toBurn instanceof MysteryMeat) {
                            ChargrilledMeat steak = new ChargrilledMeat();
                            if (!steak.collect(hero.belongings.backpack)) {
                                Dungeon.level.drop(steak, hero.pos).sprite.drop();
                            }
                        }
                        Heap.burnFX(hero.pos);
                        GLog.w(Messages.get(this, "burnsup", Messages.capitalize(toBurn.toString())));
                    }
                }
            }
        } else {
            target.damage(damage, this);
        }
        if (target instanceof Thief) {
            Item item = ((Thief) target).item;
            if (item instanceof Scroll && !(item instanceof ScrollOfUpgrade || item instanceof ScrollOfMagicalInfusion)) {
                target.sprite.emitter().burst(ElmoParticle.FACTORY, 6);
                ((Thief) target).item = null;
            } else if (item instanceof MysteryMeat) {
                target.sprite.emitter().burst(ElmoParticle.FACTORY, 6);
                ((Thief) target).item = new ChargrilledMeat();
            }
        }
    } else {
        Brimstone.BrimstoneShield brimShield = target.buff(Brimstone.BrimstoneShield.class);
        if (brimShield != null)
            brimShield.startDecay();
        detach();
    }
    if (Dungeon.level.flamable[target.pos] && Blob.volumeAt(target.pos, Fire.class) == 0) {
        GameScene.add(Blob.seed(target.pos, 4, Fire.class));
    }
    spend(TICK);
    left -= TICK;
    if (left <= 0 || (Dungeon.level.water[target.pos] && !target.flying)) {
        detach();
    }
    return true;
}
Also used : ChargrilledMeat(com.shatteredpixel.shatteredpixeldungeon.items.food.ChargrilledMeat) Thief(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Thief) Scroll(com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll) ArrayList(java.util.ArrayList) Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Brimstone(com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.Brimstone) Fire(com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Fire) Hero(com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero) ScrollOfMagicalInfusion(com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfMagicalInfusion) MysteryMeat(com.shatteredpixel.shatteredpixeldungeon.items.food.MysteryMeat) ScrollOfUpgrade(com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfUpgrade)

Example 15 with Item

use of com.shatteredpixel.shatteredpixeldungeon.items.Item in project shattered-pixel-dungeon-gdx by 00-Evan.

the class Frost method attachTo.

@Override
public boolean attachTo(Char target) {
    if (super.attachTo(target)) {
        target.paralysed++;
        Buff.detach(target, Burning.class);
        Buff.detach(target, Chill.class);
        if (target instanceof Hero) {
            Hero hero = (Hero) target;
            ArrayList<Item> freezable = new ArrayList<>();
            // does not reach inside of containers
            for (Item i : hero.belongings.backpack.items) {
                if ((i instanceof Potion && !(i instanceof PotionOfStrength || i instanceof PotionOfMight)) || i instanceof MysteryMeat) {
                    freezable.add(i);
                }
            }
            if (!freezable.isEmpty()) {
                Item toFreeze = Random.element(freezable).detach(hero.belongings.backpack);
                if (toFreeze instanceof Potion) {
                    ((Potion) toFreeze).shatter(hero.pos);
                } else if (toFreeze instanceof MysteryMeat) {
                    FrozenCarpaccio carpaccio = new FrozenCarpaccio();
                    if (!carpaccio.collect(hero.belongings.backpack)) {
                        Dungeon.level.drop(carpaccio, target.pos).sprite.drop();
                    }
                }
                GLog.w(Messages.get(this, "freezes", toFreeze.toString()));
            }
        } else if (target instanceof Thief) {
            Item item = ((Thief) target).item;
            if (item instanceof Potion && !(item instanceof PotionOfStrength || item instanceof PotionOfMight)) {
                ((Potion) ((Thief) target).item).shatter(target.pos);
                ((Thief) target).item = null;
            } else if (item instanceof MysteryMeat) {
                ((Thief) target).item = new FrozenCarpaccio();
                ;
            }
        }
        return true;
    } else {
        return false;
    }
}
Also used : Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) FrozenCarpaccio(com.shatteredpixel.shatteredpixeldungeon.items.food.FrozenCarpaccio) PotionOfMight(com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfMight) Potion(com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion) PotionOfStrength(com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfStrength) Thief(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Thief) Hero(com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero) ArrayList(java.util.ArrayList) MysteryMeat(com.shatteredpixel.shatteredpixeldungeon.items.food.MysteryMeat)

Aggregations

Item (com.shatteredpixel.shatteredpixeldungeon.items.Item)67 Heap (com.shatteredpixel.shatteredpixeldungeon.items.Heap)14 ArrayList (java.util.ArrayList)14 Hero (com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero)9 Char (com.shatteredpixel.shatteredpixeldungeon.actors.Char)7 Mob (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob)7 Gold (com.shatteredpixel.shatteredpixeldungeon.items.Gold)7 Point (com.watabou.utils.Point)7 IronKey (com.shatteredpixel.shatteredpixeldungeon.items.keys.IronKey)6 EquipableItem (com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem)5 Flare (com.shatteredpixel.shatteredpixeldungeon.effects.Flare)4 Honeypot (com.shatteredpixel.shatteredpixeldungeon.items.Honeypot)4 WndTradeItem (com.shatteredpixel.shatteredpixeldungeon.windows.WndTradeItem)4 Dewdrop (com.shatteredpixel.shatteredpixeldungeon.items.Dewdrop)3 Armor (com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor)3 Potion (com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion)3 Fire (com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Fire)2 Belongings (com.shatteredpixel.shatteredpixeldungeon.actors.hero.Belongings)2 Thief (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Thief)2 Ankh (com.shatteredpixel.shatteredpixeldungeon.items.Ankh)2