Search in sources :

Example 41 with Item

use of com.shatteredpixel.shatteredpixeldungeon.items.Item in project shattered-pixel-dungeon-gdx by 00-Evan.

the class LibraryRoom method paint.

public void paint(Level level) {
    Painter.fill(level, this, Terrain.WALL);
    Painter.fill(level, this, 1, Terrain.EMPTY_SP);
    Door entrance = entrance();
    Painter.fill(level, left + 1, top + 1, width() - 2, 1, Terrain.BOOKSHELF);
    Painter.drawInside(level, this, entrance, 1, Terrain.EMPTY_SP);
    int n = Random.IntRange(2, 3);
    for (int i = 0; i < n; i++) {
        int pos;
        do {
            pos = level.pointToCell(random());
        } while (level.map[pos] != Terrain.EMPTY_SP || level.heaps.get(pos) != null);
        Item item;
        if (i == 0)
            item = Random.Int(2) == 0 ? new ScrollOfIdentify() : new ScrollOfRemoveCurse();
        else
            item = prize(level);
        level.drop(item, pos);
    }
    entrance.set(Door.Type.LOCKED);
    level.addItemToSpawn(new IronKey(Dungeon.depth));
}
Also used : Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) ScrollOfIdentify(com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfIdentify) IronKey(com.shatteredpixel.shatteredpixeldungeon.items.keys.IronKey) ScrollOfRemoveCurse(com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfRemoveCurse)

Example 42 with Item

use of com.shatteredpixel.shatteredpixeldungeon.items.Item in project shattered-pixel-dungeon-gdx by 00-Evan.

the class ShopRoom method ChooseBag.

protected static Bag ChooseBag(Belongings pack) {
    // 0=pouch, 1=holder, 2=bandolier, 3=holster
    int[] bagItems = new int[4];
    // count up items in the main bag
    for (Item item : pack.backpack.items) {
        if (item instanceof Plant.Seed || item instanceof Runestone)
            bagItems[0]++;
        if (item instanceof Scroll)
            bagItems[1]++;
        if (item instanceof Potion)
            bagItems[2]++;
        if (item instanceof Wand || item instanceof MissileWeapon)
            bagItems[3]++;
    }
    // disqualify bags that have already been dropped
    if (Dungeon.LimitedDrops.VELVET_POUCH.dropped())
        bagItems[0] = -1;
    if (Dungeon.LimitedDrops.SCROLL_HOLDER.dropped())
        bagItems[1] = -1;
    if (Dungeon.LimitedDrops.POTION_BANDOLIER.dropped())
        bagItems[2] = -1;
    if (Dungeon.LimitedDrops.MAGICAL_HOLSTER.dropped())
        bagItems[3] = -1;
    // find the best bag to drop. This does give a preference to later bags, if counts are equal
    int bestBagIdx = 0;
    for (int i = 1; i <= 3; i++) {
        if (bagItems[bestBagIdx] <= bagItems[i]) {
            bestBagIdx = i;
        }
    }
    // drop it, or return nothing if no bag works
    if (bagItems[bestBagIdx] == -1)
        return null;
    switch(bestBagIdx) {
        case 0:
        default:
            Dungeon.LimitedDrops.VELVET_POUCH.drop();
            return new VelvetPouch();
        case 1:
            Dungeon.LimitedDrops.SCROLL_HOLDER.drop();
            return new ScrollHolder();
        case 2:
            Dungeon.LimitedDrops.POTION_BANDOLIER.drop();
            return new PotionBandolier();
        case 3:
            Dungeon.LimitedDrops.MAGICAL_HOLSTER.drop();
            return new MagicalHolster();
    }
}
Also used : Potion(com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion) Scroll(com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll) Wand(com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand) VelvetPouch(com.shatteredpixel.shatteredpixeldungeon.items.bags.VelvetPouch) ScrollHolder(com.shatteredpixel.shatteredpixeldungeon.items.bags.ScrollHolder) Runestone(com.shatteredpixel.shatteredpixeldungeon.items.stones.Runestone) Point(com.watabou.utils.Point) Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Plant(com.shatteredpixel.shatteredpixeldungeon.plants.Plant) MagicalHolster(com.shatteredpixel.shatteredpixeldungeon.items.bags.MagicalHolster) PotionBandolier(com.shatteredpixel.shatteredpixeldungeon.items.bags.PotionBandolier) MissileWeapon(com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.MissileWeapon)

Example 43 with Item

use of com.shatteredpixel.shatteredpixeldungeon.items.Item in project shattered-pixel-dungeon-gdx by 00-Evan.

the class SecretHoardRoom method paint.

