Search in sources :

Example 6 with Item

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

the class Thief method steal.

protected boolean steal(Hero hero) {
    Item item = hero.belongings.randomUnequipped();
    if (item != null && !item.unique && item.level() < 1) {
        GLog.w(Messages.get(Thief.class, "stole", item.name()));
        if (!item.stackable || hero.belongings.getSimilar(item) == null) {
            Dungeon.quickslot.convertToPlaceholder(item);
        }
        item.updateQuickslot();
        if (item instanceof Honeypot) {
            this.item = ((Honeypot) item).shatter(this, this.pos);
            item.detach(hero.belongings.backpack);
        } else {
            this.item = item.detach(hero.belongings.backpack);
            if (item instanceof Honeypot.ShatteredPot)
                ((Honeypot.ShatteredPot) item).setHolder(this);
        }
        return true;
    } else {
        return false;
    }
}
Also used : Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Honeypot(com.shatteredpixel.shatteredpixeldungeon.items.Honeypot)

Example 7 with Item

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

the class GameScene method create.

@Override
public void create() {
    Music.INSTANCE.play(Assets.TUNE, true);
    SPDSettings.lastClass(Dungeon.hero.heroClass.ordinal());
    super.create();
    Camera.main.zoom(GameMath.gate(minZoom, defaultZoom + SPDSettings.zoom(), maxZoom));
    scene = this;
    terrain = new Group();
    add(terrain);
    water = new SkinnedBlock(Dungeon.level.width() * DungeonTilemap.SIZE, Dungeon.level.height() * DungeonTilemap.SIZE, Dungeon.level.waterTex()) {

        @Override
        protected NoosaScript script() {
            return NoosaScriptNoLighting.get();
        }

        @Override
        public void draw() {
            // water has no alpha component, this improves performance
            Blending.disable();
            super.draw();
            Blending.enable();
        }
    };
    terrain.add(water);
    ripples = new Group();
    terrain.add(ripples);
    DungeonTileSheet.setupVariance(Dungeon.level.map.length, Dungeon.seedCurDepth());
    tiles = new DungeonTerrainTilemap();
    terrain.add(tiles);
    customTiles = new Group();
    terrain.add(customTiles);
    for (CustomTiledVisual visual : Dungeon.level.customTiles) {
        addCustomTile(visual);
    }
    visualGrid = new GridTileMap();
    terrain.add(visualGrid);
    terrainFeatures = new TerrainFeaturesTilemap(Dungeon.level.plants, Dungeon.level.traps);
    terrain.add(terrainFeatures);
    levelVisuals = Dungeon.level.addVisuals();
    add(levelVisuals);
    heaps = new Group();
    add(heaps);
    for (IntMap.Entry<Heap> heap : Dungeon.level.heaps) {
        addHeapSprite(heap.value);
    }
    emitters = new Group();
    effects = new Group();
    healthIndicators = new Group();
    emoicons = new Group();
    mobs = new Group();
    add(mobs);
    for (Mob mob : Dungeon.level.mobs) {
        addMobSprite(mob);
        if (Statistics.amuletObtained) {
            mob.beckon(Dungeon.hero.pos);
        }
    }
    walls = new DungeonWallsTilemap();
    add(walls);
    customWalls = new Group();
    add(customWalls);
    for (CustomTiledVisual visual : Dungeon.level.customWalls) {
        addCustomWall(visual);
    }
    wallBlocking = new WallBlockingTilemap();
    add(wallBlocking);
    add(emitters);
    add(effects);
    gases = new Group();
    add(gases);
    for (Blob blob : Dungeon.level.blobs.values()) {
        blob.emitter = null;
        addBlobSprite(blob);
    }
    fog = new FogOfWar(Dungeon.level.width(), Dungeon.level.height());
    add(fog);
    spells = new Group();
    add(spells);
    statuses = new Group();
    add(statuses);
    add(healthIndicators);
    // always appears ontop of other health indicators
    add(new TargetHealthIndicator());
    add(emoicons);
    hero = new HeroSprite();
    hero.place(Dungeon.hero.pos);
    hero.updateArmor();
    mobs.add(hero);
    add(cellSelector = new CellSelector(tiles));
    pane = new StatusPane();
    pane.camera = uiCamera;
    pane.setSize(uiCamera.width, 0);
    add(pane);
    toolbar = new Toolbar();
    toolbar.camera = uiCamera;
    toolbar.setRect(0, uiCamera.height - toolbar.height(), uiCamera.width, toolbar.height());
    add(toolbar);
    attack = new AttackIndicator();
    attack.camera = uiCamera;
    add(attack);
    loot = new LootIndicator();
    loot.camera = uiCamera;
    add(loot);
    action = new ActionIndicator();
    action.camera = uiCamera;
    add(action);
    resume = new ResumeIndicator();
    resume.camera = uiCamera;
    add(resume);
    log = new GameLog();
    log.camera = uiCamera;
    log.newLine();
    add(log);
    layoutTags();
    busy = new BusyIndicator();
    busy.camera = uiCamera;
    busy.x = 1;
    busy.y = pane.bottom() + 1;
    add(busy);
    switch(InterlevelScene.mode) {
        case RESURRECT:
            ScrollOfTeleportation.appear(Dungeon.hero, Dungeon.level.entrance);
            new Flare(8, 32).color(0xFFFF66, true).show(hero, 2f);
            break;
        case RETURN:
            ScrollOfTeleportation.appear(Dungeon.hero, Dungeon.hero.pos);
            break;
        case FALL:
            Chasm.heroLand();
            break;
        case DESCEND:
            switch(Dungeon.depth) {
                case 1:
                    WndStory.showChapter(WndStory.ID_SEWERS);
                    break;
                case 6:
                    WndStory.showChapter(WndStory.ID_PRISON);
                    break;
                case 11:
                    WndStory.showChapter(WndStory.ID_CAVES);
                    break;
                case 16:
                    WndStory.showChapter(WndStory.ID_CITY);
                    break;
                case 22:
                    WndStory.showChapter(WndStory.ID_HALLS);
                    break;
            }
            if (Dungeon.hero.isAlive() && Dungeon.depth != 22) {
                Badges.validateNoKilling();
            }
            break;
        default:
    }
    ArrayList<Item> dropped = Dungeon.droppedItems.get(Dungeon.depth);
    if (dropped != null) {
        for (Item item : dropped) {
            int pos = Dungeon.level.randomRespawnCell();
            if (item instanceof Potion) {
                ((Potion) item).shatter(pos);
            } else if (item instanceof Plant.Seed) {
                Dungeon.level.plant((Plant.Seed) item, pos);
            } else if (item instanceof Honeypot) {
                Dungeon.level.drop(((Honeypot) item).shatter(null, pos), pos);
            } else {
                Dungeon.level.drop(item, pos);
            }
        }
        Dungeon.droppedItems.remove(Dungeon.depth);
    }
    Dungeon.hero.next();
    Camera.main.target = hero;
    if (InterlevelScene.mode != InterlevelScene.Mode.NONE) {
        if (Dungeon.depth == Statistics.deepestFloor && (InterlevelScene.mode == InterlevelScene.Mode.DESCEND || InterlevelScene.mode == InterlevelScene.Mode.FALL)) {
            GLog.h(Messages.get(this, "descend"), Dungeon.depth);
            Sample.INSTANCE.play(Assets.SND_DESCEND);
        } else if (InterlevelScene.mode == InterlevelScene.Mode.RESET) {
            GLog.h(Messages.get(this, "warp"));
        } else {
            GLog.h(Messages.get(this, "return"), Dungeon.depth);
        }
        switch(Dungeon.level.feeling) {
            case CHASM:
                GLog.w(Messages.get(this, "chasm"));
                break;
            case WATER:
                GLog.w(Messages.get(this, "water"));
                break;
            case GRASS:
                GLog.w(Messages.get(this, "grass"));
                break;
            case DARK:
                GLog.w(Messages.get(this, "dark"));
                break;
            default:
        }
        if (Dungeon.level instanceof RegularLevel && ((RegularLevel) Dungeon.level).secretDoors > Random.IntRange(3, 4)) {
            GLog.w(Messages.get(this, "secrets"));
        }
        InterlevelScene.mode = InterlevelScene.Mode.NONE;
        fadeIn();
    }
    selectCell(defaultCellListener);
}
Also used : Group(com.watabou.noosa.Group) StatusPane(com.shatteredpixel.shatteredpixeldungeon.ui.StatusPane) DungeonTerrainTilemap(com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonTerrainTilemap) NoosaScript(com.watabou.noosa.NoosaScript) GridTileMap(com.shatteredpixel.shatteredpixeldungeon.tiles.GridTileMap) AttackIndicator(com.shatteredpixel.shatteredpixeldungeon.ui.AttackIndicator) Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) WndTradeItem(com.shatteredpixel.shatteredpixeldungeon.windows.WndTradeItem) WndInfoItem(com.shatteredpixel.shatteredpixeldungeon.windows.WndInfoItem) Plant(com.shatteredpixel.shatteredpixeldungeon.plants.Plant) WndInfoPlant(com.shatteredpixel.shatteredpixeldungeon.windows.WndInfoPlant) TargetHealthIndicator(com.shatteredpixel.shatteredpixeldungeon.ui.TargetHealthIndicator) IntMap(com.badlogic.gdx.utils.IntMap) BusyIndicator(com.shatteredpixel.shatteredpixeldungeon.ui.BusyIndicator) SkinnedBlock(com.watabou.noosa.SkinnedBlock) GameLog(com.shatteredpixel.shatteredpixeldungeon.ui.GameLog) Toolbar(com.shatteredpixel.shatteredpixeldungeon.ui.Toolbar) Mob(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob) WndInfoMob(com.shatteredpixel.shatteredpixeldungeon.windows.WndInfoMob) FogOfWar(com.shatteredpixel.shatteredpixeldungeon.tiles.FogOfWar) Blob(com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob) Flare(com.shatteredpixel.shatteredpixeldungeon.effects.Flare) Potion(com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion) ActionIndicator(com.shatteredpixel.shatteredpixeldungeon.ui.ActionIndicator) Heap(com.shatteredpixel.shatteredpixeldungeon.items.Heap) ResumeIndicator(com.shatteredpixel.shatteredpixeldungeon.ui.ResumeIndicator) CustomTiledVisual(com.shatteredpixel.shatteredpixeldungeon.tiles.CustomTiledVisual) TerrainFeaturesTilemap(com.shatteredpixel.shatteredpixeldungeon.tiles.TerrainFeaturesTilemap) WallBlockingTilemap(com.shatteredpixel.shatteredpixeldungeon.tiles.WallBlockingTilemap) LootIndicator(com.shatteredpixel.shatteredpixeldungeon.ui.LootIndicator) DungeonWallsTilemap(com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonWallsTilemap) HeroSprite(com.shatteredpixel.shatteredpixeldungeon.sprites.HeroSprite) Honeypot(com.shatteredpixel.shatteredpixeldungeon.items.Honeypot) RegularLevel(com.shatteredpixel.shatteredpixeldungeon.levels.RegularLevel)

