Exemplo n.º 1
0
  @Override
  public void grantAbilities(MOB mob, boolean isBorrowedClass) {
    super.grantAbilities(mob, isBorrowedClass);

    if (mob.playerStats() == null) {
      final List<AbilityMapper.AbilityMapping> V =
          CMLib.ableMapper()
              .getUpToLevelListings(ID(), mob.charStats().getClassLevel(ID()), false, false);
      for (final AbilityMapper.AbilityMapping able : V) {
        final Ability A = CMClass.getAbility(able.abilityID);
        if ((A != null)
            && ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_CHANT)
            && (!CMLib.ableMapper().getDefaultGain(ID(), true, A.ID())))
          giveMobAbility(
              mob,
              A,
              CMLib.ableMapper().getDefaultProficiency(ID(), true, A.ID()),
              CMLib.ableMapper().getDefaultParm(ID(), true, A.ID()),
              isBorrowedClass);
      }
      return;
    }

    final Vector grantable = new Vector();

    final int level = mob.charStats().getClassLevel(this);
    int numChants = 2;
    for (final Enumeration<Ability> a = CMClass.abilities(); a.hasMoreElements(); ) {
      final Ability A = a.nextElement();
      if ((CMLib.ableMapper().getQualifyingLevel(ID(), true, A.ID()) == level)
          && ((CMLib.ableMapper().getQualifyingLevel(ID(), true, A.ID()) <= 25)
              && (!CMLib.ableMapper().getSecretSkill(ID(), true, A.ID()))
              && (!CMLib.ableMapper().getDefaultGain(ID(), true, A.ID()))
              && ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_CHANT))) {
        if (!grantable.contains(A.ID())) grantable.addElement(A.ID());
      }
    }
    for (int a = 0; a < mob.numAbilities(); a++) {
      final Ability A = mob.fetchAbility(a);
      if (grantable.contains(A.ID())) {
        grantable.remove(A.ID());
        numChants--;
      }
    }
    for (int i = 0; i < numChants; i++) {
      if (grantable.size() == 0) break;
      final String AID = (String) grantable.elementAt(CMLib.dice().roll(1, grantable.size(), -1));
      if (AID != null) {
        grantable.removeElement(AID);
        giveMobAbility(
            mob,
            CMClass.getAbility(AID),
            CMLib.ableMapper().getDefaultProficiency(ID(), true, AID),
            CMLib.ableMapper().getDefaultParm(ID(), true, AID),
            isBorrowedClass);
      }
    }
  }
Exemplo n.º 2
0
  @Override
  public boolean tick(Tickable ticking, int tickID) {
    if (!(affected instanceof MOB)) return super.tick(ticking, tickID);

    final MOB mob = (MOB) affected;

    if (tickID != Tickable.TICKID_MOB) return true;
    if (!proficiencyCheck(null, 0, false)) return true;

    if ((!mob.isInCombat()) && (CMLib.flags().isSleeping(mob))) {
      roundsHibernating++;
      final double man =
          ((mob.charStats().getStat(CharStats.STAT_INTELLIGENCE)
              + mob.charStats().getStat(CharStats.STAT_WISDOM)));
      mob.curState()
          .adjMana(
              (int)
                  Math.round(
                      (man * .1)
                          + ((mob.phyStats().level() + (2.0 * super.getXLEVELLevel(invoker())))
                              / 2.0)),
              mob.maxState());
      mob.curState().setHunger(oldState.getHunger());
      mob.curState().setThirst(oldState.getThirst());
      final double move = mob.charStats().getStat(CharStats.STAT_STRENGTH);
      mob.curState()
          .adjMovement(
              (int)
                  Math.round(
                      (move * .1)
                          + ((mob.phyStats().level() + (2.0 * super.getXLEVELLevel(invoker())))
                              / 2.0)),
              mob.maxState());
      if (!CMLib.flags().isGolem(mob)) {
        final double hp = mob.charStats().getStat(CharStats.STAT_CONSTITUTION);
        if (!CMLib.combat()
            .postHealing(
                mob,
                mob,
                this,
                CMMsg.MASK_ALWAYS | CMMsg.TYP_CAST_SPELL,
                (int)
                    Math.round(
                        (hp * .1)
                            + ((mob.phyStats().level() + (2.0 * super.getXLEVELLevel(invoker())))
                                / 2.0)),
                null)) unInvoke();
      }
    } else {
      unInvoke();
      return false;
    }
    return super.tick(ticking, tickID);
  }
Exemplo n.º 3
0
 @Override
 public void affectPhyStats(Physical affected, PhyStats affectableStats) {
   super.affectPhyStats(affected, affectableStats);
   if (affected instanceof MOB) {
     if (CMLib.flags().isStanding((MOB) affected)) {
       final MOB mob = (MOB) affected;
       final int attArmor =
           (((int) Math.round(CMath.div(mob.charStats().getStat(CharStats.STAT_DEXTERITY), 9.0)))
                   + 1)
               * (mob.charStats().getClassLevel(this) - 1);
       affectableStats.setArmor(affectableStats.armor() - attArmor);
     }
   }
 }
