Autor Tema: [IMP] Comando "dressme"  (Leído 1808 veces)

Noviembre 07, 2013, 12:45:03 pm

Conectado swarlog

  • Desarrollador
  • Usuario
  • *
  • Mensajes: 1.579
  • Karma: 3
  • Sexo: Masculino
    • U3Games
Citar
CORE:

Código: You are not allowed to view links. Register or Login
### 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;
+ }
+}


Citar
DATA:

Código: You are not allowed to view links. Register or Login
### Eclipse Workspace Patch 1.0
#P L2J_Server_BETA
Index: java/com/l2jserver/extensions/VisualArmorController.java
===================================================================
--- java/com/l2jserver/extensions/VisualArmorController.java (revision 0)
+++ java/com/l2jserver/extensions/VisualArmorController.java (working copy)
@@ -0,0 +1,422 @@
+/*
+ * 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 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.actor.instance.L2PcInstance;
+import com.l2jserver.gameserver.model.itemcontainer.Inventory;
+import com.l2jserver.gameserver.model.items.L2Armor;
+import com.l2jserver.gameserver.model.items.L2Item;
+import com.l2jserver.gameserver.model.items.L2Weapon;
+import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
+import com.l2jserver.gameserver.model.items.type.ArmorType;
+import com.l2jserver.gameserver.model.items.type.WeaponType;
+import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate;
+
+/**
+ * @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[WeaponType.SWORD.ordinal()][WeaponType.BLUNT.ordinal()] = true;
+
+ // Example: a Virtual blunt can mount an Equipped sword.
+ weaponMapping[WeaponType.BLUNT.ordinal()][WeaponType.SWORD.ordinal()] = true;
+
+ // 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[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(WeaponType virtual, WeaponType 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(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(L2PcInstance actor)
+ {
+ actor.visualArmor.weaponRHANDId = actor.getInventory().getPaperdollItemDisplayId(Inventory.PAPERDOLL_RHAND);
+ }
+
+ public static void setVirtualLhand(L2PcInstance actor)
+ {
+ actor.visualArmor.weaponLHANDId = actor.getInventory().getPaperdollItemDisplayId(Inventory.PAPERDOLL_LHAND);
+ }
+
+ public static void setVirtualGloves(L2PcInstance actor)
+ {
+ actor.visualArmor.glovesTextureId = actor.getInventory().getPaperdollItemDisplayId(Inventory.PAPERDOLL_GLOVES);
+ }
+
+ public static void setVirtualBody(L2PcInstance actor)
+ {
+ actor.visualArmor.armorTextureId = actor.getInventory().getPaperdollItemDisplayId(Inventory.PAPERDOLL_CHEST);
+ }
+
+ public static void setVirtualPants(L2PcInstance actor)
+ {
+ int chestId = actor.getInventory().getPaperdollItemDisplayId(Inventory.PAPERDOLL_CHEST);
+ int pantsId = actor.getInventory().getPaperdollItemDisplayId(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().getPaperdollItemDisplayId(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().getPaperdollItemDisplayId(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().getPaperdollItemDisplayId(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().getPaperdollItemDisplayId(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().getPaperdollItemDisplayId(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().getPaperdollItemDisplayId(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().getPaperdollItemDisplayId(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().getPaperdollItemDisplayId(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();
+ }
+}
Index: java/com/l2jserver/extensions/VisualArmorController.java
===================================================================
--- java/com/l2jserver/extensions/VisualArmorController.java (revision 0)
+++ java/com/l2jserver/extensions/VisualArmorController.java (working copy)
@@ -0,0 +1,422 @@
+/*
+ * 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 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.actor.instance.L2PcInstance;
+import com.l2jserver.gameserver.model.itemcontainer.Inventory;
+import com.l2jserver.gameserver.model.items.L2Armor;
+import com.l2jserver.gameserver.model.items.L2Item;
+import com.l2jserver.gameserver.model.items.L2Weapon;
+import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
+import com.l2jserver.gameserver.model.items.type.ArmorType;
+import com.l2jserver.gameserver.model.items.type.WeaponType;
+import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate;
+
+/**
+ * @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[WeaponType.SWORD.ordinal()][WeaponType.BLUNT.ordinal()] = true;
+
+ // Example: a Virtual blunt can mount an Equipped sword.
+ weaponMapping[WeaponType.BLUNT.ordinal()][WeaponType.SWORD.ordinal()] = true;
+
+ // 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[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(WeaponType virtual, WeaponType 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(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(L2PcInstance actor)
+ {
+ actor.visualArmor.weaponRHANDId = actor.getInventory().getPaperdollItemDisplayId(Inventory.PAPERDOLL_RHAND);
+ }
+
+ public static void setVirtualLhand(L2PcInstance actor)
+ {
+ actor.visualArmor.weaponLHANDId = actor.getInventory().getPaperdollItemDisplayId(Inventory.PAPERDOLL_LHAND);
+ }
+
+ public static void setVirtualGloves(L2PcInstance actor)
+ {
+ actor.visualArmor.glovesTextureId = actor.getInventory().getPaperdollItemDisplayId(Inventory.PAPERDOLL_GLOVES);
+ }
+
+ public static void setVirtualBody(L2PcInstance actor)
+ {
+ actor.visualArmor.armorTextureId = actor.getInventory().getPaperdollItemDisplayId(Inventory.PAPERDOLL_CHEST);
+ }
+
+ public static void setVirtualPants(L2PcInstance actor)
+ {
+ int chestId = actor.getInventory().getPaperdollItemDisplayId(Inventory.PAPERDOLL_CHEST);
+ int pantsId = actor.getInventory().getPaperdollItemDisplayId(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().getPaperdollItemDisplayId(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().getPaperdollItemDisplayId(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().getPaperdollItemDisplayId(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().getPaperdollItemDisplayId(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().getPaperdollItemDisplayId(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().getPaperdollItemDisplayId(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().getPaperdollItemDisplayId(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().getPaperdollItemDisplayId(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();
+ }
+}
Index: java/com/l2jserver/extensions/VisualArmorModel.java
===================================================================
--- java/com/l2jserver/extensions/VisualArmorModel.java (revision 0)
+++ java/com/l2jserver/extensions/VisualArmorModel.java (working copy)
@@ -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 <http://www.gnu.org/licenses/>.
+ */
+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 6657)
+++ java/com/l2jserver/gameserver/GameServer.java (working copy)
@@ -37,6 +37,7 @@
 import com.l2jserver.L2DatabaseFactory;
 import com.l2jserver.Server;
 import com.l2jserver.UPnPService;
