@Override public void add(Buff buff) { super.add(buff); if (sprite != null) { if (buff instanceof Burning) { GLog.w("You catch fire!"); interrupt(); } else if (buff instanceof Paralysis) { GLog.w("You are paralysed!"); interrupt(); } else if (buff instanceof Poison) { GLog.w("You are poisoned!"); interrupt(); } else if (buff instanceof Ooze) { GLog.w("Caustic ooze eats your flesh. Wash away it!"); } else if (buff instanceof Roots) { GLog.w("You can't move!"); } else if (buff instanceof Weakness) { GLog.w("You feel weakened!"); } else if (buff instanceof Blindness) { GLog.w("You are blinded!"); } else if (buff instanceof Fury) { GLog.w("You become furious!"); sprite.showStatus(CharSprite.POSITIVE, "furious"); } else if (buff instanceof Charm) { GLog.w("You are charmed!"); } else if (buff instanceof Cripple) { GLog.w("You are crippled!"); } else if (buff instanceof Bleeding) { GLog.w("You are bleeding!"); } else if (buff instanceof Vertigo) { GLog.w("Everything is spinning around you!"); interrupt(); } else if (buff instanceof Light) { sprite.add(CharSprite.State.ILLUMINATED); } } BuffIndicator.refreshHero(); }
private boolean getCloser(final int target) { if (rooted) { return false; } int step = -1; if (Level.adjacent(pos, target)) { if (Actor.findChar(target) == null) { if (Level.pit[target] && !flying && !Chasm.jumpConfirmed) { Chasm.heroJump(this); interrupt(); return false; } if (Level.passable[target] || Level.avoid[target]) { step = target; } } } else { int len = Level.LENGTH; boolean[] p = Level.passable; boolean[] v = Dungeon.level.visited; boolean[] m = Dungeon.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, pos, target, passable, Level.fieldOfView); } if (step != -1) { int oldPos = pos; move(step); sprite.move(oldPos, pos); spend(1 / speed()); return true; } else { return false; } }
private void checkVisibleMobs() { ArrayList<Mob> visible = new ArrayList<Mob>(); boolean newMob = false; for (Mob m : Dungeon.level.mobs) { if (Level.fieldOfView[m.pos] && m.hostile) { visible.add(m); if (!visibleEnemies.contains(m)) { newMob = true; } } } if (newMob) { interrupt(); restoreHealth = false; } visibleEnemies = visible; }
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 level = intentional ? (2 * awareness - awareness * awareness) : awareness; if (distance <= 0) { level /= 2 - distance; distance = 1; } int cx = pos % Level.WIDTH; int cy = pos / Level.WIDTH; int ax = cx - distance; if (ax < 0) { ax = 0; } int bx = cx + distance; if (bx >= Level.WIDTH) { bx = Level.WIDTH - 1; } int ay = cy - distance; if (ay < 0) { ay = 0; } int by = cy + distance; if (by >= Level.HEIGHT) { by = Level.HEIGHT - 1; } for (int y = ay; y <= by; y++) { for (int x = ax, p = ax + y * Level.WIDTH; x <= bx; x++, p++) { if (Dungeon.visible[p]) { if (intentional) { sprite.parent.addToBack(new CheckedCell(p)); } if (Level.secret[p] && (intentional || Random.Float() < level)) { int oldValue = Dungeon.level.map[p]; GameScene.discoverTile(p, oldValue); Level.set(p, Terrain.discover(oldValue)); GameScene.updateMap(p); ScrollOfMagicMapping.discover(p); smthFound = true; } } } } if (intentional) { sprite.showStatus(CharSprite.DEFAULT, TXT_SEARCH); sprite.operate(pos); if (smthFound) { spendAndNext(Random.Float() < level ? 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; }