@Override public boolean check(MapleCharacter chr, Integer npcid) { int curCloseness = 0; for (MaplePet pet : chr.getPets()) { if (pet.getCloseness() > curCloseness) curCloseness = pet.getCloseness(); } return curCloseness >= minTameness; }
public Item toItem(CashItem cItem, int uniqueid, String gift) { if (uniqueid <= 0) { uniqueid = MapleInventoryIdentifier.getInstance(); } long period = cItem.getExpire(); if ((period <= 0 && GameConstants.getInventoryType(cItem.getItemId()) != MapleInventoryType.EQUIP) || GameConstants.isPet(cItem.getItemId())) { period = GameConstants.GMS ? 90 : 45; } if (cItem.getItemId() >= 5000100 && cItem.getItemId() < 5000200) { // permanent pet period = 20000; // permanent time millis } Item ret; if (GameConstants.getInventoryType(cItem.getItemId()) == MapleInventoryType.EQUIP) { Equip eq = (Equip) MapleItemInformationProvider.getInstance().getEquipById(cItem.getItemId(), uniqueid); if (period > 0) { eq.setExpiration( (long) (System.currentTimeMillis() + (long) (period * 24 * 60 * 60 * 1000))); } eq.setGMLog("Cash Shop: " + cItem.getSN() + " on " + FileoutputUtil.CurrentReadable_Date()); eq.setGiftFrom(gift); if (GameConstants.isEffectRing(cItem.getItemId()) && uniqueid > 0) { MapleRing ring = MapleRing.loadFromDb(uniqueid); if (ring != null) { eq.setRing(ring); } } ret = eq.copy(); } else { Item item = new Item(cItem.getItemId(), (byte) 0, (short) cItem.getQuantity(), (byte) 0, uniqueid); if (period > 0) { item.setExpiration( (long) (System.currentTimeMillis() + (long) (period * 24 * 60 * 60 * 1000))); } item.setGMLog("Cash Shop: " + cItem.getSN() + " on " + FileoutputUtil.CurrentReadable_Date()); item.setGiftFrom(gift); if (GameConstants.isPet(cItem.getItemId())) { final MaplePet pet = MaplePet.createPet(cItem.getItemId(), uniqueid); if (pet != null) { item.setPet(pet); } } ret = item.copy(); } return ret; }
/** * 角色快照数据 * * @param chr */ public CharacterTransfer(MapleCharacter chr) { this.characterid = chr.getId(); this.accountid = chr.getAccountID(); this.accountname = chr.getClient().getAccountName(); this.channel = (byte) chr.getClient().getChannel(); this.ACash = chr.getCSPoints(1); this.MaplePoints = chr.getCSPoints(2); this.vpoints = chr.getVPoints(); this.name = chr.getName(); this.fame = chr.getFame(); this.love = chr.getLove(); this.gender = chr.getClient().getGender(); this.level = chr.getLevel(); this.str = chr.getStat().getStr(); this.dex = chr.getStat().getDex(); this.int_ = chr.getStat().getInt(); this.luk = chr.getStat().getLuk(); this.hp = chr.getStat().getHp(); this.mp = chr.getStat().getMp(); this.maxhp = chr.getStat().getMaxHp(); this.maxmp = chr.getStat().getMaxMp(); this.exp = chr.getExp(); this.hpApUsed = chr.getHpApUsed(); this.remainingAp = chr.getRemainingAp(); this.remainingSp = chr.getRemainingSp(); this.meso = chr.getMeso(); this.pvpExp = chr.getTotalBattleExp(); this.pvpPoints = chr.getBattlePoints(); this.skinColor = chr.getSkinColor(); this.job = chr.getJob(); this.hair = chr.getHair(); this.face = chr.getFace(); this.mapid = chr.getMapId(); this.initialSpawnPoint = chr.getInitialSpawnpoint(); this.marriageId = chr.getMarriageId(); this.world = chr.getWorld(); this.guildid = chr.getGuildId(); this.guildrank = chr.getGuildRank(); this.guildContribution = chr.getGuildContribution(); this.alliancerank = chr.getAllianceRank(); this.gmLevel = (byte) chr.getGMLevel(); this.points = chr.getPoints(); this.fairyExp = chr.getFairyExp(); this.petStore = chr.getPetStores(); this.subcategory = chr.getSubcategory(); this.imps = chr.getImps(); this.fatigue = chr.getFatigue(); this.currentrep = chr.getCurrentRep(); this.totalrep = chr.getTotalRep(); this.totalWins = chr.getTotalWins(); this.totalLosses = chr.getTotalLosses(); this.gachexp = chr.getGachExp(); this.boxed = chr.getBoxed(); this.familiars = chr.getFamiliars(); this.tempIP = chr.getClient().getTempIP(); this.decorate = chr.getDecorate(); this.dollars = chr.getDollars(); this.shareLots = chr.getShareLots(); this.apstorage = chr.getAPS(); this.cardStack = chr.getCardStack(); this.morphCount = chr.getMorphCount(); this.powerCount = chr.getPowerCount(); this.playerPoints = chr.getPlayerPoints(); this.playerEnergy = chr.getPlayerEnergy(); this.runningDark = chr.getDarkType(); this.runningDarkSlot = chr.getDarkTotal(); this.runningLight = chr.getLightType(); this.runningLightSlot = chr.getLightTotal(); boolean uneq = false; MaplePet pet = chr.getSpawnPet(); if (this.petStore == 0) { this.petStore = -1; } if (pet != null) { uneq = true; this.petStore = (byte) Math.max(this.petStore, pet.getInventoryPosition()); } if (uneq) { chr.unequipAllSpawnPets(); } if (chr.getSidekick() != null) { this.sidekick = chr.getSidekick().getId(); } else { this.sidekick = 0; } for (BuddylistEntry qs : chr.getBuddylist().getBuddies()) { this.buddies.put( new CharacterNameAndId(qs.getCharacterId(), qs.getName(), qs.getGroup()), qs.isVisible()); } this.buddysize = chr.getBuddyCapacity(); this.partyid = (chr.getParty() == null ? -1 : chr.getParty().getId()); if (chr.getMessenger() != null) { this.messengerid = chr.getMessenger().getId(); } else { this.messengerid = 0; } this.finishedAchievements = chr.getFinishedAchievements(); this.KeyValue = chr.getKeyValue_Map(); this.InfoQuest = chr.getInfoQuest_Map(); for (Map.Entry qs : chr.getQuest_Map().entrySet()) { this.Quest.put(((MapleQuest) qs.getKey()).getId(), qs.getValue()); } this.inventorys = chr.getInventorys(); for (Entry<Skill, SkillEntry> qs : chr.getSkills().entrySet()) { this.Skills.put(((Skill) qs.getKey()).getId(), qs.getValue()); } this.BlessOfFairy = chr.getBlessOfFairyOrigin(); this.BlessOfEmpress = chr.getBlessOfEmpressOrigin(); this.chalkboard = chr.getChalkboard(); this.keymap = chr.getKeyLayout().Layout(); this.quickslot = chr.getQuickSlot().Layout(); this.savedlocation = chr.getSavedLocations(); this.wishlist = chr.getWishlist(); this.regrocks = chr.getRegRocks(); this.famedcharacters = chr.getFamedCharacters(); this.lastfametime = chr.getLastFameTime(); this.storage = chr.getStorage(); this.cs = chr.getCashInventory(); MapleMount mount = chr.getMount(); this.mount_itemid = mount.getItemId(); this.mount_Fatigue = mount.getFatigue(); this.mount_level = mount.getLevel(); this.mount_exp = mount.getExp(); this.battlers = chr.getBattlers(); this.lastLoveTime = chr.getLastLoveTime(); this.loveCharacters = chr.getLoveCharacters(); this.TranferTime = System.currentTimeMillis(); }
/** * 可以创建定时技能 * * @param chr * @param numTimes * @param hurt * @param now */ public static void handleCooldowns(MapleCharacter chr, int numTimes, boolean hurt, long now) { if (chr == null) { return; } if (chr.getCooldownSize() > 0) { for (MapleCoolDownValueHolder m : chr.getCooldowns()) { if (m.startTime + m.length < now) { int skillId = m.skillId; chr.removeCooldown(skillId); chr.getClient().getSession().write(MaplePacketCreator.skillCooldown(skillId, 0)); } } } if (chr.isAlive()) { if (((chr.getJob() == 131) || (chr.getJob() == 132)) && (chr.canBlood(now))) { chr.doDragonBlood(); } if (chr.canRecover(now)) { chr.doRecovery(); } if (chr.canHPRecover(now)) { chr.addHP((int) chr.getStat().getHealHP()); } if (chr.canMPRecover(now)) { chr.addMP((int) chr.getStat().getHealMP()); if ((chr.getJob() == 3111) || (chr.getJob() == 3112)) { chr.addDemonMp((int) chr.getStat().getHealMP()); } } if (chr.canFairy(now)) { chr.doFairy(); } if (chr.canFish(now)) { chr.doFish(now); } if (chr.canDOT(now)) { chr.doDOT(); } if (chr.canExpiration(now)) { chr.expirationTask(); } } if (chr.getDiseaseSize() > 0) { for (MapleDiseaseValueHolder m : chr.getAllDiseases()) { if ((m != null) && (m.startTime + m.length < now)) { chr.dispelDebuff(m.disease); } } } if ((numTimes % 7 == 0) && (chr.getMount() != null) && (chr.getMount().canTire(now))) { chr.getMount().increaseFatigue(); } if (numTimes % 13 == 0) { chr.doFamiliarSchedule(now); for (MaplePet pet : chr.getSummonedPets()) { if ((pet.getPetItemId() == 5000054) && (pet.getSecondsLeft() > 0)) { pet.setSecondsLeft(pet.getSecondsLeft() - 1); if (pet.getSecondsLeft() <= 0) { chr.unequipSpawnPet(pet, true, true); return; } } int newFullness = pet.getFullness() - PetDataFactory.getHunger(pet.getPetItemId()); if (newFullness <= 5) { pet.setFullness(15); chr.unequipSpawnPet(pet, true, true); } else { pet.setFullness(newFullness); chr.getClient() .getSession() .write( PetPacket.updatePet( pet, chr.getInventory(MapleInventoryType.CASH).getItem(pet.getInventoryPosition()), false)); } } } if ((hurt) && (chr.isAlive())) { if (chr.getInventory(MapleInventoryType.EQUIPPED).findById(chr.getMap().getHPDecProtect()) == null) { if ((chr.getMapId() == 749040100) && (chr.getInventory(MapleInventoryType.CASH).findById(5451000) == null)) { chr.addHP(-chr.getMap().getHPDec()); } else if (chr.getMapId() != 749040100) { chr.addHP(-(chr.getMap().getHPDec())); } } } }