Search in sources :

Example 1 with Scroll

use of com.watabou.pixeldungeon.items.scrolls.Scroll in project pixel-dungeon by watabou.

the class Level method drop.

public Heap drop(Item item, int cell) {
    if (Dungeon.isChallenged(Challenges.NO_FOOD) && item instanceof Food) {
        item = new Gold(item.price());
    } else if (Dungeon.isChallenged(Challenges.NO_ARMOR) && item instanceof Armor) {
        item = new Gold(item.price());
    } else if (Dungeon.isChallenged(Challenges.NO_HEALING) && item instanceof PotionOfHealing) {
        item = new Gold(item.price());
    } else if (Dungeon.isChallenged(Challenges.NO_HERBALISM) && item instanceof SeedPouch) {
        item = new Gold(item.price());
    } else if (Dungeon.isChallenged(Challenges.NO_SCROLLS) && (item instanceof Scroll || item instanceof ScrollHolder)) {
        if (item instanceof ScrollOfUpgrade) {
        // These scrolls still can be found
        } else {
            item = new Gold(item.price());
        }
    }
    if ((map[cell] == Terrain.ALCHEMY) && !(item instanceof Plant.Seed)) {
        int n;
        do {
            n = cell + NEIGHBOURS8[Random.Int(8)];
        } while (map[n] != Terrain.EMPTY_SP);
        cell = n;
    }
    Heap heap = heaps.get(cell);
    if (heap == null) {
        heap = new Heap();
        heap.pos = cell;
        if (map[cell] == Terrain.CHASM || (Dungeon.level != null && pit[cell])) {
            Dungeon.dropToChasm(item);
            GameScene.discard(heap);
        } else {
            heaps.put(cell, heap);
            GameScene.add(heap);
        }
    } else if (heap.type == Heap.Type.LOCKED_CHEST || heap.type == Heap.Type.CRYSTAL_CHEST) {
        int n;
        do {
            n = cell + Level.NEIGHBOURS8[Random.Int(8)];
        } while (!Level.passable[n] && !Level.avoid[n]);
        return drop(item, n);
    }
    heap.drop(item);
    if (Dungeon.level != null) {
        press(cell, null);
    }
    return heap;
}
Also used : Gold(com.watabou.pixeldungeon.items.Gold) Plant(com.watabou.pixeldungeon.plants.Plant) Armor(com.watabou.pixeldungeon.items.armor.Armor) SeedPouch(com.watabou.pixeldungeon.items.bags.SeedPouch) Scroll(com.watabou.pixeldungeon.items.scrolls.Scroll) PotionOfHealing(com.watabou.pixeldungeon.items.potions.PotionOfHealing) ScrollHolder(com.watabou.pixeldungeon.items.bags.ScrollHolder) ScrollOfUpgrade(com.watabou.pixeldungeon.items.scrolls.ScrollOfUpgrade) Heap(com.watabou.pixeldungeon.items.Heap) Food(com.watabou.pixeldungeon.items.food.Food)

Example 2 with Scroll

use of com.watabou.pixeldungeon.items.scrolls.Scroll in project pixel-dungeon by watabou.

the class Burning method act.

