Search in sources :

Example 1 with Mimic

use of com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mimic in project shattered-pixel-dungeon-gdx by 00-Evan.

the class Heap method freeze.

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;
    }
    boolean frozen = false;
    for (Item item : items.toArray(new Item[0])) {
        if (item instanceof MysteryMeat) {
            replace(item, FrozenCarpaccio.cook((MysteryMeat) item));
            frozen = true;
        } else if (item instanceof Potion && !(item instanceof PotionOfStrength || item instanceof PotionOfMight)) {
            items.remove(item);
            ((Potion) item).shatter(pos);
            frozen = true;
        } else if (item instanceof Bomb) {
            ((Bomb) item).fuse = null;
            frozen = true;
        }
    }
    if (frozen) {
        if (isEmpty()) {
            destroy();
        } else if (sprite != null) {
            sprite.view(items.peek());
        }
    }
}
Also used : PotionOfMight(com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfMight) Mimic(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mimic) Potion(com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion) PotionOfStrength(com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfStrength) MysteryMeat(com.shatteredpixel.shatteredpixeldungeon.items.food.MysteryMeat)

Example 2 with Mimic

use of com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mimic in project shattered-pixel-dungeon-gdx by 00-Evan.

the class Multiplicity method proc.

@Override
public int proc(Armor armor, Char attacker, Char defender, int damage) {
    if (Random.Int(20) == 0) {
        ArrayList<Integer> spawnPoints = new ArrayList<>();
        for (int i = 0; i < PathFinder.NEIGHBOURS8.length; i++) {
            int p = defender.pos + PathFinder.NEIGHBOURS8[i];
            if (Actor.findChar(p) == null && (Dungeon.level.passable[p] || Dungeon.level.avoid[p])) {
                spawnPoints.add(p);
            }
        }
        if (spawnPoints.size() > 0) {
            Mob m = null;
            if (Random.Int(2) == 0 && defender instanceof Hero) {
                m = new MirrorImage();
                ((MirrorImage) m).duplicate((Hero) defender);
            } else {
                // FIXME should probably have a mob property for this
                if (attacker.properties().contains(Char.Property.BOSS) || attacker.properties().contains(Char.Property.MINIBOSS) || attacker instanceof Mimic || attacker instanceof Statue) {
                    m = Dungeon.level.createMob();
                } else {
                    try {
                        Actor.fixTime();
                        m = (Mob) attacker.getClass().newInstance();
                        Bundle store = new Bundle();
                        attacker.storeInBundle(store);
                        m.restoreFromBundle(store);
                        m.HP = m.HT;
                        // If a thief has stolen an item, that item is not duplicated.
                        if (m instanceof Thief) {
                            ((Thief) m).item = null;
                        }
                    } catch (Exception e) {
                        ShatteredPixelDungeon.reportException(e);
                        m = null;
                    }
                }
            }
            if (m != null) {
                GameScene.add(m);
                ScrollOfTeleportation.appear(m, Random.element(spawnPoints));
            }
        }
    }
    return damage;
}
Also used : MirrorImage(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.MirrorImage) Mob(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob) Mimic(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mimic) Statue(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Statue) Bundle(com.watabou.utils.Bundle) Thief(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Thief) ArrayList(java.util.ArrayList) Hero(com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero)

Example 3 with Mimic

use of com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mimic in project shattered-pixel-dungeon-gdx by 00-Evan.

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 && !(item instanceof ScrollOfUpgrade || item instanceof ScrollOfMagicalInfusion)) {
            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;
        } else if (item instanceof Bomb) {
            items.remove(item);
            ((Bomb) item).explode(pos);
            // stop processing the burning, it will be replaced by the explosion.
            return;
        }
    }
    if (burnt || evaporated) {
        if (Dungeon.level.heroFOV[pos]) {
            if (burnt) {
                burnFX(pos);
            } else {
                evaporateFX(pos);
            }
        }
        if (isEmpty()) {
            destroy();
        } else if (sprite != null) {
            sprite.view(items.peek());
        }
    }
}
Also used : Mimic(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mimic) Scroll(com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll) ScrollOfMagicalInfusion(com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfMagicalInfusion) MysteryMeat(com.shatteredpixel.shatteredpixeldungeon.items.food.MysteryMeat) ScrollOfUpgrade(com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfUpgrade) Burning(com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Burning)

Example 4 with Mimic

use of com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mimic in project shattered-pixel-dungeon-gdx by 00-Evan.

the class ScrollOfRage method doRead.

@Override
public void doRead() {
    for (Mob mob : Dungeon.level.mobs.toArray(new Mob[0])) {
        mob.beckon(curUser.pos);
        if (Dungeon.level.heroFOV[mob.pos]) {
            Buff.prolong(mob, Amok.class, 5f);
        }
    }
    for (Heap heap : Dungeon.level.heaps.values()) {
        if (heap.type == Heap.Type.MIMIC) {
            Mimic m = Mimic.spawnAt(heap.pos, heap.items);
            if (m != null) {
                m.beckon(curUser.pos);
                heap.destroy();
            }
        }
    }
    GLog.w(Messages.get(this, "roar"));
    setKnown();
    curUser.sprite.centerEmitter().start(Speck.factory(Speck.SCREAM), 0.3f, 3);
    Sample.INSTANCE.play(Assets.SND_CHALLENGE);
    Invisibility.dispel();
    readAnimation();
}
Also used : Mob(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob) Mimic(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mimic) Heap(com.shatteredpixel.shatteredpixeldungeon.items.Heap)

