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