Search in sources :

Example 11 with Hero

use of com.watabou.pixeldungeon.actors.hero.Hero in project pixel-dungeon-remix by NYRDS.

the class Hunger method act.

@Override
public boolean act() {
    if (target.isAlive()) {
        Hero hero = (Hero) target;
        if (isStarving()) {
            if (Random.Float() < 0.3f && (target.hp() > 1 || !target.paralysed)) {
                GLog.n(TXT_STARVING[hero.getGender()]);
                if (hero.getDifficulty() >= 3) {
                    hero.damage(Math.max(hero.effectiveSTR() - 10, 1), this);
                } else {
                    hero.damage(1, this);
                }
                hero.interrupt();
            }
            if (hero.getDifficulty() >= 3 && !Dungeon.level.isSafe()) {
                if (Random.Float() < 0.01) {
                    Buff.prolong(hero, Weakness.class, Weakness.duration(hero));
                }
                if (Random.Float() < 0.01) {
                    Buff.prolong(hero, Vertigo.class, Vertigo.duration(hero));
                }
            }
        } else {
            int bonus = 0;
            for (Buff buff : target.buffs(RingOfSatiety.Satiety.class)) {
                bonus += ((RingOfSatiety.Satiety) buff).level;
            }
            float delta = STEP - bonus;
            if (PixelDungeon.realtime()) {
                delta *= 0.3;
            }
            if (hero.getDifficulty() == 0) {
                delta *= 0.8;
            }
            if (Dungeon.level.isSafe()) {
                delta = 0;
            }
            float newLevel = level + delta;
            boolean statusUpdated = false;
            if (newLevel >= STARVING) {
                GLog.n(TXT_STARVING[hero.getGender()]);
                statusUpdated = true;
                hero.interrupt();
            } else if (newLevel >= HUNGRY && level < HUNGRY) {
                GLog.w(TXT_HUNGRY[hero.getGender()]);
                statusUpdated = true;
            }
            level = newLevel;
            if (statusUpdated) {
                BuffIndicator.refreshHero();
            }
        }
        float step = hero.heroClass == HeroClass.ROGUE ? STEP * 1.2f : STEP;
        spend(target.hasBuff(Shadows.class) ? step * 1.5f : step);
    } else {
        deactivate();
    }
    return true;
}
Also used : Hero(com.watabou.pixeldungeon.actors.hero.Hero) RingOfSatiety(com.watabou.pixeldungeon.items.rings.RingOfSatiety)

Example 12 with Hero

use of com.watabou.pixeldungeon.actors.hero.Hero in project pixel-dungeon-remix by NYRDS.

the class Level method press.

