Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### Eclipse Workspace Patch 1.0
- #P L2jMega_gameserver2
- diff --git java/Base/Combination/CombinationItem.java java/Base/Combination/CombinationItem.java
- new file mode 100644
- index 0000000..4e395c3
- --- /dev/null
- +++ java/Base/Combination/CombinationItem.java
- @@ -0,0 +1,95 @@
- +package Base.Combination;
- +
- +
- +
- +import java.util.EnumMap;
- +import java.util.Map;
- +
- +import net.sf.l2j.gameserver.data.ItemTable;
- +import net.sf.l2j.gameserver.model.item.kind.Item;
- +
- +public class CombinationItem {
- + private int _itemOne;
- +
- + private int _itemTwo;
- + private int _commission;
- + private float _chance;
- + private final Map<CombinationItemType, CombinationItemReward> _rewards = new EnumMap<>(CombinationItemType.class);
- +
- + public CombinationItem(int one, int two, int commission, float chance) {
- + _itemOne = one;
- + _itemTwo = two;
- + _commission = commission;
- + _chance = chance;
- + }
- +
- +
- + public int getItemOne() {
- + return _itemOne;
- + }
- +
- +
- +
- + public int getItemTwo() {
- + return _itemTwo;
- + }
- +
- + public int setItemOne() {
- + return _itemOne;
- + }
- +
- +
- +
- + public void setItemTwo(int itemtwo) {
- + _itemTwo = itemtwo;
- + }
- +
- + public void setItemOne(int itemone) {
- + _itemOne = itemone;
- + }
- +
- + public int getCommission() {
- + return _commission;
- + }
- +
- + public void setCommission(int commission) {
- + _commission = commission;
- + }
- +
- + public float getChance() {
- + return _chance;
- + }
- +
- + public void setChance(float chance) {
- + _chance = chance;
- + }
- +
- + public String getIconOne()
- + {
- + return getItem().getIcon(_itemOne);
- + }
- +
- + public Item getItem()
- + {
- + return ItemTable.getInstance().getTemplate(_itemOne);
- + }
- +
- + public String getIconTwo()
- + {
- + return getItem2().getIcon(_itemTwo);
- + }
- +
- + public Item getItem2()
- + {
- + return ItemTable.getInstance().getTemplate(_itemTwo);
- + }
- +
- +
- + public void addReward(CombinationItemReward item) {
- + _rewards.put(item.getType(), item);
- + }
- +
- + public CombinationItemReward getReward(CombinationItemType type) {
- + return _rewards.get(type);
- + }
- +}
- diff --git java/Base/Combination/CombinationItemReward.java java/Base/Combination/CombinationItemReward.java
- new file mode 100644
- index 0000000..925121e
- --- /dev/null
- +++ java/Base/Combination/CombinationItemReward.java
- @@ -0,0 +1,23 @@
- +
- +package Base.Combination;
- +
- +import Base.Holder.ItemHolder;
- +
- +/**
- + * @author UnAfraid
- + */
- +public class CombinationItemReward extends ItemHolder
- +{
- + private final CombinationItemType _type;
- +
- + public CombinationItemReward(int id, int count, CombinationItemType type)
- + {
- + super(id, count);
- + _type = type;
- + }
- +
- + public CombinationItemType getType()
- + {
- + return _type;
- + }
- +}
- diff --git java/Base/Combination/CombinationItemType.java java/Base/Combination/CombinationItemType.java
- new file mode 100644
- index 0000000..d6c6e89
- --- /dev/null
- +++ java/Base/Combination/CombinationItemType.java
- @@ -0,0 +1,11 @@
- +
- +package Base.Combination;
- +
- +/**
- + * @author UnAfraid
- + */
- +public enum CombinationItemType
- +{
- + ON_SUCCESS,
- + ON_FAILURE;
- +}
- diff --git java/Base/Combination/XML/CombinationItemsData.java java/Base/Combination/XML/CombinationItemsData.java
- new file mode 100644
- index 0000000..5e437ab
- --- /dev/null
- +++ java/Base/Combination/XML/CombinationItemsData.java
- @@ -0,0 +1,100 @@
- +package Base.Combination.XML;
- +
- +import java.io.File;
- +import java.util.ArrayList;
- +import java.util.List;
- +import java.util.logging.Logger;
- +
- +
- +
- +import net.sf.l2j.gameserver.data.ItemTable;
- +import org.w3c.dom.Document;
- +import org.w3c.dom.NamedNodeMap;
- +import org.w3c.dom.Node;
- +
- +import Base.Combination.CombinationItem;
- +import Base.Combination.CombinationItemReward;
- +import Base.Combination.CombinationItemType;
- +import Base.Data.XMLDocument;
- +
- +
- +
- +public class CombinationItemsData extends XMLDocument {
- + private static final Logger LOGGER = Logger.getLogger(CombinationItemsData.class.getName());
- + private final List<CombinationItem> _items;
- +
- + protected CombinationItemsData() {
- + _items = new ArrayList<>();
- + load();
- + }
- +
- +
- + public void reload()
- + {
- + _items.clear();
- + load();
- + }
- +
- + @Override
- + protected void load() {
- + loadDocument("data/xml/CombinationItems.xml");
- + LOGGER.info(getClass().getSimpleName() + ": Loaded " + _items.size() + " combinations.");
- + }
- +
- + @Override
- + protected void parseDocument(Document doc, File file) {
- + final Node listNode = doc.getFirstChild();
- + for (Node itemNode = listNode.getFirstChild(); itemNode != null; itemNode = itemNode.getNextSibling()) {
- + if (!"item".equalsIgnoreCase(itemNode.getNodeName())) {
- + continue;
- + }
- +
- + NamedNodeMap attrs = itemNode.getAttributes();
- + int one = Integer.parseInt(attrs.getNamedItem("one").getNodeValue());
- + int two = Integer.parseInt(attrs.getNamedItem("two").getNodeValue());
- + int commission = Integer.parseInt(attrs.getNamedItem("commission").getNodeValue());
- + int chance = Integer.parseInt(attrs.getNamedItem("chance").getNodeValue());
- +
- + CombinationItem item = new CombinationItem(one, two, commission, chance);
- +
- +
- +
- + for (Node rewardNode = itemNode.getFirstChild(); rewardNode != null; rewardNode = rewardNode.getNextSibling()) {
- + if (!"reward".equalsIgnoreCase(rewardNode.getNodeName())) {
- + continue;
- + }
- +
- + NamedNodeMap rewardAttrs = rewardNode.getAttributes();
- + int id = Integer.parseInt(rewardAttrs.getNamedItem("id").getNodeValue());
- + int count = Integer.parseInt(rewardAttrs.getNamedItem("count").getNodeValue());
- + CombinationItemType type = CombinationItemType.valueOf(rewardAttrs.getNamedItem("type").getNodeValue());
- +
- + CombinationItemReward reward = new CombinationItemReward(id, count, type);
- + item.addReward(reward);
- +
- + if (ItemTable.getInstance().getTemplate(id) == null) {
- + LOGGER.info(getClass().getSimpleName() + ": Could not find item with id " + id);
- + }
- + }
- +
- + _items.add(item);
- + }
- + }
- +
- + public int getLoadedElementsCount() {
- + return _items.size();
- + }
- +
- + public List<CombinationItem> getItems() {
- + return _items;
- + }
- +
- +
- + public static final CombinationItemsData getInstance() {
- + return SingletonHolder.INSTANCE;
- + }
- +
- + private static class SingletonHolder {
- + protected static final CombinationItemsData INSTANCE = new CombinationItemsData();
- + }
- +}
- diff --git java/Base/Data/XMLDocument.java java/Base/Data/XMLDocument.java
- new file mode 100644
- index 0000000..175b1ca
- --- /dev/null
- +++ java/Base/Data/XMLDocument.java
- @@ -0,0 +1,121 @@
- +package Base.Data;
- +
- +
- +
- +import java.io.File;
- +import java.util.logging.Level;
- +import java.util.logging.Logger;
- +
- +import javax.xml.parsers.DocumentBuilderFactory;
- +import javax.xml.transform.OutputKeys;
- +import javax.xml.transform.Transformer;
- +import javax.xml.transform.TransformerException;
- +import javax.xml.transform.TransformerFactory;
- +import javax.xml.transform.dom.DOMSource;
- +import javax.xml.transform.stream.StreamResult;
- +
- +import net.sf.l2j.gameserver.templates.StatsSet;
- +
- +import org.w3c.dom.Document;
- +import org.w3c.dom.NamedNodeMap;
- +import org.w3c.dom.Node;
- +
- +/**
- + * An XML document, relying on a static and single DocumentBuilderFactory.
- + */
- +public abstract class XMLDocument
- +{
- + protected static final Logger LOG = Logger.getLogger(XMLDocument.class.getName());
- +
- + protected Document document;
- +
- + private static final DocumentBuilderFactory BUILDER;
- + static
- + {
- + BUILDER = DocumentBuilderFactory.newInstance();
- + BUILDER.setValidating(false);
- + BUILDER.setIgnoringComments(true);
- + }
- +
- + abstract protected void load();
- +
- + abstract protected void parseDocument(Document doc, File f);
- +
- + public void loadDocument(String filePath)
- + {
- + loadDocument(new File(filePath));
- + }
- +
- + public void writeDocument(Document doc, String fileName)
- + {
- + try
- + {
- + TransformerFactory transformerFactory = TransformerFactory.newInstance();
- + Transformer transformer = transformerFactory.newTransformer();
- + transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
- + transformer.setOutputProperty(OutputKeys.INDENT, "yes");
- + transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
- +
- + DOMSource source = new DOMSource(doc);
- + StreamResult result = new StreamResult(new File(fileName));
- +
- + transformer.transform(source, result);
- + LOG.info("XML file saved to " + fileName);
- + }
- + catch (TransformerException e)
- + {
- + LOG.warning("Error saving XML file: " + e.getMessage());
- + }
- + }
- +
- + /**
- + * Parse an entire directory or file if found.
- + * @param file
- + */
- + public void loadDocument(File file)
- + {
- + if (!file.exists())
- + {
- + LOG.severe("The following file or directory doesn't exist: " + file.getName());
- + return;
- + }
- +
- + if (file.isDirectory())
- + {
- + for (File f : file.listFiles())
- + {
- + loadDocument(f);
- + }
- + }
- + else if (file.isFile())
- + {
- + try
- + {
- + parseDocument(BUILDER.newDocumentBuilder().parse(file), file);
- + }
- + catch (Exception e)
- + {
- + LOG.log(Level.SEVERE, "Error loading XML file " + file.getName(), e);
- + }
- + }
- + }
- +
- + public Document getDocument()
- + {
- + return document;
- + }
- +
- + /**
- + * This method parses the content of a NamedNodeMap and feed the given StatsSet.
- + * @param attrs : The NamedNodeMap to parse.
- + * @param set : The StatsSet to feed.
- + */
- + public static void parseAndFeed(NamedNodeMap attrs, StatsSet set)
- + {
- + for (int i = 0; i < attrs.getLength(); i++)
- + {
- + final Node attr = attrs.item(i);
- + set.set(attr.getNodeName(), attr.getNodeValue());
- + }
- + }
- +}
- diff --git java/Base/Dolls/Doll.java java/Base/Dolls/Doll.java
- new file mode 100644
- index 0000000..7f9f136
- --- /dev/null
- +++ java/Base/Dolls/Doll.java
- @@ -0,0 +1,25 @@
- +package Base.Dolls;
- +
- +public class Doll {
- + private int id;
- + private int skillId;
- + private int skillLvl;
- +
- + public Doll(int id, int skillId, int skillLvl) {
- + this.id = id;
- + this.skillId = skillId;
- + this.skillLvl = skillLvl;
- + }
- +
- + public int getId() {
- + return id;
- + }
- +
- + public int getSkillId() {
- + return skillId;
- + }
- +
- + public int getSkillLvl() {
- + return skillLvl;
- + }
- +}
- diff --git java/Base/Dolls/DollsData.java java/Base/Dolls/DollsData.java
- new file mode 100644
- index 0000000..f3fc971
- --- /dev/null
- +++ java/Base/Dolls/DollsData.java
- @@ -0,0 +1,71 @@
- +package Base.Dolls;
- +
- +import java.io.File;
- +import java.util.HashMap;
- +import java.util.Map;
- +
- +import org.w3c.dom.Document;
- +import org.w3c.dom.NamedNodeMap;
- +import org.w3c.dom.Node;
- +
- +import Base.Data.XMLDocument;
- +
- +public class DollsData extends XMLDocument {
- + private Map<Integer, Doll> dolls;
- +
- + public DollsData() {
- + dolls = new HashMap<>();
- + load();
- + }
- +
- + public void reload() {
- + dolls.clear();
- + load();
- + }
- +
- + public static DollsData getInstance() {
- + return SingletonHolder.INSTANCE;
- + }
- +
- + private static class SingletonHolder {
- + protected static final DollsData INSTANCE = new DollsData();
- + }
- +
- + @Override
- + protected void load() {
- + loadDocument("./data/xml/Dolls.xml");
- + LOG.info("DollsData: Loaded " + dolls.size() + " dolls.");
- + }
- +
- + @Override
- + protected void parseDocument(Document doc, File file) {
- + try {
- + final Node root = doc.getFirstChild();
- +
- + for (Node node = root.getFirstChild(); node != null; node = node.getNextSibling()) {
- + if (!"Doll".equalsIgnoreCase(node.getNodeName())) {
- + continue;
- + }
- +
- + NamedNodeMap attrs = node.getAttributes();
- + int id = Integer.parseInt(attrs.getNamedItem("Id").getNodeValue());
- + int skillId = Integer.parseInt(attrs.getNamedItem("SkillId").getNodeValue());
- + int skillLvl = Integer.parseInt(attrs.getNamedItem("SkillLvl").getNodeValue());
- +
- + Doll doll = new Doll(id, skillId, skillLvl);
- + dolls.put(id, doll);
- + }
- + } catch (Exception e) {
- + // LOG.warning("DollsData: Error while loading dolls: " + e);
- + e.printStackTrace();
- + }
- + }
- +
- + public Map<Integer, Doll> getDolls() {
- + return dolls;
- + }
- +
- + public Doll getDollById(int id) {
- + return dolls.get(id);
- + }
- +}
- diff --git java/Base/Holder/IIdentifiable.java java/Base/Holder/IIdentifiable.java
- new file mode 100644
- index 0000000..cce0784
- --- /dev/null
- +++ java/Base/Holder/IIdentifiable.java
- @@ -0,0 +1,26 @@
- +/*
- + * 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 Base.Holder;
- +
- +/**
- + * Identifiable objects interface.
- + * @author Zoey76
- + */
- +public interface IIdentifiable
- +{
- + int getId();
- +}
- diff --git java/Base/Holder/ItemHolder.java java/Base/Holder/ItemHolder.java
- new file mode 100644
- index 0000000..856d735
- --- /dev/null
- +++ java/Base/Holder/ItemHolder.java
- @@ -0,0 +1,79 @@
- +/*
- + * 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 Base.Holder;
- +
- +import net.sf.l2j.gameserver.templates.StatsSet;
- +
- +/**
- + * A simple DTO for items; contains item ID and count.
- + * @author UnAfraid
- + */
- +public class ItemHolder implements IIdentifiable
- +{
- + private final int _id;
- + private final int _count;
- +
- + public ItemHolder(StatsSet set)
- + {
- + _id = set.getInteger("id");
- + _count = set.getInteger("count");
- + }
- +
- + public ItemHolder(int id, int count)
- + {
- + _id = id;
- + _count = count;
- + }
- +
- + /**
- + * @return the ID of the item contained in this object
- + */
- + @Override
- + public int getId()
- + {
- + return _id;
- + }
- +
- + /**
- + * @return the count of items contained in this object
- + */
- + public int getCount()
- + {
- + return _count;
- + }
- +
- + @Override
- + public boolean equals(Object obj)
- + {
- + if (!(obj instanceof ItemHolder))
- + {
- + return false;
- + }
- + else if (obj == this)
- + {
- + return true;
- + }
- + final ItemHolder objInstance = (ItemHolder) obj;
- + return (_id == objInstance.getId()) && (_count == objInstance.getCount());
- + }
- +
- + @Override
- + public String toString()
- + {
- + return "[" + getClass().getSimpleName() + "] ID: " + _id + ", count: " + _count;
- + }
- +}
- diff --git java/net/sf/l2j/gameserver/GameServer.java java/net/sf/l2j/gameserver/GameServer.java
- index 900b58f..8aa847e 100644
- --- java/net/sf/l2j/gameserver/GameServer.java
- +++ java/net/sf/l2j/gameserver/GameServer.java
- @@ -142,6 +142,7 @@
- import net.sf.l2j.gameserver.scripting.ScriptManager;
- import net.sf.l2j.gameserver.taskmanager.AttackStanceTaskManager;
- import net.sf.l2j.gameserver.taskmanager.DecayTaskManager;
- +//import net.sf.l2j.gameserver.taskmanager.DollsTaskManager;
- import net.sf.l2j.gameserver.taskmanager.GameTimeTaskManager;
- import net.sf.l2j.gameserver.taskmanager.ItemsOnGroundTaskManager;
- import net.sf.l2j.gameserver.taskmanager.MovementTaskManager;
- @@ -154,6 +155,8 @@
- import net.sf.l2j.util.IPv4Filter;
- import net.sf.l2j.util.Util;
- +import Base.Combination.XML.CombinationItemsData;
- +import Base.Dolls.DollsData;
- import phantom.PhantomNameManager;
- import phantom.PhantomTitleManager;
- import phantom.PhantomTownAnao;
- @@ -567,6 +571,13 @@
- LOGGER.info("Loaded {} voiced command handlers.", +VoicedCommandHandler.getInstance().size());
- LOGGER.info("Loaded {} bypass command handlers.", +BypassHandler.getInstance().size());
- +
- + StringUtil.printSection("Combine Terius");
- + CombinationItemsData.getInstance();
- +
- + StringUtil.printSection("Dolls Manager - Terius");
- + DollsData.getInstance();
- +
- StringUtil.printSection("Server Work");
- ServerWork.getInstance().StartReset();
- ServerWork.getInstance().loadServer();
- diff --git java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminAdmin.java java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminAdmin.java
- index 25ab0dc..6829ba3 100644
- --- java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminAdmin.java
- +++ java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminAdmin.java
- @@ -39,6 +39,9 @@
- import net.sf.l2j.gameserver.network.SystemMessageId;
- import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
- +
- +import Base.Combination.XML.CombinationItemsData;
- +import Base.Dolls.DollsData;
- import phantom.PhantomNameManager;
- import phantom.PhantomTitleManager;
- import phantom.PhantomTownAnao;
- @@ -220,6 +223,18 @@
- CrestCache.getInstance().reload();
- activeChar.sendMessage("Crests have been reloaded.");
- }
- +
- + else if (type.startsWith("combine"))
- + {
- + CombinationItemsData.getInstance().reload();
- + activeChar.sendMessage("Combine have been reloaded.");
- + }
- +
- + else if (type.startsWith("dolls"))
- + {
- + DollsData.getInstance().reload();
- + activeChar.sendMessage("Dolls have been reloaded.");
- + }
- else if (type.startsWith("cw"))
- {
- CursedWeaponsManager.getInstance().reload();
- diff --git java/net/sf/l2j/gameserver/model/actor/instance/CombineItem.java java/net/sf/l2j/gameserver/model/actor/instance/CombineItem.java
- new file mode 100644
- index 0000000..d75ceb7
- --- /dev/null
- +++ java/net/sf/l2j/gameserver/model/actor/instance/CombineItem.java
- @@ -0,0 +1,219 @@
- +package net.sf.l2j.gameserver.model.actor.instance;
- +
- +import net.sf.l2j.gameserver.data.ItemTable;
- +import net.sf.l2j.gameserver.model.actor.Npc;
- +import net.sf.l2j.gameserver.model.actor.ai.CtrlIntention;
- +import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
- +import net.sf.l2j.gameserver.model.item.instance.ItemInstance;
- +import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
- +import net.sf.l2j.gameserver.network.serverpackets.MoveToPawn;
- +import net.sf.l2j.gameserver.network.serverpackets.MyTargetSelected;
- +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
- +import net.sf.l2j.gameserver.network.serverpackets.ValidateLocation;
- +
- +import Base.Combination.CombinationItem;
- +import Base.Combination.CombinationItemReward;
- +import Base.Combination.CombinationItemType;
- +import Base.Combination.XML.CombinationItemsData;
- +
- +import java.util.Set;
- +
- +public class CombineItem extends Npc {
- + private CombinationItemsData combinationItemsData;
- +
- + public CombineItem(int objectId, NpcTemplate template) {
- + super(objectId, template);
- + combinationItemsData = CombinationItemsData.getInstance();
- + }
- +
- + @Override
- + public void onAction(Player player) {
- + if (this != player.getTarget()) {
- + player.setTarget(this);
- + player.sendPacket(new MyTargetSelected(getObjectId(), 0));
- + player.sendPacket(new ValidateLocation(this));
- + } else {
- + if (!canInteract(player)) {
- + player.getAI().setIntention(CtrlIntention.INTERACT, this);
- + } else {
- + player.sendPacket(new MoveToPawn(player, this, Npc.INTERACTION_DISTANCE));
- +
- + if (hasRandomAnimation()) {
- + onRandomAnimation(1);
- + }
- +
- + showCombineWindow(player);
- +
- + player.sendPacket(ActionFailed.STATIC_PACKET);
- + }
- + }
- + }
- +
- + @Override
- + public void onBypassFeedback(Player player, String command) {
- + if (command.startsWith("combine")) {
- + String[] params = command.split(" ");
- + if (params.length == 3) {
- + int itemOneId = Integer.parseInt(params[1]);
- + int itemTwoId = Integer.parseInt(params[2]);
- +
- + CombinationItem combination = combinationItemsData.getItems().stream()
- + .filter(item -> item.getItemOne() == itemOneId && item.getItemTwo() == itemTwoId)
- + .findFirst()
- + .orElse(null);
- +
- + if (combination != null) {
- + Set<ItemInstance> playerItems = player.getInventory().getItems();
- +
- + boolean hasItemOne = playerItems.stream().anyMatch(item -> item.getItemId() == itemOneId);
- + boolean hasItemTwo = playerItems.stream().anyMatch(item -> item.getItemId() == itemTwoId);
- +
- + if (hasItemOne && hasItemTwo && player.getAdena() >= combination.getCommission()) {
- + // Verificar si la combinación tiene éxito según la probabilidad
- + double chance = Math.random() * 100; // Generar un número aleatorio entre 0 y 100
- + if (chance <= combination.getChance()) {
- + // La combinación tuvo éxito
- + // Quitar los items y la comisión del jugador
- + player.destroyItemByItemId("CombineItem", itemOneId, 1, null, true);
- + player.destroyItemByItemId("CombineItem", itemTwoId, 1, null, true);
- + player.reduceAdena("CombineItem", combination.getCommission(), this, true);
- +
- + // Otorgar las recompensas correspondientes al jugador
- + CombinationItemReward successReward = combination.getReward(CombinationItemType.ON_SUCCESS);
- +
- + if (successReward != null) {
- + // Otorgar la recompensa por éxito
- + int successRewardItemId = successReward.getId();
- + int successRewardCount = successReward.getCount();
- +
- + player.addItem(command, successRewardItemId, successRewardCount, player, true);
- + // Implementa la lógica para dar el item de éxito al jugador
- +
- +
- + // Implementa la lógica para dar el item de fallo al jugador
- + }
- +
- +
- + // Mostrar mensaje de éxito al jugador
- + player.sendMessage("¡La combinación fue exitosa!");
- +
- + } else {
- + // La combinación falló
- + // Quitar la comisión del jugador
- +
- + player.destroyItemByItemId("CombineItem", itemOneId, 1, null, true);
- + player.destroyItemByItemId("CombineItem", itemTwoId, 1, null, true);
- + player.reduceAdena("CombineItem", combination.getCommission(), this, true);
- +
- + // Mostrar mensaje de fallo al jugador
- + player.sendMessage("¡La combinación falló!");
- +
- + // Otorgar las recompensas correspondientes al jugador por fallo
- + CombinationItemReward failureReward = combination.getReward(CombinationItemType.ON_FAILURE);
- + if (failureReward != null) {
- +
- + int failureRewardItemId = failureReward.getId();
- + int failureRewardCount = failureReward.getCount();
- + player.addItem(command, failureRewardItemId, failureRewardCount, player, true);
- + }
- + }
- + }
- +
- + }
- +
- + }
- + } else {
- + super.onBypassFeedback(player, command);
- + }
- + }
- +
- + private void showCombineWindow(Player player) {
- + StringBuilder html = new StringBuilder();
- + html.append("<html><body>");
- + html.append("<center>Bienvenido a Combine System!</center>");
- + html.append("<br>");
- + html.append("<center>Podrás combinar 2 items para obtener un nivel superior.</center>");
- + html.append("<br>");
- + html.append("<center>Les deseo mucha suerte</center>");
- + html.append("<br>");
- + html.append("<br>");
- +
- + Set<ItemInstance> playerItems = player.getInventory().getItems();
- + int combinationCount = 0; // Contador de combinaciones mostradas
- + for (CombinationItem combination : combinationItemsData.getItems()) {
- + int itemOne = combination.getItemOne();
- + int itemTwo = combination.getItemTwo();
- +
- + String itemOneName = ItemTable.getInstance().getTemplate(itemOne).getName();
- + String itemTwoName = ItemTable.getInstance().getTemplate(itemTwo).getName();
- +
- + boolean isSameItem = itemOne == itemTwo;
- + boolean hasItems = false;
- +
- + if (isSameItem) {
- + long countItems = playerItems.stream()
- + .filter(item -> item != null && item.getItemId() == itemOne)
- + .count();
- + hasItems = countItems >= 2;
- + } else {
- + boolean hasItemOne = playerItems.stream()
- + .anyMatch(item -> item != null && item.getItemId() == itemOne);
- + boolean hasItemTwo = playerItems.stream()
- + .anyMatch(item -> item != null && item.getItemId() == itemTwo);
- + hasItems = hasItemOne && hasItemTwo;
- + }
- +
- + if (hasItems || (isSameItem && playerItems.stream().anyMatch(item -> item != null && item.getItemId() == itemOne && item.getCount() >= 2))) {
- + html.append("<img src=\"L2UI.SquareGray\" width=295 height=1>");
- + html.append("<center>");
- + html.append("<table>");
- + html.append("<tr>");
- +
- + // Combinación de iconos
- + html.append("<td><button action=\"bypass -h npc_").append(getObjectId()).append("_combine ")
- + .append(itemOne).append(" ").append(itemTwo).append("\" width=32 height=32 back=\"icon.skill0000\" fore=\"")
- + .append(combination.getIconOne()).append("\"></td>");
- +
- + html.append("<td width=30></td>");
- +
- + html.append("<td><button action=\"bypass -h npc_").append(getObjectId()).append("_combine ")
- + .append(itemOne).append(" ").append(itemTwo).append("\" width=32 height=32 back=\"icon.skill0000\" fore=\"")
- + .append(combination.getIconTwo()).append("\"></td>");
- +
- + html.append("</tr>");
- + html.append("</table>");
- + html.append("</center>");
- + html.append("<img src=\"L2UI.SquareGray\" width=295 height=1>");
- + html.append("<br>");
- + html.append("<br>");
- + html.append("<br>");
- +
- + combinationCount++; // Incrementar el contador de combinaciones mostradas
- +
- + if (combinationCount >= 5) {
- + break; // Detener el bucle si se han mostrado 5 combinaciones
- + }
- +
- + }
- + }
- +
- + html.append("<br>");
- + html.append("<br>");
- + html.append("</body></html>");
- +
- + if (html.length() == 0) {
- + player.sendMessage("No tienes items para combinar.");
- + } else {
- + showHtmlWindow(player, html.toString());
- + }
- + }
- +
- +
- +
- + private void showHtmlWindow(Player player, String htmlContent) {
- + NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
- + html.setHtml(htmlContent);
- +
- + player.sendPacket(html);
- + }
- +}
- diff --git java/net/sf/l2j/gameserver/model/actor/instance/Player.java java/net/sf/l2j/gameserver/model/actor/instance/Player.java
- index 74f78d8..b200372 100644
- --- java/net/sf/l2j/gameserver/model/actor/instance/Player.java
- +++ java/net/sf/l2j/gameserver/model/actor/instance/Player.java
- @@ -266,6 +266,7 @@
- import net.sf.l2j.gameserver.skills.l2skills.L2SkillSiegeFlag;
- import net.sf.l2j.gameserver.skills.l2skills.L2SkillSummon;
- import net.sf.l2j.gameserver.taskmanager.AttackStanceTaskManager;
- +//import net.sf.l2j.gameserver.taskmanager.DollsTaskManager;
- import net.sf.l2j.gameserver.taskmanager.GameTimeTaskManager;
- import net.sf.l2j.gameserver.taskmanager.ItemsOnGroundTaskManager;
- import net.sf.l2j.gameserver.taskmanager.PvpFlagTaskManager;
- @@ -280,6 +281,8 @@
- import net.sf.l2j.gameserver.util.variables.sub.PlayerVariables;
- import net.sf.l2j.util.CloseUtil;
- +import Base.Dolls.Doll;
- +import Base.Dolls.DollsData;
- import phantom.PhantomTownMage;
- import phantom.Phantom_Archers;
- import phantom.Phantom_Attack;
- @@ -2881,6 +2884,39 @@
- ItemInstance item = _inventory.getItemByItemId(itemId);
- +
- +
- + DollsData dollsData = DollsData.getInstance();
- + Map<Integer, Doll> dolls = dollsData.getDolls();
- +
- + for (Doll doll : dolls.values())
- + {
- + if (item.getItemId() == doll.getId())
- + {
- + int skillId = doll.getSkillId();
- + int skillLvl = doll.getSkillLvl();
- +
- + L2Skill skill = SkillTable.getInstance().getInfo(skillId, skillLvl);
- + if (skill != null)
- + {
- + removeSkill(skill.getId(), true);
- + sendSkillList();
- + }
- + }
- + }
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- if (item == null || item.getCount() < count || _inventory.destroyItemByItemId(process, itemId, count, this, reference) == null)
- {
- if (sendMessage)
- @@ -8632,6 +8668,12 @@
- }
- }
- +
- +
- +
- +
- +
- +
- /**
- * Cancel autoshot use for shot itemId
- * @param itemId int id to disable
- @@ -8663,6 +8705,18 @@
- _activeSoulShots.clear();
- }
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- class LookingForFishTask implements Runnable
- {
- boolean _isNoob, _isUpperGrade;
- @@ -9493,6 +9547,13 @@
- public void removeItens()
- {
- +
- +
- +
- +
- +
- +
- +
- // Remove Item TATO
- if (Config.REMOVE_CHEST)
- {
- @@ -9833,25 +9894,39 @@
- if (Config.ALT_RESTORE_EFFECTS_ON_SUBCLASS_CHANGE)
- restoreEffects();
- - // Reload Inventory with runa items
- - for (ItemInstance item : getInventory().getItems())
- - {
- - if (item == null)
- - continue;
- -
- - for (Entry<Integer, Integer> itemSkill : Config.LIST_RUNE_ITEMS.entrySet())
- - {
- - if (item.getItemId() == itemSkill.getKey())
- - {
- - L2Skill skill = SkillTable.getInstance().getInfo(itemSkill.getValue(), 1);
- - if (skill != null)
- - {
- - addSkill(skill, false);
- - sendSkillList();
- - }
- - }
- - }
- +
- + DollsData dollsData = DollsData.getInstance();
- + Map<Integer, Doll> dolls = dollsData.getDolls();
- +
- + for (ItemInstance item : getInventory().getItems()) {
- + if (item == null)
- + continue;
- +
- + Doll doll = dolls.get(item.getItemId());
- + if (doll != null) {
- + int skillId = doll.getSkillId();
- + int skillLvl = doll.getSkillLvl();
- +
- + boolean hasHigherLevelSkill = false;
- +
- + // Verificar si el jugador ya tiene un skill con nivel más alto
- + for (L2Skill existingSkill : getSkills().values()) {
- + if (existingSkill.getId() == skillId && existingSkill.getLevel() > skillLvl) {
- + hasHigherLevelSkill = true;
- + break;
- + }
- + }
- +
- + if (!hasHigherLevelSkill) {
- + L2Skill skill = SkillTable.getInstance().getInfo(skillId, skillLvl);
- + if (skill != null) {
- + addSkill(skill);
- + sendSkillList();
- + }
- + }
- + }
- }
- +
- updateEffectIcons();
- sendPacket(new EtcStatusUpdate(this));
- diff --git java/net/sf/l2j/gameserver/model/itemcontainer/PcInventory.java java/net/sf/l2j/gameserver/model/itemcontainer/PcInventory.java
- index fff736e..3359dcf 100644
- --- java/net/sf/l2j/gameserver/model/itemcontainer/PcInventory.java
- +++ java/net/sf/l2j/gameserver/model/itemcontainer/PcInventory.java
- @@ -5,6 +5,7 @@
- import java.sql.ResultSet;
- import java.util.ArrayList;
- import java.util.List;
- +import java.util.Map;
- import java.util.Map.Entry;
- import java.util.logging.Level;
- import java.util.stream.Collectors;
- @@ -25,8 +26,12 @@
- import net.sf.l2j.gameserver.model.tradelist.TradeList;
- import net.sf.l2j.gameserver.network.serverpackets.InventoryUpdate;
- import net.sf.l2j.gameserver.network.serverpackets.StatusUpdate;
- +//import net.sf.l2j.gameserver.taskmanager.DollsTaskManager;
- import net.sf.l2j.gameserver.taskmanager.ShadowItemTaskManager;
- +import Base.Dolls.Doll;
- +import Base.Dolls.DollsData;
- +
- public class PcInventory extends Inventory
- {
- public static final int ADENA_ID = 57;
- @@ -45,6 +50,7 @@
- addPaperdollListener(BowRodListener.getInstance());
- addPaperdollListener(ItemPassiveSkillsListener.getInstance());
- addPaperdollListener(ShadowItemTaskManager.getInstance());
- +
- }
- @Override
- @@ -402,17 +408,39 @@
- else if (item.getItemId() == ANCIENT_ADENA_ID && !item.equals(_ancientAdena))
- _ancientAdena = item;
- - for (Entry<Integer, Integer> itemSkill : Config.LIST_RUNE_ITEMS.entrySet())
- - {
- - if (item.getItemId() == itemSkill.getKey())
- - {
- - L2Skill skill = SkillTable.getInstance().getInfo(itemSkill.getValue(), 1); // 1 REFERENCIA AO LEVEL
- - if (skill != null)
- - {
- - actor.addSkill(skill, false);
- - actor.sendSkillList();
- - }
- - }
- + // Después de que un jugador reciba un item de la lista de runas
- + // DollsTaskManager.getInstance().addDollItem(actor, item);
- +
- +
- + DollsData dollsData = DollsData.getInstance();
- + for (ItemInstance item2 : actor.getInventory().getItems()) {
- + if (item2 == null) {
- + continue;
- + }
- +
- + Doll doll = dollsData.getDollById(item.getItemId());
- + if (doll != null) {
- + int skillId = doll.getSkillId();
- + int skillLvl = doll.getSkillLvl();
- +
- + boolean hasHigherLevelSkill = false;
- +
- + // Comprobar si el jugador ya tiene la skill con un nivel más alto
- + for (L2Skill playerSkill : actor.getSkills().values()) {
- + if (playerSkill.getId() == skillId && playerSkill.getLevel() > skillLvl) {
- + hasHigherLevelSkill = true;
- + break;
- + }
- + }
- +
- + if (!hasHigherLevelSkill) {
- + L2Skill skill = SkillTable.getInstance().getInfo(skillId, skillLvl);
- + if (skill != null) {
- + actor.addSkill(skill);
- + actor.sendSkillList();
- + }
- + }
- + }
- }
- return item;
- @@ -450,20 +478,76 @@
- StatusUpdate su = new StatusUpdate(actor);
- su.addAttribute(StatusUpdate.CUR_LOAD, actor.getCurrentLoad());
- actor.sendPacket(su);
- - }
- + DollsData dollsData = DollsData.getInstance();
- + for (ItemInstance item2 : actor.getInventory().getItems()) {
- + if (item2 == null) {
- + continue;
- + }
- - for (Entry<Integer, Integer> itemSkill : Config.LIST_RUNE_ITEMS.entrySet())
- - {
- - if (item.getItemId() == itemSkill.getKey())
- - {
- - L2Skill skill = SkillTable.getInstance().getInfo(itemSkill.getValue(), 1);
- - if (skill != null)
- - {
- - actor.addSkill(skill, false);
- - actor.sendSkillList();
- - }
- + Doll doll = dollsData.getDollById(item2.getItemId());
- + if (doll != null) {
- + int skillId = doll.getSkillId();
- + int skillLvl = doll.getSkillLvl();
- +
- + boolean hasHigherLevelSkill = false;
- +
- + // Comprobar si el jugador ya tiene la skill con un nivel más alto
- + for (L2Skill playerSkill : actor.getSkills().values()) {
- + if (playerSkill.getId() == skillId && playerSkill.getLevel() > skillLvl) {
- + hasHigherLevelSkill = true;
- + break;
- + }
- + }
- +
- + if (!hasHigherLevelSkill) {
- + L2Skill skill = SkillTable.getInstance().getInfo(skillId, skillLvl);
- + if (skill != null) {
- + if (actor.getSkillLevel(skillId) != skillLvl) {
- + actor.removeSkill(skill);
- + actor.sendSkillList();
- + }
- + }
- + }
- + }
- }
- +
- + // Comprobar si el actor tiene otros ítems con habilidades y otorgar las habilidades correspondientes
- + for (ItemInstance item3 : actor.getInventory().getItems()) {
- + Doll doll = dollsData.getDollById(item3.getItemId());
- + if (doll != null) {
- + int skillId = doll.getSkillId();
- + int skillLvl = doll.getSkillLvl();
- +
- + boolean hasHigherLevelSkill = false;
- +
- + // Verificar si el jugador ya tiene un skill con nivel más alto
- + for (L2Skill existingSkill : actor.getSkills().values()) {
- + if (existingSkill.getId() == skillId && existingSkill.getLevel() > skillLvl) {
- + hasHigherLevelSkill = true;
- + break;
- + }
- + }
- +
- + if (!hasHigherLevelSkill) {
- + L2Skill skill = SkillTable.getInstance().getInfo(skillId, skillLvl);
- + if (skill != null) {
- + if (actor.getSkillLevel(skillId) != skillLvl) {
- + actor.addSkill(skill);
- + actor.sendSkillList();
- + }
- + }
- + }
- + }
- + }
- +
- +
- +
- +
- }
- + // Después de que un jugador reciba un item de la lista de runas
- + // DollsTaskManager.getInstance().addDollItem(actor, item);
- +
- +
- return item;
- }
- @@ -482,6 +566,68 @@
- {
- ItemInstance item = super.transferItem(process, objectId, count, target, actor, reference);
- +
- + DollsData dollsData = DollsData.getInstance();
- + Map<Integer, Doll> dolls = dollsData.getDolls();
- +
- + boolean hasOtherItemsWithSkills = false; // Variable para indicar si el jugador tiene otros ítems con habilidades
- +
- + for (Doll doll : dolls.values()) {
- + if (item.getItemId() == doll.getId()) {
- + int skillId = doll.getSkillId();
- + int skillLvl = doll.getSkillLvl();
- +
- + L2Skill skill = SkillTable.getInstance().getInfo(skillId, skillLvl);
- + if (skill != null) {
- + if (actor.getSkillLevel(skillId) == skillLvl) {
- + actor.removeSkill(skill.getId(), true);
- + actor.sendSkillList();
- + }
- + }
- + }
- + }
- +
- + // Comprobar si el jugador tiene otros ítems con habilidades y otorgar las habilidades correspondientes
- + for (ItemInstance item2 : actor.getInventory().getItems()) {
- + for (Doll doll : dolls.values()) {
- + if (item2.getItemId() == doll.getId()) {
- + int skillId = doll.getSkillId();
- + int skillLvl = doll.getSkillLvl();
- +
- + L2Skill skill = SkillTable.getInstance().getInfo(skillId, skillLvl);
- + if (skill != null) {
- + if (actor.getSkillLevel(skillId) != skillLvl) {
- + actor.removeSkill(skill.getId(), false);
- + actor.addSkill(skill, false);
- + actor.sendSkillList();
- + }
- + hasOtherItemsWithSkills = true; // El jugador tiene otros ítems con habilidades
- + }
- + }
- + }
- + }
- +
- + // Si el jugador ya no tiene ningún otro item con habilidades, eliminar la habilidad correspondiente
- + if (!hasOtherItemsWithSkills) {
- + for (Doll doll : dolls.values()) {
- + if (item.getItemId() == doll.getId()) {
- + int skillId = doll.getSkillId();
- + int skillLvl = doll.getSkillLvl();
- +
- + L2Skill skill = SkillTable.getInstance().getInfo(skillId, skillLvl);
- + if (skill != null) {
- + if (actor.getSkillLevel(skillId) == skillLvl) {
- + actor.removeSkill(skill.getId(), false);
- + actor.sendSkillList();
- + }
- + }
- + }
- + }
- + }
- +
- +
- +
- +
- if (_adena != null && (_adena.getCount() <= 0 || _adena.getOwnerId() != getOwnerId()))
- _adena = null;
- @@ -518,6 +664,69 @@
- {
- item = super.destroyItem(process, item, count, actor, reference);
- +
- +
- + DollsData dollsData = DollsData.getInstance();
- + Map<Integer, Doll> dolls = dollsData.getDolls();
- +
- + boolean hasOtherItemsWithSkills = false; // Variable para indicar si el jugador tiene otros ítems con habilidades
- +
- + for (Doll doll : dolls.values()) {
- + if (item.getItemId() == doll.getId()) {
- + int skillId = doll.getSkillId();
- + int skillLvl = doll.getSkillLvl();
- +
- + L2Skill skill = SkillTable.getInstance().getInfo(skillId, skillLvl);
- + if (skill != null) {
- + if (actor.getSkillLevel(skillId) == skillLvl) {
- + actor.removeSkill(skill.getId(), true);
- + actor.sendSkillList();
- + }
- + }
- + }
- + }
- +
- + // Comprobar si el jugador tiene otros ítems con habilidades y otorgar las habilidades correspondientes
- + for (ItemInstance item2 : actor.getInventory().getItems()) {
- + for (Doll doll : dolls.values()) {
- + if (item2.getItemId() == doll.getId()) {
- + int skillId = doll.getSkillId();
- + int skillLvl = doll.getSkillLvl();
- +
- + L2Skill skill = SkillTable.getInstance().getInfo(skillId, skillLvl);
- + if (skill != null) {
- + if (actor.getSkillLevel(skillId) != skillLvl) {
- + actor.removeSkill(skill.getId(), false);
- + actor.addSkill(skill, false);
- + actor.sendSkillList();
- + }
- + hasOtherItemsWithSkills = true; // El jugador tiene otros ítems con habilidades
- + }
- + }
- + }
- + }
- +
- + // Si el jugador ya no tiene ningún otro item con habilidades, eliminar la habilidad correspondiente
- + if (!hasOtherItemsWithSkills) {
- + for (Doll doll : dolls.values()) {
- + if (item.getItemId() == doll.getId()) {
- + int skillId = doll.getSkillId();
- + int skillLvl = doll.getSkillLvl();
- +
- + L2Skill skill = SkillTable.getInstance().getInfo(skillId, skillLvl);
- + if (skill != null) {
- + if (actor.getSkillLevel(skillId) == skillLvl) {
- + actor.removeSkill(skill.getId(), false);
- + actor.sendSkillList();
- + }
- + }
- + }
- + }
- + }
- +
- +
- +
- +
- if (_adena != null && _adena.getCount() <= 0)
- _adena = null;
- @@ -540,9 +749,79 @@
- public ItemInstance destroyItem(String process, int objectId, int count, Player actor, WorldObject reference)
- {
- ItemInstance item = getItemByObjectId(objectId);
- +
- + DollsData dollsData = DollsData.getInstance();
- + Map<Integer, Doll> dolls = dollsData.getDolls();
- +
- + boolean hasOtherItemsWithSkills = false; // Variable para indicar si el jugador tiene otros ítems con habilidades
- +
- + for (Doll doll : dolls.values()) {
- + if (item.getItemId() == doll.getId()) {
- + int skillId = doll.getSkillId();
- + int skillLvl = doll.getSkillLvl();
- +
- + L2Skill skill = SkillTable.getInstance().getInfo(skillId, skillLvl);
- + if (skill != null) {
- + if (actor.getSkillLevel(skillId) == skillLvl) {
- + actor.removeSkill(skill.getId(), true);
- + actor.sendSkillList();
- + }
- + }
- + }
- + }
- +
- + // Comprobar si el jugador tiene otros ítems con habilidades y otorgar las habilidades correspondientes
- + for (ItemInstance item2 : actor.getInventory().getItems()) {
- + for (Doll doll : dolls.values()) {
- + if (item2.getItemId() == doll.getId()) {
- + int skillId = doll.getSkillId();
- + int skillLvl = doll.getSkillLvl();
- +
- + L2Skill skill = SkillTable.getInstance().getInfo(skillId, skillLvl);
- + if (skill != null) {
- + if (actor.getSkillLevel(skillId) != skillLvl) {
- + actor.removeSkill(skill.getId(), false);
- + actor.addSkill(skill, false);
- + actor.sendSkillList();
- + }
- + hasOtherItemsWithSkills = true; // El jugador tiene otros ítems con habilidades
- + }
- + }
- + }
- + }
- +
- + // Si el jugador ya no tiene ningún otro item con habilidades, eliminar la habilidad correspondiente
- + if (!hasOtherItemsWithSkills) {
- + for (Doll doll : dolls.values()) {
- + if (item.getItemId() == doll.getId()) {
- + int skillId = doll.getSkillId();
- + int skillLvl = doll.getSkillLvl();
- +
- + L2Skill skill = SkillTable.getInstance().getInfo(skillId, skillLvl);
- + if (skill != null) {
- + if (actor.getSkillLevel(skillId) == skillLvl) {
- + actor.removeSkill(skill.getId(), false);
- + actor.sendSkillList();
- + }
- + }
- + }
- + }
- + }
- +
- if (item == null)
- return null;
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- return this.destroyItem(process, item, count, actor, reference);
- }
- @@ -562,6 +841,68 @@
- if (item == null)
- return null;
- +
- + DollsData dollsData = DollsData.getInstance();
- + Map<Integer, Doll> dolls = dollsData.getDolls();
- +
- + boolean hasOtherItemsWithSkills = false; // Variable para indicar si el jugador tiene otros ítems con habilidades
- +
- + for (Doll doll : dolls.values()) {
- + if (item.getItemId() == doll.getId()) {
- + int skillId = doll.getSkillId();
- + int skillLvl = doll.getSkillLvl();
- +
- + L2Skill skill = SkillTable.getInstance().getInfo(skillId, skillLvl);
- + if (skill != null) {
- + if (actor.getSkillLevel(skillId) == skillLvl) {
- + actor.removeSkill(skill.getId(), true);
- + actor.sendSkillList();
- + }
- + }
- + }
- + }
- +
- + // Comprobar si el jugador tiene otros ítems con habilidades y otorgar las habilidades correspondientes
- + for (ItemInstance item2 : actor.getInventory().getItems()) {
- + for (Doll doll : dolls.values()) {
- + if (item2.getItemId() == doll.getId()) {
- + int skillId = doll.getSkillId();
- + int skillLvl = doll.getSkillLvl();
- +
- + L2Skill skill = SkillTable.getInstance().getInfo(skillId, skillLvl);
- + if (skill != null) {
- + if (actor.getSkillLevel(skillId) != skillLvl) {
- + actor.removeSkill(skill.getId(), false);
- + actor.addSkill(skill, false);
- + actor.sendSkillList();
- + }
- + hasOtherItemsWithSkills = true; // El jugador tiene otros ítems con habilidades
- + }
- + }
- + }
- + }
- +
- + // Si el jugador ya no tiene ningún otro item con habilidades, eliminar la habilidad correspondiente
- + if (!hasOtherItemsWithSkills) {
- + for (Doll doll : dolls.values()) {
- + if (item.getItemId() == doll.getId()) {
- + int skillId = doll.getSkillId();
- + int skillLvl = doll.getSkillLvl();
- +
- + L2Skill skill = SkillTable.getInstance().getInfo(skillId, skillLvl);
- + if (skill != null) {
- + if (actor.getSkillLevel(skillId) == skillLvl) {
- + actor.removeSkill(skill.getId(), false);
- + actor.sendSkillList();
- + }
- + }
- + }
- + }
- + }
- +
- +
- +
- +
- return this.destroyItem(process, item, count, actor, reference);
- }
- @@ -578,6 +919,67 @@
- {
- item = super.dropItem(process, item, actor, reference);
- + DollsData dollsData = DollsData.getInstance();
- + Map<Integer, Doll> dolls = dollsData.getDolls();
- +
- + boolean hasOtherItemsWithSkills = false; // Variable para indicar si el jugador tiene otros ítems con habilidades
- +
- + for (Doll doll : dolls.values()) {
- + if (item.getItemId() == doll.getId()) {
- + int skillId = doll.getSkillId();
- + int skillLvl = doll.getSkillLvl();
- +
- + L2Skill skill = SkillTable.getInstance().getInfo(skillId, skillLvl);
- + if (skill != null) {
- + if (actor.getSkillLevel(skillId) == skillLvl) {
- + actor.removeSkill(skill.getId(), true);
- + actor.sendSkillList();
- + }
- + }
- + }
- + }
- +
- + // Comprobar si el jugador tiene otros ítems con habilidades y otorgar las habilidades correspondientes
- + for (ItemInstance item2 : actor.getInventory().getItems()) {
- + for (Doll doll : dolls.values()) {
- + if (item2.getItemId() == doll.getId()) {
- + int skillId = doll.getSkillId();
- + int skillLvl = doll.getSkillLvl();
- +
- + L2Skill skill = SkillTable.getInstance().getInfo(skillId, skillLvl);
- + if (skill != null) {
- + if (actor.getSkillLevel(skillId) != skillLvl) {
- + actor.removeSkill(skill.getId(), false);
- + actor.addSkill(skill, false);
- + actor.sendSkillList();
- + }
- + hasOtherItemsWithSkills = true; // El jugador tiene otros ítems con habilidades
- + }
- + }
- + }
- + }
- +
- + // Si el jugador ya no tiene ningún otro item con habilidades, eliminar la habilidad correspondiente
- + if (!hasOtherItemsWithSkills) {
- + for (Doll doll : dolls.values()) {
- + if (item.getItemId() == doll.getId()) {
- + int skillId = doll.getSkillId();
- + int skillLvl = doll.getSkillLvl();
- +
- + L2Skill skill = SkillTable.getInstance().getInfo(skillId, skillLvl);
- + if (skill != null) {
- + if (actor.getSkillLevel(skillId) == skillLvl) {
- + actor.removeSkill(skill.getId(), false);
- + actor.sendSkillList();
- + }
- + }
- + }
- + }
- + }
- +
- +
- +
- +
- if (_adena != null && (_adena.getCount() <= 0 || _adena.getOwnerId() != getOwnerId()))
- _adena = null;
- @@ -601,6 +1003,66 @@
- {
- ItemInstance item = super.dropItem(process, objectId, count, actor, reference);
- +
- + DollsData dollsData = DollsData.getInstance();
- + Map<Integer, Doll> dolls = dollsData.getDolls();
- +
- + boolean hasOtherItemsWithSkills = false; // Variable para indicar si el jugador tiene otros ítems con habilidades
- +
- + for (Doll doll : dolls.values()) {
- + if (item.getItemId() == doll.getId()) {
- + int skillId = doll.getSkillId();
- + int skillLvl = doll.getSkillLvl();
- +
- + L2Skill skill = SkillTable.getInstance().getInfo(skillId, skillLvl);
- + if (skill != null) {
- + if (actor.getSkillLevel(skillId) == skillLvl) {
- + actor.removeSkill(skill.getId(), true);
- + actor.sendSkillList();
- + }
- + }
- + }
- + }
- +
- + // Comprobar si el jugador tiene otros ítems con habilidades y otorgar las habilidades correspondientes
- + for (ItemInstance item2 : actor.getInventory().getItems()) {
- + for (Doll doll : dolls.values()) {
- + if (item2.getItemId() == doll.getId()) {
- + int skillId = doll.getSkillId();
- + int skillLvl = doll.getSkillLvl();
- +
- + L2Skill skill = SkillTable.getInstance().getInfo(skillId, skillLvl);
- + if (skill != null) {
- + if (actor.getSkillLevel(skillId) != skillLvl) {
- + actor.removeSkill(skill.getId(), false);
- + actor.addSkill(skill, false);
- + actor.sendSkillList();
- + }
- + hasOtherItemsWithSkills = true; // El jugador tiene otros ítems con habilidades
- + }
- + }
- + }
- + }
- +
- + // Si el jugador ya no tiene ningún otro item con habilidades, eliminar la habilidad correspondiente
- + if (!hasOtherItemsWithSkills) {
- + for (Doll doll : dolls.values()) {
- + if (item.getItemId() == doll.getId()) {
- + int skillId = doll.getSkillId();
- + int skillLvl = doll.getSkillLvl();
- +
- + L2Skill skill = SkillTable.getInstance().getInfo(skillId, skillLvl);
- + if (skill != null) {
- + if (actor.getSkillLevel(skillId) == skillLvl) {
- + actor.removeSkill(skill.getId(), false);
- + actor.sendSkillList();
- + }
- + }
- + }
- + }
- + }
- +
- +
- if (_adena != null && (_adena.getCount() <= 0 || _adena.getOwnerId() != getOwnerId()))
- _adena = null;
- diff --git java/net/sf/l2j/gameserver/model/tradelist/TradeList.java java/net/sf/l2j/gameserver/model/tradelist/TradeList.java
- index e6fafc6..d5a8786 100644
- --- java/net/sf/l2j/gameserver/model/tradelist/TradeList.java
- +++ java/net/sf/l2j/gameserver/model/tradelist/TradeList.java
- @@ -2,6 +2,7 @@
- import java.util.ArrayList;
- import java.util.List;
- +import java.util.Map;
- import java.util.Map.Entry;
- import java.util.Set;
- import java.util.concurrent.CopyOnWriteArrayList;
- @@ -21,8 +22,12 @@
- import net.sf.l2j.gameserver.network.serverpackets.InventoryUpdate;
- import net.sf.l2j.gameserver.network.serverpackets.StatusUpdate;
- import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
- +//import net.sf.l2j.gameserver.taskmanager.DollsTaskManager;
- import net.sf.l2j.gameserver.util.TradeLog;
- +import Base.Dolls.Doll;
- +import Base.Dolls.DollsData;
- +
- public class TradeList
- {
- private final Player _owner;
- @@ -433,33 +438,75 @@
- else
- partnerIU.addNewItem(newItem);
- }
- +
- - for (Entry<Integer, Integer> itemSkill : Config.LIST_RUNE_ITEMS.entrySet())
- - {
- - if (oldItem.getItemId() == itemSkill.getKey())
- - {
- - L2Skill skill = SkillTable.getInstance().getInfo(itemSkill.getValue(), 1);
- - if (skill != null)
- - {
- - _owner.removeSkill(skill, false);
- - _owner.sendSkillList();
- - }
- - }
- + DollsData dollsData = DollsData.getInstance();
- + Map<Integer, Doll> dolls = dollsData.getDolls();
- +
- + for (Doll doll : dolls.values()) {
- + if (oldItem.getItemId() == doll.getId()) {
- + int skillId = doll.getSkillId();
- + int skillLvl = doll.getSkillLvl();
- +
- + L2Skill skill = SkillTable.getInstance().getInfo(skillId, skillLvl);
- + if (skill != null) {
- + if (_owner.getSkillLevel(skillId) == skillLvl) {
- + _owner.removeSkill(skill, false);
- + _owner.sendSkillList();
- + }
- + }
- + }
- +
- + if (newItem.getItemId() == doll.getId()) {
- + int skillId = doll.getSkillId();
- + int skillLvl = doll.getSkillLvl();
- +
- + boolean hasHigherLevelSkill = false;
- +
- + // Verificar si el jugador ya tiene un skill con nivel más alto
- + for (L2Skill existingSkill : _partner.getSkills().values()) {
- + if (existingSkill.getId() == skillId && existingSkill.getLevel() > skillLvl) {
- + hasHigherLevelSkill = true;
- + break;
- + }
- + }
- +
- + if (!hasHigherLevelSkill) {
- + L2Skill skill = SkillTable.getInstance().getInfo(skillId, skillLvl);
- + if (skill != null) {
- + if (_partner.getSkillLevel(skillId) != skillLvl) {
- + _partner.removeSkill(skill, false);
- + _partner.addSkill(skill, false);
- + _partner.sendSkillList();
- + }
- + }
- + }
- + }
- }
- -
- - for (Entry<Integer, Integer> itemSkill : Config.LIST_RUNE_ITEMS.entrySet())
- - {
- - if (newItem.getItemId() == itemSkill.getKey())
- - {
- - L2Skill skill = SkillTable.getInstance().getInfo(itemSkill.getValue(), 1);
- - if (skill != null)
- - {
- - _partner.addSkill(skill, false);
- - _partner.sendSkillList();
- - }
- - }
- +
- + // Comprobar si el _owner tiene otros ítems con habilidades y otorgar las habilidades correspondientes
- + for (ItemInstance item : _owner.getInventory().getItems()) {
- +
- + for (Doll doll : dolls.values()) {
- + if (item.getItemId() == doll.getId()) {
- + int skillId = doll.getSkillId();
- + int skillLvl = doll.getSkillLvl();
- +
- + L2Skill skill = SkillTable.getInstance().getInfo(skillId, skillLvl);
- + if (skill != null) {
- + if (_owner.getSkillLevel(skillId) != skillLvl) {
- + _owner.addSkill(skill, false);
- + _owner.sendSkillList();
- + }
- + }
- +
- + }
- + }
- }
- +
- +
- +
- TradeLog.Log(_owner.getName(), _partner.getName(), oldItem.getItemName(), oldItem.getEnchantLevel(), oldItem.getCount(), oldItem.getObjectId());
- TradeLog.Log(_partner.getName(), _owner.getName(), oldItem.getItemName(), oldItem.getEnchantLevel(), oldItem.getCount(), oldItem.getObjectId());
- diff --git java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
- index d8fffd4..6d8f82f 100644
- --- java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
- +++ java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
- @@ -6,6 +6,8 @@
- import java.sql.ResultSet;
- import java.text.SimpleDateFormat;
- import java.util.Date;
- +import java.util.HashMap;
- +import java.util.Map;
- import java.util.Map.Entry;
- import java.util.logging.Level;
- @@ -85,10 +87,14 @@
- import net.sf.l2j.gameserver.scripting.Quest;
- import net.sf.l2j.gameserver.scripting.QuestState;
- import net.sf.l2j.gameserver.scripting.ScriptManager;
- +//import net.sf.l2j.gameserver.taskmanager.DollsTaskManager;
- import net.sf.l2j.gameserver.taskmanager.GameTimeTaskManager;
- import net.sf.l2j.gameserver.util.HWID;
- import net.sf.l2j.gameserver.util.IPLog;
- +import Base.Dolls.Doll;
- +import Base.Dolls.DollsData;
- +
- public class EnterWorld extends L2GameClientPacket
- {
- long _daysleft;
- @@ -495,7 +501,8 @@
- VoicedDonate.showMainHtml(activeChar);
- }
- + onEnterRunaReload(activeChar);
- activeChar.setPlayer(true);
- activeChar.sendPacket(ActionFailed.STATIC_PACKET);
- @@ -665,14 +672,50 @@
- }
- - private void onEnterRunaReload(Player activeChar)
- + private static void onEnterRunaReload(Player activeChar) {
- + DollsData dollsData = DollsData.getInstance();
- + Map<Integer, Integer> skillLevels = new HashMap<>();
- +
- + for (ItemInstance item : activeChar.getInventory().getItems()) {
- + if (item == null) {
- + continue;
- + }
- +
- + Doll doll = dollsData.getDollById(item.getItemId());
- + if (doll != null) {
- + int skillId = doll.getSkillId();
- + int skillLvl = doll.getSkillLvl();
- +
- + // Priorizar siempre el nivel más alto de habilidad
- + if (!skillLevels.containsKey(skillId) || skillLvl > skillLevels.get(skillId)) {
- + skillLevels.put(skillId, skillLvl);
- + }
- + }
- + }
- +
- + for (Map.Entry<Integer, Integer> entry : skillLevels.entrySet()) {
- + int skillId = entry.getKey();
- + int skillLvl = entry.getValue();
- +
- + L2Skill skill = SkillTable.getInstance().getInfo(skillId, skillLvl);
- + if (skill != null) {
- + activeChar.addSkill(skill);
- + }
- + }
- +
- + activeChar.sendSkillList();
- + }
- +
- +
- +
- @Override
- protected boolean triggersOnActionRequest()
- diff --git java/net/sf/l2j/gameserver/network/clientpackets/RequestDestroyItem.java java/net/sf/l2j/gameserver/network/clientpackets/RequestDestroyItem.java
- index d9bd04b..7ad6442 100644
- --- java/net/sf/l2j/gameserver/network/clientpackets/RequestDestroyItem.java
- +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestDestroyItem.java
- @@ -2,6 +2,7 @@
- import java.sql.Connection;
- import java.sql.PreparedStatement;
- +import java.util.Map;
- import java.util.Map.Entry;
- import java.util.logging.Level;
- @@ -17,6 +18,10 @@
- import net.sf.l2j.gameserver.network.serverpackets.InventoryUpdate;
- import net.sf.l2j.gameserver.network.serverpackets.StatusUpdate;
- +import Base.Dolls.Doll;
- +import Base.Dolls.DollsData;
- +
- +
- public final class RequestDestroyItem extends L2GameClientPacket
- {
- private int _objectId;
- @@ -121,19 +126,63 @@
- _log.log(Level.WARNING, "could not delete pet objectid: ", e);
- }
- }
- +
- - for (Entry<Integer, Integer> itemSkill : Config.LIST_RUNE_ITEMS.entrySet())
- - {
- - if (itemToRemove.getItemId() == itemSkill.getKey())
- - {
- - L2Skill skill = SkillTable.getInstance().getInfo(itemSkill.getValue(), 1);
- - if (skill != null)
- - {
- - activeChar.removeSkill(skill, false);
- - activeChar.sendSkillList();
- - }
- - }
- + DollsData dollsData = DollsData.getInstance();
- + Map<Integer, Doll> dolls = dollsData.getDolls();
- +
- + for (Doll doll : dolls.values()) {
- + if (itemToRemove.getItemId() == doll.getId()) {
- + int skillId = doll.getSkillId();
- + int skillLvl = doll.getSkillLvl();
- +
- + boolean hasHigherLevelSkill = false;
- +
- + // Verificar si el jugador ya tiene un skill con nivel más alto
- + for (L2Skill existingSkill : activeChar.getSkills().values()) {
- + if (existingSkill.getId() == skillId && existingSkill.getLevel() > skillLvl) {
- + hasHigherLevelSkill = true;
- + break;
- + }
- + }
- +
- + if (!hasHigherLevelSkill) {
- + L2Skill skill = SkillTable.getInstance().getInfo(skillId, skillLvl);
- + if (skill != null) {
- + activeChar.removeSkill(skill);
- + activeChar.sendSkillList();
- + }
- + }
- + }
- }
- +
- + // Comprobar si el jugador tiene otros ítems con habilidades y otorgar las habilidades correspondientes
- + for (ItemInstance item : activeChar.getInventory().getItems()) {
- + Doll doll = dollsData.getDollById(item.getItemId());
- + if (doll != null) {
- + int skillId = doll.getSkillId();
- + int skillLvl = doll.getSkillLvl();
- +
- + boolean hasHigherLevelSkill = false;
- +
- + // Verificar si el jugador ya tiene un skill con nivel más alto
- + for (L2Skill existingSkill : activeChar.getSkills().values()) {
- + if (existingSkill.getId() == skillId && existingSkill.getLevel() > skillLvl) {
- + hasHigherLevelSkill = true;
- + break;
- + }
- + }
- +
- + if (!hasHigherLevelSkill) {
- + L2Skill skill = SkillTable.getInstance().getInfo(skillId, skillLvl);
- + if (skill != null) {
- + activeChar.addSkill(skill);
- + activeChar.sendSkillList();
- + }
- + }
- + }
- + }
- +
- ItemInstance removedItem = activeChar.getInventory().destroyItem("Destroy", _objectId, _count, activeChar, null);
- if (removedItem == null)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement