Search in sources :

Example 21 with Item

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

the class PitRoom method paint.

public void paint(Level level) {
    Painter.fill(level, this, Terrain.WALL);
    Painter.fill(level, this, 1, Terrain.EMPTY);
    Door entrance = entrance();
    entrance.set(Door.Type.LOCKED);
    Point well = null;
    if (entrance.x == left) {
        well = new Point(right - 1, Random.Int(2) == 0 ? top + 1 : bottom - 1);
    } else if (entrance.x == right) {
        well = new Point(left + 1, Random.Int(2) == 0 ? top + 1 : bottom - 1);
    } else if (entrance.y == top) {
        well = new Point(Random.Int(2) == 0 ? left + 1 : right - 1, bottom - 1);
    } else if (entrance.y == bottom) {
        well = new Point(Random.Int(2) == 0 ? left + 1 : right - 1, top + 1);
    }
    Painter.set(level, well, Terrain.EMPTY_WELL);
    int remains = level.pointToCell(random());
    while (level.map[remains] == Terrain.EMPTY_WELL) {
        remains = level.pointToCell(random());
    }
    level.drop(new IronKey(Dungeon.depth), remains).type = Heap.Type.SKELETON;
    Item mainLoot = null;
    do {
        switch(Random.Int(3)) {
            case 0:
                mainLoot = Generator.random(Generator.Category.RING);
                break;
            case 1:
                mainLoot = Generator.random(Generator.Category.ARTIFACT);
                break;
            case 2:
                mainLoot = Generator.random(Random.oneOf(Generator.Category.WEAPON, Generator.Category.ARMOR));
                break;
        }
    } while (mainLoot == null || Challenges.isItemBlocked(mainLoot));
    level.drop(mainLoot, remains);
    int n = Random.IntRange(1, 2);
    for (int i = 0; i < n; i++) {
        level.drop(prize(level), remains);
    }
}
Also used : Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) IronKey(com.shatteredpixel.shatteredpixeldungeon.items.keys.IronKey) Point(com.watabou.utils.Point) Point(com.watabou.utils.Point)

Example 22 with Item

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

the class ShopRoom method placeItems.

protected void placeItems(Level level) {
    if (itemsToSpawn == null)
        itemsToSpawn = generateItems();
    Point itemPlacement = new Point(entrance());
    if (itemPlacement.y == top) {
        itemPlacement.y++;
    } else if (itemPlacement.y == bottom) {
        itemPlacement.y--;
    } else if (itemPlacement.x == left) {
        itemPlacement.x++;
    } else {
        itemPlacement.x--;
    }
    for (Item item : itemsToSpawn) {
        if (itemPlacement.x == left + 1 && itemPlacement.y != top + 1) {
            itemPlacement.y--;
        } else if (itemPlacement.y == top + 1 && itemPlacement.x != right - 1) {
            itemPlacement.x++;
        } else if (itemPlacement.x == right - 1 && itemPlacement.y != bottom - 1) {
            itemPlacement.y++;
        } else {
            itemPlacement.x--;
        }
        int cell = level.pointToCell(itemPlacement);
        if (level.heaps.get(cell) != null) {
            do {
                cell = level.pointToCell(random());
            } while (level.heaps.get(cell) != null || level.findMob(cell) != null);
        }
        level.drop(item, cell).type = Heap.Type.FOR_SALE;
    }
}
Also used : Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Point(com.watabou.utils.Point) Point(com.watabou.utils.Point)

Example 23 with Item

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

the class ShopRoom method generateItems.

