Ejemplo n.º 1
0
 @Override
 public void executeMsg(final Environmental myHost, final CMMsg msg) {
   super.executeMsg(myHost, msg);
   if (((msg.sourceMinor() == CMMsg.TYP_SHUTDOWN)
           || ((msg.targetMinor() == CMMsg.TYP_EXPIRE) && (msg.target() == affected))
           || (msg.sourceMinor() == CMMsg.TYP_ROOMRESET))
       && (affected instanceof Room)) {
     updateLot(null);
     final Vector mobs = new Vector();
     Room R = (Room) affected;
     if (R != null) {
       synchronized (("SYNC" + R.roomID()).intern()) {
         R = CMLib.map().getRoom(R);
         for (int m = 0; m < R.numInhabitants(); m++) {
           final MOB M = R.fetchInhabitant(m);
           if ((M != null)
               && (M.isSavable())
               && (M.getStartRoom() == R)
               && ((M.basePhyStats().rejuv() == 0)
                   || (M.basePhyStats().rejuv() == PhyStats.NO_REJUV))) {
             CMLib.catalog().updateCatalogIntegrity(M);
             mobs.addElement(M);
           }
         }
         if (!CMSecurity.isSaveFlag(CMSecurity.SaveFlag.NOPROPERTYMOBS))
           CMLib.database().DBUpdateTheseMOBs(R, mobs);
       }
     }
   }
 }
Ejemplo n.º 2
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;
         }
     }
   }
 }
Ejemplo n.º 3
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;

    final boolean success = proficiencyCheck(mob, 0, auto);
    final String str =
        auto
            ? L("The unholy word is spoken.")
            : L("^S<S-NAME> speak(s) the unholy word@x1 to <T-NAMESELF>.^?", ofDiety(mob));

    final Room room = mob.location();
    if (room != null)
      for (int i = 0; i < room.numInhabitants(); i++) {
        final MOB target = room.fetchInhabitant(i);
        if (target == null) break;
        int affectType = CMMsg.MSG_CAST_VERBAL_SPELL;
        if (auto) affectType = affectType | CMMsg.MASK_ALWAYS;
        if (CMLib.flags().isGood(target)) affectType = affectType | CMMsg.MASK_MALICIOUS;

        if (success) {
          final CMMsg msg = CMClass.getMsg(mob, target, this, affectType, str);
          if (room.okMessage(mob, msg)) {
            room.send(mob, msg);
            if (msg.value() <= 0) {
              if (CMLib.flags().canBeHeardSpeakingBy(mob, target)) {
                final Item I = Prayer_Curse.getSomething(mob, true);
                if (I != null) {
                  Prayer_Curse.endLowerBlessings(I, CMLib.ableMapper().lowestQualifyingLevel(ID()));
                  I.recoverPhyStats();
                }
                Prayer_Curse.endLowerBlessings(
                    target, CMLib.ableMapper().lowestQualifyingLevel(ID()));
                beneficialAffect(mob, target, asLevel, 0);
                target.recoverPhyStats();
              } else if (CMath.bset(affectType, CMMsg.MASK_MALICIOUS))
                maliciousFizzle(mob, target, L("<T-NAME> did not hear the unholy word!"));
              else beneficialWordsFizzle(mob, target, L("<T-NAME> did not hear the unholy word!"));
            }
          }
        } else {
          if (CMath.bset(affectType, CMMsg.MASK_MALICIOUS))
            maliciousFizzle(
                mob,
                target,
                L("<S-NAME> attempt(s) to speak the unholy word to <T-NAMESELF>, but flub(s) it."));
          else
            beneficialWordsFizzle(
                mob,
                target,
                L("<S-NAME> attempt(s) to speak the unholy word to <T-NAMESELF>, but flub(s) it."));
          return false;
        }
      }

    // return whether it worked
    return success;
  }
Ejemplo n.º 4
0
 public static boolean shopkeeperMobPresent(Room R) {
   if (R == null) return false;
   MOB M = null;
   for (int i = 0; i < R.numInhabitants(); i++) {
     M = R.fetchInhabitant(i);
     if ((M.getStartRoom() == R)
         && (M.isMonster())
         && (CMLib.coffeeShops().getShopKeeper(M) != null)) return true;
   }
   return false;
 }
