L2JMobius

High Five .dressme

alennaor · 14 · 6035

Offline alennaor

  • Heir
  • **
    • Posts: 18
good morning, someone will have the command .dressme for l2jmobius for high five? In case someone has the code, would you explain how it is installed? I have seen several codes out there but the truth is that I do not know how they are installed and I do not know if they work in l2jmobius, thanks


Offline ihearcolors

  • Knight
  • ***
    • Posts: 53
    • L2Interlude
good morning, someone will have the command .dressme for l2jmobius for high five? In case someone has the code, would you explain how it is installed? I have seen several codes out there but the truth is that I do not know how they are installed and I do not know if they work in l2jmobius, thanks

Well first you will have to compare imports....and most certainly you will have to change them and based on that make modifications accordingly to the code, depends on what project it was used on, how old the code is...


Offline alennaor

  • Heir
  • **
    • Posts: 18
I have this code

Code: [Select]
### Eclipse Workspace Patch 1.0
#P L2J_DataPack_BETA
Index: dist/game/data/scripts/handlers/MasterHandler.java
===================================================================
--- dist/game/data/scripts/handlers/MasterHandler.java (revision 10451)
+++ dist/game/data/scripts/handlers/MasterHandler.java (working copy)
@@ -270,6 +271,7 @@
 import handlers.voicedcommandhandlers.Lang;
 import handlers.voicedcommandhandlers.StatsVCmd;
 import handlers.voicedcommandhandlers.Wedding;
+import handlers.voicedcommandhandlers.VisualArmor;
 
 /**
  * Master handler.
@@ -515,6 +518,7 @@
  (Config.L2JMOD_MULTILANG_ENABLE && Config.L2JMOD_MULTILANG_VOICED_ALLOW ? Lang.class : null),
  (Config.L2JMOD_DEBUG_VOICE_COMMAND ? Debug.class : null),
  (Config.L2JMOD_ALLOW_CHANGE_PASSWORD ? ChangePassword.class : null),
+ VisualArmor.class,
  },
  {
  // Target Handlers
Index: dist/game/data/scripts/handlers/voicedcommandhandlers/VisualArmor.java
===================================================================
--- dist/game/data/scripts/handlers/voicedcommandhandlers/VisualArmor.java (revision 0)
+++ dist/game/data/scripts/handlers/voicedcommandhandlers/VisualArmor.java (working copy)
@@ -0,0 +1,71 @@
+/*
+ * 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 handlers.voicedcommandhandlers;
+
+import com.l2jserver.extensions.VisualArmorController;
+import com.l2jserver.gameserver.handler.IVoicedCommandHandler;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate;
+
+public class VisualArmor implements IVoicedCommandHandler
+{
+ private static final String[] VOICED_COMMANDS =
+ {
+ "dressme",
+ "dressMe",
+ "DressMe",
+ "cloakOn",
+ "cloakOff"
+ };
+
+ @Override
+ public boolean useVoicedCommand(String command, L2PcInstance activeChar, String params)
+ {
+ if (command.contains("cloakOn"))
+ {
+ activeChar.visualArmor.weaponLRHANDId = 0;
+ InventoryUpdate iu = new InventoryUpdate();
+ activeChar.sendPacket(iu);
+ activeChar.broadcastUserInfo();
+ InventoryUpdate iu2 = new InventoryUpdate();
+ activeChar.sendPacket(iu2);
+ activeChar.broadcastUserInfo();
+ activeChar.sendMessage("Cloak enabled.");
+ }
+ else if (command.contains("cloakOff"))
+ {
+ activeChar.visualArmor.weaponLRHANDId = 1;
+ InventoryUpdate iu = new InventoryUpdate();
+ activeChar.sendPacket(iu);
+ activeChar.broadcastUserInfo();
+ InventoryUpdate iu2 = new InventoryUpdate();
+ activeChar.sendPacket(iu2);
+ activeChar.broadcastUserInfo();
+ activeChar.sendMessage("Cloak disabled.");
+ }
+ else
+ {
+ VisualArmorController.dressMe(activeChar);
+ }
+
+ return true;
+ }
+
+ @Override
+ public String[] getVoicedCommandList()
+ {
+ return VOICED_COMMANDS;
+ }
+}

I do not know if something is missing, I am new to this and I do not know if it can work with l2jmobius high five, this code is from giorgakis, I have another code from it but it gives me an error of 20,000 characters so I can't post it


Online CostyKiller

  • Distinguished King
  • *****
    • Posts: 957
You miss the most important part from core, which is VisualArmorController
Code: [Select]
+import com.l2jserver.extensions.VisualArmorController;


Offline Invoke

  • Heir
  • **
    • Posts: 18
i did the implementation for hi5 mobius project, i think with a little bit of mod you can do it in other mobius projects too.

Also this is based on the command you specified, add the command also

Also register the instance somewhere inside GameServer.java
Code: [Select]
VisualArmorController.load();

Code: [Select]
package org.l2jmobius.gameserver.extrastuff;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import org.l2jmobius.commons.database.DatabaseFactory;
import org.l2jmobius.gameserver.datatables.ItemTable;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
import org.l2jmobius.gameserver.model.items.Armor;
import org.l2jmobius.gameserver.model.items.Item;
import org.l2jmobius.gameserver.model.items.Weapon;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.items.type.ArmorType;
import org.l2jmobius.gameserver.model.items.type.WeaponType;
import org.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;

public class VisualArmorController
{
// 17 weapon types, check WeaponType
public static final int totalWeaponTypes = 17;

// 6 armor types, check ArmorType
public static final int totalArmorTypes = 6;

public static boolean[][] weaponMapping = new boolean[totalWeaponTypes][totalWeaponTypes];
public static boolean[][] armorMapping = new boolean[totalArmorTypes][totalArmorTypes];

@SuppressWarnings("null")
public static void migrate()
{
System.out.println("[VisualArmor]: Migrating the database.");
Connection con = null;
try
{
con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(VisualArmorModel.CREATE);
statement.execute();
statement.close();
}
catch (SQLException e)
{
e.printStackTrace();
}
finally
{
try
{
con.close();
}
catch (Exception e)
{
}
}
}

public static void load()
{
migrate();
generateMappings();
}

/***
* All same type armors and same type weapons can get visual.All different types* cannot get visual unless it is stated in here.
*/

public static void generateMappings()
{
for (int i = 0; i < weaponMapping.length; i++)
{
for (int j = 0; j < weaponMapping.length; j++)
{
weaponMapping[i][j] = false;
}
}

for (int i = 0; i < armorMapping.length; i++)
{
for (int j = 0; j < armorMapping.length; j++)
{
armorMapping[i][j] = false;
}
}

callRules();

}

public static void callRules()
{
// Example: a Virtual sword can mount an Equipped blunt.
weaponMapping[WeaponType.SWORD.ordinal()][WeaponType.BLUNT.ordinal()] = true;

// Example: a Virtual blunt can mount an Equipped sword.
weaponMapping[WeaponType.BLUNT.ordinal()][WeaponType.SWORD.ordinal()] = true;

// TODO: invoke - need to check for a correct type
// weaponMapping[WeaponType..BIGSWORD.ordinal()][WeaponType.BIGBLUNT.ordinal()] = true;
// weaponMapping[WeaponType.BIGBLUNT.ordinal()][WeaponType.BIGSWORD.ordinal()] = true;

armorMapping[ArmorType.SIGIL.ordinal()][ArmorType.SHIELD.ordinal()] = true;
armorMapping[ArmorType.SHIELD.ordinal()][ArmorType.SIGIL.ordinal()] = true;

// armorMapping[ArmorType.HEAVY.ordinal()][ArmorType.LIGHT.ordinal()] = true;
// armorMapping[ArmorType.HEAVY.ordinal()][ArmorType.MAGIC.ordinal()] = true;
//
// armorMapping[ArmorType.LIGHT.ordinal()][ArmorType.HEAVY.ordinal()] = true;
// armorMapping[ArmorType.LIGHT.ordinal()][ArmorType.MAGIC.ordinal()] = true;
//
// armorMapping[ArmorType.MAGIC.ordinal()][ArmorType.LIGHT.ordinal()] = true;
// armorMapping[ArmorType.MAGIC.ordinal()][ArmorType.HEAVY.ordinal()] = true;
}

public static int weaponMatching(WeaponType virtual, WeaponType equiped, int matchId, int noMatchId)
{
if (virtual == equiped)
{
return matchId;
}
if (weaponMapping[virtual.ordinal()][equiped.ordinal()] == true)
{
return matchId;
}

return noMatchId;
}

public static int armorMatching(ArmorType virtual, ArmorType equiped, int matchId, int noMatchId)
{
if (virtual == equiped)
{
return matchId;
}

if (armorMapping[virtual.ordinal()][equiped.ordinal()] == true)
{
return matchId;
}

return noMatchId;
}

public static void setVirtualRhand(PlayerInstance actor)
{
actor.visualArmor.weaponRHANDId = actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_RHAND);
}

public static void setVirtualLhand(PlayerInstance actor)
{
actor.visualArmor.weaponLHANDId = actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_LHAND);
}

public static void setVirtualGloves(PlayerInstance actor)
{
actor.visualArmor.glovesTextureId = actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_GLOVES);
}

public static void setVirtualBody(PlayerInstance actor)
{
actor.visualArmor.armorTextureId = actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_CHEST);
}

public static void setVirtualPants(PlayerInstance actor)
{
int chestId = actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_CHEST);
int pantsId = actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_LEGS);

if ((chestId != 0) && (pantsId == 0))
{
actor.visualArmor.pantsTextureId = chestId;
}
else
{
actor.visualArmor.pantsTextureId = pantsId;
}
}

public static void setVirtualBoots(PlayerInstance actor)
{
actor.visualArmor.bootsTextureId = actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_FEET);
}

// TODO: Merge the armor getters in one function.
public static int getVirtualGloves(PlayerInstance actor)
{
ItemInstance equipedItem = actor.getInventory().getPaperdollItem(Inventory.PAPERDOLL_GLOVES);
if (equipedItem == null)
{
return 0;
}
// ClassCastException wont happen unless some jackass changes the values ​​from the database.
Armor equipedGloves = (Armor) actor.getInventory().getPaperdollItem(Inventory.PAPERDOLL_GLOVES).getItem();
int equipedGlovesId = actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_GLOVES);

int glovesTextureId = actor.visualArmor.glovesTextureId;
Armor virtualGloves = (Armor) ItemTable.getInstance().getTemplate(glovesTextureId);

if (glovesTextureId != 0)
{
return armorMatching(virtualGloves.getItemType(), equipedGloves.getItemType(), glovesTextureId, equipedGlovesId);
}
return equipedGlovesId;
}

public static int getVirtualBody(PlayerInstance actor)
{
ItemInstance equipedItem = actor.getInventory().getPaperdollItem(Inventory.PAPERDOLL_CHEST);
if (equipedItem == null)
{
return 0;
}
// ClassCastException wont happen unless some jackass changes the values ​​from the database.
Armor equipedChest = (Armor) actor.getInventory().getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem();
int equipedChestId = actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_CHEST);

