Search in sources :

Example 1 with Hero

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

the class MissileWeapon method proc.

@Override
public void proc(Char attacker, Char defender, int damage) {
    super.proc(attacker, defender, damage);
    Hero hero = (Hero) attacker;
    if (hero.rangedWeapon == null && stackable) {
        if (quantity == 1) {
            doUnequip(hero, false, false);
        } else {
            detach(null);
        }
    }
}
Also used : Hero(com.watabou.pixeldungeon.actors.hero.Hero)

Example 2 with Hero

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

the class WndTradeItem method sell.

private void sell(Item item) {
    Hero hero = Dungeon.hero;
    if (item.isEquipped(hero) && !((EquipableItem) item).doUnequip(hero, false)) {
        return;
    }
    item.detachAll(hero.belongings.backpack);
    int price = item.price();
    new Gold(price).doPickUp(hero);
    GLog.i(TXT_SOLD, item.name(), price);
}
Also used : Gold(com.watabou.pixeldungeon.items.Gold) Hero(com.watabou.pixeldungeon.actors.hero.Hero) EquipableItem(com.watabou.pixeldungeon.items.EquipableItem)

Example 3 with Hero

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

the class Foliage method evolve.

@Override
protected void evolve() {
    int from = WIDTH + 1;
    int to = Level.LENGTH - WIDTH - 1;
    int[] map = Dungeon.level.map;
    boolean regrowth = false;
    boolean visible = false;
    for (int pos = from; pos < to; pos++) {
        if (cur[pos] > 0) {
            off[pos] = cur[pos];
            volume += off[pos];
            if (map[pos] == Terrain.EMBERS) {
                map[pos] = Terrain.GRASS;
                regrowth = true;
            }
            visible = visible || Dungeon.visible[pos];
        } else {
            off[pos] = 0;
        }
    }
    Hero hero = Dungeon.hero;
    if (hero.isAlive() && hero.visibleEnemies() == 0 && cur[hero.pos] > 0) {
        Buff.affect(hero, Shadows.class).prolong();
    }
    if (regrowth) {
        GameScene.updateMap();
    }
    if (visible) {
        Journal.add(Journal.Feature.GARDEN);
    }
}
Also used : Shadows(com.watabou.pixeldungeon.actors.buffs.Shadows) Hero(com.watabou.pixeldungeon.actors.hero.Hero)

Example 4 with Hero

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

the class SacrificialFire method sacrifice.

public static void sacrifice(Char ch) {
    Wound.hit(ch);
    SacrificialFire fire = (SacrificialFire) Dungeon.level.blobs.get(SacrificialFire.class);
    if (fire != null) {
        int exp = 0;
        if (ch instanceof Mob) {
            exp = ((Mob) ch).exp() * Random.IntRange(1, 3);
        } else if (ch instanceof Hero) {
            exp = ((Hero) ch).maxExp();
        }
        if (exp > 0) {
            int volume = fire.volume - exp;
            if (volume > 0) {
                fire.seed(fire.pos, volume);
                GLog.w(TXT_WORTHY);
            } else {
                fire.seed(fire.pos, 0);
                Journal.remove(Feature.SACRIFICIAL_FIRE);
                GLog.w(TXT_REWARD);
                GameScene.effect(new Flare(7, 32).color(0x66FFFF, true).show(ch.sprite.parent, DungeonTilemap.tileCenterToWorld(fire.pos), 2f));
                Dungeon.level.drop(new ScrollOfWipeOut(), fire.pos).sprite.drop();
            }
        } else {
            GLog.w(TXT_UNWORTHY);
        }
    }
}
Also used : Mob(com.watabou.pixeldungeon.actors.mobs.Mob) Flare(com.watabou.pixeldungeon.effects.Flare) Hero(com.watabou.pixeldungeon.actors.hero.Hero) ScrollOfWipeOut(com.watabou.pixeldungeon.items.scrolls.ScrollOfWipeOut)

Example 5 with Hero

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

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.damage(1, this);
                hero.interrupt();
            }
        } else {
            int bonus = 0;
            for (Buff buff : target.buffs(RingOfSatiety.Satiety.class)) {
                bonus += ((RingOfSatiety.Satiety) buff).level;
            }
            float newLevel = level + STEP - bonus;
            boolean statusUpdated = false;
            if (newLevel >= STARVING) {
                GLog.n(TXT_STARVING);
                statusUpdated = true;
                hero.interrupt();
            } else if (newLevel >= HUNGRY && level < HUNGRY) {
                GLog.w(TXT_HUNGRY);
                statusUpdated = true;
            }
            level = newLevel;
            if (statusUpdated) {
                BuffIndicator.refreshHero();
            }
        }
        float step = ((Hero) target).heroClass == HeroClass.ROGUE ? STEP * 1.2f : STEP;
        spend(target.buff(Shadows.class) == null ? step : step * 1.5f);
    } else {
        diactivate();
    }
    return true;
}
Also used : Hero(com.watabou.pixeldungeon.actors.hero.Hero) RingOfSatiety(com.watabou.pixeldungeon.items.rings.RingOfSatiety)

Aggregations

Hero (com.watabou.pixeldungeon.actors.hero.Hero)14 Item (com.watabou.pixeldungeon.items.Item)3 EquipableItem (com.watabou.pixeldungeon.items.EquipableItem)2 Gold (com.watabou.pixeldungeon.items.Gold)2 MysteryMeat (com.watabou.pixeldungeon.items.food.MysteryMeat)2 Fire (com.watabou.pixeldungeon.actors.blobs.Fire)1 Barkskin (com.watabou.pixeldungeon.actors.buffs.Barkskin)1 Shadows (com.watabou.pixeldungeon.actors.buffs.Shadows)1 Mob (com.watabou.pixeldungeon.actors.mobs.Mob)1 Thief (com.watabou.pixeldungeon.actors.mobs.Thief)1 Flare (com.watabou.pixeldungeon.effects.Flare)1 Dewdrop (com.watabou.pixeldungeon.items.Dewdrop)1 KindOfWeapon (com.watabou.pixeldungeon.items.KindOfWeapon)1 ChargrilledMeat (com.watabou.pixeldungeon.items.food.ChargrilledMeat)1 FrozenCarpaccio (com.watabou.pixeldungeon.items.food.FrozenCarpaccio)1 Herbalism (com.watabou.pixeldungeon.items.rings.RingOfHerbalism.Herbalism)1 RingOfSatiety (com.watabou.pixeldungeon.items.rings.RingOfSatiety)1 Scroll (com.watabou.pixeldungeon.items.scrolls.Scroll)1 ScrollOfWipeOut (com.watabou.pixeldungeon.items.scrolls.ScrollOfWipeOut)1 Knuckles (com.watabou.pixeldungeon.items.weapon.melee.Knuckles)1