use of com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica in project shattered-pixel-dungeon-gdx by 00-Evan.
the class WandOfBlastWave method onHit.
@Override
public // behaves just like glyph of Repulsion
void onHit(MagesStaff staff, Char attacker, Char defender, int damage) {
int level = Math.max(0, staff.level());
// lvl 2 - 50%
if (Random.Int(level + 4) >= 3) {
int oppositeHero = defender.pos + (defender.pos - attacker.pos);
Ballistica trajectory = new Ballistica(defender.pos, oppositeHero, Ballistica.MAGIC_BOLT);
throwChar(defender, trajectory, 2);
}
}
use of com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica in project shattered-pixel-dungeon-gdx by 00-Evan.
the class WandOfBlastWave method onZap.
@Override
protected void onZap(Ballistica bolt) {
Sample.INSTANCE.play(Assets.SND_BLAST);
BlastWave.blast(bolt.collisionPos);
int damage = damageRoll();
// presses all tiles in the AOE first
for (int i : PathFinder.NEIGHBOURS9) {
Dungeon.level.press(bolt.collisionPos + i, Actor.findChar(bolt.collisionPos + i), true);
}
// throws other chars around the center.
for (int i : PathFinder.NEIGHBOURS8) {
Char ch = Actor.findChar(bolt.collisionPos + i);
if (ch != null) {
processSoulMark(ch, chargesPerCast());
ch.damage(Math.round(damage * 0.667f), this);
if (ch.isAlive()) {
Ballistica trajectory = new Ballistica(ch.pos, ch.pos + i, Ballistica.MAGIC_BOLT);
int strength = 1 + Math.round(level() / 2f);
throwChar(ch, trajectory, strength);
}
}
}
// throws the char at the center of the blast
Char ch = Actor.findChar(bolt.collisionPos);
if (ch != null) {
processSoulMark(ch, chargesPerCast());
ch.damage(damage, this);
if (ch.isAlive() && bolt.path.size() > bolt.dist + 1) {
Ballistica trajectory = new Ballistica(ch.pos, bolt.path.get(bolt.dist + 1), Ballistica.MAGIC_BOLT);
int strength = level() + 3;
throwChar(ch, trajectory, strength);
}
}
if (!curUser.isAlive()) {
Dungeon.fail(getClass());
GLog.n(Messages.get(this, "ondeath"));
}
}
use of com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Succubus method blink.
private void blink(int target) {
Ballistica route = new Ballistica(pos, target, Ballistica.PROJECTILE);
int cell = route.collisionPos;
// can't occupy the same cell as another char, so move back one.
if (Actor.findChar(cell) != null && cell != this.pos)
cell = route.path.get(route.dist - 1);
if (Dungeon.level.avoid[cell]) {
ArrayList<Integer> candidates = new ArrayList<>();
for (int n : PathFinder.NEIGHBOURS8) {
cell = route.collisionPos + n;
if (Dungeon.level.passable[cell] && Actor.findChar(cell) == null) {
candidates.add(cell);
}
}
if (candidates.size() > 0)
cell = Random.element(candidates);
else {
delay = BLINK_DELAY;
return;
}
}
ScrollOfTeleportation.appear(this, cell);
delay = BLINK_DELAY;
}
use of com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Eye method canAttack.
@Override
protected boolean canAttack(Char enemy) {
if (beamCooldown == 0) {
Ballistica aim = new Ballistica(pos, enemy.pos, Ballistica.STOP_TERRAIN);
if (enemy.invisible == 0 && !isCharmedBy(enemy) && fieldOfView[enemy.pos] && aim.subPath(1, aim.dist).contains(enemy.pos)) {
beam = aim;
beamTarget = aim.collisionPos;
return true;
} else
// if the beam is charged, it has to attack, will aim at previous location of target.
return beamCharged;
} else
return super.canAttack(enemy);
}
use of com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica in project shattered-pixel-dungeon-gdx by 00-Evan.
the class DisintegrationTrap method activate.
@Override
public void activate() {
Char target = Actor.findChar(pos);
// find the closest char that can be aimed at
if (target == null) {
for (Char ch : Actor.chars()) {
Ballistica bolt = new Ballistica(pos, ch.pos, Ballistica.PROJECTILE);
if (bolt.collisionPos == ch.pos && (target == null || Dungeon.level.trueDistance(pos, ch.pos) < Dungeon.level.trueDistance(pos, target.pos))) {
target = ch;
}
}
}
Heap heap = Dungeon.level.heaps.get(pos);
if (heap != null)
heap.explode();
if (target != null) {
if (Dungeon.level.heroFOV[pos] || Dungeon.level.heroFOV[target.pos]) {
Sample.INSTANCE.play(Assets.SND_RAY);
ShatteredPixelDungeon.scene().add(new Beam.DeathRay(DungeonTilemap.tileCenterToWorld(pos), target.sprite.center()));
}
target.damage(Math.max(target.HT / 5, Random.Int(target.HP / 2, 2 * target.HP / 3)), this);
if (target == Dungeon.hero) {
Hero hero = (Hero) target;
if (!hero.isAlive()) {
Dungeon.fail(getClass());
GLog.n(Messages.get(this, "ondeath"));
} else {
Item item = hero.belongings.randomUnequipped();
Bag bag = hero.belongings.backpack;
// bags do not protect against this trap
if (item instanceof Bag) {
bag = (Bag) item;
item = Random.element(bag.items);
}
if (item == null || item.level() > 0 || item.unique)
return;
if (!item.stackable) {
item.detachAll(bag);
GLog.w(Messages.get(this, "one", item.name()));
} else {
int n = Random.NormalIntRange(1, (item.quantity() + 1) / 2);
for (int i = 1; i <= n; i++) item.detach(bag);
GLog.w(Messages.get(this, "some", item.name()));
}
}
}
}
}
Aggregations