int chestTextureId = actor.visualArmor.armorTextureId;
Armor virtualChest = (Armor) ItemTable.getInstance().getTemplate(chestTextureId);

if (chestTextureId != 0)
{
return armorMatching(virtualChest.getItemType(), equipedChest.getItemType(), chestTextureId, equipedChestId);
}
return equipedChestId;
}

public static int getVirtualPants(PlayerInstance actor)
{
ItemInstance equipedItem = actor.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LEGS);

// Here comes the tricky part. If pants are null, then check for a fullbody armor.
if (equipedItem == null)
{
equipedItem = actor.getInventory().getPaperdollItem(Inventory.PAPERDOLL_CHEST);
}
if (equipedItem == null)
{
return 0;
}

int pantsTextureId = actor.visualArmor.pantsTextureId;

Armor equipedPants = (Armor) equipedItem.getItem();

if ((equipedPants.getBodyPart() != Item.SLOT_FULL_ARMOR) && (equipedPants.getBodyPart() != Item.SLOT_LEGS))
{
return 0;
}
int equipedPantsId = actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_LEGS);

Armor virtualPants = (Armor) ItemTable.getInstance().getTemplate(pantsTextureId);

if (pantsTextureId != 0)
{
return armorMatching(virtualPants.getItemType(), equipedPants.getItemType(), pantsTextureId, equipedPantsId);
}
return equipedPantsId;
}

public static int getVirtualBoots(PlayerInstance actor)
{
ItemInstance equipedItem = actor.getInventory().getPaperdollItem(Inventory.PAPERDOLL_FEET);
if (equipedItem == null)
{
return 0;
}
// ClassCastException wont happen unless some jackass changes the values ​​from the database.
Armor equipedBoots = (Armor) actor.getInventory().getPaperdollItem(Inventory.PAPERDOLL_FEET).getItem();
int equipedBootsId = actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_FEET);

int bootsTextureId = actor.visualArmor.bootsTextureId;
Armor virtualGloves = (Armor) ItemTable.getInstance().getTemplate(bootsTextureId);

if (bootsTextureId != 0)
{
return armorMatching(virtualGloves.getItemType(), equipedBoots.getItemType(), bootsTextureId, equipedBootsId);
}
return equipedBootsId;
}

public static int getLHAND(PlayerInstance actor)
{
ItemInstance equipedItem = actor.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LHAND);
int equipedItemId = actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_LHAND);
int weaponLHANDId = actor.visualArmor.weaponLHANDId;
Item virtualItem = ItemTable.getInstance().getTemplate(weaponLHANDId);

if ((equipedItem == null) || (weaponLHANDId == 0))
{
return equipedItemId;
}

// Only check same weapon types. Virtual replacement should not happen between armor / weapons.
if ((equipedItem.getItem() instanceof Weapon) && (virtualItem instanceof Weapon))
{
Weapon weapon = (Weapon) equipedItem.getItem();
Weapon virtualweapon = (Weapon) virtualItem;

return weaponMatching(virtualweapon.getItemType(), weapon.getItemType(), weaponLHANDId, equipedItemId);
}
else if ((equipedItem.getItem() instanceof Armor) && (virtualItem instanceof Armor))
{
Armor armor = (Armor) equipedItem.getItem();
Armor virtualarmor = (Armor) virtualItem;

return armorMatching(virtualarmor.getItemType(), armor.getItemType(), weaponLHANDId, equipedItemId);
}
return equipedItemId;
}

public static int getRHAND(PlayerInstance actor)
{
int weaponRHANDId = actor.visualArmor.weaponRHANDId;
ItemInstance equipedItem = actor.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
int equipedItemId = actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_RHAND);
Item virtualItem = ItemTable.getInstance().getTemplate(weaponRHANDId);

if ((equipedItem == null) || (weaponRHANDId == 0))
{
return equipedItemId;
}

// Only check same weapon types. Virtual replacement should not happen between armor / weapons.
if ((equipedItem.getItem() instanceof Weapon) && (virtualItem instanceof Weapon))
{
Weapon weapon = (Weapon) equipedItem.getItem();
Weapon virtualweapon = (Weapon) virtualItem;

return weaponMatching(virtualweapon.getItemType(), weapon.getItemType(), weaponRHANDId, equipedItemId);
}
else if ((equipedItem.getItem() instanceof Armor) && (virtualItem instanceof Armor))
{
Armor armor = (Armor) equipedItem.getItem();
Armor virtualarmor = (Armor) virtualItem;

return armorMatching(virtualarmor.getItemType(), armor.getItemType(), weaponRHANDId, equipedItemId);
}
return equipedItemId;

}

public static int getCloak(PlayerInstance actor)
{
if (actor.visualArmor.weaponLRHANDId == 1)
{
return 0;
}
return actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_CLOAK);

}

public static void dressMe(PlayerInstance player)
{
setVirtualBody(player);
setVirtualGloves(player);
setVirtualPants(player);
setVirtualBoots(player);
setVirtualLhand(player);
setVirtualRhand(player);

InventoryUpdate iu = new InventoryUpdate();
player.sendPacket(iu);
player.broadcastUserInfo();
InventoryUpdate iu2 = new InventoryUpdate();
player.sendPacket(iu2);
player.broadcastUserInfo();
player.sendMessage("Visual dress set is on.");
player.visualArmor.updateVisualArmor();
}
}

Code: [Select]
package org.l2jmobius.gameserver.extrastuff;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import org.l2jmobius.commons.database.DatabaseFactory;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;

public class VisualArmorModel
{
private static final String RESTORE_VISUAL_ARMOR = "SELECT GlovesId, ChestId, BootsId, PantsId, LeftHandId, RightHandId, DoubleHandId FROM visual_armor WHERE CharId =?";
private static final String UPDATE_VISUAL_ARMOR = "UPDATE visual_armor SET GlovesId = ?, ChestId = ?, BootsId = ?, PantsId = ?, LeftHandId = ?, RightHandId = ?, DoubleHandId =? WHERE CharId =?";
private static final String CREATE_VISUAL_ARMOR = "INSERT INTO visual_armor (CharId, GlovesId, ChestId, BootsId, PantsId, LeftHandId, RightHandId, DoubleHandId) values ​​(?,?,?,?,?,?,?,?)";

public static final String CREATE = "CREATE TABLE IF NOT EXISTS` visual_armor` (" + "` CharId` int (11) NOT NULL, " + "` GlovesId` int (11) NOT NULL DEFAULT '0', " + "` BootsId` int (11) NOT NULL DEFAULT '0', " + "` ChestId` int (11) NOT NULL DEFAULT '0', " + "` PantsId` int (11) NOT NULL DEFAULT '0', " + "` LeftHandId` int (11) NOT NULL DEFAULT '0', " + "` RightHandId` int (11) NOT NULL DEFAULT '0', " + "` DoubleHandId` int (11) NOT NULL DEFAULT '0', PRIMARY KEY (`CharId`))";

public static final String DROP = "DROP TABLE 'visual_armor'";

public int glovesTextureId = 0;
public int armorTextureId = 0;
public int pantsTextureId = 0;
public int bootsTextureId = 0;
public int weaponLHANDId = 0;
public int weaponRHANDId = 0;
public int weaponLRHANDId = 0;
public int ownerId;

public void updateVisualArmor()
{
Connection con = null;
try
{
con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(UPDATE_VISUAL_ARMOR);
statement.setInt(1, glovesTextureId);
statement.setInt(2, armorTextureId);
statement.setInt(3, bootsTextureId);
statement.setInt(4, pantsTextureId);
statement.setInt(5, weaponLHANDId);
statement.setInt(6, weaponRHANDId);
statement.setInt(7, weaponLRHANDId);
statement.setInt(8, ownerId);
statement.execute();
statement.close();

}
catch (SQLException e)
{
e.printStackTrace();
}
finally
{
try
{
con.close();
}
catch (Exception e)
{
}
}
}

public VisualArmorModel(PlayerInstance player)
{
ownerId = player.getObjectId();
Connection con = null;
try
{
con = DatabaseFactory.getConnection();

PreparedStatement statement = con.prepareStatement(RESTORE_VISUAL_ARMOR);
statement.setInt(1, ownerId);
ResultSet rset = statement.executeQuery();
boolean got = false;
while (rset.next())
{
glovesTextureId = rset.getInt("GlovesId");
armorTextureId = rset.getInt("ChestId");
pantsTextureId = rset.getInt("PantsId");
bootsTextureId = rset.getInt("BootsId");
weaponLHANDId = rset.getInt("LeftHandId");
weaponRHANDId = rset.getInt("RightHandId");
weaponLRHANDId = rset.getInt("DoubleHandId");
got = true;

}

rset.close();
statement.close();

if (got == false)
{
createVisualArmor();
}

InventoryUpdate iu = new InventoryUpdate();
player.sendPacket(iu);
player.broadcastUserInfo();
InventoryUpdate iu2 = new InventoryUpdate();
player.sendPacket(iu2);
player.broadcastUserInfo();
player.sendMessage("You changed clothes.");
}
catch (SQLException e)
{
e.printStackTrace();
}
finally
{
try
{
con.close();
}
catch (Exception e)
{
}
}
}

public void createVisualArmor() throws SQLException
{
Connection con = null;

try
{
con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(CREATE_VISUAL_ARMOR);

statement.setInt(1, ownerId);
statement.setInt(2, 0);
statement.setInt(3, 0);
statement.setInt(4, 0);
statement.setInt(5, 0);
statement.setInt(6, 0);
statement.setInt(7, 0);
statement.setInt(8, 0);

statement.executeUpdate();
statement.close();
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
try
{
con.close();
}
catch (Exception e)
{
}
}
}

}


Offline alennaor

  • Heir
  • **
    • Posts: 18
this is the other part of the VisualArmorController.java code i was looking for

Code: [Select]
Index: java/com/l2jserver/extensions/VisualArmorController.java
===================================================================
--- java/com/l2jserver/extensions/VisualArmorController.java    (revision 0)
    java/com/l2jserver/extensions/VisualArmorController.java    (revision 0)
