use of com.nyrds.pixeldungeon.levels.objects.LevelObject 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.nyrds.pixeldungeon.levels.objects.LevelObject 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;
}
use of com.nyrds.pixeldungeon.levels.objects.LevelObject in project pixel-dungeon-remix by NYRDS.
the class Fire method burn.
public static void burn(int pos) {
Char ch = Actor.findChar(pos);
if (ch != null) {
Buff.affect(ch, Burning.class).reignite(ch);
}
Heap heap = Dungeon.level.getHeap(pos);
if (heap != null) {
heap.burn();
}
LevelObject levelObject = Dungeon.level.getLevelObject(pos);
if (levelObject != null) {
levelObject.burn();
}
}
Aggregations