+import com.l2jserver.extensions.VisualArmorController;
 import com.l2jserver.gameserver.cache.HtmCache;
 import com.l2jserver.gameserver.datatables.AdminTable;
 import com.l2jserver.gameserver.datatables.ArmorSetsData;
@@ -328,6 +331,7 @@
  BoatManager.getInstance();
  AirShipManager.getInstance();
  GraciaSeedsManager.getInstance();
+     VisualArmorController.load();
 
  CastleManager.getInstance().activateInstances();
  FortManager.getInstance().activateInstances();
Index: java/com/l2jserver/gameserver/network/serverpackets/CharInfo.java
===================================================================
--- java/com/l2jserver/gameserver/network/serverpackets/CharInfo.java (revision 6657)
+++ java/com/l2jserver/gameserver/network/serverpackets/CharInfo.java (working copy)
@@ -19,6 +19,7 @@
 package com.l2jserver.gameserver.network.serverpackets;
 
 import com.l2jserver.Config;
+import com.l2jserver.extensions.VisualArmorController;
 import com.l2jserver.gameserver.datatables.NpcData;
 import com.l2jserver.gameserver.instancemanager.CursedWeaponsManager;
 import com.l2jserver.gameserver.model.PcCondOverride;
@@ -210,7 +211,32 @@
 
  for (int slot : getPaperdollOrder())
  {
- writeD(_activeChar.getInventory().getPaperdollItemDisplayId(slot));
+ switch (slot)
+ {
+ case 5:
+ writeD(VisualArmorController.getRHAND(_activeChar));
+ break;
+ case 6:
+ writeD(VisualArmorController.getVirtualBody(_activeChar));
+ break;
+ case 7:
+ writeD(VisualArmorController.getLHAND(_activeChar));
+ break;
+ case 10:
+ writeD(VisualArmorController.getVirtualGloves(_activeChar));
+ break;
+ case 11:
+ writeD(VisualArmorController.getVirtualPants(_activeChar));
+ break;
+ case 12:
+ writeD(VisualArmorController.getVirtualBoots(_activeChar));
+ break;
+ case 23:
+ writeD(VisualArmorController.getCloak(_activeChar));
+ break;
+ default:
+ writeD(_activeChar.getInventory().getPaperdollItemDisplayId(slot));
+ }
  }
 
  for (int slot : getPaperdollOrder())