@@ -0,0  1,373 @@
 /*
  * 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.l2jserver.extensions;
 
 import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.SQLException;
 import com.l2jserver.L2DatabaseFactory;
 import com.l2jserver.gameserver.datatables.ItemTable;
 import com.l2jserver.gameserver.model.L2ItemInstance;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.itemcontainer.Inventory;
 import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate;
 import com.l2jserver.gameserver.templates.item.L2Armor;
 import com.l2jserver.gameserver.templates.item.L2ArmorType;
 import com.l2jserver.gameserver.templates.item.L2Item;
 import com.l2jserver.gameserver.templates.item.L2Weapon;
 import com.l2jserver.gameserver.templates.item.L2WeaponType;
 
 /**
  * @author giorgakis
  *
  */
 public class VisualArmorController
 {
    //As of freya there are 19 weapon types.
    public static final int totalWeaponTypes = 19;
   
    //As of freya there are 6 armor types.
    public static final int totalArmorTypes = 6;
   
    public static boolean[][] weaponMapping = new boolean[totalWeaponTypes][totalWeaponTypes];
    public static boolean[][] armorMapping = new boolean[totalArmorTypes][totalArmorTypes];
   
    public static void migrate()
    {
        System.out.println("[VisualArmor]:Migrating the database.");
        Connection con = null;
        try
        {
            con = L2DatabaseFactory.getInstance().getConnection();
            PreparedStatement statement = con.prepareStatement(VisualArmorModel.CREATE);
            statement.execute();
            statement.close();
        }
        catch (SQLException e)
        {
            e.printStackTrace();
        }
        finally
        {
            try { con.close(); } catch (Exception e) {}
        }
    }
   
    public static void load()
    {
        migrate();
        generateMappings();
    }
   
    /**
    * All same type armors and same type weapons can get visual. All different types
    * cannot get visual unless it is stated in here.
    */
    public static void generateMappings()
    {
        for(int i =0; i< weaponMapping.length; i  )
            for(int j = 0; j< weaponMapping.length; j  )
                weaponMapping[i][j]=false;
     
        for(int i =0; i< armorMapping.length; i  )
            for(int j = 0; j< armorMapping.length; j  )
                armorMapping[i][j]=false;
     
        callRules();
     
    }
   
    public static void callRules()
    {
        //Example: a Virtual sword can mount an Equipped blunt.
        weaponMapping[L2WeaponType.SWORD.ordinal()][L2WeaponType.BLUNT.ordinal()] = true;
     
        //Example: a Virtual blunt can mount an Equipped sword.
        weaponMapping[L2WeaponType.BLUNT.ordinal()][L2WeaponType.SWORD.ordinal()] = true;
     
        weaponMapping[L2WeaponType.BIGSWORD.ordinal()][L2WeaponType.BIGBLUNT.ordinal()] = true;
        weaponMapping[L2WeaponType.BIGBLUNT.ordinal()][L2WeaponType.BIGSWORD.ordinal()] = true;
     
        armorMapping[L2ArmorType.SIGIL.ordinal()][L2ArmorType.SHIELD.ordinal()] = true;
        armorMapping[L2ArmorType.SHIELD.ordinal()][L2ArmorType.SIGIL.ordinal()] = true;
     
        //armorMapping[L2ArmorType.HEAVY.ordinal()][L2ArmorType.LIGHT.ordinal()] = true;
        //armorMapping[L2ArmorType.HEAVY.ordinal()][L2ArmorType.MAGIC.ordinal()] = true;
     
        //armorMapping[L2ArmorType.LIGHT.ordinal()][L2ArmorType.HEAVY.ordinal()] = true;
        //armorMapping[L2ArmorType.LIGHT.ordinal()][L2ArmorType.MAGIC.ordinal()] = true;
     
        //armorMapping[L2ArmorType.MAGIC.ordinal()][L2ArmorType.LIGHT.ordinal()] = true;
        //armorMapping[L2ArmorType.MAGIC.ordinal()][L2ArmorType.HEAVY.ordinal()] = true;
    }
   
    /**
    * Checks if the weapon is the same type. If that is true then return
    * the matching virtual id. Else check the mapping tables if any
    * rule states that the two different weapon types should be matched.
    * @param virtual
    * @param equiped
    * @param matchId
    * @param noMatchId
    * @return
    */
    public static int weaponMatching(L2WeaponType virtual, L2WeaponType equiped, int matchId, int noMatchId)
    {
        if(virtual == equiped)
            return matchId;
 
        if(weaponMapping[virtual.ordinal()][equiped.ordinal()] == true)
        {
            return matchId;
        }
     
        return noMatchId;
    }
   
    /**
    * Checks if the armor is the same type. If that is true then return
    * the matching virtual id. Else check the mapping tables if any
    * rule states that the two different armor types should be matched.
    * @param virtual
    * @param equiped
    * @param matchId
    * @param noMatchId
    * @return
    */
    public static int armorMatching(L2ArmorType virtual, L2ArmorType equiped, int matchId , int noMatchId)
    {
        if(virtual == equiped)
            return matchId;
     
        if(armorMapping[virtual.ordinal()][equiped.ordinal()] == true)
            return matchId;
     
        return noMatchId;
    }
   
   
   
    public static void setVirtualRhand(L2PcInstance actor)
    {
        actor.visualArmor.weaponRHANDId = actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_RHAND);
    }
   
    public static void setVirtualLhand(L2PcInstance actor)
    {
        actor.visualArmor.weaponLHANDId = actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_LHAND);
    }
   
    public static void setVirtualGloves(L2PcInstance actor)
    {
        actor.visualArmor.glovesTextureId = actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_GLOVES);
    }
   
    public static void setVirtualBody(L2PcInstance actor)
    {
        actor.visualArmor.armorTextureId = actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_CHEST);
    }
   
    public static void setVirtualPants(L2PcInstance actor)
    {
        int chestId = actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_CHEST);
        int pantsId = actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_LEGS);
     
        if(chestId != 0 && pantsId==0)
            actor.visualArmor.pantsTextureId = chestId;
        else
            actor.visualArmor.pantsTextureId = pantsId;
    }
   
    public static void setVirtualBoots(L2PcInstance actor)
    {
        actor.visualArmor.bootsTextureId = actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_FEET);
    }
   
    //TODO: Merge the armor getters in one function.
    public static int getVirtualGloves(L2PcInstance actor)
    {
        L2ItemInstance equipedItem = actor.getInventory().getPaperdollItem(Inventory.PAPERDOLL_GLOVES);
        if(equipedItem == null)
            return 0;
        //ClassCastException wont happen unless some jackass changes the values from the database.
        L2Armor equipedGloves = (L2Armor)actor.getInventory().getPaperdollItem(Inventory.PAPERDOLL_GLOVES).getItem();
        int equipedGlovesId = actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_GLOVES);
     
        int glovesTextureId = actor.visualArmor.glovesTextureId;
        L2Armor virtualGloves = (L2Armor)ItemTable.getInstance().getTemplate(glovesTextureId);
     
        if(glovesTextureId != 0)
            return armorMatching(virtualGloves.getItemType(), equipedGloves.getItemType(),glovesTextureId, equipedGlovesId);
        else
            return equipedGlovesId;
    }
   
    public static int getVirtualBody(L2PcInstance actor)
    {
        L2ItemInstance equipedItem = actor.getInventory().getPaperdollItem(Inventory.PAPERDOLL_CHEST);
        if(equipedItem == null)
            return 0;
        //ClassCastException wont happen unless some jackass changes the values from the database.
        L2Armor equipedChest = (L2Armor)actor.getInventory().getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem();
        int equipedChestId = actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_CHEST);
     
        int chestTextureId = actor.visualArmor.armorTextureId;
        L2Armor virtualChest = (L2Armor)ItemTable.getInstance().getTemplate(chestTextureId);
     
        if(chestTextureId != 0)
            return armorMatching(virtualChest.getItemType(), equipedChest.getItemType(),chestTextureId, equipedChestId);
        else
            return equipedChestId;
    }
   
    /**
    * This is a brain fu**er handling the pants since they are
    * also part of a fullbody armor.
    * @param actor
    * @return
    */
    public static int getVirtualPants(L2PcInstance actor)
    {
        L2ItemInstance equipedItem = actor.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LEGS);
     
        //Here comes the tricky part. If pants are null, then check for a fullbody armor.
        if(equipedItem == null)
            equipedItem = actor.getInventory().getPaperdollItem(Inventory.PAPERDOLL_CHEST);
        if(equipedItem == null)
            return 0;
         
        int pantsTextureId = actor.visualArmor.pantsTextureId;
     
        L2Armor equipedPants = (L2Armor) equipedItem.getItem();
     
        if(equipedPants.getBodyPart() != L2Item.SLOT_FULL_ARMOR && equipedPants.getBodyPart() != L2Item.SLOT_LEGS)
            return 0;
        int equipedPantsId = actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_LEGS);
     
     
        L2Armor virtualPants = (L2Armor)ItemTable.getInstance().getTemplate(pantsTextureId);
     
        if(pantsTextureId != 0)
            return armorMatching(virtualPants.getItemType(), equipedPants.getItemType(),pantsTextureId, equipedPantsId);
        else
            return equipedPantsId;
    }
   
    public static int getVirtualBoots(L2PcInstance actor)
    {
        L2ItemInstance equipedItem = actor.getInventory().getPaperdollItem(Inventory.PAPERDOLL_FEET);
        if(equipedItem == null)
            return 0;
        //ClassCastException wont happen unless some jackass changes the values from the database.
        L2Armor equipedBoots = (L2Armor)actor.getInventory().getPaperdollItem(Inventory.PAPERDOLL_FEET).getItem();
        int equipedBootsId = actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_FEET);
     
        int bootsTextureId = actor.visualArmor.bootsTextureId;
        L2Armor virtualGloves = (L2Armor)ItemTable.getInstance().getTemplate(bootsTextureId);
     
        if(bootsTextureId != 0)
            return armorMatching(virtualGloves.getItemType(), equipedBoots.getItemType(),bootsTextureId, equipedBootsId);
        else
            return equipedBootsId;
    }
   
    public static int getLHAND(L2PcInstance actor)
    {
        L2ItemInstance equipedItem = actor.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LHAND);
        int equipedItemId = actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_LHAND);
     
        int weaponLHANDId = actor.visualArmor.weaponLHANDId;
        L2Item virtualItem = ItemTable.getInstance().getTemplate(weaponLHANDId);
     
        if(equipedItem == null || weaponLHANDId == 0)
            return equipedItemId;
     
        //Only check same weapon types. Virtual replacement should not happen between armor/weapons.
        if(equipedItem.getItem() instanceof L2Weapon && virtualItem instanceof L2Weapon)
        {
            L2Weapon weapon = (L2Weapon) equipedItem.getItem();
            L2Weapon virtualweapon = (L2Weapon)virtualItem;
         
            return weaponMatching(virtualweapon.getItemType(), weapon.getItemType(), weaponLHANDId, equipedItemId);
        }
        else if(equipedItem.getItem() instanceof L2Armor && virtualItem instanceof L2Armor)
        {
            L2Armor armor = (L2Armor) equipedItem.getItem();
            L2Armor virtualarmor = (L2Armor)virtualItem;
         
            return armorMatching(virtualarmor.getItemType(), armor.getItemType(), weaponLHANDId, equipedItemId);
        }
        return equipedItemId;
    }
   
    public static int getRHAND(L2PcInstance actor)
    {
        int weaponRHANDId = actor.visualArmor.weaponRHANDId;
        L2ItemInstance equipedItem = actor.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
        int equipedItemId = actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_RHAND);
        L2Item virtualItem = ItemTable.getInstance().getTemplate(weaponRHANDId);
     
        if(equipedItem == null || weaponRHANDId == 0)
            return equipedItemId;
     
        //Only check same weapon types. Virtual replacement should not happen between armor/weapons.
        if(equipedItem.getItem() instanceof L2Weapon && virtualItem instanceof L2Weapon)
        {
            L2Weapon weapon = (L2Weapon) equipedItem.getItem();
            L2Weapon virtualweapon = (L2Weapon)virtualItem;
         
            return weaponMatching(virtualweapon.getItemType(), weapon.getItemType(), weaponRHANDId, equipedItemId);
        }
        else if(equipedItem.getItem() instanceof L2Armor && virtualItem instanceof L2Armor)
        {
            L2Armor armor = (L2Armor) equipedItem.getItem();
            L2Armor virtualarmor = (L2Armor)virtualItem;
         
            return armorMatching(virtualarmor.getItemType(), armor.getItemType(), weaponRHANDId, equipedItemId);
        }
        return equipedItemId;
     
    }
   
   
   
    public static int getCloak(L2PcInstance actor)
    {
        if(actor.visualArmor.weaponLRHANDId == 1)
            return 0;
        else
            return actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_CLOAK);
         
    }
   
    public static void dressMe(L2PcInstance activeChar)
    {
        setVirtualBody(activeChar);
        setVirtualGloves(activeChar);
        setVirtualPants(activeChar);
        setVirtualBoots(activeChar);
        setVirtualLhand(activeChar);
        setVirtualRhand(activeChar);
     
        InventoryUpdate iu = new InventoryUpdate();
        activeChar.sendPacket(iu);
        activeChar.broadcastUserInfo();
        InventoryUpdate iu2 = new InventoryUpdate();
        activeChar.sendPacket(iu2);
        activeChar.broadcastUserInfo();
        activeChar.sendMessage("You changed clothes.");
        activeChar.visualArmor.updateVisualArmor();
    }
 }


