Search in sources :

Example 6 with Char

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

use of com.shatteredpixel.shatteredpixeldungeon.actors.Char 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 8 with Char

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

the class Dagger method damageRoll.

@Override
public int damageRoll(Char owner) {
    if (owner instanceof Hero) {
        Hero hero = (Hero) owner;
        Char enemy = hero.enemy();
        if (enemy instanceof Mob && ((Mob) enemy).surprisedBy(hero)) {
            // deals 75% toward max to max on surprise, instead of min to max.
            int diff = max() - min();
            int damage = imbue.damageFactor(Random.NormalIntRange(min() + Math.round(diff * 0.75f), max()));
            int exStr = hero.STR() - STRReq();
            if (exStr > 0) {
                damage += Random.IntRange(0, exStr);
            }
            return damage;
        }
    }
    return super.damageRoll(owner);
}
Also used : Mob(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob) Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char) Hero(com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero)

Example 9 with Char

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

the class AssassinsBlade method damageRoll.

@Override
public int damageRoll(Char owner) {
    if (owner instanceof Hero) {
        Hero hero = (Hero) owner;
        Char enemy = hero.enemy();
        if (enemy instanceof Mob && ((Mob) enemy).surprisedBy(hero)) {
            // deals 50% toward max to max on surprise, instead of min to max.
            int diff = max() - min();
            int damage = imbue.damageFactor(Random.NormalIntRange(min() + Math.round(diff * 0.50f), max()));
            int exStr = hero.STR() - STRReq();
            if (exStr > 0) {
                damage += Random.IntRange(0, exStr);
            }
            return damage;
        }
    }
    return super.damageRoll(owner);
}
Also used : Mob(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob) Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char) Hero(com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero)

Example 10 with Char

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

the class King method summon.

private void summon() {
    nextPedestal = !nextPedestal;
    sprite.centerEmitter().start(Speck.factory(Speck.SCREAM), 0.4f, 2);
    Sample.INSTANCE.play(Assets.SND_CHALLENGE);
    boolean[] passable = Dungeon.level.passable.clone();
    for (Char c : Actor.chars()) {
        passable[c.pos] = false;
    }
    int undeadsToSummon = maxArmySize() - Undead.count;
    PathFinder.buildDistanceMap(pos, passable, undeadsToSummon);
    PathFinder.distance[pos] = Integer.MAX_VALUE;
    int dist = 1;
    undeadLabel: for (int i = 0; i < undeadsToSummon; i++) {
        do {
            for (int j = 0; j < Dungeon.level.length(); j++) {
                if (PathFinder.distance[j] == dist) {
                    Undead undead = new Undead();
                    undead.pos = j;
                    GameScene.add(undead);
                    ScrollOfTeleportation.appear(undead, j);
                    new Flare(3, 32).color(0x000000, false).show(undead.sprite, 2f);
                    PathFinder.distance[j] = Integer.MAX_VALUE;
                    continue undeadLabel;
                }
            }
            dist++;
        } while (dist < undeadsToSummon);
    }
    yell(Messages.get(this, "arise"));
}
Also used : Flare(com.shatteredpixel.shatteredpixeldungeon.effects.Flare) Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char)

Aggregations

Char (com.shatteredpixel.shatteredpixeldungeon.actors.Char)65 Mob (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob)13 Heap (com.shatteredpixel.shatteredpixeldungeon.items.Heap)13 Hero (com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero)8 Callback (com.watabou.utils.Callback)8 Item (com.shatteredpixel.shatteredpixeldungeon.items.Item)7 Ballistica (com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica)5 ArrayList (java.util.ArrayList)4 Actor (com.shatteredpixel.shatteredpixeldungeon.actors.Actor)3 Fire (com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Fire)3 Buff (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff)3 Burning (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Burning)3 Frost (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Frost)3 Bleeding (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Bleeding)2 Chill (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Chill)2 Paralysis (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Paralysis)2 Lightning (com.shatteredpixel.shatteredpixeldungeon.effects.Lightning)2 Blob (com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob)1 CorrosiveGas (com.shatteredpixel.shatteredpixeldungeon.actors.blobs.CorrosiveGas)1 Regrowth (com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Regrowth)1