Underground update.

This commit is contained in:
MobiusDev
2015-11-07 01:36:06 +00:00
parent cf1f829606
commit 37dbd02716
750 changed files with 102520 additions and 58051 deletions

View File

@ -0,0 +1,261 @@
/*
* Copyright (C) 2004-2015 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J Server is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.data.xml.impl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.base.ClassId;
import com.l2jserver.gameserver.model.holders.DailyMissionHolder;
import com.l2jserver.gameserver.network.serverpackets.dailymission.ExOneDayReceiveRewardList;
import com.l2jserver.util.data.xml.IXmlReader;
/**
* The Class DailyMissionData.
* @author Mobius
*/
public class DailyMissionData implements IXmlReader
{
private final List<DailyMissionHolder> _dailyMissions = new ArrayList<>();
private final List<DailyMissionHolder> _dailyLevelUpMissions = new ArrayList<>();
/**
* Instantiates new daily mission data.
*/
protected DailyMissionData()
{
load();
}
@Override
public void load()
{
_dailyMissions.clear();
_dailyLevelUpMissions.clear();
parseDatapackFile("dailyMissions.xml");
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _dailyMissions.size() + " daily missions.");
}
@Override
public void parseDocument(Document doc)
{
int id;
int clientId;
String type;
int level;
List<Integer> classesList;
Map<Integer, Integer> rewards;
for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
{
if ("list".equalsIgnoreCase(n.getNodeName()))
{
for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
{
if ("mission".equalsIgnoreCase(d.getNodeName()))
{
NamedNodeMap attrs = d.getAttributes();
Node att;
id = -1;
clientId = 0;
type = "";
level = 1;
classesList = new ArrayList<>();
rewards = new HashMap<>();
att = attrs.getNamedItem("id");
if (att == null)
{
LOGGER.severe(getClass().getSimpleName() + ": Missing id for daily mission, skipping");
continue;
}
id = Integer.parseInt(att.getNodeValue());
att = attrs.getNamedItem("clientId");
if (att == null)
{
LOGGER.severe(getClass().getSimpleName() + ": Missing clientId for daily mission id: " + id + ", skipping");
continue;
}
clientId = Integer.parseInt(att.getNodeValue());
att = attrs.getNamedItem("type");
if (att == null)
{
LOGGER.severe(getClass().getSimpleName() + ": Missing type for daily mission id: " + id + ", skipping");
continue;
}
type = att.getNodeValue();
att = attrs.getNamedItem("level");
if (att == null)
{
LOGGER.severe(getClass().getSimpleName() + ": Missing level for daily mission id: " + id + ", skipping");
continue;
}
level = Integer.parseInt(att.getNodeValue());
att = attrs.getNamedItem("classes");
if (att == null)
{
LOGGER.severe(getClass().getSimpleName() + ": Missing classes for daily mission id: " + id + ", skipping");
continue;
}
if (att.getNodeValue().equalsIgnoreCase("ALL"))
{
for (ClassId cid : ClassId.values())
{
classesList.add(cid.getId());
}
}
else
{
final String[] s = att.getNodeValue().split(",");
for (String element : s)
{
classesList.add(Integer.parseInt(element));
}
}
for (Node c = d.getFirstChild(); c != null; c = c.getNextSibling())
{
if ("reward".equalsIgnoreCase(c.getNodeName()))
{
final int itemId = Integer.parseInt(c.getAttributes().getNamedItem("item").getNodeValue());
final int itemCount = Integer.parseInt(c.getAttributes().getNamedItem("count").getNodeValue());
rewards.put(itemId, itemCount);
}
}
if (type.equalsIgnoreCase("LEVEL"))
{
_dailyLevelUpMissions.add(new DailyMissionHolder(id, clientId, type, level, classesList, rewards));
}
_dailyMissions.add(new DailyMissionHolder(id, clientId, type, level, classesList, rewards));
}
}
}
}
}
/**
* @param id int
* @param player L2PcInstance
* @return boolean
*/
public boolean isRewardAvailable(int id, L2PcInstance player)
{
if (player.getLevel() < _dailyMissions.get(id - 1).getLevel())
{
return false;
}
if (player.getVariables().getString("DailyMission" + id, null) != null)
{
return false;
}
return true;
}
/**
* @param rewardId1 int
* @param player L2PcInstance
*/
public void rewardPlayer(int rewardId1, L2PcInstance player)
{
for (DailyMissionHolder mission : _dailyMissions)
{
if ((mission.getClientId() == rewardId1) && isRewardAvailable(mission.getId(), player))
{
for (int itemId : mission.getRewards().keySet())
{
player.addItem("DailyMission", itemId, mission.getRewards().get(itemId), player, true);
}
for (DailyMissionHolder m : _dailyMissions)
{
if (mission.getClientId() == m.getClientId())
{
player.getVariables().set("DailyMission" + m.getId(), System.currentTimeMillis());
}
}
player.sendPacket(new ExOneDayReceiveRewardList(player));
break;
}
}
}
/**
* Gets the daily missions.
* @param classId int
* @return the daily missions
*/
public List<DailyMissionHolder> getDailyMissions(int classId)
{
List<DailyMissionHolder> missions = new ArrayList<>();
for (DailyMissionHolder mission : _dailyMissions)
{
if (mission.getAvailableClasses().contains(classId))
{
missions.add(mission);
}
}
return missions;
}
/**
* Gets the daily level up missions.
* @param classId int
* @return the daily level up missions
*/
public List<DailyMissionHolder> getDailyLevelUpMissions(int classId)
{
List<DailyMissionHolder> missions = new ArrayList<>();
for (DailyMissionHolder mission : _dailyLevelUpMissions)
{
if (mission.getAvailableClasses().contains(classId))
{
missions.add(mission);
}
}
return missions;
}
/**
* Gets the single instance of DailyMissionData.
* @return single instance of DailyMissionData
*/
public static DailyMissionData getInstance()
{
return SingletonHolder._instance;
}
/**
* The Class SingletonHolder.
*/
private static class SingletonHolder
{
protected static final DailyMissionData _instance = new DailyMissionData();
}
}

