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;
}
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;
}
Aggregations