Sync with L2JServer Jan 9th 2015.

This commit is contained in:
mobius
2015-01-09 19:55:02 +00:00
parent 9c9b0aaff7
commit 4c2db62a63
618 changed files with 19803 additions and 7853 deletions

View File

@ -0,0 +1,115 @@
/*
* 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.datatables;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jserver.gameserver.engines.DocumentParser;
import com.l2jserver.gameserver.enums.CastleSide;
import com.l2jserver.gameserver.model.holders.CastleSpawnHolder;
/**
* @author St3eT
*/
public final class CastleData implements DocumentParser
{
private final Map<Integer, List<CastleSpawnHolder>> _castles = new HashMap<>();
protected CastleData()
{
load();
}
@Override
public void load()
{
_castles.clear();
parseDatapackDirectory("data/castles", true);
}
@Override
public void parseDocument(Document doc)
{
for (Node listNode = doc.getFirstChild(); listNode != null; listNode = listNode.getNextSibling())
{
if ("list".equals(listNode.getNodeName()))
{
for (Node castleNode = listNode.getFirstChild(); castleNode != null; castleNode = castleNode.getNextSibling())
{
if ("castle".equals(castleNode.getNodeName()))
{
final int castleId = parseInteger(castleNode.getAttributes(), "id");
final List<CastleSpawnHolder> spawns = new ArrayList<>();
for (Node tpNode = castleNode.getFirstChild(); tpNode != null; tpNode = tpNode.getNextSibling())
{
if ("spawn".equals(tpNode.getNodeName()))
{
final CastleSide side = parseEnum(tpNode.getAttributes(), CastleSide.class, "castleSide", CastleSide.NEUTRAL);
for (Node npcNode = tpNode.getFirstChild(); npcNode != null; npcNode = npcNode.getNextSibling())
{
if ("npc".equals(npcNode.getNodeName()))
{
final NamedNodeMap np = npcNode.getAttributes();
final int npcId = parseInteger(np, "id");
final int x = parseInteger(np, "x");
final int y = parseInteger(np, "y");
final int z = parseInteger(np, "z");
final int heading = parseInteger(np, "heading");
spawns.add(new CastleSpawnHolder(npcId, side, x, y, z, heading));
}
}
}
}
_castles.put(castleId, spawns);
}
}
}
}
}
public final List<CastleSpawnHolder> getSpawnsForSide(int castleId, CastleSide side)
{
return _castles.getOrDefault(castleId, Collections.emptyList()).stream().filter(s -> s.getSide() == side).collect(Collectors.toList());
}
/**
* Gets the single instance of TeleportersData.
* @return single instance of TeleportersData
*/
public static CastleData getInstance()
{
return SingletonHolder._instance;
}
private static class SingletonHolder
{
protected static final CastleData _instance = new CastleData();
}
}

View File