Index: java/com/l2jserver/gameserver/network/serverpackets/UserInfo.java
===================================================================
--- java/com/l2jserver/gameserver/network/serverpackets/UserInfo.java (revision 6657)
+++ java/com/l2jserver/gameserver/network/serverpackets/UserInfo.java (working copy)
@@ -19,6 +19,7 @@
 package com.l2jserver.gameserver.network.serverpackets;
 
 import com.l2jserver.Config;
+import com.l2jserver.extensions.VisualArmorController;
 import com.l2jserver.gameserver.datatables.ExperienceTable;
 import com.l2jserver.gameserver.datatables.NpcData;
 import com.l2jserver.gameserver.instancemanager.CursedWeaponsManager;
@@ -123,7 +124,32 @@
 
  for (int slot : getPaperdollOrder())
  {
- writeD(_activeChar.getInventory().getPaperdollItemDisplayId(slot));
+ switch (slot)
+ {
+ case 5:
+ writeD(VisualArmorController.getRHAND(_activeChar));
+ break;
+ case 6:
+ writeD(VisualArmorController.getVirtualBody(_activeChar));
+ break;
+ case 7:
+ writeD(VisualArmorController.getLHAND(_activeChar));
+ break;
+ case 10:
+ writeD(VisualArmorController.getVirtualGloves(_activeChar));
+ break;
+ case 11:
+ writeD(VisualArmorController.getVirtualPants(_activeChar));
+ break;
+ case 12:
+ writeD(VisualArmorController.getVirtualBoots(_activeChar));
+ break;
+ case 23:
+ writeD(VisualArmorController.getCloak(_activeChar));
+ break;
+ default:
+ writeD(_activeChar.getInventory().getPaperdollItemDisplayId(slot));
+ }
  }
 
  for (int slot : getPaperdollOrder())
Index: java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java (revision 6657)
+++ java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java (working copy)
@@ -51,6 +51,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;
@@ -342,6 +343,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 (?,?,?,?)";
@@ -1133,6 +1138,7 @@
  _radar = new L2Radar(this);
 
  startVitalityTask();
+     visualArmor = new VisualArmorModel(this);
  }
 
  @Override
Index: java/com/l2jserver/extensions/VisualArmorModel.java
===================================================================
--- java/com/l2jserver/extensions/VisualArmorModel.java (revision 0)
+++ java/com/l2jserver/extensions/VisualArmorModel.java (working copy)
@@ -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 <http://www.gnu.org/licenses/>.
+ */
+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) {}
+       }
+   }
+   
+}
+

Citar
INFO:

Aqui tienen el comando . dressme .El parche funciona de la siguiente manera , te poner el armor que kieres mantener en aspecto colocas el comando .dressme y se guarda acontinuacion se colocan la armor de la que kieren recibir los stat y listo. Espero q les sirva.

