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; }
public static void doAnimalFreeingCheck(CharClass C, Environmental host, CMMsg msg) { if ((msg.source() != host) && (msg.sourceMinor() == CMMsg.TYP_NOFOLLOW) && (msg.source().isMonster()) && (host instanceof MOB) && (!((MOB) host).isMonster()) && (msg.target() == host) && (msg.source().getStartRoom() != null) && (CMLib.law().isACity(msg.source().getStartRoom().getArea())) && (((MOB) host).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")) && (CMLib.flags().flaggedAffects(msg.source(), Ability.FLAG_SUMMONING).size() == 0) && (msg.source().location() != null) && (!msg.source().amDestroyed()) && (CMLib.flags().isInTheGame((MOB) host, true)) && (!CMLib.law().isACity(msg.source().location().getArea()))) { Object[] stuff = (Object[]) animalChecking.get(host); final Room room = msg.source().location(); if ((stuff == null) || (System.currentTimeMillis() - ((Long) stuff[0]).longValue() > (room.getArea().getTimeObj().getDaysInMonth() * room.getArea().getTimeObj().getHoursInDay() * CMProps.getMillisPerMudHour()))) { stuff = new Object[3]; stuff[0] = Long.valueOf(System.currentTimeMillis()); animalChecking.remove(host); animalChecking.put(host, stuff); stuff[1] = Integer.valueOf(0); stuff[2] = new Vector(); } if ((((Integer) stuff[1]).intValue() < 19) && (!((List) stuff[2]).contains("" + msg.source()))) { stuff[1] = Integer.valueOf(((Integer) stuff[1]).intValue() + 1); ((MOB) host) .tell( CMLib.lang() .L( "You have freed @x1 from @x2.", msg.source().name((MOB) host), (msg.source().getStartRoom().getArea().name()))); CMLib.leveler() .postExperience((MOB) host, null, null, ((Integer) stuff[1]).intValue(), false); } } }
public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) { int type = mob.location().domainType(); if (((type & Room.INDOORS) > 0) || (type == Room.DOMAIN_OUTDOORS_AIR) || (type == Room.DOMAIN_OUTDOORS_CITY) || (type == Room.DOMAIN_OUTDOORS_SPACEPORT) || (type == Room.DOMAIN_OUTDOORS_UNDERWATER) || (type == Room.DOMAIN_OUTDOORS_WATERSURFACE)) { mob.tell("That magic won't work here."); return false; } if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false; boolean success = proficiencyCheck(mob, 0, auto); if (success) { CMMsg msg = CMClass.getMsg( mob, mob.location(), this, verbalCastCode(mob, mob.location(), auto), auto ? "" : "^S<S-NAME> " + prayForWord(mob) + " to make the land fruitful.^?"); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); beneficialAffect( mob, mob.location(), asLevel, CMLib.ableMapper().qualifyingClassLevel(mob, this) * (int) ((CMProps.getMillisPerMudHour() * ((long) mob.location().getArea().getTimeObj().getHoursInDay())) / CMProps.getTickMillis())); } } else beneficialWordsFizzle( mob, null, "<S-NAME> " + prayForWord(mob) + " to make the land fruitful, but nothing happens."); // return whether it worked return success; }
@Override protected int DISEASE_DELAY() { return (int) (CMProps.getMillisPerMudHour() / CMProps.getTickMillis()); }
@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 ((mob.getWorshipCharID().length() == 0) || (CMLib.map().getDeity(mob.getWorshipCharID()) == null)) { if (!auto) mob.tell(L("You must worship a god to use this prayer.")); return false; } final Deity D = CMLib.map().getDeity(mob.getWorshipCharID()); if ((target.getWorshipCharID().length() > 0) && (CMLib.map().getDeity(target.getWorshipCharID()) != null)) { if (!auto) mob.tell( L( "@x1 worships @x2, and may not be converted with this prayer.", target.name(mob), target.getWorshipCharID())); return false; } if ((CMLib.flags().isAnimalIntelligence(target) || CMLib.flags().isGolem(target) || (D == null))) { if (!auto) mob.tell(L("@x1 can not be converted with this prayer.", target.name(mob))); return false; } if (!auto) { if (convertStack.contains(target)) { final Long L = (Long) convertStack.elementAt(convertStack.indexOf(target), 2); if ((System.currentTimeMillis() - L.longValue()) > CMProps.getMillisPerMudHour() * 5) convertStack.removeElement(target); } if (convertStack.contains(target)) { mob.tell(L("@x1 must wait to be undeniably faithful again.", target.name(mob))); return false; } } if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false; int levelDiff = target.phyStats().level() - (mob.phyStats().level() + (2 * getXLEVELLevel(mob))); if (levelDiff < 0) levelDiff = 0; final boolean success = proficiencyCheck(mob, -(levelDiff * 25), auto); int type = verbalCastCode(mob, target, auto); int mal = CMMsg.MASK_MALICIOUS; if (auto) { type = CMath.unsetb(type, CMMsg.MASK_MALICIOUS); mal = 0; } if (success) { final CMMsg msg = CMClass.getMsg( mob, target, this, type, auto ? "" : L("^S<S-NAME> @x1 for <T-NAMESELF> to BELIEVE!^?", prayWord(mob))); final CMMsg msg2 = CMClass.getMsg(target, D, this, CMMsg.MSG_SERVE, L("<S-NAME> BELIEVE(S) !!!")); final CMMsg msg3 = CMClass.getMsg( mob, target, this, CMMsg.MSK_CAST_VERBAL | mal | CMMsg.TYP_MIND | (auto ? CMMsg.MASK_ALWAYS : 0), null); if ((mob.location().okMessage(mob, msg)) && (mob.location().okMessage(mob, msg3)) && (mob.location().okMessage(mob, msg2))) { mob.location().send(mob, msg); mob.location().send(mob, msg3); if ((msg.value() <= 0) && (msg3.value() <= 0)) { target.location().send(target, msg2); target.setWorshipCharID(godName); if (mob != target) CMLib.leveler().postExperience(mob, target, null, 25, false); godName = mob.getWorshipCharID(); beneficialAffect(mob, target, asLevel, CMProps.getIntVar(CMProps.Int.TICKSPERMUDMONTH)); convertStack.addElement(target, Long.valueOf(System.currentTimeMillis())); } } } else beneficialWordsFizzle( mob, target, auto ? "" : L("<S-NAME> @x1 for <T-NAMESELF>, but nothing happens.", prayWord(mob))); // return whether it worked return success; }