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); } } }
@Override protected Item buildMyPlant(MOB mob, Room room) { final int code = material & RawMaterial.RESOURCE_MASK; final Item newItem = CMClass.getBasicItem("GenItem"); final String name = CMLib.english().startWithAorAn(RawMaterial.CODES.NAME(code).toLowerCase() + " tree"); newItem.setName(name); newItem.setDisplayText(L("@x1 grows here.", newItem.name())); newItem.setDescription(""); newItem.basePhyStats().setWeight(10000); CMLib.flags().setGettable(newItem, false); newItem.setMaterial(material); newItem.setSecretIdentity(mob.Name()); newItem.setMiscText(newItem.text()); room.addItem(newItem); final Chant_SummonTree newChant = new Chant_SummonTree(); newItem.basePhyStats().setLevel(10 + newChant.getX1Level(mob)); newItem.setExpirationDate(0); room.showHappens( CMMsg.MSG_OK_ACTION, L("a tall, healthy @x1 tree sprouts up.", RawMaterial.CODES.NAME(code).toLowerCase())); room.recoverPhyStats(); newChant.plantsLocationR = room; newChant.littlePlantsI = newItem; if (CMLib.law().doesOwnThisLand(mob, room)) { newChant.setInvoker(mob); newChant.setMiscText(mob.Name()); newItem.addNonUninvokableEffect(newChant); } else newChant.beneficialAffect(mob, newItem, 0, (newChant.adjustedLevel(mob, 0) * 240) + 450); room.recoverPhyStats(); return newItem; }
@Override public boolean tick(Tickable ticking, int tickID) { if (!super.tick(ticking, tickID)) return false; final MOB invoker = this.invoker; if (affected instanceof MOB) { final MOB officer = (MOB) affected; final Room R = officer.location(); if (R != null) { final LegalBehavior B = CMLib.law().getLegalBehavior(R); final Area A = (B == null) ? null : CMLib.law().getLegalObject(R); if ((A != null) && (B != null)) { clearWarrants(officer, invoker, R, A, B); } } } return true; }
@Override public void unInvoke() { final Physical P = affected; super.unInvoke(); if ((P instanceof MOB) && (this.canBeUninvoked) && (this.unInvoked)) { if ((!P.amDestroyed()) && (((MOB) P).amFollowing() == null)) { final Room R = CMLib.map().roomLocation(P); if (CMLib.law().getLandOwnerName(R).length() == 0) { if (!CMLib.law().doesHavePriviledgesHere(invoker(), R)) { if ((R != null) && (!((MOB) P).amDead())) R.showHappens(CMMsg.MSG_OK_ACTION, P, L("<S-NAME> wander(s) off.")); P.destroy(); } } } } }
@Override public void executeMsg(final Environmental myHost, final CMMsg msg) { if ((System.currentTimeMillis() - lastClanCheck) > TimeManager.MILI_HOUR) { lastClanCheck = System.currentTimeMillis(); if ((clanID().length() > 0) && (CMLib.clans().getClan(clanID()) == null)) { destroy(); return; } } if (StdClanItem.stdExecuteMsg(this, msg)) { super.executeMsg(myHost, msg); if ((msg.amITarget(this)) && (clanID().length() > 0) && (msg.source().getClanRole(clanID()) != null)) { final Room R = msg.source().location(); if (R == null) return; if ((msg.targetMinor() == CMMsg.TYP_DROP) && (msg.trailerMsgs() == null)) { msg.addTrailerMsg(CMClass.getMsg(msg.source(), this, CMMsg.MSG_LOOK, null)); setRightfulOwner(R); } else if ((msg.targetMinor() == CMMsg.TYP_LOOK) || (msg.targetMinor() == CMMsg.TYP_EXAMINE)) { final LegalBehavior B = CMLib.law().getLegalBehavior(R); String s = ""; if (B != null) s = B.conquestInfo(CMLib.law().getLegalObject(R)); if (s.length() > 0) msg.source().tell(s); else msg.source().tell(L("This area is under the control of the Archons.")); return; } else if ((msg.targetMinor() == CMMsg.TYP_SPEAK) && (CMSecurity.isAllowed(msg.source(), R, CMSecurity.SecFlag.CMDROOMS)) && (msg.targetMessage() != null)) { final String msgStr = CMStrings.getSayFromMessage(msg.targetMessage().toUpperCase()); final String alert = "I HEREBY DECLARE THIS AREA"; final int msgIndex = msgStr.indexOf(alert); if (msgIndex >= 0) { final LegalBehavior B = CMLib.law().getLegalBehavior(R); if (B != null) B.setControlPoints(clanID(), B.controlPoints() + 1); } } } } }
@Override public int castingQuality(MOB mob, Physical target) { if ((mob != null) && (target != null) && (target instanceof MOB)) { final Race R = ((MOB) target).charStats().getMyRace(); if (R.bodyMask()[Race.BODY_HEAD] <= 0) return Ability.QUALITY_INDIFFERENT; LegalBehavior B = null; if (mob.location() != null) B = CMLib.law().getLegalBehavior(mob.location()); List<LegalWarrant> warrants = new Vector<LegalWarrant>(); if (B != null) warrants = B.getWarrantsOf(CMLib.law().getLegalObject(mob.location()), (MOB) target); if (warrants.size() == 0) return Ability.QUALITY_INDIFFERENT; final Item w = mob.fetchWieldedItem(); Weapon ww = null; if ((w == null) || (!(w instanceof Weapon))) return Ability.QUALITY_INDIFFERENT; ww = (Weapon) w; if (ww.weaponDamageType() != Weapon.TYPE_SLASHING) return Ability.QUALITY_INDIFFERENT; if (mob.isInCombat() && (mob.rangeToTarget() > 0)) return Ability.QUALITY_INDIFFERENT; if (!CMLib.flags().isBoundOrHeld(target)) return Ability.QUALITY_INDIFFERENT; } return super.castingQuality(mob, target); }
@Override public boolean okMessage(final Environmental myHost, final CMMsg msg) { if (affected == null) return super.okMessage(myHost, msg); if (affected instanceof MOB) { final MOB mob = (MOB) affected; if ((msg.amITarget(mob)) && (!msg.amISource(mob)) && (mob.location() != msg.source().location()) && (msg.tool() instanceof Ability) && (CMath.bset(((Ability) msg.tool()).flags(), Ability.FLAG_TRANSPORTING)) && (!mob.amDead())) { final Ability A = (Ability) msg.tool(); if (((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_CHANT) || ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SPELL) || ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_PRAYER) || ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SONG)) msg.source() .location() .showHappens( CMMsg.MSG_OK_VISUAL, L("Magical energy fizzles and is absorbed into the air!")); return false; } } else if (affected instanceof Room) { final Room R = (Room) affected; if ((msg.tool() instanceof Ability) && (msg.source().location() != null) && (msg.sourceMinor() != CMMsg.TYP_LEAVE)) { final boolean summon = CMath.bset(((Ability) msg.tool()).flags(), Ability.FLAG_SUMMONING); final boolean teleport = CMath.bset(((Ability) msg.tool()).flags(), Ability.FLAG_TRANSPORTING); final boolean shere = (msg.source().location() == affected) || ((affected instanceof Area) && (((Area) affected).inMyMetroArea(msg.source().location().getArea()))); if ((!shere) && (!summon) && (teleport) && (!CMLib.law().doesHavePriviledgesHere(msg.source(), R))) { if ((msg.source().location() != null) && (msg.source().location() != R)) msg.source() .location() .showHappens( CMMsg.MSG_OK_VISUAL, L("Magical energy fizzles and is absorbed into the air!")); R.showHappens( CMMsg.MSG_OK_VISUAL, L("Magic energy fizzles and is absorbed into the air.")); return false; } } } return super.okMessage(myHost, msg); }
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; }
@Override public void executeMsg(final Environmental myHost, final CMMsg msg) { if ((msg.targetMinor() == CMMsg.TYP_ENTER) && (msg.target() == affected) && (msg.source() != invoker()) && (!msg.source().Name().equals(text())) && (!sprung) && (invoker() != null) && (invoker().mayIFight(msg.source())) && ((canBeUninvoked()) || (!CMLib.law().doesHavePriviledgesHere(msg.source(), (Room) affected))) && (CMLib.dice().rollPercentage() > msg.source().charStats().getSave(CharStats.STAT_SAVE_TRAPS))) CMLib.combat().postDeath(invoker(), msg.source(), msg); super.executeMsg(myHost, msg); }
@Override public boolean invoke( MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) { Physical target = null; if (commands.size() > 0) { final String s = CMParms.combine(commands, 0); if (s.equalsIgnoreCase("room")) target = mob.location(); else if (s.equalsIgnoreCase("here")) target = mob.location(); else if (CMLib.english().containsString(mob.location().ID(), s) || CMLib.english().containsString(mob.location().name(), s) || CMLib.english().containsString(mob.location().displayText(), s)) target = mob.location(); } if (target == null) target = getTarget(mob, commands, givenTarget); if (target == null) return false; if ((target instanceof Room) && (target.fetchEffect(ID()) != null)) { mob.tell(L("This place is already under a teleportation ward.")); 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), auto ? L("<T-NAME> seem(s) magically protected.") : L("^S<S-NAME> invoke(s) a teleportation ward upon <T-NAMESELF>.^?")); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); if ((target instanceof Room) && (CMLib.law().doesOwnThisLand(mob, ((Room) target)))) { target.addNonUninvokableEffect((Ability) this.copyOf()); CMLib.database().DBUpdateRoom((Room) target); } else beneficialAffect(mob, target, asLevel, 0); } } else beneficialWordsFizzle( mob, target, L("<S-NAME> attempt(s) to invoke a teleportation ward, but fail(s).")); return success; }
@Override public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) { final Physical target = mob.location(); if (target == null) return false; if (target.fetchEffect(ID()) != null) { mob.tell(L("This place is already consecrated.")); 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), auto ? "" : L("^S<S-NAME> @x1 to consecrate this place.^?", prayForWord(mob))); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); setMiscText(mob.Name()); if ((target instanceof Room) && (CMLib.law().doesOwnThisLand(mob, ((Room) target)))) { target.addNonUninvokableEffect((Ability) this.copyOf()); CMLib.database().DBUpdateRoom((Room) target); } else beneficialAffect(mob, target, asLevel, 0); } } else beneficialWordsFizzle( mob, target, L( "<S-NAME> @x1 to consecrate this place, but <S-IS-ARE> not answered.", prayForWord(mob))); return success; }
@Override public boolean invoke( MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) { if (!mob.clans().iterator().hasNext()) { mob.tell(L("You aren't even a member of a clan.")); return false; } final Pair<Clan, Integer> clanPair = CMLib.clans().findPrivilegedClan(mob, Clan.Function.CLAN_BENEFITS); if (clanPair == null) { mob.tell(L("You are not authorized to draw from the power of your clan.")); return false; } final Clan C = clanPair.first; Room clanHomeRoom = null; clanHomeRoom = CMLib.map().getRoom(C.getRecall()); if (clanHomeRoom == null) { mob.tell(L("Your clan does not have a clan home.")); return false; } if (!CMLib.flags().canAccess(mob, clanHomeRoom)) { mob.tell(L("You can't use this magic to get there from here.")); return false; } if (!CMLib.law().doesOwnThisProperty(C.clanID(), clanHomeRoom)) { mob.tell(L("Your clan no longer owns that room.")); 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, null, this, CMMsg.MASK_MOVE | verbalCastCode(mob, mob, auto), L("^S<S-NAME> invoke(s) a teleportation spell.^?")); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); final Set<MOB> h = properTargets(mob, givenTarget, false); if (h == null) return false; final Room thisRoom = mob.location(); for (final Object element : h) { final MOB follower = (MOB) element; final CMMsg enterMsg = CMClass.getMsg( follower, clanHomeRoom, this, CMMsg.MSG_ENTER, null, CMMsg.MSG_ENTER, null, CMMsg.MSG_ENTER, L("<S-NAME> appears in a puff of red smoke.")); final CMMsg leaveMsg = CMClass.getMsg( follower, thisRoom, this, CMMsg.MSG_LEAVE | CMMsg.MASK_MAGIC, L("<S-NAME> disappear(s) in a puff of red smoke.")); if (thisRoom.okMessage(follower, leaveMsg) && clanHomeRoom.okMessage(follower, enterMsg)) { if (follower.isInCombat()) { CMLib.commands().postFlee(follower, ("NOWHERE")); follower.makePeace(false); } thisRoom.send(follower, leaveMsg); clanHomeRoom.bringMobHere(follower, false); clanHomeRoom.send(follower, enterMsg); follower.tell(L("\n\r\n\r")); CMLib.commands().postLook(follower, true); } } } } else beneficialWordsFizzle( mob, null, L("<S-NAME> attempt(s) to invoke transportation, but fizzle(s) the spell.")); // return whether it worked return success; }
@Override public boolean invoke( MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) { final Physical target = getAnyTarget(mob, commands, givenTarget, Wearable.FILTER_ANY, true); if (target == null) return false; if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false; int type = verbalCastCode(mob, target, auto); if ((target instanceof MOB) && (CMath.bset(type, CMMsg.MASK_MALICIOUS)) && (((MOB) target).charStats().getStat(CharStats.STAT_AGE) > 0)) { final MOB mobt = (MOB) target; if (mobt.charStats().ageCategory() <= Race.AGE_CHILD) type = CMath.unsetb(type, CMMsg.MASK_MALICIOUS); else if ((mobt.getLiegeID().equals(mob.Name())) || (mobt.amFollowing() == mob)) type = CMath.unsetb(type, CMMsg.MASK_MALICIOUS); else if ((mobt.charStats().ageCategory() <= Race.AGE_MATURE) && (mobt.getLiegeID().length() > 0)) type = CMath.unsetb(type, CMMsg.MASK_MALICIOUS); } if ((target instanceof Item) || ((target instanceof MOB) && (((MOB) target).isMonster()) && (CMLib.flags().isAnimalIntelligence((MOB) target)) && (CMLib.law().doesHavePriviledgesHere(mob, mob.location())))) { type = CMath.unsetb(type, CMMsg.MASK_MALICIOUS); } boolean success = proficiencyCheck(mob, 0, auto); if (success) { final CMMsg msg = CMClass.getMsg( mob, target, this, type, auto ? "" : L("^S<S-NAME> chant(s) to <T-NAMESELF>.^?")); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); final Ability A = target.fetchEffect("Age"); if ((!(target instanceof MOB)) && (!(target instanceof CagedAnimal)) && (A == null)) { if (target instanceof Food) { mob.tell(L("@x1 rots away!", target.name(mob))); ((Item) target).destroy(); } else if (target instanceof Item) { switch (((Item) target).material() & RawMaterial.MATERIAL_MASK) { case RawMaterial.MATERIAL_CLOTH: case RawMaterial.MATERIAL_FLESH: case RawMaterial.MATERIAL_LEATHER: case RawMaterial.MATERIAL_PAPER: case RawMaterial.MATERIAL_VEGETATION: case RawMaterial.MATERIAL_WOODEN: { mob.location() .showHappens(CMMsg.MSG_OK_VISUAL, L("@x1 rots away!", target.name())); if (target instanceof Container) ((Container) target).emptyPlease(false); ((Item) target).destroy(); break; } default: mob.location() .showHappens( CMMsg.MSG_OK_VISUAL, L("@x1 ages, but nothing happens to it.", target.name())); break; } } else mob.location() .showHappens( CMMsg.MSG_OK_VISUAL, L("@x1 ages, but nothing happens to it.", target.name())); success = false; } else if ((target instanceof MOB) && ((A == null) || (A.displayText().length() == 0))) { final MOB M = (MOB) target; mob.location().show(M, null, CMMsg.MSG_OK_VISUAL, L("<S-NAME> age(s) a bit.")); if (M.baseCharStats().getStat(CharStats.STAT_AGE) <= 0) M.setAgeMinutes(M.getAgeMinutes() + (M.getAgeMinutes() / 10)); else if ((M.playerStats() != null) && (M.playerStats().getBirthday() != null)) { final TimeClock C = CMLib.time().localClock(M.getStartRoom()); final double aging = CMath.mul(M.baseCharStats().getStat(CharStats.STAT_AGE), .10); int years = (int) Math.round(Math.floor(aging)); final int monthsInYear = C.getMonthsInYear(); int months = (int) Math.round(CMath.mul(aging - Math.floor(aging), monthsInYear)); if ((years <= 0) && (months == 0)) months++; M.playerStats().getBirthday()[PlayerStats.BIRTHDEX_YEAR] -= years; M.playerStats().getBirthday()[PlayerStats.BIRTHDEX_MONTH] -= months; if (M.playerStats().getBirthday()[PlayerStats.BIRTHDEX_MONTH] < 1) { M.playerStats().getBirthday()[PlayerStats.BIRTHDEX_YEAR]--; years++; M.playerStats().getBirthday()[PlayerStats.BIRTHDEX_MONTH] = monthsInYear + M.playerStats().getBirthday()[PlayerStats.BIRTHDEX_MONTH]; } M.baseCharStats() .setStat(CharStats.STAT_AGE, M.baseCharStats().getStat(CharStats.STAT_AGE) + years); } M.recoverPhyStats(); M.recoverCharStats(); } else if (A != null) { final long start = CMath.s_long(A.text()); long age = System.currentTimeMillis() - start; final long millisPerMudday = CMProps.getIntVar(CMProps.Int.TICKSPERMUDDAY) * CMProps.getTickMillis(); if (age < millisPerMudday) age = millisPerMudday; final long millisPerMonth = CMLib.time().globalClock().getDaysInMonth() * millisPerMudday; final long millisPerYear = CMLib.time().globalClock().getMonthsInYear() * millisPerMonth; long ageBy = age / 10; if (ageBy < millisPerMonth) ageBy = millisPerMonth + 1; else if (ageBy < millisPerYear) ageBy = millisPerYear + 1; A.setMiscText("" + (start - ageBy)); if (target instanceof MOB) mob.location() .show((MOB) target, null, CMMsg.MSG_OK_VISUAL, L("<S-NAME> age(s) a bit.")); else mob.location().showHappens(CMMsg.MSG_OK_VISUAL, L("@x1 ages a bit.", target.name())); target.recoverPhyStats(); } else return beneficialWordsFizzle( mob, target, L("<S-NAME> chant(s) to <T-NAMESELF>, but the magic fades.")); } } else if (CMath.bset(type, CMMsg.MASK_MALICIOUS)) return maliciousFizzle( mob, target, L("<S-NAME> chant(s) to <T-NAMESELF>, but the magic fades.")); else return beneficialWordsFizzle( mob, target, L("<S-NAME> chant(s) to <T-NAMESELF>, but the magic fades.")); // return whether it worked return success; }
@Override public boolean invoke( MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) { if (commands.size() < 1) { mob.tell(L("Pay Off Whom?")); return false; } final MOB target = this.getTarget(mob, commands, givenTarget); if (target == null) return false; if ((target.charStats().getStat(CharStats.STAT_INTELLIGENCE) < 3) || (!target.isMonster())) { mob.tell(L("You can't pay off @x1.", target.name(mob))); return false; } final LegalBehavior B = CMLib.law().getLegalBehavior(mob.location()); final Area A = (B == null) ? null : CMLib.law().getLegalObject(mob.location()); if ((A == null) || (B == null)) { mob.tell(L("There's no point in paying off @x1.", target.name(mob))); return false; } boolean isJudge = B.isJudge(A, target); if ((!isJudge) && (!B.isAnyOfficer(A, target))) { mob.tell(L("Paying off @x1 won't help you.", target.name(mob))); return false; } final List<LegalWarrant> warrants = B.getWarrantsOf(A, mob); if ((warrants == null) || (warrants.size() == 0)) { mob.tell(L("Pay off @x1? Why? You aren't in any trouble.", target.name(mob))); return false; } if (target.fetchEffect(ID()) != null) { mob.tell(L("@x1 is already paid off.", target.name(mob))); return false; } if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false; double amountRequired = CMLib.beanCounter().getTotalAbsoluteNativeValue(target) + ((double) ((100l - ((mob.charStats().getStat(CharStats.STAT_CHARISMA) + (2l * getXLEVELLevel(mob))) * 2))) * target.phyStats().level()); if (isJudge) amountRequired *= 2; final String currency = CMLib.beanCounter().getCurrency(target); boolean success = proficiencyCheck(mob, 0, auto); if ((!success) || (CMLib.beanCounter().getTotalAbsoluteValue(mob, currency) < amountRequired)) { final CMMsg msg = CMClass.getMsg( mob, target, this, CMMsg.MSG_SPEAK, L( "^T<S-NAME> attempt(s) to pay off <T-NAMESELF> to '@x1', but no deal is reached.^?", CMParms.combine(commands, 0))); if (mob.location().okMessage(mob, msg)) mob.location().send(mob, msg); if (CMLib.beanCounter().getTotalAbsoluteValue(mob, currency) < amountRequired) { final String costWords = CMLib.beanCounter().nameCurrencyShort(currency, amountRequired); mob.tell(L("@x1 requires @x2 to do this.", target.charStats().HeShe(), costWords)); } success = false; } else { final String costWords = CMLib.beanCounter().nameCurrencyShort(target, amountRequired); final CMMsg msg = CMClass.getMsg( mob, target, this, CMMsg.MSG_THIEF_ACT, L("^T<S-NAME> pay(s) off <T-NAMESELF>.^?", CMParms.combine(commands, 0), costWords)); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); CMLib.beanCounter().subtractMoney(mob, currency, amountRequired); CMLib.beanCounter().addMoney(mob, currency, amountRequired); if (isJudge) { for (LegalWarrant W : warrants) { if (W.punishment() > 0) W.setPunishment(W.punishment() - 1); } } else { clearWarrants(target, mob, mob.location(), A, B); super.beneficialAffect(mob, target, asLevel, 0); } } target.recoverPhyStats(); } return success; }
@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; }
@Override public boolean invoke( MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) { final MOB target = super.getTarget(mob, commands, givenTarget); if (target == null) return false; final Race R = target.charStats().getMyRace(); if (R.bodyMask()[Race.BODY_HEAD] <= 0) { mob.tell(L("@x1 has no head!", target.name(mob))); return false; } LegalBehavior B = null; if (mob.location() != null) B = CMLib.law().getLegalBehavior(mob.location()); List<LegalWarrant> warrants = new Vector<LegalWarrant>(); if (B != null) warrants = B.getWarrantsOf(CMLib.law().getLegalObject(mob.location()), target); if ((warrants.size() == 0) && (!CMSecurity.isAllowed(mob, mob.location(), CMSecurity.SecFlag.ABOVELAW))) { mob.tell(L("You are not allowed to behead @x1 at this time.", target.Name())); return false; } final Item w = mob.fetchWieldedItem(); Weapon ww = null; if ((w == null) || (!(w instanceof Weapon))) { mob.tell(L("You cannot behead without a weapon!")); return false; } ww = (Weapon) w; if ((!auto) && (!CMSecurity.isASysOp(mob))) { if (ww.weaponDamageType() != Weapon.TYPE_SLASHING) { mob.tell(L("You cannot behead with a @x1!", ww.name())); return false; } if (mob.isInCombat() && (mob.rangeToTarget() > 0)) { mob.tell(L("You are too far away to try that!")); return false; } if (!CMLib.flags().isBoundOrHeld(target)) { mob.tell(L("@x1 is not bound and would resist.", target.charStats().HeShe())); 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 = levelDiff * 3; else levelDiff = 0; final boolean hit = (auto) || CMLib.combat().rollToHit(mob, target); boolean success = proficiencyCheck(mob, 0, auto) && (hit); if (success) { final CMMsg msg = CMClass.getMsg( mob, target, this, CMMsg.MASK_MALICIOUS | CMMsg.MASK_MOVE | CMMsg.MASK_SOUND | CMMsg.TYP_JUSTICE | (auto ? CMMsg.MASK_ALWAYS : 0), null); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); target.curState().setHitPoints(1); final Ability A2 = target.fetchEffect("Injury"); if (A2 != null) A2.setMiscText(mob.Name() + "/head"); CMLib.combat() .postDamage( mob, target, ww, Integer.MAX_VALUE / 2, CMMsg.MSG_WEAPONATTACK, ww.weaponClassification(), auto ? "" : L( "^F^<FIGHT^><S-NAME> rear(s) back and behead(s) <T-NAME>!^</FIGHT^>^?@x1", CMLib.protocol().msp("decap.wav", 30))); mob.location().recoverRoomStats(); final Item limb = CMClass.getItem("GenLimb"); limb.setName(L("@x1`s head", target.Name())); limb.basePhyStats().setAbility(1); limb.setDisplayText(L("the bloody head of @x1 is sitting here.", target.Name())); limb.setSecretIdentity(target.name() + "`s bloody head."); int material = RawMaterial.RESOURCE_MEAT; for (int r = 0; r < R.myResources().size(); r++) { final Item I = R.myResources().get(r); final int mat = I.material() & RawMaterial.MATERIAL_MASK; if (((mat == RawMaterial.MATERIAL_FLESH)) || (r == R.myResources().size() - 1)) { material = I.material(); break; } } limb.setMaterial(material); limb.basePhyStats().setLevel(1); limb.basePhyStats().setWeight(5); limb.recoverPhyStats(); mob.location().addItem(limb, ItemPossessor.Expire.Player_Drop); for (int i = 0; i < warrants.size(); i++) { final LegalWarrant W = warrants.get(i); W.setCrime("pardoned"); W.setOffenses(0); } } else success = false; if (mob.getVictim() == target) mob.makePeace(true); if (target.getVictim() == mob) target.makePeace(true); } else maliciousFizzle(mob, target, L("<S-NAME> attempt(s) a beheading and fail(s)!")); return success; }