BY Giorgakis

Mayo 11, 2016, 03:36:33 pm
Respuesta #1

Desconectado waleedsid3

  • Usuario
  • *
  • Mensajes: 1
  • Karma: 0
thxxxxxxxxxxxxx

Abril 11, 2018, 06:54:27 am
Respuesta #2

Desconectado 3gato

  • Usuario
  • *
  • Mensajes: 22
  • Karma: 0
  • Sexo: Masculino
  • Learn and share my knowledge!
You are not allowed to view links. Register or Login
Citar
CORE:

Código: You are not allowed to view links. Register or Login
### 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;
+ }
+}


Citar
DATA:

Código: You are not allowed to view links. Register or Login
### Eclipse Workspace Patch 1.0
#P L2J_Server_BETA
Index: java/com/l2jserver/extensions/VisualArmorController.java
===================================================================
--- java/com/l2jserver/extensions/VisualArmorController.java (revision 0)
+++ java/com/l2jserver/extensions/VisualArmorController.java (working copy)
@@ -0,0 +1,422 @@
+/*
+ * 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 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.actor.instance.L2PcInstance;
+import com.l2jserver.gameserver.model.itemcontainer.Inventory;
+import com.l2jserver.gameserver.model.items.L2Armor;
+import com.l2jserver.gameserver.model.items.L2Item;
+import com.l2jserver.gameserver.model.items.L2Weapon;
+import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
+import com.l2jserver.gameserver.model.items.type.ArmorType;
+import com.l2jserver.gameserver.model.items.type.WeaponType;
+import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate;
+
+/**
+ * @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[WeaponType.SWORD.ordinal()][WeaponType.BLUNT.ordinal()] = true;
+
+ // Example: a Virtual blunt can mount an Equipped sword.
+ weaponMapping[WeaponType.BLUNT.ordinal()][WeaponType.SWORD.ordinal()] = true;
+
+ // 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[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(WeaponType virtual, WeaponType 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(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(L2PcInstance actor)
+ {
+ actor.visualArmor.weaponRHANDId = actor.getInventory().getPaperdollItemDisplayId(Inventory.PAPERDOLL_RHAND);
+ }
+
+ public static void setVirtualLhand(L2PcInstance actor)
+ {
+ actor.visualArmor.weaponLHANDId = actor.getInventory().getPaperdollItemDisplayId(Inventory.PAPERDOLL_LHAND);
+ }
+
+ public static void setVirtualGloves(L2PcInstance actor)
+ {
+ actor.visualArmor.glovesTextureId = actor.getInventory().getPaperdollItemDisplayId(Inventory.PAPERDOLL_GLOVES);
+ }
+
+ public static void setVirtualBody(L2PcInstance actor)
+ {
+ actor.visualArmor.armorTextureId = actor.getInventory().getPaperdollItemDisplayId(Inventory.PAPERDOLL_CHEST);
+ }
+
+ public static void setVirtualPants(L2PcInstance actor)
+ {
+ int chestId = actor.getInventory().getPaperdollItemDisplayId(Inventory.PAPERDOLL_CHEST);
+ int pantsId = actor.getInventory().getPaperdollItemDisplayId(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().getPaperdollItemDisplayId(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().getPaperdollItemDisplayId(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().getPaperdollItemDisplayId(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().getPaperdollItemDisplayId(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().getPaperdollItemDisplayId(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().getPaperdollItemDisplayId(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().getPaperdollItemDisplayId(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().getPaperdollItemDisplayId(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();
+ }
+}
Index: java/com/l2jserver/extensions/VisualArmorController.java
===================================================================
--- java/com/l2jserver/extensions/VisualArmorController.java (revision 0)
+++ java/com/l2jserver/extensions/VisualArmorController.java (working copy)
@@ -0,0 +1,422 @@
+/*
+ * 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 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.actor.instance.L2PcInstance;
+import com.l2jserver.gameserver.model.itemcontainer.Inventory;
+import com.l2jserver.gameserver.model.items.L2Armor;
+import com.l2jserver.gameserver.model.items.L2Item;
+import com.l2jserver.gameserver.model.items.L2Weapon;
+import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
+import com.l2jserver.gameserver.model.items.type.ArmorType;
+import com.l2jserver.gameserver.model.items.type.WeaponType;
+import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate;
+
+/**
+ * @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[WeaponType.SWORD.ordinal()][WeaponType.BLUNT.ordinal()] = true;
+
+ // Example: a Virtual blunt can mount an Equipped sword.
+ weaponMapping[WeaponType.BLUNT.ordinal()][WeaponType.SWORD.ordinal()] = true;
+
+ // 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[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(WeaponType virtual, WeaponType 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(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(L2PcInstance actor)
+ {
+ actor.visualArmor.weaponRHANDId = actor.getInventory().getPaperdollItemDisplayId(Inventory.PAPERDOLL_RHAND);
+ }
+
+ public static void setVirtualLhand(L2PcInstance actor)
+ {
+ actor.visualArmor.weaponLHANDId = actor.getInventory().getPaperdollItemDisplayId(Inventory.PAPERDOLL_LHAND);
+ }
+
+ public static void setVirtualGloves(L2PcInstance actor)
+ {
+ actor.visualArmor.glovesTextureId = actor.getInventory().getPaperdollItemDisplayId(Inventory.PAPERDOLL_GLOVES);
+ }
+
+ public static void setVirtualBody(L2PcInstance actor)
+ {
+ actor.visualArmor.armorTextureId = actor.getInventory().getPaperdollItemDisplayId(Inventory.PAPERDOLL_CHEST);
+ }
+
+ public static void setVirtualPants(L2PcInstance actor)
+ {
+ int chestId = actor.getInventory().getPaperdollItemDisplayId(Inventory.PAPERDOLL_CHEST);
+ int pantsId = actor.getInventory().getPaperdollItemDisplayId(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().getPaperdollItemDisplayId(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().getPaperdollItemDisplayId(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().getPaperdollItemDisplayId(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().getPaperdollItemDisplayId(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().getPaperdollItemDisplayId(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().getPaperdollItemDisplayId(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().getPaperdollItemDisplayId(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().getPaperdollItemDisplayId(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();
+ }
+}
Index: java/com/l2jserver/extensions/VisualArmorModel.java
===================================================================
--- java/com/l2jserver/extensions/VisualArmorModel.java (revision 0)
+++ java/com/l2jserver/extensions/VisualArmorModel.java (working copy)
@@ -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 <http://www.gnu.org/licenses/>.
+ */
+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 6657)
+++ java/com/l2jserver/gameserver/GameServer.java (working copy)
@@ -37,6 +37,7 @@
 import com.l2jserver.L2DatabaseFactory;
 import com.l2jserver.Server;
 import com.l2jserver.UPnPService;