Offline alennaor

  • Heir
  • **
    • Posts: 18
Code: [Select]
Index: java/com/l2jserver/extensions/VisualArmorModel.java
===================================================================
--- java/com/l2jserver/extensions/VisualArmorModel.java (revision 0)
    java/com/l2jserver/extensions/VisualArmorModel.java (revision 0)
@@ -0,0  1,171 @@
 /*
  * 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.l2jserver.extensions;
 
 import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import com.l2jserver.L2DatabaseFactory;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate;
 
 /**
  * @author Issle
  *
  */
 public class VisualArmorModel
 {
    private static final String RESTORE_VISUAL_ARMOR = "SELECT
GlovesId,ChestId,BootsId,PantsId,LeftHandId,RightHandId,DoubleHandId
FROM visual_armor WHERE CharId=?";
    private static final String UPDATE_VISUAL_ARMOR = "UPDATE
visual_armor SET
GlovesId=?,ChestId=?,BootsId=?,PantsId=?,LeftHandId=?,RightHandId=?,DoubleHandId=?
 WHERE CharId=?";
    private static final String CREATE_VISUAL_ARMOR = "INSERT INTO
visual_armor
(CharId,GlovesId,ChestId,BootsId,PantsId,LeftHandId,RightHandId,DoubleHandId)
 values (?,?,?,?,?,?,?,?)";
   
    public static final String CREATE =
        "CREATE TABLE IF NOT EXISTS `visual_armor` ("
        "`CharId` int(11) NOT NULL,"
        "`GlovesId` int(11) NOT NULL DEFAULT '0',"
        "`BootsId` int(11) NOT NULL DEFAULT '0',"
        "`ChestId` int(11) NOT NULL DEFAULT '0',"
        "`PantsId` int(11) NOT NULL DEFAULT '0',"
        "`LeftHandId` int(11) NOT NULL DEFAULT '0',"
        "`RightHandId` int(11) NOT NULL DEFAULT '0',"
        "`DoubleHandId` int(11) NOT NULL DEFAULT '0',PRIMARY KEY (`CharId`))";
   
    public static final String DROP =
        "DROP TABLE 'visual_armor'";
   
    public int glovesTextureId=0;
    public int armorTextureId=0;
    public int pantsTextureId=0;
    public int bootsTextureId=0;
    public int weaponLHANDId=0;
    public int weaponRHANDId=0;
    public int weaponLRHANDId=0;
    public int ownerId;
   
   
    public void updateVisualArmor()
    {
        Connection con = null;
        try
        {
            con = L2DatabaseFactory.getInstance().getConnection();
            PreparedStatement statement = con.prepareStatement(UPDATE_VISUAL_ARMOR);
            statement.setInt(1, glovesTextureId);
            statement.setInt(2, armorTextureId);
            statement.setInt(3, bootsTextureId);
            statement.setInt(4, pantsTextureId);
            statement.setInt(5, weaponLHANDId);
            statement.setInt(6, weaponRHANDId);
            statement.setInt(7, weaponLRHANDId);
            statement.setInt(8, ownerId);
            statement.execute();
            statement.close();
 
        }
        catch (SQLException e)
        {
            e.printStackTrace();
        }
        finally
        {
            try { con.close(); } catch (Exception e) {}
        }
    }
   
    public VisualArmorModel(L2PcInstance activeChar)
    {
        ownerId = activeChar.getObjectId();
        Connection con = null;
        try
        {
            con = L2DatabaseFactory.getInstance().getConnection();
         
            PreparedStatement statement = con.prepareStatement(RESTORE_VISUAL_ARMOR);
            statement.setInt(1, ownerId);
            ResultSet rset = statement.executeQuery();
            boolean got = false;
            while(rset.next())
            {
                glovesTextureId = rset.getInt("GlovesId");
                armorTextureId = rset.getInt("ChestId");
                pantsTextureId = rset.getInt("PantsId");
                bootsTextureId = rset.getInt("BootsId");
                weaponLHANDId = rset.getInt("LeftHandId");
                weaponRHANDId = rset.getInt("RightHandId");
                weaponLRHANDId = rset.getInt("DoubleHandId");
                got = true;
     
            }
         
            rset.close();
            statement.close();
         
            if(got == false)
            {
                createVisualArmor();
            }
         
            InventoryUpdate iu = new InventoryUpdate();
            activeChar.sendPacket(iu);
            activeChar.broadcastUserInfo();
            InventoryUpdate iu2 = new InventoryUpdate();
            activeChar.sendPacket(iu2);
            activeChar.broadcastUserInfo();
            activeChar.sendMessage("You changed clothes.");
        }
        catch (SQLException e)
        {
            e.printStackTrace();
        }
        finally
        {
            try { con.close(); } catch (Exception e) {}
        }
    }
   
    public void createVisualArmor() throws SQLException
    {
        Connection con = null;
     
        try
        {
            con = L2DatabaseFactory.getInstance().getConnection();
            PreparedStatement statement = con.prepareStatement(CREATE_VISUAL_ARMOR);
         
            statement.setInt(1, ownerId);
            statement.setInt(2, 0);
            statement.setInt(3, 0);
            statement.setInt(4, 0);
            statement.setInt(5, 0);
            statement.setInt(6, 0);
            statement.setInt(7, 0);
            statement.setInt(8, 0);
         
            statement.executeUpdate();
            statement.close();
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
        finally
        {
            try { con.close(); } catch (Exception e) {}
        }
    }
   
 }
 
Index: java/com/l2jserver/gameserver/GameServer.java
===================================================================
--- java/com/l2jserver/gameserver/GameServer.java  (revision 4469)
    java/com/l2jserver/gameserver/GameServer.java  (working copy)
@@ -32,6  32,7 @@
 import com.l2jserver.Config;
 import com.l2jserver.L2DatabaseFactory;
 import com.l2jserver.Server;
 import com.l2jserver.extensions.VisualArmorController;
 import com.l2jserver.gameserver.cache.CrestCache;
 import com.l2jserver.gameserver.cache.HtmCache;
 import com.l2jserver.gameserver.datatables.AccessLevels;
@@ -315,6  316,7 @@
        BoatManager.getInstance();
        AirShipManager.getInstance();
        GraciaSeedsManager.getInstance();
        VisualArmorController.load();
     
        try
        {
Index: java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java    (revision 4469)
    java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java    (working copy)
@@ -38,6  38,7 @@
 
 import com.l2jserver.Config;
 import com.l2jserver.L2DatabaseFactory;
 import com.l2jserver.extensions.VisualArmorModel;
 import com.l2jserver.gameserver.Announcements;
 import com.l2jserver.gameserver.GameTimeController;
 import com.l2jserver.gameserver.GeoData;
@@ -274,6  275,7 @@
  */
 public final class L2PcInstance extends L2Playable
 {
    public VisualArmorModel visualArmor;
    // Character Skill SQL String Definitions:
    private static final String RESTORE_SKILLS_FOR_CHAR = "SELECT
skill_id,skill_level FROM character_skills WHERE charId=? AND
class_index=?";
    private static final String ADD_NEW_SKILL = "INSERT INTO
character_skills (charId,skill_id,skill_level,class_index) VALUES
(?,?,?,?)";
@@ -324,6  326,8 @@
    public static final int STORE_PRIVATE_MANUFACTURE = 5;
    public static final int STORE_PRIVATE_PACKAGE_SELL = 8;
   
   
   
    /** The table containing all minimum level needed for each Expertise (None, D, C, B, A, S, S80, S84)*/
    private static final int[] EXPERTISE_LEVELS =
    {
@@ -1254,6  1258,7 @@
        if (!Config.WAREHOUSE_CACHE)
            getWarehouse();
        startVitalityTask();
        visualArmor = new VisualArmorModel(this);
    }
   
    private L2PcInstance(int objectId)
Index: java/com/l2jserver/gameserver/network/serverpackets/CharInfo.java
===================================================================
--- java/com/l2jserver/gameserver/network/serverpackets/CharInfo.java  (revision 4469)
    java/com/l2jserver/gameserver/network/serverpackets/CharInfo.java  (working copy)
@@ -17,6  17,7 @@
 import java.util.logging.Logger;
 
 import com.l2jserver.Config;
 import com.l2jserver.extensions.VisualArmorController;
 import com.l2jserver.gameserver.datatables.NpcTable;
 import com.l2jserver.gameserver.instancemanager.CursedWeaponsManager;
 import com.l2jserver.gameserver.model.actor.L2Decoy;
@@ -249,20  250,20 @@
            writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_HEAD));
            if (_airShipHelm == 0)
            {
-              writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_RHAND));
-              writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_LHAND));
                writeD(VisualArmorController.getRHAND(_activeChar));
                writeD(VisualArmorController.getLHAND(_activeChar));
            }
            else
            {
                writeD(_airShipHelm);
                writeD(0);
            }
