Search in sources :

Example 6 with MapleData

use of provider.MapleData in project HeavenMS by ronancpl.

the class MapleMonsterInformationProvider method getMobsIDsFromName.

public static ArrayList<Pair<Integer, String>> getMobsIDsFromName(String search) {
    MapleDataProvider dataProvider = MapleDataProviderFactory.getDataProvider(new File("wz/String.wz"));
    ArrayList<Pair<Integer, String>> retMobs = new ArrayList<Pair<Integer, String>>();
    MapleData data = dataProvider.getData("Mob.img");
    List<Pair<Integer, String>> mobPairList = new LinkedList<Pair<Integer, String>>();
    for (MapleData mobIdData : data.getChildren()) {
        int mobIdFromData = Integer.parseInt(mobIdData.getName());
        String mobNameFromData = MapleDataTool.getString(mobIdData.getChildByPath("name"), "NO-NAME");
        mobPairList.add(new Pair<Integer, String>(mobIdFromData, mobNameFromData));
    }
    for (Pair<Integer, String> mobPair : mobPairList) {
        if (mobPair.getRight().toLowerCase().contains(search.toLowerCase())) {
            retMobs.add(mobPair);
        }
    }
    return retMobs;
}
Also used : MapleData(provider.MapleData) ArrayList(java.util.ArrayList) MapleDataProvider(provider.MapleDataProvider) File(java.io.File) LinkedList(java.util.LinkedList) Pair(tools.Pair)

Example 7 with MapleData

use of provider.MapleData in project HeavenMS by ronancpl.

the class MobAttackInfoFactory method getMobAttackInfo.

public static MobAttackInfo getMobAttackInfo(MapleMonster mob, int attack) {
    MobAttackInfo ret = mobAttacks.get(mob.getId() + "" + attack);
    if (ret != null) {
        return ret;
    }
    synchronized (mobAttacks) {
        ret = mobAttacks.get(mob.getId() + "" + attack);
        if (ret == null) {
            MapleData mobData = dataSource.getData(StringUtil.getLeftPaddedStr(Integer.toString(mob.getId()) + ".img", '0', 11));
            if (mobData != null) {
                // MapleData infoData = mobData.getChildByPath("info");
                String linkedmob = MapleDataTool.getString("link", mobData, "");
                if (!linkedmob.equals("")) {
                    mobData = dataSource.getData(StringUtil.getLeftPaddedStr(linkedmob + ".img", '0', 11));
                }
                MapleData attackData = mobData.getChildByPath("attack" + (attack + 1) + "/info");
                if (attackData == null) {
                    return null;
                }
                MapleData deadlyAttack = attackData.getChildByPath("deadlyAttack");
                int mpBurn = MapleDataTool.getInt("mpBurn", attackData, 0);
                int disease = MapleDataTool.getInt("disease", attackData, 0);
                int level = MapleDataTool.getInt("level", attackData, 0);
                int mpCon = MapleDataTool.getInt("conMP", attackData, 0);
                ret = new MobAttackInfo(mob.getId(), attack);
                ret.setDeadlyAttack(deadlyAttack != null);
                ret.setMpBurn(mpBurn);
                ret.setDiseaseSkill(disease);
                ret.setDiseaseLevel(level);
                ret.setMpCon(mpCon);
            }
            mobAttacks.put(mob.getId() + "" + attack, ret);
        }
        return ret;
    }
}
Also used : MapleData(provider.MapleData)

Example 8 with MapleData

use of provider.MapleData in project HeavenMS by ronancpl.

the class MobSkillFactory method getMobSkill.