Exemplo n.º 4
0
 public void reloadCharClasses(CharClass oldC) {
   for (Enumeration e = CMLib.map().rooms(); e.hasMoreElements(); ) {
     Room room = (Room) e.nextElement();
     for (int i = 0; i < room.numInhabitants(); i++) {
       MOB M = room.fetchInhabitant(i);
       if (M == null) continue;
       for (int c = 0; c < M.baseCharStats().numClasses(); c++)
         if (M.baseCharStats().getMyClass(c) == oldC) {
           M.baseCharStats().setMyClasses(M.baseCharStats().getMyClassesStr());
           break;
         }
       for (int c = 0; c < M.charStats().numClasses(); c++)
         if (M.charStats().getMyClass(c) == oldC) {
           M.charStats().setMyClasses(M.charStats().getMyClassesStr());
           break;
         }
     }
     for (e = CMLib.players().players(); e.hasMoreElements(); ) {
       MOB M = (MOB) e.nextElement();
       for (int c = 0; c < M.baseCharStats().numClasses(); c++)
         if (M.baseCharStats().getMyClass(c) == oldC) {
           M.baseCharStats().setMyClasses(M.baseCharStats().getMyClassesStr());
           break;
         }
       for (int c = 0; c < M.charStats().numClasses(); c++)
         if (M.charStats().getMyClass(c) == oldC) {
           M.charStats().setMyClasses(M.charStats().getMyClassesStr());
           break;
         }
     }
   }
 }
Exemplo n.º 5
0
 @Override
 public void spring(MOB M) {
   if ((!sprung)
       && (CMLib.dice().rollPercentage() + (2 * getXLEVELLevel(invoker()))
           > M.charStats().getSave(CharStats.STAT_SAVE_TRAPS)))
     CMLib.combat().postDeath(invoker(), M, null);
 }
Exemplo n.º 6
0
  public void affectEnvStats(Environmental affected, EnvStats affectableStats) {
    super.affectEnvStats(affected, affectableStats);
    if ((affected instanceof MOB) && (((MOB) affected).location() != null)) {
      MOB mob = (MOB) affected;
      Room room = mob.location();
      int classLevel = mob.charStats().getClassLevel(this);
      if ((CMLib.flags().isHidden(mob))
          && (classLevel >= 30)
          && ((room.domainType() & Room.INDOORS) == 0)
          && (room.domainType() != Room.DOMAIN_OUTDOORS_CITY))
        affectableStats.setDisposition(affectableStats.disposition() | EnvStats.IS_NOT_SEEN);

      if (classLevel >= 5) {
        if (CMLib.flags().isInDark(room))
          affectableStats.setAttackAdjustment(
              affectableStats.attackAdjustment() - ((classLevel / 5) + 1));
        else if ((room.domainType() & Room.INDOORS) == 0)
          switch (room.getArea().getClimateObj().weatherType(room)) {
            case Climate.WEATHER_BLIZZARD:
            case Climate.WEATHER_CLOUDY:
            case Climate.WEATHER_DUSTSTORM:
            case Climate.WEATHER_HAIL:
            case Climate.WEATHER_RAIN:
            case Climate.WEATHER_SLEET:
            case Climate.WEATHER_SNOW:
            case Climate.WEATHER_THUNDERSTORM:
              break;
            default:
              affectableStats.setAttackAdjustment(
                  affectableStats.attackAdjustment() + ((classLevel / 5) + 1));
              break;
          }
      }
    }
  }
Exemplo n.º 7
0
 public void affectCharState(MOB affected, CharState affectableState) {
   super.affectCharState(affected, affectableState);
   if (affected.location() != null) {
     Room room = affected.location();
     if (affected.charStats().getClassLevel(this) >= 5) {
       if (CMLib.flags().isInDark(room)) {
         affectableState.setMana(affectableState.getMana() - (affectableState.getMana() / 4));
         affectableState.setMovement(
             affectableState.getMovement() - (affectableState.getMovement() / 4));
       } else if ((room.domainType() & Room.INDOORS) == 0)
         switch (room.getArea().getClimateObj().weatherType(room)) {
           case Climate.WEATHER_BLIZZARD:
           case Climate.WEATHER_CLOUDY:
           case Climate.WEATHER_DUSTSTORM:
           case Climate.WEATHER_HAIL:
           case Climate.WEATHER_RAIN:
           case Climate.WEATHER_SLEET:
           case Climate.WEATHER_SNOW:
           case Climate.WEATHER_THUNDERSTORM:
             break;
           default:
             affectableState.setMana(affectableState.getMana() + (affectableState.getMana() / 4));
             affectableState.setMovement(
                 affectableState.getMovement() + (affectableState.getMovement() / 4));
             break;
         }
     }
   }
 }
Exemplo n.º 8
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;
  }