protected static ArrayList<Item> generateItems() {
    ArrayList<Item> itemsToSpawn = new ArrayList<>();
    switch(Dungeon.depth) {
        case 6:
            itemsToSpawn.add((Random.Int(2) == 0 ? new Shortsword().identify() : new HandAxe()).identify());
            itemsToSpawn.add(Random.Int(2) == 0 ? new FishingSpear().quantity(2) : new Shuriken().quantity(2));
            itemsToSpawn.add(new LeatherArmor().identify());
            break;
        case 11:
            itemsToSpawn.add((Random.Int(2) == 0 ? new Sword().identify() : new Mace()).identify());
            itemsToSpawn.add(Random.Int(2) == 0 ? new ThrowingSpear().quantity(2) : new Bolas().quantity(2));
            itemsToSpawn.add(new MailArmor().identify());
            break;
        case 16:
            itemsToSpawn.add((Random.Int(2) == 0 ? new Longsword().identify() : new BattleAxe()).identify());
            itemsToSpawn.add(Random.Int(2) == 0 ? new Javelin().quantity(2) : new Tomahawk().quantity(2));
            itemsToSpawn.add(new ScaleArmor().identify());
            break;
        case 21:
            itemsToSpawn.add(Random.Int(2) == 0 ? new Greatsword().identify() : new WarHammer().identify());
            itemsToSpawn.add(Random.Int(2) == 0 ? new Trident().quantity(2) : new ThrowingHammer().quantity(2));
            itemsToSpawn.add(new PlateArmor().identify());
            itemsToSpawn.add(new Torch());
            itemsToSpawn.add(new Torch());
            itemsToSpawn.add(new Torch());
            break;
    }
    itemsToSpawn.add(TippedDart.randomTipped());
    itemsToSpawn.add(new MerchantsBeacon());
    itemsToSpawn.add(ChooseBag(Dungeon.hero.belongings));
    itemsToSpawn.add(new PotionOfHealing());
    for (int i = 0; i < 3; i++) itemsToSpawn.add(Generator.random(Generator.Category.POTION));
    itemsToSpawn.add(new ScrollOfIdentify());
    itemsToSpawn.add(new ScrollOfRemoveCurse());
    itemsToSpawn.add(new ScrollOfMagicMapping());
    itemsToSpawn.add(Generator.random(Generator.Category.SCROLL));
    for (int i = 0; i < 2; i++) itemsToSpawn.add(Random.Int(2) == 0 ? Generator.random(Generator.Category.POTION) : Generator.random(Generator.Category.SCROLL));
    itemsToSpawn.add(new SmallRation());
    itemsToSpawn.add(new SmallRation());
    itemsToSpawn.add(new Bomb().random());
    switch(Random.Int(5)) {
        case 1:
            itemsToSpawn.add(new Bomb());
            break;
        case 2:
            itemsToSpawn.add(new Bomb().random());
            break;
        case 3:
        case 4:
            itemsToSpawn.add(new Honeypot());
            break;
    }
    if (Dungeon.depth == 6) {
        itemsToSpawn.add(new Ankh());
        itemsToSpawn.add(new Weightstone());
    } else {
        itemsToSpawn.add(Random.Int(2) == 0 ? new Ankh() : new Weightstone());
    }
    TimekeepersHourglass hourglass = Dungeon.hero.belongings.getItem(TimekeepersHourglass.class);
    if (hourglass != null) {
        int bags = 0;
        // this way players who get the hourglass late can still max it, usually.
        switch(Dungeon.depth) {
            case 6:
                bags = (int) Math.ceil((5 - hourglass.sandBags) * 0.20f);
                break;
            case 11:
                bags = (int) Math.ceil((5 - hourglass.sandBags) * 0.25f);
                break;
            case 16:
                bags = (int) Math.ceil((5 - hourglass.sandBags) * 0.50f);
                break;
            case 21:
                bags = (int) Math.ceil((5 - hourglass.sandBags) * 0.80f);
                break;
        }
        for (int i = 1; i <= bags; i++) {
            itemsToSpawn.add(new TimekeepersHourglass.sandBag());
            hourglass.sandBags++;
        }
    }
    Item rare;
    switch(Random.Int(10)) {
        case 0:
            rare = Generator.random(Generator.Category.WAND);
            rare.level(0);
            break;
        case 1:
            rare = Generator.random(Generator.Category.RING);
            rare.level(0);
            break;
        case 2:
            rare = Generator.random(Generator.Category.ARTIFACT);
            break;
        default:
            rare = new Stylus();
    }
    rare.cursed = rare.cursedKnown = false;
    itemsToSpawn.add(rare);
    // hard limit is 63 items + 1 shopkeeper, as shops can't be bigger than 8x8=64 internally
    if (itemsToSpawn.size() > 63)
        throw new RuntimeException("Shop attempted to carry more than 63 items!");
    Random.shuffle(itemsToSpawn);
    return itemsToSpawn;
}
Also used : MailArmor(com.shatteredpixel.shatteredpixeldungeon.items.armor.MailArmor) Tomahawk(com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.Tomahawk) ScrollOfIdentify(com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfIdentify) Bolas(com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.Bolas) ThrowingHammer(com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.ThrowingHammer) ArrayList(java.util.ArrayList) BattleAxe(com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.BattleAxe) Javelin(com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.Javelin) ScrollOfMagicMapping(com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfMagicMapping) Torch(com.shatteredpixel.shatteredpixeldungeon.items.Torch) Stylus(com.shatteredpixel.shatteredpixeldungeon.items.Stylus) Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Longsword(com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Longsword) Sword(com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Sword) Trident(com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.Trident) LeatherArmor(com.shatteredpixel.shatteredpixeldungeon.items.armor.LeatherArmor) Greatsword(com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Greatsword) PotionOfHealing(com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfHealing) Bomb(com.shatteredpixel.shatteredpixeldungeon.items.Bomb) TimekeepersHourglass(com.shatteredpixel.shatteredpixeldungeon.items.artifacts.TimekeepersHourglass) Shortsword(com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Shortsword) ThrowingSpear(com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.ThrowingSpear) ScaleArmor(com.shatteredpixel.shatteredpixeldungeon.items.armor.ScaleArmor) MerchantsBeacon(com.shatteredpixel.shatteredpixeldungeon.items.MerchantsBeacon) Point(com.watabou.utils.Point) WarHammer(com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.WarHammer) ScrollOfRemoveCurse(com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfRemoveCurse) Weightstone(com.shatteredpixel.shatteredpixeldungeon.items.Weightstone) PlateArmor(com.shatteredpixel.shatteredpixeldungeon.items.armor.PlateArmor) FishingSpear(com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.FishingSpear) Mace(com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Mace) Shuriken(com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.Shuriken) Ankh(com.shatteredpixel.shatteredpixeldungeon.items.Ankh) SmallRation(com.shatteredpixel.shatteredpixeldungeon.items.food.SmallRation) HandAxe(com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.HandAxe) Honeypot(com.shatteredpixel.shatteredpixeldungeon.items.Honeypot)

