warc222

Fastaugment By AbsolutePower v2

Sep 17th, 2015
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.13 KB | None | 0 0
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package com.l2jhellas.gameserver.model.actor.instance;
  16.  
  17. import java.util.StringTokenizer;
  18.  
  19. import com.l2jhellas.gameserver.ai.CtrlIntention;
  20. import com.l2jhellas.gameserver.datatables.xml.AugmentationData;
  21. import com.l2jhellas.gameserver.model.L2Augmentation;
  22. import com.l2jhellas.gameserver.model.L2ItemInstance;
  23. import com.l2jhellas.gameserver.network.SystemMessageId;
  24. import com.l2jhellas.gameserver.network.serverpackets.ActionFailed;
  25. import com.l2jhellas.gameserver.network.serverpackets.ExShowScreenMessage;
  26. import com.l2jhellas.gameserver.network.serverpackets.ExVariationCancelResult;
  27. import com.l2jhellas.gameserver.network.serverpackets.ExVariationResult;
  28. import com.l2jhellas.gameserver.network.serverpackets.InventoryUpdate;
  29. import com.l2jhellas.gameserver.network.serverpackets.MyTargetSelected;
  30. import com.l2jhellas.gameserver.network.serverpackets.NpcHtmlMessage;
  31. import com.l2jhellas.gameserver.network.serverpackets.SkillList;
  32. import com.l2jhellas.gameserver.network.serverpackets.SocialAction;
  33. import com.l2jhellas.gameserver.network.serverpackets.StatusUpdate;
  34. import com.l2jhellas.gameserver.network.serverpackets.SystemMessage;
  35. import com.l2jhellas.gameserver.network.serverpackets.ValidateLocation;
  36. import com.l2jhellas.gameserver.network.serverpackets.ExShowScreenMessage.SMPOS;
  37. import com.l2jhellas.gameserver.templates.L2NpcTemplate;
  38. import com.l2jhellas.gameserver.templates.L2WeaponType;
  39. import com.l2jhellas.util.Rnd;
  40.  
  41.  
  42. /**
  43. * Author AbsolutePower
  44. */
  45. public final class L2FastAugByAbsoInstance extends L2NpcInstance
  46. {
  47.  
  48. public L2FastAugByAbsoInstance(int objectId, L2NpcTemplate template)
  49. {
  50. super(objectId, template);
  51. }
  52.  
  53. @Override
  54. public void onBypassFeedback(L2PcInstance player, String command)
  55. {
  56. if(player==null)
  57. return;
  58.  
  59. final StringTokenizer st = new StringTokenizer(command, " ");
  60. final String currentcommand = st.nextToken();
  61.  
  62. final String letsSliptIt = currentcommand;
  63. final String[] nowTheId = letsSliptIt.split("-");
  64.  
  65. final String OurSplititCommand = nowTheId[0];
  66. final String FinallyWeHaveObjectId = nowTheId[1];
  67.  
  68.  
  69. if(OurSplititCommand.startsWith("showremlist"))
  70. {
  71. showListWindowForRemove(player);
  72. player.sendPacket(new ActionFailed());
  73. }
  74.  
  75. else if(OurSplititCommand.startsWith("showauglist"))
  76. {
  77. showListWindow(player);
  78. player.sendPacket(new ActionFailed());
  79. }
  80.  
  81. else if(OurSplititCommand.startsWith("tryremove"))
  82. {
  83. final L2ItemInstance item = player.getInventory().getItemByObjectId(Integer.parseInt(FinallyWeHaveObjectId));
  84.  
  85. if(item == null )
  86. {
  87. player.sendPacket(new ActionFailed());
  88. return;
  89. }
  90.  
  91. if (item.isEquipped())
  92. {
  93. player.disarmWeapons();
  94. player.broadcastUserInfo();
  95. }
  96.  
  97. item.removeAugmentation();
  98.  
  99. player.sendPacket(new ExVariationCancelResult(1));
  100.  
  101. InventoryUpdate iu = new InventoryUpdate();
  102. iu.addModifiedItem(item);
  103. player.sendPacket(iu);
  104.  
  105. player.sendPacket(new SkillList());
  106.  
  107. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.AUGMENTATION_HAS_BEEN_SUCCESSFULLY_REMOVED_FROM_YOUR_S1);
  108. sm.addItemName(item);
  109. player.sendPacket(sm);
  110. showListWindowForRemove(player);
  111. player.sendPacket(new ActionFailed());
  112. }
  113.  
  114. else if(OurSplititCommand.startsWith("tryaug"))
  115. {
  116. if (player.getInventory().getInventoryItemCount(57, 0) < 200000)
  117. {
  118. player.sendMessage("You do not have enough adena!");
  119. player.sendPacket(new ActionFailed());
  120. return;
  121. }
  122.  
  123. final L2ItemInstance item = player.getInventory().getItemByObjectId(Integer.parseInt(FinallyWeHaveObjectId));
  124.  
  125.  
  126. if(item == null )
  127. {
  128. player.sendPacket(new ActionFailed());
  129. return;
  130. }
  131.  
  132. if (item.isEquipped())
  133. {
  134. player.disarmWeapons();
  135. player.broadcastUserInfo();
  136. }
  137.  
  138. final L2Augmentation aug = AugmentationData.getInstance().generateRandomAugmentation(item,2,2);
  139. item.setAugmentation(aug);
  140.  
  141. final int stat12 = 0x0000FFFF & aug.getAugmentationId();
  142. final int stat34 = aug.getAugmentationId() >> 16;
  143. player.sendPacket(new ExVariationResult(stat12, stat34, 1));
  144.  
  145. InventoryUpdate iu = new InventoryUpdate();
  146. iu.addModifiedItem(item);
  147. player.sendPacket(iu);
  148.  
  149. StatusUpdate su = new StatusUpdate(player.getObjectId());
  150. su.addAttribute(StatusUpdate.CUR_LOAD, player.getCurrentLoad());
  151. player.sendPacket(su);
  152.  
  153. showListWindow(player);
  154.  
  155. player.getInventory().reduceAdena("FastAugh", 200000, player, null);
  156.  
  157. player.sendPacket(SystemMessageId.THE_ITEM_WAS_SUCCESSFULLY_AUGMENTED);
  158.  
  159. if(item.getAugmentation().getSkill()!=null)
  160. {
  161. player.sendPacket(new ExShowScreenMessage("You have " + item.getAugmentation().getSkill().getName(), 5000, SMPOS.TOP_CENTER, true));
  162. player.sendPacket(new SkillList());
  163. }
  164.  
  165. player.sendPacket(new ActionFailed());
  166.  
  167. }
  168.  
  169. super.onBypassFeedback(player, command);
  170.  
  171. player.sendPacket(new ActionFailed());
  172. }
  173.  
  174. public void showListWindow(L2PcInstance player)
  175. {
  176. NpcHtmlMessage nhm = new NpcHtmlMessage(5);
  177. StringBuilder tb = new StringBuilder("");
  178. String Rem = "RemoveAug";
  179.  
  180. tb.append("<html><head><title>By AbsolutePower</title></head><body>");
  181. tb.append("<center>");
  182. tb.append("<table width=\"250\" cellpadding=\"5\" bgcolor=\"000000\">");
  183. tb.append("<tr>");
  184. tb.append("<td width=\"45\" valign=\"top\" align=\"center\"><img src=\"L2ui_ch3.menubutton4\" width=\"38\" height=\"38\"></td>");
  185. tb.append("<td valign=\"top\"><font color=\"FF6600\">AugmentHelper</font>");
  186. tb.append("<br1><font color=\"00FF00ju\">" + player.getName() + "</font>, use this menu for fast augment :)<br1></td>");
  187. tb.append("</tr>");
  188. tb.append("</table>");
  189. tb.append("</center>");
  190. tb.append("<center>");
  191. tb.append("<br>");
  192.  
  193. for (L2ItemInstance item : player.getInventory().getItems())
  194. {
  195.  
  196. if(!item.isAugmented() && item.getItemType() instanceof L2WeaponType && item.isEquipable() && !item.isQuestItem())
  197. {
  198. if(item!=null)
  199. tb.append("<button value=\""+item.getItemName()+"\" action=\"bypass -h npc_" + getObjectId() + "_tryaug-"+item.getObjectId()+"\" width=204 height=20 back=\"sek.cbui75\" fore=\"sek.cbui75\"><br>");
  200. //tb.append("<table border=0 width=\"100%\">");
  201. // tb.append("<tr><td><img src=\""+IconJava.getIcon(item.getItemId())+"\"width=\"32\"height=\"32\"></td>"
  202. //+"<td>"+"<button value=\""+item.getItemName()+"\" action=\"bypass -h npc_"+getObjectId()+"_tryaug-"+item.getObjectId()+"\"width=204 height=21 back=\"sek.cbui75\" fore=\"sek.cbui75\"><br>"+"</td>"+"<td>+"+item.getEnchantLevel()+"</td></tr></table>");
  203. }
  204.  
  205.  
  206. }
  207.  
  208. tb.append("<br>");
  209. tb.append("<button value=\""+Rem+"\" action=\"bypass -h npc_" + getObjectId() + "_showremlist-1"+"\" width=204 height=20 back=\"sek.cbui75\" fore=\"sek.cbui75\"><br>");
  210. tb.append("</center>");
  211. tb.append("</body></html>");
  212.  
  213. nhm.setHtml(tb.toString());
  214. player.sendPacket(nhm);
  215. }
  216.  
  217. public void showListWindowForRemove(L2PcInstance player)
  218. {
  219. NpcHtmlMessage nhm = new NpcHtmlMessage(5);
  220. StringBuilder tb = new StringBuilder("");
  221. String Rem = "GobackToAugList";
  222.  
  223. tb.append("<html><head><title>By AbsolutePower</title></head><body>");
  224. tb.append("<center>");
  225. tb.append("<table width=\"250\" cellpadding=\"5\" bgcolor=\"000000\">");
  226. tb.append("<tr>");
  227. tb.append("<td width=\"45\" valign=\"top\" align=\"center\"><img src=\"L2ui_ch3.menubutton4\" width=\"38\" height=\"38\"></td>");
  228. tb.append("<td valign=\"top\"><font color=\"FF6600\">AugmentHelper</font>");
  229. tb.append("<br1><font color=\"00FF00ju\">" + player.getName() + "</font>, use this menu for fast augment :)<br1></td>");
  230. tb.append("</tr>");
  231. tb.append("</table>");
  232. tb.append("</center>");
  233. tb.append("<center>");
  234. tb.append("<br>");
  235.  
  236. for (L2ItemInstance item : player.getInventory().getItems())
  237. {
  238.  
  239. if(item.isAugmented() && item.getItemType() instanceof L2WeaponType && item.isEquipable() && !item.isQuestItem())
  240. {
  241. if(item!=null)
  242. tb.append("<button value=\""+item.getItemName()+"\" action=\"bypass -h npc_" + getObjectId() + "_tryremove-"+item.getObjectId()+"\" width=204 height=20 back=\"sek.cbui75\" fore=\"sek.cbui75\"><br>");
  243. //tb.append("<table border=0 width=\"100%\">");
  244. // tb.append("<tr><td><img src=\""+IconJava.getIcon(item.getItemId())+"\"width=\"32\"height=\"32\"></td>"
  245. //+"<td>"+"<button value=\""+item.getItemName()+"\" action=\"bypass -h npc_"+getObjectId()+"_tryaug-"+item.getObjectId()+"\"width=204 height=21 back=\"sek.cbui75\" fore=\"sek.cbui75\"><br>"+"</td>"+"<td>+"+item.getEnchantLevel()+"</td></tr></table>");
  246. }
  247.  
  248.  
  249. }
  250.  
  251. tb.append("<br>");
  252. tb.append("<button value=\""+Rem+"\" action=\"bypass -h npc_" + getObjectId() + "_showauglist-1"+"\" width=204 height=20 back=\"sek.cbui75\" fore=\"sek.cbui75\"><br>");
  253. tb.append("</center>");
  254. tb.append("</body></html>");
  255.  
  256. nhm.setHtml(tb.toString());
  257. player.sendPacket(nhm);
  258. }
  259. @Override
  260. public void onAction(L2PcInstance player)
  261. {
  262. if (this != player.getTarget())
  263. {
  264. player.setTarget(this);
  265. player.sendPacket(new MyTargetSelected(getObjectId(), player.getLevel() - getLevel()));
  266. player.sendPacket(new ValidateLocation(this));
  267. }
  268. else if (isInsideRadius(player, INTERACTION_DISTANCE, false, false))
  269. {
  270. SocialAction sa = new SocialAction(this.getObjectId(), Rnd.get(8));
  271. broadcastPacket(sa);
  272. player.setLastFolkNPC(this);
  273. showListWindow(player);
  274. player.sendPacket(ActionFailed.STATIC_PACKET);
  275. }
  276. else {
  277. player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, this);
  278. player.sendPacket(ActionFailed.STATIC_PACKET);
  279. }
  280. }
  281. }
Advertisement
Add Comment
Please, Sign In to add comment