Example 5 with Mimic

use of com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mimic in project shattered-pixel-dungeon-gdx by 00-Evan.

the class CursedWand method veryRareEffect.

private static void veryRareEffect(final Wand wand, final Hero user, final Ballistica bolt) {
    switch(Random.Int(4)) {
        // great forest fire!
        case 0:
            for (int i = 0; i < Dungeon.level.length(); i++) {
                int c = Dungeon.level.map[i];
                if (c == Terrain.EMPTY || c == Terrain.EMBERS || c == Terrain.EMPTY_DECO || c == Terrain.GRASS || c == Terrain.HIGH_GRASS) {
                    GameScene.add(Blob.seed(i, 15, Regrowth.class));
                }
            }
            do {
                GameScene.add(Blob.seed(Dungeon.level.randomDestination(), 10, Fire.class));
            } while (Random.Int(5) != 0);
            new Flare(8, 32).color(0xFFFF66, true).show(user.sprite, 2f);
            Sample.INSTANCE.play(Assets.SND_TELEPORT);
            GLog.p(Messages.get(CursedWand.class, "grass"));
            GLog.w(Messages.get(CursedWand.class, "fire"));
            wand.wandUsed();
            break;
        // superpowered mimic
        case 1:
            cursedFX(user, bolt, new Callback() {

                public void call() {
                    Mimic mimic = Mimic.spawnAt(bolt.collisionPos, new ArrayList<Item>());
                    if (mimic != null) {
                        mimic.adjustStats(Dungeon.depth + 10);
                        mimic.HP = mimic.HT;
                        Item reward;
                        do {
                            reward = Generator.random(Random.oneOf(Generator.Category.WEAPON, Generator.Category.ARMOR, Generator.Category.RING, Generator.Category.WAND));
                        } while (reward.level() < 1);
                        Sample.INSTANCE.play(Assets.SND_MIMIC, 1, 1, 0.5f);
                        mimic.items.clear();
                        mimic.items.add(reward);
                    } else {
                        GLog.i(Messages.get(CursedWand.class, "nothing"));
                    }
                    wand.wandUsed();
                }
            });
            break;
        // crashes the game, yes, really.
        case 2:
            try {
                Dungeon.saveAll();
                if (Messages.lang() != Languages.ENGLISH) {
                    // Don't bother doing this joke to none-english speakers, I doubt it would translate.
                    GLog.i(Messages.get(CursedWand.class, "nothing"));
                    wand.wandUsed();
                } else {
                    GameScene.show(new WndOptions("CURSED WAND ERROR", "this application will now self-destruct", "abort", "retry", "fail") {

                        @Override
                        protected void onSelect(int index) {
                            Game.instance.finish();
                        }

                        @Override
                        public void onBackPressed() {
                        // do nothing
                        }
                    });
                }
            } catch (IOException e) {
                ShatteredPixelDungeon.reportException(e);
                // oookay maybe don't kill the game if the save failed.
                GLog.i(Messages.get(CursedWand.class, "nothing"));
                wand.wandUsed();
            }
            break;
        // random transmogrification
        case 3:
            wand.wandUsed();
            wand.detach(user.belongings.backpack);
            Item result;
            do {
                result = Generator.random(Random.oneOf(Generator.Category.WEAPON, Generator.Category.ARMOR, Generator.Category.RING, Generator.Category.ARTIFACT));
            } while (result.cursed);
            if (result.isUpgradable())
                result.upgrade();
            result.cursed = result.cursedKnown = true;
            GLog.w(Messages.get(CursedWand.class, "transmogrify"));
            Dungeon.level.drop(result, user.pos).sprite.drop();
            wand.wandUsed();
            break;
    }
}
Also used : WndOptions(com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions) Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Flare(com.shatteredpixel.shatteredpixeldungeon.effects.Flare) Callback(com.watabou.utils.Callback) Mimic(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mimic) Fire(com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Fire) ArrayList(java.util.ArrayList) Regrowth(com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Regrowth) IOException(java.io.IOException)

Aggregations

Mimic (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mimic)6 Mob (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob)3 Statue (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Statue)2 MysteryMeat (com.shatteredpixel.shatteredpixeldungeon.items.food.MysteryMeat)2 ArrayList (java.util.ArrayList)2 Char (com.shatteredpixel.shatteredpixeldungeon.actors.Char)1 Fire (com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Fire)1 Regrowth (com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Regrowth)1 Buff (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff)1 Burning (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Burning)1 FlavourBuff (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.FlavourBuff)1 Hero (com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero)1 Bee (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Bee)1 King (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.King)1 Piranha (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Piranha)1 Swarm (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Swarm)1 Thief (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Thief)1 Wraith (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Wraith)1 Yog (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Yog)1 MirrorImage (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.MirrorImage)1