Example 24 with Item

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

the class HighGrass method trample.

public static void trample(Level level, int pos, Char ch) {
    Level.set(pos, Terrain.GRASS);
    GameScene.updateMap(pos);
    int naturalismLevel = 0;
    if (ch != null) {
        SandalsOfNature.Naturalism naturalism = ch.buff(SandalsOfNature.Naturalism.class);
        if (naturalism != null) {
            if (!naturalism.isCursed()) {
                naturalismLevel = naturalism.itemLevel() + 1;
                naturalism.charge();
            } else {
                naturalismLevel = -1;
            }
        }
    }
    if (naturalismLevel >= 0) {
        // Seed, scales from 1/16 to 1/4
        if (Random.Int(16 - ((int) (naturalismLevel * 3))) == 0) {
            Item seed = Generator.random(Generator.Category.SEED);
            if (seed instanceof BlandfruitBush.Seed) {
                if (Random.Int(3) - Dungeon.LimitedDrops.BLANDFRUIT_SEED.count >= 0) {
                    level.drop(seed, pos).sprite.drop();
                    Dungeon.LimitedDrops.BLANDFRUIT_SEED.count++;
                }
            } else
                level.drop(seed, pos).sprite.drop();
        }
        // Dew, scales from 1/6 to 1/3
        if (Random.Int(24 - naturalismLevel * 3) <= 3) {
            level.drop(new Dewdrop(), pos).sprite.drop();
        }
    }
    int leaves = 4;
    if (ch instanceof Hero) {
        Hero hero = (Hero) ch;
        // Barkskin
        if (hero.subClass == HeroSubClass.WARDEN) {
            Buff.affect(ch, Barkskin.class).level(ch.HT / 3);
            leaves += 4;
        }
        // Camouflage
        if (hero.belongings.armor != null && hero.belongings.armor.hasGlyph(Camouflage.class)) {
            Buff.affect(hero, Camouflage.Camo.class).set(3 + hero.belongings.armor.level());
            leaves += 4;
        }
    }
    CellEmitter.get(pos).burst(LeafParticle.LEVEL_SPECIFIC, leaves);
    if (Dungeon.level.heroFOV[pos])
        Dungeon.observe();
}
Also used : Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Camouflage(com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.Camouflage) Dewdrop(com.shatteredpixel.shatteredpixeldungeon.items.Dewdrop) Hero(com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero) Barkskin(com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Barkskin) SandalsOfNature(com.shatteredpixel.shatteredpixeldungeon.items.artifacts.SandalsOfNature)

Example 25 with Item

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

the class RatKingRoom method addChest.

private static void addChest(Level level, int pos, int door) {
    if (pos == door - 1 || pos == door + 1 || pos == door - level.width() || pos == door + level.width()) {
        return;
    }
    Item prize = new Gold(Random.IntRange(10, 25));
    level.drop(prize, pos).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