+import com.l2jserver.extensions.VisualArmorController;
 import com.l2jserver.gameserver.cache.HtmCache;
 import com.l2jserver.gameserver.datatables.AdminTable;
 import com.l2jserver.gameserver.datatables.ArmorSetsData;
@@ -328,6 +331,7 @@
  BoatManager.getInstance();
  AirShipManager.getInstance();
  GraciaSeedsManager.getInstance();
+     VisualArmorController.load();
 
  CastleManager.getInstance().activateInstances();
  FortManager.getInstance().activateInstances();
Index: java/com/l2jserver/gameserver/network/serverpackets/CharInfo.java
===================================================================
--- java/com/l2jserver/gameserver/network/serverpackets/CharInfo.java (revision 6657)
+++ java/com/l2jserver/gameserver/network/serverpackets/CharInfo.java (working copy)
@@ -19,6 +19,7 @@
 package com.l2jserver.gameserver.network.serverpackets;
 
 import com.l2jserver.Config;
+import com.l2jserver.extensions.VisualArmorController;
 import com.l2jserver.gameserver.datatables.NpcData;
 import com.l2jserver.gameserver.instancemanager.CursedWeaponsManager;
 import com.l2jserver.gameserver.model.PcCondOverride;
@@ -210,7 +211,32 @@
 
  for (int slot : getPaperdollOrder())
  {
- writeD(_activeChar.getInventory().getPaperdollItemDisplayId(slot));
+ switch (slot)
+ {
+ case 5:
+ writeD(VisualArmorController.getRHAND(_activeChar));
+ break;
+ case 6:
+ writeD(VisualArmorController.getVirtualBody(_activeChar));
+ break;
+ case 7:
+ writeD(VisualArmorController.getLHAND(_activeChar));
+ break;
+ case 10:
+ writeD(VisualArmorController.getVirtualGloves(_activeChar));
+ break;
+ case 11:
+ writeD(VisualArmorController.getVirtualPants(_activeChar));
+ break;
+ case 12:
+ writeD(VisualArmorController.getVirtualBoots(_activeChar));
+ break;
+ case 23:
+ writeD(VisualArmorController.getCloak(_activeChar));
+ break;
+ default:
+ writeD(_activeChar.getInventory().getPaperdollItemDisplayId(slot));
+ }
  }
 
  for (int slot : getPaperdollOrder())