public static MobSkill getMobSkill(final int skillId, final int level) {
    final String key = skillId + "" + level;
    rL.lock();
    try {
        MobSkill ret = mobSkills.get(key);
        if (ret != null) {
            return ret;
        }
    } finally {
        rL.unlock();
    }
    wL.lock();
    try {
        MobSkill ret;
        ret = mobSkills.get(key);
        if (ret == null) {
            MapleData skillData = skillRoot.getChildByPath(skillId + "/level/" + level);
            if (skillData != null) {
                int mpCon = MapleDataTool.getInt(skillData.getChildByPath("mpCon"), 0);
                List<Integer> toSummon = new ArrayList<Integer>();
                for (int i = 0; i > -1; i++) {
                    if (skillData.getChildByPath(String.valueOf(i)) == null) {
                        break;
                    }
                    toSummon.add(Integer.valueOf(MapleDataTool.getInt(skillData.getChildByPath(String.valueOf(i)), 0)));
                }
                int effect = MapleDataTool.getInt("summonEffect", skillData, 0);
                int hp = MapleDataTool.getInt("hp", skillData, 100);
                int x = MapleDataTool.getInt("x", skillData, 1);
                int y = MapleDataTool.getInt("y", skillData, 1);
                long duration = MapleDataTool.getInt("time", skillData, 0) * 1000;
                long cooltime = MapleDataTool.getInt("interval", skillData, 0) * 1000;
                int iprop = MapleDataTool.getInt("prop", skillData, 100);
                float prop = iprop / 100;
                int limit = MapleDataTool.getInt("limit", skillData, 0);
                MapleData ltd = skillData.getChildByPath("lt");
                Point lt = null;
                Point rb = null;
                if (ltd != null) {
                    lt = (Point) ltd.getData();
                    rb = (Point) skillData.getChildByPath("rb").getData();
                }
                ret = new MobSkill(skillId, level);
                ret.addSummons(toSummon);
                ret.setCoolTime(cooltime);
                ret.setDuration(duration);
                ret.setHp(hp);
                ret.setMpCon(mpCon);
                ret.setSpawnEffect(effect);
                ret.setX(x);
                ret.setY(y);
                ret.setProp(prop);
                ret.setLimit(limit);
                ret.setLtRb(lt, rb);
            }
            mobSkills.put(skillId + "" + level, ret);
        }
        return ret;
    } finally {
        wL.unlock();
    }
}
Also used : MapleData(provider.MapleData) ArrayList(java.util.ArrayList) Point(java.awt.Point) Point(java.awt.Point)

Example 9 with MapleData

use of provider.MapleData in project HeavenMS by ronancpl.

the class MapleLifeFactory method getMonster.

public static MapleMonster getMonster(int mid) {
    try {
        MapleMonsterStats stats = monsterStats.get(Integer.valueOf(mid));
        if (stats == null) {
            MapleData monsterData = data.getData(StringUtil.getLeftPaddedStr(Integer.toString(mid) + ".img", '0', 11));
            if (monsterData == null) {
                return null;
            }
            MapleData monsterInfoData = monsterData.getChildByPath("info");
            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(Integer.valueOf(mid), stats);
        }
        MapleMonster ret = new MapleMonster(mid, stats);
        return ret;
    } catch (NullPointerException npe) {
        System.out.println("[SEVERE] MOB " + mid + " failed to load. Issue: " + npe.getMessage() + "\n\n");
        npe.printStackTrace();
        return null;
    }
}
Also used : MapleData(provider.MapleData) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) Pair(tools.Pair)

Example 10 with MapleData

use of provider.MapleData in project HeavenMS by ronancpl.

the class MapleLifeFactory method getMonsterLevel.

public static int getMonsterLevel(int mid) {
    try {
        MapleMonsterStats stats = monsterStats.get(Integer.valueOf(mid));
        if (stats == null) {
            MapleData monsterData = data.getData(StringUtil.getLeftPaddedStr(Integer.toString(mid) + ".img", '0', 11));
            if (monsterData == null) {
                return -1;
            }
            MapleData monsterInfoData = monsterData.getChildByPath("info");
            return MapleDataTool.getIntConvert("level", monsterInfoData);
        } else {
            return stats.getLevel();
        }
    } catch (NullPointerException npe) {
        System.out.println("[SEVERE] MOB " + mid + " failed to load. Issue: " + npe.getMessage() + "\n\n");
        npe.printStackTrace();
    }
    return -1;
}
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