-          writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_GLOVES));
-          writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_CHEST));
-          writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_LEGS));
-          writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_FEET));
-          writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_CLOAK));
-          writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_RHAND));
            writeD(VisualArmorController.getVirtualGloves(_activeChar));
            writeD(VisualArmorController.getVirtualBody(_activeChar));
            writeD(VisualArmorController.getVirtualPants(_activeChar));
            writeD(VisualArmorController.getVirtualBoots(_activeChar));
            writeD(VisualArmorController.getCloak(_activeChar));
            writeD(VisualArmorController.getRHAND(_activeChar));
            writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_HAIR));
            writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_HAIR2));
            // T1 new d's
Index: java/com/l2jserver/gameserver/network/serverpackets/UserInfo.java
===================================================================
--- java/com/l2jserver/gameserver/network/serverpackets/UserInfo.java  (revision 4469)
    java/com/l2jserver/gameserver/network/serverpackets/UserInfo.java  (working copy)
@@ -15,6  15,7 @@
 package com.l2jserver.gameserver.network.serverpackets;
 
 import com.l2jserver.Config;
 import com.l2jserver.extensions.VisualArmorController;
 import com.l2jserver.gameserver.datatables.NpcTable;
 import com.l2jserver.gameserver.instancemanager.CursedWeaponsManager;
 import com.l2jserver.gameserver.instancemanager.TerritoryWarManager;
@@ -192,20  193,20 @@
        writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_HEAD));
        if (_airShipHelm == 0)
        {
-          writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_RHAND));
-          writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_LHAND));
            writeD(VisualArmorController.getRHAND(_activeChar));
            writeD(VisualArmorController.getLHAND(_activeChar));
        }
        else
        {
            writeD(_airShipHelm);
            writeD(0);
        }
-      writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_GLOVES));
-      writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_CHEST));
-      writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_LEGS));
-      writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_FEET));
-      writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_CLOAK));
-      writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_RHAND));
        writeD(VisualArmorController.getVirtualGloves(_activeChar));
        writeD(VisualArmorController.getVirtualBody(_activeChar));
        writeD(VisualArmorController.getVirtualPants(_activeChar));
        writeD(VisualArmorController.getVirtualBoots(_activeChar));
        writeD(VisualArmorController.getCloak(_activeChar));
        writeD(VisualArmorController.getRHAND(_activeChar));
        writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_HAIR));
        writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_HAIR2));
        writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_RBRACELET));


Offline Invoke

  • Heir
  • **
    • Posts: 18
for CharInfo.java
find this: packet.writeD(_player.getInventory().getPaperdollItemDisplayId(slot));
and replace it with this:
Code: [Select]
for (int slot : getPaperdollOrder())
{
switch (slot)
{
case 5:
packet.writeD(VisualArmorController.getRHAND(_player));
break;
case 6:
packet.writeD(VisualArmorController.getVirtualBody(_player));
break;
case 7:
packet.writeD(VisualArmorController.getLHAND(_player));
break;
case 10:
packet.writeD(VisualArmorController.getVirtualGloves(_player));
break;
case 11:
packet.writeD(VisualArmorController.getVirtualPants(_player));
break;
case 12:
packet.writeD(VisualArmorController.getVirtualBoots(_player));
break;
case 23:
packet.writeD(VisualArmorController.getCloak(_player));
break;
default:
packet.writeD(_player.getInventory().getPaperdollItemDisplayId(slot));
}
}

for UserInfo.java
find this: packet.writeD(_player.getInventory().getPaperdollItemDisplayId(slot));
and replace it with this:
Code: [Select]
for (int slot : getPaperdollOrder())
{
switch (slot)
{
case 5:
packet.writeD(VisualArmorController.getRHAND(_player));
break;
case 6:
packet.writeD(VisualArmorController.getVirtualBody(_player));
break;
case 7:
packet.writeD(VisualArmorController.getLHAND(_player));
break;
case 10:
packet.writeD(VisualArmorController.getVirtualGloves(_player));
break;
case 11:
packet.writeD(VisualArmorController.getVirtualPants(_player));
break;
case 12:
packet.writeD(VisualArmorController.getVirtualBoots(_player));
break;
case 23:
packet.writeD(VisualArmorController.getCloak(_player));
break;
default:
packet.writeD(_player.getInventory().getPaperdollItemDisplayId(slot));
}
}


Offline alennaor

  • Heir
  • **
    • Posts: 18
I have already modified the source files for charinfo.java

Code: [Select]
package org.l2jmobius.gameserver.network.serverpackets;

import org.l2jmobius.Config;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
import org.l2jmobius.gameserver.model.actor.Decoy;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.clan.Clan;
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
import org.l2jmobius.gameserver.model.skills.AbnormalVisualEffect;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.OutgoingPackets;

public class CharInfo implements IClientOutgoingPacket
{
private final PlayerInstance _player;
private final Clan _clan;
private int _objId;
private int _x;
private int _y;
private int _z;
private int _heading;
private final int _mAtkSpd;
private final int _pAtkSpd;
private final int _runSpd;
private final int _walkSpd;
private final int _swimRunSpd;
private final int _swimWalkSpd;
private final int _flyRunSpd;
private final int _flyWalkSpd;
private final double _moveMultiplier;

private int _vehicleId = 0;
private final boolean _gmSeeInvis;

private static final int[] PAPERDOLL_ORDER = new int[]
{
Inventory.PAPERDOLL_UNDER,
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
};

public CharInfo(PlayerInstance player, boolean gmSeeInvis)
{
_player = player;
_objId = player.getObjectId();
_clan = player.getClan();
if ((_player.getVehicle() != null) && (_player.getInVehiclePosition() != null))
{
_x = _player.getInVehiclePosition().getX();
_y = _player.getInVehiclePosition().getY();
_z = _player.getInVehiclePosition().getZ();
_vehicleId = _player.getVehicle().getObjectId();
}
else
{
_x = _player.getX();
_y = _player.getY();
_z = _player.getZ();
}
_heading = _player.getHeading();
_mAtkSpd = _player.getMAtkSpd();
_pAtkSpd = (int) _player.getPAtkSpd();
_moveMultiplier = player.getMovementSpeedMultiplier();
_runSpd = (int) Math.round(player.getRunSpeed() / _moveMultiplier);
_walkSpd = (int) Math.round(player.getWalkSpeed() / _moveMultiplier);
_swimRunSpd = (int) Math.round(player.getSwimRunSpeed() / _moveMultiplier);
_swimWalkSpd = (int) Math.round(player.getSwimWalkSpeed() / _moveMultiplier);
_flyRunSpd = player.isFlying() ? _runSpd : 0;
_flyWalkSpd = player.isFlying() ? _walkSpd : 0;
_gmSeeInvis = gmSeeInvis;
}

public CharInfo(Decoy decoy, boolean gmSeeInvis)
{
this(decoy.getActingPlayer(), gmSeeInvis); // init
_objId = decoy.getObjectId();
_x = decoy.getX();
_y = decoy.getY();
_z = decoy.getZ();
_heading = decoy.getHeading();
}

@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.CHAR_INFO.writeId(packet);
packet.writeD(_x);
packet.writeD(_y);
packet.writeD(_z);
packet.writeD(_vehicleId);
packet.writeD(_objId);
packet.writeS(_player.getAppearance().getVisibleName());
packet.writeD(_player.getRace().ordinal());
packet.writeD(_player.getAppearance().isFemale() ? 1 : 0);
packet.writeD(_player.getBaseClass());

for (int slot : getPaperdollOrder())
{
switch (slot)
{
case 5:
packet.writeD(VisualArmorController.getRHAND(_player));
break;
case 6:
packet.writeD(VisualArmorController.getVirtualBody(_player));
break;
case 7:
packet.writeD(VisualArmorController.getLHAND(_player));
break;
case 10:
packet.writeD(VisualArmorController.getVirtualGloves(_player));
break;
case 11:
packet.writeD(VisualArmorController.getVirtualPants(_player));
break;
case 12:
packet.writeD(VisualArmorController.getVirtualBoots(_player));
break;
case 23:
packet.writeD(VisualArmorController.getCloak(_player));
break;
default:
packet.writeD(_player.getInventory().getPaperdollItemDisplayId(slot));
}
}

for (int slot : getPaperdollOrder())
{
packet.writeD(_player.getInventory().getPaperdollAugmentationId(slot));
}

packet.writeD(_player.getInventory().getTalismanSlots());
packet.writeD(_player.getInventory().canEquipCloak() ? 1 : 0);

packet.writeD(_player.getPvpFlag());
packet.writeD(_player.getKarma());

packet.writeD(_mAtkSpd);
packet.writeD(_pAtkSpd);

packet.writeD(0x00); // ?

packet.writeD(_runSpd);
packet.writeD(_walkSpd);
packet.writeD(_swimRunSpd);
packet.writeD(_swimWalkSpd);
packet.writeD(_flyRunSpd);
packet.writeD(_flyWalkSpd);
packet.writeD(_flyRunSpd);
packet.writeD(_flyWalkSpd);
packet.writeF(_moveMultiplier);
packet.writeF(_player.getAttackSpeedMultiplier());

packet.writeF(_player.getCollisionRadius());
packet.writeF(_player.getCollisionHeight());

packet.writeD(_player.getAppearance().getHairStyle());
packet.writeD(_player.getAppearance().getHairColor());
packet.writeD(_player.getAppearance().getFace());

packet.writeS(_gmSeeInvis ? "Invisible" : _player.getAppearance().getVisibleTitle());

if (!_player.isCursedWeaponEquipped())
{
packet.writeD(_player.getClanId());
packet.writeD(_player.getClanCrestId());
packet.writeD(_player.getAllyId());
packet.writeD(_player.getAllyCrestId());
}
else
{
packet.writeD(0x00);
packet.writeD(0x00);
packet.writeD(0x00);
packet.writeD(0x00);
}

packet.writeC(_player.isSitting() ? 0 : 1); // standing = 1 sitting = 0
packet.writeC(_player.isRunning() ? 1 : 0); // running = 1 walking = 0
packet.writeC(_player.isInCombat() ? 1 : 0);

packet.writeC(!_player.isInOlympiadMode() && _player.isAlikeDead() ? 1 : 0);

packet.writeC(!_gmSeeInvis && _player.isInvisible() ? 1 : 0); // invisible = 1 visible =0

packet.writeC(_player.getMountType().ordinal()); // 1-on Strider, 2-on Wyvern, 3-on Great Wolf, 0-no mount
packet.writeC(_player.getPrivateStoreType().getId());

packet.writeH(_player.getCubics().size());
for (int cubicId : _player.getCubics().keySet())
{
packet.writeH(cubicId);
}

packet.writeC(_player.isInPartyMatchRoom() ? 1 : 0);

packet.writeD(_gmSeeInvis ? (_player.getAbnormalVisualEffects() | AbnormalVisualEffect.STEALTH.getMask()) : _player.getAbnormalVisualEffects());

packet.writeC(_player.isInsideZone(ZoneId.WATER) ? 1 : _player.isFlyingMounted() ? 2 : 0);

packet.writeH(_player.getRecomHave()); // Blue value for name (0 = white, 255 = pure blue)
packet.writeD(_player.getMountNpcId() + 1000000);
packet.writeD(_player.getClassId().getId());
packet.writeD(0x00); // ?
packet.writeC(_player.isMounted() ? 0 : _player.getEnchantEffect());

packet.writeC(_player.getTeam().getId());

packet.writeD(_player.getClanCrestLargeId());
packet.writeC(_player.isNoble() ? 1 : 0); // Symbol on char menu ctrl+I
packet.writeC(_player.isHero() || (_player.isGM() && Config.GM_HERO_AURA) ? 1 : 0); // Hero Aura

packet.writeC(_player.isFishing() ? 1 : 0); // 0x01: Fishing Mode (Cant be undone by setting back to 0)
packet.writeD(_player.getFishx());
packet.writeD(_player.getFishy());
packet.writeD(_player.getFishz());

packet.writeD(_player.getAppearance().getNameColor());

packet.writeD(_heading);

packet.writeD(_player.getPledgeClass());
packet.writeD(_player.getPledgeType());

packet.writeD(_player.getAppearance().getTitleColor());

packet.writeD(_player.isCursedWeaponEquipped() ? CursedWeaponsManager.getInstance().getLevel(_player.getCursedWeaponEquippedId()) : 0);

packet.writeD(_clan != null ? _clan.getReputationScore() : 0);

// T1
packet.writeD(_player.getTransformationDisplayId());
packet.writeD(_player.getAgathionId());

// T2
packet.writeD(0x01);

// T2.3
packet.writeD(_player.getAbnormalVisualEffectSpecial());
return true;
}

