Search in sources :

Example 36 with Item

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

the class Bones method pickItem.

private static Item pickItem(Hero hero) {
    Item item = null;
    if (Random.Int(3) != 0) {
        switch(Random.Int(6)) {
            case 0:
                item = hero.belongings.weapon;
                break;
            case 1:
                item = hero.belongings.armor;
                break;
            case 2:
                item = hero.belongings.misc1;
                break;
            case 3:
                item = hero.belongings.misc2;
                break;
            case 4:
            case 5:
                item = Dungeon.quickslot.randomNonePlaceholder();
                break;
        }
        if (item == null || !item.bones) {
            return pickItem(hero);
        }
    } else {
        Iterator<Item> iterator = hero.belongings.backpack.iterator();
        Item curItem;
        ArrayList<Item> items = new ArrayList<Item>();
        while (iterator.hasNext()) {
            curItem = iterator.next();
            if (curItem.bones)
                items.add(curItem);
        }
        if (Random.Int(3) < items.size()) {
            item = Random.element(items);
            if (item.stackable) {
                item.quantity(Random.NormalIntRange(1, (item.quantity() + 1) / 2));
            }
        } else {
            if (Dungeon.gold > 100) {
                item = new Gold(Random.NormalIntRange(50, Dungeon.gold / 2));
            } else {
                item = new Gold(50);
            }
        }
    }
    return item;
}
Also used : Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Gold(com.shatteredpixel.shatteredpixeldungeon.items.Gold) ArrayList(java.util.ArrayList)

Example 37 with Item

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

the class Mimic method spawnAt.

public static Mimic spawnAt(int pos, List<Item> items) {
    if (Dungeon.level.pit[pos])
        return null;
    Char ch = Actor.findChar(pos);
    if (ch != null) {
        ArrayList<Integer> candidates = new ArrayList<>();
        for (int n : PathFinder.NEIGHBOURS8) {
            int cell = pos + n;
            if ((Dungeon.level.passable[cell] || Dungeon.level.avoid[cell]) && Actor.findChar(cell) == null) {
                candidates.add(cell);
            }
        }
        if (candidates.size() > 0) {
            int newPos = Random.element(candidates);
            Actor.addDelayed(new Pushing(ch, ch.pos, newPos), -1);
            ch.pos = newPos;
            Dungeon.level.press(newPos, ch);
        } else {
            return null;
        }
    }
    Mimic m = new Mimic();
    m.items = new ArrayList<>(items);
    m.adjustStats(Dungeon.depth);
    m.pos = pos;
    m.state = m.HUNTING;
    GameScene.add(m, 1);
    m.sprite.turnTo(pos, Dungeon.hero.pos);
    if (Dungeon.level.heroFOV[m.pos]) {
        CellEmitter.get(pos).burst(Speck.factory(Speck.STAR), 10);
        Sample.INSTANCE.play(Assets.SND_MIMIC);
    }
    // generate an extra reward for killing the mimic
    Item reward = null;
    do {
        switch(Random.Int(5)) {
            case 0:
                reward = new Gold().random();
                break;
            case 1:
                reward = Generator.randomMissile();
                break;
            case 2:
                reward = Generator.randomArmor();
                break;
            case 3:
                reward = Generator.randomWeapon();
                break;
            case 4:
                reward = Generator.random(Generator.Category.RING);
                break;
        }
    } while (reward == null || Challenges.isItemBlocked(reward));
    m.items.add(reward);
    return m;
}
Also used : Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Gold(com.shatteredpixel.shatteredpixeldungeon.items.Gold) Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char) Pushing(com.shatteredpixel.shatteredpixeldungeon.effects.Pushing) ArrayList(java.util.ArrayList)

Example 38 with Item

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

the class Mob method rollToDropLoot.

public void rollToDropLoot() {
    if (Dungeon.hero.lvl > maxLvl + 2)
        return;
    float lootChance = this.lootChance;
    lootChance *= RingOfWealth.dropChanceMultiplier(Dungeon.hero);
    if (Random.Float() < lootChance) {
        Item loot = createLoot();
        if (loot != null) {
            Dungeon.level.drop(loot, pos).sprite.drop();
        }
    }
    // ring of wealth logic
    if (Ring.getBonus(Dungeon.hero, RingOfWealth.Wealth.class) > 0) {
        int rolls = 1;
        if (properties.contains(Property.BOSS))
            rolls = 15;
        else if (properties.contains(Property.MINIBOSS))
            rolls = 5;
        ArrayList<Item> bonus = RingOfWealth.tryRareDrop(Dungeon.hero, rolls);
        if (bonus != null) {
            for (Item b : bonus) Dungeon.level.drop(b, pos).sprite.drop();
            new Flare(8, 32).color(0xFFFF00, true).show(sprite, 2f);
        }
    }
}
Also used : Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Flare(com.shatteredpixel.shatteredpixeldungeon.effects.Flare) RingOfWealth(com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfWealth)

Example 39 with Item

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

the class Skeleton method createLoot.

@Override
protected Item createLoot() {
    Item loot;
    do {
        loot = Generator.randomWeapon();
    // 50% chance of re-rolling tier 4 or 5 melee weapons
    } while (((MeleeWeapon) loot).tier >= 4 && Random.Int(2) == 0);
    loot.level(0);
    return loot;
}
Also used : MeleeWeapon(com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MeleeWeapon) Item(com.shatteredpixel.shatteredpixeldungeon.items.Item)

Example 40 with Item

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

the class PrisonBossLevel method createItems.

@Override
protected void createItems() {
    Item item = Bones.get();
    if (item != null) {
        drop(item, randomRespawnCell()).type = Heap.Type.REMAINS;
    }
    drop(new IronKey(10), randomPrisonCell());
}
Also used : Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) IronKey(com.shatteredpixel.shatteredpixeldungeon.items.keys.IronKey)

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