Search in sources :

Example 1 with Buff

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

the class WandOfCorruption method debuffEnemy.

private void debuffEnemy(Mob enemy, HashMap<Class<? extends Buff>, Float> category) {
    // do not consider buffs which are already assigned, or that the enemy is immune to.
    HashMap<Class<? extends Buff>, Float> debuffs = new HashMap<>(category);
    for (Buff existing : enemy.buffs()) {
        if (debuffs.containsKey(existing.getClass())) {
            debuffs.put(existing.getClass(), 0f);
        }
    }
    for (Class<? extends Buff> toAssign : debuffs.keySet()) {
        if (debuffs.get(toAssign) > 0 && enemy.isImmune(toAssign)) {
            debuffs.put(toAssign, 0f);
        }
    }
    // all buffs with a > 0 chance are flavor buffs
    Class<? extends FlavourBuff> debuffCls = (Class<? extends FlavourBuff>) Random.chances(debuffs);
    if (debuffCls != null) {
        Buff.append(enemy, debuffCls, 6 + level() * 3);
    } else {
        // if no debuff can be applied (all are present), then go up one tier
        if (category == MINOR_DEBUFFS)
            debuffEnemy(enemy, MAJOR_DEBUFFS);
        else if (category == MAJOR_DEBUFFS)
            corruptEnemy(enemy);
    }
}
Also used : HashMap(java.util.HashMap) FlavourBuff(com.shatteredpixel.shatteredpixeldungeon.actors.buffs.FlavourBuff) FlavourBuff(com.shatteredpixel.shatteredpixeldungeon.actors.buffs.FlavourBuff) Buff(com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff)

Example 2 with Buff

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

the class WandOfCorruption method corruptEnemy.

private void corruptEnemy(Mob enemy) {
    // cannot re-corrupt or doom an enemy, so give them a major debuff instead
    if (enemy.buff(Corruption.class) != null || enemy.buff(Doom.class) != null) {
        GLog.w(Messages.get(this, "already_corrupted"));
        return;
    }
    if (!enemy.isImmune(Corruption.class)) {
        enemy.HP = enemy.HT;
        for (Buff buff : enemy.buffs()) {
            if (buff.type == Buff.buffType.NEGATIVE && !(buff instanceof SoulMark)) {
                buff.detach();
            } else if (buff instanceof PinCushion) {
                buff.detach();
            }
        }
        Buff.affect(enemy, Corruption.class);
        Statistics.enemiesSlain++;
        Badges.validateMonstersSlain();
        Statistics.qualifiedForNoKilling = false;
        if (enemy.EXP > 0 && curUser.lvl <= enemy.maxLvl) {
            curUser.sprite.showStatus(CharSprite.POSITIVE, Messages.get(enemy, "exp", enemy.EXP));
            curUser.earnExp(enemy.EXP);
        }
        enemy.rollToDropLoot();
    } else {
        Buff.affect(enemy, Doom.class);
    }
}
Also used : SoulMark(com.shatteredpixel.shatteredpixeldungeon.actors.buffs.SoulMark) Corruption(com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Corruption) PinCushion(com.shatteredpixel.shatteredpixeldungeon.actors.buffs.PinCushion) FlavourBuff(com.shatteredpixel.shatteredpixeldungeon.actors.buffs.FlavourBuff) Buff(com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff)

Example 3 with Buff

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

the class Hero method actAscend.

private boolean actAscend(HeroAction.Ascend action) {
    int stairs = action.dst;
    if (pos == stairs && pos == Dungeon.level.entrance) {
        if (Dungeon.depth == 1) {
            if (belongings.getItem(Amulet.class) == null) {
                GameScene.show(new WndMessage(Messages.get(this, "leave")));
                ready();
            } else {
                Dungeon.win(Amulet.class);
                Dungeon.deleteGame(GamesInProgress.curSlot, true);
                Game.switchScene(SurfaceScene.class);
            }
        } else {
            curAction = null;
            Buff buff = buff(TimekeepersHourglass.timeFreeze.class);
            if (buff != null)
                buff.detach();
            InterlevelScene.mode = InterlevelScene.Mode.ASCEND;
            Game.switchScene(InterlevelScene.class);
        }
        return false;
    } else if (getCloser(stairs)) {
        return true;
    } else {
        ready();
        return false;
    }
}
Also used : Amulet(com.shatteredpixel.shatteredpixeldungeon.items.Amulet) TimekeepersHourglass(com.shatteredpixel.shatteredpixeldungeon.items.artifacts.TimekeepersHourglass) WndMessage(com.shatteredpixel.shatteredpixeldungeon.windows.WndMessage) Buff(com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff) FlavourBuff(com.shatteredpixel.shatteredpixeldungeon.actors.buffs.FlavourBuff)