Ejemplo n.º 5
0
  @Override
  public boolean tick(Tickable ticking, int tickID) {
    if ((affected == null) || (!(affected instanceof Room))) return super.tick(ticking, tickID);

    if ((--damageTickDown) >= 0) return super.tick(ticking, tickID);
    damageTickDown = 4;

    HashSet H = null;
    if ((invoker() != null) && (invoker().location() == affected)) {
      H = new HashSet();
      invoker().getGroupMembers(H);
    }
    final Room R = (Room) affected;
    for (int i = 0; i < R.numInhabitants(); i++) {
      final MOB M = R.fetchInhabitant(i);
      if ((M != null) && ((H == null) || (!H.contains(M)))) {
        if (invoker() != null) {
          final int harming = CMLib.dice().roll(1, adjustedLevel(invoker(), 0) / 3, 1);
          CMLib.combat()
              .postDamage(
                  invoker(),
                  M,
                  this,
                  harming,
                  CMMsg.MASK_MALICIOUS | CMMsg.TYP_UNDEAD,
                  Weapon.TYPE_BURSTING,
                  L("The unholy aura <DAMAGE> <T-NAME>!"));
        } else {
          final int harming =
              CMLib.dice().roll(1, CMLib.ableMapper().lowestQualifyingLevel(ID()) / 3, 1);
          CMLib.combat()
              .postDamage(
                  M,
                  M,
                  this,
                  harming,
                  CMMsg.MASK_MALICIOUS | CMMsg.TYP_UNDEAD,
                  Weapon.TYPE_BURSTING,
                  L("The unholy aura <DAMAGE> <T-NAME>!"));
        }
        if ((!M.isInCombat())
            && (M.isMonster())
            && (M != invoker)
            && (invoker != null)
            && (M.location() == invoker.location())
            && (M.location().isInhabitant(invoker))
            && (CMLib.flags().canBeSeenBy(invoker, M)))
          CMLib.combat().postAttack(M, invoker, M.fetchWieldedItem());
      }
    }
    return super.tick(ticking, tickID);
  }
Ejemplo n.º 6
0
  public boolean nonIPnonMonsterWithMe(MOB me) {
    if ((me.location() != null) && (me.session() != null)) {
      final Room R = me.location();
      for (int i = 0; i < R.numInhabitants(); i++) {
        final MOB M = R.fetchInhabitant(i);
        if ((M == null) || (M == me)) continue;

        if ((M.session() != null) && (M.session().getAddress().equals(me.session().getAddress())))
          return true;
      }
    }
    return false;
  }
Ejemplo n.º 7
0
 private void fillCheckDeviations(Room R, String type, Vector<Environmental> check) {
   if (type.equalsIgnoreCase("mobs") || type.equalsIgnoreCase("both")) {
     for (int m = 0; m < R.numInhabitants(); m++) {
       final MOB M = R.fetchInhabitant(m);
       if ((M != null) && (M.isSavable()) && (!alreadyDone(M, check))) check.add(M);
     }
   }
   if (type.equalsIgnoreCase("items") || type.equalsIgnoreCase("both")) {
     for (int i = 0; i < R.numItems(); i++) {
       final Item I = R.getItem(i);
       if ((I != null)
           && ((I instanceof Armor) || (I instanceof Weapon))
           && (!alreadyDone(I, check))) check.add(I);
     }
     for (int m = 0; m < R.numInhabitants(); m++) {
       final MOB M = R.fetchInhabitant(m);
       if (M != null) {
         for (int i = 0; i < M.numItems(); i++) {
           final Item I = M.getItem(i);
           if ((I != null)
               && ((I instanceof Armor) || (I instanceof Weapon))
               && (!alreadyDone(I, check))) check.add(I);
         }
         final ShopKeeper SK = CMLib.coffeeShops().getShopKeeper(M);
         if (SK != null) {
           for (final Iterator<Environmental> i = SK.getShop().getStoreInventory();
               i.hasNext(); ) {
             final Environmental E2 = i.next();
             if (E2 instanceof Item) {
               final Item I = (Item) E2;
               if (((I instanceof Armor) || (I instanceof Weapon)) && (!alreadyDone(I, check)))
                 check.add(I);
             }
           }
         }
       }
     }
   }
 }