Example 8 with Item

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

the class CursingTrap method activate.

@Override
public void activate() {
    if (Dungeon.level.heroFOV[pos]) {
        CellEmitter.get(pos).burst(ShadowParticle.UP, 5);
        Sample.INSTANCE.play(Assets.SND_CURSED);
    }
    Heap heap = Dungeon.level.heaps.get(pos);
    if (heap != null) {
        for (Item item : heap.items) {
            if (item.isUpgradable())
                curse(item);
        }
    }
    if (Dungeon.hero.pos == pos) {
        curse(Dungeon.hero);
    }
}
Also used : EquipableItem(com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem) Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Heap(com.shatteredpixel.shatteredpixeldungeon.items.Heap)

Example 9 with Item

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

the class CursingTrap method curse.

public static void curse(Hero hero) {
    // items the trap wants to curse because it will create a more negative effect
    ArrayList<Item> priorityCurse = new ArrayList<>();
    // items the trap can curse if nothing else is available.
    ArrayList<Item> canCurse = new ArrayList<>();
    KindOfWeapon weapon = hero.belongings.weapon;
    if (weapon instanceof Weapon && !weapon.cursed && !(weapon instanceof Boomerang)) {
        if (((Weapon) weapon).enchantment == null)
            priorityCurse.add(weapon);
        else
            canCurse.add(weapon);
    }
    Armor armor = hero.belongings.armor;
    if (armor != null && !armor.cursed) {
        if (armor.glyph == null)
            priorityCurse.add(armor);
        else
            canCurse.add(armor);
    }
    KindofMisc misc1 = hero.belongings.misc1;
    if (misc1 != null) {
        canCurse.add(misc1);
    }
    KindofMisc misc2 = hero.belongings.misc2;
    if (misc2 != null) {
        canCurse.add(misc2);
    }
    Collections.shuffle(priorityCurse);
    Collections.shuffle(canCurse);
    int numCurses = Random.Int(2) == 0 ? 1 : 2;
    for (int i = 0; i < numCurses; i++) {
        if (!priorityCurse.isEmpty()) {
            curse(priorityCurse.remove(0));
        } else if (!canCurse.isEmpty()) {
            curse(canCurse.remove(0));
        }
    }
    EquipableItem.equipCursed(hero);
    GLog.n(Messages.get(CursingTrap.class, "curse"));
}
Also used : EquipableItem(com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem) Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Armor(com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor) KindofMisc(com.shatteredpixel.shatteredpixeldungeon.items.KindofMisc) ArrayList(java.util.ArrayList) KindOfWeapon(com.shatteredpixel.shatteredpixeldungeon.items.KindOfWeapon) Boomerang(com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.Boomerang) KindOfWeapon(com.shatteredpixel.shatteredpixeldungeon.items.KindOfWeapon) Weapon(com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon)

