Search in sources :

Example 1 with Heap

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

the class WandOfTransfusion method onZap.

@Override
protected void onZap(Ballistica beam) {
    for (int c : beam.subPath(0, beam.dist)) CellEmitter.center(c).burst(BloodParticle.BURST, 1);
    int cell = beam.collisionPos;
    Char ch = Actor.findChar(cell);
    Heap heap = Dungeon.level.heaps.get(cell);
    // if we find a character..
    if (ch != null && ch instanceof Mob) {
        processSoulMark(ch, chargesPerCast());
        // heals an ally, or a charmed enemy
        if (ch.alignment == Char.Alignment.ALLY || ch.buff(Charm.class) != null) {
            int missingHP = ch.HT - ch.HP;
            // heals 30%+3%*lvl missing HP.
            int healing = (int) Math.ceil((missingHP * (0.30f + (0.03f * level()))));
            ch.HP += healing;
            ch.sprite.emitter().burst(Speck.factory(Speck.HEALING), 1 + level() / 2);
            ch.sprite.showStatus(CharSprite.POSITIVE, "+%dHP", healing);
        // harms the undead
        } else if (ch.properties().contains(Char.Property.UNDEAD)) {
            // deals 30%+5%*lvl total HP.
            int damage = (int) Math.ceil(ch.HT * (0.3f + (0.05f * level())));
            ch.damage(damage, this);
            ch.sprite.emitter().start(ShadowParticle.UP, 0.05f, 10 + level());
            Sample.INSTANCE.play(Assets.SND_BURNING);
        // charms an enemy
        } else {
            float duration = 5 + level();
            Buff.affect(ch, Charm.class, duration).object = curUser.id();
            duration *= Random.Float(0.75f, 1f);
            Buff.affect(curUser, Charm.class, duration).object = ch.id();
            ch.sprite.centerEmitter().start(Speck.factory(Speck.HEART), 0.2f, 5);
            curUser.sprite.centerEmitter().start(Speck.factory(Speck.HEART), 0.2f, 5);
        }
    // if we find an item...
    } else if (heap != null && heap.type == Heap.Type.HEAP) {
        Item item = heap.peek();
        // 30% + 10%*lvl chance to uncurse the item and reset it to base level if degraded.
        if (item != null && Random.Float() <= 0.3f + level() * 0.1f) {
            if (item.cursed) {
                item.cursed = false;
                CellEmitter.get(cell).start(ShadowParticle.UP, 0.05f, 10);
                Sample.INSTANCE.play(Assets.SND_BURNING);
            }
            int lvldiffFromBase = item.level() - (item instanceof Ring ? 1 : 0);
            if (lvldiffFromBase < 0) {
                item.upgrade(-lvldiffFromBase);
                CellEmitter.get(cell).start(Speck.factory(Speck.UP), 0.2f, 3);
                Sample.INSTANCE.play(Assets.SND_BURNING);
            }
        }
    // if we find some trampled grass...
    } else if (Dungeon.level.map[cell] == Terrain.GRASS) {
        // regrow one grass tile, suuuuuper useful...
        Dungeon.level.set(cell, Terrain.HIGH_GRASS);
        GameScene.updateMap(cell);
        CellEmitter.get(cell).burst(LeafParticle.LEVEL_SPECIFIC, 4);
    // If we find embers...
    } else if (Dungeon.level.map[cell] == Terrain.EMBERS) {
        // 30% + 3%*lvl chance to grow a random plant, or just regrow grass.
        if (Random.Float() <= 0.3f + level() * 0.03f) {
            Dungeon.level.plant((Plant.Seed) Generator.random(Generator.Category.SEED), cell);
            CellEmitter.get(cell).burst(LeafParticle.LEVEL_SPECIFIC, 8);
            GameScene.updateMap(cell);
        } else {
            Dungeon.level.set(cell, Terrain.HIGH_GRASS);
            GameScene.updateMap(cell);
            CellEmitter.get(cell).burst(LeafParticle.LEVEL_SPECIFIC, 4);
        }
    } else
        // don't damage the hero if we can't find a target;
        return;
    if (!freeCharge) {
        damageHero();
    } else {
        freeCharge = false;
    }
}
Also used : Mob(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob) Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char) Ring(com.shatteredpixel.shatteredpixeldungeon.items.rings.Ring) Charm(com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Charm) Heap(com.shatteredpixel.shatteredpixeldungeon.items.Heap)

Example 2 with Heap

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

the class CeremonialCandle method checkCandles.

private static void checkCandles() {
    Heap heapTop = Dungeon.level.heaps.get(ritualPos - Dungeon.level.width());
    Heap heapRight = Dungeon.level.heaps.get(ritualPos + 1);
    Heap heapBottom = Dungeon.level.heaps.get(ritualPos + Dungeon.level.width());
    Heap heapLeft = Dungeon.level.heaps.get(ritualPos - 1);
    if (heapTop != null && heapRight != null && heapBottom != null && heapLeft != null) {
        if (heapTop.peek() instanceof CeremonialCandle && heapRight.peek() instanceof CeremonialCandle && heapBottom.peek() instanceof CeremonialCandle && heapLeft.peek() instanceof CeremonialCandle) {
            heapTop.pickUp();
            heapRight.pickUp();
            heapBottom.pickUp();
            heapLeft.pickUp();
            NewbornElemental elemental = new NewbornElemental();
            Char ch = Actor.findChar(ritualPos);
            if (ch != null) {
                ArrayList<Integer> candidates = new ArrayList<>();
                for (int n : PathFinder.NEIGHBOURS8) {
                    int cell = ritualPos + n;
                    if ((Dungeon.level.passable[cell] || Dungeon.level.avoid[cell]) && Actor.findChar(cell) == null) {
                        candidates.add(cell);
                    }
                }
                if (candidates.size() > 0) {
                    elemental.pos = Random.element(candidates);
                } else {
                    elemental.pos = ritualPos;
                }
            } else {
                elemental.pos = ritualPos;
            }
            elemental.state = elemental.HUNTING;
            GameScene.add(elemental, 1);
            for (int i : PathFinder.NEIGHBOURS9) {
                CellEmitter.get(ritualPos + i).burst(ElmoParticle.FACTORY, 10);
            }
            Sample.INSTANCE.play(Assets.SND_BURNING);
        }
    }
}
Also used : NewbornElemental(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.NewbornElemental) Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char) ArrayList(java.util.ArrayList) Heap(com.shatteredpixel.shatteredpixeldungeon.items.Heap)