Ejemplo n.º 8
0
 public Set<MOB> getEveryoneHere(MOB spareMe, Room R) {
   final Set<MOB> V = new HashSet<MOB>();
   if (R == null) return V;
   for (int i = 0; i < R.numInhabitants(); i++) {
     final MOB M = R.fetchInhabitant(i);
     if ((spareMe != null) && (spareMe == M)) continue;
     if ((M != null)
         && (!CMSecurity.isAllowed(M, R, CMSecurity.SecFlag.IMMORT))
         && ((mask == null) || (CMLib.masking().maskCheck(mask, M, false)))) V.add(M);
   }
   return V;
   // CMLib.combat().postDeath(null,M,null);
 }
Ejemplo n.º 9
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);
     }
   }
 }
 @Override
 public int castingQuality(MOB mob, Physical target) {
   if (mob != null) {
     if (target instanceof MOB) {
       final Room R = ((MOB) target).location();
       boolean found = false;
       if (R != null)
         for (int r = 0; r < R.numInhabitants(); r++) {
           final MOB M = R.fetchInhabitant(r);
           if ((M != null) && (M != mob) && (M != target) && (CMLib.flags().isInvisible(M))) {
             found = true;
             break;
           }
         }
       if (!found) return Ability.QUALITY_INDIFFERENT;
     }
   }
   return super.castingQuality(mob, target);
 }
Ejemplo n.º 11
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);
   }
 }
Ejemplo n.º 12
0
 public static boolean robberyCheck(LandTitle A, CMMsg msg) {
   if (((msg.targetMinor() == CMMsg.TYP_GET) && (!msg.isTarget(CMMsg.MASK_INTERMSG)))
       || (msg.targetMinor() == CMMsg.TYP_PUSH)
       || (msg.targetMinor() == CMMsg.TYP_PULL)) {
     if ((msg.target() instanceof Item)
         && (((Item) msg.target()).owner() == msg.source().location())
         && ((!(msg.tool() instanceof Item)) || (msg.source().isMine(msg.tool())))
         && (!msg.sourceMajor(CMMsg.MASK_ALWAYS))
         && (A.getOwnerName().length() > 0)
         && (msg.source().location() != null)
         && (msg.othersMessage() != null)
         && (msg.othersMessage().length() > 0)
         && (!shopkeeperMobPresent(msg.source().location()))
         && (!CMLib.law().doesHavePriviledgesHere(msg.source(), msg.source().location()))) {
       final Room R = msg.source().location();
       final LegalBehavior B = CMLib.law().getLegalBehavior(R);
       if (B != null) {
         for (int m = 0; m < R.numInhabitants(); m++) {
           final MOB M = R.fetchInhabitant(m);
           if (CMLib.law().doesHavePriviledgesHere(M, R)) return true;
         }
         MOB D = null;
         final Clan C = CMLib.clans().getClan(A.getOwnerName());
         if (C != null) D = C.getResponsibleMember();
         else D = CMLib.players().getLoadPlayer(A.getOwnerName());
         if (D == null) return true;
         B.accuse(
             CMLib.law().getLegalObject(R),
             msg.source(),
             D,
             new String[] {"PROPERTYROB", "THIEF_ROBBERY"});
       }
     }
     return true;
   }
   return false;
 }
