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);
}
}
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);
}
}
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();
}
}
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"));
}
}
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();
}
Aggregations