Search in sources :

Example 76 with MapleData

use of provider.MapleData in project HeavenMS by ronancpl.

the class MapleItemInformationProvider method getItemData.

private MapleData getItemData(int itemId) {
    MapleData ret = null;
    String idStr = "0" + String.valueOf(itemId);
    MapleDataDirectoryEntry root = itemData.getRoot();
    for (MapleDataDirectoryEntry topDir : root.getSubdirectories()) {
        for (MapleDataFileEntry iFile : topDir.getFiles()) {
            if (iFile.getName().equals(idStr.substring(0, 4) + ".img")) {
                ret = itemData.getData(topDir.getName() + "/" + iFile.getName());
                if (ret == null) {
                    return null;
                }
                ret = ret.getChildByPath(idStr);
                return ret;
            } else if (iFile.getName().equals(idStr.substring(1) + ".img")) {
                return itemData.getData(topDir.getName() + "/" + iFile.getName());
            }
        }
    }
    root = equipData.getRoot();
    for (MapleDataDirectoryEntry topDir : root.getSubdirectories()) {
        for (MapleDataFileEntry iFile : topDir.getFiles()) {
            if (iFile.getName().equals(idStr + ".img")) {
                return equipData.getData(topDir.getName() + "/" + iFile.getName());
            }
        }
    }
    return ret;
}
Also used : MapleData(provider.MapleData) MapleDataDirectoryEntry(provider.MapleDataDirectoryEntry) MapleDataFileEntry(provider.MapleDataFileEntry)

Example 77 with MapleData

use of provider.MapleData in project HeavenMS by ronancpl.

the class MapleLifeFactory method getAllMonsterStats.

public static Map<Integer, MapleMonsterStats> getAllMonsterStats() {
    MapleDataDirectoryEntry root = data.getRoot();
    System.out.print("Parsing mob stats... ");
    for (MapleDataFileEntry mFile : root.getFiles()) {
        try {
            String fileName = mFile.getName();
            // System.out.println("Parsing '" + fileName + "'");
            MapleData monsterData = data.getData(fileName);
            if (monsterData == null) {
                continue;
            }
            Integer mid = getMonsterId(fileName);
            MapleData monsterInfoData = monsterData.getChildByPath("info");
            MapleMonsterStats stats = new MapleMonsterStats();
            stats.setHp(MapleDataTool.getIntConvert("maxHP", monsterInfoData));
            stats.setFriendly(MapleDataTool.getIntConvert("damagedByMob", monsterInfoData, 0) == 1);
            stats.setPADamage(MapleDataTool.getIntConvert("PADamage", monsterInfoData));
            stats.setPDDamage(MapleDataTool.getIntConvert("PDDamage", monsterInfoData));
            stats.setMADamage(MapleDataTool.getIntConvert("MADamage", monsterInfoData));
            stats.setMDDamage(MapleDataTool.getIntConvert("MDDamage", monsterInfoData));
            stats.setMp(MapleDataTool.getIntConvert("maxMP", monsterInfoData, 0));
            stats.setExp(MapleDataTool.getIntConvert("exp", monsterInfoData, 0));
            stats.setLevel(MapleDataTool.getIntConvert("level", monsterInfoData));
            stats.setRemoveAfter(MapleDataTool.getIntConvert("removeAfter", monsterInfoData, 0));
            stats.setBoss(MapleDataTool.getIntConvert("boss", monsterInfoData, 0) > 0);
            stats.setExplosiveReward(MapleDataTool.getIntConvert("explosiveReward", monsterInfoData, 0) > 0);
            stats.setFfaLoot(MapleDataTool.getIntConvert("publicReward", monsterInfoData, 0) > 0);
            stats.setUndead(MapleDataTool.getIntConvert("undead", monsterInfoData, 0) > 0);
            stats.setName(MapleDataTool.getString(mid + "/name", mobStringData, "MISSINGNO"));
            stats.setBuffToGive(MapleDataTool.getIntConvert("buff", monsterInfoData, -1));
            stats.setCP(MapleDataTool.getIntConvert("getCP", monsterInfoData, 0));
            stats.setRemoveOnMiss(MapleDataTool.getIntConvert("removeOnMiss", monsterInfoData, 0) > 0);
            MapleData special = monsterInfoData.getChildByPath("coolDamage");
            if (special != null) {
                int coolDmg = MapleDataTool.getIntConvert("coolDamage", monsterInfoData);
                int coolProb = MapleDataTool.getIntConvert("coolDamageProb", monsterInfoData, 0);
                stats.setCool(new Pair<>(coolDmg, coolProb));
            }
            special = monsterInfoData.getChildByPath("loseItem");
            if (special != null) {
                for (MapleData liData : special.getChildren()) {
                    stats.addLoseItem(new loseItem(MapleDataTool.getInt(liData.getChildByPath("id")), (byte) MapleDataTool.getInt(liData.getChildByPath("prop")), (byte) MapleDataTool.getInt(liData.getChildByPath("x"))));
                }
            }
            special = monsterInfoData.getChildByPath("selfDestruction");
            if (special != null) {
                stats.setSelfDestruction(new selfDestruction((byte) MapleDataTool.getInt(special.getChildByPath("action")), MapleDataTool.getIntConvert("removeAfter", special, -1), MapleDataTool.getIntConvert("hp", special, -1)));
            }
            MapleData firstAttackData = monsterInfoData.getChildByPath("firstAttack");
            int firstAttack = 0;
            if (firstAttackData != null) {
                if (firstAttackData.getType() == MapleDataType.FLOAT) {
                    firstAttack = Math.round(MapleDataTool.getFloat(firstAttackData));
                } else {
                    firstAttack = MapleDataTool.getInt(firstAttackData);
                }
            }
            stats.setFirstAttack(firstAttack > 0);
            stats.setDropPeriod(MapleDataTool.getIntConvert("dropItemPeriod", monsterInfoData, 0) * 10000);
            stats.setTagColor(MapleDataTool.getIntConvert("hpTagColor", monsterInfoData, 0));
            stats.setTagBgColor(MapleDataTool.getIntConvert("hpTagBgcolor", monsterInfoData, 0));
            for (MapleData idata : monsterData) {
                if (!idata.getName().equals("info")) {
                    int delay = 0;
                    for (MapleData pic : idata.getChildren()) {
                        delay += MapleDataTool.getIntConvert("delay", pic, 0);
                    }
                    stats.setAnimationTime(idata.getName(), delay);
                }
            }
            MapleData reviveInfo = monsterInfoData.getChildByPath("revive");
            if (reviveInfo != null) {
                List<Integer> revives = new LinkedList<>();
                for (MapleData data_ : reviveInfo) {
                    revives.add(MapleDataTool.getInt(data_));
                }
                stats.setRevives(revives);
            }
            decodeElementalString(stats, MapleDataTool.getString("elemAttr", monsterInfoData, ""));
            MapleData monsterSkillData = monsterInfoData.getChildByPath("skill");
            if (monsterSkillData != null) {
                int i = 0;
                List<Pair<Integer, Integer>> skills = new ArrayList<>();
                while (monsterSkillData.getChildByPath(Integer.toString(i)) != null) {
                    skills.add(new Pair<>(Integer.valueOf(MapleDataTool.getInt(i + "/skill", monsterSkillData, 0)), Integer.valueOf(MapleDataTool.getInt(i + "/level", monsterSkillData, 0))));
                    i++;
                }
                stats.setSkills(skills);
            }
            MapleData banishData = monsterInfoData.getChildByPath("ban");
            if (banishData != null) {
                stats.setBanishInfo(new BanishInfo(MapleDataTool.getString("banMsg", banishData), MapleDataTool.getInt("banMap/0/field", banishData, -1), MapleDataTool.getString("banMap/0/portal", banishData, "sp")));
            }
            monsterStats.put(mid, stats);
        } catch (NullPointerException npe) {
        // System.out.println("[SEVERE] " + mFile.getName() + " failed to load. Issue: " + npe.getMessage() + "\n\n");
        }
    }
    System.out.println("done!");
    return monsterStats;
}
Also used : MapleData(provider.MapleData) MapleDataDirectoryEntry(provider.MapleDataDirectoryEntry) MapleDataFileEntry(provider.MapleDataFileEntry) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) Pair(tools.Pair)