@Override
public int[] getPaperdollOrder()
{
return PAPERDOLL_ORDER;
}
}

and for userinfo.java

Code: [Select]
package org.l2jmobius.gameserver.network.serverpackets;

import org.l2jmobius.Config;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.data.xml.impl.ExperienceData;
import org.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
import org.l2jmobius.gameserver.instancemanager.TerritoryWarManager;
import org.l2jmobius.gameserver.model.Elementals;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.skills.AbnormalVisualEffect;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.OutgoingPackets;

public class UserInfo implements IClientOutgoingPacket
{
private final PlayerInstance _player;
private int _relation;
private int _airShipHelm;

private final int _runSpd;
private final int _walkSpd;
private final int _swimRunSpd;
private final int _swimWalkSpd;
private final int _flyRunSpd;
private final int _flyWalkSpd;
private final double _moveMultiplier;

public UserInfo(PlayerInstance player)
{
_player = player;

final int _territoryId = TerritoryWarManager.getInstance().getRegisteredTerritoryId(player);
_relation = _player.isClanLeader() ? 0x40 : 0;
if (_player.getSiegeState() == 1)
{
if (_territoryId == 0)
{
_relation |= 0x180;
}
else
{
_relation |= 0x1000;
}
}
if (_player.getSiegeState() == 2)
{
_relation |= 0x80;
}
// _isDisguised = TerritoryWarManager.getInstance().isDisguised(character.getObjectId());
if (_player.isInAirShip() && _player.getAirShip().isCaptain(_player))
{
_airShipHelm = _player.getAirShip().getHelmItemId();
}
else
{
_airShipHelm = 0;
}

_moveMultiplier = player.getMovementSpeedMultiplier();
_runSpd = (int) Math.round(player.getRunSpeed() / _moveMultiplier);
_walkSpd = (int) Math.round(player.getWalkSpeed() / _moveMultiplier);
_swimRunSpd = (int) Math.round(player.getSwimRunSpeed() / _moveMultiplier);
_swimWalkSpd = (int) Math.round(player.getSwimWalkSpeed() / _moveMultiplier);
_flyRunSpd = player.isFlying() ? _runSpd : 0;
_flyWalkSpd = player.isFlying() ? _walkSpd : 0;
}

@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.USER_INFO.writeId(packet);

packet.writeD(_player.getX());
packet.writeD(_player.getY());
packet.writeD(_player.getZ());
packet.writeD(_player.getVehicle() != null ? _player.getVehicle().getObjectId() : 0);

packet.writeD(_player.getObjectId());
packet.writeS(_player.getAppearance().getVisibleName());
packet.writeD(_player.getRace().ordinal());
packet.writeD(_player.getAppearance().isFemale() ? 1 : 0);

packet.writeD(_player.getBaseClass());

packet.writeD(_player.getLevel());
packet.writeQ(_player.getExp());
packet.writeF((float) (_player.getExp() - ExperienceData.getInstance().getExpForLevel(_player.getLevel())) / (ExperienceData.getInstance().getExpForLevel(_player.getLevel() + 1) - ExperienceData.getInstance().getExpForLevel(_player.getLevel()))); // High Five exp %
packet.writeD(_player.getSTR());
packet.writeD(_player.getDEX());
packet.writeD(_player.getCON());
packet.writeD(_player.getINT());
packet.writeD(_player.getWIT());
packet.writeD(_player.getMEN());
packet.writeD(_player.getMaxHp());
packet.writeD((int) Math.round(_player.getCurrentHp()));
packet.writeD(_player.getMaxMp());
packet.writeD((int) Math.round(_player.getCurrentMp()));
packet.writeD((int) _player.getSp());
packet.writeD(_player.getCurrentLoad());
packet.writeD(_player.getMaxLoad());

packet.writeD(_player.getActiveWeaponItem() != null ? 40 : 20); // 20 no weapon, 40 weapon equipped

for (int slot : getPaperdollOrder())
{
packet.writeD(_player.getInventory().getPaperdollObjectId(slot));
}

for (int slot : getPaperdollOrder())
{
switch (slot)
{
case 5:
packet.writeD(VisualArmorController.getRHAND(_player));
break;
case 6:
packet.writeD(VisualArmorController.getVirtualBody(_player));
break;
case 7:
packet.writeD(VisualArmorController.getLHAND(_player));
break;
case 10:
packet.writeD(VisualArmorController.getVirtualGloves(_player));
break;
case 11:
packet.writeD(VisualArmorController.getVirtualPants(_player));
break;
case 12:
packet.writeD(VisualArmorController.getVirtualBoots(_player));
break;
case 23:
packet.writeD(VisualArmorController.getCloak(_player));
break;
default:
packet.writeD(_player.getInventory().getPaperdollItemDisplayId(slot));
}
}

for (int slot : getPaperdollOrder())
{
packet.writeD(_player.getInventory().getPaperdollAugmentationId(slot));
}

packet.writeD(_player.getInventory().getTalismanSlots());
packet.writeD(_player.getInventory().canEquipCloak() ? 1 : 0);
packet.writeD((int) _player.getPAtk(null));
packet.writeD((int) _player.getPAtkSpd());
packet.writeD((int) _player.getPDef(null));
packet.writeD(_player.getEvasionRate(null));
packet.writeD(_player.getAccuracy());
packet.writeD(_player.getCriticalHit(null, null));
packet.writeD((int) _player.getMAtk(null, null));

packet.writeD(_player.getMAtkSpd());
packet.writeD((int) _player.getPAtkSpd());

packet.writeD((int) _player.getMDef(null, null));

packet.writeD(_player.getPvpFlag());
packet.writeD(_player.getKarma());

packet.writeD(_runSpd);
packet.writeD(_walkSpd);
packet.writeD(_swimRunSpd);
packet.writeD(_swimWalkSpd);
packet.writeD(_flyRunSpd);
packet.writeD(_flyWalkSpd);
packet.writeD(_flyRunSpd);
packet.writeD(_flyWalkSpd);
packet.writeF(_moveMultiplier);
packet.writeF(_player.getAttackSpeedMultiplier());

packet.writeF(_player.getCollisionRadius());
packet.writeF(_player.getCollisionHeight());

packet.writeD(_player.getAppearance().getHairStyle());
packet.writeD(_player.getAppearance().getHairColor());
packet.writeD(_player.getAppearance().getFace());
packet.writeD(_player.isGM() ? 1 : 0); // builder level

String title = _player.getTitle();
if (_player.isGM() && _player.isInvisible())
{
title = "[Invisible]";
}
packet.writeS(title);

packet.writeD(_player.getClanId());
packet.writeD(_player.getClanCrestId());
packet.writeD(_player.getAllyId());
packet.writeD(_player.getAllyCrestId()); // ally crest id
// 0x40 leader rights
// siege flags: attacker - 0x180 sword over name, defender - 0x80 shield, 0xC0 crown (|leader), 0x1C0 flag (|leader)
packet.writeD(_relation);
packet.writeC(_player.getMountType().ordinal()); // mount type
packet.writeC(_player.getPrivateStoreType().getId());
packet.writeC(_player.hasDwarvenCraft() ? 1 : 0);
packet.writeD(_player.getPkKills());
packet.writeD(_player.getPvpKills());

packet.writeH(_player.getCubics().size());
for (int cubicId : _player.getCubics().keySet())
{
packet.writeH(cubicId);
}

packet.writeC(_player.isInPartyMatchRoom() ? 1 : 0);

packet.writeD(_player.isInvisible() ? _player.getAbnormalVisualEffects() | AbnormalVisualEffect.STEALTH.getMask() : _player.getAbnormalVisualEffects());
packet.writeC(_player.isInsideZone(ZoneId.WATER) ? 1 : _player.isFlyingMounted() ? 2 : 0);

packet.writeD(_player.getClanPrivileges().getBitmask());

packet.writeH(_player.getRecomLeft()); // c2 recommendations remaining
packet.writeH(_player.getRecomHave()); // c2 recommendations received
packet.writeD(_player.getMountNpcId() > 0 ? _player.getMountNpcId() + 1000000 : 0);
packet.writeH(_player.getInventoryLimit());

packet.writeD(_player.getClassId().getId());
packet.writeD(0x00); // special effects? circles around player...
packet.writeD(_player.getMaxCp());
packet.writeD((int) _player.getCurrentCp());
packet.writeC(_player.isMounted() || (_airShipHelm != 0) ? 0 : _player.getEnchantEffect());

packet.writeC(_player.getTeam().getId());

packet.writeD(_player.getClanCrestLargeId());
packet.writeC(_player.isNoble() ? 1 : 0); // 0x01: symbol on char menu ctrl+I
packet.writeC(_player.isHero() || (_player.isGM() && Config.GM_HERO_AURA) ? 1 : 0); // 0x01: Hero Aura

packet.writeC(_player.isFishing() ? 1 : 0); // Fishing Mode
packet.writeD(_player.getFishx()); // fishing x
packet.writeD(_player.getFishy()); // fishing y
packet.writeD(_player.getFishz()); // fishing z
packet.writeD(_player.getAppearance().getNameColor());

// new c5
packet.writeC(_player.isRunning() ? 0x01 : 0x00); // changes the Speed display on Status Window

packet.writeD(_player.getPledgeClass()); // changes the text above CP on Status Window
packet.writeD(_player.getPledgeType());

packet.writeD(_player.getAppearance().getTitleColor());

packet.writeD(_player.isCursedWeaponEquipped() ? CursedWeaponsManager.getInstance().getLevel(_player.getCursedWeaponEquippedId()) : 0);

// T1 Starts
packet.writeD(_player.getTransformationDisplayId());

final byte attackAttribute = _player.getAttackElement();
packet.writeH(attackAttribute);
packet.writeH(_player.getAttackElementValue(attackAttribute));
packet.writeH(_player.getDefenseElementValue(Elementals.FIRE));
packet.writeH(_player.getDefenseElementValue(Elementals.WATER));
packet.writeH(_player.getDefenseElementValue(Elementals.WIND));
packet.writeH(_player.getDefenseElementValue(Elementals.EARTH));
packet.writeH(_player.getDefenseElementValue(Elementals.HOLY));
packet.writeH(_player.getDefenseElementValue(Elementals.DARK));

packet.writeD(_player.getAgathionId());

// T2 Starts
packet.writeD(_player.getFame()); // Fame
packet.writeD(_player.isMinimapAllowed() ? 1 : 0); // Minimap on Hellbound
packet.writeD(_player.getVitalityPoints()); // Vitality Points
packet.writeD(_player.getAbnormalVisualEffectSpecial());
// packet.writeD(_territoryId); // CT2.3
// packet.writeD((_isDisguised ? 0x01: 0x00)); // CT2.3
// packet.writeD(_territoryId); // CT2.3
return true;
}
}