Index: java/com/l2jserver/gameserver/network/serverpackets/UserInfo.java
===================================================================
--- java/com/l2jserver/gameserver/network/serverpackets/UserInfo.java (revision 6657)
+++ java/com/l2jserver/gameserver/network/serverpackets/UserInfo.java (working copy)
@@ -19,6 +19,7 @@
 package com.l2jserver.gameserver.network.serverpackets;
 
 import com.l2jserver.Config;
+import com.l2jserver.extensions.VisualArmorController;
 import com.l2jserver.gameserver.datatables.ExperienceTable;
 import com.l2jserver.gameserver.datatables.NpcData;
 import com.l2jserver.gameserver.instancemanager.CursedWeaponsManager;
@@ -123,7 +124,32 @@
 
  for (int slot : getPaperdollOrder())
  {
- writeD(_activeChar.getInventory().getPaperdollItemDisplayId(slot));
+ switch (slot)
+ {
+ case 5:
+ writeD(VisualArmorController.getRHAND(_activeChar));
+ break;
+ case 6:
+ writeD(VisualArmorController.getVirtualBody(_activeChar));
+ break;
+ case 7:
+ writeD(VisualArmorController.getLHAND(_activeChar));
+ break;
+ case 10:
+ writeD(VisualArmorController.getVirtualGloves(_activeChar));
+ break;
+ case 11:
+ writeD(VisualArmorController.getVirtualPants(_activeChar));
+ break;
+ case 12:
+ writeD(VisualArmorController.getVirtualBoots(_activeChar));
+ break;
+ case 23:
+ writeD(VisualArmorController.getCloak(_activeChar));
+ break;
+ default:
+ writeD(_activeChar.getInventory().getPaperdollItemDisplayId(slot));
+ }
  }
 
  for (int slot : getPaperdollOrder())
Index: java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java (revision 6657)
+++ java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java (working copy)
@@ -51,6 +51,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;
@@ -342,6 +343,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 (?,?,?,?)";
@@ -1133,6 +1138,7 @@
  _radar = new L2Radar(this);
 
  startVitalityTask();
+     visualArmor = new VisualArmorModel(this);
  }
 
  @Override
Index: java/com/l2jserver/extensions/VisualArmorModel.java
===================================================================
--- java/com/l2jserver/extensions/VisualArmorModel.java (revision 0)
+++ java/com/l2jserver/extensions/VisualArmorModel.java (working copy)
@@ -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 <http://www.gnu.org/licenses/>.
+ */
+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) {}
+       }
+   }
+   
+}
+