Ejemplo n.º 13
0
 public int processVariableEquipment(MOB mob) {
   int newLastTickedDateTime = 0;
   if (mob != null) {
     Room R = mob.location();
     if (R != null) {
       for (int i = 0; i < R.numInhabitants(); i++) {
         MOB M = R.fetchInhabitant(i);
         if ((M != null) && (!M.isMonster()) && (CMSecurity.isAllowed(M, R, "CMDMOBS"))) {
           newLastTickedDateTime = -1;
           break;
         }
       }
       if (newLastTickedDateTime == 0) {
         Vector rivals = new Vector();
         for (int i = 0; i < mob.inventorySize(); i++) {
           Item I = mob.fetchInventory(i);
           if ((I != null)
               && (I.baseEnvStats().rejuv() > 0)
               && (I.baseEnvStats().rejuv() < Integer.MAX_VALUE)) {
             Vector V = null;
             for (int r = 0; r < rivals.size(); r++) {
               Vector V2 = (Vector) rivals.elementAt(r);
               Item I2 = (Item) V2.firstElement();
               if (I2.rawWornCode() == I.rawWornCode()) {
                 V = V2;
                 break;
               }
             }
             if (V == null) {
               V = new Vector();
               rivals.addElement(V);
             }
             V.addElement(I);
           }
         }
         for (int i = 0; i < rivals.size(); i++) {
           Vector V = (Vector) rivals.elementAt(i);
           if ((V.size() == 1) || (((Item) V.firstElement()).rawWornCode() == 0)) {
             for (int r = 0; r < V.size(); r++) {
               Item I = (Item) V.elementAt(r);
               if (CMLib.dice().rollPercentage() < I.baseEnvStats().rejuv()) mob.delInventory(I);
               else {
                 I.baseEnvStats().setRejuv(0);
                 I.envStats().setRejuv(0);
               }
             }
           } else {
             int totalChance = 0;
             for (int r = 0; r < V.size(); r++) {
               Item I = (Item) V.elementAt(r);
               totalChance += I.baseEnvStats().rejuv();
             }
             int chosenChance = CMLib.dice().roll(1, totalChance, 0);
             totalChance = 0;
             Item chosenI = null;
             for (int r = 0; r < V.size(); r++) {
               Item I = (Item) V.elementAt(r);
               if (chosenChance <= (totalChance + I.baseEnvStats().rejuv())) {
                 chosenI = I;
                 break;
               }
               totalChance += I.baseEnvStats().rejuv();
             }
             for (int r = 0; r < V.size(); r++) {
               Item I = (Item) V.elementAt(r);
               if (chosenI != I) mob.delInventory(I);
               else {
                 I.baseEnvStats().setRejuv(0);
                 I.envStats().setRejuv(0);
               }
             }
           }
         }
         if (mob instanceof ShopKeeper) {
           rivals = new Vector();
           CoffeeShop shop = ((ShopKeeper) mob).getShop();
           for (int v = 0; v < shop.getBaseInventory().size(); v++) {
             Environmental E = (Environmental) shop.getBaseInventory().elementAt(v);
             if ((E.baseEnvStats().rejuv() > 0) && (E.baseEnvStats().rejuv() < Integer.MAX_VALUE))
               rivals.addElement(E);
           }
           for (int r = 0; r < rivals.size(); r++) {
             Environmental E = (Environmental) rivals.elementAt(r);
             if (CMLib.dice().rollPercentage() > E.baseEnvStats().rejuv())
               shop.delAllStoreInventory(E);
             else {
               E.baseEnvStats().setRejuv(0);
               E.envStats().setRejuv(0);
             }
           }
         }
         mob.recoverEnvStats();
         mob.recoverCharStats();
         mob.recoverMaxState();
       }
     }
   }
   return newLastTickedDateTime;
 }