Offline Invoke

  • Heir
  • **
    • Posts: 18
I'm sorry to answer so late, but I was looking for those lines in the code but I don't see them, I suppose I will simply change the entire line of charinfo.java and userinfo.java for the code you sent me

NO LOL:D

take this diff
Code: [Select]
diff --git a/java/org/l2jmobius/gameserver/network/serverpackets/UserInfo.java b/java/org/l2jmobius/gameserver/network/serverpackets/UserInfo.java
index 3fd718c..30db077 100644
--- a/java/org/l2jmobius/gameserver/network/serverpackets/UserInfo.java
+++ b/java/org/l2jmobius/gameserver/network/serverpackets/UserInfo.java
@@ -124,34 +124,35 @@
  }
 
  for (int slot : getPaperdollOrder())
{
- packet.writeD(_player.getInventory().getPaperdollItemDisplayId(slot));
+ switch (slot)
+ {
+ case 5:
+ packet.writeD(VisualArmorController.getRHAND(_player));
+ break;
+ case 6:
+ packet.writeD(VisualArmorController.getVirtualBody(_player));
+ break;
+ case 7:
+ packet.writeD(VisualArmorController.getLHAND(_player));
+ break;
+ case 10:
+ packet.writeD(VisualArmorController.getVirtualGloves(_player));
+ break;
+ case 11:
+ packet.writeD(VisualArmorController.getVirtualPants(_player));
+ break;
+ case 12:
+ packet.writeD(VisualArmorController.getVirtualBoots(_player));
+ break;
+ case 23:
+ packet.writeD(VisualArmorController.getCloak(_player));
+ break;
+ default:
+ packet.writeD(_player.getInventory().getPaperdollItemDisplayId(slot));
+ }
+ }
- }
+
 
  for (int slot : getPaperdollOrder())
  {

Code: [Select]
diff --git a/java/org/l2jmobius/gameserver/network/serverpackets/CharInfo.java b/java/org/l2jmobius/gameserver/network/serverpackets/CharInfo.java
index 3fd718c..30db077 100644
--- a/java/org/l2jmobius/gameserver/network/serverpackets/CharInfo.java
+++ b/java/org/l2jmobius/gameserver/network/serverpackets/CharInfo.java
@@ -124,34 +124,35 @@
  }
 
  for (int slot : getPaperdollOrder())
{
- packet.writeD(_player.getInventory().getPaperdollItemDisplayId(slot));
+ switch (slot)
+ {
+ case 5:
+ packet.writeD(VisualArmorController.getRHAND(_player));
+ break;
+ case 6:
+ packet.writeD(VisualArmorController.getVirtualBody(_player));
+ break;
+ case 7:
+ packet.writeD(VisualArmorController.getLHAND(_player));
+ break;
+ case 10:
+ packet.writeD(VisualArmorController.getVirtualGloves(_player));
+ break;
+ case 11:
+ packet.writeD(VisualArmorController.getVirtualPants(_player));
+ break;
+ case 12:
+ packet.writeD(VisualArmorController.getVirtualBoots(_player));
+ break;
+ case 23:
+ packet.writeD(VisualArmorController.getCloak(_player));
+ break;
+ default:
+ packet.writeD(_player.getInventory().getPaperdollItemDisplayId(slot));
+ }
+ }
- }
+
 
  for (int slot : getPaperdollOrder())
  {


Offline alennaor

  • Heir
  • **
    • Posts: 18
lol sorry, I already had, what happened is that my browser could not find the file charinfo.java and userinfo.java and I got confused thinking that I should modify something else xD


Offline alennaor

  • Heir
  • **
    • Posts: 18
For the .dressme command, is there a way it can be configured with an html? that is, create as a store that opens with the command and shows you the html with all the possible skins to use?


Offline Invoke

  • Heir
  • **
    • Posts: 18
For the .dressme command, is there a way it can be configured with an html? that is, create as a store that opens with the command and shows you the html with all the possible skins to use?

I don't think anyone will do this for free but in any case you can implement one from fandc since their sources are shared in mxc somewhere, with some java knowledge you will be able to to addapt it


Offline oedoardo

  • Vassal
  • *
    • Posts: 3
i did the implementation for hi5 mobius project, i think with a little bit of mod you can do it in other mobius projects too.

Also this is based on the command you specified, add the command also

Also register the instance somewhere inside GameServer.java
Code: [Select]
VisualArmorController.load();

Code: [Select]
package org.l2jmobius.gameserver.extrastuff;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import org.l2jmobius.commons.database.DatabaseFactory;
import org.l2jmobius.gameserver.datatables.ItemTable;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
import org.l2jmobius.gameserver.model.items.Armor;
import org.l2jmobius.gameserver.model.items.Item;
import org.l2jmobius.gameserver.model.items.Weapon;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.items.type.ArmorType;
import org.l2jmobius.gameserver.model.items.type.WeaponType;
import org.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;

public class VisualArmorController
{
// 17 weapon types, check WeaponType
public static final int totalWeaponTypes = 17;

// 6 armor types, check ArmorType
public static final int totalArmorTypes = 6;

public static boolean[][] weaponMapping = new boolean[totalWeaponTypes][totalWeaponTypes];
public static boolean[][] armorMapping = new boolean[totalArmorTypes][totalArmorTypes];

@SuppressWarnings("null")
public static void migrate()
{
System.out.println("[VisualArmor]: Migrating the database.");
Connection con = null;
try
{
con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(VisualArmorModel.CREATE);
statement.execute();
statement.close();
}
catch (SQLException e)
{
e.printStackTrace();
}
finally
{
try
{
con.close();
}
catch (Exception e)
{
}
}
}

public static void load()
{
migrate();
generateMappings();
}

/***
* All same type armors and same type weapons can get visual.All different types* cannot get visual unless it is stated in here.
*/

public static void generateMappings()
{
for (int i = 0; i < weaponMapping.length; i++)
{
for (int j = 0; j < weaponMapping.length; j++)
{
weaponMapping[i][j] = false;
}
}

for (int i = 0; i < armorMapping.length; i++)
{
for (int j = 0; j < armorMapping.length; j++)
{
armorMapping[i][j] = false;
}
}

callRules();

}

public static void callRules()
{
// Example: a Virtual sword can mount an Equipped blunt.
weaponMapping[WeaponType.SWORD.ordinal()][WeaponType.BLUNT.ordinal()] = true;

// Example: a Virtual blunt can mount an Equipped sword.
weaponMapping[WeaponType.BLUNT.ordinal()][WeaponType.SWORD.ordinal()] = true;

// TODO: invoke - need to check for a correct type
// weaponMapping[WeaponType..BIGSWORD.ordinal()][WeaponType.BIGBLUNT.ordinal()] = true;
// weaponMapping[WeaponType.BIGBLUNT.ordinal()][WeaponType.BIGSWORD.ordinal()] = true;

armorMapping[ArmorType.SIGIL.ordinal()][ArmorType.SHIELD.ordinal()] = true;
armorMapping[ArmorType.SHIELD.ordinal()][ArmorType.SIGIL.ordinal()] = true;

// armorMapping[ArmorType.HEAVY.ordinal()][ArmorType.LIGHT.ordinal()] = true;
// armorMapping[ArmorType.HEAVY.ordinal()][ArmorType.MAGIC.ordinal()] = true;
//
// armorMapping[ArmorType.LIGHT.ordinal()][ArmorType.HEAVY.ordinal()] = true;
// armorMapping[ArmorType.LIGHT.ordinal()][ArmorType.MAGIC.ordinal()] = true;
//
// armorMapping[ArmorType.MAGIC.ordinal()][ArmorType.LIGHT.ordinal()] = true;
// armorMapping[ArmorType.MAGIC.ordinal()][ArmorType.HEAVY.ordinal()] = true;
}

public static int weaponMatching(WeaponType virtual, WeaponType equiped, int matchId, int noMatchId)
{
if (virtual == equiped)
{
return matchId;
}
if (weaponMapping[virtual.ordinal()][equiped.ordinal()] == true)
{
return matchId;
}

return noMatchId;
}

public static int armorMatching(ArmorType virtual, ArmorType equiped, int matchId, int noMatchId)
{
if (virtual == equiped)
{
return matchId;
}

if (armorMapping[virtual.ordinal()][equiped.ordinal()] == true)
{
return matchId;
}

return noMatchId;
}

public static void setVirtualRhand(PlayerInstance actor)
{
actor.visualArmor.weaponRHANDId = actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_RHAND);
}

public static void setVirtualLhand(PlayerInstance actor)
{
actor.visualArmor.weaponLHANDId = actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_LHAND);
}

public static void setVirtualGloves(PlayerInstance actor)
{
actor.visualArmor.glovesTextureId = actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_GLOVES);
}

public static void setVirtualBody(PlayerInstance actor)
{
actor.visualArmor.armorTextureId = actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_CHEST);
}

public static void setVirtualPants(PlayerInstance actor)
{
int chestId = actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_CHEST);
int pantsId = actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_LEGS);

if ((chestId != 0) && (pantsId == 0))
{
actor.visualArmor.pantsTextureId = chestId;
}
else
{
actor.visualArmor.pantsTextureId = pantsId;
}
}

public static void setVirtualBoots(PlayerInstance actor)
{
actor.visualArmor.bootsTextureId = actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_FEET);
}