Example 10 with Item

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

the class DisintegrationTrap method activate.

@Override
public void activate() {
    Char target = Actor.findChar(pos);
    // find the closest char that can be aimed at
    if (target == null) {
        for (Char ch : Actor.chars()) {
            Ballistica bolt = new Ballistica(pos, ch.pos, Ballistica.PROJECTILE);
            if (bolt.collisionPos == ch.pos && (target == null || Dungeon.level.trueDistance(pos, ch.pos) < Dungeon.level.trueDistance(pos, target.pos))) {
                target = ch;
            }
        }
    }
    Heap heap = Dungeon.level.heaps.get(pos);
    if (heap != null)
        heap.explode();
    if (target != null) {
        if (Dungeon.level.heroFOV[pos] || Dungeon.level.heroFOV[target.pos]) {
            Sample.INSTANCE.play(Assets.SND_RAY);
            ShatteredPixelDungeon.scene().add(new Beam.DeathRay(DungeonTilemap.tileCenterToWorld(pos), target.sprite.center()));
        }
        target.damage(Math.max(target.HT / 5, Random.Int(target.HP / 2, 2 * target.HP / 3)), this);
        if (target == Dungeon.hero) {
            Hero hero = (Hero) target;
            if (!hero.isAlive()) {
                Dungeon.fail(getClass());
                GLog.n(Messages.get(this, "ondeath"));
            } else {
                Item item = hero.belongings.randomUnequipped();
                Bag bag = hero.belongings.backpack;
                // bags do not protect against this trap
                if (item instanceof Bag) {
                    bag = (Bag) item;
                    item = Random.element(bag.items);
                }
                if (item == null || item.level() > 0 || item.unique)
                    return;
                if (!item.stackable) {
                    item.detachAll(bag);
                    GLog.w(Messages.get(this, "one", item.name()));
                } else {
                    int n = Random.NormalIntRange(1, (item.quantity() + 1) / 2);
                    for (int i = 1; i <= n; i++) item.detach(bag);
                    GLog.w(Messages.get(this, "some", item.name()));
                }
            }
        }
    }
}
Also used : Beam(com.shatteredpixel.shatteredpixeldungeon.effects.Beam) Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char) Ballistica(com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica) Hero(com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero) Bag(com.shatteredpixel.shatteredpixeldungeon.items.bags.Bag) Heap(com.shatteredpixel.shatteredpixeldungeon.items.Heap)

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