niraklas Posted June 27, 2012 Posted June 27, 2012 Hello i need one java code which when you change subclass you put off the armor to avoid bugs Quote
0 ^Wyatt Posted June 27, 2012 Posted June 27, 2012 try adding it on L2PcInstance, addSubClass method Index: java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java =================================================================== --- java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java (revision 268) +++ java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java (working copy) @@ -11554,6 +11554,13 @@ if (_transformation != null) return false; + this.getInventory().unEquipItemInSlot(Inventory.PAPERDOLL_GLOVES); + this.getInventory().unEquipItemInSlot(Inventory.PAPERDOLL_CHEST); + this.getInventory().unEquipItemInSlot(Inventory.PAPERDOLL_CLOAK); + this.getInventory().unEquipItemInSlot(Inventory.PAPERDOLL_FEET); + this.getInventory().unEquipItemInSlot(Inventory.PAPERDOLL_LEGS); + this.getInventory().unEquipItemInSlot(Inventory.PAPERDOLL_HEAD); + // Remove active item skills before saving char to database // because next time when choosing this class, weared items can // be different Quote
0 vampir Posted June 28, 2012 Posted June 28, 2012 try adding it on L2PcInstance, addSubClass method Index: java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java =================================================================== --- java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java (revision 268) +++ java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java (working copy) @@ -11554,6 +11554,13 @@ if (_transformation != null) return false; + this.getInventory().unEquipItemInSlot(Inventory.PAPERDOLL_GLOVES); + this.getInventory().unEquipItemInSlot(Inventory.PAPERDOLL_CHEST); + this.getInventory().unEquipItemInSlot(Inventory.PAPERDOLL_CLOAK); + this.getInventory().unEquipItemInSlot(Inventory.PAPERDOLL_FEET); + this.getInventory().unEquipItemInSlot(Inventory.PAPERDOLL_LEGS); + this.getInventory().unEquipItemInSlot(Inventory.PAPERDOLL_HEAD); + // Remove active item skills before saving char to database // because next time when choosing this class, weared items can // be different if i may suggest something, try to avoid L2PcInstance for such things, also, better would be something like that: for(int i = 0;i<Inventory.PAPERDOLL_TOTALSLOTS;i++) getInventory().unEquipItemInSlot(i); also u can do thread to equip those items after some time for example: private class EquipItems implements Runnable { @Override public void run() { for(int i = 0;i<Inventory.PAPERDOLL_TOTALSLOTS;i++) getInventory().equipItemInSlot(i); } } and u apply it with: ThreadPoolManager.getInstance.scheduleGeneral(new EquipItems(), timeInMilis); hf :) Quote
0 Rizlaaa Posted June 29, 2012 Posted June 29, 2012 if i may suggest something, try to avoid L2PcInstance for such things, also, better would be something like that: for(int i = 0;i<Inventory.PAPERDOLL_TOTALSLOTS;i++) getInventory().unEquipItemInSlot(i); also u can do thread to equip those items after some time for example: private class EquipItems implements Runnable { @Override public void run() { for(int i = 0;i<Inventory.PAPERDOLL_TOTALSLOTS;i++) getInventory().equipItemInSlot(i); } } and u apply it with: ThreadPoolManager.getInstance.scheduleGeneral(new EquipItems(), timeInMilis); hf :) for(int i = 0;i<Inventory.PAPERDOLL_TOTALSLOTS;i++) getInventory().equipItemInSlot(i); It won't work since these items are not equiped. He must create a list type of L2ItemInstance and add these items in ( so it will need L2PcInstance ) , then after x time just equip the items from the list and clear the list. Quote
0 Tryskell Posted June 29, 2012 Posted June 29, 2012 ^Wyatt solution is the most simple and accurate, you can drop "this." as it's optional, but else, it's the only decent solution. - PAPERDOLL_TOTALSLOTS means you unequip the 20 slots, when we need to drop only main pieces. - you equipItemInSlot( when it should be unEquipItemInSlot(... I guess you simply misread. Anyway. - the task is useless as there is no need to delay. Quote
0 AbsolutePower Posted June 30, 2012 Posted June 30, 2012 Hello i need one java code which when you change subclass you put off the armor to avoid bugs you can make this: player.getInventory().reloadEquippedItems(); or you can make if (player.getActiveWeaponInstance() != null || player.getActiveShieldInstance() != null) player.disarmWeapons(); if (player.getActiveChestArmorItem() != null) { final L2ItemInstance chest = player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_CHEST); if (chest != null) { final L2ItemInstance[] unequipped = player.getInventory().unEquipItemInBodySlotAndRecord(chest.getItem().getBodyPart()); final InventoryUpdate iu = new InventoryUpdate(); for (L2ItemInstance element : unequipped) iu.addModifiedItem(element); sendPacket(iu); } } Quote
Question
niraklas
Hello i need one java code which when you change subclass you put off the armor to avoid bugs
5 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.