Search in sources :

Example 36 with Char

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

the class GrippingTrap method activate.

@Override
public void activate() {
    Char c = Actor.findChar(pos);
    if (c != null) {
        int damage = Math.max(0, (2 + Dungeon.depth) - c.drRoll());
        Buff.affect(c, Bleeding.class).set(damage);
        Buff.prolong(c, Cripple.class, Cripple.DURATION);
        Wound.hit(c);
    } else {
        Wound.hit(pos);
    }
}
Also used : Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char) Bleeding(com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Bleeding)

Example 37 with Char

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

the class RockfallTrap method activate.

@Override
public void activate() {
    ArrayList<Integer> rockCells = new ArrayList<>();
    if (Dungeon.level instanceof RegularLevel) {
        Room r = ((RegularLevel) Dungeon.level).room(pos);
        int cell;
        for (Point p : r.getPoints()) {
            cell = Dungeon.level.pointToCell(p);
            if (!Dungeon.level.solid[cell]) {
                rockCells.add(cell);
            }
        }
    // if we don't have rooms, then just do 5x5
    } else {
        PathFinder.buildDistanceMap(pos, BArray.not(Dungeon.level.solid, null), 2);
        for (int i = 0; i < PathFinder.distance.length; i++) {
            if (PathFinder.distance[i] < Integer.MAX_VALUE) {
                rockCells.add(i);
            }
        }
    }
    boolean seen = false;
    for (int cell : rockCells) {
        if (Dungeon.level.heroFOV[cell]) {
            CellEmitter.get(cell - Dungeon.level.width()).start(Speck.factory(Speck.ROCK), 0.07f, 10);
            seen = true;
        }
        Char ch = Actor.findChar(cell);
        if (ch != null) {
            int damage = Random.NormalIntRange(5 + Dungeon.depth, 10 + Dungeon.depth * 2);
            damage -= ch.drRoll();
            ch.damage(Math.max(damage, 0), this);
            Buff.prolong(ch, Paralysis.class, Paralysis.DURATION);
            if (!ch.isAlive() && ch == Dungeon.hero) {
                Dungeon.fail(getClass());
                GLog.n(Messages.get(this, "ondeath"));
            }
        }
    }
    if (seen) {
        Camera.main.shake(3, 0.7f);
        Sample.INSTANCE.play(Assets.SND_ROCKS);
    }
}
Also used : Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char) ArrayList(java.util.ArrayList) Point(com.watabou.utils.Point) Room(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room) Point(com.watabou.utils.Point) RegularLevel(com.shatteredpixel.shatteredpixeldungeon.levels.RegularLevel)

Example 38 with Char

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

the class TeleportationTrap method activate.

@Override
public void activate() {
    CellEmitter.get(pos).start(Speck.factory(Speck.LIGHT), 0.2f, 3);
    Sample.INSTANCE.play(Assets.SND_TELEPORT);
    Char ch = Actor.findChar(pos);
    if (ch instanceof Hero) {
        ScrollOfTeleportation.teleportHero((Hero) ch);
    } else if (ch != null) {
        int count = 10;
        int pos;
        do {
            pos = Dungeon.level.randomRespawnCell();
            if (count-- <= 0) {
                break;
            }
        } while (pos == -1);
        if (pos == -1 || Dungeon.bossLevel()) {
            GLog.w(Messages.get(ScrollOfTeleportation.class, "no_tele"));
        } else {
            ch.pos = pos;
            if (ch instanceof Mob && ((Mob) ch).state == ((Mob) ch).HUNTING) {
                ((Mob) ch).state = ((Mob) ch).WANDERING;
            }
            ch.sprite.place(ch.pos);
            ch.sprite.visible = Dungeon.level.heroFOV[pos];
        }
    }
    Heap heap = Dungeon.level.heaps.get(pos);
    if (heap != null) {
        int cell = Dungeon.level.randomRespawnCell();
        Item item = heap.pickUp();
        if (cell != -1) {
            Dungeon.level.drop(item, cell);
        }
    }
}
Also used : Mob(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob) Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char) Hero(com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero) Heap(com.shatteredpixel.shatteredpixeldungeon.items.Heap)

Example 39 with Char

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

the class Fadeleaf method activate.

@Override
public void activate() {
    Char ch = Actor.findChar(pos);
    if (ch instanceof Hero) {
        ScrollOfTeleportation.teleportHero((Hero) ch);
        ((Hero) ch).curAction = null;
    } else if (ch instanceof Mob && !ch.properties().contains(Char.Property.IMMOVABLE)) {
        int count = 10;
        int newPos;
        do {
            newPos = Dungeon.level.randomRespawnCell();
            if (count-- <= 0) {
                break;
            }
        } while (newPos == -1);
        if (newPos != -1 && !Dungeon.bossLevel()) {
            ch.pos = newPos;
            if (((Mob) ch).state == ((Mob) ch).HUNTING)
                ((Mob) ch).state = ((Mob) ch).WANDERING;
            ch.sprite.place(ch.pos);
            ch.sprite.visible = Dungeon.level.heroFOV[ch.pos];
        }
    }
    if (Dungeon.level.heroFOV[pos]) {
        CellEmitter.get(pos).start(Speck.factory(Speck.LIGHT), 0.2f, 3);
    }
}
Also used : Mob(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob) Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char) Hero(com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero)

Example 40 with Char

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

the class Blindweed method activate.

@Override
public void activate() {
    Char ch = Actor.findChar(pos);
    if (ch != null) {
        int len = Random.Int(5, 10);
        Buff.prolong(ch, Blindness.class, len);
        Buff.prolong(ch, Cripple.class, len);
        if (ch instanceof Mob) {
            if (((Mob) ch).state == ((Mob) ch).HUNTING)
                ((Mob) ch).state = ((Mob) ch).WANDERING;
            ((Mob) ch).beckon(Dungeon.level.randomDestination());
        }
    }
    if (Dungeon.level.heroFOV[pos]) {
        CellEmitter.get(pos).burst(Speck.factory(Speck.LIGHT), 4);
    }
}
Also used : Mob(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob) 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