Search in sources :

Example 1 with MirrorImage

use of com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.MirrorImage 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 2 with MirrorImage

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

the class ScrollOfMirrorImage method spawnImages.

// returns the number of images spawned
public static int spawnImages(Hero hero, int nImages) {
    ArrayList<Integer> respawnPoints = new ArrayList<Integer>();
    for (int i = 0; i < PathFinder.NEIGHBOURS8.length; i++) {
        int p = hero.pos + PathFinder.NEIGHBOURS8[i];
        if (Actor.findChar(p) == null && (Dungeon.level.passable[p] || Dungeon.level.avoid[p])) {
            respawnPoints.add(p);
        }
    }
    int spawned = 0;
    while (nImages > 0 && respawnPoints.size() > 0) {
        int index = Random.index(respawnPoints);
        MirrorImage mob = new MirrorImage();
        mob.duplicate(hero);
        GameScene.add(mob);
        ScrollOfTeleportation.appear(mob, respawnPoints.get(index));
        respawnPoints.remove(index);
        nImages--;
        spawned++;
    }
    return spawned;
}
Also used : MirrorImage(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.MirrorImage) ArrayList(java.util.ArrayList)

Aggregations

MirrorImage (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.MirrorImage)2 ArrayList (java.util.ArrayList)2 Hero (com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero)1 Mimic (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mimic)1 Mob (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob)1 Statue (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Statue)1 Thief (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Thief)1 Bundle (com.watabou.utils.Bundle)1