public void press(int cell, Presser actor) {
    Char chr = null;
    if (actor != null) {
        if (actor instanceof Char) {
            chr = (Char) actor;
            if (pit[cell] && !chr.isFlying()) {
                Chasm.charFall(chr.getPos(), chr);
                return;
            }
            if (actor instanceof Hero) {
                pressHero(cell, (Hero) chr);
            }
        }
        if (actor instanceof LevelObject) {
            if (pit[cell]) {
                ((LevelObject) actor).fall();
                return;
            }
        }
        if (actor instanceof Item || actor instanceof LevelObject) {
            set(cell, Terrain.discover(map[cell]));
        }
        if (actor.affectLevelObjects()) {
            LevelObject levelObject = getTopLevelObject(cell);
            if (levelObject != null && levelObject != actor) {
                levelObject.bump(actor);
            }
        }
    }
    switch(map[cell]) {
        case Terrain.TOXIC_TRAP:
            ToxicTrap.trigger(cell, chr);
            break;
        case Terrain.FIRE_TRAP:
            FireTrap.trigger(cell, chr);
            break;
        case Terrain.PARALYTIC_TRAP:
            ParalyticTrap.trigger(cell, chr);
            break;
        case Terrain.POISON_TRAP:
            PoisonTrap.trigger(cell, chr);
            break;
        case Terrain.ALARM_TRAP:
            AlarmTrap.trigger(cell, chr);
            break;
        case Terrain.LIGHTNING_TRAP:
            LightningTrap.trigger(cell, chr);
            break;
        case Terrain.GRIPPING_TRAP:
            GrippingTrap.trigger(cell, chr);
            break;
        case Terrain.SUMMONING_TRAP:
            SummoningTrap.trigger(cell, chr);
            break;
        case Terrain.DOOR:
            Door.enter(cell);
            break;
    }
    if (!(actor instanceof Mob)) {
        switch(map[cell]) {
            case Terrain.HIGH_GRASS:
                HighGrass.trample(this, cell, chr);
                break;
            case Terrain.WELL:
                WellWater.affectCell(cell);
                break;
            case Terrain.ALCHEMY:
                Alchemy.transmute(cell);
                break;
        }
    }
    if (TerrainFlags.is(map[cell], TerrainFlags.TRAP)) {
        if (Dungeon.visible[cell]) {
            Sample.INSTANCE.play(Assets.SND_TRAP);
        }
        if (actor instanceof Hero) {
            ((Hero) actor).interrupt();
        }
        set(cell, Terrain.INACTIVE_TRAP);
        GameScene.updateMap(cell);
    }
    Plant plant = plants.get(cell);
    if (plant != null) {
        plant.activate(chr);
    }
}
Also used : Item(com.watabou.pixeldungeon.items.Item) Mob(com.watabou.pixeldungeon.actors.mobs.Mob) Plant(com.watabou.pixeldungeon.plants.Plant) LevelObject(com.nyrds.pixeldungeon.levels.objects.LevelObject) Char(com.watabou.pixeldungeon.actors.Char) Hero(com.watabou.pixeldungeon.actors.hero.Hero)

Example 13 with Hero

use of com.watabou.pixeldungeon.actors.hero.Hero in project pixel-dungeon-remix by NYRDS.

the class HighGrass method trample.

public static void trample(Level level, int pos, Char ch) {
    level.set(pos, Terrain.GRASS);
    GameScene.updateMap(pos);
    if (!Dungeon.isChallenged(Challenges.NO_HERBALISM)) {
        int herbalismLevel = 0;
        if (ch != null) {
            Herbalism herbalism = ch.buff(Herbalism.class);
            if (herbalism != null) {
                herbalismLevel = herbalism.level;
            }
        }
        // Seed
        if (herbalismLevel >= 0 && Random.Int(18) <= Random.Int(herbalismLevel + 1)) {
            ItemSprite is = level.drop(Generator.random(Generator.Category.SEED), pos).sprite;
            if (is != null) {
                is.drop();
            }
        }
        // Dew
        if (herbalismLevel >= 0 && Random.Int(6) <= Random.Int(herbalismLevel + 1)) {
            ItemSprite is = level.drop(new Dewdrop(), pos).sprite;
            if (is != null) {
                is.drop();
            }
        }
    }
    int leaves = 4;
    // Barkskin
    if (ch instanceof Hero && ((Hero) ch).subClass == HeroSubClass.WARDEN) {
        Buff.affect(ch, Barkskin.class).level(ch.ht() / 3);
        leaves = 8;
    }
    if (ch instanceof Hero && ((Hero) ch).subClass == HeroSubClass.SCOUT) {
        Buff.prolong(ch, Invisibility.class, 5);
        leaves = 2;
    }
    Emitter emitter = CellEmitter.get(pos);
    if (emitter != null) {
        emitter.burst(LeafParticle.LEVEL_SPECIFIC, leaves);
    }
    Dungeon.observe();
}
Also used : CellEmitter(com.watabou.pixeldungeon.effects.CellEmitter) Emitter(com.watabou.noosa.particles.Emitter) Dewdrop(com.watabou.pixeldungeon.items.Dewdrop) Hero(com.watabou.pixeldungeon.actors.hero.Hero) Barkskin(com.watabou.pixeldungeon.actors.buffs.Barkskin) Herbalism(com.watabou.pixeldungeon.items.rings.RingOfHerbalism.Herbalism) ItemSprite(com.watabou.pixeldungeon.sprites.ItemSprite)