@Override
public boolean act() {
    if (target.isAlive()) {
        if (target instanceof Hero) {
            Buff.prolong(target, Light.class, TICK * 1.01f);
        }
        target.damage(Random.Int(1, 5), this);
        if (target instanceof Hero) {
            Item item = ((Hero) target).belongings.randomUnequipped();
            if (item instanceof Scroll) {
                item = item.detach(((Hero) target).belongings.backpack);
                GLog.w(TXT_BURNS_UP, item.toString());
                Heap.burnFX(target.pos);
            } else if (item instanceof MysteryMeat) {
                item = item.detach(((Hero) target).belongings.backpack);
                ChargrilledMeat steak = new ChargrilledMeat();
                if (!steak.collect(((Hero) target).belongings.backpack)) {
                    Dungeon.level.drop(steak, target.pos).sprite.drop();
                }
                GLog.w(TXT_BURNS_UP, item.toString());
                Heap.burnFX(target.pos);
            }
        } else if (target instanceof Thief && ((Thief) target).item instanceof Scroll) {
            ((Thief) target).item = null;
            target.sprite.emitter().burst(ElmoParticle.FACTORY, 6);
        }
    } else {
        detach();
    }
    if (Level.flamable[target.pos]) {
        GameScene.add(Blob.seed(target.pos, 4, Fire.class));
    }
    spend(TICK);
    left -= TICK;
    if (left <= 0 || Random.Float() > (2 + (float) target.HP / target.HT) / 3 || (Level.water[target.pos] && !target.flying)) {
        detach();
    }
    return true;
}
Also used : Item(com.watabou.pixeldungeon.items.Item) ChargrilledMeat(com.watabou.pixeldungeon.items.food.ChargrilledMeat) Thief(com.watabou.pixeldungeon.actors.mobs.Thief) Scroll(com.watabou.pixeldungeon.items.scrolls.Scroll) Fire(com.watabou.pixeldungeon.actors.blobs.Fire) Hero(com.watabou.pixeldungeon.actors.hero.Hero) MysteryMeat(com.watabou.pixeldungeon.items.food.MysteryMeat)

Example 3 with Scroll

use of com.watabou.pixeldungeon.items.scrolls.Scroll in project pixel-dungeon by watabou.

the class Heap method burn.

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;
    }
    boolean burnt = false;
    boolean evaporated = false;
    for (Item item : items.toArray(new Item[0])) {
        if (item instanceof Scroll) {
            items.remove(item);
            burnt = true;
        } else if (item instanceof Dewdrop) {
            items.remove(item);
            evaporated = true;
        } else if (item instanceof MysteryMeat) {
            replace(item, ChargrilledMeat.cook((MysteryMeat) item));
            burnt = true;
        }
    }
    if (burnt || evaporated) {
        if (Dungeon.visible[pos]) {
            if (burnt) {
                burnFX(pos);
            } else {
                evaporateFX(pos);
            }
        }
        if (isEmpty()) {
            destroy();
        } else if (sprite != null) {
            sprite.view(image(), glowing());
        }
    }
}
Also used : Mimic(com.watabou.pixeldungeon.actors.mobs.Mimic) Scroll(com.watabou.pixeldungeon.items.scrolls.Scroll) MysteryMeat(com.watabou.pixeldungeon.items.food.MysteryMeat) Burning(com.watabou.pixeldungeon.actors.buffs.Burning)

Aggregations

Scroll (com.watabou.pixeldungeon.items.scrolls.Scroll)3 MysteryMeat (com.watabou.pixeldungeon.items.food.MysteryMeat)2 Fire (com.watabou.pixeldungeon.actors.blobs.Fire)1 Burning (com.watabou.pixeldungeon.actors.buffs.Burning)1 Hero (com.watabou.pixeldungeon.actors.hero.Hero)1 Mimic (com.watabou.pixeldungeon.actors.mobs.Mimic)1 Thief (com.watabou.pixeldungeon.actors.mobs.Thief)1 Gold (com.watabou.pixeldungeon.items.Gold)1 Heap (com.watabou.pixeldungeon.items.Heap)1 Item (com.watabou.pixeldungeon.items.Item)1 Armor (com.watabou.pixeldungeon.items.armor.Armor)1 ScrollHolder (com.watabou.pixeldungeon.items.bags.ScrollHolder)1 SeedPouch (com.watabou.pixeldungeon.items.bags.SeedPouch)1 ChargrilledMeat (com.watabou.pixeldungeon.items.food.ChargrilledMeat)1 Food (com.watabou.pixeldungeon.items.food.Food)1 PotionOfHealing (com.watabou.pixeldungeon.items.potions.PotionOfHealing)1 ScrollOfUpgrade (com.watabou.pixeldungeon.items.scrolls.ScrollOfUpgrade)1 Plant (com.watabou.pixeldungeon.plants.Plant)1