Agathion related rework.
This commit is contained in:
@@ -45,6 +45,7 @@ import org.l2jmobius.gameserver.data.sql.CrestTable;
|
||||
import org.l2jmobius.gameserver.data.sql.OfflineTraderTable;
|
||||
import org.l2jmobius.gameserver.data.xml.ActionData;
|
||||
import org.l2jmobius.gameserver.data.xml.AdminData;
|
||||
import org.l2jmobius.gameserver.data.xml.AgathionData;
|
||||
import org.l2jmobius.gameserver.data.xml.AlchemyData;
|
||||
import org.l2jmobius.gameserver.data.xml.AppearanceItemData;
|
||||
import org.l2jmobius.gameserver.data.xml.ArmorSetData;
|
||||
@@ -266,6 +267,7 @@ public class GameServer
|
||||
EnchantItemHPBonusData.getInstance();
|
||||
BuyListData.getInstance();
|
||||
MultisellData.getInstance();
|
||||
AgathionData.getInstance();
|
||||
RecipeData.getInstance();
|
||||
ArmorSetData.getInstance();
|
||||
FishingData.getInstance();
|
||||
|
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 org.l2jmobius.gameserver.data.xml;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
import org.l2jmobius.commons.util.IXmlReader;
|
||||
import org.l2jmobius.gameserver.data.ItemTable;
|
||||
import org.l2jmobius.gameserver.model.StatSet;
|
||||
import org.l2jmobius.gameserver.model.holders.AgathionSkillHolder;
|
||||
import org.l2jmobius.gameserver.model.holders.SkillHolder;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class AgathionData implements IXmlReader
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(AgathionData.class.getName());
|
||||
|
||||
private static final Map<Integer, AgathionSkillHolder> AGATHION_SKILLS = new HashMap<>();
|
||||
|
||||
protected AgathionData()
|
||||
{
|
||||
load();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load()
|
||||
{
|
||||
AGATHION_SKILLS.clear();
|
||||
parseDatapackFile("data/AgathionData.xml");
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + AGATHION_SKILLS.size() + " agathion data.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseDocument(Document doc, File f)
|
||||
{
|
||||
forEach(doc, "list", listNode -> forEach(listNode, "agathion", agathionNode ->
|
||||
{
|
||||
final StatSet set = new StatSet(parseAttributes(agathionNode));
|
||||
|
||||
final int id = set.getInt("id");
|
||||
if (ItemTable.getInstance().getTemplate(id) == null)
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Could not find agathion with id " + id + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
final int enchant = set.getInt("enchant", 0);
|
||||
|
||||
final Map<Integer, List<SkillHolder>> mainSkills = AGATHION_SKILLS.containsKey(id) ? AGATHION_SKILLS.get(id).getMainSkills() : new HashMap<>();
|
||||
final List<SkillHolder> mainSkillList = new ArrayList<>();
|
||||
final String main = set.getString("mainSkill", "");
|
||||
for (String skill : main.split(";"))
|
||||
{
|
||||
if (skill.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final String[] split = skill.split(",");
|
||||
final int skillId = Integer.parseInt(split[0]);
|
||||
final int level = Integer.parseInt(split[1]);
|
||||
if (SkillData.getInstance().getSkill(skillId, level) == null)
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Could not find agathion skill id " + skillId + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
mainSkillList.add(new SkillHolder(skillId, level));
|
||||
}
|
||||
mainSkills.put(enchant, mainSkillList);
|
||||
|
||||
final Map<Integer, List<SkillHolder>> subSkills = AGATHION_SKILLS.containsKey(id) ? AGATHION_SKILLS.get(id).getSubSkills() : new HashMap<>();
|
||||
final List<SkillHolder> subSkillList = new ArrayList<>();
|
||||
final String sub = set.getString("subSkill", "");
|
||||
for (String skill : sub.split(";"))
|
||||
{
|
||||
if (skill.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final String[] split = skill.split(",");
|
||||
final int skillId = Integer.parseInt(split[0]);
|
||||
final int level = Integer.parseInt(split[1]);
|
||||
if (SkillData.getInstance().getSkill(skillId, level) == null)
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Could not find agathion skill id " + skillId + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
subSkillList.add(new SkillHolder(skillId, level));
|
||||
}
|
||||
subSkills.put(enchant, subSkillList);
|
||||
|
||||
AGATHION_SKILLS.put(id, new AgathionSkillHolder(mainSkills, subSkills));
|
||||
}));
|
||||
}
|
||||
|
||||
public AgathionSkillHolder getSkills(int agathionId)
|
||||
{
|
||||
return AGATHION_SKILLS.get(agathionId);
|
||||
}
|
||||
|
||||
public static AgathionData getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final AgathionData INSTANCE = new AgathionData();
|
||||
}
|
||||
}
|
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 org.l2jmobius.gameserver.model.holders;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class AgathionSkillHolder
|
||||
{
|
||||
private final Map<Integer, List<SkillHolder>> _mainSkill;
|
||||
private final Map<Integer, List<SkillHolder>> _subSkill;
|
||||
|
||||
public AgathionSkillHolder(Map<Integer, List<SkillHolder>> mainSkill, Map<Integer, List<SkillHolder>> subSkill)
|
||||
{
|
||||
_mainSkill = mainSkill;
|
||||
_subSkill = subSkill;
|
||||
}
|
||||
|
||||
public Map<Integer, List<SkillHolder>> getMainSkills()
|
||||
{
|
||||
return _mainSkill;
|
||||
}
|
||||
|
||||
public Map<Integer, List<SkillHolder>> getSubSkills()
|
||||
{
|
||||
return _subSkill;
|
||||
}
|
||||
|
||||
public List<SkillHolder> getMainSkills(int enchantLevel)
|
||||
{
|
||||
if (!_mainSkill.containsKey(enchantLevel))
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return _mainSkill.get(enchantLevel);
|
||||
}
|
||||
|
||||
public List<SkillHolder> getSubSkills(int enchantLevel)
|
||||
{
|
||||
if (!_subSkill.containsKey(enchantLevel))
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return _subSkill.get(enchantLevel);
|
||||
}
|
||||
}
|
@@ -35,6 +35,7 @@ import org.l2jmobius.commons.database.DatabaseFactory;
|
||||
import org.l2jmobius.commons.util.CommonUtil;
|
||||
import org.l2jmobius.gameserver.cache.PaperdollCache;
|
||||
import org.l2jmobius.gameserver.data.ItemTable;
|
||||
import org.l2jmobius.gameserver.data.xml.AgathionData;
|
||||
import org.l2jmobius.gameserver.data.xml.AppearanceItemData;
|
||||
import org.l2jmobius.gameserver.data.xml.ArmorSetData;
|
||||
import org.l2jmobius.gameserver.enums.ItemLocation;
|
||||
@@ -48,8 +49,10 @@ import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.model.events.EventDispatcher;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerItemUnequip;
|
||||
import org.l2jmobius.gameserver.model.holders.AgathionSkillHolder;
|
||||
import org.l2jmobius.gameserver.model.holders.ArmorsetSkillHolder;
|
||||
import org.l2jmobius.gameserver.model.holders.ItemSkillHolder;
|
||||
import org.l2jmobius.gameserver.model.holders.SkillHolder;
|
||||
import org.l2jmobius.gameserver.model.items.EtcItem;
|
||||
import org.l2jmobius.gameserver.model.items.Item;
|
||||
import org.l2jmobius.gameserver.model.items.appearance.AppearanceStone;
|
||||
@@ -599,8 +602,12 @@ public abstract class Inventory extends ItemContainer
|
||||
}
|
||||
}
|
||||
|
||||
// Apply skill, if weapon have "skills on equip"
|
||||
item.getItem().forEachSkill(ItemSkillType.ON_EQUIP, holder -> holder.getSkill().activateSkill(player, player));
|
||||
// Apply skill, if item has "skills on equip" and it is not a secondary agathion.
|
||||
if ((slot < PAPERDOLL_AGATHION2) || (slot > PAPERDOLL_AGATHION5))
|
||||
{
|
||||
item.getItem().forEachSkill(ItemSkillType.ON_EQUIP, holder -> holder.getSkill().activateSkill(player, player));
|
||||
}
|
||||
|
||||
if (update)
|
||||
{
|
||||
player.sendSkillList();
|
||||
@@ -1351,7 +1358,32 @@ public abstract class Inventory extends ItemContainer
|
||||
listener.notifyUnequiped(slot, old, this);
|
||||
}
|
||||
old.updateDatabase();
|
||||
|
||||
// Remove agathion skills.
|
||||
if ((slot >= PAPERDOLL_AGATHION1) && (slot <= PAPERDOLL_AGATHION5) && getOwner().isPlayer())
|
||||
{
|
||||
final AgathionSkillHolder agathionSkills = AgathionData.getInstance().getSkills(old.getId());
|
||||
if (agathionSkills != null)
|
||||
{
|
||||
boolean update = false;
|
||||
for (SkillHolder holder : agathionSkills.getMainSkills(old.getEnchantLevel()))
|
||||
{
|
||||
getOwner().getActingPlayer().removeSkill(holder.getSkill(), false, holder.getSkill().isPassive());
|
||||
update = true;
|
||||
}
|
||||
for (SkillHolder holder : agathionSkills.getSubSkills(old.getEnchantLevel()))
|
||||
{
|
||||
getOwner().getActingPlayer().removeSkill(holder.getSkill(), false, holder.getSkill().isPassive());
|
||||
update = true;
|
||||
}
|
||||
if (update)
|
||||
{
|
||||
getOwner().getActingPlayer().sendSkillList();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add new item in slot of paperdoll
|
||||
if (item != null)
|
||||
{
|
||||
@@ -1371,6 +1403,41 @@ public abstract class Inventory extends ItemContainer
|
||||
listener.notifyEquiped(slot, item, this);
|
||||
}
|
||||
item.updateDatabase();
|
||||
|
||||
// Add agathion skills.
|
||||
if ((slot >= PAPERDOLL_AGATHION1) && (slot <= PAPERDOLL_AGATHION5) && getOwner().isPlayer())
|
||||
{
|
||||
final AgathionSkillHolder agathionSkills = AgathionData.getInstance().getSkills(item.getId());
|
||||
if (agathionSkills != null)
|
||||
{
|
||||
boolean update = false;
|
||||
if (slot == PAPERDOLL_AGATHION1)
|
||||
{
|
||||
for (SkillHolder holder : agathionSkills.getMainSkills(item.getEnchantLevel()))
|
||||
{
|
||||
if (holder.getSkill().isPassive() && !holder.getSkill().checkConditions(SkillConditionScope.PASSIVE, getOwner().getActingPlayer(), getOwner().getActingPlayer()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
getOwner().getActingPlayer().addSkill(holder.getSkill(), false);
|
||||
update = true;
|
||||
}
|
||||
}
|
||||
for (SkillHolder holder : agathionSkills.getSubSkills(item.getEnchantLevel()))
|
||||
{
|
||||
if (holder.getSkill().isPassive() && !holder.getSkill().checkConditions(SkillConditionScope.PASSIVE, getOwner().getActingPlayer(), getOwner().getActingPlayer()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
getOwner().getActingPlayer().addSkill(holder.getSkill(), false);
|
||||
update = true;
|
||||
}
|
||||
if (update)
|
||||
{
|
||||
getOwner().getActingPlayer().sendSkillList();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_paperdollCache.clearCachedStats();
|
||||
|
@@ -827,6 +827,13 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
||||
|
||||
public void addSkill(ItemSkillHolder holder)
|
||||
{
|
||||
// Agathion skills managed by AgathionData.
|
||||
// if ((getBodyPart() == SLOT_AGATHION) && (holder.getType() != ItemSkillType.ON_EQUIP) && (holder.getType() != ItemSkillType.ON_UNEQUIP))
|
||||
// {
|
||||
// LOGGER.warning("Remove from agathion " + _itemId + " " + holder + "!");
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (_skills == null)
|
||||
{
|
||||
_skills = new ArrayList<>();
|
||||
|
@@ -36,6 +36,7 @@ import java.util.logging.Logger;
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||
import org.l2jmobius.gameserver.data.ItemTable;
|
||||
import org.l2jmobius.gameserver.data.xml.AgathionData;
|
||||
import org.l2jmobius.gameserver.data.xml.AppearanceItemData;
|
||||
import org.l2jmobius.gameserver.data.xml.EnchantItemOptionsData;
|
||||
import org.l2jmobius.gameserver.data.xml.EnsoulData;
|
||||
@@ -70,7 +71,10 @@ import org.l2jmobius.gameserver.model.events.impl.item.OnItemBypassEvent;
|
||||
import org.l2jmobius.gameserver.model.events.impl.item.OnItemEnchantAdd;
|
||||
import org.l2jmobius.gameserver.model.events.impl.item.OnItemSoulCrystalAdd;
|
||||
import org.l2jmobius.gameserver.model.events.impl.item.OnItemTalk;
|
||||
import org.l2jmobius.gameserver.model.holders.AgathionSkillHolder;
|
||||
import org.l2jmobius.gameserver.model.holders.SkillHolder;
|
||||
import org.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||
import org.l2jmobius.gameserver.model.items.Armor;
|
||||
import org.l2jmobius.gameserver.model.items.EtcItem;
|
||||
import org.l2jmobius.gameserver.model.items.Item;
|
||||
@@ -83,6 +87,7 @@ import org.l2jmobius.gameserver.model.options.EnchantOptions;
|
||||
import org.l2jmobius.gameserver.model.options.Options;
|
||||
import org.l2jmobius.gameserver.model.siege.Castle;
|
||||
import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
import org.l2jmobius.gameserver.model.skills.SkillConditionScope;
|
||||
import org.l2jmobius.gameserver.model.variables.ItemVariables;
|
||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.DropItem;
|
||||
@@ -930,7 +935,56 @@ public class ItemInstance extends WorldObject
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
clearEnchantStats();
|
||||
|
||||
// Agathion skills.
|
||||
if (isEquipped() && (_item.getBodyPart() == Item.SLOT_AGATHION))
|
||||
{
|
||||
final AgathionSkillHolder agathionSkills = AgathionData.getInstance().getSkills(getId());
|
||||
if (agathionSkills != null)
|
||||
{
|
||||
boolean update = false;
|
||||
// Remove old skills.
|
||||
for (SkillHolder holder : agathionSkills.getMainSkills(_enchantLevel))
|
||||
{
|
||||
getActingPlayer().removeSkill(holder.getSkill(), false, holder.getSkill().isPassive());
|
||||
update = true;
|
||||
}
|
||||
for (SkillHolder holder : agathionSkills.getSubSkills(_enchantLevel))
|
||||
{
|
||||
getActingPlayer().removeSkill(holder.getSkill(), false, holder.getSkill().isPassive());
|
||||
update = true;
|
||||
}
|
||||
// Add new skills.
|
||||
if (getLocationSlot() == Inventory.PAPERDOLL_AGATHION1)
|
||||
{
|
||||
for (SkillHolder holder : agathionSkills.getMainSkills(enchantLevel))
|
||||
{
|
||||
if (holder.getSkill().isPassive() && !holder.getSkill().checkConditions(SkillConditionScope.PASSIVE, getActingPlayer(), getActingPlayer()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
getActingPlayer().addSkill(holder.getSkill(), false);
|
||||
update = true;
|
||||
}
|
||||
}
|
||||
for (SkillHolder holder : agathionSkills.getSubSkills(enchantLevel))
|
||||
{
|
||||
if (holder.getSkill().isPassive() && !holder.getSkill().checkConditions(SkillConditionScope.PASSIVE, getActingPlayer(), getActingPlayer()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
getActingPlayer().addSkill(holder.getSkill(), false);
|
||||
update = true;
|
||||
}
|
||||
if (update)
|
||||
{
|
||||
getActingPlayer().sendSkillList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_enchantLevel = enchantLevel;
|
||||
applyEnchantStats();
|
||||
_storedInDb = false;
|
||||
|
@@ -52,6 +52,7 @@ import org.l2jmobius.gameserver.model.clan.Clan;
|
||||
import org.l2jmobius.gameserver.model.holders.AttendanceInfoHolder;
|
||||
import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder;
|
||||
import org.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
import org.l2jmobius.gameserver.model.items.Item;
|
||||
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||
import org.l2jmobius.gameserver.model.quest.Quest;
|
||||
import org.l2jmobius.gameserver.model.residences.ClanHall;
|
||||
@@ -645,6 +646,13 @@ public class EnterWorld implements IClientIncomingPacket
|
||||
player.updateAbnormalVisualEffects();
|
||||
}
|
||||
|
||||
// Activate first agathion when available.
|
||||
final ItemInstance agathion = player.getInventory().unEquipItemInBodySlot(Item.SLOT_AGATHION);
|
||||
if (agathion != null)
|
||||
{
|
||||
player.getInventory().equipItemAndRecord(agathion);
|
||||
}
|
||||
|
||||
if (Config.ENABLE_ATTENDANCE_REWARDS)
|
||||
{
|
||||
ThreadPool.schedule(() ->
|
||||
|
Reference in New Issue
Block a user