Search in sources :

Example 6 with Buff

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

the class Chasm method heroFall.

public static void heroFall(int pos) {
    jumpConfirmed = false;
    Sample.INSTANCE.play(Assets.SND_FALLING);
    Buff buff = Dungeon.hero.buff(TimekeepersHourglass.timeFreeze.class);
    if (buff != null)
        buff.detach();
    if (Dungeon.hero.isAlive()) {
        Dungeon.hero.interrupt();
        InterlevelScene.mode = InterlevelScene.Mode.FALL;
        if (Dungeon.level instanceof RegularLevel) {
            Room room = ((RegularLevel) Dungeon.level).room(pos);
            InterlevelScene.fallIntoPit = room != null && room instanceof WeakFloorRoom;
        } else {
            InterlevelScene.fallIntoPit = false;
        }
        Game.switchScene(InterlevelScene.class);
    } else {
        Dungeon.hero.sprite.visible = false;
    }
}
Also used : TimekeepersHourglass(com.shatteredpixel.shatteredpixeldungeon.items.artifacts.TimekeepersHourglass) WeakFloorRoom(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.WeakFloorRoom) Buff(com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff) Room(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room) WeakFloorRoom(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.WeakFloorRoom) RegularLevel(com.shatteredpixel.shatteredpixeldungeon.levels.RegularLevel)

Example 7 with Buff

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

the class LloydsBeacon method execute.

@Override
public void execute(Hero hero, String action) {
    super.execute(hero, action);
    if (action == AC_SET || action == AC_RETURN) {
        if (Dungeon.bossLevel()) {
            hero.spend(LloydsBeacon.TIME_TO_USE);
            GLog.w(Messages.get(this, "preventing"));
            return;
        }
        for (int i = 0; i < PathFinder.NEIGHBOURS8.length; i++) {
            Char ch = Actor.findChar(hero.pos + PathFinder.NEIGHBOURS8[i]);
            if (ch != null && ch.alignment == Char.Alignment.ENEMY) {
                GLog.w(Messages.get(this, "creatures"));
                return;
            }
        }
    }
    if (action == AC_ZAP) {
        curUser = hero;
        int chargesToUse = Dungeon.depth > 20 ? 2 : 1;
        if (!isEquipped(hero)) {
            GLog.i(Messages.get(Artifact.class, "need_to_equip"));
            QuickSlotButton.cancel();
        } else if (charge < chargesToUse) {
            GLog.i(Messages.get(this, "no_charge"));
            QuickSlotButton.cancel();
        } else {
            GameScene.selectCell(zapper);
        }
    } else if (action == AC_SET) {
        returnDepth = Dungeon.depth;
        returnPos = hero.pos;
        hero.spend(LloydsBeacon.TIME_TO_USE);
        hero.busy();
        hero.sprite.operate(hero.pos);
        Sample.INSTANCE.play(Assets.SND_BEACON);
        GLog.i(Messages.get(this, "return"));
    } else if (action == AC_RETURN) {
        if (returnDepth == Dungeon.depth) {
            ScrollOfTeleportation.appear(hero, returnPos);
            Dungeon.level.press(returnPos, hero);
            Dungeon.observe();
            GameScene.updateFog();
        } else {
            Buff buff = Dungeon.hero.buff(TimekeepersHourglass.timeFreeze.class);
            if (buff != null)
                buff.detach();
            InterlevelScene.mode = InterlevelScene.Mode.RETURN;
            InterlevelScene.returnDepth = returnDepth;
            InterlevelScene.returnPos = returnPos;
            Game.switchScene(InterlevelScene.class);
        }
    }
}
Also used : Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char) Buff(com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff)

Example 8 with Buff

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

the class CursedWand method rareEffect.

