@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; }
public List<Object> convertToV2(List<Ability> spellsV, Physical target) { final List<Object> VTOO = new Vector<Object>(); for (int v = 0; v < spellsV.size(); v++) { Ability A = spellsV.get(v); final Ability EA = (target != null) ? target.fetchEffect(A.ID()) : null; if ((EA == null) && (didHappen())) { final String t = A.text(); A = (Ability) A.copyOf(); Vector<String> V2 = new Vector<String>(); if (t.length() > 0) { final int x = t.indexOf('/'); if (x < 0) { V2 = CMParms.parse(t); A.setMiscText(""); } else { V2 = CMParms.parse(t.substring(0, x)); A.setMiscText(t.substring(x + 1)); } } VTOO.add(A); VTOO.add(V2); } } return VTOO; }
public List<Ability> getMySpellsV() { if (spellV != null) return spellV; spellV = new Vector<Ability>(); final String names = getParmString(text()); final List<String> set = CMParms.parseSemicolons(names, true); String thisOne = null; for (int s = 0; s < set.size(); s++) { thisOne = set.get(s); if (thisOne.equalsIgnoreCase("NOUNINVOKE")) { this.uninvocable = false; continue; } if (thisOne.toUpperCase().startsWith("LEVEL")) { level = (short) CMParms.getParmInt(thisOne, "LEVEL", -1); if (level >= 0) continue; } if (thisOne.toUpperCase().startsWith("MAXTICKS")) { maxTicks = (short) CMParms.getParmInt(thisOne, "MAXTICKS", -1); if (maxTicks != -1) continue; } final int pctDex = thisOne.indexOf("% "); if ((pctDex > 0) && (thisOne.substring(pctDex + 1).trim().length() > 0)) thisOne = thisOne.substring(pctDex + 1).trim(); String parm = ""; if ((thisOne != null) && (thisOne.endsWith(")"))) { final int x = thisOne.indexOf('('); if (x > 0) { parm = thisOne.substring(x + 1, thisOne.length() - 1); thisOne = thisOne.substring(0, x).trim(); } } Ability A = CMClass.getAbility(thisOne); if ((A != null) && ((A.classificationCode() & Ability.ALL_DOMAINS) != Ability.DOMAIN_ARCHON)) { A = (Ability) A.copyOf(); A.setMiscText(parm); spellV.add(A); } } return spellV; }
@Override public void executeMsg(final Environmental myHost, final CMMsg msg) { super.executeMsg(myHost, msg); if ((myHost == null) || (!(myHost instanceof MOB))) return; final MOB mob = (MOB) myHost; if (msg.amISource(mob)) { if (((msg.sourceMinor() == CMMsg.TYP_LOOK) || (msg.sourceMinor() == CMMsg.TYP_EXAMINE)) && (msg.target() instanceof Wand) && (mob.charStats().getClassLevel(this) >= 30)) { final String message = "<O-NAME> has " + ((Wand) msg.target()).usesRemaining() + " charges remaining."; msg.addTrailerMsg( CMClass.getMsg( mob, null, msg.target(), CMMsg.MSG_OK_VISUAL, CMMsg.NO_EFFECT, CMMsg.NO_EFFECT, message)); } else if (msg.tool() != null) { if (msg.tool().ID().equals("Skill_Spellcraft")) { if ((msg.tool().text().length() > 0) && (msg.target() instanceof MOB)) { Ability A = ((MOB) msg.target()).fetchAbility(msg.tool().text()); if (A == null) return; final Ability myA = mob.fetchAbility(A.ID()); if (myA != null) { if ((!A.isSavable()) && ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SPELL) && (CMLib.ableMapper().lowestQualifyingLevel(A.ID()) < 30)) addAbilityToSpellcraftList(mob, A); } else if (CMLib.ableMapper().lowestQualifyingLevel(A.ID()) < 30) { final Vector<Ability> otherChoices = new Vector<Ability>(); for (int a = 0; a < mob.numAbilities(); a++) { final Ability A2 = mob.fetchAbility(a); if ((A2 != null) && (!A2.isSavable()) && ((A2.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SPELL)) otherChoices.addElement(A2); } A = (Ability) A.copyOf(); A.setProficiency(0); A.setSavable(false); if (otherChoices.size() > (mob.charStats().getClassLevel(this) / 3)) { final Ability A2 = otherChoices.elementAt(CMLib.dice().roll(1, otherChoices.size(), -1)); clearAbilityFromSpellcraftList(mob, A2); } addAbilityToSpellcraftList(mob, A); } } } else if (msg.tool().ID().equals("Spell_Scribe") || msg.tool().ID().equals("Spell_EnchantWand") || msg.tool().ID().equals("Spell_MagicItem") || msg.tool().ID().equals("Spell_StoreSpell") || msg.tool().ID().equals("Spell_WardArea")) { final Ability A = mob.fetchAbility(msg.tool().text()); if ((A != null) && (!A.isSavable())) clearAbilityFromSpellcraftList(mob, A); } else if (msg.tool() instanceof Ability) { final Ability A = mob.fetchAbility(msg.tool().ID()); if ((A != null) && (!A.isSavable()) && ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SPELL)) clearAbilityFromSpellcraftList(mob, A); } } } }