@Override public boolean tick(Tickable ticking, int tickID) { if (!super.tick(ticking, tickID)) return false; if ((tickID == Tickable.TICKID_MOB) && (invoker() != null) && (affected instanceof MOB)) { final MOB mob = (MOB) affected; final Set<MOB> invokerGroup = invoker().getGroupMembers(new HashSet<MOB>()); if (mob != invoker()) { if (mob.location() != invoker().location()) unInvoke(); else { if (invokerGroup.contains(mob)) unInvoke(); else if (mob.isInCombat()) { int levels = invoker().charStats().getClassLevel("Templar"); if (levels < 0) levels = invoker().phyStats().level(); if (CMLib.dice().rollPercentage() >= levels) { final MOB newvictim = mob.location().fetchRandomInhabitant(); if (newvictim != mob) mob.setVictim(newvictim); } } } } else if ((mob.location() != null) && (CMLib.flags().isEvil(invoker()))) { for (int m = 0; m < mob.location().numInhabitants(); m++) { final MOB M = mob.location().fetchInhabitant(m); if ((M != null) && (M != invoker()) && (!invokerGroup.contains(M)) && (!M.Name().equals(mob.getLiegeID()))) beneficialAffect(invoker, M, 0, Ability.TICKS_FOREVER); } } } return true; }
@Override public boolean isValidClassDivider(MOB killer, MOB killed, MOB mob, Set<MOB> followers) { if ((mob != null) && (mob != killed) && (!mob.amDead()) && ((!mob.isMonster()) || (!CMLib.flags().isAnimalIntelligence(mob))) && ((mob.getVictim() == killed) || (followers.contains(mob)) || (mob == killer))) return true; return false; }
@Override public void setRacialStat(final int abilityCode, final int racialMax) { if ((!CharStats.CODES.isBASE(abilityCode)) || (getStat(abilityCode) == VALUE_ALLSTATS_DEFAULT)) setPermanentStat(abilityCode, racialMax); else { final int baseMax = CMProps.getIntVar(CMProps.Int.BASEMAXSTAT); int currMax = getStat(CharStats.CODES.toMAXBASE(abilityCode)) + baseMax; if (currMax <= 0) currMax = 1; int curStat = getStat(abilityCode); if (curStat > currMax * 7) { final String errorMsg = "Detected mob with " + curStat + "/" + currMax + " " + CharStats.CODES.ABBR(abilityCode); @SuppressWarnings({"unchecked", "rawtypes"}) Set<String> errs = (Set) Resources.getResource("SYSTEM_DEFCHARSTATS_ERRORS"); if (errs == null) { errs = new TreeSet<String>(); Resources.submitResource("SYSTEM_DEFCHARSTATS_ERRORS", errs); } if (!errs.contains(errorMsg)) { errs.add(errorMsg); final StringBuilder str = new StringBuilder(errorMsg); // ByteArrayOutputStream stream=new ByteArrayOutputStream(); // new Exception().printStackTrace(new PrintStream(stream)); // str.append("\n\r"+new String(stream.toByteArray())); Log.errOut("DefCharStats", str.toString()); } curStat = currMax * 7; } final int pctOfMax = Math.round(((float) curStat / (float) currMax) * racialMax); final int stdMaxAdj = Math.round((((float) (currMax - VALUE_ALLSTATS_DEFAULT)) / (float) currMax) * racialMax); final int racialStat = pctOfMax + stdMaxAdj; setStat(abilityCode, ((racialStat < 1) && (racialMax > 0)) ? 1 : racialStat); setStat(CharStats.CODES.toMAXBASE(abilityCode), racialMax - baseMax); } }
@Override public void spring(MOB mob) { final Room room = mob.location(); if (room != null) { final Set<MOB> friendlySet = new HashSet<MOB>(); if (invoker() != null) invoker().getGroupMembers(friendlySet); room.show( mob, affected, CMMsg.MSG_OK_ACTION, L("<T-NAME> explodes, spraying clumps of stomach acid everywhere!")); for (final Enumeration<MOB> m = room.inhabitants(); m.hasMoreElements(); ) { MOB M = m.nextElement(); if ((M != null) && (!friendlySet.contains(M))) { final MOB invoker = (invoker() != null) ? invoker() : M; final int damage = CMLib.dice().roll(4, 5 + invoker.phyStats().level(), 0); CMLib.combat() .postDamage( invoker, M, this, damage, CMMsg.MASK_MALICIOUS | CMMsg.MASK_ALWAYS | CMMsg.TYP_ACID, Weapon.TYPE_MELTING, L("The acid clumps <DAMAGE> <T-NAME>!")); if ((!M.isInCombat()) && (M.isMonster()) && (M != invoker) && (M.location() == invoker.location()) && (M.location().isInhabitant(invoker)) && (CMLib.flags().canBeSeenBy(invoker, M))) CMLib.combat().postAttack(M, invoker, M.fetchWieldedItem()); } } } Physical affected = this.affected; unInvoke(); if (affected instanceof Item) ((Item) affected).destroy(); }