private static void rareEffect(final Wand wand, final Hero user, final Ballistica bolt) {
    switch(Random.Int(4)) {
        // sheep transformation
        case 0:
            cursedFX(user, bolt, new Callback() {

                public void call() {
                    Char ch = Actor.findChar(bolt.collisionPos);
                    if (ch != null && ch != user && !ch.properties().contains(Char.Property.BOSS) && !ch.properties().contains(Char.Property.MINIBOSS)) {
                        Sheep sheep = new Sheep();
                        sheep.lifespan = 10;
                        sheep.pos = ch.pos;
                        ch.destroy();
                        ch.sprite.killAndErase();
                        Dungeon.level.mobs.remove(ch);
                        TargetHealthIndicator.instance.target(null);
                        GameScene.add(sheep);
                        CellEmitter.get(sheep.pos).burst(Speck.factory(Speck.WOOL), 4);
                    } else {
                        GLog.i(Messages.get(CursedWand.class, "nothing"));
                    }
                    wand.wandUsed();
                }
            });
            break;
        // curses!
        case 1:
            CursingTrap.curse(user);
            wand.wandUsed();
            break;
        // inter-level teleportation
        case 2:
            if (Dungeon.depth > 1 && !Dungeon.bossLevel()) {
                // each depth has 1 more weight than the previous depth.
                float[] depths = new float[Dungeon.depth - 1];
                for (int i = 1; i < Dungeon.depth; i++) depths[i - 1] = i;
                int depth = 1 + Random.chances(depths);
                Buff buff = Dungeon.hero.buff(TimekeepersHourglass.timeFreeze.class);
                if (buff != null)
                    buff.detach();
                InterlevelScene.mode = InterlevelScene.Mode.RETURN;
                InterlevelScene.returnDepth = depth;
                InterlevelScene.returnPos = -1;
                Game.switchScene(InterlevelScene.class);
            } else {
                ScrollOfTeleportation.teleportHero(user);
                wand.wandUsed();
            }
            break;
        // summon monsters
        case 3:
            new SummoningTrap().set(user.pos).activate();
            wand.wandUsed();
            break;
    }
}
Also used : Callback(com.watabou.utils.Callback) TimekeepersHourglass(com.shatteredpixel.shatteredpixeldungeon.items.artifacts.TimekeepersHourglass) Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char) Sheep(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Sheep) SummoningTrap(com.shatteredpixel.shatteredpixeldungeon.levels.traps.SummoningTrap) Buff(com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff)

Example 9 with Buff

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

the class WandOfCorruption method onZap.

@Override
protected void onZap(Ballistica bolt) {
    Char ch = Actor.findChar(bolt.collisionPos);
    if (ch != null) {
        if (!(ch instanceof Mob)) {
            return;
        }
        Mob enemy = (Mob) ch;
        float corruptingPower = 2 + level();
        // base enemy resistance is usually based on their exp, but in special cases it is based on other criteria
        float enemyResist = 1 + enemy.EXP;
        if (ch instanceof Mimic || ch instanceof Statue) {
            enemyResist = 1 + Dungeon.depth;
        } else if (ch instanceof Piranha || ch instanceof Bee) {
            enemyResist = 1 + Dungeon.depth / 2f;
        } else if (ch instanceof Wraith) {
            // this is so low because wraiths are always at max hp
            enemyResist = 0.5f + Dungeon.depth / 8f;
        } else if (ch instanceof Yog.BurningFist || ch instanceof Yog.RottingFist) {
            enemyResist = 1 + 30;
        } else if (ch instanceof Yog.Larva || ch instanceof King.Undead) {
            enemyResist = 1 + 5;
        } else if (ch instanceof Swarm) {
            // child swarms don't give exp, so we force this here.
            enemyResist = 1 + 3;
        }
        // 100% health: 3x resist   75%: 2.1x resist   50%: 1.5x resist   25%: 1.1x resist
        enemyResist *= 1 + 2 * Math.pow(enemy.HP / (float) enemy.HT, 2);
        // debuffs placed on the enemy reduce their resistance
        for (Buff buff : enemy.buffs()) {
            if (MAJOR_DEBUFFS.containsKey(buff.getClass()))
                enemyResist *= MAJOR_DEBUFF_WEAKEN;
            else if (MINOR_DEBUFFS.containsKey(buff.getClass()))
                enemyResist *= MINOR_DEBUFF_WEAKEN;
            else if (buff.type == Buff.buffType.NEGATIVE)
                enemyResist *= MINOR_DEBUFF_WEAKEN;
        }
        // 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) {
            enemyResist = corruptingPower * .99f;
        }
        if (corruptingPower > enemyResist) {
            corruptEnemy(enemy);
        } else {
            float debuffChance = corruptingPower / enemyResist;
            if (Random.Float() < debuffChance) {
                debuffEnemy(enemy, MAJOR_DEBUFFS);
            } else {
                debuffEnemy(enemy, MINOR_DEBUFFS);
            }
        }
        processSoulMark(ch, chargesPerCast());
    } else {
        Dungeon.level.press(bolt.collisionPos, null, true);
    }
}
Also used : Mob(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob) Bee(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Bee) Mimic(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mimic) Piranha(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Piranha) FlavourBuff(com.shatteredpixel.shatteredpixeldungeon.actors.buffs.FlavourBuff) Buff(com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff) Yog(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Yog) Swarm(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Swarm) King(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.King) Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char) Statue(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Statue) Wraith(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Wraith)

Example 10 with Buff

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

the class Char method restoreFromBundle.

@Override
public void restoreFromBundle(Bundle bundle) {
    super.restoreFromBundle(bundle);
    pos = bundle.getInt(POS);
    HP = bundle.getInt(TAG_HP);
    HT = bundle.getInt(TAG_HT);
    SHLD = bundle.getInt(TAG_SHLD);
    for (Bundlable b : bundle.getCollection(BUFFS)) {
        if (b != null) {
            ((Buff) b).attachTo(this);
        }
    }
}
Also used : Bundlable(com.watabou.utils.Bundlable) 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