Search in sources :

Example 91 with Item

use of com.watabou.pixeldungeon.items.Item in project pixel-dungeon-remix by NYRDS.

the class Mob method dropLoot.

@SuppressWarnings("unchecked")
protected void dropLoot() {
    if (loot != null && Random.Float() <= lootChance) {
        Item item;
        if (loot instanceof Generator.Category) {
            item = Generator.random((Generator.Category) loot);
        } else if (loot instanceof Class<?>) {
            item = Generator.random((Class<? extends Item>) loot);
        } else {
            item = (Item) loot;
        }
        Dungeon.level.drop(item, getPos()).sprite.drop();
    }
}
Also used : Item(com.watabou.pixeldungeon.items.Item)

Example 92 with Item

use of com.watabou.pixeldungeon.items.Item in project pixel-dungeon-remix by NYRDS.

the class Mob method die.

@Override
public void die(Object cause) {
    runMobScript("onDie", cause);
    Hero hero = Dungeon.hero;
    {
        // TODO we should move this block out of Mob class
        if (hero.heroClass == HeroClass.NECROMANCER) {
            if (hero.isAlive()) {
                if (hero.belongings.armor instanceof NecromancerRobe) {
                    hero.accumulateSoulPoints();
                }
            }
        }
        for (Item item : hero.belongings) {
            if (item instanceof BlackSkull && item.isEquipped(hero)) {
                ((BlackSkull) item).mobDied(this, hero);
            }
        }
    }
    {
        if (hero.isAlive()) {
            if (!friendly(hero)) {
                Statistics.enemiesSlain++;
                Badges.validateMonstersSlain();
                Statistics.qualifiedForNoKilling = false;
                if (Dungeon.nightMode) {
                    Statistics.nightHunt++;
                } else {
                    Statistics.nightHunt = 0;
                }
                Badges.validateNightHunter();
            }
            if (!(cause instanceof Mob) || hero.heroClass == HeroClass.NECROMANCER) {
                if (hero.lvl() <= maxLvl && exp > 0) {
                    hero.earnExp(exp);
                }
            }
        }
    }
    super.die(cause);
    Library.identify(Library.MOB, getMobClassName());
    if (hero.lvl() <= maxLvl + 2) {
        dropLoot();
    }
    if (hero.isAlive() && !Dungeon.visible[getPos()]) {
        GLog.i(TXT_DIED);
    }
}
Also used : NecromancerRobe(com.nyrds.pixeldungeon.items.common.armor.NecromancerRobe) Item(com.watabou.pixeldungeon.items.Item) Hero(com.watabou.pixeldungeon.actors.hero.Hero) BlackSkull(com.nyrds.pixeldungeon.items.necropolis.BlackSkull)

Example 93 with Item

use of com.watabou.pixeldungeon.items.Item in project pixel-dungeon-remix by NYRDS.

the class WellWater method affect.

protected boolean affect() {
    Heap heap;
    if (pos == Dungeon.hero.getPos() && affectHero(Dungeon.hero)) {
        volume = off[pos] = cur[pos] = 0;
        return true;
    } else if ((heap = Dungeon.level.getHeap(pos)) != null) {
        Item oldItem = heap.peek();
        Item newItem = affectItem(oldItem);
        if (newItem != null) {
            if (newItem == oldItem) {
            } else if (oldItem.quantity() > 1) {
                oldItem.quantity(oldItem.quantity() - 1);
                heap.drop(newItem);
            } else {
                heap.replace(oldItem, newItem);
            }
            heap.sprite.link();
            volume = off[pos] = cur[pos] = 0;
            return true;
        } else {
            int newPlace;
            do {
                newPlace = pos + Level.NEIGHBOURS8[Random.Int(8)];
            } while (!Dungeon.level.passable[newPlace] && !Dungeon.level.avoid[newPlace]);
            Dungeon.level.drop(heap.pickUp(), newPlace).sprite.drop(pos);
            return false;
        }
    } else {
        return false;
    }
}
Also used : Item(com.watabou.pixeldungeon.items.Item) Heap(com.watabou.pixeldungeon.items.Heap)

Aggregations

Item (com.watabou.pixeldungeon.items.Item)93 Hero (com.watabou.pixeldungeon.actors.hero.Hero)8 WndTradeItem (com.watabou.pixeldungeon.windows.WndTradeItem)8 Heap (com.watabou.pixeldungeon.items.Heap)6 IronKey (com.watabou.pixeldungeon.items.keys.IronKey)6 Point (com.watabou.utils.Point)6 ArrayList (java.util.ArrayList)6 IChaosItem (com.nyrds.pixeldungeon.items.chaos.IChaosItem)5 Mob (com.watabou.pixeldungeon.actors.mobs.Mob)5 Gold (com.watabou.pixeldungeon.items.Gold)5 WndQuest (com.watabou.pixeldungeon.windows.WndQuest)5 IActingItem (com.nyrds.pixeldungeon.items.artifacts.IActingItem)4 EquipableItem (com.watabou.pixeldungeon.items.EquipableItem)4 Wand (com.watabou.pixeldungeon.items.wands.Wand)4 TrackedRuntimeException (com.nyrds.android.util.TrackedRuntimeException)3 ScrollOfUpgrade (com.watabou.pixeldungeon.items.scrolls.ScrollOfUpgrade)3 TomeOfKnowledge (com.nyrds.pixeldungeon.items.books.TomeOfKnowledge)2 BlackSkull (com.nyrds.pixeldungeon.items.necropolis.BlackSkull)2 Char (com.watabou.pixeldungeon.actors.Char)2 Belongings (com.watabou.pixeldungeon.actors.hero.Belongings)2