View File

@ -53,6 +53,14 @@ public class EnchantSkillGroupsData implements IXmlReader
public static final int CHANGE_ENCHANT_BOOK = 30299;
public static final int UNTRAIN_ENCHANT_BOOK = 30300;
public static final int IMMORTAL_SCROLL = 37044;
public static final int NORMAL_ENCHANT_BOOK_V2 = 46150;
public static final int SAFE_ENCHANT_BOOK_V2 = 46151;
public static final int CHANGE_ENCHANT_BOOK_V2 = 46152;
public static final int IMMORTAL_SCROLL_V2 = 46153;
public static final int NORMAL_ENCHANT_BOOK_V3 = 46154;
public static final int SAFE_ENCHANT_BOOK_V3 = 46155;
public static final int CHANGE_ENCHANT_BOOK_V3 = 46156;
public static final int IMMORTAL_SCROLL_V3 = 46157;
private final Map<Integer, L2EnchantSkillGroup> _enchantSkillGroups = new HashMap<>();
private final Map<Integer, L2EnchantSkillLearn> _enchantSkillTrees = new HashMap<>();

View File

@ -25,6 +25,7 @@ import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jserver.Config;
import com.l2jserver.util.data.xml.IXmlReader;
/**
@ -51,7 +52,7 @@ public final class ExperienceData implements IXmlReader
{
_expTable.clear();
parseDatapackFile("stats/experience.xml");
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _expTable.size() + " levels.");
LOGGER.info(getClass().getSimpleName() + ": Loaded " + (_expTable.size() - 1) + " levels.");
LOGGER.info(getClass().getSimpleName() + ": Max Player Level is: " + (MAX_LEVEL - 1));
LOGGER.info(getClass().getSimpleName() + ": Max Pet Level is: " + (MAX_PET_LEVEL - 1));
}
@ -65,12 +66,27 @@ public final class ExperienceData implements IXmlReader
MAX_LEVEL = (byte) (Byte.parseByte(tableAttr.getNamedItem("maxLevel").getNodeValue()) + 1);
MAX_PET_LEVEL = (byte) (Byte.parseByte(tableAttr.getNamedItem("maxPetLevel").getNodeValue()) + 1);
if (MAX_LEVEL > Config.PLAYER_MAXIMUM_LEVEL)
{
MAX_LEVEL = Config.PLAYER_MAXIMUM_LEVEL;
}
if (MAX_PET_LEVEL > MAX_LEVEL)
{
MAX_PET_LEVEL = MAX_LEVEL; // Pet level should not exceed owner level.
}
int maxLevel = 0;
for (Node n = table.getFirstChild(); n != null; n = n.getNextSibling())
{
if ("experience".equals(n.getNodeName()))
{
NamedNodeMap attrs = n.getAttributes();
_expTable.put(parseInteger(attrs, "level"), parseLong(attrs, "tolevel"));
maxLevel = parseInteger(attrs, "level");
if (maxLevel > Config.PLAYER_MAXIMUM_LEVEL)
{
break;
}
_expTable.put(maxLevel, parseLong(attrs, "tolevel"));
}
}
}
@ -82,6 +98,10 @@ public final class ExperienceData implements IXmlReader
*/
public long getExpForLevel(int level)
{
if (level > Config.PLAYER_MAXIMUM_LEVEL)
{
level = Config.PLAYER_MAXIMUM_LEVEL;
}
return _expTable.get(level);
}