Ejemplo n.º 14
0
  @Override
  public boolean okMessage(final Environmental myHost, final CMMsg msg) {
    if ((clanID().length() > 0) && (msg.amITarget(this))) {
      if (msg.source().getClanRole(clanID()) == null) {
        if ((msg.targetMinor() == CMMsg.TYP_GET)
            || (msg.targetMinor() == CMMsg.TYP_PUSH)
            || (msg.targetMinor() == CMMsg.TYP_PULL)
            || (msg.targetMinor() == CMMsg.TYP_CAST_SPELL)) {
          final Room R = CMLib.map().roomLocation(this);
          if (CMLib.clans().findRivalrousClan(msg.source()) == null) {
            msg.source().tell(L("You must belong to an elligible clan to take a clan item."));
            return false;
          } else if (R != null) {
            for (int i = 0; i < R.numInhabitants(); i++) {
              final MOB M = R.fetchInhabitant(i);
              if ((M != null)
                  && (M.isMonster())
                  && (M.getClanRole(clanID()) != null)
                  && (CMLib.flags().aliveAwakeMobileUnbound(M, true))
                  && (CMLib.flags().canBeSeenBy(this, M))
                  && (!CMLib.flags().isAnimalIntelligence(M))) {
                R.show(
                    M, null, CMMsg.MSG_QUIETMOVEMENT, L("<S-NAME> guard(s) @x1 closely.", name()));
                return false;
              }
            }
            String rulingClan = "";
            final LegalBehavior B = CMLib.law().getLegalBehavior(R);
            if (B != null) rulingClan = B.rulingOrganization();
            if (msg.source().getClanRole(rulingClan) == null) {
              msg.source()
                  .tell(L("You must conquer and fully control this area to take the clan flag."));
              return false;
            }
            if ((B != null) && (!B.isFullyControlled())) {
              msg.source().tell(L("Your clan does not yet fully control the area."));
              return false;
            }
          }
        } else if ((msg.targetMinor() == CMMsg.TYP_DROP)
            && (!CMath.bset(msg.targetMajor(), CMMsg.MASK_INTERMSG))) {
          final Room R = msg.source().location();
          LandTitle T = null;
          Area A = null;
          LegalBehavior B = null;
          if (R != null) {
            A = R.getArea();
            T = CMLib.law().getLandTitle(R);
          }
          if ((T == null)
              || ((!T.getOwnerName().equals(clanID()))
                  && ((!T.getOwnerName().equals(msg.source().getLiegeID()))
                      || (!msg.source().isMarriedToLiege()))
                  && (!T.getOwnerName().equals(msg.source().Name())))) {
            boolean ok = false;
            if (A != null) {
              B = CMLib.law().getLegalBehavior(R);
              if (B != null) ok = B.controlPoints() > 0;
            }
            if (!ok) {
              msg.source()
                  .tell(
                      L("You can not place a flag here, this place is controlled by the Archons."));
              return false;
            }
          }
        }
      } else if ((msg.targetMinor() == CMMsg.TYP_GET)
          && (msg.source().location() != null)
          && (msg.source().isMonster())) {
        boolean foundOne = false;
        for (int i = 0; i < msg.source().location().numInhabitants(); i++) {
          final MOB M = msg.source().location().fetchInhabitant(i);
          if ((M != null) && (!M.isMonster()) && (M.getClanRole(clanID()) != null)) {
            foundOne = true;
            break;
          }
        }
        if (!foundOne) {
          msg.source().tell(L("You are guarding @x1 too closely.", name()));
          return false;
        }
      }
    }

    if (StdClanItem.stdOkMessage(this, msg)) {
      if ((clanID().length() > 0)
          && (msg.amITarget(this))
          && (msg.targetMinor() == CMMsg.TYP_DROP)) {
        final LegalBehavior B = CMLib.law().getLegalBehavior(msg.source().location());
        final String rulingClan = (B != null) ? B.rulingOrganization() : "";
        if (rulingClan.length() == 0)
          msg.source()
              .tell(
                  L("Area '@x1' is presently neutral.", msg.source().location().getArea().name()));
        else {
          msg.source()
              .tell(
                  L(
                      "Area '@x1' is presently controlled by @x2.",
                      msg.source().location().getArea().name(),
                      rulingClan));
          if (!rulingClan.equals(clanID())) {
            int relation = Clan.REL_WAR;
            final Clan C = CMLib.clans().getClan(clanID());
            if (C == null) {
              msg.source().tell(L("This ancient relic from a lost clan fades out of existence."));
              this.destroy();
              return false;
            }
            relation = C.getClanRelations(rulingClan);
            if (relation != Clan.REL_WAR) {
              msg.source()
                  .tell(
                      L("You must be at war with this clan to put down your flag on their area."));
              return false;
            }
          }
        }
      }
      return super.okMessage(myHost, msg);
    }
    return false;
  }