Example 78 with MapleData

use of provider.MapleData in project HeavenMS by ronancpl.

the class MapleItemInformationProvider method isDropRestricted.

public boolean isDropRestricted(int itemId) {
    if (dropRestrictionCache.containsKey(itemId)) {
        return dropRestrictionCache.get(itemId);
    }
    MapleData data = getItemData(itemId);
    boolean bRestricted = MapleDataTool.getIntConvert("info/tradeBlock", data, 0) == 1;
    if (!bRestricted) {
        bRestricted = MapleDataTool.getIntConvert("info/accountSharable", data, 0) == 1;
    }
    if (!bRestricted) {
        bRestricted = MapleDataTool.getIntConvert("info/quest", data, 0) == 1;
    }
    dropRestrictionCache.put(itemId, bRestricted);
    return bRestricted;
}
Also used : MapleData(provider.MapleData)

Example 79 with MapleData

use of provider.MapleData in project HeavenMS by ronancpl.

the class MapleItemInformationProvider method petsCanConsume.

public List<Integer> petsCanConsume(int itemId) {
    List<Integer> ret = new ArrayList<>();
    MapleData data = getItemData(itemId);
    int curPetId;
    for (int i = 0; i < data.getChildren().size(); i++) {
        curPetId = MapleDataTool.getInt("spec/" + Integer.toString(i), data, 0);
        if (curPetId == 0) {
            break;
        }
        ret.add(Integer.valueOf(curPetId));
    }
    return ret;
}
Also used : MapleData(provider.MapleData) ArrayList(java.util.ArrayList)

Example 80 with MapleData

use of provider.MapleData in project HeavenMS by ronancpl.

the class MapleItemInformationProvider method isQuestItem.

public boolean isQuestItem(int itemId) {
    if (isQuestItemCache.containsKey(itemId)) {
        return isQuestItemCache.get(itemId);
    }
    MapleData data = getItemData(itemId);
    boolean questItem = MapleDataTool.getIntConvert("info/quest", data, 0) == 1;
    isQuestItemCache.put(itemId, questItem);
    return questItem;
}
Also used : MapleData(provider.MapleData)

Aggregations

MapleData (provider.MapleData)90 ArrayList (java.util.ArrayList)19 Pair (tools.Pair)11 File (java.io.File)8 Point (java.awt.Point)7 LinkedList (java.util.LinkedList)6 MapleDataDirectoryEntry (provider.MapleDataDirectoryEntry)6 MapleDataFileEntry (provider.MapleDataFileEntry)6 LinkedHashMap (java.util.LinkedHashMap)5 SQLException (java.sql.SQLException)4 MapleDataProvider (provider.MapleDataProvider)4 Skill (client.Skill)2 IOException (java.io.IOException)2 Node (org.w3c.dom.Node)2 NodeList (org.w3c.dom.NodeList)2 AbstractLoadedMapleLife (server.life.AbstractLoadedMapleLife)2 MapleCharacter (client.MapleCharacter)1 Item (client.inventory.Item)1 MonsterStatus (client.status.MonsterStatus)1 Rectangle (java.awt.Rectangle)1