Example 3 with Heap

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

the class Shopkeeper method flee.

public void flee() {
    for (Heap heap : Dungeon.level.heaps.values()) {
        if (heap.type == Heap.Type.FOR_SALE) {
            CellEmitter.get(heap.pos).burst(ElmoParticle.FACTORY, 4);
            heap.destroy();
        }
    }
    destroy();
    sprite.killAndErase();
    CellEmitter.get(pos).burst(ElmoParticle.FACTORY, 6);
}
Also used : Heap(com.shatteredpixel.shatteredpixeldungeon.items.Heap)

Example 4 with Heap

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

the class GameScene method examineCell.

public static void examineCell(Integer cell) {
    if (cell == null || cell < 0 || cell > Dungeon.level.length() || (!Dungeon.level.visited[cell] && !Dungeon.level.mapped[cell])) {
        return;
    }
    ArrayList<String> names = new ArrayList<>();
    final ArrayList<Object> objects = new ArrayList<>();
    if (cell == Dungeon.hero.pos) {
        objects.add(Dungeon.hero);
        names.add(Dungeon.hero.className().toUpperCase(Locale.ENGLISH));
    } else {
        if (Dungeon.level.heroFOV[cell]) {
            Mob mob = (Mob) Actor.findChar(cell);
            if (mob != null) {
                objects.add(mob);
                names.add(Messages.titleCase(mob.name));
            }
        }
    }
    Heap heap = Dungeon.level.heaps.get(cell);
    if (heap != null && heap.seen) {
        objects.add(heap);
        names.add(Messages.titleCase(heap.toString()));
    }
    Plant plant = Dungeon.level.plants.get(cell);
    if (plant != null) {
        objects.add(plant);
        names.add(Messages.titleCase(plant.plantName));
    }
    Trap trap = Dungeon.level.traps.get(cell);
    if (trap != null && trap.visible) {
        objects.add(trap);
        names.add(Messages.titleCase(trap.name));
    }
    if (objects.isEmpty()) {
        GameScene.show(new WndInfoCell(cell));
    } else if (objects.size() == 1) {
        examineObject(objects.get(0));
    } else {
        GameScene.show(new WndOptions(Messages.get(GameScene.class, "choose_examine"), Messages.get(GameScene.class, "multiple_examine"), names.toArray(new String[names.size()])) {

            @Override
            protected void onSelect(int index) {
                examineObject(objects.get(index));
            }
        });
    }
}
Also used : WndOptions(com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions) Mob(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob) WndInfoMob(com.shatteredpixel.shatteredpixeldungeon.windows.WndInfoMob) Plant(com.shatteredpixel.shatteredpixeldungeon.plants.Plant) WndInfoPlant(com.shatteredpixel.shatteredpixeldungeon.windows.WndInfoPlant) ArrayList(java.util.ArrayList) Trap(com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap) WndInfoTrap(com.shatteredpixel.shatteredpixeldungeon.windows.WndInfoTrap) WndInfoCell(com.shatteredpixel.shatteredpixeldungeon.windows.WndInfoCell) Heap(com.shatteredpixel.shatteredpixeldungeon.items.Heap)

Example 5 with Heap

use of com.shatteredpixel.shatteredpixeldungeon.items.Heap 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)

Aggregations

Heap (com.shatteredpixel.shatteredpixeldungeon.items.Heap)33 Item (com.shatteredpixel.shatteredpixeldungeon.items.Item)14 Char (com.shatteredpixel.shatteredpixeldungeon.actors.Char)13 Mob (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob)11 Hero (com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero)5 GoldenKey (com.shatteredpixel.shatteredpixeldungeon.items.keys.GoldenKey)4 Plant (com.shatteredpixel.shatteredpixeldungeon.plants.Plant)4 ArrayList (java.util.ArrayList)4 CrystalKey (com.shatteredpixel.shatteredpixeldungeon.items.keys.CrystalKey)3 Blob (com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob)2 Awareness (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Awareness)2 Chill (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Chill)2 Frost (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Frost)2 MindVision (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.MindVision)2 IronKey (com.shatteredpixel.shatteredpixeldungeon.items.keys.IronKey)2 SkeletonKey (com.shatteredpixel.shatteredpixeldungeon.items.keys.SkeletonKey)2 Trap (com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap)2 CustomTiledVisual (com.shatteredpixel.shatteredpixeldungeon.tiles.CustomTiledVisual)2 WndInfoMob (com.shatteredpixel.shatteredpixeldungeon.windows.WndInfoMob)2 WndInfoPlant (com.shatteredpixel.shatteredpixeldungeon.windows.WndInfoPlant)2