Exemplo n.º 9
0
 public static void doAnimalFollowerLevelingCheck(CharClass C, Environmental host, CMMsg msg) {
   if ((msg.sourceMessage() == null)
       && (msg.sourceMinor() == CMMsg.TYP_LEVEL)
       && (msg.source().isMonster())) {
     final MOB druidM = msg.source().amUltimatelyFollowing();
     if ((druidM != null)
         && (!druidM.isMonster())
         && (druidM.charStats().getCurrentClass().ID().equals(C.ID()))
         && (CMLib.flags().isAnimalIntelligence(msg.source())
             || msg.source()
                 .charStats()
                 .getMyRace()
                 .racialCategory()
                 .equalsIgnoreCase("Vegetation")
             || msg.source()
                 .charStats()
                 .getMyRace()
                 .racialCategory()
                 .equalsIgnoreCase("Stone Golem"))) {
       final int xp = msg.source().phyStats().level() * 5;
       if (xp > 0) {
         druidM.tell(
             CMLib.lang().L("Your stewardship has benefitted @x1.", msg.source().name(druidM)));
         CMLib.leveler().postExperience(druidM, null, null, xp, false);
       }
     }
   }
 }
Exemplo n.º 10
0
 public void swapRaces(Race newR, Race oldR) {
   for (Enumeration e = CMLib.map().rooms(); e.hasMoreElements(); ) {
     Room room = (Room) e.nextElement();
     for (int i = 0; i < room.numInhabitants(); i++) {
       MOB M = room.fetchInhabitant(i);
       if (M == null) continue;
       if (M.baseCharStats().getMyRace() == oldR) M.baseCharStats().setMyRace(newR);
       if (M.charStats().getMyRace() == oldR) M.charStats().setMyRace(newR);
     }
     for (e = CMLib.players().players(); e.hasMoreElements(); ) {
       MOB M = (MOB) e.nextElement();
       if (M.baseCharStats().getMyRace() == oldR) M.baseCharStats().setMyRace(newR);
       if (M.charStats().getMyRace() == oldR) M.charStats().setMyRace(newR);
     }
   }
 }
Exemplo n.º 11
0
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    MOB target = null;
    Ability reAffect = null;
    if (mob.isInCombat()) {
      if (mob.rangeToTarget() > 0) {
        mob.tell(L("You are too far away to touch!"));
        return false;
      }
      final MOB victim = mob.getVictim();
      reAffect = victim.fetchEffect("Undead_WeakEnergyDrain");
      if (reAffect == null) reAffect = victim.fetchEffect("Undead_EnergyDrain");
      if (reAffect != null) target = victim;
    }
    if (target == null) target = this.getTarget(mob, commands, givenTarget);
    if (target == null) return false;

    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;

    boolean success = proficiencyCheck(mob, 0, auto);

    String str = null;
    if (success) {
      str = auto ? "" : L("^S<S-NAME> extend(s) an energy draining hand to <T-NAMESELF>!^?");
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              CMMsg.MSK_MALICIOUS_MOVE | CMMsg.TYP_UNDEAD | (auto ? CMMsg.MASK_ALWAYS : 0),
              str);
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        if (msg.value() <= 0) {
          mob.location().show(target, null, CMMsg.MSG_OK_VISUAL, L("<S-NAME> <S-IS-ARE> drained!"));
          if (reAffect != null) {
            if (reAffect instanceof Undead_EnergyDrain)
              ((Undead_EnergyDrain) reAffect).levelsDown++;
            ((StdAbility) reAffect)
                .setTickDownRemaining(
                    ((StdAbility) reAffect).getTickDownRemaining() + mob.phyStats().level());
            mob.recoverPhyStats();
            mob.recoverCharStats();
            mob.recoverMaxState();
          } else {
            direction = 1;
            if (target.charStats().getMyRace().racialCategory().equalsIgnoreCase("Undead"))
              direction = -1;
            success = maliciousAffect(mob, target, asLevel, 0, -1) != null;
          }
        }
      }
    } else
      return maliciousFizzle(
          mob, target, L("<S-NAME> attempt(s) to drain <T-NAMESELF>, but fail(s)."));

    return success;
  }
Exemplo n.º 12
0
 @Override
 public void level(MOB mob, List<String> newAbilityIDs) {
   super.level(mob, newAbilityIDs);
   if (CMSecurity.isDisabled(CMSecurity.DisFlag.LEVELS)) return;
   final int attArmor =
       (((int) Math.round(CMath.div(mob.charStats().getStat(CharStats.STAT_DEXTERITY), 9.0))) + 1);
   mob.tell(L("^NYour grace grants you a defensive bonus of ^H@x1^?.^N", "" + attArmor));
 }
Exemplo n.º 13
0
 public boolean okMessage(Environmental myHost, CMMsg msg) {
   if (!(myHost instanceof MOB)) return super.okMessage(myHost, msg);
   MOB myChar = (MOB) myHost;
   if ((msg.tool() == null) || (!(msg.tool() instanceof Ability)))
     return super.okMessage(myChar, msg);
   if (msg.amISource(myChar) && (myChar.isMine(msg.tool()))) {
     if ((msg.sourceMinor() == CMMsg.TYP_CAST_SPELL)
         && (!CMLib.ableMapper().getDefaultGain(ID(), true, msg.tool().ID()))) {
       if (CMLib.dice().rollPercentage()
           > (myChar.charStats().getStat(CharStats.STAT_INTELLIGENCE)
               * ((myChar.charStats().getCurrentClass().ID().equals(ID())) ? 1 : 2))) {
         myChar.location().show(myChar, null, CMMsg.MSG_OK_VISUAL, "<S-NAME> fizzle(s) a spell.");
         return false;
       }
     }
   }
   return super.okMessage(myChar, msg);
 }
