Support for agathion item slots.

This commit is contained in:
MobiusDev
2018-07-29 00:48:58 +00:00
parent a1361bbb8b
commit 67465014b0
15 changed files with 180 additions and 32 deletions

View File

@@ -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

View File

@@ -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;

View File

@@ -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)
{

View File

@@ -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();

View File

@@ -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'"))
{

View File

@@ -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;

View File

@@ -248,6 +248,9 @@ public enum Stats
// Brooches
BROOCH_JEWELS("broochJewels"),
// Agathions
AGATHION_SLOTS("agathionSlots"),
// Summon Points
MAX_SUMMON_POINTS("summonPoints"),

View File

@@ -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())

View File

@@ -126,7 +126,7 @@ public abstract class AbstractItemPacket extends AbstractMaskPacket<ItemListType
packet.writeC(0x01); // TODO : Find me
packet.writeD(item.getMana());
packet.writeD(item.getTime());
packet.writeC(0x01); // GOD Item enabled = 1 disabled (red) = 0
packet.writeC(item.isAvailable() ? 1 : 0); // GOD Item enabled = 1 disabled (red) = 0
packet.writeC(0x00); // 140 protocol
packet.writeC(0x00); // 140 protocol
if (containsMask(mask, ItemListType.AUGMENT_BONUS))

View File

@@ -49,6 +49,43 @@ public class CharSelectionInfo implements IClientOutgoingPacket
private int _activeId;
private final CharSelectInfoPackage[] _characterPackages;
private static final int[] PAPERDOLL_ORDER = new int[]
{
Inventory.PAPERDOLL_UNDER,
Inventory.PAPERDOLL_REAR,
Inventory.PAPERDOLL_LEAR,
Inventory.PAPERDOLL_NECK,
Inventory.PAPERDOLL_RFINGER,
Inventory.PAPERDOLL_LFINGER,
Inventory.PAPERDOLL_HEAD,
Inventory.PAPERDOLL_RHAND,
Inventory.PAPERDOLL_LHAND,
Inventory.PAPERDOLL_GLOVES,
Inventory.PAPERDOLL_CHEST,
Inventory.PAPERDOLL_LEGS,
Inventory.PAPERDOLL_FEET,
Inventory.PAPERDOLL_CLOAK,
Inventory.PAPERDOLL_RHAND,
Inventory.PAPERDOLL_HAIR,
Inventory.PAPERDOLL_HAIR2,
Inventory.PAPERDOLL_RBRACELET,
Inventory.PAPERDOLL_LBRACELET,
Inventory.PAPERDOLL_DECO1,
Inventory.PAPERDOLL_DECO2,
Inventory.PAPERDOLL_DECO3,
Inventory.PAPERDOLL_DECO4,
Inventory.PAPERDOLL_DECO5,
Inventory.PAPERDOLL_DECO6,
Inventory.PAPERDOLL_BELT,
Inventory.PAPERDOLL_BROOCH,
Inventory.PAPERDOLL_BROOCH_JEWEL1,
Inventory.PAPERDOLL_BROOCH_JEWEL2,
Inventory.PAPERDOLL_BROOCH_JEWEL3,
Inventory.PAPERDOLL_BROOCH_JEWEL4,
Inventory.PAPERDOLL_BROOCH_JEWEL5,
Inventory.PAPERDOLL_BROOCH_JEWEL6
};
private static final int[] PAPERDOLL_ORDER_VISUAL_ID = new int[]
{
Inventory.PAPERDOLL_RHAND,
@@ -415,6 +452,12 @@ public class CharSelectionInfo implements IClientOutgoingPacket
return charInfopackage;
}
@Override
public int[] getPaperdollOrder()
{
return PAPERDOLL_ORDER;
}
@Override
public int[] getPaperdollOrderVisualId()
{

View File

@@ -52,6 +52,11 @@ public interface IClientOutgoingPacket extends IOutgoingPacket
Inventory.PAPERDOLL_HAIR2,
Inventory.PAPERDOLL_RBRACELET,
Inventory.PAPERDOLL_LBRACELET,
Inventory.PAPERDOLL_AGATHION1,
Inventory.PAPERDOLL_AGATHION2,
Inventory.PAPERDOLL_AGATHION3,
Inventory.PAPERDOLL_AGATHION4,
Inventory.PAPERDOLL_AGATHION5,
Inventory.PAPERDOLL_DECO1,
Inventory.PAPERDOLL_DECO2,
Inventory.PAPERDOLL_DECO3,
@@ -66,7 +71,6 @@ public interface IClientOutgoingPacket extends IOutgoingPacket
Inventory.PAPERDOLL_BROOCH_JEWEL4,
Inventory.PAPERDOLL_BROOCH_JEWEL5,
Inventory.PAPERDOLL_BROOCH_JEWEL6
};
int[] PAPERDOLL_ORDER_AUGMENT = new int[]

View File

@@ -328,7 +328,10 @@ public class UserInfo extends AbstractMaskPacket<UserInfoType>
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))