public final boolean mobKilled(final int id, final int skillID) { if (quest != null && quest.getSkillID() > 0) { if (quest.getSkillID() != skillID) { return false; } } final Integer mob = killedMobs.get(id); if (mob != null) { final int mo = maxMob(id); if (mob >= mo) { return false; // nothing happened } killedMobs.put(id, Math.min(mob + 1, mo)); return true; } for (Entry<Integer, Integer> mo : killedMobs.entrySet()) { if (questCount(mo.getKey(), id)) { final int mobb = maxMob(mo.getKey()); if (mo.getValue() >= mobb) { return false; // nothing } killedMobs.put(mo.getKey(), Math.min(mo.getValue() + 1, mobb)); return true; } } // i doubt this return false; }
@Override public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) { final MapleCharacter chr = c.getPlayer(); if ((slea.available() > 8L) && (chr != null)) { slea.skip(4); int numChanges = slea.readInt(); for (int i = 0; i < numChanges; i++) { int key = slea.readInt(); byte type = slea.readByte(); int action = slea.readInt(); if ((type == 1) && (action >= 1000)) { Skill skil = SkillFactory.getSkill(action); if ((skil != null) && (((!skil.isFourthJob()) && (!skil.isBeginnerSkill()) && (skil.isInvisible()) && (chr.getSkillLevel(skil) <= 0)) || (GameConstants.isLinkedAttackSkill(action)) || (action % 10000 < 1000))) { continue; } } chr.changeKeybinding(key, type, action); } } else if (chr != null) { int type = slea.readInt(); int data = slea.readInt(); switch (type) { case 1: if (data <= 0) { chr.getQuestRemove(MapleQuest.getInstance(GameConstants.HP_ITEM)); } else { chr.getQuestNAdd(MapleQuest.getInstance(GameConstants.HP_ITEM)) .setCustomData(String.valueOf(data)); } break; case 2: if (data <= 0) { chr.getQuestRemove(MapleQuest.getInstance(GameConstants.MP_ITEM)); } else { chr.getQuestNAdd(MapleQuest.getInstance(GameConstants.MP_ITEM)) .setCustomData(String.valueOf(data)); } break; } } }
public void end(MapleClient c, short questid, int npc) { MapleQuest quest = MapleQuest.getInstance(questid); if (!c.getPlayer().getQuest(quest).getStatus().equals(MapleQuestStatus.Status.STARTED) || !c.getPlayer().getMap().containsNPC(npc)) { dispose(c); return; } try { QuestActionManager qm = new QuestActionManager(c, questid, npc, false); if (qms.containsKey(c)) { return; } if (c.canClickNPC()) { qms.put(c, qm); Invocable iv = getInvocable("quest/" + questid + ".js", c); if (iv == null) { qm.dispose(); return; } engine.put("qm", qm); scripts.put(c, iv); c.setClickedNPC(); iv.invokeFunction("end", (byte) 1, (byte) 0, 0); } } catch (final UndeclaredThrowableException ute) { FilePrinter.printError(FilePrinter.QUEST + questid + ".txt", ute); dispose(c); } catch (final Throwable t) { FilePrinter.printError(FilePrinter.QUEST + getQM(c).getQuest() + ".txt", t); dispose(c); } }
private int maxMob(final int mobid) { for (final Map.Entry<Integer, Integer> qs : quest.getRelevantMobs().entrySet()) { if (qs.getKey() == mobid) { return qs.getValue(); } } return 0; }
public MapleQuestStatus(MapleQuest quest, Status status, int npc) { this.questID = quest.getId(); this.setStatus(status); this.setNpc(npc); this.completionTime = System.currentTimeMillis(); if (status == Status.STARTED) { registerMobs(); } }
/** * Creates a new instance of MapleQuestStatus * * @param quest * @param status */ public MapleQuestStatus(final MapleQuest quest, final int status) { this.quest = quest; this.setStatus((byte) status); this.completionTime = System.currentTimeMillis(); if (status == 1) { // Started if (!quest.getRelevantMobs().isEmpty()) { registerMobs(); } } }
public static void loadData(boolean reload) { System.out.println("载入数据(因为数据量大可能比较久而且内存消耗会飙升)"); System.out.println("加载等级经验数据"); GameConstants.LoadEXP(); System.out.println("加载排名信息数据"); MapleGuildRanking.getInstance().load(reload); // System.out.println("加载公会数据并清理不存在公会"); // MapleGuild.loadAll(); System.out.println("加载任务数据"); // 加载任务信息 MapleLifeFactory.loadQuestCounts(reload); // 加载转存到数据库的任务信息 MapleQuest.initQuests(reload); System.out.println("加载爆物数据"); // 加载爆物数据 MapleMonsterInformationProvider.getInstance().addExtra(); // 加载全域爆物数据 MapleMonsterInformationProvider.getInstance().load(); System.out.println("加载道具数据"); // 加载道具信息(从WZ) MapleItemInformationProvider.getInstance().runEtc(reload); // 加载道具信息(从SQL) MapleItemInformationProvider.getInstance().runItems(reload); // 加载发型脸型 MapleItemInformationProvider.getInstance().loadHairFace(reload); System.out.println("加载技能数据"); // 加载技能 SkillFactory.loadAllSkills(reload); MobSkillFactory.getInstance(); // 载入怪物技能 System.out.println("loadSpeedRuns"); // ? SpeedRunner.loadSpeedRuns(reload); System.out.println("加载商城道具数据"); // 加载商城道具信息 CashItemFactory.getInstance().initialize(reload); System.out.println("数据载入完成!\r\n"); }
public MapleQuest getQuest() { return MapleQuest.getInstance(questID); }
private void registerMobs() { for (int i : MapleQuest.getInstance(questID).getRelevantMobs()) { progress.put(i, "000"); } }
public static final void CreateUltimate(final LittleEndianAccessor slea, final MapleClient c) { if (!c.isLoggedIn() || c.getPlayer() == null || c.getPlayer().getLevel() < 120 || c.getPlayer().getMapId() != 130000000 || c.getPlayer().getQuestStatus(20734) != 0 || c.getPlayer().getQuestStatus(20616) != 2 || !GameConstants.isKOC(c.getPlayer().getJob()) || !c.canMakeCharacter(c.getPlayer().getWorld())) { c.getPlayer().dropMessage(1, "You have no character slots."); c.getSession().write(CField.createUltimate(0)); return; } System.out.println(slea.toString()); final String name = slea.readMapleAsciiString(); final int job = slea.readInt(); // job ID final int face = slea.readInt(); final int hair = slea.readInt(); final int hat = slea.readInt(); final int top = slea.readInt(); final int glove = slea.readInt(); final int shoes = slea.readInt(); final int weapon = slea.readInt(); final byte gender = c.getPlayer().getGender(); JobType jobType = JobType.Adventurer; // if (!LoginInformationProvider.getInstance().isEligibleItem(gender, 0, jobType.type, face) || // !LoginInformationProvider.getInstance().isEligibleItem(gender, 1, jobType.type, hair)) { // c.getPlayer().dropMessage(1, "An error occurred."); // c.getSession().write(CField.createUltimate(0)); // return; // } jobType = JobType.UltimateAdventurer; MapleCharacter newchar = MapleCharacter.getDefault(c, jobType); newchar.setJob(job); newchar.setWorld((byte) c.getPlayer().getWorld()); newchar.setFace(face); newchar.setHair(hair); newchar.setGender(gender); newchar.setName(name); newchar.setSkinColor((byte) 3); // troll newchar.setLevel((short) 50); newchar.getStat().str = (short) 4; newchar.getStat().dex = (short) 4; newchar.getStat().int_ = (short) 4; newchar.getStat().luk = (short) 4; newchar.setRemainingAp((short) 254); // 49*5 + 25 - 16 newchar.setRemainingSp( job / 100 == 2 ? 128 : 122); // 2 from job advancements. 120 from leveling. (mages get +6) newchar.getStat().maxhp += 150; // Beginner 10 levels newchar.getStat().maxmp += 125; newchar.getStat().hp += 150; // Beginner 10 levels newchar.getStat().mp += 125; switch (job) { case 110: case 120: case 130: newchar.getStat().maxhp += 600; // Job Advancement newchar.getStat().maxhp += 2000; // Levelup 40 times newchar.getStat().maxmp += 200; newchar.getStat().hp += 600; // Job Advancement newchar.getStat().hp += 2000; // Levelup 40 times newchar.getStat().mp += 200; break; case 210: case 220: case 230: newchar.getStat().maxmp += 600; newchar.getStat().maxhp += 500; // Levelup 40 times newchar.getStat().maxmp += 2000; newchar.getStat().mp += 600; newchar.getStat().hp += 500; // Levelup 40 times newchar.getStat().mp += 2000; break; case 310: case 320: case 410: case 420: case 520: newchar.getStat().maxhp += 500; newchar.getStat().maxmp += 250; newchar.getStat().maxhp += 900; // Levelup 40 times newchar.getStat().maxmp += 600; newchar.getStat().maxhp += 500; newchar.getStat().mp += 250; newchar.getStat().hp += 900; // Levelup 40 times newchar.getStat().mp += 600; break; case 510: newchar.getStat().maxhp += 500; newchar.getStat().maxmp += 250; newchar.getStat().maxhp += 450; // Levelup 20 times newchar.getStat().maxmp += 300; newchar.getStat().maxhp += 800; // Levelup 20 times newchar.getStat().maxmp += 400; newchar.getStat().hp += 500; newchar.getStat().mp += 250; newchar.getStat().hp += 450; // Levelup 20 times newchar.getStat().mp += 300; newchar.getStat().hp += 800; // Levelup 20 times newchar.getStat().mp += 400; break; default: return; } for (int i = 2490; i < 2507; i++) { newchar.setQuestAdd(MapleQuest.getInstance(i), (byte) 2, null); } newchar.setQuestAdd(MapleQuest.getInstance(29947), (byte) 2, null); newchar.setQuestAdd( MapleQuest.getInstance(GameConstants.ULT_EXPLORER), (byte) 0, c.getPlayer().getName()); final Map<Skill, SkillEntry> ss = new HashMap<>(); ss.put(SkillFactory.getSkill(1074 + (job / 100)), new SkillEntry((byte) 5, (byte) 5, -1)); ss.put(SkillFactory.getSkill(1195 + (job / 100)), new SkillEntry((byte) 5, (byte) 5, -1)); ss.put(SkillFactory.getSkill(80), new SkillEntry((byte) 1, (byte) 1, -1)); newchar.changeSkillLevel_Skip(ss, false); final MapleItemInformationProvider li = MapleItemInformationProvider.getInstance(); int[] items = new int[] { 1142257, hat, top, shoes, glove, weapon, hat + 1, top + 1, shoes + 1, glove + 1, weapon + 1 }; // brilliant = fine+1 for (byte i = 0; i < items.length; i++) { Item item = li.getEquipById(items[i]); item.setPosition((byte) (i + 1)); newchar.getInventory(MapleInventoryType.EQUIP).addFromDB(item); } newchar .getInventory(MapleInventoryType.USE) .addItem(new Item(2000004, (byte) 0, (short) 100, (byte) 0)); newchar .getInventory(MapleInventoryType.USE) .addItem(new Item(2000004, (byte) 0, (short) 100, (byte) 0)); c.getPlayer().fakeRelog(); if (MapleCharacterUtil.canCreateChar(name, c.isGm()) && (!LoginInformationProvider.getInstance().isForbiddenName(name) || c.isGm())) { MapleCharacter.saveNewCharToDB(newchar, jobType, (short) 0); MapleQuest.getInstance(20734).forceComplete(c.getPlayer(), 1101000); c.getSession().write(CField.createUltimate(1)); } else { c.getSession().write(CField.createUltimate(0)); } }
public static void CreateChar(final LittleEndianAccessor slea, final MapleClient c) { if (!c.isLoggedIn()) { c.getSession().close(); return; } final String name = slea.readMapleAsciiString(); final JobType jobType = JobType.getByType( slea.readInt()); // BIGBANG: 0 = Resistance, 1 = Adventurer, 2 = Cygnus, 3 = Aran, 4 = // Evan, 5 = mercedes final short db = slea.readShort(); // whether dual blade = 1 or adventurer = 0 final byte gender = slea.readByte(); // ??idk corresponds with the thing in addCharStats byte skinColor = slea.readByte(); // 01 int hairColor = 0; final byte unk2 = slea.readByte(); // 08 final boolean mercedes = (jobType == JobType.Mercedes); final boolean demon = (jobType == JobType.Demon); final boolean mihile = (jobType == JobType.Mihile); boolean jettPhantom = (jobType == LoginInformationProvider.JobType.Jett) || (jobType == LoginInformationProvider.JobType.Phantom) || (jobType == LoginInformationProvider.JobType.DualBlade); final int face = slea.readInt(); final int hair = slea.readInt(); if (!mercedes && !mihile && !demon && !jettPhantom) { // mercedes/demon dont need hair color since its already in the hair hairColor = slea.readInt(); skinColor = (byte) slea.readInt(); } final int demonMark = demon ? slea.readInt() : 0; final int top = (mihile) ? 0 : slea.readInt(); final int bottom = (mihile) ? 0 : slea.readInt(); final int shoes = (mihile) ? 0 : slea.readInt(); final int weapon = jobType == LoginInformationProvider.JobType.Phantom ? 1362046 : mercedes ? 1522038 : (mihile || demon) ? 0 : slea.readInt(); int shield = jobType == LoginInformationProvider.JobType.Phantom ? 1352100 : jobType == LoginInformationProvider.JobType.Mihile ? 1098000 : mercedes ? 1352000 : demon ? slea.readInt() : 0; MapleCharacter newchar = MapleCharacter.getDefault(c, jobType); newchar.setWorld((byte) c.getWorld()); newchar.setFace(face); newchar.setHair(hair + hairColor); newchar.setGender(gender); newchar.setName(name); newchar.setSkinColor(skinColor); newchar.setDemonMarking(demonMark); final MapleItemInformationProvider li = MapleItemInformationProvider.getInstance(); final MapleInventory equip = newchar.getInventory(MapleInventoryType.EQUIPPED); Item item = li.getEquipById(top); item.setPosition((byte) -5); equip.addFromDB(item); if (bottom > 0) { // resistance have overall item = li.getEquipById(bottom); item.setPosition((short) (byte) (jettPhantom ? -9 : -6)); equip.addFromDB(item); } item = li.getEquipById(shoes); item.setPosition((byte) -7); equip.addFromDB(item); item = li.getEquipById(weapon); item.setPosition((byte) -11); equip.addFromDB(item); if (shield > 0) { item = li.getEquipById(shield); item.setPosition((byte) -10); equip.addFromDB(item); } newchar .getInventory(MapleInventoryType.USE) .addItem(new Item(2000013, (byte) 0, (short) 100, (byte) 0)); newchar .getInventory(MapleInventoryType.USE) .addItem(new Item(2000014, (byte) 0, (short) 100, (byte) 0)); // blue/red pots switch (jobType) { case Resistance: // Resistance newchar .getInventory(MapleInventoryType.ETC) .addItem(new Item(4161001, (byte) 0, (short) 1, (byte) 0)); final Map<Skill, SkillEntry> ss = new HashMap<>(); ss.put(SkillFactory.getSkill(80001152), new SkillEntry((byte) 1, (byte) 1, -1)); newchar.changeSkillLevel_Skip(ss, false); break; case Adventurer: // Adventurer newchar .getInventory(MapleInventoryType.ETC) .addItem(new Item(4161001, (byte) 0, (short) 1, (byte) 0)); final Map<Skill, SkillEntry> ss1 = new HashMap<>(); ss1.put(SkillFactory.getSkill(80001152), new SkillEntry((byte) 1, (byte) 1, -1)); newchar.changeSkillLevel_Skip(ss1, false); break; case Cygnus: // Cygnus newchar .getInventory(MapleInventoryType.ETC) .addItem(new Item(4161047, (byte) 0, (short) 1, (byte) 0)); newchar.setQuestAdd(MapleQuest.getInstance(20022), (byte) 1, "1"); newchar.setQuestAdd(MapleQuest.getInstance(20010), (byte) 1, null); // >_>_>_> ugh final Map<Skill, SkillEntry> ss2 = new HashMap<>(); ss2.put(SkillFactory.getSkill(80001152), new SkillEntry((byte) 1, (byte) 1, -1)); newchar.changeSkillLevel_Skip(ss2, false); break; case Aran: // Aran newchar .getInventory(MapleInventoryType.ETC) .addItem(new Item(4161048, (byte) 0, (short) 1, (byte) 0)); final Map<Skill, SkillEntry> ss3 = new HashMap<>(); ss3.put(SkillFactory.getSkill(80001152), new SkillEntry((byte) 1, (byte) 1, -1)); newchar.changeSkillLevel_Skip(ss3, false); break; case Evan: // Evan newchar .getInventory(MapleInventoryType.ETC) .addItem(new Item(4161052, (byte) 0, (short) 1, (byte) 0)); final Map<Skill, SkillEntry> ss4 = new HashMap<>(); ss4.put(SkillFactory.getSkill(80001152), new SkillEntry((byte) 1, (byte) 1, -1)); newchar.changeSkillLevel_Skip(ss4, false); break; case Mercedes: // Mercedes newchar .getInventory(MapleInventoryType.ETC) .addItem(new Item(4161079, (byte) 0, (short) 1, (byte) 0)); final Map<Skill, SkillEntry> ss5 = new HashMap<>(); ss5.put(SkillFactory.getSkill(20021000), new SkillEntry((byte) 0, (byte) 0, -1)); ss5.put(SkillFactory.getSkill(20021001), new SkillEntry((byte) 0, (byte) 0, -1)); ss5.put(SkillFactory.getSkill(20020002), new SkillEntry((byte) 0, (byte) 0, -1)); ss5.put(SkillFactory.getSkill(20020022), new SkillEntry((byte) 1, (byte) 1, -1)); ss5.put(SkillFactory.getSkill(20020109), new SkillEntry((byte) 1, (byte) 1, -1)); ss5.put(SkillFactory.getSkill(20021110), new SkillEntry((byte) 1, (byte) 1, -1)); ss5.put(SkillFactory.getSkill(20020111), new SkillEntry((byte) 1, (byte) 1, -1)); ss5.put(SkillFactory.getSkill(20020112), new SkillEntry((byte) 1, (byte) 1, -1)); ss5.put(SkillFactory.getSkill(20021181), new SkillEntry((byte) -1, (byte) 0, -1)); ss5.put(SkillFactory.getSkill(20021166), new SkillEntry((byte) -1, (byte) 0, -1)); ss5.put(SkillFactory.getSkill(80001152), new SkillEntry((byte) 1, (byte) 1, -1)); newchar.changeSkillLevel_Skip(ss5, false); break; case Demon: // Demon newchar .getInventory(MapleInventoryType.ETC) .addItem(new Item(4161054, (byte) 0, (short) 1, (byte) 0)); final Map<Skill, SkillEntry> ss6 = new HashMap<>(); ss6.put(SkillFactory.getSkill(30011000), new SkillEntry((byte) 0, (byte) 0, -1)); ss6.put(SkillFactory.getSkill(30011001), new SkillEntry((byte) 0, (byte) 0, -1)); ss6.put(SkillFactory.getSkill(30010002), new SkillEntry((byte) 0, (byte) 0, -1)); ss6.put(SkillFactory.getSkill(30010185), new SkillEntry((byte) 1, (byte) 1, -1)); ss6.put(SkillFactory.getSkill(30010112), new SkillEntry((byte) 1, (byte) 1, -1)); ss6.put(SkillFactory.getSkill(30010111), new SkillEntry((byte) 1, (byte) 1, -1)); ss6.put(SkillFactory.getSkill(30010110), new SkillEntry((byte) 1, (byte) 1, -1)); ss6.put(SkillFactory.getSkill(30010022), new SkillEntry((byte) 1, (byte) 1, -1)); ss6.put(SkillFactory.getSkill(30011109), new SkillEntry((byte) 1, (byte) 1, -1)); ss6.put(SkillFactory.getSkill(30011170), new SkillEntry((byte) 1, (byte) 1, -1)); ss6.put(SkillFactory.getSkill(30011169), new SkillEntry((byte) 1, (byte) 1, -1)); ss6.put(SkillFactory.getSkill(30011168), new SkillEntry((byte) 1, (byte) 1, -1)); ss6.put(SkillFactory.getSkill(30011167), new SkillEntry((byte) 1, (byte) 1, -1)); ss6.put(SkillFactory.getSkill(30010166), new SkillEntry((byte) 1, (byte) 1, -1)); ss6.put(SkillFactory.getSkill(80001152), new SkillEntry((byte) 1, (byte) 1, -1)); newchar.changeSkillLevel_Skip(ss6, false); break; case Phantom: newchar.setLevel((short) 10); newchar.setJob(2400); newchar.getStat().maxhp += 294; // Beginner 10 levels newchar.getStat().maxmp += 113; newchar.getStat().hp += 294; // Beginner 10 levels newchar.getStat().mp += 113; newchar.getStat().str -= 8; newchar.getStat().dex -= 1; newchar.getStat().luk += 31; newchar.setRemainingAp((short) 23); newchar.setRemainingSp(5); final Map<Skill, SkillEntry> ss7 = new HashMap<>(); ss7.put(SkillFactory.getSkill(20031203), new SkillEntry((byte) 1, (byte) 1, -1)); ss7.put(SkillFactory.getSkill(20030204), new SkillEntry((byte) 1, (byte) 1, -1)); ss7.put(SkillFactory.getSkill(20031205), new SkillEntry((byte) 1, (byte) 1, -1)); ss7.put(SkillFactory.getSkill(20030206), new SkillEntry((byte) 1, (byte) 1, -1)); ss7.put(SkillFactory.getSkill(20031207), new SkillEntry((byte) 1, (byte) 1, -1)); ss7.put(SkillFactory.getSkill(20031208), new SkillEntry((byte) 1, (byte) 1, -1)); ss7.put(SkillFactory.getSkill(20031209), new SkillEntry((byte) 1, (byte) 1, -1)); ss7.put(SkillFactory.getSkill(20031210), new SkillEntry((byte) 1, (byte) 1, -1)); ss7.put(SkillFactory.getSkill(80001152), new SkillEntry((byte) 1, (byte) 1, -1)); newchar.changeSkillLevel_Skip(ss7, false); break; case Jett: newchar.setLevel((short) 10); newchar.setJob(508); newchar.getStat().maxhp += 294; // Beginner 10 newchar.getStat().maxmp += 113; newchar.getStat().hp += 294; // Beginner 10 newchar.getStat().mp += 113; newchar.getStat().str -= 8; newchar.getStat().dex += 15; newchar.setRemainingAp((short) 38); newchar.setRemainingSp(1); final Map<Skill, SkillEntry> ss8 = new HashMap<>(); ss8.put(SkillFactory.getSkill(228), new SkillEntry((byte) 1, (byte) 1, -1)); ss8.put(SkillFactory.getSkill(80001152), new SkillEntry((byte) 1, (byte) 1, -1)); // ss8.put(SkillFactory.getSkill(80001151), new SkillEntry((byte) 1, (byte) 1, -1)); newchar.changeSkillLevel_Skip(ss8, false); break; case Mihile: final Map<Skill, SkillEntry> ss9 = new HashMap<>(); ss9.put(SkillFactory.getSkill(80001152), new SkillEntry((byte) 1, (byte) 1, -1)); newchar.changeSkillLevel_Skip(ss9, false); break; } if (MapleCharacterUtil.canCreateChar(name, c.isGm()) && (!LoginInformationProvider.getInstance().isForbiddenName(name) || c.isGm()) && (c.isGm() || c.canMakeCharacter(c.getWorld()))) { MapleCharacter.saveNewCharToDB(newchar, jobType, db); c.getSession().write(LoginPacket.addNewCharEntry(newchar, true)); c.createdChar(newchar.getId()); } else { c.getSession().write(LoginPacket.addNewCharEntry(newchar, false)); } }
private void registerMobs() { killedMobs = new LinkedHashMap<>(); for (final int i : quest.getRelevantMobs().keySet()) { killedMobs.put(i, 0); } }
public boolean isCustom() { return GameConstants.isCustomQuest(quest.getId()); }
public final void setQuest(int qid) { this.quest = MapleQuest.getInstance(qid); }