Exemplo n.º 14
0
 public void confirmWearability(MOB mob) {
   if (mob == null) return;
   Race R = mob.charStats().getMyRace();
   DVector reWearSet = new DVector(2);
   Item item = null;
   for (int i = 0; i < mob.inventorySize(); i++) {
     item = mob.fetchInventory(i);
     if ((item != null) && (!item.amWearingAt(Wearable.IN_INVENTORY))) {
       Long oldCode = Long.valueOf(item.rawWornCode());
       item.unWear();
       if (reWearSet.size() == 0) reWearSet.addElement(item, oldCode);
       else {
         short layer = (item instanceof Armor) ? ((Armor) item).getClothingLayer() : 0;
         int d = 0;
         for (; d < reWearSet.size(); d++)
           if (reWearSet.elementAt(d, 1) instanceof Armor) {
             if (((Armor) reWearSet.elementAt(d, 1)).getClothingLayer() > layer) break;
           } else if (0 > layer) break;
         if (d >= reWearSet.size()) reWearSet.addElement(item, oldCode);
         else reWearSet.insertElementAt(d, item, oldCode);
       }
     }
   }
   for (int r = 0; r < reWearSet.size(); r++) {
     item = (Item) reWearSet.elementAt(r, 1);
     long oldCode = ((Long) reWearSet.elementAt(r, 2)).longValue();
     int msgCode = CMMsg.MSG_WEAR;
     if ((oldCode & Wearable.WORN_WIELD) > 0) msgCode = CMMsg.MSG_WIELD;
     else if ((oldCode & Wearable.WORN_HELD) > 0) msgCode = CMMsg.MSG_HOLD;
     CMMsg msg =
         CMClass.getMsg(
             mob, item, null, CMMsg.NO_EFFECT, null, msgCode, null, CMMsg.NO_EFFECT, null);
     if ((R.okMessage(mob, msg))
         && (item.okMessage(item, msg))
         && ((mob.charStats().getWearableRestrictionsBitmap() & oldCode) == 0)
         && (item.canWear(mob, oldCode))) item.wearAt(oldCode);
   }
   // why wasn't that here before?
   mob.recoverEnvStats();
   mob.recoverCharStats();
   mob.recoverMaxState();
 }
Exemplo n.º 15
0
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    if (!mob.isInCombat()) {
      mob.tell(L("You must be in combat to do this!"));
      return false;
    }
    final MOB victim = super.getTarget(mob, commands, givenTarget);
    if (victim == null) return false;
    if (((victim == mob.getVictim()) && (mob.rangeToTarget() > 0))
        || ((victim.getVictim() == mob) && (victim.rangeToTarget() > 0))) {
      mob.tell(L("You are too far away to disarm!"));
      return false;
    }
    if (mob.fetchWieldedItem() == null) {
      mob.tell(L("You need a weapon to disarm someone!"));
      return false;
    }
    Item hisWeapon = victim.fetchWieldedItem();
    if (hisWeapon == null) hisWeapon = victim.fetchHeldItem();
    if ((hisWeapon == null)
        || (!(hisWeapon instanceof Weapon))
        || ((((Weapon) hisWeapon).weaponClassification() == Weapon.CLASS_NATURAL))) {
      mob.tell(L("@x1 is not wielding a weapon!", victim.charStats().HeShe()));
      return false;
    }

    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;

    int levelDiff =
        victim.phyStats().level() - (mob.phyStats().level() + (2 * getXLEVELLevel(mob)));
    if (levelDiff > 0) levelDiff = levelDiff * 5;
    else levelDiff = 0;
    final boolean hit = (auto) || CMLib.combat().rollToHit(mob, victim);
    final boolean success = proficiencyCheck(mob, -levelDiff, auto) && (hit);
    if ((success)
        && ((hisWeapon.fitsOn(Wearable.WORN_WIELD))
            || hisWeapon.fitsOn(Wearable.WORN_WIELD | Wearable.WORN_HELD))) {
      if (mob.location().show(mob, victim, this, CMMsg.MSG_NOISYMOVEMENT, null)) {
        final CMMsg msg = CMClass.getMsg(victim, hisWeapon, null, CMMsg.MSG_DROP, null);
        if (mob.location().okMessage(mob, msg)) {
          mob.location().send(victim, msg);
          mob.location()
              .show(
                  mob,
                  victim,
                  CMMsg.MSG_NOISYMOVEMENT,
                  auto ? L("<T-NAME> is disarmed!") : L("<S-NAME> disarm(s) <T-NAMESELF>!"));
        }
      }
    } else
      maliciousFizzle(mob, victim, L("<S-NAME> attempt(s) to disarm <T-NAMESELF> and fail(s)!"));
    return success;
  }