Example 4 with Buff

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

the class Level method updateFieldOfView.

public void updateFieldOfView(Char c, boolean[] fieldOfView) {
    int cx = c.pos % width();
    int cy = c.pos / width();
    boolean sighted = c.buff(Blindness.class) == null && c.buff(Shadows.class) == null && c.buff(TimekeepersHourglass.timeStasis.class) == null && c.isAlive();
    if (sighted) {
        ShadowCaster.castShadow(cx, cy, fieldOfView, c.viewDistance);
    } else {
        BArray.setFalse(fieldOfView);
    }
    int sense = 1;
    // Currently only the hero can get mind vision
    if (c.isAlive() && c == Dungeon.hero) {
        for (Buff b : c.buffs(MindVision.class)) {
            sense = Math.max(((MindVision) b).distance, sense);
        }
    }
    if ((sighted && sense > 1) || !sighted) {
        int ax = Math.max(0, cx - sense);
        int bx = Math.min(cx + sense, width() - 1);
        int ay = Math.max(0, cy - sense);
        int by = Math.min(cy + sense, height() - 1);
        int len = bx - ax + 1;
        int pos = ax + ay * width();
        for (int y = ay; y <= by; y++, pos += width()) {
            System.arraycopy(discoverable, pos, fieldOfView, pos, len);
        }
    }
    // Currently only the hero can get mind vision or awareness
    if (c.isAlive() && c == Dungeon.hero) {
        Dungeon.hero.mindVisionEnemies.clear();
        if (c.buff(MindVision.class) != null) {
            for (Mob mob : mobs) {
                int p = mob.pos;
                if (!fieldOfView[p]) {
                    Dungeon.hero.mindVisionEnemies.add(mob);
                }
            }
        } else if (((Hero) c).heroClass == HeroClass.HUNTRESS) {
            for (Mob mob : mobs) {
                int p = mob.pos;
                if (distance(c.pos, p) == 2) {
                    if (!fieldOfView[p]) {
                        Dungeon.hero.mindVisionEnemies.add(mob);
                    }
                }
            }
        }
        for (Mob m : Dungeon.hero.mindVisionEnemies) {
            for (int i : PathFinder.NEIGHBOURS9) {
                fieldOfView[m.pos + i] = true;
            }
        }
        if (c.buff(Awareness.class) != null) {
            for (Heap heap : heaps.values()) {
                int p = heap.pos;
                for (int i : PathFinder.NEIGHBOURS9) fieldOfView[p + i] = true;
            }
        }
    }
    if (c == Dungeon.hero) {
        for (Heap heap : heaps.values()) if (!heap.seen && fieldOfView[heap.pos])
            heap.seen = true;
    }
}
Also used : Mob(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob) Awareness(com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Awareness) Hero(com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero) Buff(com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff) MindVision(com.shatteredpixel.shatteredpixeldungeon.actors.buffs.MindVision) Point(com.watabou.utils.Point) Heap(com.shatteredpixel.shatteredpixeldungeon.items.Heap)

Example 5 with Buff

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

the class Actor method add.

private static synchronized void add(Actor actor, float time) {
    if (all.contains(actor)) {
        return;
    }
    ids.put(actor.id(), actor);
    all.add(actor);
    actor.time += time;
    actor.onAdd();
    if (actor instanceof Char) {
        Char ch = (Char) actor;
        chars.add(ch);
        for (Buff buff : ch.buffs()) {
            all.add(buff);
            buff.onAdd();
        }
    }
}
Also used : Buff(com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff)

Aggregations

Buff (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff)13 FlavourBuff (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.FlavourBuff)5 TimekeepersHourglass (com.shatteredpixel.shatteredpixeldungeon.items.artifacts.TimekeepersHourglass)4 Char (com.shatteredpixel.shatteredpixeldungeon.actors.Char)3 Mob (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob)2 Awareness (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Awareness)1 Corruption (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Corruption)1 MindVision (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.MindVision)1 PinCushion (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.PinCushion)1 SoulMark (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.SoulMark)1 Hero (com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero)1 HeroSubClass (com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroSubClass)1 Bee (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Bee)1 King (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.King)1 Mimic (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mimic)1 Piranha (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Piranha)1 Statue (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Statue)1 Swarm (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Swarm)1 Wraith (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Wraith)1 Yog (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Yog)1