Search in sources :

Example 6 with Hero

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

the class Dungeon method init.

public static void init() {
    version = Game.versionCode;
    challenges = SPDSettings.challenges();
    seed = DungeonSeed.randomSeed();
    Actor.clear();
    Actor.resetNextID();
    Random.seed(seed);
    Scroll.initLabels();
    Potion.initColors();
    Ring.initGems();
    SpecialRoom.initForRun();
    SecretRoom.initForRun();
    Random.seed();
    Statistics.reset();
    Notes.reset();
    quickslot.reset();
    QuickSlotButton.reset();
    depth = 0;
    gold = 0;
    droppedItems = new SparseArray<ArrayList<Item>>();
    for (LimitedDrops a : LimitedDrops.values()) a.count = 0;
    chapters = new HashSet<Integer>();
    Ghost.Quest.reset();
    Wandmaker.Quest.reset();
    Blacksmith.Quest.reset();
    Imp.Quest.reset();
    Generator.reset();
    Generator.initArtifacts();
    hero = new Hero();
    hero.live();
    Badges.reset();
    GamesInProgress.selectedClass.initHero(hero);
}
Also used : ArrayList(java.util.ArrayList) Hero(com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero)

Example 7 with Hero

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

the class Burning method act.

@Override
public boolean act() {
    if (target.isAlive()) {
        int damage = Random.NormalIntRange(1, 3 + target.HT / 40);
        Buff.detach(target, Chill.class);
        if (target instanceof Hero) {
            Hero hero = (Hero) target;
            if (hero.belongings.armor != null && hero.belongings.armor.hasGlyph(Brimstone.class)) {
                Buff.affect(target, Brimstone.BrimstoneShield.class);
            } else {
                hero.damage(damage, this);
                burnIncrement++;
                // at 4+ turns, there is a (turns-3)/3 chance an item burns
                if (Random.Int(3) < (burnIncrement - 3)) {
                    burnIncrement = 0;
                    ArrayList<Item> burnable = new ArrayList<>();
                    // does not reach inside of containers
                    for (Item i : hero.belongings.backpack.items) {
                        if ((i instanceof Scroll && !(i instanceof ScrollOfUpgrade || i instanceof ScrollOfMagicalInfusion)) || i instanceof MysteryMeat) {
                            burnable.add(i);
                        }
                    }
                    if (!burnable.isEmpty()) {
                        Item toBurn = Random.element(burnable).detach(hero.belongings.backpack);
                        if (toBurn instanceof MysteryMeat) {
                            ChargrilledMeat steak = new ChargrilledMeat();
                            if (!steak.collect(hero.belongings.backpack)) {
                                Dungeon.level.drop(steak, hero.pos).sprite.drop();
                            }
                        }
                        Heap.burnFX(hero.pos);
                        GLog.w(Messages.get(this, "burnsup", Messages.capitalize(toBurn.toString())));
                    }
                }
            }
        } else {
            target.damage(damage, this);
        }
        if (target instanceof Thief) {
            Item item = ((Thief) target).item;
            if (item instanceof Scroll && !(item instanceof ScrollOfUpgrade || item instanceof ScrollOfMagicalInfusion)) {
                target.sprite.emitter().burst(ElmoParticle.FACTORY, 6);
                ((Thief) target).item = null;
            } else if (item instanceof MysteryMeat) {
                target.sprite.emitter().burst(ElmoParticle.FACTORY, 6);
                ((Thief) target).item = new ChargrilledMeat();
            }
        }
    } else {
        Brimstone.BrimstoneShield brimShield = target.buff(Brimstone.BrimstoneShield.class);
        if (brimShield != null)
            brimShield.startDecay();
        detach();
    }
    if (Dungeon.level.flamable[target.pos] && Blob.volumeAt(target.pos, Fire.class) == 0) {
        GameScene.add(Blob.seed(target.pos, 4, Fire.class));
    }
    spend(TICK);
    left -= TICK;
    if (left <= 0 || (Dungeon.level.water[target.pos] && !target.flying)) {
        detach();
    }
    return true;
}
Also used : ChargrilledMeat(com.shatteredpixel.shatteredpixeldungeon.items.food.ChargrilledMeat) Thief(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Thief) Scroll(com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll) ArrayList(java.util.ArrayList) Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Brimstone(com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.Brimstone) Fire(com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Fire) Hero(com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero) ScrollOfMagicalInfusion(com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfMagicalInfusion) MysteryMeat(com.shatteredpixel.shatteredpixeldungeon.items.food.MysteryMeat) ScrollOfUpgrade(com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfUpgrade)

