From 67465014b01a0e919c4834de77fdd62d5e55708e Mon Sep 17 00:00:00 2001
From: MobiusDev <8391001+MobiusDevelopment@users.noreply.github.com>
Date: Sun, 29 Jul 2018 00:48:58 +0000
Subject: [PATCH] Support for agathion item slots.
---
.../scripts/handlers/EffectMasterHandler.java | 1 +
.../handlers/effecthandlers/AgathionSlot.java | 31 +++++++
.../game/data/stats/skills/documentation.txt | 1 +
.../gameserver/datatables/ItemTable.java | 1 +
.../gameserver/enums/InventorySlot.java | 12 +--
.../gameserver/model/actor/stat/PcStat.java | 9 ++
.../model/itemcontainer/Inventory.java | 86 ++++++++++++++-----
.../model/itemcontainer/PcInventory.java | 2 +-
.../gameserver/model/items/L2Item.java | 1 +
.../gameserver/model/stats/Stats.java | 3 +
.../network/clientpackets/UseItem.java | 9 ++
.../serverpackets/AbstractItemPacket.java | 2 +-
.../serverpackets/CharSelectionInfo.java | 43 ++++++++++
.../serverpackets/IClientOutgoingPacket.java | 6 +-
.../network/serverpackets/UserInfo.java | 5 +-
15 files changed, 180 insertions(+), 32 deletions(-)
create mode 100644 L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/effecthandlers/AgathionSlot.java
diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/EffectMasterHandler.java b/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/EffectMasterHandler.java
index c5a80cc065..cac79b558f 100644
--- a/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/EffectMasterHandler.java
+++ b/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/EffectMasterHandler.java
@@ -39,6 +39,7 @@ public final class EffectMasterHandler
EffectHandler.getInstance().registerHandler("AddHate", AddHate::new);
EffectHandler.getInstance().registerHandler("AddSkillBySkill", AddSkillBySkill::new);
EffectHandler.getInstance().registerHandler("AddTeleportBookmarkSlot", AddTeleportBookmarkSlot::new);
+ EffectHandler.getInstance().registerHandler("AgathionSlot", AgathionSlot::new);
EffectHandler.getInstance().registerHandler("AreaDamage", AreaDamage::new);
EffectHandler.getInstance().registerHandler("AttackAttribute", AttackAttribute::new);
EffectHandler.getInstance().registerHandler("AttackAttributeAdd", AttackAttributeAdd::new);
diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/effecthandlers/AgathionSlot.java b/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/effecthandlers/AgathionSlot.java
new file mode 100644
index 0000000000..fca05829b0
--- /dev/null
+++ b/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/effecthandlers/AgathionSlot.java
@@ -0,0 +1,31 @@
+/*
+ * 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 handlers.effecthandlers;
+
+import com.l2jmobius.gameserver.model.StatsSet;
+import com.l2jmobius.gameserver.model.stats.Stats;
+
+/**
+ * @author Mobius
+ */
+public class AgathionSlot extends AbstractStatAddEffect
+{
+ public AgathionSlot(StatsSet params)
+ {
+ super(params, Stats.AGATHION_SLOTS);
+ }
+}
diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/stats/skills/documentation.txt b/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/stats/skills/documentation.txt
index 995d512e9a..e9444ba234 100644
--- a/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/stats/skills/documentation.txt
+++ b/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/stats/skills/documentation.txt
@@ -8,6 +8,7 @@ Accuracy: P. Accuracy stat.
AddHate: Instant effect that increases target's hate towards you.
AddSkillBySkill: Add skill when other skill already exists. (l2jmobius)
AddTeleportBookmarkSlot: Instant effect that increases the amount of My Teleport slots.
+AgathionSlot: Agathion slot modifier. (l2jmobius)
AreaDamage: Topography (Danger Zone) resistance stat.
AttackAttribute: Stat that increases specific attack attribute.
AttackAttributeAdd: Stat that increases all attack attribute.
diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/datatables/ItemTable.java b/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/datatables/ItemTable.java
index c8f34ed812..2f5fde4fb3 100644
--- a/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/datatables/ItemTable.java
+++ b/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/datatables/ItemTable.java
@@ -95,6 +95,7 @@ public class ItemTable
SLOTS.put("babypet", L2Item.SLOT_BABYPET);
SLOTS.put("brooch", L2Item.SLOT_BROOCH);
SLOTS.put("brooch_jewel", L2Item.SLOT_BROOCH_JEWEL);
+ SLOTS.put("agathion", L2Item.SLOT_AGATHION);
SLOTS.put("none", L2Item.SLOT_NONE);
// retail compatibility
diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/enums/InventorySlot.java b/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/enums/InventorySlot.java
index 004ef691e4..6896867a67 100644
--- a/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/enums/InventorySlot.java
+++ b/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/enums/InventorySlot.java
@@ -43,6 +43,11 @@ public enum InventorySlot implements IUpdateTypeComponent
HAIR2(Inventory.PAPERDOLL_HAIR2),
RBRACELET(Inventory.PAPERDOLL_RBRACELET),
LBRACELET(Inventory.PAPERDOLL_LBRACELET),
+ AGATHION1(Inventory.PAPERDOLL_AGATHION1),
+ AGATHION2(Inventory.PAPERDOLL_AGATHION2),
+ AGATHION3(Inventory.PAPERDOLL_AGATHION3),
+ AGATHION4(Inventory.PAPERDOLL_AGATHION4),
+ AGATHION5(Inventory.PAPERDOLL_AGATHION5),
DECO1(Inventory.PAPERDOLL_DECO1),
DECO2(Inventory.PAPERDOLL_DECO2),
DECO3(Inventory.PAPERDOLL_DECO3),
@@ -56,12 +61,7 @@ public enum InventorySlot implements IUpdateTypeComponent
BROOCH_JEWEL3(Inventory.PAPERDOLL_BROOCH_JEWEL3),
BROOCH_JEWEL4(Inventory.PAPERDOLL_BROOCH_JEWEL4),
BROOCH_JEWEL5(Inventory.PAPERDOLL_BROOCH_JEWEL5),
- BROOCH_JEWEL6(Inventory.PAPERDOLL_BROOCH_JEWEL6),
- AGATION1(32), // new 140
- AGATION2(33), // new 140
- AGATION3(34), // new 140
- AGATION4(35), // new 140
- AGATION5(36); // new 140
+ BROOCH_JEWEL6(Inventory.PAPERDOLL_BROOCH_JEWEL6);
private final int _paperdollSlot;
diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/model/actor/stat/PcStat.java b/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/model/actor/stat/PcStat.java
index e14c57783d..5850b53b3d 100644
--- a/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/model/actor/stat/PcStat.java
+++ b/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/model/actor/stat/PcStat.java
@@ -666,6 +666,15 @@ public class PcStat extends PlayableStat
return (int) getValue(Stats.BROOCH_JEWELS, 0);
}
+ /**
+ * Gets the maximum agathion count.
+ * @return the maximum agathion count
+ */
+ public int getAgathionSlots()
+ {
+ return (int) getValue(Stats.AGATHION_SLOTS, 0);
+ }
+
@Override
protected void onRecalculateStats(boolean broadcast)
{
diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/model/itemcontainer/Inventory.java b/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/model/itemcontainer/Inventory.java
index 224a7409ef..f50560ce09 100644
--- a/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/model/itemcontainer/Inventory.java
+++ b/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/model/itemcontainer/Inventory.java
@@ -98,26 +98,26 @@ public abstract class Inventory extends ItemContainer
public static final int PAPERDOLL_LFINGER = 14;
public static final int PAPERDOLL_LBRACELET = 15;
public static final int PAPERDOLL_RBRACELET = 16;
- public static final int PAPERDOLL_DECO1 = 17;
- public static final int PAPERDOLL_DECO2 = 18;
- public static final int PAPERDOLL_DECO3 = 19;
- public static final int PAPERDOLL_DECO4 = 20;
- public static final int PAPERDOLL_DECO5 = 21;
- public static final int PAPERDOLL_DECO6 = 22;
- public static final int PAPERDOLL_CLOAK = 23;
- public static final int PAPERDOLL_BELT = 24;
- public static final int PAPERDOLL_BROOCH = 25;
- public static final int PAPERDOLL_BROOCH_JEWEL1 = 26;
- public static final int PAPERDOLL_BROOCH_JEWEL2 = 27;
- public static final int PAPERDOLL_BROOCH_JEWEL3 = 28;
- public static final int PAPERDOLL_BROOCH_JEWEL4 = 29;
- public static final int PAPERDOLL_BROOCH_JEWEL5 = 30;
- public static final int PAPERDOLL_BROOCH_JEWEL6 = 31;
- public static final int PAPERDOLL_AGATION1 = 32; // new 140
- public static final int PAPERDOLL_AGATION2 = 33; // new 140
- public static final int PAPERDOLL_AGATION3 = 34; // new 140
- public static final int PAPERDOLL_AGATION4 = 35; // new 140
- public static final int PAPERDOLL_AGATION5 = 36; // new 140
+ public static final int PAPERDOLL_AGATHION1 = 17;
+ public static final int PAPERDOLL_AGATHION2 = 18;
+ public static final int PAPERDOLL_AGATHION3 = 19;
+ public static final int PAPERDOLL_AGATHION4 = 20;
+ public static final int PAPERDOLL_AGATHION5 = 21;
+ public static final int PAPERDOLL_DECO1 = 22;
+ public static final int PAPERDOLL_DECO2 = 23;
+ public static final int PAPERDOLL_DECO3 = 24;
+ public static final int PAPERDOLL_DECO4 = 25;
+ public static final int PAPERDOLL_DECO5 = 26;
+ public static final int PAPERDOLL_DECO6 = 27;
+ public static final int PAPERDOLL_CLOAK = 28;
+ public static final int PAPERDOLL_BELT = 29;
+ public static final int PAPERDOLL_BROOCH = 30;
+ public static final int PAPERDOLL_BROOCH_JEWEL1 = 31;
+ public static final int PAPERDOLL_BROOCH_JEWEL2 = 32;
+ public static final int PAPERDOLL_BROOCH_JEWEL3 = 33;
+ public static final int PAPERDOLL_BROOCH_JEWEL4 = 34;
+ public static final int PAPERDOLL_BROOCH_JEWEL5 = 35;
+ public static final int PAPERDOLL_BROOCH_JEWEL6 = 36;
public static final int PAPERDOLL_TOTALSLOTS = 37;
// Speed percentage mods
@@ -1728,6 +1728,11 @@ public abstract class Inventory extends ItemContainer
equipBroochJewel(item);
break;
}
+ case L2Item.SLOT_AGATHION:
+ {
+ equipAgathion(item);
+ break;
+ }
default:
{
LOGGER.warning("Unknown body slot " + targetSlot + " for Item ID: " + item.getId());
@@ -1877,7 +1882,7 @@ public abstract class Inventory extends ItemContainer
{
if (getPaperdollItemId(i) == item.getId())
{
- // overwtite
+ // overwrite
setPaperdollItem(i, item);
return;
}
@@ -1915,7 +1920,7 @@ public abstract class Inventory extends ItemContainer
{
if ((_paperdoll[i] != null) && (getPaperdollItemId(i) == item.getId()))
{
- // overwtite
+ // overwrite
setPaperdollItem(i, item);
return;
}
@@ -1935,6 +1940,43 @@ public abstract class Inventory extends ItemContainer
setPaperdollItem(PAPERDOLL_BROOCH_JEWEL1, item);
}
+ public int getAgathionSlots()
+ {
+ return getOwner().getActingPlayer().getStat().getAgathionSlots();
+ }
+
+ private void equipAgathion(L2ItemInstance item)
+ {
+ if (getAgathionSlots() == 0)
+ {
+ return;
+ }
+
+ // find same (or incompatible) agathion type
+ for (int i = PAPERDOLL_AGATHION1; i < (PAPERDOLL_AGATHION1 + getAgathionSlots()); i++)
+ {
+ if ((_paperdoll[i] != null) && (getPaperdollItemId(i) == item.getId()))
+ {
+ // overwrite
+ setPaperdollItem(i, item);
+ return;
+ }
+ }
+
+ // no free slot found - put on first free
+ for (int i = PAPERDOLL_AGATHION1; i < (PAPERDOLL_AGATHION1 + getAgathionSlots()); i++)
+ {
+ if (_paperdoll[i] == null)
+ {
+ setPaperdollItem(i, item);
+ return;
+ }
+ }
+
+ // no free slots - put on first
+ setPaperdollItem(PAPERDOLL_AGATHION1, item);
+ }
+
public boolean canEquipCloak()
{
return getOwner().getActingPlayer().getStat().canEquipCloak();
diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/model/itemcontainer/PcInventory.java b/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/model/itemcontainer/PcInventory.java
index 9228d151c2..b36280a83c 100644
--- a/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/model/itemcontainer/PcInventory.java
+++ b/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/model/itemcontainer/PcInventory.java
@@ -737,7 +737,7 @@ public class PcInventory extends Inventory
public static int[][] restoreVisibleInventory(int objectId)
{
- final int[][] paperdoll = new int[33][4];
+ final int[][] paperdoll = new int[Inventory.PAPERDOLL_TOTALSLOTS][4];
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement statement2 = con.prepareStatement("SELECT object_id,item_id,loc_data,enchant_level FROM items WHERE owner_id=? AND loc='PAPERDOLL'"))
{
diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/model/items/L2Item.java b/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/model/items/L2Item.java
index 2229a95622..2614f9fd41 100644
--- a/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/model/items/L2Item.java
+++ b/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/model/items/L2Item.java
@@ -111,6 +111,7 @@ public abstract class L2Item extends ListenersContainer implements IIdentifiable
public static final int SLOT_BELT = 0x10000000;
public static final int SLOT_BROOCH = 0x20000000;
public static final int SLOT_BROOCH_JEWEL = 0x40000000;
+ public static final int SLOT_AGATHION = 0x80000000;
public static final int SLOT_WOLF = -100;
public static final int SLOT_HATCHLING = -101;
diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/model/stats/Stats.java b/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/model/stats/Stats.java
index 097a3f3ee1..bdeec065c3 100644
--- a/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/model/stats/Stats.java
+++ b/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/model/stats/Stats.java
@@ -248,6 +248,9 @@ public enum Stats
// Brooches
BROOCH_JEWELS("broochJewels"),
+ // Agathions
+ AGATHION_SLOTS("agathionSlots"),
+
// Summon Points
MAX_SUMMON_POINTS("summonPoints"),
diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java b/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java
index d7e1ef6419..7c24354f3f 100644
--- a/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java
+++ b/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java
@@ -239,6 +239,15 @@ public final class UseItem implements IClientIncomingPacket
}
break;
}
+ case L2Item.SLOT_AGATHION:
+ {
+ if (!item.isEquipped() && (activeChar.getInventory().getAgathionSlots() == 0))
+ {
+ activeChar.sendPacket(SystemMessageId.YOU_DO_NOT_MEET_THE_REQUIRED_CONDITION_TO_EQUIP_THAT_ITEM);
+ return;
+ }
+ break;
+ }
}
if (activeChar.isCastingNow())
diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/network/serverpackets/AbstractItemPacket.java b/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/network/serverpackets/AbstractItemPacket.java
index e2e4db4e43..d948355baa 100644
--- a/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/network/serverpackets/AbstractItemPacket.java
+++ b/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/network/serverpackets/AbstractItemPacket.java
@@ -126,7 +126,7 @@ public abstract class AbstractItemPacket extends AbstractMaskPacket
packet.writeC(_activeChar.getTeam().getId());
packet.writeC(0x00);
packet.writeC(0x00);
- packet.writeD(0x00);
+ packet.writeC(0x00);
+ packet.writeC(0x00);
+ packet.writeC(_activeChar.getInventory().getAgathionSlots());
+ packet.writeC(_activeChar.getInventory().getAgathionSlots() - 1);
}
if (containsMask(UserInfoType.MOVEMENTS))