@ -401,12 +401,14 @@ public class ClanTable
_log.log(Level.SEVERE, getClass().getSimpleName() + ": Error storing clan wars data.", e);
}
// SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.A_CLAN_WAR_WITH_CLAN_S1_HAS_STARTED_THE_CLAN_THAT_CANCELS_THE_WAR_FIRST_WILL_LOSE_5_000_CLAN_REPUTATION_ANY_CLAN_THAT_CANCELS_THE_WAR_WILL_BE_UNABLE_TO_DECLARE_A_WAR_FOR_1_WEEK_IF_YOUR_CLAN_MEMBER_GETS_KILLED_BY_THE_OTHER_CLAN_XP_DECREASES_BY_1_4_OF_THE_AMOUNT_THAT_DECREASES_IN_THE_HUNTING_GROUND);
// SystemMessage msg =
// SystemMessage.getSystemMessage(SystemMessageId.A_CLAN_WAR_WITH_CLAN_S1_HAS_STARTED_THE_CLAN_THAT_CANCELS_THE_WAR_FIRST_WILL_LOSE_5_000_CLAN_REPUTATION_ANY_CLAN_THAT_CANCELS_THE_WAR_WILL_BE_UNABLE_TO_DECLARE_A_WAR_FOR_1_WEEK_IF_YOUR_CLAN_MEMBER_GETS_KILLED_BY_THE_OTHER_CLAN_XP_DECREASES_BY_1_4_OF_THE_AMOUNT_THAT_DECREASES_IN_THE_HUNTING_GROUND);
//
SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_DECLARED_A_CLAN_WAR_WITH_S1);
msg.addString(clan2.getName());
clan1.broadcastToOnlineMembers(msg);
// msg = SystemMessage.getSystemMessage(SystemMessageId.A_CLAN_WAR_WITH_CLAN_S1_HAS_STARTED_THE_CLAN_THAT_CANCELS_THE_WAR_FIRST_WILL_LOSE_5_000_CLAN_REPUTATION_ANY_CLAN_THAT_CANCELS_THE_WAR_WILL_BE_UNABLE_TO_DECLARE_A_WAR_FOR_1_WEEK_IF_YOUR_CLAN_MEMBER_GETS_KILLED_BY_THE_OTHER_CLAN_XP_DECREASES_BY_1_4_OF_THE_AMOUNT_THAT_DECREASES_IN_THE_HUNTING_GROUND);
// msg =
// SystemMessage.getSystemMessage(SystemMessageId.A_CLAN_WAR_WITH_CLAN_S1_HAS_STARTED_THE_CLAN_THAT_CANCELS_THE_WAR_FIRST_WILL_LOSE_5_000_CLAN_REPUTATION_ANY_CLAN_THAT_CANCELS_THE_WAR_WILL_BE_UNABLE_TO_DECLARE_A_WAR_FOR_1_WEEK_IF_YOUR_CLAN_MEMBER_GETS_KILLED_BY_THE_OTHER_CLAN_XP_DECREASES_BY_1_4_OF_THE_AMOUNT_THAT_DECREASES_IN_THE_HUNTING_GROUND);
// msg.addString(clan1.getName());
// clan2.broadcastToOnlineMembers(msg);
// clan1 declared clan war.
@ -458,7 +460,7 @@ public class ClanTable
count++;
}
}
if (count == (clan1.getMembers().length - 1))
if (count == (clan1.getMembers().size() - 1))
{
clan1.deleteEnemyClan(clan2);
clan2.deleteEnemyClan(clan1);

View File

@ -20,6 +20,8 @@ package com.l2jserver.gameserver.datatables;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
@ -27,6 +29,7 @@ import java.util.logging.Logger;
import com.l2jserver.Config;
import com.l2jserver.gameserver.engines.DocumentEngine;
import com.l2jserver.gameserver.model.skills.CommonSkill;
import com.l2jserver.gameserver.model.skills.Skill;
/**
@ -150,21 +153,23 @@ public final class SkillData
* @param hasCastle
* @return an array with siege skills. If addNoble == true, will add also Advanced headquarters.
*/
public Skill[] getSiegeSkills(boolean addNoble, boolean hasCastle)
public List<Skill> getSiegeSkills(boolean addNoble, boolean hasCastle)
{
Skill[] temp = new Skill[2 + (addNoble ? 1 : 0) + (hasCastle ? 2 : 0)];
int i = 0;
temp[i++] = _skills.get(SkillData.getSkillHashCode(246, 1));
temp[i++] = _skills.get(SkillData.getSkillHashCode(247, 1));
final List<Skill> temp = new LinkedList<>();
temp.add(_skills.get(SkillData.getSkillHashCode(CommonSkill.IMPRIT_OF_LIGHT.getId(), 1)));
temp.add(_skills.get(SkillData.getSkillHashCode(CommonSkill.IMPRIT_OF_DARKNESS.getId(), 1)));
temp.add(_skills.get(SkillData.getSkillHashCode(247, 1))); // Build Headquarters
if (addNoble)
{
temp[i++] = _skills.get(SkillData.getSkillHashCode(326, 1));
temp.add(_skills.get(SkillData.getSkillHashCode(326, 1))); // Build Advanced Headquarters
}
if (hasCastle)
{
temp[i++] = _skills.get(SkillData.getSkillHashCode(844, 1));
temp[i++] = _skills.get(SkillData.getSkillHashCode(845, 1));
temp.add(_skills.get(SkillData.getSkillHashCode(844, 1))); // Outpost Construction
temp.add(_skills.get(SkillData.getSkillHashCode(845, 1))); // Outpost Demolition
}
return temp;
}

View File

@ -23,6 +23,7 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@ -35,6 +36,7 @@ import org.w3c.dom.Node;
import com.l2jserver.Config;
import com.l2jserver.gameserver.engines.DocumentParser;
import com.l2jserver.gameserver.enums.Race;
import com.l2jserver.gameserver.enums.SubclassType;
import com.l2jserver.gameserver.model.L2Clan;
import com.l2jserver.gameserver.model.L2SkillLearn;
import com.l2jserver.gameserver.model.L2SkillLearn.SubClassData;
@ -78,6 +80,7 @@ public final class SkillTreesData implements DocumentParser
private static final Map<ClassId, Map<Integer, L2SkillLearn>> _classSkillTrees = new HashMap<>();
private static final Map<ClassId, Map<Integer, L2SkillLearn>> _transferSkillTrees = new HashMap<>();
private static final Map<Race, Map<Integer, L2SkillLearn>> _raceSkillTree = new HashMap<>();
private static final Map<SubclassType, Map<Integer, L2SkillLearn>> _revelationSkillTree = new HashMap<>();
// Skill Hash Code, L2SkillLearn
private static final Map<Integer, L2SkillLearn> _collectSkillTree = new HashMap<>();
private static final Map<Integer, L2SkillLearn> _fishingSkillTree = new HashMap<>();
@ -133,6 +136,7 @@ public final class SkillTreesData implements DocumentParser
_gameMasterSkillTree.clear();
_gameMasterAuraSkillTree.clear();
_raceSkillTree.clear();
_revelationSkillTree.clear();
// Load files.
parseDatapackDirectory("data/skillTrees/", false);
@ -156,6 +160,7 @@ public final class SkillTreesData implements DocumentParser
Node attr;
String type = null;
Race race = null;
SubclassType subType = null;
int cId = -1;
int parentClassId = -1;
ClassId classId = null;
@ -170,6 +175,7 @@ public final class SkillTreesData implements DocumentParser
final Map<Integer, L2SkillLearn> classSkillTree = new HashMap<>();
final Map<Integer, L2SkillLearn> transferSkillTree = new HashMap<>();
final Map<Integer, L2SkillLearn> raceSkillTree = new HashMap<>();
final Map<Integer, L2SkillLearn> revelationSkillTree = new HashMap<>();
type = d.getAttributes().getNamedItem("type").getNodeValue();
attr = d.getAttributes().getNamedItem("classId");
@ -189,6 +195,12 @@ public final class SkillTreesData implements DocumentParser
race = parseEnum(attr, Race.class);
}
attr = d.getAttributes().getNamedItem("subType");
if (attr != null)
{
subType = parseEnum(attr, SubclassType.class);
}
attr = d.getAttributes().getNamedItem("parentClassId");
if (attr != null)
{
@ -271,6 +283,11 @@ public final class SkillTreesData implements DocumentParser
raceSkillTree.put(skillHashCode, skillLearn);
break;
}
case "revelationSkillTree":
{
revelationSkillTree.put(skillHashCode, skillLearn);
break;
}
case "fishingSkillTree":
{
_fishingSkillTree.put(skillHashCode, skillLearn);
@ -365,6 +382,17 @@ public final class SkillTreesData implements DocumentParser
_raceSkillTree.get(race).putAll(raceSkillTree);
}
}
else if (type.equals("revelationSkillTree") && (subType != null))
{
if (!_revelationSkillTree.containsKey(subType))
{
_revelationSkillTree.put(subType, revelationSkillTree);
}
else
{
_revelationSkillTree.get(subType).putAll(revelationSkillTree);
}
}
}
}
}
@ -576,7 +604,7 @@ public final class SkillTreesData implements DocumentParser
final Map<Integer, L2SkillLearn> skills = getCompleteClassSkillTree(classId);
for (L2SkillLearn skill : skills.values())
{
if ((skill.getSkillId() == CommonSkill.DIVINE_INSPIRATION.getId()) || skill.isAutoGet() || skill.isLearnedByFS())
if ((skill.getSkillId() == CommonSkill.DIVINE_INSPIRATION.getId()) || skill.isAutoGet() || skill.isLearnedByFS() || (skill.getGetLevel() > player.getLevel()))
{
continue;
}
@ -585,7 +613,7 @@ public final class SkillTreesData implements DocumentParser
{
return true;
}
else if (skill.getSkillLevel() == 1)
else if ((oldSkill == null) && (skill.getSkillLevel() == 1))
{
return true;
}
@ -617,7 +645,7 @@ public final class SkillTreesData implements DocumentParser
*/
private List<L2SkillLearn> getAvailableSkills(L2PcInstance player, ClassId classId, boolean includeByFs, boolean includeAutoGet, ISkillsHolder holder)
{
final List<L2SkillLearn> result = new ArrayList<>();
final List<L2SkillLearn> result = new LinkedList<>();
final Map<Integer, L2SkillLearn> skills = getCompleteClassSkillTree(classId);
if (skills.isEmpty())
@ -761,6 +789,29 @@ public final class SkillTreesData implements DocumentParser
return result;
}
/**
* Gets the available revelation skills
* @param player the player requesting the revelation skills
* @param type the player current subclass type
* @return all the available revelation skills for a given {@code player}
*/
public List<L2SkillLearn> getAvailableRevelationSkills(L2PcInstance player, SubclassType type)
{
final List<L2SkillLearn> result = new ArrayList<>();
Map<Integer, L2SkillLearn> revelationSkills = _revelationSkillTree.get(type);
for (L2SkillLearn skill : revelationSkills.values())
{
final Skill oldSkill = player.getSkills().get(skill.getSkillId());
if (oldSkill == null)
{
result.add(skill);
}
}
return result;
}
/**
* Gets the available alchemy skills, restricted to Ertheia
* @param player the player requesting the alchemy skills
@ -1057,6 +1108,12 @@ public final class SkillTreesData implements DocumentParser
case COLLECT:
sl = getCollectSkill(id, lvl);
break;
case REVELATION:
sl = getRevelationSkill(SubclassType.BASECLASS, id, lvl);
break;
case REVELATION_DUALCLASS:
sl = getRevelationSkill(SubclassType.DUALCLASS, id, lvl);
break;
case ALCHEMY:
sl = getAlchemySkill(id, lvl);
break;
@ -1214,6 +1271,18 @@ public final class SkillTreesData implements DocumentParser
return _collectSkillTree.get(SkillData.getSkillHashCode(id, lvl));
}
/**
* Gets the revelation skill.
* @param type the subclass type
* @param id the revelation skill Id
* @param lvl the revelation skill level
* @return the revelation skill from the Revelation Skill Tree for a given {@code id} and {@code lvl}
*/
public L2SkillLearn getRevelationSkill(SubclassType type, int id, int lvl)
{
return _revelationSkillTree.get(type).get(SkillData.getSkillHashCode(id, lvl));
}
/**
* Gets the minimum level for new skill.
* @param player the player that requires the minimum level
@ -1243,6 +1312,40 @@ public final class SkillTreesData implements DocumentParser
return minLevel;
}
public List<L2SkillLearn> getNextAvailableSkills(L2PcInstance player, ClassId classId, boolean includeByFs, boolean includeAutoGet)
{
final Map<Integer, L2SkillLearn> completeClassSkillTree = getCompleteClassSkillTree(classId);
final List<L2SkillLearn> result = new LinkedList<>();
if (completeClassSkillTree.isEmpty())
{
return result;
}
final int minLevelForNewSkill = getMinLevelForNewSkill(player, completeClassSkillTree);
if (minLevelForNewSkill > 0)
{
for (L2SkillLearn skill : completeClassSkillTree.values())
{
if (((includeAutoGet && skill.isAutoGet()) || skill.isLearnedByNpc() || (includeByFs && skill.isLearnedByFS())) && (minLevelForNewSkill == skill.getGetLevel()))
{
final Skill oldSkill = player.getKnownSkill(skill.getSkillId());
if (oldSkill != null)
{
if (oldSkill.getLevel() == (skill.getSkillLevel() - 1))
{
result.add(skill);
}
}
else if (skill.getSkillLevel() == 1)
{
result.add(skill);
}
}
}
}
return result;
}
/**
* Checks if is hero skill.
* @param skillId the Id of the skill to check
@ -1517,6 +1620,12 @@ public final class SkillTreesData implements DocumentParser
raceSkillTreeCount += raceSkillTree.size();
}
int revelationSkillTreeCount = 0;
for (Map<Integer, L2SkillLearn> revelationSkillTree : _revelationSkillTree.values())
{
revelationSkillTreeCount += revelationSkillTree.size();
}
int dwarvenOnlyFishingSkillCount = 0;
for (L2SkillLearn fishSkill : _fishingSkillTree.values())
{
@ -1551,6 +1660,7 @@ public final class SkillTreesData implements DocumentParser
LOGGER.info(className + ": Loaded " + _gameMasterAuraSkillTree.size() + " Game Master Aura Skills.");
LOGGER.info(className + ": Loaded " + _abilitySkillTree.size() + " Ability Skills.");
LOGGER.info(className + ": Loaded " + _alchemySkillTree.size() + " Alchemy Skills.");
LOGGER.info(className + ": Loaded " + revelationSkillTreeCount + " Revelation Skills.");
final int commonSkills = _commonSkillTree.size();
if (commonSkills > 0)