public void recursiveDropMOB(MOB mob, Room room, Item thisContainer, boolean bodyFlag) { // caller is responsible for recovering any env // stat changes! if (CMLib.flags().isHidden(thisContainer)) thisContainer .baseEnvStats() .setDisposition( thisContainer.baseEnvStats().disposition() & ((int) EnvStats.ALLMASK - EnvStats.IS_HIDDEN)); mob.delInventory(thisContainer); thisContainer.unWear(); if (!bodyFlag) bodyFlag = (thisContainer instanceof DeadBody); if (bodyFlag) { room.addItem(thisContainer); thisContainer.setExpirationDate(0); } else room.addItemRefuse(thisContainer, CMProps.getIntVar(CMProps.SYSTEMI_EXPIRE_PLAYER_DROP)); thisContainer.recoverEnvStats(); boolean nothingDone = true; do { nothingDone = true; for (int i = 0; i < mob.inventorySize(); i++) { Item thisItem = mob.fetchInventory(i); if ((thisItem != null) && (thisItem.container() == thisContainer)) { recursiveDropMOB(mob, room, thisItem, bodyFlag); nothingDone = false; break; } } } while (!nothingDone); }
public boolean armorCheck(MOB mob, int allowedArmorLevel) { if (allowedArmorLevel == CharClass.ARMOR_ANY) return true; for (int i = 0; i < mob.inventorySize(); i++) { Item I = mob.fetchInventory(i); if ((I != null) && (!I.amWearingAt(Wearable.IN_INVENTORY))) { boolean ok = armorCheck(mob, I, allowedArmorLevel); if ((!ok) && ((I.rawWornCode() & CharClass.ARMOR_WEARMASK) > 0)) return false; } } return true; }
public void confirmWearability(MOB mob) { if (mob == null) return; Race R = mob.charStats().getMyRace(); DVector reWearSet = new DVector(2); Item item = null; for (int i = 0; i < mob.inventorySize(); i++) { item = mob.fetchInventory(i); if ((item != null) && (!item.amWearingAt(Wearable.IN_INVENTORY))) { Long oldCode = Long.valueOf(item.rawWornCode()); item.unWear(); if (reWearSet.size() == 0) reWearSet.addElement(item, oldCode); else { short layer = (item instanceof Armor) ? ((Armor) item).getClothingLayer() : 0; int d = 0; for (; d < reWearSet.size(); d++) if (reWearSet.elementAt(d, 1) instanceof Armor) { if (((Armor) reWearSet.elementAt(d, 1)).getClothingLayer() > layer) break; } else if (0 > layer) break; if (d >= reWearSet.size()) reWearSet.addElement(item, oldCode); else reWearSet.insertElementAt(d, item, oldCode); } } } for (int r = 0; r < reWearSet.size(); r++) { item = (Item) reWearSet.elementAt(r, 1); long oldCode = ((Long) reWearSet.elementAt(r, 2)).longValue(); int msgCode = CMMsg.MSG_WEAR; if ((oldCode & Wearable.WORN_WIELD) > 0) msgCode = CMMsg.MSG_WIELD; else if ((oldCode & Wearable.WORN_HELD) > 0) msgCode = CMMsg.MSG_HOLD; CMMsg msg = CMClass.getMsg( mob, item, null, CMMsg.NO_EFFECT, null, msgCode, null, CMMsg.NO_EFFECT, null); if ((R.okMessage(mob, msg)) && (item.okMessage(item, msg)) && ((mob.charStats().getWearableRestrictionsBitmap() & oldCode) == 0) && (item.canWear(mob, oldCode))) item.wearAt(oldCode); } // why wasn't that here before? mob.recoverEnvStats(); mob.recoverCharStats(); mob.recoverMaxState(); }
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); } }
public String builtPrompt(MOB mob) { StringBuffer buf = new StringBuffer("\n\r"); String prompt = mob.playerStats().getPrompt(); String promptUp = null; int c = 0; while (c < prompt.length()) if ((prompt.charAt(c) == '%') && (c < (prompt.length() - 1))) { switch (prompt.charAt(++c)) { case '-': if (c < (prompt.length() - 2)) { if (promptUp == null) promptUp = prompt.toUpperCase(); String promptSub = promptUp.substring(c + 1); Wearable.CODES wcodes = Wearable.CODES.instance(); boolean isFound = false; for (long code : wcodes.all()) if (promptSub.startsWith(wcodes.nameup(code))) { c += 1 + wcodes.nameup(code).length(); Item I = mob.fetchFirstWornItem(code); if (I != null) buf.append(I.name()); isFound = true; break; } if (!isFound) { CharStats.CODES ccodes = CharStats.CODES.instance(); for (int code : ccodes.all()) if (promptSub.startsWith(ccodes.name(code))) { c += 1 + ccodes.name(code).length(); buf.append(mob.charStats().getStat(code)); isFound = true; break; } if (!isFound) for (int code : ccodes.all()) if (promptSub.startsWith("BASE " + ccodes.name(code))) { buf.append(mob.baseCharStats().getStat(code)); c += 6 + ccodes.name(code).length(); isFound = true; break; } } if (!isFound) { for (String s : mob.envStats().getStatCodes()) if (promptSub.startsWith(s)) { c += 1 + s.length(); buf.append(mob.envStats().getStat(s)); isFound = true; break; } if (!isFound) for (String s : mob.baseEnvStats().getStatCodes()) if (promptSub.startsWith("BASE " + s)) { c += 6 + s.length(); buf.append(mob.baseEnvStats().getStat(s)); isFound = true; break; } } if (!isFound) { for (String s : mob.curState().getStatCodes()) if (promptSub.startsWith(s)) { c += 1 + s.length(); buf.append(mob.curState().getStat(s)); isFound = true; break; } if (!isFound) for (String s : mob.maxState().getStatCodes()) if (promptSub.startsWith("MAX " + s)) { c += 5 + s.length(); buf.append(mob.maxState().getStat(s)); isFound = true; break; } if (!isFound) for (String s : mob.baseState().getStatCodes()) if (promptSub.startsWith("BASE " + s)) { c += 6 + s.length(); buf.append(mob.baseState().getStat(s)); isFound = true; break; } } } break; case 'a': { buf.append( CMLib.factions() .getRangePercent( CMLib.factions().AlignID(), mob.fetchFaction(CMLib.factions().AlignID())) + "%"); c++; break; } case 'A': { Faction.FactionRange FR = CMLib.factions() .getRange( CMLib.factions().AlignID(), mob.fetchFaction(CMLib.factions().AlignID())); buf.append( (FR != null) ? FR.name() : "" + mob.fetchFaction(CMLib.factions().AlignID())); c++; break; } case 'B': { buf.append("\n\r"); c++; break; } case 'c': { buf.append(mob.inventorySize()); c++; break; } case 'C': { buf.append(mob.maxItems()); c++; break; } case 'd': { MOB victim = mob.getVictim(); if ((mob.isInCombat()) && (victim != null)) buf.append("" + mob.rangeToTarget()); c++; break; } case 'e': { MOB victim = mob.getVictim(); if ((mob.isInCombat()) && (victim != null) && (CMLib.flags().canBeSeenBy(victim, mob))) buf.append(victim.displayName(mob)); c++; break; } case 'E': { MOB victim = mob.getVictim(); if ((mob.isInCombat()) && (victim != null) && (!victim.amDead()) && (CMLib.flags().canBeSeenBy(victim, mob))) buf.append(victim.healthText(mob) + "\n\r"); c++; break; } case 'g': { buf.append( (int) Math.round( Math.floor( CMLib.beanCounter().getTotalAbsoluteNativeValue(mob) / CMLib.beanCounter() .getLowestDenomination( CMLib.beanCounter().getCurrency(mob))))); c++; break; } case 'G': { buf.append( CMLib.beanCounter() .nameCurrencyShort( mob, CMLib.beanCounter().getTotalAbsoluteNativeValue(mob))); c++; break; } case 'h': { buf.append("^<Hp^>" + mob.curState().getHitPoints() + "^</Hp^>"); c++; break; } case 'H': { buf.append("^<MaxHp^>" + mob.maxState().getHitPoints() + "^</MaxHp^>"); c++; break; } case 'I': { if ((CMLib.flags().isCloaked(mob)) && (((mob.envStats().disposition() & EnvStats.IS_NOT_SEEN) != 0))) buf.append("Wizinvisible"); else if (CMLib.flags().isCloaked(mob)) buf.append("Cloaked"); else if (!CMLib.flags().isSeen(mob)) buf.append("Undetectable"); else if (CMLib.flags().isInvisible(mob) && CMLib.flags().isHidden(mob)) buf.append("Hidden/Invisible"); else if (CMLib.flags().isInvisible(mob)) buf.append("Invisible"); else if (CMLib.flags().isHidden(mob)) buf.append("Hidden"); c++; break; } case 'K': case 'k': { MOB tank = mob; if ((tank.getVictim() != null) && (tank.getVictim().getVictim() != null) && (tank.getVictim().getVictim() != mob)) tank = tank.getVictim().getVictim(); if (((c + 1) < prompt.length()) && (tank != null)) switch (prompt.charAt(c + 1)) { case 'h': { buf.append(tank.curState().getHitPoints()); c++; break; } case 'H': { buf.append(tank.maxState().getHitPoints()); c++; break; } case 'm': { buf.append(tank.curState().getMana()); c++; break; } case 'M': { buf.append(tank.maxState().getMana()); c++; break; } case 'v': { buf.append(tank.curState().getMovement()); c++; break; } case 'V': { buf.append(tank.maxState().getMovement()); c++; break; } case 'e': { buf.append(tank.displayName(mob)); c++; break; } case 'E': { if ((mob.isInCombat()) && (CMLib.flags().canBeSeenBy(tank, mob))) buf.append(tank.healthText(mob) + "\n\r"); c++; break; } } c++; break; } case 'm': { buf.append("^<Mana^>" + mob.curState().getMana() + "^</Mana^>"); c++; break; } case 'M': { buf.append("^<MaxMana^>" + mob.maxState().getMana() + "^</MaxMana^>"); c++; break; } case 'r': { if (mob.location() != null) buf.append(mob.location().displayText()); c++; break; } case 'R': { if ((mob.location() != null) && CMSecurity.isAllowed(mob, mob.location(), "SYSMSGS")) buf.append(mob.location().roomID()); c++; break; } case 'v': { buf.append("^<Move^>" + mob.curState().getMovement() + "^</Move^>"); c++; break; } case 'V': { buf.append("^<MaxMove^>" + mob.maxState().getMovement() + "^</MaxMove^>"); c++; break; } case 'w': { buf.append(mob.envStats().weight()); c++; break; } case 'W': { buf.append(mob.maxCarry()); c++; break; } case 'x': { buf.append(mob.getExperience()); c++; break; } case 'X': { if (mob.getExpNeededLevel() == Integer.MAX_VALUE) buf.append("N/A"); else buf.append(mob.getExpNeededLevel()); c++; break; } case 'z': { if (mob.location() != null) buf.append(mob.location().getArea().name()); c++; break; } case 't': { if (mob.location() != null) buf.append( CMStrings.capitalizeAndLower( TimeClock.TOD_DESC[mob.location().getArea().getTimeObj().getTODCode()] .toLowerCase())); c++; break; } case 'T': { if (mob.location() != null) buf.append(mob.location().getArea().getTimeObj().getTimeOfDay()); c++; break; } case '@': { if (mob.location() != null) buf.append( mob.location().getArea().getClimateObj().weatherDescription(mob.location())); c++; break; } default: { buf.append("%" + prompt.charAt(c)); c++; break; } } } else buf.append(prompt.charAt(c++)); return buf.toString(); }
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; }
public static String getBasic(MOB M, int i) { StringBuffer str = new StringBuffer(""); switch (i) { case 0: str.append(M.Name() + ", "); break; case 1: str.append(M.description() + ", "); break; case 2: if (M.playerStats() != null) str.append(CMLib.time().date2String(M.playerStats().lastDateTime()) + ", "); break; case 3: if (M.playerStats() != null) str.append(M.playerStats().getEmail() + ", "); break; case 4: str.append(M.baseCharStats().getMyRace().name() + ", "); break; case 5: str.append( M.baseCharStats().getCurrentClass().name(M.baseCharStats().getCurrentClassLevel()) + ", "); break; case 6: str.append(M.baseEnvStats().level() + ", "); break; case 7: str.append(M.baseCharStats().displayClassLevel(M, true) + ", "); break; case 8: str.append(M.baseCharStats().getClassLevel(M.baseCharStats().getCurrentClass()) + ", "); break; case 9: { for (int c = M.charStats().numClasses() - 1; c >= 0; c--) { CharClass C = M.charStats().getMyClass(c); str.append( C.name(M.baseCharStats().getCurrentClassLevel()) + " (" + M.charStats().getClassLevel(C) + ") "); } str.append(", "); break; } case 10: if (M.maxCarry() > (Integer.MAX_VALUE / 3)) str.append("NA, "); else str.append(M.maxCarry() + ", "); break; case 11: str.append(CMStrings.capitalizeAndLower(CMLib.combat().fightingProwessStr(M)) + ", "); break; case 12: str.append(CMStrings.capitalizeAndLower(CMLib.combat().armorStr(M)) + ", "); break; case 13: str.append(CMLib.combat().adjustedDamage(M, null, null) + ", "); break; case 14: str.append(Math.round(CMath.div(M.getAgeHours(), 60.0)) + ", "); break; case 15: str.append(M.getPractices() + ", "); break; case 16: str.append(M.getExperience() + ", "); break; case 17: if (M.getExpNeededLevel() == Integer.MAX_VALUE) str.append("N/A, "); else str.append(M.getExpNextLevel() + ", "); break; case 18: str.append(M.getTrains() + ", "); break; case 19: str.append(CMLib.beanCounter().getMoney(M) + ", "); break; case 20: str.append(M.getWorshipCharID() + ", "); break; case 21: str.append(M.getLiegeID() + ", "); break; case 22: str.append(M.getClanID() + ", "); break; case 23: if (M.getClanID().length() > 0) { Clan C = CMLib.clans().getClan(M.getClanID()); if (C != null) str.append( CMLib.clans().getRoleName(C.getGovernment(), M.getClanRole(), true, false) + ", "); } break; case 24: str.append(M.fetchFaction(CMLib.factions().AlignID()) + ", "); break; case 25: { Faction.FactionRange FR = CMLib.factions() .getRange(CMLib.factions().AlignID(), M.fetchFaction(CMLib.factions().AlignID())); if (FR != null) str.append(FR.name() + ", "); else str.append(M.fetchFaction(CMLib.factions().AlignID())); break; } case 26: str.append(M.getWimpHitPoint() + ", "); break; case 27: if (M.getStartRoom() != null) str.append(M.getStartRoom().displayText() + ", "); break; case 28: if (M.location() != null) str.append(M.location().displayText() + ", "); break; case 29: if (M.getStartRoom() != null) str.append(M.getStartRoom().roomID() + ", "); break; case 30: if (M.location() != null) str.append(M.location().roomID() + ", "); break; case 31: { for (int inv = 0; inv < M.inventorySize(); inv++) { Item I = M.fetchInventory(inv); if ((I != null) && (I.container() == null)) str.append(I.name() + ", "); } break; } case 32: str.append(M.baseEnvStats().weight() + ", "); break; case 33: str.append(M.envStats().weight() + ", "); break; case 34: str.append(CMStrings.capitalizeAndLower(M.baseCharStats().genderName()) + ", "); break; case 35: if (M.playerStats() != null) str.append(M.playerStats().lastDateTime() + ", "); break; case 36: str.append(M.curState().getHitPoints() + ", "); break; case 37: str.append(M.curState().getMana() + ", "); break; case 38: str.append(M.curState().getMovement() + ", "); break; case 39: if (M.riding() != null) str.append(M.riding().name() + ", "); break; case 40: str.append(M.baseEnvStats().height() + ", "); break; case 41: if (!M.isMonster()) str.append(M.session().getAddress() + ", "); else if (M.playerStats() != null) str.append(M.playerStats().lastIP() + ", "); break; case 42: str.append(M.getQuestPoint() + ", "); break; case 43: str.append(M.maxState().getHitPoints() + ", "); break; case 44: str.append(M.maxState().getMana() + ", "); break; case 45: str.append(M.maxState().getMovement() + ", "); break; case 46: str.append(M.rawImage() + ", "); break; case 47: str.append(M.maxItems() + ", "); break; case 48: { String[] paths = CMProps.mxpImagePath(M.image()); if (paths[0].length() > 0) str.append(paths[0] + paths[1] + ", "); break; } case 49: if (CMProps.mxpImagePath(M.image())[0].length() > 0) str.append("true, "); else str.append("false, "); break; case 50: if (M.playerStats() != null) str.append(M.playerStats().notes() + ", "); break; case 51: if (M.playerStats() != null) { long lastDateTime = -1; for (int level = 0; level <= M.envStats().level(); level++) { long dateTime = M.playerStats().leveledDateTime(level); if ((dateTime > 1529122205) && (dateTime != lastDateTime)) { str.append("<TR>"); if (level == 0) str.append("<TD><FONT COLOR=WHITE>Created</FONT></TD>"); else str.append("<TD><FONT COLOR=WHITE>" + level + "</FONT></TD>"); str.append( "<TD><FONT COLOR=WHITE>" + CMLib.time().date2String(dateTime) + "</FONT></TD></TR>"); } } str.append(", "); } break; case 52: str.append(M.baseEnvStats().attackAdjustment() + ", "); break; case 53: str.append(M.baseEnvStats().damage() + ", "); break; case 54: str.append(M.baseEnvStats().armor() + ", "); break; case 55: str.append(M.envStats().speed() + ", "); break; case 56: str.append(M.baseEnvStats().speed() + ", "); break; case 57: { for (int e = 0; e < M.numExpertises(); e++) { String E = M.fetchExpertise(e); ExpertiseLibrary.ExpertiseDefinition X = CMLib.expertises().getDefinition(E); if (X == null) str.append(E + ", "); else str.append(X.name + ", "); } break; } case 58: { for (int t = 0; t < M.numTattoos(); t++) { String E = M.fetchTattoo(t); str.append(E + ", "); } break; } case 59: { if (M.playerStats() != null) for (int b = 0; b < M.playerStats().getSecurityGroups().size(); b++) { String B = (String) M.playerStats().getSecurityGroups().elementAt(b); if (B != null) str.append(B + ", "); } break; } case 60: { if (M.playerStats() != null) for (int b = 0; b < M.playerStats().getTitles().size(); b++) { String B = (String) M.playerStats().getTitles().elementAt(b); if (B != null) str.append(B + ", "); } break; } case 61: { for (Enumeration e = M.fetchFactions(); e.hasMoreElements(); ) { String FID = (String) e.nextElement(); Faction F = CMLib.factions().getFaction(FID); int value = M.fetchFaction(FID); if (F != null) str.append(F.name() + " (" + value + "), "); } break; } case 62: str.append(CMProps.getBoolVar(CMProps.SYSTEMB_ACCOUNTEXPIRATION) ? "true" : "false"); break; case 63: if (M.playerStats() != null) str.append(CMLib.time().date2String(M.playerStats().getAccountExpiration())); break; case 64: { for (int f = 0; f < M.numFollowers(); f++) str.append(M.fetchFollower(f).name()).append(", "); // Vector V=CMLib.database().DBScanFollowers(M); // for(int v=0;v<V.size();v++) // str.append(((MOB)V.elementAt(v)).name()).append(", "); break; } case 65: if ((M.playerStats() != null) && (M.playerStats().getAccount() != null)) str.append(M.playerStats().getAccount().accountName()); break; } return str.toString(); }