Search in sources :

Example 46 with Char

use of com.shatteredpixel.shatteredpixeldungeon.actors.Char 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 47 with Char

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

the class WandOfCorrosion method onZap.

@Override
protected void onZap(Ballistica bolt) {
    Blob corrosiveGas = Blob.seed(bolt.collisionPos, 50 + 10 * level(), CorrosiveGas.class);
    CellEmitter.center(bolt.collisionPos).burst(CorrosionParticle.SPLASH, 10);
    ((CorrosiveGas) corrosiveGas).setStrength(level() + 1);
    GameScene.add(corrosiveGas);
    for (int i : PathFinder.NEIGHBOURS9) {
        Char ch = Actor.findChar(bolt.collisionPos + i);
        if (ch != null) {
            processSoulMark(ch, chargesPerCast());
        }
    }
    if (Actor.findChar(bolt.collisionPos) == null) {
        Dungeon.level.press(bolt.collisionPos, null, true);
    }
}
Also used : Blob(com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob) Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char) CorrosiveGas(com.shatteredpixel.shatteredpixeldungeon.actors.blobs.CorrosiveGas)

Example 48 with Char

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

the class WandOfDisintegration method onZap.

@Override
protected void onZap(Ballistica beam) {
    boolean terrainAffected = false;
    int level = level();
    int maxDistance = Math.min(distance(), beam.dist);
    ArrayList<Char> chars = new ArrayList<>();
    int terrainPassed = 2, terrainBonus = 0;
    for (int c : beam.subPath(1, maxDistance)) {
        Char ch;
        if ((ch = Actor.findChar(c)) != null) {
            // we don't want to count passed terrain after the last enemy hit. That would be a lot of bonus levels.
            // terrainPassed starts at 2, equivalent of rounding up when /3 for integer arithmetic.
            terrainBonus += terrainPassed / 3;
            terrainPassed = terrainPassed % 3;
            chars.add(ch);
        }
        if (Dungeon.level.flamable[c]) {
            Dungeon.level.destroy(c);
            GameScene.updateMap(c);
            terrainAffected = true;
        }
        if (Dungeon.level.solid[c])
            terrainPassed++;
        CellEmitter.center(c).burst(PurpleParticle.BURST, Random.IntRange(1, 2));
    }
    if (terrainAffected) {
        Dungeon.observe();
    }
    int lvl = level + (chars.size() - 1) + terrainBonus;
    for (Char ch : chars) {
        processSoulMark(ch, chargesPerCast());
        ch.damage(damageRoll(lvl), this);
        ch.sprite.centerEmitter().burst(PurpleParticle.BURST, Random.IntRange(1, 2));
        ch.sprite.flash();
    }
}
Also used : Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char) ArrayList(java.util.ArrayList)

Example 49 with Char

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

the class WandOfLightning method onZap.

@Override
protected void onZap(Ballistica bolt) {
    // lightning deals less damage per-target, the more targets that are hit.
    float multipler = 0.4f + (0.6f / affected.size());
    // if the main target is in water, all affected take full damage
    if (Dungeon.level.water[bolt.collisionPos])
        multipler = 1f;
    int min = 5 + level();
    int max = 10 + 5 * level();
    for (Char ch : affected) {
        processSoulMark(ch, chargesPerCast());
        ch.damage(Math.round(damageRoll() * multipler), this);
        if (ch == Dungeon.hero)
            Camera.main.shake(2, 0.3f);
        ch.sprite.centerEmitter().burst(SparkParticle.FACTORY, 3);
        ch.sprite.flash();
    }
    if (!curUser.isAlive()) {
        Dungeon.fail(getClass());
        GLog.n(Messages.get(this, "ondeath"));
    }
}
Also used : Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char)

Example 50 with Char

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

the class WandOfLightning method fx.

@Override
protected void fx(Ballistica bolt, Callback callback) {
    affected.clear();
    arcs.clear();
    int cell = bolt.collisionPos;
    Char ch = Actor.findChar(cell);
    if (ch != null) {
        arcs.add(new Lightning.Arc(curUser.sprite.center(), ch.sprite.center()));
        arc(ch);
    } else {
        arcs.add(new Lightning.Arc(curUser.sprite.center(), DungeonTilemap.raisedTileCenterToWorld(bolt.collisionPos)));
        CellEmitter.center(cell).burst(SparkParticle.FACTORY, 3);
    }
    // don't want to wait for the effect before processing damage.
    curUser.sprite.parent.addToFront(new Lightning(arcs, null));
    callback.call();
}
Also used : Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char) Lightning(com.shatteredpixel.shatteredpixeldungeon.effects.Lightning)

Aggregations

Char (com.shatteredpixel.shatteredpixeldungeon.actors.Char)65 Mob (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob)13 Heap (com.shatteredpixel.shatteredpixeldungeon.items.Heap)13 Hero (com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero)8 Callback (com.watabou.utils.Callback)8 Item (com.shatteredpixel.shatteredpixeldungeon.items.Item)7 Ballistica (com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica)5 ArrayList (java.util.ArrayList)4 Actor (com.shatteredpixel.shatteredpixeldungeon.actors.Actor)3 Fire (com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Fire)3 Buff (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff)3 Burning (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Burning)3 Frost (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Frost)3 Bleeding (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Bleeding)2 Chill (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Chill)2 Paralysis (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Paralysis)2 Lightning (com.shatteredpixel.shatteredpixeldungeon.effects.Lightning)2 Blob (com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob)1 CorrosiveGas (com.shatteredpixel.shatteredpixeldungeon.actors.blobs.CorrosiveGas)1 Regrowth (com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Regrowth)1