Jump to content
  • 0

Adapting Anarchy's Dressme to L2JMobius


Question

Posted

Hello maxcheaters! We are a small group of friends that are developing a closed roleplay community, and want to adapt some customs to our L2JMobius free pack (currently we are using Classic Zaken 2.1). We have currently adapted a Skin Manager and L2JDevs ModEngine, but we are having some problem with An4rchy's Dressme. So far, te code is "working". Panel works, get target appearance works, but only for other players. That's surely because our CharInfo implementation is ok, but the UserInfo is messed up. That's something that we can usually fix on our end but...

 

We have realised that the UserInfo in L2JMobius is pretty different from the one present on aCIs or Frozen, and that the appareance of the player is controlled by ExUserInfoEquipSlot (I guess?). We have currently tried some approachs to solve this, none of them with success. This is our last try:

 

/*
 * This file is part of the L2J Mobius project.
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
package org.l2jmobius.gameserver.network.serverpackets;

import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.enums.InventorySlot;
import org.l2jmobius.gameserver.model.VariationInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.itemcontainer.PlayerInventory;
import org.l2jmobius.gameserver.network.OutgoingPackets;

/**
 * @author Sdw
 */
public class ExUserInfoEquipSlot extends AbstractMaskPacket<InventorySlot>
{
	private final PlayerInstance _player;
	
	private final byte[] _masks = new byte[]
	{
		(byte) 0x00,
		(byte) 0x00,
		(byte) 0x00,
		(byte) 0x00,
		(byte) 0x00
	};
	
	public ExUserInfoEquipSlot(PlayerInstance player)
	{
		this(player, true);
	}
	
	public ExUserInfoEquipSlot(PlayerInstance player, boolean addAll)
	{
		_player = player;
		
		if (addAll)
		{
			addComponentType(InventorySlot.values());
		}
	}
	
	@Override
	protected byte[] getMasks()
	{
		return _masks;
	}
	