Exemplo n.º 16
0
  public int classDurationModifier(MOB myChar, Ability skill, int duration) {
    if (myChar == null) return duration;
    if (((skill.classificationCode() & Ability.ALL_DOMAINS) == Ability.DOMAIN_CRAFTINGSKILL)
        && (myChar.charStats().getCurrentClass().ID().equals(ID()))
        && (!skill.ID().equals("FoodPrep"))
        && (!skill.ID().equals("Cooking"))
        && (!skill.ID().equals("Herbalism"))
        && (!skill.ID().equals("Weaving"))
        && (!skill.ID().equals("Masonry"))) return duration * 2;

    return duration;
  }
Exemplo n.º 17
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    final MOB target = this.getTarget(mob, commands, givenTarget);
    if (target == null) return false;

    if ((!target.charStats().getMyRace().racialCategory().equals("Earth Elemental"))
        && (!target.charStats().getMyRace().racialCategory().equals("Stone Golem"))
        && (!target.charStats().getMyRace().racialCategory().equals("Metal Golem"))) {
      mob.tell(L("@x1 is not an stone/metal golem or earth elemental!", target.name(mob)));
      return false;
    }

    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;

    // now see if it worked
    boolean success = proficiencyCheck(mob, 0, auto);
    if (success) {
      final String str = auto ? "" : L("^S<S-NAME> chant(s) at <T-NAMESELF>.^?");
      final CMMsg msg = CMClass.getMsg(mob, target, this, verbalCastCode(mob, target, auto), str);
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        if (msg.value() <= 0) {
          success = maliciousAffect(mob, target, asLevel, 0, -1) != null;
          if (success) {
            if (target.isInCombat()) target.makePeace();
            CMLib.commands().postFollow(target, mob, false);
            CMLib.combat().makePeaceInGroup(mob);
            if (target.amFollowing() != mob)
              mob.tell(L("@x1 seems unwilling to follow you.", target.name(mob)));
          }
        }
      }
    }
    if (!success)
      return maliciousFizzle(
          mob, target, L("<S-NAME> chant(s) at <T-NAMESELF>, but nothing happens."));

    // return whether it worked
    return success;
  }
Exemplo n.º 18
0
 public Item buildMyThing(MOB mob, Room room) {
   Area A = room.getArea();
   boolean bonusWorthy = (Druid_MyPlants.myPlant(room, mob, 0) == null);
   Vector V = Druid_MyPlants.myAreaPlantRooms(mob, room.getArea());
   int pct = 0;
   if (A.getAreaIStats()[Area.Stats.VISITABLE_ROOMS.ordinal()] > 10)
     pct =
         (int)
             Math.round(
                 100.0
                     * CMath.div(
                         V.size(), A.getAreaIStats()[Area.Stats.VISITABLE_ROOMS.ordinal()]));
   Item I = buildMyPlant(mob, room);
   if ((I != null)
       && ((mob.charStats().getCurrentClass().baseClass().equalsIgnoreCase("Druid"))
           || (CMSecurity.isASysOp(mob)))) {
     if (!CMLib.law().isACity(A)) {
       if (pct > 0) {
         int newPct =
             (int)
                 Math.round(
                     100.0
                         * CMath.div(
                             V.size(), A.getAreaIStats()[Area.Stats.VISITABLE_ROOMS.ordinal()]));
         if ((newPct >= 50) && (A.fetchEffect("Chant_DruidicConnection") == null)) {
           Ability A2 = CMClass.getAbility("Chant_DruidicConnection");
           if (A2 != null) A2.invoke(mob, A, true, 0);
         }
       }
     } else if ((bonusWorthy) && (!mob.isMonster())) {
       long[] num = (long[]) plantBonuses.get(mob.Name() + "/" + room.getArea().Name());
       if ((num == null)
           || (System.currentTimeMillis() - num[1]
               > (room.getArea().getTimeObj().getDaysInMonth()
                   * room.getArea().getTimeObj().getHoursInDay()
                   * CMProps.getMillisPerMudHour()))) {
         num = new long[2];
         plantBonuses.remove(mob.Name() + "/" + room.getArea().Name());
         plantBonuses.put(mob.Name() + "/" + room.getArea().Name(), num);
         num[1] = System.currentTimeMillis();
       }
       if (V.size() >= num[0]) {
         num[0]++;
         if (num[0] < 19) {
           mob.tell("You have made this city greener.");
           CMLib.leveler().postExperience(mob, null, null, (int) num[0], false);
         }
       }
     }
   }
   return I;
 }
Exemplo n.º 19
0
 public boolean qualifiesForThisClass(MOB mob, boolean quiet) {
   if (mob != null) {
     if (mob.baseCharStats().getStat(CharStats.STAT_CONSTITUTION) <= 8) {
       if (!quiet) mob.tell("You need at least a 9 Constitution to become a Gaian.");
       return false;
     }
     if (mob.baseCharStats().getStat(CharStats.STAT_WISDOM) <= 8) {
       if (!quiet) mob.tell("You need at least a 9 Wisdom to become a Gaian.");
       return false;
     }
     if (!(mob.charStats().getMyRace().racialCategory().equals("Human"))
         && !(mob.charStats().getMyRace().racialCategory().equals("Elf"))
         && !(mob.charStats().getMyRace().racialCategory().equals("Vegetation"))
         && !(mob.charStats().getMyRace().racialCategory().equals("Humanoid"))
         && !(mob.charStats().getMyRace().racialCategory().equals("Halfling"))
         && !(mob.charStats().getMyRace().racialCategory().equals("Dwarf"))) {
       if (!quiet) mob.tell("You must be Human, Elf, Dwarf, Halfling, or Half Elf to be a Gaian");
       return false;
     }
   }
   return super.qualifiesForThisClass(mob, quiet);
 }