Citar
INFO:

Aqui tienen el comando . dressme .El parche funciona de la siguiente manera , te poner el armor que kieres mantener en aspecto colocas el comando .dressme y se guarda acontinuacion se colocan la armor de la que kieren recibir los stat y listo. Espero q les sirva.

BY Giorgakis


El código funciona.

la parte de las armaduras / escudo / cloack funciona perfectamente.

pero la parte de las armas tiene algunos errores. ¿Cómo puedes mantener la apariencia del Blunt y usar la Sword?
¡Usa la espada del tanque con la mirada de la espada del titán!

el codigo debería funcionar sólo si intercambia Sword x Sword, Blunt x Blunt.

ERRO:



Tiene que corregir para

SWORD "rhand"  x  SWORD  "rhand"
SWORD "lrhand"  x  SWORD  "lrhand"

e

BLUNT "rhand"  x   BLUNT  "rhand"
BLUNT "lrhand"  x   BLUNT  "lrhand"

Abril 21, 2018, 12:51:20 am
Respuesta #3

Conectado swarlog

  • Desarrollador
  • Usuario
  • *
  • Mensajes: 1.579
  • Karma: 3
  • Sexo: Masculino
    • U3Games
Para ello tendrias que crear condiciones y configurarlas a vuestro gusto,

Abril 22, 2018, 05:53:32 am
Respuesta #4

Desconectado 3gato

  • Usuario
  • *
  • Mensajes: 22
  • Karma: 0
  • Sexo: Masculino
  • Learn and share my knowledge!
You are not allowed to view links. Register or Login
Para ello tendrias que crear condiciones y configurarlas a vuestro gusto,


Yes !

Quiero restringir el uso de armas dependiendo del arma que utilizó cuando activó el comando de vestir. Ejemplo: Una espada de mano sólo trabaja con otra espada Una espada de mano y dos manos sólo trabaja con otra espada de dos manos. ¿puede min ayudar?

Abril 25, 2018, 04:04:12 pm
Respuesta #5

Conectado swarlog

  • Desarrollador
  • Usuario
  • *
  • Mensajes: 1.579
  • Karma: 3
  • Sexo: Masculino
    • U3Games
You are not allowed to view links. Register or Login
You are not allowed to view links. Register or Login
Para ello tendrias que crear condiciones y configurarlas a vuestro gusto,


Yes !

Quiero restringir el uso de armas dependiendo del arma que utilizó cuando activó el comando de vestir. Ejemplo: Una espada de mano sólo trabaja con otra espada Una espada de mano y dos manos sólo trabaja con otra espada de dos manos. ¿puede min ayudar?

Lo solucionaste o aun necesitas soporte?

Avisa para lo que sea, que ando sin tiempo y quiero ponerme al día este fin de semana.

Saludos ^^

Abril 26, 2018, 11:52:16 pm
Respuesta #6

Desconectado 3gato

  • Usuario
  • *
  • Mensajes: 22
  • Karma: 0
  • Sexo: Masculino
  • Learn and share my knowledge!
You are not allowed to view links. Register or Login
You are not allowed to view links. Register or Login
You are not allowed to view links. Register or Login
Para ello tendrias que crear condiciones y configurarlas a vuestro gusto,


Yes !

Quiero restringir el uso de armas dependiendo del arma que utilizó cuando activó el comando de vestir. Ejemplo: Una espada de mano sólo trabaja con otra espada Una espada de mano y dos manos sólo trabaja con otra espada de dos manos. ¿puede min ayudar?

Lo solucionaste o aun necesitas soporte?

Avisa para lo que sea, que ando sin tiempo y quiero ponerme al día este fin de semana.

Saludos ^^

Necesito ayuda.
No puedo resolver