use of com.watabou.pixeldungeon.levels.Level in project pixel-dungeon-remix by NYRDS.
the class WindGust method cast.
@Override
public boolean cast(Char chr, int cell) {
Level level = Dungeon.level;
if (level.cellValid(cell)) {
Char ch;
boolean triggered = false;
Ballistica.cast(chr.getPos(), cell, true, false);
for (int i = 1; i < 3; i++) {
int c = Ballistica.trace[i];
if ((ch = Actor.findChar(c)) != null) {
int next = Ballistica.trace[i + 1];
triggered = true;
ch.getSprite().emitter().burst(WindParticle.FACTORY, 5);
ch.getSprite().burst(0xFF99FFFF, 3);
Sample.INSTANCE.play(Assets.SND_MELD);
if (ch.isMovable() && (level.passable[next] || level.avoid[next]) && Actor.findChar(next) == null) {
ch.move(next);
ch.getSprite().move(ch.getPos(), next);
Dungeon.observe();
} else {
ch.damage(2, this);
}
}
if (triggered) {
castCallback(chr);
return true;
}
}
}
return false;
}
use of com.watabou.pixeldungeon.levels.Level in project pixel-dungeon-remix by NYRDS.
the class Bounce method proc.
@Override
public int proc(Armor armor, @NonNull Char attacker, Char defender, int damage) {
int armorLevel = Math.max(0, armor.level());
Level level = Dungeon.level;
if (attacker.isMovable() && level.adjacent(attacker.getPos(), defender.getPos()) && Random.Int(armorLevel + 5) >= 4) {
for (int i = 0; i < Level.NEIGHBOURS8.length; i++) {
int ofs = Level.NEIGHBOURS8[i];
if (attacker.getPos() - defender.getPos() == ofs) {
int newPos = attacker.getPos() + ofs;
if (newPos < 0 || newPos > level.passable.length) {
newPos = defender.getPos();
}
if ((level.passable[newPos] || level.avoid[newPos]) && Actor.findChar(newPos) == null) {
Actor.addDelayed(new Pushing(attacker, attacker.getPos(), newPos), -1);
attacker.setPos(newPos);
level.press(newPos, attacker);
}
break;
}
}
}
return damage;
}
use of com.watabou.pixeldungeon.levels.Level in project pixel-dungeon-remix by NYRDS.
the class PseudoPasty method pick.
@Override
public Item pick(Char ch, int pos) {
Level level = Dungeon.level;
int spawnPos = level.getEmptyCellNextTo(pos);
if (!level.cellValid(spawnPos)) {
return this;
}
MimicPie mob = new MimicPie();
mob.setPos(spawnPos);
mob.setState(mob.WANDERING);
mob.adjustStats(Dungeon.depth);
level.spawnMob(mob);
Dungeon.hero.checkVisibleMobs();
AttackIndicator.updateState();
CellEmitter.get(pos).burst(Speck.factory(Speck.STAR), 10);
Sample.INSTANCE.play(Assets.SND_MIMIC);
return null;
}
use of com.watabou.pixeldungeon.levels.Level in project pixel-dungeon-remix by NYRDS.
the class Hero method getCloser.
private boolean getCloser(final int target) {
if (rooted) {
return false;
}
int step = -1;
Level level = Dungeon.level;
Buff wallWalkerBuff = null;
if (!level.isBossLevel()) {
wallWalkerBuff = buff(RingOfStoneWalking.StoneWalking.class);
}
if (level.adjacent(getPos(), target)) {
if (Actor.findChar(target) == null) {
if (!hasBuff(Blindness.class)) {
if (level.pit[target] && !isFlying() && !Chasm.jumpConfirmed) {
Chasm.heroJump(this);
interrupt();
return false;
}
if (TrapHelper.isVisibleTrap(level.map[target]) && !isFlying() && !TrapHelper.stepConfirmed) {
TrapHelper.heroTriggerTrap(this);
interrupt();
return false;
}
}
if (wallWalkerBuff == null && (level.passable[target] || level.avoid[target])) {
step = target;
}
if (wallWalkerBuff != null && level.solid[target]) {
step = target;
}
LevelObject obj = level.getTopLevelObject(target);
if (obj != null && obj.pushable(this)) {
interrupt();
if (!obj.push(this)) {
return false;
}
}
}
} else {
int len = level.getLength();
boolean[] p = wallWalkerBuff != null ? level.solid : level.passable;
boolean[] v = level.visited;
boolean[] m = level.mapped;
boolean[] passable = new boolean[len];
for (int i = 0; i < len; i++) {
passable[i] = p[i] && (v[i] || m[i]);
}
step = Dungeon.findPath(this, getPos(), target, passable, level.fieldOfView);
}
if (step != -1) {
int oldPos = getPos();
LevelObject obj = level.getTopLevelObject(step);
if (obj != null) {
if (step == target) {
interrupt();
if (!obj.interact(this)) {
return false;
}
} else {
if (!obj.stepOn(this)) {
interrupt();
return false;
}
}
}
move(step);
getSprite().move(oldPos, getPos());
if (wallWalkerBuff != null) {
int dmg = hp() / 2 > 2 ? hp() / 2 : 2;
damage(dmg, wallWalkerBuff);
}
spend(1 / speed());
return true;
} else {
return false;
}
}
use of com.watabou.pixeldungeon.levels.Level in project pixel-dungeon-remix by NYRDS.
the class Hero method search.
public boolean search(boolean intentional) {
boolean smthFound = false;
int positive = 0;
int negative = 0;
for (Buff buff : buffs(RingOfDetection.Detection.class)) {
int bonus = ((RingOfDetection.Detection) buff).level;
if (bonus > positive) {
positive = bonus;
} else if (bonus < 0) {
negative += bonus;
}
}
int distance = 1 + positive + negative;
float searchLevel = intentional ? (2 * awareness - awareness * awareness) : awareness;
if (distance <= 0) {
searchLevel /= 2 - distance;
distance = 1;
}
Level level = Dungeon.level;
int cx = level.cellX(getPos());
int cy = level.cellY(getPos());
int ax = cx - distance;
if (ax < 0) {
ax = 0;
}
int bx = cx + distance;
if (bx >= level.getWidth()) {
bx = level.getWidth() - 1;
}
int ay = cy - distance;
if (ay < 0) {
ay = 0;
}
int by = cy + distance;
if (by >= level.getHeight()) {
by = level.getHeight() - 1;
}
for (int y = ay; y <= by; y++) {
for (int x = ax, p = ax + y * level.getWidth(); x <= bx; x++, p++) {
if (Dungeon.visible[p]) {
if (intentional) {
getSprite().getParent().addToBack(new CheckedCell(p));
}
if (intentional || Random.Float() < searchLevel) {
if (level.secret[p]) {
int oldValue = level.map[p];
GameScene.discoverTile(p);
level.set(p, Terrain.discover(oldValue));
GameScene.updateMap(p);
ScrollOfMagicMapping.discover(p);
smthFound = true;
}
LevelObject obj = level.getLevelObject(p);
if (obj != null && obj.secret()) {
obj.discover();
smthFound = true;
}
}
}
}
}
if (intentional) {
getSprite().showStatus(CharSprite.DEFAULT, TXT_SEARCH);
getSprite().operate(getPos());
if (smthFound) {
spendAndNext(Random.Float() < searchLevel ? TIME_TO_SEARCH : TIME_TO_SEARCH * 2);
} else {
spendAndNext(TIME_TO_SEARCH);
}
}
if (smthFound) {
GLog.w(TXT_NOTICED_SMTH);
Sample.INSTANCE.play(Assets.SND_SECRET);
interrupt();
}
return smthFound;
}
Aggregations