Advertisement
Guest User

Buffer

a guest
Aug 26th, 2018
2,605
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 32.52 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P aCis_gameserver
  3. Index: java/net/sf/l2j/gameserver/model/actor/instance/PlayerBuffer.java
  4. ===================================================================
  5. --- java/net/sf/l2j/gameserver/model/actor/instance/PlayerBuffer.java   (nonexistent)
  6. +++ java/net/sf/l2j/gameserver/model/actor/instance/PlayerBuffer.java   (working copy)
  7. @@ -0,0 +1,667 @@
  8. +package net.sf.l2j.gameserver.model.actor.instance;
  9. +
  10. +import java.util.ArrayList;
  11. +import java.util.List;
  12. +import java.util.Map;
  13. +import java.util.StringTokenizer;
  14. +
  15. +import net.sf.l2j.commons.lang.StringUtil;
  16. +import net.sf.l2j.commons.random.Rnd;
  17. +
  18. +import net.sf.l2j.Config;
  19. +import net.sf.l2j.gameserver.data.BufferTable;
  20. +import net.sf.l2j.gameserver.data.SkillTable;
  21. +import net.sf.l2j.gameserver.model.L2Skill;
  22. +import net.sf.l2j.gameserver.model.actor.Creature;
  23. +import net.sf.l2j.gameserver.model.actor.Npc;
  24. +import net.sf.l2j.gameserver.model.actor.Summon;
  25. +import net.sf.l2j.gameserver.model.actor.ai.CtrlIntention;
  26. +import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
  27. +import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
  28. +import net.sf.l2j.gameserver.network.serverpackets.ItemList;
  29. +import net.sf.l2j.gameserver.network.serverpackets.MagicSkillUse;
  30. +import net.sf.l2j.gameserver.network.serverpackets.MoveToPawn;
  31. +import net.sf.l2j.gameserver.network.serverpackets.MyTargetSelected;
  32. +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
  33. +import net.sf.l2j.gameserver.network.serverpackets.ValidateLocation;
  34. +
  35. +/**
  36. + * @author Baggos
  37. + */
  38. +public final class PlayerBuffer extends Npc
  39. +{
  40. +   public PlayerBuffer(int objectId, NpcTemplate template)
  41. +   {
  42. +       super(objectId, template);
  43. +   }
  44. +  
  45. +   @Override
  46. +   public void onAction(Player player)
  47. +   {
  48. +       if (this != player.getTarget())
  49. +       {
  50. +           player.setTarget(this);
  51. +           player.sendPacket(new MyTargetSelected(getObjectId(), 0));
  52. +           player.sendPacket(new ValidateLocation(this));
  53. +       }
  54. +       else
  55. +       {
  56. +           if (!canInteract(player))
  57. +               player.getAI().setIntention(CtrlIntention.INTERACT, this);
  58. +           else
  59. +           {
  60. +               // Rotate the player to face the instance
  61. +               player.sendPacket(new MoveToPawn(player, this, Npc.INTERACTION_DISTANCE));
  62. +              
  63. +               if (hasRandomAnimation())
  64. +                   onRandomAnimation(Rnd.get(8));
  65. +              
  66. +               showMainWindow(player);
  67. +              
  68. +               // Send ActionFailed to the player in order to avoid he stucks
  69. +               player.sendPacket(ActionFailed.STATIC_PACKET);
  70. +           }
  71. +       }
  72. +   }
  73. +  
  74. +   private void showMainWindow(Player activeChar)
  75. +   {      
  76. +       NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
  77. +       html.setFile("data/html/mods/buffer/index.htm");
  78. +       html.replace("%objectId%", String.valueOf(getObjectId()));
  79. +       html.replace("%name%", activeChar.getName());
  80. +       html.replace("%buffcount%", "You have " + activeChar.getBuffCount() + "/" + activeChar.getMaxBuffCount() + " buffs.");
  81. +      
  82. +       activeChar.sendPacket(html);
  83. +   }
  84. +  
  85. +   @Override
  86. +   public void onBypassFeedback(Player player, String command)
  87. +   {
  88. +       if (player.getPvpFlag() > 0 && Config.PRESTRICT_USE_BUFFER_ON_PVPFLAG)
  89. +       {
  90. +           player.sendMessage("You can't use buffer when you are pvp flagged.");
  91. +           return;
  92. +       }
  93. +      
  94. +       if (player.isInCombat() && Config.PRESTRICT_USE_BUFFER_IN_COMBAT)
  95. +       {
  96. +           player.sendMessage("You can't use buffer when you are in combat.");
  97. +           return;
  98. +       }
  99. +      
  100. +       if (player.isDead())
  101. +           return;
  102. +      
  103. +       StringTokenizer st = new StringTokenizer(command, " ");
  104. +       String actualCommand = st.nextToken();
  105. +      
  106. +       if (actualCommand.equalsIgnoreCase("bufflist"))
  107. +       {
  108. +           autoBuffFunction(player, st.nextToken());
  109. +       }
  110. +       else if (actualCommand.equalsIgnoreCase("restore"))
  111. +       {
  112. +           String noble = st.nextToken();
  113. +           player.setCurrentHpMp(player.getMaxHp(), player.getMaxMp());
  114. +           player.setCurrentCp(player.getMaxCp());
  115. +          
  116. +           if (noble.equals("true"))
  117. +           {
  118. +               SkillTable.getInstance().getInfo(1323, 1).getEffects(player, player);
  119. +               player.broadcastPacket(new MagicSkillUse(this, player, 1323, 1, 850, 0));
  120. +           }
  121. +          
  122. +           final Summon summon = player.getPet();
  123. +           if (summon != null)
  124. +               summon.setCurrentHpMp(summon.getMaxHp(), summon.getMaxMp());
  125. +          
  126. +           showMainWindow(player);
  127. +       }
  128. +       else if (actualCommand.equalsIgnoreCase("cancellation"))
  129. +       {
  130. +           L2Skill buff;
  131. +           buff = SkillTable.getInstance().getInfo(1056, 1);
  132. +           buff.getEffects(this, player);
  133. +           player.stopAllEffectsExceptThoseThatLastThroughDeath();
  134. +           player.broadcastPacket(new MagicSkillUse(this, player, 1056, 1, 850, 0));
  135. +           player.stopAllEffects();
  136. +          
  137. +           final Summon summon = player.getPet();
  138. +           if (summon != null)
  139. +               summon.stopAllEffects();
  140. +          
  141. +           showMainWindow(player);
  142. +       }
  143. +       else if (actualCommand.equalsIgnoreCase("openlist"))
  144. +       {
  145. +           String category = st.nextToken();
  146. +           String htmfile = st.nextToken();
  147. +          
  148. +           NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
  149. +          
  150. +           if (category.equalsIgnoreCase("null"))
  151. +           {
  152. +               html.setFile("data/html/mods/buffer/" + htmfile + ".htm");
  153. +              
  154. +               // First Page
  155. +               if (htmfile.equals("index"))
  156. +               {
  157. +                   html.replace("%name%", player.getName());
  158. +                   html.replace("%buffcount%", "You have " + player.getBuffCount() + "/" + player.getMaxBuffCount() + " buffs.");
  159. +               }
  160. +           }
  161. +           else
  162. +               html.setFile("data/html/mods/buffer/" + category + "/" + htmfile + ".htm");
  163. +          
  164. +           html.replace("%objectId%", String.valueOf(getObjectId()));
  165. +           player.sendPacket(html);
  166. +       }
  167. +      
  168. +       else if (actualCommand.equalsIgnoreCase("dobuff"))
  169. +       {
  170. +           int buffid = Integer.valueOf(st.nextToken());
  171. +           int bufflevel = Integer.valueOf(st.nextToken());
  172. +           String category = st.nextToken();
  173. +           String windowhtml = st.nextToken();
  174. +           String votebuff = null;
  175. +          
  176. +           if (st.hasMoreTokens())
  177. +               votebuff = st.nextToken();
  178. +          
  179. +           if (windowhtml.equals("malaria"))
  180. +           {
  181. +               if (player.getInventory().getInventoryItemCount(Config.PVOTE_BUFF_ITEM_ID, 0) >= 1)
  182. +               {
  183. +                   player.getInventory().destroyItemByItemId("VoteCoins", Config.PVOTE_BUFF_ITEM_ID, 1, player, null);
  184. +                   player.getInventory().updateDatabase();
  185. +                   player.sendPacket(new ItemList(player, true));
  186. +                   player.sendMessage(1 + " Vote eye destroyed.");
  187. +               }
  188. +               else
  189. +               {
  190. +                   player.sendMessage("You dont have enough (" + 1 + ") vote item for buff.");
  191. +                   return;
  192. +               }
  193. +           }
  194. +          
  195. +           if (votebuff != null)
  196. +           {
  197. +               if (player.getInventory().getInventoryItemCount(Config.PVOTE_BUFF_ITEM_ID, 0) >= Config.PVOTE_BUFF_ITEM_COUNT)
  198. +               {
  199. +                   player.getInventory().destroyItemByItemId("VoteCoins", Config.PVOTE_BUFF_ITEM_ID, Config.PVOTE_BUFF_ITEM_COUNT, player, null);
  200. +                   player.getInventory().updateDatabase();
  201. +                   player.sendPacket(new ItemList(player, true));
  202. +                   player.sendMessage(Config.PVOTE_BUFF_ITEM_COUNT + " vote stone destroyed.");
  203. +               }
  204. +               else
  205. +               {
  206. +                   player.sendMessage("You dont have enough (" + Config.PVOTE_BUFF_ITEM_COUNT + ") vote item for buff.");
  207. +                   return;
  208. +               }
  209. +           }
  210. +          
  211. +           Creature target = player;
  212. +           if (category.equalsIgnoreCase("pet"))
  213. +           {
  214. +               if (player.getPet() == null)
  215. +               {
  216. +                   player.sendMessage("Incorrect Pet");
  217. +                   showMainWindow(player);
  218. +                   return;
  219. +               }
  220. +               target = player.getPet();
  221. +           }
  222. +          
  223. +           MagicSkillUse mgc = new MagicSkillUse(this, target, buffid, bufflevel, 1150, 0);
  224. +           player.sendPacket(mgc);
  225. +           player.broadcastPacket(mgc);
  226. +           SkillTable.getInstance().getInfo(buffid, bufflevel).getEffects(this, target);
  227. +          
  228. +           NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
  229. +           html.setFile("data/html/mods/buffer/" + category + "/" + windowhtml + ".htm");
  230. +           html.replace("%objectId%", String.valueOf(getObjectId()));
  231. +           html.replace("%name%", player.getName());
  232. +           player.sendPacket(html);
  233. +       }
  234. +       else if (actualCommand.equalsIgnoreCase("getbuff"))
  235. +       {
  236. +           int buffid = Integer.valueOf(st.nextToken());
  237. +           int bufflevel = Integer.valueOf(st.nextToken());
  238. +           if (buffid != 0)
  239. +           {
  240. +               SkillTable.getInstance().getInfo(buffid, bufflevel).getEffects(this, player);
  241. +               broadcastPacket(new MagicSkillUse(this, player, buffid, bufflevel, 450, 0));
  242. +               showMainWindow(player);
  243. +           }
  244. +       }
  245. +       else if (actualCommand.startsWith("support"))
  246. +       {
  247. +           showGiveBuffsWindow(player, st.nextToken());
  248. +       }
  249. +       else if (actualCommand.startsWith("givebuffs"))
  250. +       {
  251. +           final String targetType = st.nextToken();
  252. +           final String schemeName = st.nextToken();
  253. +           final int cost = Integer.parseInt(st.nextToken());
  254. +          
  255. +           final Creature target = (targetType.equalsIgnoreCase("pet")) ? player.getPet() : player;
  256. +           if (target == null)
  257. +               player.sendMessage("You don't have a pet.");
  258. +           else if (cost == 0 || player.reduceAdena("NPC Buffer", cost, this, true))
  259. +           {
  260. +               for (int skillId : BufferTable.getInstance().getScheme(player.getObjectId(), schemeName))
  261. +                   SkillTable.getInstance().getInfo(skillId, SkillTable.getInstance().getMaxLevel(skillId)).getEffects(this, target);
  262. +           }
  263. +           showGiveBuffsWindow(player, targetType);
  264. +       }
  265. +       else if (actualCommand.startsWith("editschemes"))
  266. +       {
  267. +           if (st.countTokens() == 2)
  268. +               showEditSchemeWindow(player, st.nextToken(), st.nextToken());
  269. +           else
  270. +               player.sendMessage("Something wrong with your scheme. Please contact with Admin");
  271. +       }
  272. +       else if (actualCommand.startsWith("skill"))
  273. +       {
  274. +           final String groupType = st.nextToken();
  275. +           final String schemeName = st.nextToken();
  276. +          
  277. +           final int skillId = Integer.parseInt(st.nextToken());
  278. +          
  279. +           final List<Integer> skills = BufferTable.getInstance().getScheme(player.getObjectId(), schemeName);
  280. +          
  281. +           if (actualCommand.startsWith("skillselect") && !schemeName.equalsIgnoreCase("none"))
  282. +           {
  283. +               if (skills.size() < Config.PBUFFER_MAX_SKILLS)
  284. +                   skills.add(skillId);
  285. +               else
  286. +                   player.sendMessage("This scheme has reached the maximum amount of buffs.");
  287. +           }
  288. +           else if (actualCommand.startsWith("skillunselect"))
  289. +               skills.remove(Integer.valueOf(skillId));
  290. +          
  291. +           showEditSchemeWindow(player, groupType, schemeName);
  292. +       }
  293. +       else if (actualCommand.startsWith("manageschemes"))
  294. +       {
  295. +           showManageSchemeWindow(player);
  296. +       }
  297. +       else if (actualCommand.startsWith("createscheme"))
  298. +       {
  299. +           try
  300. +           {
  301. +               final String schemeName = st.nextToken();
  302. +               if (schemeName.length() > 14)
  303. +               {
  304. +                   player.sendMessage("Scheme's name must contain up to 14 chars. Spaces are trimmed.");
  305. +                   showManageSchemeWindow(player);
  306. +                   return;
  307. +               }
  308. +              
  309. +               final Map<String, ArrayList<Integer>> schemes = BufferTable.getInstance().getPlayerSchemes(player.getObjectId());
  310. +               if (schemes != null)
  311. +               {
  312. +                   if (schemes.size() == Config.PBUFFER_MAX_SCHEMES)
  313. +                   {
  314. +                       player.sendMessage("Maximum schemes amount is already reached.");
  315. +                       showManageSchemeWindow(player);
  316. +                       return;
  317. +                   }
  318. +                  
  319. +                   if (schemes.containsKey(schemeName))
  320. +                   {
  321. +                       player.sendMessage("The scheme name already exists.");
  322. +                       showManageSchemeWindow(player);
  323. +                       return;
  324. +                   }
  325. +               }
  326. +              
  327. +               BufferTable.getInstance().setScheme(player.getObjectId(), schemeName.trim(), new ArrayList<Integer>());
  328. +               showManageSchemeWindow(player);
  329. +           }
  330. +           catch (Exception e)
  331. +           {
  332. +               player.sendMessage("Scheme's name must contain up to 14 chars. Spaces are trimmed.");
  333. +               showManageSchemeWindow(player);
  334. +           }
  335. +       }
  336. +       else if (actualCommand.startsWith("deletescheme"))
  337. +       {
  338. +           try
  339. +           {
  340. +               final String schemeName = st.nextToken();
  341. +               final Map<String, ArrayList<Integer>> schemes = BufferTable.getInstance().getPlayerSchemes(player.getObjectId());
  342. +              
  343. +               if (schemes != null && schemes.containsKey(schemeName))
  344. +                   schemes.remove(schemeName);
  345. +           }
  346. +           catch (Exception e)
  347. +           {
  348. +               player.sendMessage("This scheme name is invalid.");
  349. +           }
  350. +           showManageSchemeWindow(player);
  351. +       }
  352. +       else if (actualCommand.startsWith("clearscheme"))
  353. +       {
  354. +           try
  355. +           {
  356. +               final String schemeName = st.nextToken();
  357. +               final Map<String, ArrayList<Integer>> schemes = BufferTable.getInstance().getPlayerSchemes(player.getObjectId());
  358. +              
  359. +               if (schemes != null && schemes.containsKey(schemeName))
  360. +                   schemes.get(schemeName).clear();
  361. +           }
  362. +           catch (Exception e)
  363. +           {
  364. +               player.sendMessage("This scheme name is invalid.");
  365. +           }
  366. +           showManageSchemeWindow(player);
  367. +       }
  368. +       else
  369. +           super.onBypassFeedback(player, command);
  370. +   }
  371. +  
  372. +   /**
  373. +    * Sends an html packet to player with Give Buffs menu info for player and pet, depending on targetType parameter {player, pet}
  374. +    * @param player : The player to make checks on.
  375. +    * @param targetType : a String used to define if the player or his pet must be used as target.
  376. +    */
  377. +   private void showGiveBuffsWindow(Player player, String targetType)
  378. +   {
  379. +       final StringBuilder sb = new StringBuilder(200);
  380. +      
  381. +       final Map<String, ArrayList<Integer>> schemes = BufferTable.getInstance().getPlayerSchemes(player.getObjectId());
  382. +       if (schemes == null || schemes.isEmpty())
  383. +           sb.append("<font color=\"LEVEL\">You haven't defined any scheme, please go to 'Manage my schemes' and create at least one valid scheme.</font>");
  384. +       else
  385. +       {
  386. +           for (Map.Entry<String, ArrayList<Integer>> scheme : schemes.entrySet())
  387. +           {
  388. +               final int cost = getFee(scheme.getValue());
  389. +               StringUtil.append(sb, "<font color=\"LEVEL\"><a action=\"bypass -h npc_%objectId%_givebuffs ", targetType, " ", scheme.getKey(), " ", cost, "\">", scheme.getKey(), " (", scheme.getValue().size(), " skill(s))</a>", ((cost > 0) ? " - Adena cost: " + cost : ""), "</font><br1>");
  390. +           }
  391. +       }
  392. +      
  393. +       final NpcHtmlMessage html = new NpcHtmlMessage(0);
  394. +       html.setFile("data/html/mods/buffer/schememanager/index-1.htm");
  395. +       html.replace("%schemes%", sb.toString());
  396. +       html.replace("%targettype%", (targetType.equalsIgnoreCase("pet") ? "&nbsp;<a action=\"bypass -h npc_%objectId%_support player\">yourself</a>&nbsp;|&nbsp;your pet" : "yourself&nbsp;|&nbsp;<a action=\"bypass -h npc_%objectId%_support pet\">your pet</a>"));
  397. +       html.replace("%objectId%", getObjectId());
  398. +       player.sendPacket(html);
  399. +   }
  400. +  
  401. +   /**
  402. +    * Sends an html packet to player with Manage scheme menu info. This allows player to create/delete/clear schemes
  403. +    * @param player : The player to make checks on.
  404. +    */
  405. +   private void showManageSchemeWindow(Player player)
  406. +   {
  407. +       final StringBuilder sb = new StringBuilder(200);
  408. +      
  409. +       final Map<String, ArrayList<Integer>> schemes = BufferTable.getInstance().getPlayerSchemes(player.getObjectId());
  410. +       if (schemes == null || schemes.isEmpty())
  411. +           sb.append("<font color=\"LEVEL\">You haven't created any scheme.</font>");
  412. +       else
  413. +       {
  414. +           sb.append("<table>");
  415. +           for (Map.Entry<String, ArrayList<Integer>> scheme : schemes.entrySet())
  416. +               StringUtil.append(sb, "<tr><td width=140>", scheme.getKey(), " (", scheme.getValue().size(), " skill(s))</td><td width=60><button value=\"Clear\" action=\"bypass -h npc_%objectId%_clearscheme ", scheme.getKey(), "\" width=55 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td><td width=60><button value=\"Drop\" action=\"bypass -h npc_%objectId%_deletescheme ", scheme.getKey(), "\" width=55 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td></tr>");
  417. +          
  418. +           sb.append("</table>");
  419. +       }
  420. +      
  421. +       final NpcHtmlMessage html = new NpcHtmlMessage(0);
  422. +       html.setFile("data/html/mods/buffer/schememanager/index-2.htm");
  423. +       html.replace("%schemes%", sb.toString());
  424. +       html.replace("%max_schemes%", Config.PBUFFER_MAX_SCHEMES);
  425. +       html.replace("%objectId%", getObjectId());
  426. +       player.sendPacket(html);
  427. +   }
  428. +  
  429. +   /**
  430. +    * This sends an html packet to player with Edit Scheme Menu info. This allows player to edit each created scheme (add/delete skills)
  431. +    * @param player : The player to make checks on.
  432. +    * @param groupType : The group of skills to select.
  433. +    * @param schemeName : The scheme to make check.
  434. +    */
  435. +   private void showEditSchemeWindow(Player player, String groupType, String schemeName)
  436. +   {
  437. +       final NpcHtmlMessage html = new NpcHtmlMessage(0);
  438. +      
  439. +       if (schemeName.equalsIgnoreCase("none"))
  440. +           html.setFile("data/html/mods/buffer/schememanager/index-3.htm");
  441. +       else
  442. +       {
  443. +           if (groupType.equalsIgnoreCase("none"))
  444. +               html.setFile("data/html/mods/buffer/schememanager/index-4.htm");
  445. +           else
  446. +           {
  447. +               html.setFile("data/html/mods/buffer/schememanager/index-5.htm");
  448. +               html.replace("%skilllistframe%", getGroupSkillList(player, groupType, schemeName));
  449. +           }
  450. +           html.replace("%schemename%", schemeName);
  451. +           html.replace("%myschemeframe%", getPlayerSchemeSkillList(player, groupType, schemeName));
  452. +           html.replace("%typesframe%", getTypesFrame(groupType, schemeName));
  453. +       }
  454. +       html.replace("%schemes%", getPlayerSchemes(player, schemeName));
  455. +       html.replace("%objectId%", getObjectId());
  456. +       player.sendPacket(html);
  457. +   }
  458. +  
  459. +   /**
  460. +    * @param player : The player to make checks on.
  461. +    * @param schemeName : The name to don't link (previously clicked).
  462. +    * @return a String listing player's schemes. The scheme currently on selection isn't linkable.
  463. +    */
  464. +   private static String getPlayerSchemes(Player player, String schemeName)
  465. +   {
  466. +       final Map<String, ArrayList<Integer>> schemes = BufferTable.getInstance().getPlayerSchemes(player.getObjectId());
  467. +       if (schemes == null || schemes.isEmpty())
  468. +           return "Please create at least one scheme.";
  469. +      
  470. +       final StringBuilder sb = new StringBuilder(200);
  471. +       sb.append("<table>");
  472. +      
  473. +       for (Map.Entry<String, ArrayList<Integer>> scheme : schemes.entrySet())
  474. +       {
  475. +           if (schemeName.equalsIgnoreCase(scheme.getKey()))
  476. +               StringUtil.append(sb, "<tr><td width=200>", scheme.getKey(), " (<font color=\"LEVEL\">", scheme.getValue().size(), "</font> / ", Config.PBUFFER_MAX_SKILLS, " skill(s))</td></tr>");
  477. +           else
  478. +               StringUtil.append(sb, "<tr><td width=200><a action=\"bypass -h npc_%objectId%_editschemes none ", scheme.getKey(), "\">", scheme.getKey(), " (", scheme.getValue().size(), " / ", Config.PBUFFER_MAX_SKILLS, " skill(s))</a></td></tr>");
  479. +       }
  480. +      
  481. +       sb.append("</table>");
  482. +      
  483. +       return sb.toString();
  484. +   }
  485. +  
  486. +   /**
  487. +    * @param player : The player to make checks on.
  488. +    * @param groupType : The group of skills to select.
  489. +    * @param schemeName : The scheme to make check.
  490. +    * @return a String representing skills available to selection for a given groupType.
  491. +    */
  492. +   private static String getGroupSkillList(Player player, String groupType, String schemeName)
  493. +   {
  494. +       final List<Integer> skills = new ArrayList<>();
  495. +       for (int skillId : BufferTable.getSkillsIdsByType(groupType))
  496. +       {
  497. +           if (BufferTable.getInstance().getSchemeContainsSkill(player.getObjectId(), schemeName, skillId))
  498. +               continue;
  499. +          
  500. +           skills.add(skillId);
  501. +       }
  502. +      
  503. +       if (skills.isEmpty())
  504. +           return "That group doesn't contain any skills.";
  505. +      
  506. +       final StringBuilder sb = new StringBuilder(500);
  507. +      
  508. +       sb.append("<table>");
  509. +       int count = 0;
  510. +       for (int skillId : skills)
  511. +       {
  512. +           if (BufferTable.getInstance().getSchemeContainsSkill(player.getObjectId(), schemeName, skillId))
  513. +               continue;
  514. +          
  515. +           if (count == 0)
  516. +               sb.append("<tr>");
  517. +          
  518. +           if (skillId < 100)
  519. +               sb.append("<td width=180><font color=\"949490\"><a action=\"bypass -h npc_%objectId%_skillselect " + groupType + " " + schemeName + " " + skillId + "\">" + SkillTable.getInstance().getInfo(skillId, 1).getName() + "</a></font></td>");
  520. +           else if (skillId < 1000)
  521. +               sb.append("<td width=180><font color=\"949490\"><a action=\"bypass -h npc_%objectId%_skillselect " + groupType + " " + schemeName + " " + skillId + "\">" + SkillTable.getInstance().getInfo(skillId, 1).getName() + "</a></font></td>");
  522. +           else
  523. +               sb.append("<td width=180><font color=\"949490\"><a action=\"bypass -h npc_%objectId%_skillselect " + groupType + " " + schemeName + " " + skillId + "\">" + SkillTable.getInstance().getInfo(skillId, 1).getName() + "</a></font></td>");
  524. +          
  525. +           count++;
  526. +           if (count == 2)
  527. +           {
  528. +               sb.append("</tr><tr><td></td></tr>");
  529. +               count = 0;
  530. +           }
  531. +       }
  532. +      
  533. +       if (!sb.toString().endsWith("</tr>"))
  534. +           sb.append("</tr>");
  535. +      
  536. +       sb.append("</table>");
  537. +      
  538. +       return sb.toString();
  539. +   }
  540. +  
  541. +   /**
  542. +    * @param player : The player to make checks on.
  543. +    * @param groupType : The group of skills to select.
  544. +    * @param schemeName : The scheme to make check.
  545. +    * @return a String representing a given scheme's content.
  546. +    */
  547. +   private static String getPlayerSchemeSkillList(Player player, String groupType, String schemeName)
  548. +   {
  549. +       final List<Integer> skills = BufferTable.getInstance().getScheme(player.getObjectId(), schemeName);
  550. +       if (skills.isEmpty())
  551. +           return "That scheme is empty.";
  552. +      
  553. +       final StringBuilder sb = new StringBuilder(500);
  554. +       sb.append("<table>");
  555. +       int count = 0;
  556. +      
  557. +       for (int sk : skills)
  558. +       {
  559. +           if (count == 0)
  560. +               sb.append("<tr>");
  561. +          
  562. +           if (sk < 100)
  563. +               sb.append("<td width=180><font color=\"6e6e6a\"><a action=\"bypass -h npc_%objectId%_skillunselect " + groupType + " " + schemeName + " " + sk + "\">" + SkillTable.getInstance().getInfo(sk, 1).getName() + "</a></font></td>");
  564. +           else if (sk < 1000)
  565. +               sb.append("<td width=180><font color=\"6e6e6a\"><a action=\"bypass -h npc_%objectId%_skillunselect " + groupType + " " + schemeName + " " + sk + "\">" + SkillTable.getInstance().getInfo(sk, 1).getName() + "</a></font></td>");
  566. +           else
  567. +               sb.append("<td width=180><font color=\"6e6e6a\"><a action=\"bypass -h npc_%objectId%_skillunselect " + groupType + " " + schemeName + " " + sk + "\">" + SkillTable.getInstance().getInfo(sk, 1).getName() + "</a></font></td>");
  568. +          
  569. +           count++;
  570. +           if (count == 2)
  571. +           {
  572. +               sb.append("</tr><tr><td></td></tr>");
  573. +               count = 0;
  574. +           }
  575. +       }
  576. +      
  577. +       if (!sb.toString().endsWith("<tr>"))
  578. +           sb.append("<tr>");
  579. +      
  580. +       sb.append("</table>");
  581. +      
  582. +       return sb.toString();
  583. +   }
  584. +  
  585. +   /**
  586. +    * @param groupType : The group of skills to select.
  587. +    * @param schemeName : The scheme to make check.
  588. +    * @return a string representing all groupTypes availables. The group currently on selection isn't linkable.
  589. +    */
  590. +   private static String getTypesFrame(String groupType, String schemeName)
  591. +   {
  592. +       final StringBuilder sb = new StringBuilder(500);
  593. +       sb.append("<table>");
  594. +      
  595. +       int count = 0;
  596. +       for (String s : BufferTable.getSkillTypes())
  597. +       {
  598. +           if (count == 0)
  599. +               sb.append("<tr>");
  600. +          
  601. +           if (groupType.equalsIgnoreCase(s))
  602. +               StringUtil.append(sb, "<td width=65>", s, "</td>");
  603. +           else
  604. +               StringUtil.append(sb, "<td width=65><a action=\"bypass -h npc_%objectId%_editschemes ", s, " ", schemeName, "\">", s, "</a></td>");
  605. +          
  606. +           count++;
  607. +           if (count == 4)
  608. +           {
  609. +               sb.append("</tr>");
  610. +               count = 0;
  611. +           }
  612. +       }
  613. +      
  614. +       if (!sb.toString().endsWith("</tr>"))
  615. +           sb.append("</tr>");
  616. +      
  617. +       sb.append("</table>");
  618. +      
  619. +       return sb.toString();
  620. +   }
  621. +  
  622. +   /**
  623. +    * @param list : A list of skill ids.
  624. +    * @return a global fee for all skills contained in list.
  625. +    */
  626. +   private static int getFee(ArrayList<Integer> list)
  627. +   {
  628. +       if (Config.PBUFFER_STATIC_BUFF_COST >= 0)
  629. +           return (list.size() * Config.PBUFFER_STATIC_BUFF_COST);
  630. +      
  631. +       int fee = 0;
  632. +       for (int sk : list)
  633. +       {
  634. +           if (Config.PBUFFER_BUFFLIST.get(sk) == null)
  635. +               continue;
  636. +          
  637. +           fee += Config.PBUFFER_BUFFLIST.get(sk).getValue();
  638. +       }
  639. +      
  640. +       return fee;
  641. +   }
  642. +  
  643. +   private void autoBuffFunction(Player player, String bufflist)
  644. +   {
  645. +       ArrayList<L2Skill> skills_to_buff = new ArrayList<>();
  646. +       List<Integer> list = null;
  647. +      
  648. +       if (bufflist.equalsIgnoreCase("fighter"))
  649. +           list = Config.PFIGHTER_SKILL_LIST;
  650. +       else if (bufflist.equalsIgnoreCase("mage"))
  651. +           list = Config.PMAGE_SKILL_LIST;
  652. +      
  653. +       if (list != null)
  654. +       {
  655. +           for (int skillId : list)
  656. +           {
  657. +               L2Skill skill = SkillTable.getInstance().getInfo(skillId, SkillTable.getInstance().getMaxLevel(skillId));
  658. +               if (skill != null)
  659. +                   skills_to_buff.add(skill);
  660. +           }
  661. +          
  662. +           for (L2Skill sk : skills_to_buff)
  663. +               sk.getEffects(player, player);
  664. +          
  665. +           player.updateEffectIcons();
  666. +          
  667. +           list = null;
  668. +       }
  669. +      
  670. +       skills_to_buff.clear();
  671. +      
  672. +       showMainWindow(player);
  673. +   }
  674. +}
  675. \ No newline at end of file
  676. Index: java/net/sf/l2j/Config.java
  677. ===================================================================
  678. --- java/net/sf/l2j/Config.java (revision 4)
  679. +++ java/net/sf/l2j/Config.java (working copy)
  680. @@ -774,6 +774,26 @@
  681.     public static boolean DIVINE_SP_BOOK_NEEDED;
  682.     public static boolean ALT_GAME_SUBCLASS_WITHOUT_QUESTS;
  683.    
  684. +   /** Buffer */
  685. +   public static String PFIGHTER_SET;
  686. +   public static int[] PFIGHTER_SET_LIST;
  687. +   public static String PMAGE_SET;
  688. +   public static int[] PMAGE_SET_LIST;
  689. +   public static int PBUFFER_MAX_SCHEMES;
  690. +   public static int PBUFFER_MAX_SKILLS;
  691. +   public static int PBUFFER_STATIC_BUFF_COST;
  692. +   public static String PBUFFER_BUFFS;
  693. +   public static Map<Integer, BuffSkillHolder> PBUFFER_BUFFLIST;
  694. +  
  695. +   public static List<Integer> PFIGHTER_SKILL_LIST;
  696. +   public static List<Integer> PMAGE_SKILL_LIST;
  697. +  
  698. +   public static boolean PRESTRICT_USE_BUFFER_ON_PVPFLAG;
  699. +   public static boolean PRESTRICT_USE_BUFFER_IN_COMBAT;
  700. +  
  701. +   public static int PVOTE_BUFF_ITEM_ID;
  702. +   public static int PVOTE_BUFF_ITEM_COUNT;
  703. +  
  704.     /** Buffs */
  705.     public static boolean STORE_SKILL_COOLTIME;
  706.     public static int BUFFS_MAX_AMOUNT;
  707. @@ -2103,6 +2123,45 @@
  708.         DIVINE_SP_BOOK_NEEDED = players.getProperty("DivineInspirationSpBookNeeded", true);
  709.         ALT_GAME_SUBCLASS_WITHOUT_QUESTS = players.getProperty("AltSubClassWithoutQuests", false);
  710.        
  711. +       PBUFFER_MAX_SCHEMES = players.getProperty("BufferMaxSchemesPerChar", 4);
  712. +       PBUFFER_MAX_SKILLS = players.getProperty("BufferMaxSkillsPerScheme", 24);
  713. +       PBUFFER_STATIC_BUFF_COST = players.getProperty("BufferStaticCostPerBuff", -1);
  714. +       PBUFFER_BUFFS = players.getProperty("BufferBuffs");
  715. +      
  716. +       PFIGHTER_SET = players.getProperty("FighterSet", "2375,3500,3501,3502,4422,4423,4424,4425,6648,6649,6650");
  717. +       PMAGE_SET = players.getProperty("MageSet", "2375,3500,3501,3502,4422,4423,4424,4425,6648,6649,6650");
  718. +      
  719. +       String[] FighterList = PFIGHTER_SET.split(",");
  720. +       PFIGHTER_SET_LIST = new int[FighterList.length];
  721. +       for (int i = 0; i < FighterList.length; i++)
  722. +           PFIGHTER_SET_LIST[i] = Integer.parseInt(FighterList[i]);
  723. +      
  724. +       String[] MageList = PMAGE_SET.split(",");
  725. +       PMAGE_SET_LIST = new int[MageList.length];
  726. +       for (int i = 0; i < MageList.length; i++)
  727. +           PMAGE_SET_LIST[i] = Integer.parseInt(MageList[i]);
  728. +      
  729. +       PBUFFER_BUFFLIST = new HashMap<>();
  730. +       for (String skillInfo : PBUFFER_BUFFS.split(";"))
  731. +       {
  732. +           final String[] infos = skillInfo.split(",");
  733. +           PBUFFER_BUFFLIST.put(Integer.valueOf(infos[0]), new BuffSkillHolder(Integer.valueOf(infos[0]), Integer.valueOf(infos[1]), infos[2], skillInfo));
  734. +       }
  735. +      
  736. +       PRESTRICT_USE_BUFFER_ON_PVPFLAG = players.getProperty("RestrictUseBufferOnPvPFlag", true);
  737. +       PRESTRICT_USE_BUFFER_IN_COMBAT = players.getProperty("RestrictUseBufferInCombat", true);
  738. +      
  739. +       PVOTE_BUFF_ITEM_ID = players.getProperty("VoteBuffItemId", 57);
  740. +       PVOTE_BUFF_ITEM_COUNT = players.getProperty("VoteBuffItemCount", 1);
  741. +      
  742. +       PFIGHTER_SKILL_LIST = new ArrayList<>();
  743. +       for (String skill_id : players.getProperty("FighterSkillList", "").split(";"))
  744. +           PFIGHTER_SKILL_LIST.add(Integer.parseInt(skill_id));
  745. +      
  746. +       PMAGE_SKILL_LIST = new ArrayList<>();
  747. +       for (String skill_id : players.getProperty("MageSkillList", "").split(";"))
  748. +           PMAGE_SKILL_LIST.add(Integer.parseInt(skill_id));
  749. +      
  750.         BUFFS_MAX_AMOUNT = players.getProperty("MaxBuffsAmount", 20);
  751.         STORE_SKILL_COOLTIME = players.getProperty("StoreSkillCooltime", true);
  752.        
  753. Index: config/players.properties
  754. ===================================================================
  755. --- config/players.properties   (revision 4)
  756. +++ config/players.properties   (working copy)
  757. @@ -241,6 +241,33 @@
  758.  AltSubClassWithoutQuests = True
  759.  
  760.  #=============================================================
  761. +#                          Buffer
  762. +#=============================================================
  763. +
  764. +# Maximum number of available schemes per player.
  765. +BufferMaxSchemesPerChar = 4
  766. +
  767. +# Maximum number of buffs per scheme.
  768. +BufferMaxSkillsPerScheme = 24
  769. +
  770. +# Static cost of buffs ; override skills price if different of -1.
  771. +BufferStaticCostPerBuff = -1
  772. +
  773. +# Fighter Set List
  774. +FighterSkillList = 1204;1045;1068;1040;1035;1086;1242;1268;1036;1240;1077;1087;271;272;274;275;310;264;266;267;268;269;270;304;305;349;364;1388;1363;4699;1393;1392;1352;1353;1354;306;1259;1182;1189;1191
  775. +# Mage Set List
  776. +MageSkillList = 1204;1048;1045;1040;1035;1085;1303;1243;1304;1036;1087;1059;1078;1062;273;365;1393;1392;1352;1353;1354;307;309;306;308;1259;1182;1191;1033;1391;1363;264;266;267;268;270;304;349;4703;276
  777. +
  778. +# Buffer List, skillId,buffPrice,type.
  779. +BufferBuffs = 264,0,Songs;265,0,Songs;266,0,Songs;267,0,Songs;268,0,Songs;269,0,Songs;270,0,Songs;304,0,Songs;305,0,Songs;306,0,Songs;308,0,Songs;349,0,Songs;363,0,Songs;364,0,Songs;271,0,Dances;272,0,Dances;273,0,Dances;274,0,Dances;275,0,Dances;276,0,Dances;277,0,Dances;309,0,Dances;310,0,Dances;311,0,Dances;307,0,Dances;365,0,Dances;1002,0,Warcryer;1006,0,Warcryer;1007,0,Warcryer;1009,0,Warcryer;1308,0,Warcryer;1309,0,Warcryer;1310,0,Warcryer;1362,0,Warcryer;1390,0,Warcryer;1391,0,Warcryer;1413,0,Warcryer;1416,0,Overlord;1003,0,Overlord;1004,0,Overlord;1005,0,Overlord;1008,0,Overlord;1249,0,Overlord;1364,0,Overlord;1365,0,Overlord;1032,0,Prophet;1033,0,Prophet;1035,0,Prophet;1036,0,Prophet;1040,0,Prophet;1043,0,Prophet;1044,0,Prophet;1045,0,Prophet;1048,0,Prophet;1059,0,Shillen_Elder;1062,0,Prophet;1068,0,Prophet;1073,0,Elder;1077,0,Shillen_Elder;1078,0,Shillen_Elder;1085,0,Prophet;1086,0,Prophet;1087,0,Elder;1182,0,Elder;1189,0,Shillen_Elder;1191,0,Prophet;1204,0,Prophet;1242,0,Shillen_Elder;1243,0,Prophet;1259,0,Elder;1268,0,Shillen_Elder;1303,0,Shillen_Elder;1304,0,Elder;1352,0,Elder;1353,0,Elder;1354,0,Elder;1388,0,Shillen_Elder;1389,0,Shillen_Elder;1392,0,Prophet;1393,0,Elder;1397,0,Elder;1355,0,Elder;4699,0,Elder;4700,0,Elder;4702,0,Elder;4703,0,Elder;1356,0,Prophet;1357,0,Shillen_Elder;1363,0,Warcryer;1414,0,Overlord
  780. +
  781. +RestrictUseBufferOnPvPFlag = true
  782. +RestrictUseBufferInCombat = true
  783. +
  784. +VoteBuffItemId = 57
  785. +VoteBuffItemCount = 15
  786. +
  787. +#=============================================================
  788.  #                        Buffs config
  789.  #=============================================================
  790.  
  791. #P aCis_datapack
  792. Index: data/xml/buffer_skills.xml
  793. ===================================================================
  794. --- data/xml/buffer_skills.xml  (revision 4)
  795. +++ data/xml/buffer_skills.xml  (working copy)
  796. @@ -25,18 +25,12 @@
  797.         <buff id="1352" price="0" desc="Increases resistance to atures." /> <!-- Elemental Protection -->
  798.         <buff id="1353" price="0" desc="Increases resistance to dark attack." /> <!-- Divine Protection -->
  799.         <buff id="1354" price="0" desc="Increases resistance to de-buff attack." /> <!-- Arcane Protection -->
  800. -       <buff id="1355" price="0" desc="Increases mage abilities." /> <!-- Prophecy of Water -->
  801. -       <buff id="1356" price="0" desc="Increases fighter abilities." /> <!-- Prophecy of Fire -->
  802. -       <buff id="1357" price="0" desc="Increases dagger abilities." /> <!-- Prophecy of Wind -->
  803. -       <buff id="1363" price="0" desc="Increases combat abilities." /> <!-- Chant of Victory -->
  804.         <buff id="1388" price="0" desc="Increases P. Atk." /> <!-- Greater Might -->
  805.         <buff id="1389" price="0" desc="Increases P. Def." /> <!-- Greater Shield -->
  806. -       <buff id="1390" price="0" desc="Increases P. Atk." /> <!-- War Chant -->
  807. -       <buff id="1391" price="0" desc="Increases P. Def." /> <!-- Earth Chant -->
  808. -       <buff id="1397" price="0" desc="Decreases MP consumption rate." /> <!-- Clarity -->
  809. +       <buff id="1363" price="0" desc="Increases fighter abilities." /> <!-- Victory Chant -->
  810.         <buff id="1413" price="0" desc="Increases mage abilities." /> <!-- Magnus' Chant -->
  811.     </category>
  812. -   <category type="Dances">
  813. +   <category type="Other">
  814.         <buff id="271" price="0" desc="Increases P. Atk." /> <!-- Dance of the Warrior -->
  815.         <buff id="272" price="0" desc="Increases Accuracy." /> <!-- Dance of Inspiration -->
  816.         <buff id="273" price="0" desc="Increases M. Atk." /> <!-- Dance of the Mystic -->
  817. @@ -49,8 +43,6 @@
  818.         <buff id="310" price="0" desc="Restores HP by inflicted damage." /> <!-- Dance of the Vampire -->
  819.         <buff id="311" price="0" desc="Increases resistance to terrain damage." /> <!-- Dance of Protection -->
  820.         <buff id="365" price="0" desc="Increases rate of magic crit. damage." /> <!-- Siren's Dance -->
  821. -   </category>
  822. -   <category type="Songs">
  823.         <buff id="264" price="0" desc="Increases P. Def." /> <!-- Song of Earth -->
  824.         <buff id="265" price="0" desc="Increases HP regeneration." /> <!-- Song of Life -->
  825.         <buff id="266" price="0" desc="Increases Evasion." /> <!-- Song of Water -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement