use of com.watabou.pixeldungeon.actors.Char in project pixel-dungeon by watabou.
the class Skeleton method die.
@Override
public void die(Object cause) {
super.die(cause);
boolean heroKilled = false;
for (int i = 0; i < Level.NEIGHBOURS8.length; i++) {
Char ch = findChar(pos + Level.NEIGHBOURS8[i]);
if (ch != null && ch.isAlive()) {
int damage = Math.max(0, damageRoll() - Random.IntRange(0, ch.dr() / 2));
ch.damage(damage, this);
if (ch == Dungeon.hero && !ch.isAlive()) {
heroKilled = true;
}
}
}
if (Dungeon.visible[pos]) {
Sample.INSTANCE.play(Assets.SND_BONES);
}
if (heroKilled) {
Dungeon.fail(Utils.format(ResultDescriptions.MOB, Utils.indefinite(name), Dungeon.depth));
GLog.n(TXT_HERO_KILLED);
}
}
use of com.watabou.pixeldungeon.actors.Char in project pixel-dungeon by watabou.
the class Item method cast.
public void cast(final Hero user, int dst) {
final int cell = Ballistica.cast(user.pos, dst, false, true);
user.sprite.zap(cell);
user.busy();
Sample.INSTANCE.play(Assets.SND_MISS, 0.6f, 0.6f, 1.5f);
Char enemy = Actor.findChar(cell);
QuickSlot.target(this, enemy);
// FIXME!!!
float delay = TIME_TO_THROW;
if (this instanceof MissileWeapon) {
delay *= ((MissileWeapon) this).speedFactor(user);
if (enemy != null) {
SnipersMark mark = user.buff(SnipersMark.class);
if (mark != null) {
if (mark.object == enemy.id()) {
delay *= 0.5f;
}
user.remove(mark);
}
}
}
final float finalDelay = delay;
((MissileSprite) user.sprite.parent.recycle(MissileSprite.class)).reset(user.pos, cell, this, new Callback() {
@Override
public void call() {
Item.this.detach(user.belongings.backpack).onThrow(cell);
user.spendAndNext(finalDelay);
}
});
}
use of com.watabou.pixeldungeon.actors.Char in project pixel-dungeon by watabou.
the class DM300 method move.
@Override
public void move(int step) {
super.move(step);
if (Dungeon.level.map[step] == Terrain.INACTIVE_TRAP && HP < HT) {
HP += Random.Int(1, HT - HP);
sprite.emitter().burst(ElmoParticle.FACTORY, 5);
if (Dungeon.visible[step] && Dungeon.hero.isAlive()) {
GLog.n("DM-300 repairs itself!");
}
}
int[] cells = { step - 1, step + 1, step - Level.WIDTH, step + Level.WIDTH, step - 1 - Level.WIDTH, step - 1 + Level.WIDTH, step + 1 - Level.WIDTH, step + 1 + Level.WIDTH };
int cell = cells[Random.Int(cells.length)];
if (Dungeon.visible[cell]) {
CellEmitter.get(cell).start(Speck.factory(Speck.ROCK), 0.07f, 10);
Camera.main.shake(3, 0.7f);
Sample.INSTANCE.play(Assets.SND_ROCKS);
if (Level.water[cell]) {
GameScene.ripple(cell);
} else if (Dungeon.level.map[cell] == Terrain.EMPTY) {
Level.set(cell, Terrain.EMPTY_DECO);
GameScene.updateMap(cell);
}
}
Char ch = Actor.findChar(cell);
if (ch != null && ch != this) {
Buff.prolong(ch, Paralysis.class, 2);
}
}
use of com.watabou.pixeldungeon.actors.Char in project pixel-dungeon by watabou.
the class King method summon.
private void summon() {
nextPedestal = !nextPedestal;
sprite.centerEmitter().start(Speck.factory(Speck.SCREAM), 0.4f, 2);
Sample.INSTANCE.play(Assets.SND_CHALLENGE);
boolean[] passable = Level.passable.clone();
for (Actor actor : Actor.all()) {
if (actor instanceof Char) {
passable[((Char) actor).pos] = false;
}
}
int undeadsToSummon = maxArmySize() - Undead.count;
PathFinder.buildDistanceMap(pos, passable, undeadsToSummon);
PathFinder.distance[pos] = Integer.MAX_VALUE;
int dist = 1;
undeadLabel: for (int i = 0; i < undeadsToSummon; i++) {
do {
for (int j = 0; j < Level.LENGTH; j++) {
if (PathFinder.distance[j] == dist) {
Undead undead = new Undead();
undead.pos = j;
GameScene.add(undead);
WandOfBlink.appear(undead, j);
new Flare(3, 32).color(0x000000, false).show(undead.sprite, 2f);
PathFinder.distance[j] = Integer.MAX_VALUE;
continue undeadLabel;
}
}
dist++;
} while (dist < undeadsToSummon);
}
yell("Arise, slaves!");
}
use of com.watabou.pixeldungeon.actors.Char in project pixel-dungeon by watabou.
the class WandOfFirebolt method onZap.
@Override
protected void onZap(int cell) {
int level = power();
for (int i = 1; i < Ballistica.distance - 1; i++) {
int c = Ballistica.trace[i];
if (Level.flamable[c]) {
GameScene.add(Blob.seed(c, 1, Fire.class));
}
}
GameScene.add(Blob.seed(cell, 1, Fire.class));
Char ch = Actor.findChar(cell);
if (ch != null) {
ch.damage(Random.Int(1, 8 + level * level), this);
Buff.affect(ch, Burning.class).reignite(ch);
ch.sprite.emitter().burst(FlameParticle.FACTORY, 5);
if (ch == curUser && !ch.isAlive()) {
Dungeon.fail(Utils.format(ResultDescriptions.WAND, name, Dungeon.depth));
GLog.n("You killed yourself with your own Wand of Firebolt...");
}
}
}
Aggregations