Search in sources :

Example 21 with Char

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

the class PoisonDartTrap 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;
            }
        }
    }
    if (target != null) {
        final Char finalTarget = target;
        final PoisonDartTrap trap = this;
        if (Dungeon.level.heroFOV[pos] || Dungeon.level.heroFOV[target.pos]) {
            Actor.add(new Actor() {

                {
                    // it's a visual effect, gets priority no matter what
                    actPriority = VFX_PRIO;
                }

                @Override
                protected boolean act() {
                    final Actor toRemove = this;
                    ((MissileSprite) ShatteredPixelDungeon.scene().recycle(MissileSprite.class)).reset(pos, finalTarget.sprite, new PoisonDart(), new Callback() {

                        @Override
                        public void call() {
                            int dmg = Random.NormalIntRange(1, 4) - finalTarget.drRoll();
                            finalTarget.damage(dmg, trap);
                            if (finalTarget == Dungeon.hero && !finalTarget.isAlive()) {
                                Dungeon.fail(trap.getClass());
                            }
                            Buff.affect(finalTarget, Poison.class).set(4 + Dungeon.depth);
                            Sample.INSTANCE.play(Assets.SND_HIT, 1, 1, Random.Float(0.8f, 1.25f));
                            finalTarget.sprite.bloodBurstA(finalTarget.sprite.center(), dmg);
                            finalTarget.sprite.flash();
                            Actor.remove(toRemove);
                            next();
                        }
                    });
                    return false;
                }
            });
        } else {
            finalTarget.damage(Random.NormalIntRange(1, 4) - finalTarget.drRoll(), trap);
            Buff.affect(finalTarget, Poison.class).set(4 + Dungeon.depth);
        }
    }
}
Also used : Callback(com.watabou.utils.Callback) Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char) Actor(com.shatteredpixel.shatteredpixeldungeon.actors.Actor) Ballistica(com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica) PoisonDart(com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.darts.PoisonDart) Poison(com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Poison)

Example 22 with Char

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

the class Earthroot method activate.

@Override
public void activate() {
    Char ch = Actor.findChar(pos);
    if (ch == Dungeon.hero) {
        Buff.affect(ch, Armor.class).level(ch.HT);
    }
    if (Dungeon.level.heroFOV[pos]) {
        CellEmitter.bottom(pos).start(EarthParticle.FACTORY, 0.05f, 8);
        Camera.main.shake(1, 0.4f);
    }
}
Also used : Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char)

Example 23 with Char

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

the class ToxicGas method evolve.

@Override
protected void evolve() {
    super.evolve();
    int levelDamage = 5 + Dungeon.depth * 5;
    Char ch;
    int cell;
    for (int i = area.left; i < area.right; i++) {
        for (int j = area.top; j < area.bottom; j++) {
            cell = i + j * Dungeon.level.width();
            if (cur[cell] > 0 && (ch = Actor.findChar(cell)) != null) {
                if (!ch.isImmune(this.getClass())) {
                    int damage = (ch.HT + levelDamage) / 40;
                    if (Random.Int(40) < (ch.HT + levelDamage) % 40) {
                        damage++;
                    }
                    ch.damage(damage, this);
                }
            }
        }
    }
}
Also used : Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char)

Example 24 with Char

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

the class CorrosiveGas method evolve.

@Override
protected void evolve() {
    super.evolve();
    if (volume == 0) {
        strength = 0;
    } else {
        Char ch;
        int cell;
        for (int i = area.left; i < area.right; i++) {
            for (int j = area.top; j < area.bottom; j++) {
                cell = i + j * Dungeon.level.width();
                if (cur[cell] > 0 && (ch = Actor.findChar(cell)) != null) {
                    if (!ch.isImmune(this.getClass()))
                        Buff.affect(ch, Corrosion.class).set(2f, strength);
                }
            }
        }
    }
}
Also used : Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char)

Example 25 with Char

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

the class Fire method burn.

private void burn(int pos) {
    Char ch = Actor.findChar(pos);
    if (ch != null && !ch.isImmune(this.getClass())) {
        Buff.affect(ch, Burning.class).reignite(ch);
    }
    Heap heap = Dungeon.level.heaps.get(pos);
    if (heap != null) {
        heap.burn();
    }
    Plant plant = Dungeon.level.plants.get(pos);
    if (plant != null) {
        plant.wither();
    }
}
Also used : Plant(com.shatteredpixel.shatteredpixeldungeon.plants.Plant) Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char) Heap(com.shatteredpixel.shatteredpixeldungeon.items.Heap) Burning(com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Burning)

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