// TODO: Merge the armor getters in one function.
public static int getVirtualGloves(PlayerInstance actor)
{
ItemInstance equipedItem = actor.getInventory().getPaperdollItem(Inventory.PAPERDOLL_GLOVES);
if (equipedItem == null)
{
return 0;
}
// ClassCastException wont happen unless some jackass changes the values ​​from the database.
Armor equipedGloves = (Armor) actor.getInventory().getPaperdollItem(Inventory.PAPERDOLL_GLOVES).getItem();
int equipedGlovesId = actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_GLOVES);

int glovesTextureId = actor.visualArmor.glovesTextureId;
Armor virtualGloves = (Armor) ItemTable.getInstance().getTemplate(glovesTextureId);

if (glovesTextureId != 0)
{
return armorMatching(virtualGloves.getItemType(), equipedGloves.getItemType(), glovesTextureId, equipedGlovesId);
}
return equipedGlovesId;
}

public static int getVirtualBody(PlayerInstance actor)
{
ItemInstance equipedItem = actor.getInventory().getPaperdollItem(Inventory.PAPERDOLL_CHEST);
if (equipedItem == null)
{
return 0;
}
// ClassCastException wont happen unless some jackass changes the values ​​from the database.
Armor equipedChest = (Armor) actor.getInventory().getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem();
int equipedChestId = actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_CHEST);

int chestTextureId = actor.visualArmor.armorTextureId;
Armor virtualChest = (Armor) ItemTable.getInstance().getTemplate(chestTextureId);

if (chestTextureId != 0)
{
return armorMatching(virtualChest.getItemType(), equipedChest.getItemType(), chestTextureId, equipedChestId);
}
return equipedChestId;
}

public static int getVirtualPants(PlayerInstance actor)
{
ItemInstance equipedItem = actor.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LEGS);

// Here comes the tricky part. If pants are null, then check for a fullbody armor.
if (equipedItem == null)
{
equipedItem = actor.getInventory().getPaperdollItem(Inventory.PAPERDOLL_CHEST);
}
if (equipedItem == null)
{
return 0;
}

int pantsTextureId = actor.visualArmor.pantsTextureId;

Armor equipedPants = (Armor) equipedItem.getItem();

if ((equipedPants.getBodyPart() != Item.SLOT_FULL_ARMOR) && (equipedPants.getBodyPart() != Item.SLOT_LEGS))
{
return 0;
}
int equipedPantsId = actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_LEGS);

Armor virtualPants = (Armor) ItemTable.getInstance().getTemplate(pantsTextureId);

if (pantsTextureId != 0)
{
return armorMatching(virtualPants.getItemType(), equipedPants.getItemType(), pantsTextureId, equipedPantsId);
}
return equipedPantsId;
}

public static int getVirtualBoots(PlayerInstance actor)
{
ItemInstance equipedItem = actor.getInventory().getPaperdollItem(Inventory.PAPERDOLL_FEET);
if (equipedItem == null)
{
return 0;
}
// ClassCastException wont happen unless some jackass changes the values ​​from the database.
Armor equipedBoots = (Armor) actor.getInventory().getPaperdollItem(Inventory.PAPERDOLL_FEET).getItem();
int equipedBootsId = actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_FEET);

int bootsTextureId = actor.visualArmor.bootsTextureId;
Armor virtualGloves = (Armor) ItemTable.getInstance().getTemplate(bootsTextureId);

if (bootsTextureId != 0)
{
return armorMatching(virtualGloves.getItemType(), equipedBoots.getItemType(), bootsTextureId, equipedBootsId);
}
return equipedBootsId;
}

public static int getLHAND(PlayerInstance actor)
{
ItemInstance equipedItem = actor.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LHAND);
int equipedItemId = actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_LHAND);
int weaponLHANDId = actor.visualArmor.weaponLHANDId;
Item virtualItem = ItemTable.getInstance().getTemplate(weaponLHANDId);

if ((equipedItem == null) || (weaponLHANDId == 0))
{
return equipedItemId;
}

// Only check same weapon types. Virtual replacement should not happen between armor / weapons.
if ((equipedItem.getItem() instanceof Weapon) && (virtualItem instanceof Weapon))
{
Weapon weapon = (Weapon) equipedItem.getItem();
Weapon virtualweapon = (Weapon) virtualItem;

return weaponMatching(virtualweapon.getItemType(), weapon.getItemType(), weaponLHANDId, equipedItemId);
}
else if ((equipedItem.getItem() instanceof Armor) && (virtualItem instanceof Armor))
{
Armor armor = (Armor) equipedItem.getItem();
Armor virtualarmor = (Armor) virtualItem;

return armorMatching(virtualarmor.getItemType(), armor.getItemType(), weaponLHANDId, equipedItemId);
}
return equipedItemId;
}

public static int getRHAND(PlayerInstance actor)
{
int weaponRHANDId = actor.visualArmor.weaponRHANDId;
ItemInstance equipedItem = actor.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
int equipedItemId = actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_RHAND);
Item virtualItem = ItemTable.getInstance().getTemplate(weaponRHANDId);

if ((equipedItem == null) || (weaponRHANDId == 0))
{
return equipedItemId;
}

// Only check same weapon types. Virtual replacement should not happen between armor / weapons.
if ((equipedItem.getItem() instanceof Weapon) && (virtualItem instanceof Weapon))
{
Weapon weapon = (Weapon) equipedItem.getItem();
Weapon virtualweapon = (Weapon) virtualItem;

return weaponMatching(virtualweapon.getItemType(), weapon.getItemType(), weaponRHANDId, equipedItemId);
}
else if ((equipedItem.getItem() instanceof Armor) && (virtualItem instanceof Armor))
{
Armor armor = (Armor) equipedItem.getItem();
Armor virtualarmor = (Armor) virtualItem;

return armorMatching(virtualarmor.getItemType(), armor.getItemType(), weaponRHANDId, equipedItemId);
}
return equipedItemId;

}

public static int getCloak(PlayerInstance actor)
{
if (actor.visualArmor.weaponLRHANDId == 1)
{
return 0;
}
return actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_CLOAK);

}

public static void dressMe(PlayerInstance player)
{
setVirtualBody(player);
setVirtualGloves(player);
setVirtualPants(player);
setVirtualBoots(player);
setVirtualLhand(player);
setVirtualRhand(player);

InventoryUpdate iu = new InventoryUpdate();
player.sendPacket(iu);
player.broadcastUserInfo();
InventoryUpdate iu2 = new InventoryUpdate();
player.sendPacket(iu2);
player.broadcastUserInfo();
player.sendMessage("Visual dress set is on.");
player.visualArmor.updateVisualArmor();
}
}

Code: [Select]
package org.l2jmobius.gameserver.extrastuff;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import org.l2jmobius.commons.database.DatabaseFactory;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;

public class VisualArmorModel
{
private static final String RESTORE_VISUAL_ARMOR = "SELECT GlovesId, ChestId, BootsId, PantsId, LeftHandId, RightHandId, DoubleHandId FROM visual_armor WHERE CharId =?";
private static final String UPDATE_VISUAL_ARMOR = "UPDATE visual_armor SET GlovesId = ?, ChestId = ?, BootsId = ?, PantsId = ?, LeftHandId = ?, RightHandId = ?, DoubleHandId =? WHERE CharId =?";
private static final String CREATE_VISUAL_ARMOR = "INSERT INTO visual_armor (CharId, GlovesId, ChestId, BootsId, PantsId, LeftHandId, RightHandId, DoubleHandId) values ​​(?,?,?,?,?,?,?,?)";

public static final String CREATE = "CREATE TABLE IF NOT EXISTS` visual_armor` (" + "` CharId` int (11) NOT NULL, " + "` GlovesId` int (11) NOT NULL DEFAULT '0', " + "` BootsId` int (11) NOT NULL DEFAULT '0', " + "` ChestId` int (11) NOT NULL DEFAULT '0', " + "` PantsId` int (11) NOT NULL DEFAULT '0', " + "` LeftHandId` int (11) NOT NULL DEFAULT '0', " + "` RightHandId` int (11) NOT NULL DEFAULT '0', " + "` DoubleHandId` int (11) NOT NULL DEFAULT '0', PRIMARY KEY (`CharId`))";

public static final String DROP = "DROP TABLE 'visual_armor'";

public int glovesTextureId = 0;
public int armorTextureId = 0;
public int pantsTextureId = 0;
public int bootsTextureId = 0;
public int weaponLHANDId = 0;
public int weaponRHANDId = 0;
public int weaponLRHANDId = 0;
public int ownerId;

public void updateVisualArmor()
{
Connection con = null;
try
{
con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(UPDATE_VISUAL_ARMOR);
statement.setInt(1, glovesTextureId);
statement.setInt(2, armorTextureId);
statement.setInt(3, bootsTextureId);
statement.setInt(4, pantsTextureId);
statement.setInt(5, weaponLHANDId);
statement.setInt(6, weaponRHANDId);
statement.setInt(7, weaponLRHANDId);
statement.setInt(8, ownerId);
statement.execute();
statement.close();

}
catch (SQLException e)
{
e.printStackTrace();
}
finally
{
try
{
con.close();
}
catch (Exception e)
{
}
}
}

public VisualArmorModel(PlayerInstance player)
{
ownerId = player.getObjectId();
Connection con = null;
try
{
con = DatabaseFactory.getConnection();

PreparedStatement statement = con.prepareStatement(RESTORE_VISUAL_ARMOR);
statement.setInt(1, ownerId);
ResultSet rset = statement.executeQuery();
boolean got = false;
while (rset.next())
{
glovesTextureId = rset.getInt("GlovesId");
armorTextureId = rset.getInt("ChestId");
pantsTextureId = rset.getInt("PantsId");
bootsTextureId = rset.getInt("BootsId");
weaponLHANDId = rset.getInt("LeftHandId");
weaponRHANDId = rset.getInt("RightHandId");
weaponLRHANDId = rset.getInt("DoubleHandId");
got = true;

}

rset.close();
statement.close();

if (got == false)
{
createVisualArmor();
}

InventoryUpdate iu = new InventoryUpdate();
player.sendPacket(iu);
player.broadcastUserInfo();
InventoryUpdate iu2 = new InventoryUpdate();
player.sendPacket(iu2);
player.broadcastUserInfo();
player.sendMessage("You changed clothes.");
}
catch (SQLException e)
{
e.printStackTrace();
}
finally
{
try
{
con.close();
}
catch (Exception e)
{
}
}
}

public void createVisualArmor() throws SQLException
{
Connection con = null;

try
{
con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(CREATE_VISUAL_ARMOR);

statement.setInt(1, ownerId);
statement.setInt(2, 0);
statement.setInt(3, 0);
statement.setInt(4, 0);
statement.setInt(5, 0);
statement.setInt(6, 0);
statement.setInt(7, 0);
statement.setInt(8, 0);

statement.executeUpdate();
statement.close();
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
try
{
con.close();
}
catch (Exception e)
{
}
}
}

}


Hi Invoke, you have anything on Playerinstance? Missing class visualarmor on playerinstance.