コード例 #1
0
ファイル: Shock.java プロジェクト: Decker2/pixel-dungeon
  private void hit(Char ch, int damage) {

    if (damage < 1) {
      return;
    }

    affected.add(ch);
    ch.damage(
        Level.water[ch.pos] && !ch.flying ? (int) (damage * 2) : damage, LightningTrap.LIGHTNING);

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

    points[nPoints++] = ch.pos;

    HashSet<Char> ns = new HashSet<Char>();
    for (int i = 0; i < Level.NEIGHBOURS8.length; i++) {
      Char n = Actor.findChar(ch.pos + Level.NEIGHBOURS8[i]);
      if (n != null && !affected.contains(n)) {
        ns.add(n);
      }
    }

    if (ns.size() > 0) {
      hit(Random.element(ns), Random.Int(damage / 2, damage));
    }
  }
コード例 #2
0
  @Override
  public boolean attack(Char enemy) {

    for (int i = 1; i < Ballistica.distance; i++) {

      int pos = Ballistica.trace[i];

      Char ch = Actor.findChar(pos);
      if (ch == null) {
        continue;
      }

      if (hit(this, ch, true)) {
        ch.damage(Random.NormalIntRange(14, 20), this);

        if (Dungeon.visible[pos]) {
          ch.getSprite().flash();
          CellEmitter.center(pos).burst(PurpleParticle.BURST, Random.IntRange(1, 2));
        }

        if (!ch.isAlive() && ch == Dungeon.hero) {
          Dungeon.fail(
              Utils.format(ResultDescriptions.MOB, Utils.indefinite(getName()), Dungeon.depth));
          GLog.n(TXT_DEATHGAZE_KILLED, getName());
        }
      } else {
        ch.getSprite().showStatus(CharSprite.NEUTRAL, ch.defenseVerb());
      }
    }

    return true;
  }
コード例 #3
0
  @Override
  public void damage(int dmg, Object src) {
    restoreHealth = false;
    super.damage(dmg, src);

    if (subClass == HeroSubClass.BERSERKER && 0 < HP && HP <= HT * Fury.LEVEL) {
      Buff.affect(this, Fury.class);
    }
  }
コード例 #4
0
  @Override
  public int defenseProc(Char enemy, int damage) {

    RingOfThorns.Thorns thorns = buff(RingOfThorns.Thorns.class);
    if (thorns != null) {
      int dmg = Random.IntRange(0, damage);
      if (dmg > 0) {
        enemy.damage(dmg, thorns);
      }
    }

    Earthroot.Armor armor = buff(Earthroot.Armor.class);
    if (armor != null) {
      damage = armor.absorb(damage);
    }

    if (belongings.armor != null) {
      damage = belongings.armor.proc(enemy, this, damage);
    }

    return damage;
  }