Exemplo n.º 20
0
 @Override
 public void executeMsg(Environmental host, CMMsg msg) {
   if (host instanceof MOB) {
     final MOB myChar = (MOB) host;
     if (msg.amISource(myChar)
         && (msg.tool() instanceof Ability)
         && (!myChar.isMonster())
         && (msg.sourceMinor() == CMMsg.TYP_PREINVOKE)
         && (myChar.isMine(msg.tool()))
         && (myChar.charStats().getClassLevel(this) >= 30)
         && (CMLib.ableMapper().getQualifyingLevel(ID(), true, msg.tool().ID()) < 1))
       invokable = new WeakReference(msg.tool());
   }
   super.executeMsg(host, msg);
   Bard.visitationBonusMessage(host, msg);
 }
Exemplo n.º 21
0
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    final MOB target = this.getTarget(mob, commands, givenTarget);
    if (target == null) return false;

    if (target.charStats().getBodyPart(Race.BODY_FOOT) == 0) {
      mob.tell(L("@x1 has no feet!", target.name(mob)));
      return false;
    }

    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;

    final boolean success = proficiencyCheck(mob, 0, auto);
    if (success) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto) | CMMsg.MASK_MALICIOUS,
              auto ? "" : L("^S<S-NAME> chant(s) at <T-YOUPOSS> feet!^?"));
      final CMMsg msg2 =
          CMClass.getMsg(
              mob, target, this, verbalCastMask(mob, target, auto) | CMMsg.TYP_DISEASE, null);
      if ((mob.location().okMessage(mob, msg)) && (mob.location().okMessage(mob, msg2))) {
        mob.location().send(mob, msg);
        mob.location().send(mob, msg2);
        if ((msg.value() <= 0) && (msg2.value() <= 0)) {
          invoker = mob;
          maliciousAffect(mob, target, asLevel, Ability.TICKS_ALMOST_FOREVER, -1);
          mob.location()
              .show(
                  target,
                  null,
                  CMMsg.MSG_OK_VISUAL,
                  L("A fungus sprouts up between <S-YOUPOSS> toes!"));
        } else spreadImmunity(target);
      }
    } else
      return maliciousFizzle(
          mob, target, L("<S-NAME> chant(s) at <T-YOUPOSS> feet, but nothing happens."));

    // return whether it worked
    return success;
  }
Exemplo n.º 22
0
  @Override
  public boolean okMessage(final Environmental myHost, final CMMsg msg) {
    if (!(myHost instanceof MOB)) return super.okMessage(myHost, msg);

    final MOB myChar = (MOB) myHost;
    if (msg.tool() instanceof Ability) {
      if (msg.amISource(myChar)
          && (!myChar.isMonster())
          && (msg.sourceMinor() != CMMsg.TYP_PREINVOKE)) {
        final WeakReference<Ability> curRef = invokable;
        if ((curRef != null) && (msg.tool() == curRef.get())) {
          curRef.clear();
          final Ability A = ((Ability) msg.tool());
          final int[] usageCost = A.usageCost(myChar, false);
          if (CMath.bset(A.usageType(), Ability.USAGE_MANA))
            myChar.curState().adjMana(usageCost[Ability.USAGEINDEX_MANA] / 4, myChar.maxState());
          if (CMath.bset(A.usageType(), Ability.USAGE_MOVEMENT))
            myChar
                .curState()
                .adjMovement(usageCost[Ability.USAGEINDEX_MOVEMENT] / 4, myChar.maxState());
          if (CMath.bset(A.usageType(), Ability.USAGE_HITPOINTS))
            myChar
                .curState()
                .adjHitPoints(usageCost[Ability.USAGEINDEX_HITPOINTS] / 4, myChar.maxState());
        }
      } else if (msg.amITarget(myChar)) {
        if (((((Ability) msg.tool()).classificationCode() & Ability.ALL_ACODES)
                == Ability.ACODE_SPELL)
            && ((((Ability) msg.tool()).classificationCode() & Ability.ALL_DOMAINS)
                == Ability.DOMAIN_DIVINATION)
            && (CMLib.dice().roll(1, 100, 0) < (myChar.charStats().getClassLevel(this) * 4))) {
          myChar
              .location()
              .show(
                  msg.source(),
                  myChar,
                  CMMsg.MSG_OK_ACTION,
                  L(
                      "<T-NAME> fool(s) <S-NAMESELF>, causing <S-HIM-HER> to fizzle @x1.",
                      msg.tool().name()));
          return false;
        }
      }
    }
    return super.okMessage(myHost, msg);
  }
