use of com.shatteredpixel.shatteredpixeldungeon.actors.Char in project shattered-pixel-dungeon-gdx by 00-Evan.
the class GrippingTrap method activate.
@Override
public void activate() {
Char c = Actor.findChar(pos);
if (c != null) {
int damage = Math.max(0, (2 + Dungeon.depth) - c.drRoll());
Buff.affect(c, Bleeding.class).set(damage);
Buff.prolong(c, Cripple.class, Cripple.DURATION);
Wound.hit(c);
} else {
Wound.hit(pos);
}
}
use of com.shatteredpixel.shatteredpixeldungeon.actors.Char in project shattered-pixel-dungeon-gdx by 00-Evan.
the class RockfallTrap method activate.
@Override
public void activate() {
ArrayList<Integer> rockCells = new ArrayList<>();
if (Dungeon.level instanceof RegularLevel) {
Room r = ((RegularLevel) Dungeon.level).room(pos);
int cell;
for (Point p : r.getPoints()) {
cell = Dungeon.level.pointToCell(p);
if (!Dungeon.level.solid[cell]) {
rockCells.add(cell);
}
}
// if we don't have rooms, then just do 5x5
} else {
PathFinder.buildDistanceMap(pos, BArray.not(Dungeon.level.solid, null), 2);
for (int i = 0; i < PathFinder.distance.length; i++) {
if (PathFinder.distance[i] < Integer.MAX_VALUE) {
rockCells.add(i);
}
}
}
boolean seen = false;
for (int cell : rockCells) {
if (Dungeon.level.heroFOV[cell]) {
CellEmitter.get(cell - Dungeon.level.width()).start(Speck.factory(Speck.ROCK), 0.07f, 10);
seen = true;
}
Char ch = Actor.findChar(cell);
if (ch != null) {
int damage = Random.NormalIntRange(5 + Dungeon.depth, 10 + Dungeon.depth * 2);
damage -= ch.drRoll();
ch.damage(Math.max(damage, 0), this);
Buff.prolong(ch, Paralysis.class, Paralysis.DURATION);
if (!ch.isAlive() && ch == Dungeon.hero) {
Dungeon.fail(getClass());
GLog.n(Messages.get(this, "ondeath"));
}
}
}
if (seen) {
Camera.main.shake(3, 0.7f);
Sample.INSTANCE.play(Assets.SND_ROCKS);
}
}
use of com.shatteredpixel.shatteredpixeldungeon.actors.Char in project shattered-pixel-dungeon-gdx by 00-Evan.
the class TeleportationTrap method activate.
@Override
public void activate() {
CellEmitter.get(pos).start(Speck.factory(Speck.LIGHT), 0.2f, 3);
Sample.INSTANCE.play(Assets.SND_TELEPORT);
Char ch = Actor.findChar(pos);
if (ch instanceof Hero) {
ScrollOfTeleportation.teleportHero((Hero) ch);
} else if (ch != null) {
int count = 10;
int pos;
do {
pos = Dungeon.level.randomRespawnCell();
if (count-- <= 0) {
break;
}
} while (pos == -1);
if (pos == -1 || Dungeon.bossLevel()) {
GLog.w(Messages.get(ScrollOfTeleportation.class, "no_tele"));
} else {
ch.pos = pos;
if (ch instanceof Mob && ((Mob) ch).state == ((Mob) ch).HUNTING) {
((Mob) ch).state = ((Mob) ch).WANDERING;
}
ch.sprite.place(ch.pos);
ch.sprite.visible = Dungeon.level.heroFOV[pos];
}
}
Heap heap = Dungeon.level.heaps.get(pos);
if (heap != null) {
int cell = Dungeon.level.randomRespawnCell();
Item item = heap.pickUp();
if (cell != -1) {
Dungeon.level.drop(item, cell);
}
}
}
use of com.shatteredpixel.shatteredpixeldungeon.actors.Char in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Fadeleaf method activate.
@Override
public void activate() {
Char ch = Actor.findChar(pos);
if (ch instanceof Hero) {
ScrollOfTeleportation.teleportHero((Hero) ch);
((Hero) ch).curAction = null;
} else if (ch instanceof Mob && !ch.properties().contains(Char.Property.IMMOVABLE)) {
int count = 10;
int newPos;
do {
newPos = Dungeon.level.randomRespawnCell();
if (count-- <= 0) {
break;
}
} while (newPos == -1);
if (newPos != -1 && !Dungeon.bossLevel()) {
ch.pos = newPos;
if (((Mob) ch).state == ((Mob) ch).HUNTING)
((Mob) ch).state = ((Mob) ch).WANDERING;
ch.sprite.place(ch.pos);
ch.sprite.visible = Dungeon.level.heroFOV[ch.pos];
}
}
if (Dungeon.level.heroFOV[pos]) {
CellEmitter.get(pos).start(Speck.factory(Speck.LIGHT), 0.2f, 3);
}
}
use of com.shatteredpixel.shatteredpixeldungeon.actors.Char in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Blindweed method activate.
@Override
public void activate() {
Char ch = Actor.findChar(pos);
if (ch != null) {
int len = Random.Int(5, 10);
Buff.prolong(ch, Blindness.class, len);
Buff.prolong(ch, Cripple.class, len);
if (ch instanceof Mob) {
if (((Mob) ch).state == ((Mob) ch).HUNTING)
((Mob) ch).state = ((Mob) ch).WANDERING;
((Mob) ch).beckon(Dungeon.level.randomDestination());
}
}
if (Dungeon.level.heroFOV[pos]) {
CellEmitter.get(pos).burst(Speck.factory(Speck.LIGHT), 4);
}
}
Aggregations