@Override
public void paint(Level level) {
    super.paint(level);
    Painter.fill(level, this, Terrain.WALL);
    Painter.fill(level, this, 1, Terrain.EMPTY);
    Class<? extends Trap> trapClass;
    if (Random.Int(2) == 0) {
        trapClass = RockfallTrap.class;
    } else if (Dungeon.depth >= 10) {
        trapClass = DisintegrationTrap.class;
    } else {
        trapClass = PoisonDartTrap.class;
    }
    int goldPos;
    // half of the internal space of the room
    int totalGold = ((width() - 2) * (height() - 2)) / 2;
    // no matter how much gold it drops, roughly equals 8 gold stacks.
    float goldRatio = 8 / (float) totalGold;
    for (int i = 0; i < totalGold; i++) {
        do {
            goldPos = level.pointToCell(random());
        } while (level.heaps.get(goldPos) != null);
        Item gold = new Gold().random();
        gold.quantity(Math.round(gold.quantity() * goldRatio));
        level.drop(gold, goldPos);
    }
    for (Point p : getPoints()) {
        if (Random.Int(2) == 0 && level.map[level.pointToCell(p)] == Terrain.EMPTY) {
            try {
                level.setTrap(trapClass.newInstance().reveal(), level.pointToCell(p));
                Painter.set(level, p, Terrain.TRAP);
            } catch (Exception e) {
                ShatteredPixelDungeon.reportException(e);
            }
        }
    }
    entrance().set(Door.Type.HIDDEN);
}
Also used : Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Gold(com.shatteredpixel.shatteredpixeldungeon.items.Gold) DisintegrationTrap(com.shatteredpixel.shatteredpixeldungeon.levels.traps.DisintegrationTrap) PoisonDartTrap(com.shatteredpixel.shatteredpixeldungeon.levels.traps.PoisonDartTrap) Point(com.watabou.utils.Point) Point(com.watabou.utils.Point)

Example 44 with Item

use of com.shatteredpixel.shatteredpixeldungeon.items.Item in project shattered-pixel-dungeon-gdx by 00-Evan.

the class SecretMazeRoom method paint.

@Override
public void paint(Level level) {
    super.paint(level);
    Painter.fill(level, this, Terrain.WALL);
    Painter.fill(level, this, 1, Terrain.EMPTY);
    // true = space, false = wall
    boolean[][] maze = Maze.generate(this);
    boolean[] passable = new boolean[width() * height()];
    Painter.fill(level, this, 1, Terrain.EMPTY);
    for (int x = 0; x < maze.length; x++) {
        for (int y = 0; y < maze[0].length; y++) {
            if (maze[x][y] == Maze.FILLED) {
                Painter.fill(level, x + left, y + top, 1, 1, Terrain.WALL);
            }
            passable[x + width() * y] = maze[x][y] == Maze.EMPTY;
        }
    }
    PathFinder.setMapSize(width(), height());
    Point entrance = entrance();
    int entrancePos = (entrance.x - left) + width() * (entrance.y - top);
    PathFinder.buildDistanceMap(entrancePos, passable);
    int bestDist = 0;
    Point bestDistP = new Point();
    for (int i = 0; i < PathFinder.distance.length; i++) {
        if (PathFinder.distance[i] != Integer.MAX_VALUE && PathFinder.distance[i] > bestDist) {
            bestDist = PathFinder.distance[i];
            bestDistP.x = (i % width()) + left;
            bestDistP.y = (i / width()) + top;
        }
    }
    Item prize;
    // 1 floor set higher in probability, never cursed
    do {
        if (Random.Int(2) == 0) {
            prize = Generator.randomWeapon((Dungeon.depth / 5) + 1);
        } else {
            prize = Generator.randomArmor((Dungeon.depth / 5) + 1);
        }
    } while (prize.cursed || Challenges.isItemBlocked(prize));
    // 33% chance for an extra update.
    if (Random.Int(3) == 0) {
        prize.upgrade();
    }
    level.drop(prize, level.pointToCell(bestDistP)).type = Heap.Type.CHEST;
    PathFinder.setMapSize(level.width(), level.height());
    entrance().set(Door.Type.HIDDEN);
}
Also used : Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Point(com.watabou.utils.Point) Point(com.watabou.utils.Point)

Example 45 with Item

use of com.shatteredpixel.shatteredpixeldungeon.items.Item in project shattered-pixel-dungeon-gdx by 00-Evan.

the class SuspiciousChestRoom method paint.

@Override
public void paint(Level level) {
    super.paint(level);
    Item i = level.findPrizeItem();
    if (i == null) {
        i = new Gold().random();
    }
    int center = level.pointToCell(center());
    Painter.set(level, center, Terrain.PEDESTAL);
    if (Random.Int(3) == 0) {
        level.drop(i, center).type = Heap.Type.MIMIC;
    } else {
        level.drop(i, center).type = Heap.Type.CHEST;
    }
}
Also used : Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Gold(com.shatteredpixel.shatteredpixeldungeon.items.Gold)

Aggregations

Item (com.shatteredpixel.shatteredpixeldungeon.items.Item)67 Heap (com.shatteredpixel.shatteredpixeldungeon.items.Heap)14 ArrayList (java.util.ArrayList)14 Hero (com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero)9 Char (com.shatteredpixel.shatteredpixeldungeon.actors.Char)7 Mob (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob)7 Gold (com.shatteredpixel.shatteredpixeldungeon.items.Gold)7 Point (com.watabou.utils.Point)7 IronKey (com.shatteredpixel.shatteredpixeldungeon.items.keys.IronKey)6 EquipableItem (com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem)5 Flare (com.shatteredpixel.shatteredpixeldungeon.effects.Flare)4 Honeypot (com.shatteredpixel.shatteredpixeldungeon.items.Honeypot)4 WndTradeItem (com.shatteredpixel.shatteredpixeldungeon.windows.WndTradeItem)4 Dewdrop (com.shatteredpixel.shatteredpixeldungeon.items.Dewdrop)3 Armor (com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor)3 Potion (com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion)3 Fire (com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Fire)2 Belongings (com.shatteredpixel.shatteredpixeldungeon.actors.hero.Belongings)2 Thief (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Thief)2 Ankh (com.shatteredpixel.shatteredpixeldungeon.items.Ankh)2