	@Override
	public boolean write(PacketWriter packet)
	{
		OutgoingPackets.EX_USER_INFO_EQUIP_SLOT.writeId(packet);
		
		packet.writeD(_player.getObjectId());
		packet.writeH(InventorySlot.values().length);
		packet.writeB(_masks);
		
		final PlayerInventory inventory = _player.getInventory();
		for (InventorySlot slot : InventorySlot.values())
		{
			if (containsMask(slot))
			{
				if (!_player.isDressMeEnabled())
				{
					final VariationInstance augment = inventory.getPaperdollAugmentation(slot.getSlot());
					packet.writeH(22); // 10 + 4 * 3
					packet.writeD(inventory.getPaperdollObjectId(slot.getSlot()));
					packet.writeD(inventory.getPaperdollItemId(slot.getSlot()));
					packet.writeD(augment != null ? augment.getOption1Id() : 0);
					packet.writeD(augment != null ? augment.getOption2Id() : 0);
					packet.writeD(inventory.getPaperdollItemVisualId(slot.getSlot()));
				}
				else
				{
					switch (slot)
					{
						case RHAND:
							final VariationInstance augmentRHand = inventory.getPaperdollAugmentation(slot.getSlot());
							packet.writeH(22); // 10 + 4 * 3
							packet.writeD(_player.getDressMeData() == null ? inventory.getPaperdollObjectId(slot.getSlot()) : (_player.getDressMeData().getWeapId() == 0 ? inventory.getPaperdollObjectId(slot.getSlot()) : _player.getDressMeData().getWeapId()));
							packet.writeD(_player.getDressMeData() == null ? inventory.getPaperdollItemId(slot.getSlot()) : (_player.getDressMeData().getWeapId() == 0 ? inventory.getPaperdollItemId(slot.getSlot()) : _player.getDressMeData().getWeapId()));
							packet.writeD(augmentRHand != null ? augmentRHand.getOption1Id() : 0);
							packet.writeD(augmentRHand != null ? augmentRHand.getOption2Id() : 0);
							packet.writeD(_player.getDressMeData() == null ? inventory.getPaperdollItemVisualId(slot.getSlot()) : (_player.getDressMeData().getWeapId() == 0 ? inventory.getPaperdollItemVisualId(slot.getSlot()) : _player.getDressMeData().getWeapId()));
							break;
						case GLOVES:
							final VariationInstance augmentGloves = inventory.getPaperdollAugmentation(slot.getSlot());
							packet.writeH(22); // 10 + 4 * 3
							packet.writeD(_player.getDressMeData() == null ? inventory.getPaperdollObjectId(slot.getSlot()) : (_player.getDressMeData().getGlovesId() == 0 ? inventory.getPaperdollObjectId(slot.getSlot()) : _player.getDressMeData().getGlovesId()));
							packet.writeD(_player.getDressMeData() == null ? inventory.getPaperdollItemId(slot.getSlot()) : (_player.getDressMeData().getGlovesId() == 0 ? inventory.getPaperdollItemId(slot.getSlot()) : _player.getDressMeData().getGlovesId()));
							packet.writeD(augmentGloves != null ? augmentGloves.getOption1Id() : 0);
							packet.writeD(augmentGloves != null ? augmentGloves.getOption2Id() : 0);
							packet.writeD(_player.getDressMeData() == null ? inventory.getPaperdollItemVisualId(slot.getSlot()) : (_player.getDressMeData().getGlovesId() == 0 ? inventory.getPaperdollItemVisualId(slot.getSlot()) : _player.getDressMeData().getGlovesId()));
							break;
						case CHEST:
							final VariationInstance augmentChest = inventory.getPaperdollAugmentation(slot.getSlot());
							packet.writeH(22); // 10 + 4 * 3
							packet.writeD(_player.getDressMeData() == null ? inventory.getPaperdollObjectId(slot.getSlot()) : (_player.getDressMeData().getChestId() == 0 ? inventory.getPaperdollObjectId(slot.getSlot()) : _player.getDressMeData().getChestId()));
							packet.writeD(_player.getDressMeData() == null ? inventory.getPaperdollItemId(slot.getSlot()) : (_player.getDressMeData().getChestId() == 0 ? inventory.getPaperdollItemId(slot.getSlot()) : _player.getDressMeData().getChestId()));
							packet.writeD(augmentChest != null ? augmentChest.getOption1Id() : 0);
							packet.writeD(augmentChest != null ? augmentChest.getOption2Id() : 0);
							packet.writeD(_player.getDressMeData() == null ? inventory.getPaperdollItemVisualId(slot.getSlot()) : (_player.getDressMeData().getChestId() == 0 ? inventory.getPaperdollItemVisualId(slot.getSlot()) : _player.getDressMeData().getChestId()));
							break;
						case LEGS:
							final VariationInstance augmentLegs = inventory.getPaperdollAugmentation(slot.getSlot());
							packet.writeH(22); // 10 + 4 * 3
							packet.writeD(_player.getDressMeData() == null ? inventory.getPaperdollObjectId(slot.getSlot()) : (_player.getDressMeData().getLegsId() == 0 ? inventory.getPaperdollObjectId(slot.getSlot()) : _player.getDressMeData().getLegsId()));
							packet.writeD(_player.getDressMeData() == null ? inventory.getPaperdollItemId(slot.getSlot()) : (_player.getDressMeData().getLegsId() == 0 ? inventory.getPaperdollItemId(slot.getSlot()) : _player.getDressMeData().getLegsId()));
							packet.writeD(augmentLegs != null ? augmentLegs.getOption1Id() : 0);
							packet.writeD(augmentLegs != null ? augmentLegs.getOption2Id() : 0);
							packet.writeD(_player.getDressMeData() == null ? inventory.getPaperdollItemVisualId(slot.getSlot()) : (_player.getDressMeData().getLegsId() == 0 ? inventory.getPaperdollItemVisualId(slot.getSlot()) : _player.getDressMeData().getLegsId()));
							break;
						case FEET:
							final VariationInstance augmentFeet = inventory.getPaperdollAugmentation(slot.getSlot());
							packet.writeH(22); // 10 + 4 * 3
							packet.writeD(_player.getDressMeData() == null ? inventory.getPaperdollObjectId(slot.getSlot()) : (_player.getDressMeData().getBootsId() == 0 ? inventory.getPaperdollObjectId(slot.getSlot()) : _player.getDressMeData().getBootsId()));
							packet.writeD(_player.getDressMeData() == null ? inventory.getPaperdollItemId(slot.getSlot()) : (_player.getDressMeData().getBootsId() == 0 ? inventory.getPaperdollItemId(slot.getSlot()) : _player.getDressMeData().getBootsId()));
							packet.writeD(augmentFeet != null ? augmentFeet.getOption1Id() : 0);
							packet.writeD(augmentFeet != null ? augmentFeet.getOption2Id() : 0);
							packet.writeD(_player.getDressMeData() == null ? inventory.getPaperdollItemVisualId(slot.getSlot()) : (_player.getDressMeData().getBootsId() == 0 ? inventory.getPaperdollItemVisualId(slot.getSlot()) : _player.getDressMeData().getBootsId()));
							break;
						default:
							final VariationInstance augment = inventory.getPaperdollAugmentation(slot.getSlot());
							packet.writeH(22); // 10 + 4 * 3
							packet.writeD(inventory.getPaperdollObjectId(slot.getSlot()));
							packet.writeD(inventory.getPaperdollItemId(slot.getSlot()));
							packet.writeD(augment != null ? augment.getOption1Id() : 0);
							packet.writeD(augment != null ? augment.getOption2Id() : 0);
							packet.writeD(inventory.getPaperdollItemVisualId(slot.getSlot()));
							break;
					}
				}
			}
		}
		return true;
	}
}

I know it can be wrote WAY better, but we are ourselves PHP devs, so pls understand :p

 

These are the reference classes, so you can see the difference:

https://bitbucket.org/MobiusDev/l2j_mobius/src/master/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/serverpackets/UserInfo.java

https://bitbucket.org/MobiusDev/l2j_mobius/src/master/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/serverpackets/ExUserInfoEquipSlot.java

and

https://gitlab.com/Tryskell/acis_public/-/blob/master/aCis_gameserver/java/net/sf/l2j/gameserver/network/serverpackets/UserInfo.java

 

We are adapting An4rchy's dressme:

 

Some help would be much appreciated. In exchange, we will release and share it with the community!

 

Have a nice corona-day!

1 answer to this question

Recommended Posts

  • 0
Posted (edited)

Welp... just solved it xD

 

The code is fine (ugly, but fine), it only required sending this packet on every dressme action on RequestBypassToServer:

 

player.sendPacket(new ExUserInfoEquipSlot(player));

 

It's working frawlessly now. Gonna clean it a little and share it soon!

 

EDIT: Can close now!

Edited by Ikeryn

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...