View File

@ -26,6 +26,7 @@ import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jserver.Config;
import com.l2jserver.util.data.xml.IXmlReader;
/**
@ -61,7 +62,12 @@ public class KarmaData implements IXmlReader
if ("increase".equalsIgnoreCase(d.getNodeName()))
{
final NamedNodeMap attrs = d.getAttributes();
_karmaTable.put(parseInteger(attrs, "lvl"), parseDouble(attrs, "val"));
int level = parseInteger(attrs, "lvl");
if (level >= Config.PLAYER_MAXIMUM_LEVEL)
{
break;
}
_karmaTable.put(level, parseDouble(attrs, "val"));
}
}
}

View File

@ -28,6 +28,7 @@ import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jserver.Config;
import com.l2jserver.gameserver.model.Location;
import com.l2jserver.gameserver.model.StatsSet;
import com.l2jserver.gameserver.model.actor.templates.L2PcTemplate;
@ -152,12 +153,11 @@ public final class PlayerTemplateData implements IXmlReader
{
attrs = lvlNode.getAttributes();
int level = parseInteger(attrs, "val");
for (Node valNode = lvlNode.getFirstChild(); valNode != null; valNode = valNode.getNextSibling())
{
String nodeName = valNode.getNodeName();
if ((nodeName.startsWith("hp") || nodeName.startsWith("mp") || nodeName.startsWith("cp")) && _playerTemplates.containsKey(ClassId.getClassId(classId)))
if ((level < Config.PLAYER_MAXIMUM_LEVEL) && (nodeName.startsWith("hp") || nodeName.startsWith("mp") || nodeName.startsWith("cp")) && _playerTemplates.containsKey(ClassId.getClassId(classId)))
{
_playerTemplates.get(ClassId.getClassId(classId)).setUpgainValue(nodeName, level, Double.parseDouble(valNode.getTextContent()));
_dataCount++;
@ -165,6 +165,7 @@ public final class PlayerTemplateData implements IXmlReader
}
}
}
// TODO: Generate stats automatically.
}
}
}

View File

@ -59,7 +59,12 @@ public final class PlayerXpPercentLostData implements IXmlReader
if ("xpLost".equalsIgnoreCase(d.getNodeName()))
{
NamedNodeMap attrs = d.getAttributes();
_playerXpPercentLost[parseInteger(attrs, "level")] = parseDouble(attrs, "val");
Integer level = parseInteger(attrs, "level");
if (level > _maxlevel)
{
break;
}
_playerXpPercentLost[level] = parseDouble(attrs, "val");
}
}
}