@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) {

      int count = 10;
      int newPos;
      do {
        newPos = Dungeon.level.randomRespawnCell();
        if (count-- <= 0) {
          break;
        }
      } while (newPos == -1);

      if (newPos != -1) {

        ch.pos = newPos;
        ch.sprite.place(ch.pos);
        ch.sprite.visible = Dungeon.visible[pos];
      }
    }

    if (Dungeon.visible[pos]) {
      CellEmitter.get(pos).start(Speck.factory(Speck.LIGHT), 0.2f, 3);
    }
  }
Exemple #2
0
  @Override
  public boolean proc(Weapon weapon, Char attacker, Char defender, int damage) {
    int level = Math.max(0, weapon.level);

    int dmg = damage;
    for (int i = 1; i <= level + 1; i++) {
      dmg = Math.max(dmg, attacker.damageRoll() - i);
    }

    if (dmg > damage) {
      defender.damage(dmg - damage, this);
      return true;
    } else {
      return false;
    }
  }
Exemple #3
0
  @Override
  protected boolean doAttack(Char enemy) {

    if (Level.distance(pos, enemy.pos) <= 1) {

      return super.doAttack(enemy);

    } else {

      boolean visible = Level.fieldOfView[pos] || Level.fieldOfView[enemy.pos];
      if (visible) {
        ((ShamanSprite) sprite).zap(enemy.pos);
      }

      spend(TIME_TO_ZAP);

      if (hit(this, enemy, true)) {
        int dmg = Random.Int(2, 12);
        if (Level.water[enemy.pos] && !enemy.flying) {
          dmg *= 1.5f;
        }
        enemy.damage(dmg, LightningTrap.LIGHTNING);

        enemy.sprite.centerEmitter().burst(SparkParticle.FACTORY, 3);
        enemy.sprite.flash();

        if (enemy == Dungeon.hero) {

          Camera.main.shake(2, 0.3f);

          if (!enemy.isAlive()) {
            Dungeon.fail(Utils.format(ResultDescriptions.MOB, Utils.indefinite(name)));
            GLog.n(TXT_LIGHTNING_KILLED, name);
          }
        }
      } else {
        enemy.sprite.showStatus(CharSprite.NEUTRAL, enemy.defenseVerb());
      }

      return !visible;
    }
  }