Exemplo n.º 23
0
 @Override
 public boolean execute(MOB mob, List<String> commands, int metaFlags) throws java.io.IOException {
   final StringBuffer head = new StringBuffer("");
   final boolean isArchonLooker = CMSecurity.isASysOp(mob);
   head.append("^x[");
   head.append(CMStrings.padRight(L("Class"), 16) + " ");
   head.append(CMStrings.padRight(L("Race"), 8) + " ");
   head.append(CMStrings.padRight(L("Lvl"), 4) + " ");
   if (isArchonLooker) head.append(CMStrings.padRight(L("Last"), 18) + " ");
   head.append("] Character Name^.^?\n\r");
   mob.tell(
       "^x["
           + CMStrings.centerPreserve(
               L("The Administrators of @x1", CMProps.getVar(CMProps.Str.MUDNAME)),
               head.length() - 10)
           + "]^.^?");
   final java.util.List<PlayerLibrary.ThinPlayer> allUsers =
       CMLib.database().getExtendedUserList();
   String mask = CMProps.getVar(CMProps.Str.WIZLISTMASK);
   if (mask.length() == 0) mask = "-ANYCLASS +Archon";
   final MaskingLibrary.CompiledZMask compiledMask = CMLib.masking().maskCompile(mask);
   for (final PlayerLibrary.ThinPlayer U : allUsers) {
     CharClass C;
     final MOB player = CMLib.players().getPlayer(U.name());
     if (player != null) C = player.charStats().getCurrentClass();
     else C = CMClass.getCharClass(U.charClass());
     if (C == null) C = CMClass.findCharClass(U.charClass());
     if (((player != null) && (CMLib.masking().maskCheck(compiledMask, player, true)))
         || (CMLib.masking().maskCheck(compiledMask, U))) {
       head.append("[");
       if (C != null) head.append(CMStrings.padRight(C.name(), 16) + " ");
       else head.append(CMStrings.padRight(L("Unknown"), 16) + " ");
       head.append(CMStrings.padRight(U.race(), 8) + " ");
       if ((C == null) || (!C.leveless()))
         head.append(CMStrings.padRight("" + U.level(), 4) + " ");
       else head.append(CMStrings.padRight("    ", 4) + " ");
       if (isArchonLooker)
         head.append(CMStrings.padRight(CMLib.time().date2String(U.last()), 18) + " ");
       head.append("] " + U.name());
       head.append("\n\r");
     }
   }
   mob.tell(head.toString());
   return false;
 }
Exemplo n.º 24
0
  public boolean okMessage(Environmental myHost, CMMsg msg) {
    if (!(myHost instanceof MOB)) return super.okMessage(myHost, msg);
    MOB myChar = (MOB) myHost;
    if (!super.okMessage(myChar, msg)) return false;

    if ((msg.amITarget(myChar))
        && (msg.targetMinor() == CMMsg.TYP_DAMAGE)
        && (msg.sourceMinor() == CMMsg.TYP_ACID)) {
      int recovery = myChar.charStats().getClassLevel(this);
      msg.setValue(msg.value() - recovery);
    } else if ((msg.amITarget(myChar))
        && (msg.targetMinor() == CMMsg.TYP_DAMAGE)
        && (msg.sourceMinor() == CMMsg.TYP_ELECTRIC)) {
      int recovery = msg.value();
      msg.setValue(msg.value() + recovery);
    }
    return true;
  }
Exemplo n.º 25
0
  @Override
  public boolean okMessage(final Environmental myHost, final CMMsg msg) {
    if ((myHost == null) || (!(myHost instanceof MOB))) return super.okMessage(myHost, msg);

    final MOB mob = (MOB) myHost;
    if ((msg.amISource(mob)) && (mob.charStats().getClassLevel(this) > 4)) {
      if (((msg.sourceMinor() == CMMsg.TYP_BUY) || (msg.sourceMinor() == CMMsg.TYP_LIST))
          && (msg.tool() instanceof Potion)) {
        mob.basePhyStats().setDisposition(mob.basePhyStats().disposition() | PhyStats.IS_BONUS);
        mob.recoverPhyStats();
        mob.recoverCharStats();
      } else if ((mob.basePhyStats().disposition() & PhyStats.IS_BONUS) == PhyStats.IS_BONUS) {
        mob.basePhyStats().setDisposition(mob.basePhyStats().disposition() - PhyStats.IS_BONUS);
        mob.recoverPhyStats();
        mob.recoverCharStats();
      }
    }
    return super.okMessage(myHost, msg);
  }
Exemplo n.º 26
0
 public void grantAbilities(MOB mob, boolean isBorrowedClass) {
   super.grantAbilities(mob, isBorrowedClass);
   if (mob.playerStats() == null) {
     DVector V =
         CMLib.ableMapper()
             .getUpToLevelListings(ID(), mob.charStats().getClassLevel(ID()), false, false);
     for (Enumeration a = V.getDimensionVector(1).elements(); a.hasMoreElements(); ) {
       Ability A = CMClass.getAbility((String) a.nextElement());
       if ((A != null)
           && ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_CHANT)
           && (!CMLib.ableMapper().getDefaultGain(ID(), true, A.ID())))
         giveMobAbility(
             mob,
             A,
             CMLib.ableMapper().getDefaultProficiency(ID(), true, A.ID()),
             CMLib.ableMapper().getDefaultParm(ID(), true, A.ID()),
             isBorrowedClass);
     }
   }
 }
