Guest User

Untitled

a guest
Jul 1st, 2013
280
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.l2jserver.gameserver.model.actor.instance;
  2.  
  3. import java.util.StringTokenizer;
  4.  
  5. import com.l2jserver.gameserver.datatables.AugmentationData;
  6. import com.l2jserver.gameserver.datatables.ItemTable;
  7. import com.l2jserver.gameserver.model.actor.templates.L2NpcTemplate;
  8. import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
  9. import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate;
  10. import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
  11. import com.l2jserver.util.Rnd;
  12.  
  13. public class L2ItemEnchanterInstance extends L2NpcInstance
  14. {
  15.     /**
  16.      * @param objectId
  17.      * @param template
  18.      * By Drake2wow
  19.      */
  20.     public L2ItemEnchanterInstance(int objectId, L2NpcTemplate template)
  21.     {
  22.         super(objectId, template);
  23.         setInstanceType(InstanceType.L2ItemEnchanterInstance);
  24.     }  
  25.     int ObjId=getObjectId();
  26.     public static int WeapEnch=20;
  27.     public static int ArmorEnch=20;
  28.     int IngredientID=57;//adena
  29.     int IeAmountWeap=300;//300 adena needed for weapons
  30.     int IeAmountArmor=100;//100 adena needed for armors
  31.     boolean flip=true;
  32.     String IeName=ItemTable.getInstance().createDummyItem(IngredientID).getName();
  33.     @Override
  34.     public void showChatWindow(L2PcInstance player)
  35.     { //WEAPONS on the initial screen;
  36.         L2ItemInstance[] weap=player.getInventory().getWeaponsList();
  37.         int size=weap.length;String DopWepText="";String bgcolor="";
  38.         for (int i=0;i!=size;i++)
  39.         {
  40.             flip = !flip;
  41.             String icon=weap[i].getItem().getIcon();String name=weap[i].getItemName();
  42.             String Action = "Item "+String.valueOf(weap[i].getObjectId());
  43.             bgcolor="";
  44.             if (flip == true) bgcolor = "bgcolor=131210";
  45.             DopWepText += "<table "+bgcolor+"><tr><td width=40><button action=\"bypass -h npc_"+ObjId+"_"+Action+"\" width=32 height=32 back=icon"+icon+" fore=icon."+icon+"></td><td width=220><table width=300><tr><td><font color=LEVEL>+"+WeapEnch+"</font> "+name+"<font color=a1a1a1></font> <font color=ae9977></font></td><td></td></tr><tr><td><font color=%col1%> "+IeAmountWeap+" "+IeName+"</font></td></tr></table></td></tr></table>";
  46.         }
  47.         NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
  48.         html.setFile(player.getHtmlPrefix(), "data/html/drake2wow/700000.htm");
  49.         int Q = 0;
  50.         if (player.getInventory().getItemByItemId(IngredientID) != null) Q = (int) player.getInventory().getItemByItemId(IngredientID).getCount();
  51.         html.replace("%type%", "Armors");
  52.         html.replace("%objectId%", String.valueOf(ObjId));
  53.         html.replace("%Quan%", String.valueOf(Q));
  54.         html.replace("%Cur%", String.valueOf(IeName));
  55.         html.replace("%HyperText%", String.valueOf(DopWepText));
  56.         player.sendPacket(html);
  57.     }
  58.     @Override
  59.     public void onBypassFeedback(L2PcInstance player, String command)
  60.     {
  61.         StringTokenizer st = new StringTokenizer(command, " ");
  62.         String actualCommand = st.nextToken();
  63.         if (actualCommand.equalsIgnoreCase("WeaponsGo"))
  64.         {
  65.             L2ItemInstance[] weap=player.getInventory().getWeaponsList();
  66.             int size=weap.length;String DopWepText="";String bgcolor="";
  67.             for (int i=0;i!=size;i++)
  68.             {
  69.                 flip = !flip;
  70.                 String icon=weap[i].getItem().getIcon();String name=weap[i].getItemName();
  71.                 String Action = "Item "+String.valueOf(weap[i].getObjectId());
  72.                 bgcolor="";
  73.                 if (flip == true) bgcolor = "bgcolor=131210";
  74.                 DopWepText += "<table "+bgcolor+"><tr><td width=40><button action=\"bypass -h npc_"+ObjId+"_"+Action+"\" width=32 height=32 back=icon"+icon+" fore=icon."+icon+"></td><td width=220><table width=300><tr><td><font color=LEVEL>+"+WeapEnch+"</font> "+name+"<font color=a1a1a1></font> <font color=ae9977></font></td><td></td></tr><tr><td><font color=%col1%> "+IeAmountWeap+" "+IeName+"</font></td></tr></table></td></tr></table>";
  75.             }
  76.             NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
  77.             html.setFile(player.getHtmlPrefix(), "data/html/drake2wow/700000.htm");
  78.             int Q = 0;
  79.             if (player.getInventory().getItemByItemId(IngredientID) != null) Q = (int) player.getInventory().getItemByItemId(IngredientID).getCount();
  80.             html.replace("%type%", "Armors");
  81.             html.replace("%objectId%", String.valueOf(ObjId));
  82.             html.replace("%Quan%", String.valueOf(Q));
  83.             html.replace("%Cur%", String.valueOf(IeName));
  84.             html.replace("%HyperText%", String.valueOf(DopWepText));
  85.             player.sendPacket(html);
  86.         }
  87.         if (actualCommand.equalsIgnoreCase("ArmorsGo"))
  88.         {
  89.             L2ItemInstance[] armor=player.getInventory().getArmorsList();
  90.             int size=armor.length;String DopWepText="";String bgcolor="";
  91.             for (int i=0;i!=size;i++)
  92.             {
  93.                 flip = !flip;
  94.                 String icon=armor[i].getItem().getIcon();String name=armor[i].getItemName();
  95.                 String Action = "Item "+String.valueOf(armor[i].getObjectId());
  96.                 bgcolor="";
  97.                 if (flip == true) bgcolor = "bgcolor=131210";
  98.                 DopWepText += "<table "+bgcolor+"><tr><td width=40><button action=\"bypass -h npc_"+ObjId+"_"+Action+"\" width=32 height=32 back=icon"+icon+" fore=icon."+icon+"></td><td width=220><table width=300><tr><td><font color=LEVEL>+"+WeapEnch+"</font> "+name+"<font color=a1a1a1></font> <font color=ae9977></font></td><td></td></tr><tr><td><font color=%col1%> "+IeAmountArmor+" "+IeName+"</font></td></tr></table></td></tr></table>";
  99.             }
  100.             NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
  101.             html.setFile(player.getHtmlPrefix(), "data/html/drake2wow/700000.htm");
  102.             int Q = 0;
  103.             if (player.getInventory().getItemByItemId(IngredientID) != null) Q = (int) player.getInventory().getItemByItemId(IngredientID).getCount();
  104.             html.replace("%type%", "Weapons");
  105.             html.replace("%objectId%", String.valueOf(ObjId));
  106.             html.replace("%Quan%", String.valueOf(Q));
  107.             html.replace("%Cur%", String.valueOf(IeName));
  108.             html.replace("%HyperText%", String.valueOf(DopWepText));
  109.             player.sendPacket(html);
  110.         }
  111.         if (actualCommand.equalsIgnoreCase("Item"))
  112.         {
  113.             String bbx = st.nextToken();int own=0;int ench=WeapEnch;int amount=IeAmountWeap;
  114.             int id=Integer.valueOf(bbx);
  115.             if (player.getInventory().getItemByObjectId(id) == null)
  116.             {
  117.                 player.sendMessage("That item doesn't exist in your inventory");
  118.                 return;
  119.             }
  120.             L2ItemInstance item=player.getInventory().getItemByObjectId(id);
  121.             if (item.isArmor())
  122.             {
  123.                 ench=ArmorEnch;amount=IeAmountArmor;
  124.             }
  125.             if (player.getInventory().getItemByItemId(IngredientID)!=null)
  126.             {
  127.                 own=(int) player.getInventory().getItemByItemId(IngredientID).getCount();
  128.                 if (own<amount)
  129.                     player.sendMessage("Incorect item count");
  130.                 else
  131.                 {
  132.                     item.setEnchantLevel(ench);
  133.                     player.destroyItemByItemId("Enchater", IngredientID, amount, player, true);
  134.                     player.sendMessage("Success: Your "+item.getItemName()+" has been enchanted to +"+ench);
  135.                     if (!item.isAugmented() && Rnd.get(100)<=25)
  136.                         item.setAugmentation(AugmentationData.getInstance().generateRandomAugmentation(Rnd.get(2,3), Rnd.get(7,9), 100));
  137.                     InventoryUpdate iu = new InventoryUpdate();
  138.                     iu.addModifiedItem(item);
  139.                     player.sendPacket(iu);
  140.                     player.broadcastUserInfo();
  141.                 }
  142.             }
  143.         }
  144.         super.onBypassFeedback(player, command);
  145.     }
  146. }      
  147.  
  148.  
  149. gameserver/model/itemcontainer/PcInventory.java
  150. =================================================
  151.  
  152.  
  153.  
  154.  
  155.         L2ItemInstance[] result = list.toArray(new L2ItemInstance[list.size()]);
  156.         FastList.recycle(list);
  157.        
  158.         return result;
  159.     }
  160. +   public L2ItemInstance[] getWeaponsList()
  161. +   {
  162. +       FastList<L2ItemInstance> list = FastList.newInstance();
  163. +       for (L2ItemInstance item : _items)
  164. +       {
  165. +           if (item != null && item.isEnchantable()==1 && item.isWeapon() && item.getEnchantLevel()<L2ItemEnchanterInstance.WeapEnch)
  166. +               list.add(item);
  167. +       }
  168. +      
  169. +       L2ItemInstance[] result = list.toArray(new L2ItemInstance[list.size()]);
  170. +       FastList.recycle(list);
  171. +       return result;
  172. +   }
  173. +   public L2ItemInstance[] getArmorsList()
  174. +   {
  175. +       FastList<L2ItemInstance> list = FastList.newInstance();
  176. +       for (L2ItemInstance item : _items)
  177. +       {
  178. +           if (item != null && item.isEnchantable()==1 && item.isArmor() && item.getEnchantLevel()<L2ItemEnchanterInstance.ArmorEnch)
  179. +              
  180. +               list.add(item);
  181. +       }
  182. +      
  183. +       L2ItemInstance[] result = list.toArray(new L2ItemInstance[list.size()]);
  184. +       FastList.recycle(list);
  185. +       return result;
  186. +   }
  187.     /**
  188.      * Get all element items
  189.      * @return
  190.      */
  191.     public L2ItemInstance[] getElementItems()
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×