use of com.shatteredpixel.shatteredpixeldungeon.items.Item in project shattered-pixel-dungeon-gdx by 00-Evan.
the class WarpingTrap method activate.
@Override
public void activate() {
CellEmitter.get(pos).start(Speck.factory(Speck.LIGHT), 0.2f, 3);
Sample.INSTANCE.play(Assets.SND_TELEPORT);
Char ch = Actor.findChar(pos);
if (ch instanceof Hero) {
ScrollOfTeleportation.teleportHero((Hero) ch);
BArray.setFalse(Dungeon.level.visited);
BArray.setFalse(Dungeon.level.mapped);
GameScene.updateFog();
Dungeon.observe();
} else if (ch != null) {
int count = 10;
int pos;
do {
pos = Dungeon.level.randomRespawnCell();
if (count-- <= 0) {
break;
}
} while (pos == -1);
if (pos == -1 || Dungeon.bossLevel()) {
GLog.w(Messages.get(ScrollOfTeleportation.class, "no_tele"));
} else {
ch.pos = pos;
if (ch instanceof Mob && ((Mob) ch).state == ((Mob) ch).HUNTING) {
((Mob) ch).state = ((Mob) ch).WANDERING;
}
ch.sprite.place(ch.pos);
ch.sprite.visible = Dungeon.level.heroFOV[pos];
}
}
Heap heap = Dungeon.level.heaps.get(pos);
if (heap != null) {
int cell = Dungeon.level.randomRespawnCell();
Item item = heap.pickUp();
if (cell != -1) {
Dungeon.level.drop(item, cell);
}
}
}
use of com.shatteredpixel.shatteredpixeldungeon.items.Item in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Plant method wither.
public void wither() {
Dungeon.level.uproot(pos);
if (Dungeon.level.heroFOV[pos]) {
CellEmitter.get(pos).burst(LeafParticle.GENERAL, 6);
}
if (Dungeon.hero.subClass == HeroSubClass.WARDEN) {
int naturalismLevel = 0;
SandalsOfNature.Naturalism naturalism = Dungeon.hero.buff(SandalsOfNature.Naturalism.class);
if (naturalism != null) {
naturalismLevel = naturalism.itemLevel() + 1;
}
if (Random.Int(5 - (naturalismLevel / 2)) == 0) {
Item seed = Generator.random(Generator.Category.SEED);
if (seed instanceof BlandfruitBush.Seed) {
if (Random.Int(3) - Dungeon.LimitedDrops.BLANDFRUIT_SEED.count >= 0) {
Dungeon.level.drop(seed, pos).sprite.drop();
Dungeon.LimitedDrops.BLANDFRUIT_SEED.count++;
}
} else
Dungeon.level.drop(seed, pos).sprite.drop();
}
if (Random.Int(5 - naturalismLevel) == 0) {
Dungeon.level.drop(new Dewdrop(), pos).sprite.drop();
}
}
}
use of com.shatteredpixel.shatteredpixeldungeon.items.Item in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Dungeon method loadGame.
public static void loadGame(int save, boolean fullLoad) throws IOException {
Bundle bundle = FileUtils.bundleFromFile(GamesInProgress.gameFile(save));
version = bundle.getInt(VERSION);
seed = bundle.contains(SEED) ? bundle.getLong(SEED) : DungeonSeed.randomSeed();
Actor.restoreNextID(bundle);
quickslot.reset();
QuickSlotButton.reset();
Dungeon.challenges = bundle.getInt(CHALLENGES);
Dungeon.level = null;
Dungeon.depth = -1;
Scroll.restore(bundle);
Potion.restore(bundle);
Ring.restore(bundle);
quickslot.restorePlaceholders(bundle);
if (fullLoad) {
// pre-0.6.1
if (bundle.contains("limiteddrops")) {
LimitedDrops.legacyRestore(bundle.getIntArray("limiteddrops"));
} else {
LimitedDrops.restore(bundle.getBundle(LIMDROPS));
}
chapters = new HashSet<Integer>();
int[] ids = bundle.getIntArray(CHAPTERS);
if (ids != null) {
for (int id : ids) {
chapters.add(id);
}
}
Bundle quests = bundle.getBundle(QUESTS);
if (!quests.isNull()) {
Ghost.Quest.restoreFromBundle(quests);
Wandmaker.Quest.restoreFromBundle(quests);
Blacksmith.Quest.restoreFromBundle(quests);
Imp.Quest.restoreFromBundle(quests);
} else {
Ghost.Quest.reset();
Wandmaker.Quest.reset();
Blacksmith.Quest.reset();
Imp.Quest.reset();
}
SpecialRoom.restoreRoomsFromBundle(bundle);
SecretRoom.restoreRoomsFromBundle(bundle);
}
Bundle badges = bundle.getBundle(BADGES);
if (!badges.isNull()) {
Badges.loadLocal(badges);
} else {
Badges.reset();
}
Notes.restoreFromBundle(bundle);
hero = null;
hero = (Hero) bundle.get(HERO);
WndAlchemy.restoreFromBundle(bundle, hero);
gold = bundle.getInt(GOLD);
depth = bundle.getInt(DEPTH);
Statistics.restoreFromBundle(bundle);
Generator.restoreFromBundle(bundle);
droppedItems = new SparseArray<>();
for (int i = 2; i <= Statistics.deepestFloor + 1; i++) {
ArrayList<Item> dropped = new ArrayList<Item>();
if (bundle.contains(Messages.format(DROPPED, i)))
for (Bundlable b : bundle.getCollection(Messages.format(DROPPED, i))) {
dropped.add((Item) b);
}
if (!dropped.isEmpty()) {
droppedItems.put(i, dropped);
}
}
}
use of com.shatteredpixel.shatteredpixeldungeon.items.Item in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Burning method act.
@Override
public boolean act() {
if (target.isAlive()) {
int damage = Random.NormalIntRange(1, 3 + target.HT / 40);
Buff.detach(target, Chill.class);
if (target instanceof Hero) {
Hero hero = (Hero) target;
if (hero.belongings.armor != null && hero.belongings.armor.hasGlyph(Brimstone.class)) {
Buff.affect(target, Brimstone.BrimstoneShield.class);
} else {
hero.damage(damage, this);
burnIncrement++;
// at 4+ turns, there is a (turns-3)/3 chance an item burns
if (Random.Int(3) < (burnIncrement - 3)) {
burnIncrement = 0;
ArrayList<Item> burnable = new ArrayList<>();
// does not reach inside of containers
for (Item i : hero.belongings.backpack.items) {
if ((i instanceof Scroll && !(i instanceof ScrollOfUpgrade || i instanceof ScrollOfMagicalInfusion)) || i instanceof MysteryMeat) {
burnable.add(i);
}
}
if (!burnable.isEmpty()) {
Item toBurn = Random.element(burnable).detach(hero.belongings.backpack);
if (toBurn instanceof MysteryMeat) {
ChargrilledMeat steak = new ChargrilledMeat();
if (!steak.collect(hero.belongings.backpack)) {
Dungeon.level.drop(steak, hero.pos).sprite.drop();
}
}
Heap.burnFX(hero.pos);
GLog.w(Messages.get(this, "burnsup", Messages.capitalize(toBurn.toString())));
}
}
}
} else {
target.damage(damage, this);
}
if (target instanceof Thief) {
Item item = ((Thief) target).item;
if (item instanceof Scroll && !(item instanceof ScrollOfUpgrade || item instanceof ScrollOfMagicalInfusion)) {
target.sprite.emitter().burst(ElmoParticle.FACTORY, 6);
((Thief) target).item = null;
} else if (item instanceof MysteryMeat) {
target.sprite.emitter().burst(ElmoParticle.FACTORY, 6);
((Thief) target).item = new ChargrilledMeat();
}
}
} else {
Brimstone.BrimstoneShield brimShield = target.buff(Brimstone.BrimstoneShield.class);
if (brimShield != null)
brimShield.startDecay();
detach();
}
if (Dungeon.level.flamable[target.pos] && Blob.volumeAt(target.pos, Fire.class) == 0) {
GameScene.add(Blob.seed(target.pos, 4, Fire.class));
}
spend(TICK);
left -= TICK;
if (left <= 0 || (Dungeon.level.water[target.pos] && !target.flying)) {
detach();
}
return true;
}
use of com.shatteredpixel.shatteredpixeldungeon.items.Item in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Frost method attachTo.
@Override
public boolean attachTo(Char target) {
if (super.attachTo(target)) {
target.paralysed++;
Buff.detach(target, Burning.class);
Buff.detach(target, Chill.class);
if (target instanceof Hero) {
Hero hero = (Hero) target;
ArrayList<Item> freezable = new ArrayList<>();
// does not reach inside of containers
for (Item i : hero.belongings.backpack.items) {
if ((i instanceof Potion && !(i instanceof PotionOfStrength || i instanceof PotionOfMight)) || i instanceof MysteryMeat) {
freezable.add(i);
}
}
if (!freezable.isEmpty()) {
Item toFreeze = Random.element(freezable).detach(hero.belongings.backpack);
if (toFreeze instanceof Potion) {
((Potion) toFreeze).shatter(hero.pos);
} else if (toFreeze instanceof MysteryMeat) {
FrozenCarpaccio carpaccio = new FrozenCarpaccio();
if (!carpaccio.collect(hero.belongings.backpack)) {
Dungeon.level.drop(carpaccio, target.pos).sprite.drop();
}
}
GLog.w(Messages.get(this, "freezes", toFreeze.toString()));
}
} else if (target instanceof Thief) {
Item item = ((Thief) target).item;
if (item instanceof Potion && !(item instanceof PotionOfStrength || item instanceof PotionOfMight)) {
((Potion) ((Thief) target).item).shatter(target.pos);
((Thief) target).item = null;
} else if (item instanceof MysteryMeat) {
((Thief) target).item = new FrozenCarpaccio();
;
}
}
return true;
} else {
return false;
}
}
Aggregations