Exemplo n.º 27
0
 @Override
 public void grantAbilities(MOB mob, boolean isBorrowedClass) {
   super.grantAbilities(mob, isBorrowedClass);
   if (mob.playerStats() == null) {
     final List<AbilityMapper.AbilityMapping> V =
         CMLib.ableMapper()
             .getUpToLevelListings(ID(), mob.charStats().getClassLevel(ID()), false, false);
     for (final AbilityMapper.AbilityMapping able : V) {
       final Ability A = CMClass.getAbility(able.abilityID);
       if ((A != null)
           && ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SONG)
           && (!CMLib.ableMapper().getDefaultGain(ID(), true, A.ID())))
         giveMobAbility(
             mob,
             A,
             CMLib.ableMapper().getDefaultProficiency(ID(), true, A.ID()),
             CMLib.ableMapper().getDefaultParm(ID(), true, A.ID()),
             isBorrowedClass);
     }
   }
 }
Exemplo n.º 28
0
 public boolean tick(Tickable ticking, int tickID) {
   if (!super.tick(ticking, tickID)) return false;
   if ((tickID == Tickable.TICKID_MOB) && (affected != null) && (affected instanceof MOB)) {
     MOB mob = (MOB) affected;
     if ((mob.isInCombat())
         && (CMLib.flags().aliveAwakeMobileUnbound(mob, true))
         && (mob.rangeToTarget() == 0)
         && (mob.charStats().getBodyPart(Race.BODY_HAND) > 1)
         && (!anyWeapons(mob))) {
       if (CMLib.dice().rollPercentage() > 95) helpProficiency(mob, 0);
       if ((naturalWeapon == null) || (naturalWeapon.amDestroyed())) {
         naturalWeapon = CMClass.getWeapon("GenWeapon");
         naturalWeapon.setName("a knife hand");
         naturalWeapon.setWeaponType(Weapon.TYPE_PIERCING);
         naturalWeapon.basePhyStats().setDamage(7);
         naturalWeapon.recoverPhyStats();
       }
       CMLib.combat().postAttack(mob, mob.getVictim(), naturalWeapon);
     }
   }
   return true;
 }
Exemplo n.º 29
0
 public void extinguish(MOB source, Environmental target, boolean mundane) {
   if (target instanceof Room) {
     Room R = (Room) target;
     for (int m = 0; m < R.numInhabitants(); m++) {
       MOB M = R.fetchInhabitant(m);
       if (M != null) extinguish(source, M, mundane);
     }
     for (int i = 0; i < R.numItems(); i++) {
       Item I = R.fetchItem(i);
       if (I != null) extinguish(source, I, mundane);
     }
     return;
   }
   for (int a = target.numEffects() - 1; a >= 0; a--) {
     Ability A = target.fetchEffect(a);
     if ((A != null)
         && ((!mundane)
             || ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_PROPERTY))) {
       if ((CMath.bset(A.flags(), Ability.FLAG_HEATING) && (!mundane))
           || (CMath.bset(A.flags(), Ability.FLAG_FIREBASED))
           || ((A.ID().equalsIgnoreCase("Spell_SummonElemental")
               && A.text().toUpperCase().indexOf("FIRE") >= 0))) A.unInvoke();
     }
   }
   if ((target instanceof MOB) && (!mundane)) {
     MOB tmob = (MOB) target;
     if (tmob.charStats().getMyRace().ID().equals("FireElemental"))
       CMLib.combat().postDeath(source, (MOB) target, null);
     for (int i = 0; i < tmob.inventorySize(); i++) {
       Item I = tmob.fetchInventory(i);
       if (I != null) extinguish(tmob, I, mundane);
     }
   }
   if ((target instanceof Light) && (((Light) target).isLit())) {
     ((Light) target).tick(target, Tickable.TICKID_LIGHT_FLICKERS);
     ((Light) target).light(false);
   }
 }
Exemplo n.º 30
0
  public boolean okMessage(final Environmental myHost, final CMMsg msg) {
    if ((affected == null) || (!(affected instanceof MOB))) return true;

    MOB mob = (MOB) affected;

    // when this spell is on a MOBs Affected list,
    // it should consistantly prevent the mob
    // from trying to do ANYTHING except sleep
    if (msg.amISource(mob)) {
      if (msg.sourceMinor() == CMMsg.TYP_ADVANCE) {
        if (mob.location()
            .show(
                mob,
                null,
                CMMsg.MSG_OK_ACTION,
                "<S-NAME> struggle(s) against the repulsion field.")) {
          amountRemaining -= mob.charStats().getStat(CharStats.STAT_STRENGTH);
          if (amountRemaining < 0) unInvoke();
        }
        return false;
      }
    }
    return super.okMessage(myHost, msg);
  }