Example 8 with Hero

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

the class Frost method attachTo.

@Override
public boolean attachTo(Char target) {
    if (super.attachTo(target)) {
        target.paralysed++;
        Buff.detach(target, Burning.class);
        Buff.detach(target, Chill.class);
        if (target instanceof Hero) {
            Hero hero = (Hero) target;
            ArrayList<Item> freezable = new ArrayList<>();
            // does not reach inside of containers
            for (Item i : hero.belongings.backpack.items) {
                if ((i instanceof Potion && !(i instanceof PotionOfStrength || i instanceof PotionOfMight)) || i instanceof MysteryMeat) {
                    freezable.add(i);
                }
            }
            if (!freezable.isEmpty()) {
                Item toFreeze = Random.element(freezable).detach(hero.belongings.backpack);
                if (toFreeze instanceof Potion) {
                    ((Potion) toFreeze).shatter(hero.pos);
                } else if (toFreeze instanceof MysteryMeat) {
                    FrozenCarpaccio carpaccio = new FrozenCarpaccio();
                    if (!carpaccio.collect(hero.belongings.backpack)) {
                        Dungeon.level.drop(carpaccio, target.pos).sprite.drop();
                    }
                }
                GLog.w(Messages.get(this, "freezes", toFreeze.toString()));
            }
        } else if (target instanceof Thief) {
            Item item = ((Thief) target).item;
            if (item instanceof Potion && !(item instanceof PotionOfStrength || item instanceof PotionOfMight)) {
                ((Potion) ((Thief) target).item).shatter(target.pos);
                ((Thief) target).item = null;
            } else if (item instanceof MysteryMeat) {
                ((Thief) target).item = new FrozenCarpaccio();
                ;
            }
        }
        return true;
    } else {
        return false;
    }
}
Also used : Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) FrozenCarpaccio(com.shatteredpixel.shatteredpixeldungeon.items.food.FrozenCarpaccio) PotionOfMight(com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfMight) Potion(com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion) PotionOfStrength(com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfStrength) Thief(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Thief) Hero(com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero) ArrayList(java.util.ArrayList) MysteryMeat(com.shatteredpixel.shatteredpixeldungeon.items.food.MysteryMeat)

Example 9 with Hero

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

the class Hunger method act.

@Override
public boolean act() {
    if (Dungeon.level.locked) {
        spend(STEP);
        return true;
    }
    if (target.isAlive()) {
        Hero hero = (Hero) target;
        if (isStarving()) {
            partialDamage += STEP * target.HT / 1000f;
            if (partialDamage > 1) {
                target.damage((int) partialDamage, this);
                partialDamage -= (int) partialDamage;
            }
        } else {
            float newLevel = level + STEP;
            boolean statusUpdated = false;
            if (newLevel >= STARVING) {
                GLog.n(Messages.get(this, "onstarving"));
                hero.resting = false;
                hero.damage(1, this);
                statusUpdated = true;
                hero.interrupt();
            } else if (newLevel >= HUNGRY && level < HUNGRY) {
                GLog.w(Messages.get(this, "onhungry"));
                statusUpdated = true;
            }
            level = newLevel;
            if (statusUpdated) {
                BuffIndicator.refreshHero();
            }
        }
        spend(target.buff(Shadows.class) == null ? STEP : STEP * 1.5f);
    } else {
        diactivate();
    }
    return true;
}
Also used : Hero(com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero)

Example 10 with Hero

use of com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero 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)

Aggregations

Hero (com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero)25 Mob (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob)9 Item (com.shatteredpixel.shatteredpixeldungeon.items.Item)9 Char (com.shatteredpixel.shatteredpixeldungeon.actors.Char)8 Heap (com.shatteredpixel.shatteredpixeldungeon.items.Heap)5 ArrayList (java.util.ArrayList)4 Thief (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Thief)3 Barkskin (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Barkskin)2 EquipableItem (com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem)2 Gold (com.shatteredpixel.shatteredpixeldungeon.items.Gold)2 KindOfWeapon (com.shatteredpixel.shatteredpixeldungeon.items.KindOfWeapon)2 MysteryMeat (com.shatteredpixel.shatteredpixeldungeon.items.food.MysteryMeat)2 Knuckles (com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Knuckles)2 Fire (com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Fire)1 Awareness (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Awareness)1 Bleeding (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Bleeding)1 Buff (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff)1 EarthImbue (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.EarthImbue)1 FireImbue (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.FireImbue)1 MindVision (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.MindVision)1