From 267f50a36b7611fdf312f419fb93d14485a6b1b7 Mon Sep 17 00:00:00 2001 From: MobiusDev <8391001+MobiusDevelopment@users.noreply.github.com> Date: Sun, 3 Mar 2019 01:19:23 +0000 Subject: [PATCH] Addition of ensoul extraction. --- .../dist/game/data/html/default/30298.htm | 17 +-- .../dist/game/data/html/default/30300.htm | 17 +-- .../dist/game/data/html/default/30317.htm | 17 +-- .../dist/game/data/html/default/30458.htm | 17 +-- .../dist/game/data/html/default/30678.htm | 19 +-- .../dist/game/data/html/default/30688.htm | 15 ++- .../dist/game/data/html/default/30846.htm | 9 +- .../dist/game/data/html/default/30898.htm | 11 +- .../dist/game/data/html/default/31271.htm | 17 +-- .../dist/game/data/html/default/31316.htm | 17 +-- .../dist/game/data/html/default/31960.htm | 17 +-- .../handlers/bypasshandlers/EnsoulWindow.java | 15 ++- .../gameserver/data/xml/impl/EnsoulData.java | 39 ++++++ .../gameserver/model/ensoul/EnsoulFee.java | 14 +++ .../model/items/instance/L2ItemInstance.java | 22 ++++ .../gameserver/network/ExIncomingPackets.java | 3 +- .../ensoul/RequestTryEnSoulExtraction.java | 118 ++++++++++++++++++ .../ensoul/ExEnSoulExtractionResult.java | 59 +++++++++ .../ensoul/ExShowEnsoulExtractionWindow.java | 40 ++++++ .../dist/game/data/html/default/30298.htm | 17 +-- .../dist/game/data/html/default/30300.htm | 17 +-- .../dist/game/data/html/default/30317.htm | 17 +-- .../dist/game/data/html/default/30458.htm | 17 +-- .../dist/game/data/html/default/30678.htm | 19 +-- .../dist/game/data/html/default/30688.htm | 15 ++- .../dist/game/data/html/default/30846.htm | 9 +- .../dist/game/data/html/default/30898.htm | 11 +- .../dist/game/data/html/default/31271.htm | 17 +-- .../dist/game/data/html/default/31316.htm | 17 +-- .../dist/game/data/html/default/31960.htm | 17 +-- .../handlers/bypasshandlers/EnsoulWindow.java | 15 ++- .../gameserver/data/xml/impl/EnsoulData.java | 39 ++++++ .../gameserver/model/ensoul/EnsoulFee.java | 14 +++ .../model/items/instance/L2ItemInstance.java | 22 ++++ .../gameserver/network/ExIncomingPackets.java | 3 +- .../ensoul/RequestTryEnSoulExtraction.java | 118 ++++++++++++++++++ .../ensoul/ExEnSoulExtractionResult.java | 59 +++++++++ .../ensoul/ExShowEnsoulExtractionWindow.java | 40 ++++++ .../dist/game/data/html/default/30298.htm | 17 +-- .../dist/game/data/html/default/30300.htm | 17 +-- .../dist/game/data/html/default/30317.htm | 17 +-- .../dist/game/data/html/default/30458.htm | 17 +-- .../dist/game/data/html/default/30678.htm | 19 +-- .../dist/game/data/html/default/30688.htm | 15 ++- .../dist/game/data/html/default/30846.htm | 9 +- .../dist/game/data/html/default/30898.htm | 11 +- .../dist/game/data/html/default/31271.htm | 17 +-- .../dist/game/data/html/default/31316.htm | 17 +-- .../dist/game/data/html/default/31960.htm | 17 +-- .../handlers/bypasshandlers/EnsoulWindow.java | 15 ++- .../gameserver/data/xml/impl/EnsoulData.java | 39 ++++++ .../gameserver/model/ensoul/EnsoulFee.java | 14 +++ .../model/items/instance/L2ItemInstance.java | 22 ++++ .../gameserver/network/ExIncomingPackets.java | 3 +- .../ensoul/RequestTryEnSoulExtraction.java | 118 ++++++++++++++++++ .../ensoul/ExEnSoulExtractionResult.java | 59 +++++++++ .../ensoul/ExShowEnsoulExtractionWindow.java | 40 ++++++ .../dist/game/data/html/default/30298.htm | 17 +-- .../dist/game/data/html/default/30300.htm | 17 +-- .../dist/game/data/html/default/30317.htm | 17 +-- .../dist/game/data/html/default/30458.htm | 17 +-- .../dist/game/data/html/default/30678.htm | 19 +-- .../dist/game/data/html/default/30688.htm | 15 ++- .../dist/game/data/html/default/30846.htm | 9 +- .../dist/game/data/html/default/30898.htm | 11 +- .../dist/game/data/html/default/31271.htm | 17 +-- .../dist/game/data/html/default/31316.htm | 17 +-- .../dist/game/data/html/default/31960.htm | 17 +-- .../handlers/bypasshandlers/EnsoulWindow.java | 15 ++- .../gameserver/data/xml/impl/EnsoulData.java | 39 ++++++ .../gameserver/model/ensoul/EnsoulFee.java | 14 +++ .../model/items/instance/L2ItemInstance.java | 22 ++++ .../gameserver/network/ExIncomingPackets.java | 3 +- .../ensoul/RequestTryEnSoulExtraction.java | 118 ++++++++++++++++++ .../ensoul/ExEnSoulExtractionResult.java | 59 +++++++++ .../ensoul/ExShowEnsoulExtractionWindow.java | 40 ++++++ 76 files changed, 1600 insertions(+), 332 deletions(-) create mode 100644 L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/network/clientpackets/ensoul/RequestTryEnSoulExtraction.java create mode 100644 L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/network/serverpackets/ensoul/ExEnSoulExtractionResult.java create mode 100644 L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/network/serverpackets/ensoul/ExShowEnsoulExtractionWindow.java create mode 100644 L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/network/clientpackets/ensoul/RequestTryEnSoulExtraction.java create mode 100644 L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/network/serverpackets/ensoul/ExEnSoulExtractionResult.java create mode 100644 L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/network/serverpackets/ensoul/ExShowEnsoulExtractionWindow.java create mode 100644 L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/network/clientpackets/ensoul/RequestTryEnSoulExtraction.java create mode 100644 L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/network/serverpackets/ensoul/ExEnSoulExtractionResult.java create mode 100644 L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/network/serverpackets/ensoul/ExShowEnsoulExtractionWindow.java create mode 100644 L2J_Mobius_6.0_Fafurion/java/com/l2jmobius/gameserver/network/clientpackets/ensoul/RequestTryEnSoulExtraction.java create mode 100644 L2J_Mobius_6.0_Fafurion/java/com/l2jmobius/gameserver/network/serverpackets/ensoul/ExEnSoulExtractionResult.java create mode 100644 L2J_Mobius_6.0_Fafurion/java/com/l2jmobius/gameserver/network/serverpackets/ensoul/ExShowEnsoulExtractionWindow.java diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/html/default/30298.htm b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/html/default/30298.htm index 5480743a8a..f6ee0059be 100644 --- a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/html/default/30298.htm +++ b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/html/default/30298.htm @@ -1,12 +1,13 @@ Blacksmith Pinter:
Welcome. What brings you here, my friend? The name's Pinter. Yes, yes, I'm a Dwarf, and proud of it! My family has been blacksmiths in this town for three generations now! This place is in our blood!
- - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/html/default/30300.htm b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/html/default/30300.htm index f0eaf38fd9..44a475cdd7 100644 --- a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/html/default/30300.htm +++ b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/html/default/30300.htm @@ -1,13 +1,14 @@ Blacksmith Pushkin:
Nice to meet you, wanderer!
Rupio and I have come all the way from the Black Anvil Guild to set up shop here. We haven't been here long, but we're gonna turn this place into the best forge in Giran! What can we do for you?
- - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/html/default/30317.htm b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/html/default/30317.htm index 605b347831..c4013df238 100644 --- a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/html/default/30317.htm +++ b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/html/default/30317.htm @@ -1,12 +1,13 @@ Blacksmith Kluto:
Interested in seeing a genius at work, hmm? Just hang around!
- - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/html/default/30458.htm b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/html/default/30458.htm index e608c357b1..1189600c08 100644 --- a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/html/default/30458.htm +++ b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/html/default/30458.htm @@ -1,13 +1,14 @@ Blacksmith Poitan:
Nice to meet you, traveler. Your timing is excellent! I just finished remodeling the workshop yesterday, so you're my first customer this season!
What can I do for you?
- - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/html/default/30678.htm b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/html/default/30678.htm index d53b6550fe..5c34023a5b 100644 --- a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/html/default/30678.htm +++ b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/html/default/30678.htm @@ -2,13 +2,14 @@ Hmph, who are you? Why did you come here? Unless you have a case of Dwarven beer in that tiny saddle bag, I don't want to hear about it! Bahhh!
All I ever hear is heat this, cool that, get to the bellows, it's too hot, don't drop it! Argh! Makes me want to puke! It SO does not pay to be the low man on the totem pole! I want to MAKE something!
Armor, a blade... anything!
- - - - - - - - + + + + + + + + + - + \ No newline at end of file diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/html/default/30688.htm b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/html/default/30688.htm index 248cba686d..a8baa74ed6 100644 --- a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/html/default/30688.htm +++ b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/html/default/30688.htm @@ -1,10 +1,13 @@ Blacksmith Duning:
Hello there! Welcome to the forge! It's so exciting here. So many adventurers stopping by! Why just yesterday, I had lunch with a bounty hunter, tea with an informer, and supper with a ruins explorer! The stories! The romances! The adventures! Better than day time theater!
- - - - - - + + + + + + + + + \ No newline at end of file diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/html/default/30846.htm b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/html/default/30846.htm index f14051188a..16582e3faa 100644 --- a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/html/default/30846.htm +++ b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/html/default/30846.htm @@ -1,13 +1,14 @@ Blacksmith Wilbert:
What do we do here? Well, blacksmiths make things like armor, swords, polearms, axes, plows... But wait! There's more! Look, over there... Aden Castle stands, proudly disregarding the laws of gravity. And you know why? Engineering! It would have collapsed a long time ago if it hadn't been for the efforts of the Black Anvil craftsmen.
And... This is just a rumor, but... They say that the giant golem the rebels used to evict the Human lords was made and sold by the Black Anvil. After all, who else could do something like that, right?
- + + + + - - - + \ No newline at end of file diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/html/default/30898.htm b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/html/default/30898.htm index 128bbc3e52..e090794162 100644 --- a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/html/default/30898.htm +++ b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/html/default/30898.htm @@ -1,12 +1,13 @@ Blacksmith Morning:
Welcome! If you have money, I have skills. What do you need, friend?
- - - + + + + + - - + \ No newline at end of file diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/html/default/31271.htm b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/html/default/31271.htm index 8f122ff5dc..c2183e6aba 100644 --- a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/html/default/31271.htm +++ b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/html/default/31271.htm @@ -1,12 +1,13 @@ Blacksmith Hilda:
Do you have any business for Hilda? Hmm? Hilda is busy, busy! She must make swords, plows, polearms, and armor! No visiting! Hilda doesn't visit, just works! Hilda doesn't mind watchers, but if someone talks while Hilda works, someone might get hit by hammer. In the face. Hard.
- - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/html/default/31316.htm b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/html/default/31316.htm index a71c7dcfec..7c0124cbd9 100644 --- a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/html/default/31316.htm +++ b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/html/default/31316.htm @@ -1,13 +1,14 @@ Blacksmith Vincenz:
Welcome to the thunder forge! Hahaha! Noisy, isn't it?
Do you have anything that you like to craft? We do it all here! Order whatever you like. A pendant? A sword? A war golem? It's all the same to us.
- - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/html/default/31960.htm b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/html/default/31960.htm index ec5f9b02a2..3cd19caec8 100644 --- a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/html/default/31960.htm +++ b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/html/default/31960.htm @@ -1,12 +1,13 @@ Blacksmith Buryun:
Welcome! Your timing is impeccable, I just finished up a three-day job repairing this here Claymore for Fred. A nasty piece of work that! What can I help you with?
- - - - - - - - + + + + + + + + + diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/handlers/bypasshandlers/EnsoulWindow.java b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/handlers/bypasshandlers/EnsoulWindow.java index ab17ea149a..3c78cde4b8 100644 --- a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/handlers/bypasshandlers/EnsoulWindow.java +++ b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/handlers/bypasshandlers/EnsoulWindow.java @@ -19,6 +19,7 @@ package handlers.bypasshandlers; import com.l2jmobius.gameserver.handler.IBypassHandler; import com.l2jmobius.gameserver.model.actor.L2Character; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; +import com.l2jmobius.gameserver.network.serverpackets.ensoul.ExShowEnsoulExtractionWindow; import com.l2jmobius.gameserver.network.serverpackets.ensoul.ExShowEnsoulWindow; /** @@ -29,6 +30,7 @@ public class EnsoulWindow implements IBypassHandler private static final String[] COMMANDS = { "show_ensoul_window", + "show_extract_ensoul_window" }; @Override @@ -39,8 +41,17 @@ public class EnsoulWindow implements IBypassHandler return false; } - activeChar.sendPacket(ExShowEnsoulWindow.STATIC_PACKET); - return true; + if (command.toLowerCase().startsWith(COMMANDS[0])) // show_ensoul_window + { + activeChar.sendPacket(ExShowEnsoulWindow.STATIC_PACKET); + return true; + } + else if (command.toLowerCase().startsWith(COMMANDS[1])) // show_extract_ensoul_window + { + activeChar.sendPacket(ExShowEnsoulExtractionWindow.STATIC_PACKET); + return true; + } + return false; } @Override diff --git a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/data/xml/impl/EnsoulData.java b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/data/xml/impl/EnsoulData.java index 239b582894..0881f3aaec 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/data/xml/impl/EnsoulData.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/data/xml/impl/EnsoulData.java @@ -17,6 +17,8 @@ package com.l2jmobius.gameserver.data.xml.impl; import java.io.File; +import java.util.Collection; +import java.util.Collections; import java.util.EnumMap; import java.util.HashMap; import java.util.Map; @@ -122,6 +124,11 @@ public class EnsoulData implements IGameXmlReader parseReFee(feeNode, fee, 2); break; } + case "remove": + { + parseRemove(feeNode, fee); + break; + } } }); } @@ -143,6 +150,14 @@ public class EnsoulData implements IGameXmlReader fee.setResoul(index, new ItemHolder(id, count)); } + private void parseRemove(Node ensoulNode, EnsoulFee fee) + { + final NamedNodeMap attrs = ensoulNode.getAttributes(); + final int id = parseInteger(attrs, "itemId"); + final int count = parseInteger(attrs, "count"); + fee.addRemovalFee(new ItemHolder(id, count)); + } + private void parseOptions(Node ensoulNode) { final NamedNodeMap attrs = ensoulNode.getAttributes(); @@ -177,6 +192,12 @@ public class EnsoulData implements IGameXmlReader return fee != null ? fee.getResoul(index) : null; } + public Collection getRemovalFee(CrystalType type) + { + final EnsoulFee fee = _ensoulFees.get(type); + return fee != null ? fee.getRemovalFee() : Collections.emptyList(); + } + public EnsoulOption getOption(int id) { return _ensoulOptions.get(id); @@ -187,6 +208,24 @@ public class EnsoulData implements IGameXmlReader return _ensoulStones.get(id); } + public int getStone(int type, int optionId) + { + for (EnsoulStone stone : _ensoulStones.values()) + { + if (stone.getSlotType() == type) + { + for (int id : stone.getOptions()) + { + if (id == optionId) + { + return stone.getId(); + } + } + } + } + return 0; + } + /** * Gets the single instance of EnsoulData. * @return single instance of EnsoulData diff --git a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/model/ensoul/EnsoulFee.java b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/model/ensoul/EnsoulFee.java index f62baeedb2..ae71e99afa 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/model/ensoul/EnsoulFee.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/model/ensoul/EnsoulFee.java @@ -16,6 +16,9 @@ */ package com.l2jmobius.gameserver.model.ensoul; +import java.util.ArrayList; +import java.util.List; + import com.l2jmobius.gameserver.model.holders.ItemHolder; import com.l2jmobius.gameserver.model.items.type.CrystalType; @@ -28,6 +31,7 @@ public class EnsoulFee private final ItemHolder[] _ensoulFee = new ItemHolder[3]; private final ItemHolder[] _resoulFees = new ItemHolder[3]; + private final List _removalFee = new ArrayList<>(); public EnsoulFee(CrystalType type) { @@ -49,6 +53,11 @@ public class EnsoulFee _resoulFees[index] = item; } + public void addRemovalFee(ItemHolder itemHolder) + { + _removalFee.add(itemHolder); + } + public ItemHolder getEnsoul(int index) { return _ensoulFee[index]; @@ -58,4 +67,9 @@ public class EnsoulFee { return _resoulFees[index]; } + + public List getRemovalFee() + { + return _removalFee; + } } diff --git a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/model/items/instance/L2ItemInstance.java b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/model/items/instance/L2ItemInstance.java index a2092facf2..dc62f94d94 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/model/items/instance/L2ItemInstance.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/model/items/instance/L2ItemInstance.java @@ -2175,6 +2175,28 @@ public final class L2ItemInstance extends L2Object } } + public void removeSpecialAbility(int position, int type) + { + if (type == 1) + { + final EnsoulOption option = _ensoulOptions.get(position); + if (option != null) + { + removeSpecialAbility(option); + _ensoulOptions.remove(position); + } + } + else if (type == 2) + { + final EnsoulOption option = _ensoulSpecialOptions.get(position); + if (option != null) + { + removeSpecialAbility(option); + _ensoulSpecialOptions.remove(position); + } + } + } + public void clearSpecialAbilities() { _ensoulOptions.values().forEach(this::clearSpecialAbility); diff --git a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/network/ExIncomingPackets.java b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/network/ExIncomingPackets.java index 43cd9a1ac5..54484e0fba 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/network/ExIncomingPackets.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/network/ExIncomingPackets.java @@ -70,6 +70,7 @@ import com.l2jmobius.gameserver.network.clientpackets.crystalization.RequestCrys import com.l2jmobius.gameserver.network.clientpackets.dailymission.RequestOneDayRewardReceive; import com.l2jmobius.gameserver.network.clientpackets.dailymission.RequestTodoList; import com.l2jmobius.gameserver.network.clientpackets.ensoul.RequestItemEnsoul; +import com.l2jmobius.gameserver.network.clientpackets.ensoul.RequestTryEnSoulExtraction; import com.l2jmobius.gameserver.network.clientpackets.faction.RequestUserFactionInfo; import com.l2jmobius.gameserver.network.clientpackets.friend.RequestFriendDetailInfo; import com.l2jmobius.gameserver.network.clientpackets.luckygame.RequestLuckyGamePlay; @@ -392,7 +393,7 @@ public enum ExIncomingPackets implements IIncomingPackets REQUEST_SSO_AUTHN_TOKEN(0x125, null, ConnectionState.IN_GAME), REQUEST_QUEUE_TICKET_LOGIN(0x126, null, ConnectionState.IN_GAME), REQUEST_BLOCK_MEMO_INFO(0x127, null, ConnectionState.IN_GAME), - REQUEST_TRY_EN_SOUL_EXTRACTION(0x128, null, ConnectionState.IN_GAME), + REQUEST_TRY_EN_SOUL_EXTRACTION(0x128, RequestTryEnSoulExtraction::new, ConnectionState.IN_GAME), REQUEST_RAIDBOSS_SPAWN_INFO(0x129, RequestRaidBossSpawnInfo::new, ConnectionState.IN_GAME), REQUEST_RAID_SERVER_INFO(0x12A, RequestRaidServerInfo::new, ConnectionState.IN_GAME), REQUEST_SHOW_AGIT_SIEGE_INFO(0x12B, null, ConnectionState.IN_GAME), diff --git a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/network/clientpackets/ensoul/RequestTryEnSoulExtraction.java b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/network/clientpackets/ensoul/RequestTryEnSoulExtraction.java new file mode 100644 index 0000000000..e0d7142936 --- /dev/null +++ b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/network/clientpackets/ensoul/RequestTryEnSoulExtraction.java @@ -0,0 +1,118 @@ +/* + * 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 . + */ +package com.l2jmobius.gameserver.network.clientpackets.ensoul; + +import java.util.Collection; + +import com.l2jmobius.commons.network.PacketReader; +import com.l2jmobius.gameserver.data.xml.impl.EnsoulData; +import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; +import com.l2jmobius.gameserver.model.ensoul.EnsoulOption; +import com.l2jmobius.gameserver.model.holders.ItemHolder; +import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance; +import com.l2jmobius.gameserver.network.L2GameClient; +import com.l2jmobius.gameserver.network.SystemMessageId; +import com.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket; +import com.l2jmobius.gameserver.network.serverpackets.InventoryUpdate; +import com.l2jmobius.gameserver.network.serverpackets.ensoul.ExEnSoulExtractionResult; + +/** + * @author Mobius + */ +public class RequestTryEnSoulExtraction implements IClientIncomingPacket +{ + private int _itemObjectId; + private int _type; + private int _position; + + @Override + public boolean read(L2GameClient client, PacketReader packet) + { + _itemObjectId = packet.readD(); + _type = packet.readC(); + _position = packet.readC() - 1; + return true; + } + + @Override + public void run(L2GameClient client) + { + L2PcInstance player = client.getActiveChar(); + if (player == null) + { + return; + } + + final L2ItemInstance item = player.getInventory().getItemByObjectId(_itemObjectId); + if (item == null) + { + return; + } + + EnsoulOption option = null; + if (_type == 1) + { + option = item.getSpecialAbility(_position); + } + if (_type == 2) + { + option = item.getAdditionalSpecialAbility(_position); + } + if (option == null) + { + return; + } + + final Collection removalFee = EnsoulData.getInstance().getRemovalFee(item.getItem().getCrystalType()); + if (removalFee.isEmpty()) + { + return; + } + + // Check if player has required items. + for (ItemHolder itemHolder : removalFee) + { + if (player.getInventory().getInventoryItemCount(itemHolder.getId(), -1) < itemHolder.getCount()) + { + player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT); + player.sendPacket(new ExEnSoulExtractionResult(false, item)); + return; + } + } + + // Take required items. + for (ItemHolder itemHolder : removalFee) + { + player.destroyItemByItemId("Rune Extract", itemHolder.getId(), itemHolder.getCount(), player, true); + } + + // Remove equipped rune. + item.removeSpecialAbility(_position, _type); + final InventoryUpdate iu = new InventoryUpdate(); + iu.addModifiedItem(item); + + // Add rune in player inventory. + final int runeId = EnsoulData.getInstance().getStone(_type, option.getId()); + if (runeId > 0) + { + iu.addItem(player.addItem("Rune Extract", runeId, 1, player, true)); + } + + player.sendInventoryUpdate(iu); + player.sendPacket(new ExEnSoulExtractionResult(true, item)); + } +} \ No newline at end of file diff --git a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/network/serverpackets/ensoul/ExEnSoulExtractionResult.java b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/network/serverpackets/ensoul/ExEnSoulExtractionResult.java new file mode 100644 index 0000000000..8b8b2e564b --- /dev/null +++ b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/network/serverpackets/ensoul/ExEnSoulExtractionResult.java @@ -0,0 +1,59 @@ +/* + * 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 . + */ +package com.l2jmobius.gameserver.network.serverpackets.ensoul; + +import com.l2jmobius.commons.network.PacketWriter; +import com.l2jmobius.gameserver.model.ensoul.EnsoulOption; +import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance; +import com.l2jmobius.gameserver.network.OutgoingPackets; +import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; + +/** + * @author Mobius + */ +public class ExEnSoulExtractionResult implements IClientOutgoingPacket +{ + private final boolean _success; + private final L2ItemInstance _item; + + public ExEnSoulExtractionResult(boolean success, L2ItemInstance item) + { + _success = success; + _item = item; + } + + @Override + public boolean write(PacketWriter packet) + { + OutgoingPackets.EX_ENSOUL_EXTRACTION_RESULT.writeId(packet); + packet.writeC(_success ? 1 : 0); + if (_success) + { + packet.writeC(_item.getSpecialAbilities().size()); + for (EnsoulOption option : _item.getSpecialAbilities()) + { + packet.writeD(option.getId()); + } + packet.writeC(_item.getAdditionalSpecialAbilities().size()); + for (EnsoulOption option : _item.getAdditionalSpecialAbilities()) + { + packet.writeD(option.getId()); + } + } + return true; + } +} diff --git a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/network/serverpackets/ensoul/ExShowEnsoulExtractionWindow.java b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/network/serverpackets/ensoul/ExShowEnsoulExtractionWindow.java new file mode 100644 index 0000000000..76ec17cfd2 --- /dev/null +++ b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/network/serverpackets/ensoul/ExShowEnsoulExtractionWindow.java @@ -0,0 +1,40 @@ +/* + * 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 . + */ +package com.l2jmobius.gameserver.network.serverpackets.ensoul; + +import com.l2jmobius.commons.network.PacketWriter; +import com.l2jmobius.gameserver.network.OutgoingPackets; +import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; + +/** + * @author Mobius + */ +public class ExShowEnsoulExtractionWindow implements IClientOutgoingPacket +{ + public static final ExShowEnsoulExtractionWindow STATIC_PACKET = new ExShowEnsoulExtractionWindow(); + + private ExShowEnsoulExtractionWindow() + { + } + + @Override + public boolean write(PacketWriter packet) + { + OutgoingPackets.EX_ENSOUL_EXTRACTION_SHOW.writeId(packet); + return true; + } +} \ No newline at end of file diff --git a/L2J_Mobius_5.0_Salvation/dist/game/data/html/default/30298.htm b/L2J_Mobius_5.0_Salvation/dist/game/data/html/default/30298.htm index 5480743a8a..f6ee0059be 100644 --- a/L2J_Mobius_5.0_Salvation/dist/game/data/html/default/30298.htm +++ b/L2J_Mobius_5.0_Salvation/dist/game/data/html/default/30298.htm @@ -1,12 +1,13 @@ Blacksmith Pinter:
Welcome. What brings you here, my friend? The name's Pinter. Yes, yes, I'm a Dwarf, and proud of it! My family has been blacksmiths in this town for three generations now! This place is in our blood!
- - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/L2J_Mobius_5.0_Salvation/dist/game/data/html/default/30300.htm b/L2J_Mobius_5.0_Salvation/dist/game/data/html/default/30300.htm index f0eaf38fd9..44a475cdd7 100644 --- a/L2J_Mobius_5.0_Salvation/dist/game/data/html/default/30300.htm +++ b/L2J_Mobius_5.0_Salvation/dist/game/data/html/default/30300.htm @@ -1,13 +1,14 @@ Blacksmith Pushkin:
Nice to meet you, wanderer!
Rupio and I have come all the way from the Black Anvil Guild to set up shop here. We haven't been here long, but we're gonna turn this place into the best forge in Giran! What can we do for you?
- - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/L2J_Mobius_5.0_Salvation/dist/game/data/html/default/30317.htm b/L2J_Mobius_5.0_Salvation/dist/game/data/html/default/30317.htm index 605b347831..c4013df238 100644 --- a/L2J_Mobius_5.0_Salvation/dist/game/data/html/default/30317.htm +++ b/L2J_Mobius_5.0_Salvation/dist/game/data/html/default/30317.htm @@ -1,12 +1,13 @@ Blacksmith Kluto:
Interested in seeing a genius at work, hmm? Just hang around!
- - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/L2J_Mobius_5.0_Salvation/dist/game/data/html/default/30458.htm b/L2J_Mobius_5.0_Salvation/dist/game/data/html/default/30458.htm index e608c357b1..1189600c08 100644 --- a/L2J_Mobius_5.0_Salvation/dist/game/data/html/default/30458.htm +++ b/L2J_Mobius_5.0_Salvation/dist/game/data/html/default/30458.htm @@ -1,13 +1,14 @@ Blacksmith Poitan:
Nice to meet you, traveler. Your timing is excellent! I just finished remodeling the workshop yesterday, so you're my first customer this season!
What can I do for you?
- - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/L2J_Mobius_5.0_Salvation/dist/game/data/html/default/30678.htm b/L2J_Mobius_5.0_Salvation/dist/game/data/html/default/30678.htm index d53b6550fe..5c34023a5b 100644 --- a/L2J_Mobius_5.0_Salvation/dist/game/data/html/default/30678.htm +++ b/L2J_Mobius_5.0_Salvation/dist/game/data/html/default/30678.htm @@ -2,13 +2,14 @@ Hmph, who are you? Why did you come here? Unless you have a case of Dwarven beer in that tiny saddle bag, I don't want to hear about it! Bahhh!
All I ever hear is heat this, cool that, get to the bellows, it's too hot, don't drop it! Argh! Makes me want to puke! It SO does not pay to be the low man on the totem pole! I want to MAKE something!
Armor, a blade... anything!
- - - - - - - - + + + + + + + + + - + \ No newline at end of file diff --git a/L2J_Mobius_5.0_Salvation/dist/game/data/html/default/30688.htm b/L2J_Mobius_5.0_Salvation/dist/game/data/html/default/30688.htm index 248cba686d..a8baa74ed6 100644 --- a/L2J_Mobius_5.0_Salvation/dist/game/data/html/default/30688.htm +++ b/L2J_Mobius_5.0_Salvation/dist/game/data/html/default/30688.htm @@ -1,10 +1,13 @@ Blacksmith Duning:
Hello there! Welcome to the forge! It's so exciting here. So many adventurers stopping by! Why just yesterday, I had lunch with a bounty hunter, tea with an informer, and supper with a ruins explorer! The stories! The romances! The adventures! Better than day time theater!
- - - - - - + + + + + + + + + \ No newline at end of file diff --git a/L2J_Mobius_5.0_Salvation/dist/game/data/html/default/30846.htm b/L2J_Mobius_5.0_Salvation/dist/game/data/html/default/30846.htm index f14051188a..16582e3faa 100644 --- a/L2J_Mobius_5.0_Salvation/dist/game/data/html/default/30846.htm +++ b/L2J_Mobius_5.0_Salvation/dist/game/data/html/default/30846.htm @@ -1,13 +1,14 @@ Blacksmith Wilbert:
What do we do here? Well, blacksmiths make things like armor, swords, polearms, axes, plows... But wait! There's more! Look, over there... Aden Castle stands, proudly disregarding the laws of gravity. And you know why? Engineering! It would have collapsed a long time ago if it hadn't been for the efforts of the Black Anvil craftsmen.
And... This is just a rumor, but... They say that the giant golem the rebels used to evict the Human lords was made and sold by the Black Anvil. After all, who else could do something like that, right?
- + + + + - - - + \ No newline at end of file diff --git a/L2J_Mobius_5.0_Salvation/dist/game/data/html/default/30898.htm b/L2J_Mobius_5.0_Salvation/dist/game/data/html/default/30898.htm index 128bbc3e52..e090794162 100644 --- a/L2J_Mobius_5.0_Salvation/dist/game/data/html/default/30898.htm +++ b/L2J_Mobius_5.0_Salvation/dist/game/data/html/default/30898.htm @@ -1,12 +1,13 @@ Blacksmith Morning:
Welcome! If you have money, I have skills. What do you need, friend?
- - - + + + + + - - + \ No newline at end of file diff --git a/L2J_Mobius_5.0_Salvation/dist/game/data/html/default/31271.htm b/L2J_Mobius_5.0_Salvation/dist/game/data/html/default/31271.htm index 8f122ff5dc..c2183e6aba 100644 --- a/L2J_Mobius_5.0_Salvation/dist/game/data/html/default/31271.htm +++ b/L2J_Mobius_5.0_Salvation/dist/game/data/html/default/31271.htm @@ -1,12 +1,13 @@ Blacksmith Hilda:
Do you have any business for Hilda? Hmm? Hilda is busy, busy! She must make swords, plows, polearms, and armor! No visiting! Hilda doesn't visit, just works! Hilda doesn't mind watchers, but if someone talks while Hilda works, someone might get hit by hammer. In the face. Hard.
- - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/L2J_Mobius_5.0_Salvation/dist/game/data/html/default/31316.htm b/L2J_Mobius_5.0_Salvation/dist/game/data/html/default/31316.htm index a71c7dcfec..7c0124cbd9 100644 --- a/L2J_Mobius_5.0_Salvation/dist/game/data/html/default/31316.htm +++ b/L2J_Mobius_5.0_Salvation/dist/game/data/html/default/31316.htm @@ -1,13 +1,14 @@ Blacksmith Vincenz:
Welcome to the thunder forge! Hahaha! Noisy, isn't it?
Do you have anything that you like to craft? We do it all here! Order whatever you like. A pendant? A sword? A war golem? It's all the same to us.
- - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/L2J_Mobius_5.0_Salvation/dist/game/data/html/default/31960.htm b/L2J_Mobius_5.0_Salvation/dist/game/data/html/default/31960.htm index ec5f9b02a2..3cd19caec8 100644 --- a/L2J_Mobius_5.0_Salvation/dist/game/data/html/default/31960.htm +++ b/L2J_Mobius_5.0_Salvation/dist/game/data/html/default/31960.htm @@ -1,12 +1,13 @@ Blacksmith Buryun:
Welcome! Your timing is impeccable, I just finished up a three-day job repairing this here Claymore for Fred. A nasty piece of work that! What can I help you with?
- - - - - - - - + + + + + + + + + diff --git a/L2J_Mobius_5.0_Salvation/dist/game/data/scripts/handlers/bypasshandlers/EnsoulWindow.java b/L2J_Mobius_5.0_Salvation/dist/game/data/scripts/handlers/bypasshandlers/EnsoulWindow.java index ab17ea149a..3c78cde4b8 100644 --- a/L2J_Mobius_5.0_Salvation/dist/game/data/scripts/handlers/bypasshandlers/EnsoulWindow.java +++ b/L2J_Mobius_5.0_Salvation/dist/game/data/scripts/handlers/bypasshandlers/EnsoulWindow.java @@ -19,6 +19,7 @@ package handlers.bypasshandlers; import com.l2jmobius.gameserver.handler.IBypassHandler; import com.l2jmobius.gameserver.model.actor.L2Character; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; +import com.l2jmobius.gameserver.network.serverpackets.ensoul.ExShowEnsoulExtractionWindow; import com.l2jmobius.gameserver.network.serverpackets.ensoul.ExShowEnsoulWindow; /** @@ -29,6 +30,7 @@ public class EnsoulWindow implements IBypassHandler private static final String[] COMMANDS = { "show_ensoul_window", + "show_extract_ensoul_window" }; @Override @@ -39,8 +41,17 @@ public class EnsoulWindow implements IBypassHandler return false; } - activeChar.sendPacket(ExShowEnsoulWindow.STATIC_PACKET); - return true; + if (command.toLowerCase().startsWith(COMMANDS[0])) // show_ensoul_window + { + activeChar.sendPacket(ExShowEnsoulWindow.STATIC_PACKET); + return true; + } + else if (command.toLowerCase().startsWith(COMMANDS[1])) // show_extract_ensoul_window + { + activeChar.sendPacket(ExShowEnsoulExtractionWindow.STATIC_PACKET); + return true; + } + return false; } @Override diff --git a/L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/data/xml/impl/EnsoulData.java b/L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/data/xml/impl/EnsoulData.java index 239b582894..0881f3aaec 100644 --- a/L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/data/xml/impl/EnsoulData.java +++ b/L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/data/xml/impl/EnsoulData.java @@ -17,6 +17,8 @@ package com.l2jmobius.gameserver.data.xml.impl; import java.io.File; +import java.util.Collection; +import java.util.Collections; import java.util.EnumMap; import java.util.HashMap; import java.util.Map; @@ -122,6 +124,11 @@ public class EnsoulData implements IGameXmlReader parseReFee(feeNode, fee, 2); break; } + case "remove": + { + parseRemove(feeNode, fee); + break; + } } }); } @@ -143,6 +150,14 @@ public class EnsoulData implements IGameXmlReader fee.setResoul(index, new ItemHolder(id, count)); } + private void parseRemove(Node ensoulNode, EnsoulFee fee) + { + final NamedNodeMap attrs = ensoulNode.getAttributes(); + final int id = parseInteger(attrs, "itemId"); + final int count = parseInteger(attrs, "count"); + fee.addRemovalFee(new ItemHolder(id, count)); + } + private void parseOptions(Node ensoulNode) { final NamedNodeMap attrs = ensoulNode.getAttributes(); @@ -177,6 +192,12 @@ public class EnsoulData implements IGameXmlReader return fee != null ? fee.getResoul(index) : null; } + public Collection getRemovalFee(CrystalType type) + { + final EnsoulFee fee = _ensoulFees.get(type); + return fee != null ? fee.getRemovalFee() : Collections.emptyList(); + } + public EnsoulOption getOption(int id) { return _ensoulOptions.get(id); @@ -187,6 +208,24 @@ public class EnsoulData implements IGameXmlReader return _ensoulStones.get(id); } + public int getStone(int type, int optionId) + { + for (EnsoulStone stone : _ensoulStones.values()) + { + if (stone.getSlotType() == type) + { + for (int id : stone.getOptions()) + { + if (id == optionId) + { + return stone.getId(); + } + } + } + } + return 0; + } + /** * Gets the single instance of EnsoulData. * @return single instance of EnsoulData diff --git a/L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/model/ensoul/EnsoulFee.java b/L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/model/ensoul/EnsoulFee.java index f62baeedb2..ae71e99afa 100644 --- a/L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/model/ensoul/EnsoulFee.java +++ b/L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/model/ensoul/EnsoulFee.java @@ -16,6 +16,9 @@ */ package com.l2jmobius.gameserver.model.ensoul; +import java.util.ArrayList; +import java.util.List; + import com.l2jmobius.gameserver.model.holders.ItemHolder; import com.l2jmobius.gameserver.model.items.type.CrystalType; @@ -28,6 +31,7 @@ public class EnsoulFee private final ItemHolder[] _ensoulFee = new ItemHolder[3]; private final ItemHolder[] _resoulFees = new ItemHolder[3]; + private final List _removalFee = new ArrayList<>(); public EnsoulFee(CrystalType type) { @@ -49,6 +53,11 @@ public class EnsoulFee _resoulFees[index] = item; } + public void addRemovalFee(ItemHolder itemHolder) + { + _removalFee.add(itemHolder); + } + public ItemHolder getEnsoul(int index) { return _ensoulFee[index]; @@ -58,4 +67,9 @@ public class EnsoulFee { return _resoulFees[index]; } + + public List getRemovalFee() + { + return _removalFee; + } } diff --git a/L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/model/items/instance/L2ItemInstance.java b/L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/model/items/instance/L2ItemInstance.java index a2092facf2..dc62f94d94 100644 --- a/L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/model/items/instance/L2ItemInstance.java +++ b/L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/model/items/instance/L2ItemInstance.java @@ -2175,6 +2175,28 @@ public final class L2ItemInstance extends L2Object } } + public void removeSpecialAbility(int position, int type) + { + if (type == 1) + { + final EnsoulOption option = _ensoulOptions.get(position); + if (option != null) + { + removeSpecialAbility(option); + _ensoulOptions.remove(position); + } + } + else if (type == 2) + { + final EnsoulOption option = _ensoulSpecialOptions.get(position); + if (option != null) + { + removeSpecialAbility(option); + _ensoulSpecialOptions.remove(position); + } + } + } + public void clearSpecialAbilities() { _ensoulOptions.values().forEach(this::clearSpecialAbility); diff --git a/L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/network/ExIncomingPackets.java b/L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/network/ExIncomingPackets.java index 649d58e0af..614867569a 100644 --- a/L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/network/ExIncomingPackets.java +++ b/L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/network/ExIncomingPackets.java @@ -68,6 +68,7 @@ import com.l2jmobius.gameserver.network.clientpackets.compound.RequestNewEnchant import com.l2jmobius.gameserver.network.clientpackets.crystalization.RequestCrystallizeEstimate; import com.l2jmobius.gameserver.network.clientpackets.crystalization.RequestCrystallizeItemCancel; import com.l2jmobius.gameserver.network.clientpackets.ensoul.RequestItemEnsoul; +import com.l2jmobius.gameserver.network.clientpackets.ensoul.RequestTryEnSoulExtraction; import com.l2jmobius.gameserver.network.clientpackets.faction.RequestUserFactionInfo; import com.l2jmobius.gameserver.network.clientpackets.friend.RequestFriendDetailInfo; import com.l2jmobius.gameserver.network.clientpackets.luckygame.RequestLuckyGamePlay; @@ -396,7 +397,7 @@ public enum ExIncomingPackets implements IIncomingPackets REQUEST_SSO_AUTHN_TOKEN(0x125, null, ConnectionState.IN_GAME), REQUEST_QUEUE_TICKET_LOGIN(0x126, null, ConnectionState.IN_GAME), REQUEST_BLOCK_MEMO_INFO(0x127, null, ConnectionState.IN_GAME), - REQUEST_TRY_EN_SOUL_EXTRACTION(0x128, null, ConnectionState.IN_GAME), + REQUEST_TRY_EN_SOUL_EXTRACTION(0x128, RequestTryEnSoulExtraction::new, ConnectionState.IN_GAME), REQUEST_RAIDBOSS_SPAWN_INFO(0x129, RequestRaidBossSpawnInfo::new, ConnectionState.IN_GAME), REQUEST_RAID_SERVER_INFO(0x12A, RequestRaidServerInfo::new, ConnectionState.IN_GAME), REQUEST_SHOW_AGIT_SIEGE_INFO(0x12B, null, ConnectionState.IN_GAME), diff --git a/L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/network/clientpackets/ensoul/RequestTryEnSoulExtraction.java b/L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/network/clientpackets/ensoul/RequestTryEnSoulExtraction.java new file mode 100644 index 0000000000..e0d7142936 --- /dev/null +++ b/L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/network/clientpackets/ensoul/RequestTryEnSoulExtraction.java @@ -0,0 +1,118 @@ +/* + * 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 . + */ +package com.l2jmobius.gameserver.network.clientpackets.ensoul; + +import java.util.Collection; + +import com.l2jmobius.commons.network.PacketReader; +import com.l2jmobius.gameserver.data.xml.impl.EnsoulData; +import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; +import com.l2jmobius.gameserver.model.ensoul.EnsoulOption; +import com.l2jmobius.gameserver.model.holders.ItemHolder; +import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance; +import com.l2jmobius.gameserver.network.L2GameClient; +import com.l2jmobius.gameserver.network.SystemMessageId; +import com.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket; +import com.l2jmobius.gameserver.network.serverpackets.InventoryUpdate; +import com.l2jmobius.gameserver.network.serverpackets.ensoul.ExEnSoulExtractionResult; + +/** + * @author Mobius + */ +public class RequestTryEnSoulExtraction implements IClientIncomingPacket +{ + private int _itemObjectId; + private int _type; + private int _position; + + @Override + public boolean read(L2GameClient client, PacketReader packet) + { + _itemObjectId = packet.readD(); + _type = packet.readC(); + _position = packet.readC() - 1; + return true; + } + + @Override + public void run(L2GameClient client) + { + L2PcInstance player = client.getActiveChar(); + if (player == null) + { + return; + } + + final L2ItemInstance item = player.getInventory().getItemByObjectId(_itemObjectId); + if (item == null) + { + return; + } + + EnsoulOption option = null; + if (_type == 1) + { + option = item.getSpecialAbility(_position); + } + if (_type == 2) + { + option = item.getAdditionalSpecialAbility(_position); + } + if (option == null) + { + return; + } + + final Collection removalFee = EnsoulData.getInstance().getRemovalFee(item.getItem().getCrystalType()); + if (removalFee.isEmpty()) + { + return; + } + + // Check if player has required items. + for (ItemHolder itemHolder : removalFee) + { + if (player.getInventory().getInventoryItemCount(itemHolder.getId(), -1) < itemHolder.getCount()) + { + player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT); + player.sendPacket(new ExEnSoulExtractionResult(false, item)); + return; + } + } + + // Take required items. + for (ItemHolder itemHolder : removalFee) + { + player.destroyItemByItemId("Rune Extract", itemHolder.getId(), itemHolder.getCount(), player, true); + } + + // Remove equipped rune. + item.removeSpecialAbility(_position, _type); + final InventoryUpdate iu = new InventoryUpdate(); + iu.addModifiedItem(item); + + // Add rune in player inventory. + final int runeId = EnsoulData.getInstance().getStone(_type, option.getId()); + if (runeId > 0) + { + iu.addItem(player.addItem("Rune Extract", runeId, 1, player, true)); + } + + player.sendInventoryUpdate(iu); + player.sendPacket(new ExEnSoulExtractionResult(true, item)); + } +} \ No newline at end of file diff --git a/L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/network/serverpackets/ensoul/ExEnSoulExtractionResult.java b/L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/network/serverpackets/ensoul/ExEnSoulExtractionResult.java new file mode 100644 index 0000000000..8b8b2e564b --- /dev/null +++ b/L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/network/serverpackets/ensoul/ExEnSoulExtractionResult.java @@ -0,0 +1,59 @@ +/* + * 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 . + */ +package com.l2jmobius.gameserver.network.serverpackets.ensoul; + +import com.l2jmobius.commons.network.PacketWriter; +import com.l2jmobius.gameserver.model.ensoul.EnsoulOption; +import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance; +import com.l2jmobius.gameserver.network.OutgoingPackets; +import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; + +/** + * @author Mobius + */ +public class ExEnSoulExtractionResult implements IClientOutgoingPacket +{ + private final boolean _success; + private final L2ItemInstance _item; + + public ExEnSoulExtractionResult(boolean success, L2ItemInstance item) + { + _success = success; + _item = item; + } + + @Override + public boolean write(PacketWriter packet) + { + OutgoingPackets.EX_ENSOUL_EXTRACTION_RESULT.writeId(packet); + packet.writeC(_success ? 1 : 0); + if (_success) + { + packet.writeC(_item.getSpecialAbilities().size()); + for (EnsoulOption option : _item.getSpecialAbilities()) + { + packet.writeD(option.getId()); + } + packet.writeC(_item.getAdditionalSpecialAbilities().size()); + for (EnsoulOption option : _item.getAdditionalSpecialAbilities()) + { + packet.writeD(option.getId()); + } + } + return true; + } +} diff --git a/L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/network/serverpackets/ensoul/ExShowEnsoulExtractionWindow.java b/L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/network/serverpackets/ensoul/ExShowEnsoulExtractionWindow.java new file mode 100644 index 0000000000..76ec17cfd2 --- /dev/null +++ b/L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/network/serverpackets/ensoul/ExShowEnsoulExtractionWindow.java @@ -0,0 +1,40 @@ +/* + * 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 . + */ +package com.l2jmobius.gameserver.network.serverpackets.ensoul; + +import com.l2jmobius.commons.network.PacketWriter; +import com.l2jmobius.gameserver.network.OutgoingPackets; +import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; + +/** + * @author Mobius + */ +public class ExShowEnsoulExtractionWindow implements IClientOutgoingPacket +{ + public static final ExShowEnsoulExtractionWindow STATIC_PACKET = new ExShowEnsoulExtractionWindow(); + + private ExShowEnsoulExtractionWindow() + { + } + + @Override + public boolean write(PacketWriter packet) + { + OutgoingPackets.EX_ENSOUL_EXTRACTION_SHOW.writeId(packet); + return true; + } +} \ No newline at end of file diff --git a/L2J_Mobius_5.5_EtinasFate/dist/game/data/html/default/30298.htm b/L2J_Mobius_5.5_EtinasFate/dist/game/data/html/default/30298.htm index 5480743a8a..f6ee0059be 100644 --- a/L2J_Mobius_5.5_EtinasFate/dist/game/data/html/default/30298.htm +++ b/L2J_Mobius_5.5_EtinasFate/dist/game/data/html/default/30298.htm @@ -1,12 +1,13 @@ Blacksmith Pinter:
Welcome. What brings you here, my friend? The name's Pinter. Yes, yes, I'm a Dwarf, and proud of it! My family has been blacksmiths in this town for three generations now! This place is in our blood!
- - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/L2J_Mobius_5.5_EtinasFate/dist/game/data/html/default/30300.htm b/L2J_Mobius_5.5_EtinasFate/dist/game/data/html/default/30300.htm index f0eaf38fd9..44a475cdd7 100644 --- a/L2J_Mobius_5.5_EtinasFate/dist/game/data/html/default/30300.htm +++ b/L2J_Mobius_5.5_EtinasFate/dist/game/data/html/default/30300.htm @@ -1,13 +1,14 @@ Blacksmith Pushkin:
Nice to meet you, wanderer!
Rupio and I have come all the way from the Black Anvil Guild to set up shop here. We haven't been here long, but we're gonna turn this place into the best forge in Giran! What can we do for you?
- - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/L2J_Mobius_5.5_EtinasFate/dist/game/data/html/default/30317.htm b/L2J_Mobius_5.5_EtinasFate/dist/game/data/html/default/30317.htm index 605b347831..c4013df238 100644 --- a/L2J_Mobius_5.5_EtinasFate/dist/game/data/html/default/30317.htm +++ b/L2J_Mobius_5.5_EtinasFate/dist/game/data/html/default/30317.htm @@ -1,12 +1,13 @@ Blacksmith Kluto:
Interested in seeing a genius at work, hmm? Just hang around!
- - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/L2J_Mobius_5.5_EtinasFate/dist/game/data/html/default/30458.htm b/L2J_Mobius_5.5_EtinasFate/dist/game/data/html/default/30458.htm index e608c357b1..1189600c08 100644 --- a/L2J_Mobius_5.5_EtinasFate/dist/game/data/html/default/30458.htm +++ b/L2J_Mobius_5.5_EtinasFate/dist/game/data/html/default/30458.htm @@ -1,13 +1,14 @@ Blacksmith Poitan:
Nice to meet you, traveler. Your timing is excellent! I just finished remodeling the workshop yesterday, so you're my first customer this season!
What can I do for you?
- - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/L2J_Mobius_5.5_EtinasFate/dist/game/data/html/default/30678.htm b/L2J_Mobius_5.5_EtinasFate/dist/game/data/html/default/30678.htm index d53b6550fe..5c34023a5b 100644 --- a/L2J_Mobius_5.5_EtinasFate/dist/game/data/html/default/30678.htm +++ b/L2J_Mobius_5.5_EtinasFate/dist/game/data/html/default/30678.htm @@ -2,13 +2,14 @@ Hmph, who are you? Why did you come here? Unless you have a case of Dwarven beer in that tiny saddle bag, I don't want to hear about it! Bahhh!
All I ever hear is heat this, cool that, get to the bellows, it's too hot, don't drop it! Argh! Makes me want to puke! It SO does not pay to be the low man on the totem pole! I want to MAKE something!
Armor, a blade... anything!
- - - - - - - - + + + + + + + + + - + \ No newline at end of file diff --git a/L2J_Mobius_5.5_EtinasFate/dist/game/data/html/default/30688.htm b/L2J_Mobius_5.5_EtinasFate/dist/game/data/html/default/30688.htm index 248cba686d..a8baa74ed6 100644 --- a/L2J_Mobius_5.5_EtinasFate/dist/game/data/html/default/30688.htm +++ b/L2J_Mobius_5.5_EtinasFate/dist/game/data/html/default/30688.htm @@ -1,10 +1,13 @@ Blacksmith Duning:
Hello there! Welcome to the forge! It's so exciting here. So many adventurers stopping by! Why just yesterday, I had lunch with a bounty hunter, tea with an informer, and supper with a ruins explorer! The stories! The romances! The adventures! Better than day time theater!
- - - - - - + + + + + + + + + \ No newline at end of file diff --git a/L2J_Mobius_5.5_EtinasFate/dist/game/data/html/default/30846.htm b/L2J_Mobius_5.5_EtinasFate/dist/game/data/html/default/30846.htm index f14051188a..16582e3faa 100644 --- a/L2J_Mobius_5.5_EtinasFate/dist/game/data/html/default/30846.htm +++ b/L2J_Mobius_5.5_EtinasFate/dist/game/data/html/default/30846.htm @@ -1,13 +1,14 @@ Blacksmith Wilbert:
What do we do here? Well, blacksmiths make things like armor, swords, polearms, axes, plows... But wait! There's more! Look, over there... Aden Castle stands, proudly disregarding the laws of gravity. And you know why? Engineering! It would have collapsed a long time ago if it hadn't been for the efforts of the Black Anvil craftsmen.
And... This is just a rumor, but... They say that the giant golem the rebels used to evict the Human lords was made and sold by the Black Anvil. After all, who else could do something like that, right?
- + + + + - - - + \ No newline at end of file diff --git a/L2J_Mobius_5.5_EtinasFate/dist/game/data/html/default/30898.htm b/L2J_Mobius_5.5_EtinasFate/dist/game/data/html/default/30898.htm index 128bbc3e52..e090794162 100644 --- a/L2J_Mobius_5.5_EtinasFate/dist/game/data/html/default/30898.htm +++ b/L2J_Mobius_5.5_EtinasFate/dist/game/data/html/default/30898.htm @@ -1,12 +1,13 @@ Blacksmith Morning:
Welcome! If you have money, I have skills. What do you need, friend?
- - - + + + + + - - + \ No newline at end of file diff --git a/L2J_Mobius_5.5_EtinasFate/dist/game/data/html/default/31271.htm b/L2J_Mobius_5.5_EtinasFate/dist/game/data/html/default/31271.htm index 8f122ff5dc..c2183e6aba 100644 --- a/L2J_Mobius_5.5_EtinasFate/dist/game/data/html/default/31271.htm +++ b/L2J_Mobius_5.5_EtinasFate/dist/game/data/html/default/31271.htm @@ -1,12 +1,13 @@ Blacksmith Hilda:
Do you have any business for Hilda? Hmm? Hilda is busy, busy! She must make swords, plows, polearms, and armor! No visiting! Hilda doesn't visit, just works! Hilda doesn't mind watchers, but if someone talks while Hilda works, someone might get hit by hammer. In the face. Hard.
- - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/L2J_Mobius_5.5_EtinasFate/dist/game/data/html/default/31316.htm b/L2J_Mobius_5.5_EtinasFate/dist/game/data/html/default/31316.htm index a71c7dcfec..7c0124cbd9 100644 --- a/L2J_Mobius_5.5_EtinasFate/dist/game/data/html/default/31316.htm +++ b/L2J_Mobius_5.5_EtinasFate/dist/game/data/html/default/31316.htm @@ -1,13 +1,14 @@ Blacksmith Vincenz:
Welcome to the thunder forge! Hahaha! Noisy, isn't it?
Do you have anything that you like to craft? We do it all here! Order whatever you like. A pendant? A sword? A war golem? It's all the same to us.
- - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/L2J_Mobius_5.5_EtinasFate/dist/game/data/html/default/31960.htm b/L2J_Mobius_5.5_EtinasFate/dist/game/data/html/default/31960.htm index ec5f9b02a2..3cd19caec8 100644 --- a/L2J_Mobius_5.5_EtinasFate/dist/game/data/html/default/31960.htm +++ b/L2J_Mobius_5.5_EtinasFate/dist/game/data/html/default/31960.htm @@ -1,12 +1,13 @@ Blacksmith Buryun:
Welcome! Your timing is impeccable, I just finished up a three-day job repairing this here Claymore for Fred. A nasty piece of work that! What can I help you with?
- - - - - - - - + + + + + + + + + diff --git a/L2J_Mobius_5.5_EtinasFate/dist/game/data/scripts/handlers/bypasshandlers/EnsoulWindow.java b/L2J_Mobius_5.5_EtinasFate/dist/game/data/scripts/handlers/bypasshandlers/EnsoulWindow.java index ab17ea149a..3c78cde4b8 100644 --- a/L2J_Mobius_5.5_EtinasFate/dist/game/data/scripts/handlers/bypasshandlers/EnsoulWindow.java +++ b/L2J_Mobius_5.5_EtinasFate/dist/game/data/scripts/handlers/bypasshandlers/EnsoulWindow.java @@ -19,6 +19,7 @@ package handlers.bypasshandlers; import com.l2jmobius.gameserver.handler.IBypassHandler; import com.l2jmobius.gameserver.model.actor.L2Character; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; +import com.l2jmobius.gameserver.network.serverpackets.ensoul.ExShowEnsoulExtractionWindow; import com.l2jmobius.gameserver.network.serverpackets.ensoul.ExShowEnsoulWindow; /** @@ -29,6 +30,7 @@ public class EnsoulWindow implements IBypassHandler private static final String[] COMMANDS = { "show_ensoul_window", + "show_extract_ensoul_window" }; @Override @@ -39,8 +41,17 @@ public class EnsoulWindow implements IBypassHandler return false; } - activeChar.sendPacket(ExShowEnsoulWindow.STATIC_PACKET); - return true; + if (command.toLowerCase().startsWith(COMMANDS[0])) // show_ensoul_window + { + activeChar.sendPacket(ExShowEnsoulWindow.STATIC_PACKET); + return true; + } + else if (command.toLowerCase().startsWith(COMMANDS[1])) // show_extract_ensoul_window + { + activeChar.sendPacket(ExShowEnsoulExtractionWindow.STATIC_PACKET); + return true; + } + return false; } @Override diff --git a/L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/data/xml/impl/EnsoulData.java b/L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/data/xml/impl/EnsoulData.java index 239b582894..0881f3aaec 100644 --- a/L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/data/xml/impl/EnsoulData.java +++ b/L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/data/xml/impl/EnsoulData.java @@ -17,6 +17,8 @@ package com.l2jmobius.gameserver.data.xml.impl; import java.io.File; +import java.util.Collection; +import java.util.Collections; import java.util.EnumMap; import java.util.HashMap; import java.util.Map; @@ -122,6 +124,11 @@ public class EnsoulData implements IGameXmlReader parseReFee(feeNode, fee, 2); break; } + case "remove": + { + parseRemove(feeNode, fee); + break; + } } }); } @@ -143,6 +150,14 @@ public class EnsoulData implements IGameXmlReader fee.setResoul(index, new ItemHolder(id, count)); } + private void parseRemove(Node ensoulNode, EnsoulFee fee) + { + final NamedNodeMap attrs = ensoulNode.getAttributes(); + final int id = parseInteger(attrs, "itemId"); + final int count = parseInteger(attrs, "count"); + fee.addRemovalFee(new ItemHolder(id, count)); + } + private void parseOptions(Node ensoulNode) { final NamedNodeMap attrs = ensoulNode.getAttributes(); @@ -177,6 +192,12 @@ public class EnsoulData implements IGameXmlReader return fee != null ? fee.getResoul(index) : null; } + public Collection getRemovalFee(CrystalType type) + { + final EnsoulFee fee = _ensoulFees.get(type); + return fee != null ? fee.getRemovalFee() : Collections.emptyList(); + } + public EnsoulOption getOption(int id) { return _ensoulOptions.get(id); @@ -187,6 +208,24 @@ public class EnsoulData implements IGameXmlReader return _ensoulStones.get(id); } + public int getStone(int type, int optionId) + { + for (EnsoulStone stone : _ensoulStones.values()) + { + if (stone.getSlotType() == type) + { + for (int id : stone.getOptions()) + { + if (id == optionId) + { + return stone.getId(); + } + } + } + } + return 0; + } + /** * Gets the single instance of EnsoulData. * @return single instance of EnsoulData diff --git a/L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/model/ensoul/EnsoulFee.java b/L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/model/ensoul/EnsoulFee.java index f62baeedb2..ae71e99afa 100644 --- a/L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/model/ensoul/EnsoulFee.java +++ b/L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/model/ensoul/EnsoulFee.java @@ -16,6 +16,9 @@ */ package com.l2jmobius.gameserver.model.ensoul; +import java.util.ArrayList; +import java.util.List; + import com.l2jmobius.gameserver.model.holders.ItemHolder; import com.l2jmobius.gameserver.model.items.type.CrystalType; @@ -28,6 +31,7 @@ public class EnsoulFee private final ItemHolder[] _ensoulFee = new ItemHolder[3]; private final ItemHolder[] _resoulFees = new ItemHolder[3]; + private final List _removalFee = new ArrayList<>(); public EnsoulFee(CrystalType type) { @@ -49,6 +53,11 @@ public class EnsoulFee _resoulFees[index] = item; } + public void addRemovalFee(ItemHolder itemHolder) + { + _removalFee.add(itemHolder); + } + public ItemHolder getEnsoul(int index) { return _ensoulFee[index]; @@ -58,4 +67,9 @@ public class EnsoulFee { return _resoulFees[index]; } + + public List getRemovalFee() + { + return _removalFee; + } } diff --git a/L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/model/items/instance/L2ItemInstance.java b/L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/model/items/instance/L2ItemInstance.java index a2092facf2..dc62f94d94 100644 --- a/L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/model/items/instance/L2ItemInstance.java +++ b/L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/model/items/instance/L2ItemInstance.java @@ -2175,6 +2175,28 @@ public final class L2ItemInstance extends L2Object } } + public void removeSpecialAbility(int position, int type) + { + if (type == 1) + { + final EnsoulOption option = _ensoulOptions.get(position); + if (option != null) + { + removeSpecialAbility(option); + _ensoulOptions.remove(position); + } + } + else if (type == 2) + { + final EnsoulOption option = _ensoulSpecialOptions.get(position); + if (option != null) + { + removeSpecialAbility(option); + _ensoulSpecialOptions.remove(position); + } + } + } + public void clearSpecialAbilities() { _ensoulOptions.values().forEach(this::clearSpecialAbility); diff --git a/L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/network/ExIncomingPackets.java b/L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/network/ExIncomingPackets.java index 3c2ea735ff..83e93c9f52 100644 --- a/L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/network/ExIncomingPackets.java +++ b/L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/network/ExIncomingPackets.java @@ -68,6 +68,7 @@ import com.l2jmobius.gameserver.network.clientpackets.compound.RequestNewEnchant import com.l2jmobius.gameserver.network.clientpackets.crystalization.RequestCrystallizeEstimate; import com.l2jmobius.gameserver.network.clientpackets.crystalization.RequestCrystallizeItemCancel; import com.l2jmobius.gameserver.network.clientpackets.ensoul.RequestItemEnsoul; +import com.l2jmobius.gameserver.network.clientpackets.ensoul.RequestTryEnSoulExtraction; import com.l2jmobius.gameserver.network.clientpackets.faction.RequestUserFactionInfo; import com.l2jmobius.gameserver.network.clientpackets.friend.RequestFriendDetailInfo; import com.l2jmobius.gameserver.network.clientpackets.luckygame.RequestLuckyGamePlay; @@ -396,7 +397,7 @@ public enum ExIncomingPackets implements IIncomingPackets REQUEST_SSO_AUTHN_TOKEN(0x125, null, ConnectionState.IN_GAME), REQUEST_QUEUE_TICKET_LOGIN(0x126, null, ConnectionState.IN_GAME), REQUEST_BLOCK_MEMO_INFO(0x127, null, ConnectionState.IN_GAME), - REQUEST_TRY_EN_SOUL_EXTRACTION(0x128, null, ConnectionState.IN_GAME), + REQUEST_TRY_EN_SOUL_EXTRACTION(0x128, RequestTryEnSoulExtraction::new, ConnectionState.IN_GAME), REQUEST_RAIDBOSS_SPAWN_INFO(0x129, RequestRaidBossSpawnInfo::new, ConnectionState.IN_GAME), REQUEST_RAID_SERVER_INFO(0x12A, RequestRaidServerInfo::new, ConnectionState.IN_GAME), REQUEST_SHOW_AGIT_SIEGE_INFO(0x12B, null, ConnectionState.IN_GAME), diff --git a/L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/network/clientpackets/ensoul/RequestTryEnSoulExtraction.java b/L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/network/clientpackets/ensoul/RequestTryEnSoulExtraction.java new file mode 100644 index 0000000000..e0d7142936 --- /dev/null +++ b/L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/network/clientpackets/ensoul/RequestTryEnSoulExtraction.java @@ -0,0 +1,118 @@ +/* + * 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 . + */ +package com.l2jmobius.gameserver.network.clientpackets.ensoul; + +import java.util.Collection; + +import com.l2jmobius.commons.network.PacketReader; +import com.l2jmobius.gameserver.data.xml.impl.EnsoulData; +import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; +import com.l2jmobius.gameserver.model.ensoul.EnsoulOption; +import com.l2jmobius.gameserver.model.holders.ItemHolder; +import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance; +import com.l2jmobius.gameserver.network.L2GameClient; +import com.l2jmobius.gameserver.network.SystemMessageId; +import com.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket; +import com.l2jmobius.gameserver.network.serverpackets.InventoryUpdate; +import com.l2jmobius.gameserver.network.serverpackets.ensoul.ExEnSoulExtractionResult; + +/** + * @author Mobius + */ +public class RequestTryEnSoulExtraction implements IClientIncomingPacket +{ + private int _itemObjectId; + private int _type; + private int _position; + + @Override + public boolean read(L2GameClient client, PacketReader packet) + { + _itemObjectId = packet.readD(); + _type = packet.readC(); + _position = packet.readC() - 1; + return true; + } + + @Override + public void run(L2GameClient client) + { + L2PcInstance player = client.getActiveChar(); + if (player == null) + { + return; + } + + final L2ItemInstance item = player.getInventory().getItemByObjectId(_itemObjectId); + if (item == null) + { + return; + } + + EnsoulOption option = null; + if (_type == 1) + { + option = item.getSpecialAbility(_position); + } + if (_type == 2) + { + option = item.getAdditionalSpecialAbility(_position); + } + if (option == null) + { + return; + } + + final Collection removalFee = EnsoulData.getInstance().getRemovalFee(item.getItem().getCrystalType()); + if (removalFee.isEmpty()) + { + return; + } + + // Check if player has required items. + for (ItemHolder itemHolder : removalFee) + { + if (player.getInventory().getInventoryItemCount(itemHolder.getId(), -1) < itemHolder.getCount()) + { + player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT); + player.sendPacket(new ExEnSoulExtractionResult(false, item)); + return; + } + } + + // Take required items. + for (ItemHolder itemHolder : removalFee) + { + player.destroyItemByItemId("Rune Extract", itemHolder.getId(), itemHolder.getCount(), player, true); + } + + // Remove equipped rune. + item.removeSpecialAbility(_position, _type); + final InventoryUpdate iu = new InventoryUpdate(); + iu.addModifiedItem(item); + + // Add rune in player inventory. + final int runeId = EnsoulData.getInstance().getStone(_type, option.getId()); + if (runeId > 0) + { + iu.addItem(player.addItem("Rune Extract", runeId, 1, player, true)); + } + + player.sendInventoryUpdate(iu); + player.sendPacket(new ExEnSoulExtractionResult(true, item)); + } +} \ No newline at end of file diff --git a/L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/network/serverpackets/ensoul/ExEnSoulExtractionResult.java b/L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/network/serverpackets/ensoul/ExEnSoulExtractionResult.java new file mode 100644 index 0000000000..8b8b2e564b --- /dev/null +++ b/L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/network/serverpackets/ensoul/ExEnSoulExtractionResult.java @@ -0,0 +1,59 @@ +/* + * 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 . + */ +package com.l2jmobius.gameserver.network.serverpackets.ensoul; + +import com.l2jmobius.commons.network.PacketWriter; +import com.l2jmobius.gameserver.model.ensoul.EnsoulOption; +import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance; +import com.l2jmobius.gameserver.network.OutgoingPackets; +import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; + +/** + * @author Mobius + */ +public class ExEnSoulExtractionResult implements IClientOutgoingPacket +{ + private final boolean _success; + private final L2ItemInstance _item; + + public ExEnSoulExtractionResult(boolean success, L2ItemInstance item) + { + _success = success; + _item = item; + } + + @Override + public boolean write(PacketWriter packet) + { + OutgoingPackets.EX_ENSOUL_EXTRACTION_RESULT.writeId(packet); + packet.writeC(_success ? 1 : 0); + if (_success) + { + packet.writeC(_item.getSpecialAbilities().size()); + for (EnsoulOption option : _item.getSpecialAbilities()) + { + packet.writeD(option.getId()); + } + packet.writeC(_item.getAdditionalSpecialAbilities().size()); + for (EnsoulOption option : _item.getAdditionalSpecialAbilities()) + { + packet.writeD(option.getId()); + } + } + return true; + } +} diff --git a/L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/network/serverpackets/ensoul/ExShowEnsoulExtractionWindow.java b/L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/network/serverpackets/ensoul/ExShowEnsoulExtractionWindow.java new file mode 100644 index 0000000000..76ec17cfd2 --- /dev/null +++ b/L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/network/serverpackets/ensoul/ExShowEnsoulExtractionWindow.java @@ -0,0 +1,40 @@ +/* + * 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 . + */ +package com.l2jmobius.gameserver.network.serverpackets.ensoul; + +import com.l2jmobius.commons.network.PacketWriter; +import com.l2jmobius.gameserver.network.OutgoingPackets; +import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; + +/** + * @author Mobius + */ +public class ExShowEnsoulExtractionWindow implements IClientOutgoingPacket +{ + public static final ExShowEnsoulExtractionWindow STATIC_PACKET = new ExShowEnsoulExtractionWindow(); + + private ExShowEnsoulExtractionWindow() + { + } + + @Override + public boolean write(PacketWriter packet) + { + OutgoingPackets.EX_ENSOUL_EXTRACTION_SHOW.writeId(packet); + return true; + } +} \ No newline at end of file diff --git a/L2J_Mobius_6.0_Fafurion/dist/game/data/html/default/30298.htm b/L2J_Mobius_6.0_Fafurion/dist/game/data/html/default/30298.htm index 5480743a8a..f6ee0059be 100644 --- a/L2J_Mobius_6.0_Fafurion/dist/game/data/html/default/30298.htm +++ b/L2J_Mobius_6.0_Fafurion/dist/game/data/html/default/30298.htm @@ -1,12 +1,13 @@ Blacksmith Pinter:
Welcome. What brings you here, my friend? The name's Pinter. Yes, yes, I'm a Dwarf, and proud of it! My family has been blacksmiths in this town for three generations now! This place is in our blood!
- - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/L2J_Mobius_6.0_Fafurion/dist/game/data/html/default/30300.htm b/L2J_Mobius_6.0_Fafurion/dist/game/data/html/default/30300.htm index f0eaf38fd9..44a475cdd7 100644 --- a/L2J_Mobius_6.0_Fafurion/dist/game/data/html/default/30300.htm +++ b/L2J_Mobius_6.0_Fafurion/dist/game/data/html/default/30300.htm @@ -1,13 +1,14 @@ Blacksmith Pushkin:
Nice to meet you, wanderer!
Rupio and I have come all the way from the Black Anvil Guild to set up shop here. We haven't been here long, but we're gonna turn this place into the best forge in Giran! What can we do for you?
- - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/L2J_Mobius_6.0_Fafurion/dist/game/data/html/default/30317.htm b/L2J_Mobius_6.0_Fafurion/dist/game/data/html/default/30317.htm index 605b347831..c4013df238 100644 --- a/L2J_Mobius_6.0_Fafurion/dist/game/data/html/default/30317.htm +++ b/L2J_Mobius_6.0_Fafurion/dist/game/data/html/default/30317.htm @@ -1,12 +1,13 @@ Blacksmith Kluto:
Interested in seeing a genius at work, hmm? Just hang around!
- - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/L2J_Mobius_6.0_Fafurion/dist/game/data/html/default/30458.htm b/L2J_Mobius_6.0_Fafurion/dist/game/data/html/default/30458.htm index e608c357b1..1189600c08 100644 --- a/L2J_Mobius_6.0_Fafurion/dist/game/data/html/default/30458.htm +++ b/L2J_Mobius_6.0_Fafurion/dist/game/data/html/default/30458.htm @@ -1,13 +1,14 @@ Blacksmith Poitan:
Nice to meet you, traveler. Your timing is excellent! I just finished remodeling the workshop yesterday, so you're my first customer this season!
What can I do for you?
- - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/L2J_Mobius_6.0_Fafurion/dist/game/data/html/default/30678.htm b/L2J_Mobius_6.0_Fafurion/dist/game/data/html/default/30678.htm index d53b6550fe..5c34023a5b 100644 --- a/L2J_Mobius_6.0_Fafurion/dist/game/data/html/default/30678.htm +++ b/L2J_Mobius_6.0_Fafurion/dist/game/data/html/default/30678.htm @@ -2,13 +2,14 @@ Hmph, who are you? Why did you come here? Unless you have a case of Dwarven beer in that tiny saddle bag, I don't want to hear about it! Bahhh!
All I ever hear is heat this, cool that, get to the bellows, it's too hot, don't drop it! Argh! Makes me want to puke! It SO does not pay to be the low man on the totem pole! I want to MAKE something!
Armor, a blade... anything!
- - - - - - - - + + + + + + + + + - + \ No newline at end of file diff --git a/L2J_Mobius_6.0_Fafurion/dist/game/data/html/default/30688.htm b/L2J_Mobius_6.0_Fafurion/dist/game/data/html/default/30688.htm index 248cba686d..a8baa74ed6 100644 --- a/L2J_Mobius_6.0_Fafurion/dist/game/data/html/default/30688.htm +++ b/L2J_Mobius_6.0_Fafurion/dist/game/data/html/default/30688.htm @@ -1,10 +1,13 @@ Blacksmith Duning:
Hello there! Welcome to the forge! It's so exciting here. So many adventurers stopping by! Why just yesterday, I had lunch with a bounty hunter, tea with an informer, and supper with a ruins explorer! The stories! The romances! The adventures! Better than day time theater!
- - - - - - + + + + + + + + + \ No newline at end of file diff --git a/L2J_Mobius_6.0_Fafurion/dist/game/data/html/default/30846.htm b/L2J_Mobius_6.0_Fafurion/dist/game/data/html/default/30846.htm index f14051188a..16582e3faa 100644 --- a/L2J_Mobius_6.0_Fafurion/dist/game/data/html/default/30846.htm +++ b/L2J_Mobius_6.0_Fafurion/dist/game/data/html/default/30846.htm @@ -1,13 +1,14 @@ Blacksmith Wilbert:
What do we do here? Well, blacksmiths make things like armor, swords, polearms, axes, plows... But wait! There's more! Look, over there... Aden Castle stands, proudly disregarding the laws of gravity. And you know why? Engineering! It would have collapsed a long time ago if it hadn't been for the efforts of the Black Anvil craftsmen.
And... This is just a rumor, but... They say that the giant golem the rebels used to evict the Human lords was made and sold by the Black Anvil. After all, who else could do something like that, right?
- + + + + - - - + \ No newline at end of file diff --git a/L2J_Mobius_6.0_Fafurion/dist/game/data/html/default/30898.htm b/L2J_Mobius_6.0_Fafurion/dist/game/data/html/default/30898.htm index 128bbc3e52..e090794162 100644 --- a/L2J_Mobius_6.0_Fafurion/dist/game/data/html/default/30898.htm +++ b/L2J_Mobius_6.0_Fafurion/dist/game/data/html/default/30898.htm @@ -1,12 +1,13 @@ Blacksmith Morning:
Welcome! If you have money, I have skills. What do you need, friend?
- - - + + + + + - - + \ No newline at end of file diff --git a/L2J_Mobius_6.0_Fafurion/dist/game/data/html/default/31271.htm b/L2J_Mobius_6.0_Fafurion/dist/game/data/html/default/31271.htm index 8f122ff5dc..c2183e6aba 100644 --- a/L2J_Mobius_6.0_Fafurion/dist/game/data/html/default/31271.htm +++ b/L2J_Mobius_6.0_Fafurion/dist/game/data/html/default/31271.htm @@ -1,12 +1,13 @@ Blacksmith Hilda:
Do you have any business for Hilda? Hmm? Hilda is busy, busy! She must make swords, plows, polearms, and armor! No visiting! Hilda doesn't visit, just works! Hilda doesn't mind watchers, but if someone talks while Hilda works, someone might get hit by hammer. In the face. Hard.
- - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/L2J_Mobius_6.0_Fafurion/dist/game/data/html/default/31316.htm b/L2J_Mobius_6.0_Fafurion/dist/game/data/html/default/31316.htm index a71c7dcfec..7c0124cbd9 100644 --- a/L2J_Mobius_6.0_Fafurion/dist/game/data/html/default/31316.htm +++ b/L2J_Mobius_6.0_Fafurion/dist/game/data/html/default/31316.htm @@ -1,13 +1,14 @@ Blacksmith Vincenz:
Welcome to the thunder forge! Hahaha! Noisy, isn't it?
Do you have anything that you like to craft? We do it all here! Order whatever you like. A pendant? A sword? A war golem? It's all the same to us.
- - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/L2J_Mobius_6.0_Fafurion/dist/game/data/html/default/31960.htm b/L2J_Mobius_6.0_Fafurion/dist/game/data/html/default/31960.htm index ec5f9b02a2..3cd19caec8 100644 --- a/L2J_Mobius_6.0_Fafurion/dist/game/data/html/default/31960.htm +++ b/L2J_Mobius_6.0_Fafurion/dist/game/data/html/default/31960.htm @@ -1,12 +1,13 @@ Blacksmith Buryun:
Welcome! Your timing is impeccable, I just finished up a three-day job repairing this here Claymore for Fred. A nasty piece of work that! What can I help you with?
- - - - - - - - + + + + + + + + + diff --git a/L2J_Mobius_6.0_Fafurion/dist/game/data/scripts/handlers/bypasshandlers/EnsoulWindow.java b/L2J_Mobius_6.0_Fafurion/dist/game/data/scripts/handlers/bypasshandlers/EnsoulWindow.java index ab17ea149a..3c78cde4b8 100644 --- a/L2J_Mobius_6.0_Fafurion/dist/game/data/scripts/handlers/bypasshandlers/EnsoulWindow.java +++ b/L2J_Mobius_6.0_Fafurion/dist/game/data/scripts/handlers/bypasshandlers/EnsoulWindow.java @@ -19,6 +19,7 @@ package handlers.bypasshandlers; import com.l2jmobius.gameserver.handler.IBypassHandler; import com.l2jmobius.gameserver.model.actor.L2Character; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; +import com.l2jmobius.gameserver.network.serverpackets.ensoul.ExShowEnsoulExtractionWindow; import com.l2jmobius.gameserver.network.serverpackets.ensoul.ExShowEnsoulWindow; /** @@ -29,6 +30,7 @@ public class EnsoulWindow implements IBypassHandler private static final String[] COMMANDS = { "show_ensoul_window", + "show_extract_ensoul_window" }; @Override @@ -39,8 +41,17 @@ public class EnsoulWindow implements IBypassHandler return false; } - activeChar.sendPacket(ExShowEnsoulWindow.STATIC_PACKET); - return true; + if (command.toLowerCase().startsWith(COMMANDS[0])) // show_ensoul_window + { + activeChar.sendPacket(ExShowEnsoulWindow.STATIC_PACKET); + return true; + } + else if (command.toLowerCase().startsWith(COMMANDS[1])) // show_extract_ensoul_window + { + activeChar.sendPacket(ExShowEnsoulExtractionWindow.STATIC_PACKET); + return true; + } + return false; } @Override diff --git a/L2J_Mobius_6.0_Fafurion/java/com/l2jmobius/gameserver/data/xml/impl/EnsoulData.java b/L2J_Mobius_6.0_Fafurion/java/com/l2jmobius/gameserver/data/xml/impl/EnsoulData.java index 239b582894..0881f3aaec 100644 --- a/L2J_Mobius_6.0_Fafurion/java/com/l2jmobius/gameserver/data/xml/impl/EnsoulData.java +++ b/L2J_Mobius_6.0_Fafurion/java/com/l2jmobius/gameserver/data/xml/impl/EnsoulData.java @@ -17,6 +17,8 @@ package com.l2jmobius.gameserver.data.xml.impl; import java.io.File; +import java.util.Collection; +import java.util.Collections; import java.util.EnumMap; import java.util.HashMap; import java.util.Map; @@ -122,6 +124,11 @@ public class EnsoulData implements IGameXmlReader parseReFee(feeNode, fee, 2); break; } + case "remove": + { + parseRemove(feeNode, fee); + break; + } } }); } @@ -143,6 +150,14 @@ public class EnsoulData implements IGameXmlReader fee.setResoul(index, new ItemHolder(id, count)); } + private void parseRemove(Node ensoulNode, EnsoulFee fee) + { + final NamedNodeMap attrs = ensoulNode.getAttributes(); + final int id = parseInteger(attrs, "itemId"); + final int count = parseInteger(attrs, "count"); + fee.addRemovalFee(new ItemHolder(id, count)); + } + private void parseOptions(Node ensoulNode) { final NamedNodeMap attrs = ensoulNode.getAttributes(); @@ -177,6 +192,12 @@ public class EnsoulData implements IGameXmlReader return fee != null ? fee.getResoul(index) : null; } + public Collection getRemovalFee(CrystalType type) + { + final EnsoulFee fee = _ensoulFees.get(type); + return fee != null ? fee.getRemovalFee() : Collections.emptyList(); + } + public EnsoulOption getOption(int id) { return _ensoulOptions.get(id); @@ -187,6 +208,24 @@ public class EnsoulData implements IGameXmlReader return _ensoulStones.get(id); } + public int getStone(int type, int optionId) + { + for (EnsoulStone stone : _ensoulStones.values()) + { + if (stone.getSlotType() == type) + { + for (int id : stone.getOptions()) + { + if (id == optionId) + { + return stone.getId(); + } + } + } + } + return 0; + } + /** * Gets the single instance of EnsoulData. * @return single instance of EnsoulData diff --git a/L2J_Mobius_6.0_Fafurion/java/com/l2jmobius/gameserver/model/ensoul/EnsoulFee.java b/L2J_Mobius_6.0_Fafurion/java/com/l2jmobius/gameserver/model/ensoul/EnsoulFee.java index f62baeedb2..ae71e99afa 100644 --- a/L2J_Mobius_6.0_Fafurion/java/com/l2jmobius/gameserver/model/ensoul/EnsoulFee.java +++ b/L2J_Mobius_6.0_Fafurion/java/com/l2jmobius/gameserver/model/ensoul/EnsoulFee.java @@ -16,6 +16,9 @@ */ package com.l2jmobius.gameserver.model.ensoul; +import java.util.ArrayList; +import java.util.List; + import com.l2jmobius.gameserver.model.holders.ItemHolder; import com.l2jmobius.gameserver.model.items.type.CrystalType; @@ -28,6 +31,7 @@ public class EnsoulFee private final ItemHolder[] _ensoulFee = new ItemHolder[3]; private final ItemHolder[] _resoulFees = new ItemHolder[3]; + private final List _removalFee = new ArrayList<>(); public EnsoulFee(CrystalType type) { @@ -49,6 +53,11 @@ public class EnsoulFee _resoulFees[index] = item; } + public void addRemovalFee(ItemHolder itemHolder) + { + _removalFee.add(itemHolder); + } + public ItemHolder getEnsoul(int index) { return _ensoulFee[index]; @@ -58,4 +67,9 @@ public class EnsoulFee { return _resoulFees[index]; } + + public List getRemovalFee() + { + return _removalFee; + } } diff --git a/L2J_Mobius_6.0_Fafurion/java/com/l2jmobius/gameserver/model/items/instance/L2ItemInstance.java b/L2J_Mobius_6.0_Fafurion/java/com/l2jmobius/gameserver/model/items/instance/L2ItemInstance.java index a2092facf2..dc62f94d94 100644 --- a/L2J_Mobius_6.0_Fafurion/java/com/l2jmobius/gameserver/model/items/instance/L2ItemInstance.java +++ b/L2J_Mobius_6.0_Fafurion/java/com/l2jmobius/gameserver/model/items/instance/L2ItemInstance.java @@ -2175,6 +2175,28 @@ public final class L2ItemInstance extends L2Object } } + public void removeSpecialAbility(int position, int type) + { + if (type == 1) + { + final EnsoulOption option = _ensoulOptions.get(position); + if (option != null) + { + removeSpecialAbility(option); + _ensoulOptions.remove(position); + } + } + else if (type == 2) + { + final EnsoulOption option = _ensoulSpecialOptions.get(position); + if (option != null) + { + removeSpecialAbility(option); + _ensoulSpecialOptions.remove(position); + } + } + } + public void clearSpecialAbilities() { _ensoulOptions.values().forEach(this::clearSpecialAbility); diff --git a/L2J_Mobius_6.0_Fafurion/java/com/l2jmobius/gameserver/network/ExIncomingPackets.java b/L2J_Mobius_6.0_Fafurion/java/com/l2jmobius/gameserver/network/ExIncomingPackets.java index 3c2ea735ff..83e93c9f52 100644 --- a/L2J_Mobius_6.0_Fafurion/java/com/l2jmobius/gameserver/network/ExIncomingPackets.java +++ b/L2J_Mobius_6.0_Fafurion/java/com/l2jmobius/gameserver/network/ExIncomingPackets.java @@ -68,6 +68,7 @@ import com.l2jmobius.gameserver.network.clientpackets.compound.RequestNewEnchant import com.l2jmobius.gameserver.network.clientpackets.crystalization.RequestCrystallizeEstimate; import com.l2jmobius.gameserver.network.clientpackets.crystalization.RequestCrystallizeItemCancel; import com.l2jmobius.gameserver.network.clientpackets.ensoul.RequestItemEnsoul; +import com.l2jmobius.gameserver.network.clientpackets.ensoul.RequestTryEnSoulExtraction; import com.l2jmobius.gameserver.network.clientpackets.faction.RequestUserFactionInfo; import com.l2jmobius.gameserver.network.clientpackets.friend.RequestFriendDetailInfo; import com.l2jmobius.gameserver.network.clientpackets.luckygame.RequestLuckyGamePlay; @@ -396,7 +397,7 @@ public enum ExIncomingPackets implements IIncomingPackets REQUEST_SSO_AUTHN_TOKEN(0x125, null, ConnectionState.IN_GAME), REQUEST_QUEUE_TICKET_LOGIN(0x126, null, ConnectionState.IN_GAME), REQUEST_BLOCK_MEMO_INFO(0x127, null, ConnectionState.IN_GAME), - REQUEST_TRY_EN_SOUL_EXTRACTION(0x128, null, ConnectionState.IN_GAME), + REQUEST_TRY_EN_SOUL_EXTRACTION(0x128, RequestTryEnSoulExtraction::new, ConnectionState.IN_GAME), REQUEST_RAIDBOSS_SPAWN_INFO(0x129, RequestRaidBossSpawnInfo::new, ConnectionState.IN_GAME), REQUEST_RAID_SERVER_INFO(0x12A, RequestRaidServerInfo::new, ConnectionState.IN_GAME), REQUEST_SHOW_AGIT_SIEGE_INFO(0x12B, null, ConnectionState.IN_GAME), diff --git a/L2J_Mobius_6.0_Fafurion/java/com/l2jmobius/gameserver/network/clientpackets/ensoul/RequestTryEnSoulExtraction.java b/L2J_Mobius_6.0_Fafurion/java/com/l2jmobius/gameserver/network/clientpackets/ensoul/RequestTryEnSoulExtraction.java new file mode 100644 index 0000000000..e0d7142936 --- /dev/null +++ b/L2J_Mobius_6.0_Fafurion/java/com/l2jmobius/gameserver/network/clientpackets/ensoul/RequestTryEnSoulExtraction.java @@ -0,0 +1,118 @@ +/* + * 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 . + */ +package com.l2jmobius.gameserver.network.clientpackets.ensoul; + +import java.util.Collection; + +import com.l2jmobius.commons.network.PacketReader; +import com.l2jmobius.gameserver.data.xml.impl.EnsoulData; +import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; +import com.l2jmobius.gameserver.model.ensoul.EnsoulOption; +import com.l2jmobius.gameserver.model.holders.ItemHolder; +import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance; +import com.l2jmobius.gameserver.network.L2GameClient; +import com.l2jmobius.gameserver.network.SystemMessageId; +import com.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket; +import com.l2jmobius.gameserver.network.serverpackets.InventoryUpdate; +import com.l2jmobius.gameserver.network.serverpackets.ensoul.ExEnSoulExtractionResult; + +/** + * @author Mobius + */ +public class RequestTryEnSoulExtraction implements IClientIncomingPacket +{ + private int _itemObjectId; + private int _type; + private int _position; + + @Override + public boolean read(L2GameClient client, PacketReader packet) + { + _itemObjectId = packet.readD(); + _type = packet.readC(); + _position = packet.readC() - 1; + return true; + } + + @Override + public void run(L2GameClient client) + { + L2PcInstance player = client.getActiveChar(); + if (player == null) + { + return; + } + + final L2ItemInstance item = player.getInventory().getItemByObjectId(_itemObjectId); + if (item == null) + { + return; + } + + EnsoulOption option = null; + if (_type == 1) + { + option = item.getSpecialAbility(_position); + } + if (_type == 2) + { + option = item.getAdditionalSpecialAbility(_position); + } + if (option == null) + { + return; + } + + final Collection removalFee = EnsoulData.getInstance().getRemovalFee(item.getItem().getCrystalType()); + if (removalFee.isEmpty()) + { + return; + } + + // Check if player has required items. + for (ItemHolder itemHolder : removalFee) + { + if (player.getInventory().getInventoryItemCount(itemHolder.getId(), -1) < itemHolder.getCount()) + { + player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT); + player.sendPacket(new ExEnSoulExtractionResult(false, item)); + return; + } + } + + // Take required items. + for (ItemHolder itemHolder : removalFee) + { + player.destroyItemByItemId("Rune Extract", itemHolder.getId(), itemHolder.getCount(), player, true); + } + + // Remove equipped rune. + item.removeSpecialAbility(_position, _type); + final InventoryUpdate iu = new InventoryUpdate(); + iu.addModifiedItem(item); + + // Add rune in player inventory. + final int runeId = EnsoulData.getInstance().getStone(_type, option.getId()); + if (runeId > 0) + { + iu.addItem(player.addItem("Rune Extract", runeId, 1, player, true)); + } + + player.sendInventoryUpdate(iu); + player.sendPacket(new ExEnSoulExtractionResult(true, item)); + } +} \ No newline at end of file diff --git a/L2J_Mobius_6.0_Fafurion/java/com/l2jmobius/gameserver/network/serverpackets/ensoul/ExEnSoulExtractionResult.java b/L2J_Mobius_6.0_Fafurion/java/com/l2jmobius/gameserver/network/serverpackets/ensoul/ExEnSoulExtractionResult.java new file mode 100644 index 0000000000..8b8b2e564b --- /dev/null +++ b/L2J_Mobius_6.0_Fafurion/java/com/l2jmobius/gameserver/network/serverpackets/ensoul/ExEnSoulExtractionResult.java @@ -0,0 +1,59 @@ +/* + * 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 . + */ +package com.l2jmobius.gameserver.network.serverpackets.ensoul; + +import com.l2jmobius.commons.network.PacketWriter; +import com.l2jmobius.gameserver.model.ensoul.EnsoulOption; +import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance; +import com.l2jmobius.gameserver.network.OutgoingPackets; +import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; + +/** + * @author Mobius + */ +public class ExEnSoulExtractionResult implements IClientOutgoingPacket +{ + private final boolean _success; + private final L2ItemInstance _item; + + public ExEnSoulExtractionResult(boolean success, L2ItemInstance item) + { + _success = success; + _item = item; + } + + @Override + public boolean write(PacketWriter packet) + { + OutgoingPackets.EX_ENSOUL_EXTRACTION_RESULT.writeId(packet); + packet.writeC(_success ? 1 : 0); + if (_success) + { + packet.writeC(_item.getSpecialAbilities().size()); + for (EnsoulOption option : _item.getSpecialAbilities()) + { + packet.writeD(option.getId()); + } + packet.writeC(_item.getAdditionalSpecialAbilities().size()); + for (EnsoulOption option : _item.getAdditionalSpecialAbilities()) + { + packet.writeD(option.getId()); + } + } + return true; + } +} diff --git a/L2J_Mobius_6.0_Fafurion/java/com/l2jmobius/gameserver/network/serverpackets/ensoul/ExShowEnsoulExtractionWindow.java b/L2J_Mobius_6.0_Fafurion/java/com/l2jmobius/gameserver/network/serverpackets/ensoul/ExShowEnsoulExtractionWindow.java new file mode 100644 index 0000000000..76ec17cfd2 --- /dev/null +++ b/L2J_Mobius_6.0_Fafurion/java/com/l2jmobius/gameserver/network/serverpackets/ensoul/ExShowEnsoulExtractionWindow.java @@ -0,0 +1,40 @@ +/* + * 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 . + */ +package com.l2jmobius.gameserver.network.serverpackets.ensoul; + +import com.l2jmobius.commons.network.PacketWriter; +import com.l2jmobius.gameserver.network.OutgoingPackets; +import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; + +/** + * @author Mobius + */ +public class ExShowEnsoulExtractionWindow implements IClientOutgoingPacket +{ + public static final ExShowEnsoulExtractionWindow STATIC_PACKET = new ExShowEnsoulExtractionWindow(); + + private ExShowEnsoulExtractionWindow() + { + } + + @Override + public boolean write(PacketWriter packet) + { + OutgoingPackets.EX_ENSOUL_EXTRACTION_SHOW.writeId(packet); + return true; + } +} \ No newline at end of file