Example #1
0
  @Override
  public boolean tick(Tickable ticking, int tickID) {
    if (!super.tick(ticking, tickID)) return false;

    if (affected == null) return false;
    if (!(affected instanceof MOB)) return false;
    final MOB mob = (MOB) affected;
    if (mob.location().numInhabitants() == 1) return true;
    final Vector choices = new Vector();
    for (final Enumeration<Ability> a = mob.effects(); a.hasMoreElements(); ) {
      final Ability A = a.nextElement();
      if ((A != null)
          && (A.canBeUninvoked())
          && (!A.ID().equals(ID()))
          && (A.abstractQuality() == Ability.QUALITY_MALICIOUS)
          && (((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SPELL)
              || ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_PRAYER))
          && (!A.isAutoInvoked())) choices.addElement(A);
    }
    if (choices.size() == 0) return true;
    final MOB target = mob.location().fetchRandomInhabitant();
    final Ability thisOne = (Ability) choices.elementAt(CMLib.dice().roll(1, choices.size(), -1));
    if ((target == null) || (thisOne == null) || (target.fetchEffect(ID()) != null)) return true;
    if (CMLib.dice().rollPercentage() > (target.charStats().getSave(CharStats.STAT_SAVE_DISEASE))) {
      ((Ability) this.copyOf()).invoke(target, target, true, 0);
      if (target.fetchEffect(ID()) != null)
        ((Ability) thisOne.copyOf()).invoke(target, target, true, 0);
    } else spreadImmunity(target);
    return true;
  }