Search in sources :

Example 11 with Hero

use of com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero in project shattered-pixel-dungeon-gdx by 00-Evan.

the class Chasm method heroLand.

public static void heroLand() {
    Hero hero = Dungeon.hero;
    hero.sprite.burst(hero.sprite.blood(), 10);
    Camera.main.shake(4, 0.2f);
    Dungeon.level.press(hero.pos, hero, true);
    Buff.prolong(hero, Cripple.class, Cripple.DURATION);
    // The lower the hero's HP, the more bleed and the less upfront damage.
    // Hero has a 50% chance to bleed out at 66% HP, and begins to risk instant-death at 25%
    Buff.affect(hero, Bleeding.class).set(Math.round(hero.HT / (6f + (6f * (hero.HP / (float) hero.HT)))));
    hero.damage(Math.max(hero.HP / 2, Random.NormalIntRange(hero.HP / 2, hero.HT / 4)), new Hero.Doom() {

        @Override
        public void onDeath() {
            Badges.validateDeathFromFalling();
            Dungeon.fail(Chasm.class);
            GLog.n(Messages.get(Chasm.class, "ondeath"));
        }
    });
}
Also used : Hero(com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero) Bleeding(com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Bleeding)

Example 12 with Hero

use of com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero 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 13 with Hero

use of com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero in project shattered-pixel-dungeon-gdx by 00-Evan.

the class Multiplicity method proc.

@Override
public int proc(Armor armor, Char attacker, Char defender, int damage) {
    if (Random.Int(20) == 0) {
        ArrayList<Integer> spawnPoints = new ArrayList<>();
        for (int i = 0; i < PathFinder.NEIGHBOURS8.length; i++) {
            int p = defender.pos + PathFinder.NEIGHBOURS8[i];
            if (Actor.findChar(p) == null && (Dungeon.level.passable[p] || Dungeon.level.avoid[p])) {
                spawnPoints.add(p);
            }
        }
        if (spawnPoints.size() > 0) {
            Mob m = null;
            if (Random.Int(2) == 0 && defender instanceof Hero) {
                m = new MirrorImage();
                ((MirrorImage) m).duplicate((Hero) defender);
            } else {
                // FIXME should probably have a mob property for this
                if (attacker.properties().contains(Char.Property.BOSS) || attacker.properties().contains(Char.Property.MINIBOSS) || attacker instanceof Mimic || attacker instanceof Statue) {
                    m = Dungeon.level.createMob();
                } else {
                    try {
                        Actor.fixTime();
                        m = (Mob) attacker.getClass().newInstance();
                        Bundle store = new Bundle();
                        attacker.storeInBundle(store);
                        m.restoreFromBundle(store);
                        m.HP = m.HT;
                        // If a thief has stolen an item, that item is not duplicated.
                        if (m instanceof Thief) {
                            ((Thief) m).item = null;
                        }
                    } catch (Exception e) {
                        ShatteredPixelDungeon.reportException(e);
                        m = null;
                    }
                }
            }
            if (m != null) {
                GameScene.add(m);
                ScrollOfTeleportation.appear(m, Random.element(spawnPoints));
            }
        }
    }
    return damage;
}
Also used : MirrorImage(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.MirrorImage) Mob(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob) Mimic(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mimic) Statue(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Statue) Bundle(com.watabou.utils.Bundle) Thief(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Thief) ArrayList(java.util.ArrayList) Hero(com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero)

Example 14 with Hero

use of com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero in project shattered-pixel-dungeon-gdx by 00-Evan.

the class WndTradeItem method sell.

private void sell(Item item) {
    Hero hero = Dungeon.hero;
    if (item.isEquipped(hero) && !((EquipableItem) item).doUnequip(hero, false)) {
        return;
    }
    item.detachAll(hero.belongings.backpack);
    new Gold(item.price()).doPickUp(hero);
    // selling items in the sell interface doesn't spend time
    hero.spend(-hero.cooldown());
}
Also used : Gold(com.shatteredpixel.shatteredpixeldungeon.items.Gold) Hero(com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero) EquipableItem(com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem)

Example 15 with Hero

use of com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero in project shattered-pixel-dungeon-gdx by 00-Evan.

the class DisarmingTrap method activate.

@Override
public void activate() {
    Heap heap = Dungeon.level.heaps.get(pos);
    if (heap != null) {
        int cell = Dungeon.level.randomRespawnCell();
        if (cell != -1) {
            Item item = heap.pickUp();
            Dungeon.level.drop(item, cell).seen = true;
            for (int i : PathFinder.NEIGHBOURS9) Dungeon.level.visited[cell + i] = true;
            GameScene.updateFog();
            Sample.INSTANCE.play(Assets.SND_TELEPORT);
            CellEmitter.get(pos).burst(Speck.factory(Speck.LIGHT), 4);
        }
    }
    if (Dungeon.hero.pos == pos) {
        Hero hero = Dungeon.hero;
        KindOfWeapon weapon = hero.belongings.weapon;
        if (weapon != null && !(weapon instanceof Knuckles) && !weapon.cursed) {
            int cell = Dungeon.level.randomRespawnCell();
            if (cell != -1) {
                hero.belongings.weapon = null;
                Dungeon.quickslot.clearItem(weapon);
                weapon.updateQuickslot();
                Dungeon.level.drop(weapon, cell).seen = true;
                for (int i : PathFinder.NEIGHBOURS9) Dungeon.level.visited[cell + i] = true;
                GameScene.updateFog();
                GLog.w(Messages.get(this, "disarm"));
                Sample.INSTANCE.play(Assets.SND_TELEPORT);
                CellEmitter.get(pos).burst(Speck.factory(Speck.LIGHT), 4);
            }
        }
    }
}
Also used : Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Knuckles(com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Knuckles) Hero(com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero) KindOfWeapon(com.shatteredpixel.shatteredpixeldungeon.items.KindOfWeapon) Heap(com.shatteredpixel.shatteredpixeldungeon.items.Heap)

Aggregations

Hero (com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero)25 Mob (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob)9 Item (com.shatteredpixel.shatteredpixeldungeon.items.Item)9 Char (com.shatteredpixel.shatteredpixeldungeon.actors.Char)8 Heap (com.shatteredpixel.shatteredpixeldungeon.items.Heap)5 ArrayList (java.util.ArrayList)4 Thief (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Thief)3 Barkskin (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Barkskin)2 EquipableItem (com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem)2 Gold (com.shatteredpixel.shatteredpixeldungeon.items.Gold)2 KindOfWeapon (com.shatteredpixel.shatteredpixeldungeon.items.KindOfWeapon)2 MysteryMeat (com.shatteredpixel.shatteredpixeldungeon.items.food.MysteryMeat)2 Knuckles (com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Knuckles)2 Fire (com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Fire)1 Awareness (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Awareness)1 Bleeding (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Bleeding)1 Buff (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff)1 EarthImbue (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.EarthImbue)1 FireImbue (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.FireImbue)1 MindVision (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.MindVision)1