Example 14 with Hero

use of com.watabou.pixeldungeon.actors.hero.Hero in project pixel-dungeon-remix by NYRDS.

the class MissileWeapon method proc.

@Override
public void proc(Char attacker, Char defender, int damage) {
    super.proc(attacker, defender, damage);
    if (this instanceof Arrow) {
        Arrow arrow = (Arrow) this;
        if (arrow.firedFrom != null && arrow.firedFrom.isEnchanted()) {
            arrow.firedFrom.getEnchantment().proc(arrow.firedFrom, attacker, defender, damage);
        }
    }
    Hero hero = (Hero) attacker;
    if (hero.rangedWeapon == null && stackable) {
        if (this != hero.belongings.weapon) {
            if (quantity() == 1) {
                doUnequip(hero, false, false);
            } else {
                detach(null);
            }
        }
    }
}
Also used : Hero(com.watabou.pixeldungeon.actors.hero.Hero)

Example 15 with Hero

use of com.watabou.pixeldungeon.actors.hero.Hero in project pixel-dungeon-remix by NYRDS.

the class Multiplicity method proc.

@Override
public int proc(Armor armor, Char attacker, Char defender, int damage) {
    int level = Math.max(0, armor.level());
    if (Random.Int(level / 2 + 6) >= 5) {
        int imgCell = Dungeon.level.getEmptyCellNextTo(defender.getPos());
        if (Dungeon.level.cellValid(imgCell)) {
            if (defender instanceof Hero) {
                MirrorImage img = new MirrorImage((Hero) defender);
                Dungeon.level.spawnMob(img);
                WandOfBlink.appear(img, imgCell);
            }
            if (defender instanceof Mob) {
                ((Mob) defender).split(imgCell, damage);
            }
            defender.damage(Random.IntRange(1, defender.ht() / 6), /*attacker*/
            this);
            checkOwner(defender);
        }
    }
    return damage;
}
Also used : MirrorImage(com.watabou.pixeldungeon.actors.mobs.npcs.MirrorImage) Mob(com.watabou.pixeldungeon.actors.mobs.Mob) Hero(com.watabou.pixeldungeon.actors.hero.Hero)

Aggregations

Hero (com.watabou.pixeldungeon.actors.hero.Hero)44 Mob (com.watabou.pixeldungeon.actors.mobs.Mob)8 Item (com.watabou.pixeldungeon.items.Item)8 Char (com.watabou.pixeldungeon.actors.Char)6 Gold (com.watabou.pixeldungeon.items.Gold)5 EquipableItem (com.watabou.pixeldungeon.items.EquipableItem)4 BlackSkull (com.nyrds.pixeldungeon.items.necropolis.BlackSkull)2 Fire (com.watabou.pixeldungeon.actors.blobs.Fire)2 Barkskin (com.watabou.pixeldungeon.actors.buffs.Barkskin)2 Shadows (com.watabou.pixeldungeon.actors.buffs.Shadows)2 Thief (com.watabou.pixeldungeon.actors.mobs.Thief)2 Dewdrop (com.watabou.pixeldungeon.items.Dewdrop)2 KindOfWeapon (com.watabou.pixeldungeon.items.KindOfWeapon)2 MysteryMeat (com.watabou.pixeldungeon.items.food.MysteryMeat)2 Herbalism (com.watabou.pixeldungeon.items.rings.RingOfHerbalism.Herbalism)2 RingOfSatiety (com.watabou.pixeldungeon.items.rings.RingOfSatiety)2 Knuckles (com.watabou.pixeldungeon.items.weapon.melee.Knuckles)2 Level (com.watabou.pixeldungeon.levels.Level)2 SuppressLint (android.annotation.SuppressLint)1 TrackedRuntimeException (com.nyrds.android.util.TrackedRuntimeException)1