Axelut

NPC Buffer aCis 401 baggos

Sep 12th, 2023
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --- a/aCis_datapack/data/xml/bufferSkills.xml
  2. +++ b/aCis_datapack/data/xml/bufferSkills.xml
  3. @@ -37,7 +37,7 @@
  4.         <buff id="1397" desc="Decreases MP consumption rate."/><!-- Clarity -->
  5.         <buff id="1413" desc="Increases mage abilities."/><!-- Magnus' Chant -->
  6.     </category>
  7. -   <category type="Dances">
  8. +   <category type="Other">
  9.         <buff id="271" desc="Increases P. Atk."/><!-- Dance of the Warrior -->
  10.         <buff id="272" desc="Increases Accuracy."/><!-- Dance of Inspiration -->
  11.         <buff id="273" desc="Increases M. Atk."/><!-- Dance of the Mystic -->
  12. @@ -50,8 +50,6 @@
  13.         <buff id="310" desc="Restores HP by inflicted damage."/><!-- Dance of the Vampire -->
  14.         <buff id="311" desc="Increases resistance to terrain damage."/><!-- Dance of Protection -->
  15.         <buff id="365" desc="Increases rate of magic crit. damage."/><!-- Siren's Dance -->
  16. -   </category>
  17. -   <category type="Songs">
  18.         <buff id="264" desc="Increases P. Def."/><!-- Song of Earth -->
  19.         <buff id="265" desc="Increases HP regeneration."/><!-- Song of Life -->
  20.         <buff id="266" desc="Increases Evasion."/><!-- Song of Water -->
  21. diff --git a/aCis_datapack/data/xml/npcs/50000-50999.xml b/aCis_datapack/data/xml/npcs/50000-50999.xml
  22. index cfcc992..3adcd84 100644
  23. --- a/aCis_datapack/data/xml/npcs/50000-50999.xml
  24. +++ b/aCis_datapack/data/xml/npcs/50000-50999.xml
  25. @@ -82,7 +82,7 @@
  26.         <set name="height" val="18"/>
  27.         <set name="rHand" val="0"/>
  28.         <set name="lHand" val="0"/>
  29. -       <set name="type" val="SchemeBuffer"/>
  30. +       <set name="type" val="PlayerBuffer"/>
  31.         <set name="exp" val="0"/>
  32.         <set name="sp" val="0"/>
  33.         <set name="hp" val="2444.46819"/>
  34. diff --git a/aCis_gameserver/config/npcs.properties b/aCis_gameserver/config/npcs.properties
  35. index c05f8a9..e99f647 100644
  36. --- a/aCis_gameserver/config/npcs.properties
  37. +++ b/aCis_gameserver/config/npcs.properties
  38. @@ -201,4 +201,31 @@
  39.  MinNPCAnimation = 20
  40.  MaxNPCAnimation = 40
  41.  MinMonsterAnimation = 10
  42. -MaxMonsterAnimation = 40
  43. \ No newline at end of file
  44. +MaxMonsterAnimation = 40
  45. +
  46. + #=============================================================
  47. +#                          Buffer
  48. +#=============================================================
  49. +
  50. +# Maximum number of available schemes per player.
  51. +BufferMaxSchemesPerChar = 4
  52. +
  53. +# Maximum number of buffs per scheme.
  54. +BufferMaxSkillsPerScheme = 24
  55. +
  56. +# Static cost of buffs ; override skills price if different of -1.
  57. +BufferStaticCostPerBuff = -1
  58. +
  59. +# Fighter Set List
  60. +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
  61. +# Mage Set List
  62. +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
  63. +
  64. +# Buffer List, skillId, skillevel, buffPrice,type.
  65. +BufferBuffs = 264,1,0,Songs;265,1,0,Songs;266,1,0,Songs;267,1,0,Songs;268,1,0,Songs;269,1,0,Songs;270,1,0,Songs;304,1,0,Songs;305,1,0,Songs;306,1,0,Songs;308,1,0,Songs;349,1,0,Songs;363,1,0,Songs;364,1,0,Songs;271,1,0,Dances;272,1,0,Dances;273,1,0,Dances;274,1,0,Dances;275,1,0,Dances;276,1,0,Dances;277,1,0,Dances;309,1,0,Dances;310,1,0,Dances;311,1,0,Dances;307,1,0,Dances;365,1,0,Dances;1002,1,0,Warcryer;1006,1,0,Warcryer;1007,1,0,Warcryer;1009,1,0,Warcryer;1308,1,0,Warcryer;1309,1,0,Warcryer;1310,1,0,Warcryer;1362,1,0,Warcryer;1390,1,0,Warcryer;1391,1,0,Warcryer;1413,1,0,Warcryer;1416,1,0,Overlord;1003,1,0,Overlord;1004,1,0,Overlord;1005,1,0,Overlord;1008,1,0,Overlord;1249,1,0,Overlord;1364,1,0,Overlord;1365,1,0,Overlord;1032,1,0,Prophet;1033,1,0,Prophet;1035,1,0,Prophet;1036,1,0,Prophet;1040,1,0,Prophet;1043,1,0,Prophet;1044,1,0,Prophet;1045,1,0,Prophet;1048,1,0,Prophet;1059,1,0,Shillen_Elder;1062,1,0,Prophet;1068,1,0,Prophet;1073,1,0,Elder;1077,1,0,Shillen_Elder;1078,1,0,Shillen_Elder;1085,1,0,Prophet;1086,1,0,Prophet;1087,1,0,Elder;1182,1,0,Elder;1189,1,0,Shillen_Elder;1191,1,0,Prophet;1204,1,0,Prophet;1242,1,0,Shillen_Elder;1243,1,0,Prophet;1259,1,0,Elder;1268,1,0,Shillen_Elder;1303,1,0,Shillen_Elder;1304,1,0,Elder;1352,1,0,Elder;1353,1,0,Elder;1354,1,0,Elder;1388,1,0,Shillen_Elder;1389,1,0,Shillen_Elder;1392,1,0,Prophet;1393,1,0,Elder;1397,1,0,Elder;1355,1,0,Elder;4699,1,0,Elder;4700,1,0,Elder;4702,1,0,Elder;4703,1,0,Elder;1356,1,0,Prophet;1357,1,0,Shillen_Elder;1363,1,0,Warcryer;1414,1,0,Overlord
  66. +
  67. +RestrictUseBufferOnPvPFlag = true
  68. +RestrictUseBufferInCombat = true
  69. +
  70. +VoteBuffItemId = 57
  71. +VoteBuffItemCount = 15
  72. \ No newline at end of file
  73. diff --git a/aCis_gameserver/java/net/sf/l2j/Config.java b/aCis_gameserver/java/net/sf/l2j/Config.java
  74. index 65daaa6..ae3938c 100644
  75. --- a/aCis_gameserver/java/net/sf/l2j/Config.java
  76. +++ b/aCis_gameserver/java/net/sf/l2j/Config.java
  77. @@ -16,6 +16,7 @@
  78.  import net.sf.l2j.commons.math.MathUtil;
  79.  
  80.  import net.sf.l2j.gameserver.enums.GeoType;
  81. +import net.sf.l2j.gameserver.model.holder.BuffSkillHolder;
  82.  import net.sf.l2j.gameserver.model.holder.IntIntHolder;
  83.  
  84.  /**
  85. @@ -326,6 +327,26 @@
  86.     public static int MIN_MONSTER_ANIMATION;
  87.     public static int MAX_MONSTER_ANIMATION;
  88.    
  89. +   /** Buffer */
  90. +   public static String PFIGHTER_SET;
  91. +   public static int[] PFIGHTER_SET_LIST;
  92. +   public static String PMAGE_SET;
  93. +   public static int[] PMAGE_SET_LIST;
  94. +   public static int PBUFFER_MAX_SCHEMES;
  95. +   public static int PBUFFER_MAX_SKILLS;
  96. +   public static int PBUFFER_STATIC_BUFF_COST;
  97. +   public static String PBUFFER_BUFFS;
  98. +   public static Map<Integer, BuffSkillHolder> PBUFFER_BUFFLIST;
  99. +  
  100. +   public static List<Integer> PFIGHTER_SKILL_LIST;
  101. +   public static List<Integer> PMAGE_SKILL_LIST;
  102. +  
  103. +   public static boolean PRESTRICT_USE_BUFFER_ON_PVPFLAG;
  104. +   public static boolean PRESTRICT_USE_BUFFER_IN_COMBAT;
  105. +  
  106. +   public static int PVOTE_BUFF_ITEM_ID;
  107. +   public static int PVOTE_BUFF_ITEM_COUNT;
  108. +  
  109.     // --------------------------------------------------
  110.     // Players
  111.     // --------------------------------------------------
  112. @@ -949,6 +970,45 @@
  113.         MAX_NPC_ANIMATION = npcs.getProperty("MaxNPCAnimation", 40);
  114.         MIN_MONSTER_ANIMATION = npcs.getProperty("MinMonsterAnimation", 10);
  115.         MAX_MONSTER_ANIMATION = npcs.getProperty("MaxMonsterAnimation", 40);
  116. +      
  117. +       PBUFFER_MAX_SCHEMES = npcs.getProperty("BufferMaxSchemesPerChar", 4);
  118. +       PBUFFER_MAX_SKILLS = npcs.getProperty("BufferMaxSkillsPerScheme", 24);
  119. +       PBUFFER_STATIC_BUFF_COST = npcs.getProperty("BufferStaticCostPerBuff", -1);
  120. +       PBUFFER_BUFFS = npcs.getProperty("BufferBuffs");
  121. +      
  122. +       PFIGHTER_SET = npcs.getProperty("FighterSet", "2375,3500,3501,3502,4422,4423,4424,4425,6648,6649,6650");
  123. +       PMAGE_SET = npcs.getProperty("MageSet", "2375,3500,3501,3502,4422,4423,4424,4425,6648,6649,6650");
  124. +      
  125. +       String[] FighterList = PFIGHTER_SET.split(",");
  126. +       PFIGHTER_SET_LIST = new int[FighterList.length];
  127. +       for (int i = 0; i < FighterList.length; i++)
  128. +           PFIGHTER_SET_LIST[i] = Integer.parseInt(FighterList[i]);
  129. +      
  130. +       String[] MageList = PMAGE_SET.split(",");
  131. +       PMAGE_SET_LIST = new int[MageList.length];
  132. +       for (int i = 0; i < MageList.length; i++)
  133. +           PMAGE_SET_LIST[i] = Integer.parseInt(MageList[i]);
  134. +      
  135. +       PBUFFER_BUFFLIST = new HashMap<>();
  136. +       for (String skillInfo : PBUFFER_BUFFS.split(";"))
  137. +       {
  138. +           final String[] infos = skillInfo.split(",");
  139. +           PBUFFER_BUFFLIST.put(Integer.valueOf(infos[0]), new BuffSkillHolder(Integer.valueOf(infos[0]), Integer.valueOf(infos[1]), Integer.valueOf(infos[2]), infos[3], skillInfo));
  140. +       }
  141. +      
  142. +       PRESTRICT_USE_BUFFER_ON_PVPFLAG = npcs.getProperty("RestrictUseBufferOnPvPFlag", true);
  143. +       PRESTRICT_USE_BUFFER_IN_COMBAT = npcs.getProperty("RestrictUseBufferInCombat", true);
  144. +      
  145. +       PVOTE_BUFF_ITEM_ID = npcs.getProperty("VoteBuffItemId", 57);
  146. +       PVOTE_BUFF_ITEM_COUNT = npcs.getProperty("VoteBuffItemCount", 1);
  147. +      
  148. +       PFIGHTER_SKILL_LIST = new ArrayList<>();
  149. +       for (String skill_id : npcs.getProperty("FighterSkillList", "").split(";"))
  150. +           PFIGHTER_SKILL_LIST.add(Integer.parseInt(skill_id));
  151. +      
  152. +       PMAGE_SKILL_LIST = new ArrayList<>();
  153. +       for (String skill_id : npcs.getProperty("MageSkillList", "").split(";"))
  154. +           PMAGE_SKILL_LIST.add(Integer.parseInt(skill_id));
  155.     }
  156.    
  157.     /**
  158. diff --git a/aCis_gameserver/java/net/sf/l2j/gameserver/model/actor/instance/PlayerBuffer.java b/aCis_gameserver/java/net/sf/l2j/gameserver/model/actor/instance/PlayerBuffer.java
  159. new file mode 100644
  160. index 0000000..284f86a
  161. --- /dev/null
  162. +++ b/aCis_gameserver/java/net/sf/l2j/gameserver/model/actor/instance/PlayerBuffer.java
  163. @@ -0,0 +1,524 @@
  164. +package net.sf.l2j.gameserver.model.actor.instance;
  165. +
  166. +import java.util.ArrayList;
  167. +import java.util.List;
  168. +import java.util.Map;
  169. +import java.util.StringTokenizer;
  170. +
  171. +import net.sf.l2j.commons.lang.StringUtil;
  172. +import net.sf.l2j.commons.math.MathUtil;
  173. +
  174. +import net.sf.l2j.Config;
  175. +import net.sf.l2j.gameserver.data.SkillTable;
  176. +import net.sf.l2j.gameserver.data.manager.BufferManager;
  177. +import net.sf.l2j.gameserver.model.actor.Creature;
  178. +import net.sf.l2j.gameserver.model.actor.Player;
  179. +import net.sf.l2j.gameserver.model.actor.Summon;
  180. +import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
  181. +import net.sf.l2j.gameserver.network.serverpackets.ItemList;
  182. +import net.sf.l2j.gameserver.network.serverpackets.MagicSkillUse;
  183. +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
  184. +import net.sf.l2j.gameserver.skills.L2Skill;
  185. +
  186. +/**
  187. + * @author Baggos
  188. + */
  189. +public class PlayerBuffer extends Folk
  190. +{
  191. +   private static final int PAGE_LIMIT = 6;
  192. +  
  193. +   public PlayerBuffer(int objectId, NpcTemplate template)
  194. +   {
  195. +       super(objectId, template);
  196. +   }
  197. +  
  198. +   private void showMainWindow(Player activeChar)
  199. +   {
  200. +       final NpcHtmlMessage html = new NpcHtmlMessage(0);
  201. +       html.setFile(getHtmlPath(getNpcId(), 0));
  202. +       html.replace("%objectId%", String.valueOf(getObjectId()));
  203. +       html.replace("%name%", activeChar.getName());
  204. +       html.replace("%buffcount%", "You have " + activeChar.getBuffCount() + "/" + activeChar.getMaxBuffCount() + " buffs.");
  205. +      
  206. +       activeChar.sendPacket(html);
  207. +   }
  208. +  
  209. +   @Override
  210. +   public void onBypassFeedback(Player player, String command)
  211. +   {
  212. +       if (player.getPvpFlag() > 0 && Config.PRESTRICT_USE_BUFFER_ON_PVPFLAG)
  213. +       {
  214. +           player.sendMessage("You can't use buffer when you are pvp flagged.");
  215. +           return;
  216. +       }
  217. +      
  218. +       if (player.isInCombat() && Config.PRESTRICT_USE_BUFFER_IN_COMBAT)
  219. +       {
  220. +           player.sendMessage("You can't use buffer when you are in combat.");
  221. +           return;
  222. +       }
  223. +      
  224. +       if (player.isDead())
  225. +           return;
  226. +      
  227. +       StringTokenizer st = new StringTokenizer(command, " ");
  228. +       String actualCommand = st.nextToken();
  229. +      
  230. +       if (actualCommand.startsWith("bufflist"))
  231. +       {
  232. +           autoBuffFunction(player, st.nextToken());
  233. +       }
  234. +       else if (actualCommand.startsWith("restore"))
  235. +       {
  236. +           String noble = st.nextToken();
  237. +           player.getStatus().setMaxCpHpMp();
  238. +          
  239. +           if (noble.equals("true"))
  240. +           {
  241. +               SkillTable.getInstance().getInfo(1323, 1).getEffects(player, player);
  242. +               player.broadcastPacket(new MagicSkillUse(this, player, 1323, 1, 850, 0));
  243. +           }
  244. +          
  245. +           final Summon summon = player.getSummon();
  246. +           if (summon != null)
  247. +               summon.getStatus().setMaxHpMp();
  248. +          
  249. +           showMainWindow(player);
  250. +       }
  251. +       else if (actualCommand.startsWith("cancellation"))
  252. +       {
  253. +           L2Skill buff;
  254. +           buff = SkillTable.getInstance().getInfo(1056, 1);
  255. +           buff.getEffects(this, player);
  256. +           player.stopAllEffectsExceptThoseThatLastThroughDeath();
  257. +           player.broadcastPacket(new MagicSkillUse(this, player, 1056, 1, 850, 0));
  258. +           player.stopAllEffects();
  259. +          
  260. +           final Summon summon = player.getSummon();
  261. +           if (summon != null)
  262. +               summon.stopAllEffects();
  263. +          
  264. +           showMainWindow(player);
  265. +       }
  266. +       else if (actualCommand.startsWith("openlist"))
  267. +       {
  268. +           String category = st.nextToken();
  269. +           String htmfile = st.nextToken();
  270. +          
  271. +           NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
  272. +          
  273. +           if (category.startsWith("null"))
  274. +           {
  275. +               html.setFile("data/html/mods/buffer/" + htmfile + ".htm");
  276. +              
  277. +               // First Page
  278. +               if (htmfile.equals("index"))
  279. +               {
  280. +                   html.replace("%name%", player.getName());
  281. +                   html.replace("%buffcount%", "You have " + player.getBuffCount() + "/" + player.getMaxBuffCount() + " buffs.");
  282. +               }
  283. +           }
  284. +           else
  285. +               html.setFile("data/html/mods/buffer/" + category + "/" + htmfile + ".htm");
  286. +          
  287. +           html.replace("%objectId%", String.valueOf(getObjectId()));
  288. +           player.sendPacket(html);
  289. +       }
  290. +      
  291. +       else if (actualCommand.startsWith("dobuff"))
  292. +       {
  293. +           int buffid = Integer.valueOf(st.nextToken());
  294. +           int bufflevel = Integer.valueOf(st.nextToken());
  295. +           String category = st.nextToken();
  296. +           String windowhtml = st.nextToken();
  297. +           String votebuff = null;
  298. +          
  299. +           if (st.hasMoreTokens())
  300. +               votebuff = st.nextToken();
  301. +          
  302. +           if (windowhtml.equals("malaria"))
  303. +           {
  304. +               if (player.getInventory().getItemCount(Config.PVOTE_BUFF_ITEM_ID, 0) >= 1)
  305. +               {
  306. +                   player.getInventory().destroyItemByItemId("VoteCoins", Config.PVOTE_BUFF_ITEM_ID, 1, player, null);
  307. +                   player.getInventory().updateDatabase();
  308. +                   player.sendPacket(new ItemList(player, true));
  309. +                   player.sendMessage(1 + " Vote eye destroyed.");
  310. +               }
  311. +               else
  312. +               {
  313. +                   player.sendMessage("You dont have enough (" + 1 + ") vote item for buff.");
  314. +                   return;
  315. +               }
  316. +           }
  317. +          
  318. +           if (votebuff != null)
  319. +           {
  320. +               if (player.getInventory().getItemCount(Config.PVOTE_BUFF_ITEM_ID, 0) >= Config.PVOTE_BUFF_ITEM_COUNT)
  321. +               {
  322. +                   player.getInventory().destroyItemByItemId("VoteCoins", Config.PVOTE_BUFF_ITEM_ID, Config.PVOTE_BUFF_ITEM_COUNT, player, null);
  323. +                   player.getInventory().updateDatabase();
  324. +                   player.sendPacket(new ItemList(player, true));
  325. +                   player.sendMessage(Config.PVOTE_BUFF_ITEM_COUNT + " vote stone destroyed.");
  326. +               }
  327. +               else
  328. +               {
  329. +                   player.sendMessage("You dont have enough (" + Config.PVOTE_BUFF_ITEM_COUNT + ") vote item for buff.");
  330. +                   return;
  331. +               }
  332. +           }
  333. +          
  334. +           Creature target = player;
  335. +           if (category.startsWith("pet"))
  336. +           {
  337. +               if (player.getSummon() == null)
  338. +               {
  339. +                   player.sendMessage("Incorrect Pet");
  340. +                   showMainWindow(player);
  341. +                   return;
  342. +               }
  343. +               target = player.getSummon();
  344. +           }
  345. +          
  346. +           MagicSkillUse mgc = new MagicSkillUse(this, target, buffid, bufflevel, 1150, 0);
  347. +           player.sendPacket(mgc);
  348. +           player.broadcastPacket(mgc);
  349. +           SkillTable.getInstance().getInfo(buffid, bufflevel).getEffects(this, target);
  350. +          
  351. +           NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
  352. +           html.setFile("data/html/mods/buffer/" + category + "/" + windowhtml + ".htm");
  353. +           html.replace("%objectId%", String.valueOf(getObjectId()));
  354. +           html.replace("%name%", player.getName());
  355. +           player.sendPacket(html);
  356. +       }
  357. +       else if (actualCommand.startsWith("getbuff"))
  358. +       {
  359. +           int buffid = Integer.valueOf(st.nextToken());
  360. +           int bufflevel = Integer.valueOf(st.nextToken());
  361. +           if (buffid != 0)
  362. +           {
  363. +               SkillTable.getInstance().getInfo(buffid, bufflevel).getEffects(this, player);
  364. +               broadcastPacket(new MagicSkillUse(this, player, buffid, bufflevel, 450, 0));
  365. +               showMainWindow(player);
  366. +           }
  367. +       }
  368. +       else if (actualCommand.startsWith("support"))
  369. +       {
  370. +           showGiveBuffsWindow(player);
  371. +       }
  372. +       else if (actualCommand.startsWith("givebuffs"))
  373. +       {
  374. +           final String schemeName = st.nextToken();
  375. +           final int cost = Integer.parseInt(st.nextToken());
  376. +          
  377. +           Creature target = null;
  378. +           if (st.hasMoreTokens())
  379. +           {
  380. +               final String targetType = st.nextToken();
  381. +               if (targetType != null && targetType.equalsIgnoreCase("pet"))
  382. +                   target = player.getSummon();
  383. +           }
  384. +           else
  385. +               target = player;
  386. +          
  387. +           if (target == null)
  388. +               player.sendMessage("You don't have a pet.");
  389. +           else if (cost == 0 || player.reduceAdena("NPC Buffer", cost, this, true))
  390. +               BufferManager.getInstance().applySchemeEffects(this, target, player.getObjectId(), schemeName);
  391. +       }
  392. +       else if (actualCommand.startsWith("editschemes"))
  393. +       {
  394. +           showEditSchemeWindow(player, st.nextToken(), st.nextToken(), Integer.parseInt(st.nextToken()));
  395. +       }
  396. +       else if (actualCommand.startsWith("skill"))
  397. +       {
  398. +           final String groupType = st.nextToken();
  399. +           final String schemeName = st.nextToken();
  400. +          
  401. +           final int skillId = Integer.parseInt(st.nextToken());
  402. +           final int page = Integer.parseInt(st.nextToken());
  403. +          
  404. +           final List<Integer> skills = BufferManager.getInstance().getScheme(player.getObjectId(), schemeName);
  405. +          
  406. +           if (actualCommand.startsWith("skillselect") && !schemeName.equalsIgnoreCase("none"))
  407. +           {
  408. +               if (skills.size() < player.getMaxBuffCount())
  409. +                   skills.add(skillId);
  410. +               else
  411. +                   player.sendMessage("This scheme has reached the maximum amount of buffs.");
  412. +           }
  413. +           else if (actualCommand.startsWith("skillunselect"))
  414. +               skills.remove(Integer.valueOf(skillId));
  415. +          
  416. +           showEditSchemeWindow(player, groupType, schemeName, page);
  417. +       }
  418. +       else if (actualCommand.startsWith("createscheme"))
  419. +       {
  420. +           try
  421. +           {
  422. +               final String schemeName = st.nextToken();
  423. +               if (schemeName.length() > 14)
  424. +               {
  425. +                   player.sendMessage("Scheme's name must contain up to 14 chars. Spaces are trimmed.");
  426. +                   return;
  427. +               }
  428. +              
  429. +               final Map<String, ArrayList<Integer>> schemes = BufferManager.getInstance().getPlayerSchemes(player.getObjectId());
  430. +               if (schemes != null)
  431. +               {
  432. +                   if (schemes.size() == Config.PBUFFER_MAX_SCHEMES)
  433. +                   {
  434. +                       player.sendMessage("Maximum schemes amount is already reached.");
  435. +                       return;
  436. +                   }
  437. +                  
  438. +                   if (schemes.containsKey(schemeName))
  439. +                   {
  440. +                       player.sendMessage("The scheme name already exists.");
  441. +                       return;
  442. +                   }
  443. +               }
  444. +              
  445. +               BufferManager.getInstance().setScheme(player.getObjectId(), schemeName.trim(), new ArrayList<>());
  446. +               showGiveBuffsWindow(player);
  447. +           }
  448. +           catch (Exception e)
  449. +           {
  450. +               player.sendMessage("Scheme's name must contain up to 14 chars. Spaces are trimmed.");
  451. +           }
  452. +       }
  453. +       else if (actualCommand.startsWith("deletescheme"))
  454. +       {
  455. +           try
  456. +           {
  457. +               final String schemeName = st.nextToken();
  458. +               final Map<String, ArrayList<Integer>> schemes = BufferManager.getInstance().getPlayerSchemes(player.getObjectId());
  459. +              
  460. +               if (schemes != null && schemes.containsKey(schemeName))
  461. +                   schemes.remove(schemeName);
  462. +           }
  463. +           catch (Exception e)
  464. +           {
  465. +               player.sendMessage("This scheme name is invalid.");
  466. +           }
  467. +           showGiveBuffsWindow(player);
  468. +       }
  469. +      
  470. +       super.onBypassFeedback(player, command);
  471. +   }
  472. +  
  473. +   @Override
  474. +   public String getHtmlPath(int npcId, int val)
  475. +   {
  476. +       String filename = "";
  477. +       if (val == 0)
  478. +           filename = "" + npcId;
  479. +       else
  480. +           filename = npcId + "-" + val;
  481. +      
  482. +       return "data/html/mods/buffer/" + filename + ".htm";
  483. +   }
  484. +  
  485. +   /**
  486. +    * Send an html packet to the {@link Player} set a parameter with Give Buffs menu info for player and pet, depending on targetType parameter {player, pet}.
  487. +    * @param player : The {@link Player} to make checks on.
  488. +    */
  489. +   private void showGiveBuffsWindow(Player player)
  490. +   {
  491. +       final StringBuilder sb = new StringBuilder(200);
  492. +      
  493. +       final Map<String, ArrayList<Integer>> schemes = BufferManager.getInstance().getPlayerSchemes(player.getObjectId());
  494. +       if (schemes == null || schemes.isEmpty())
  495. +           sb.append("<font color=\"LEVEL\">You haven't defined any scheme.</font>");
  496. +       else
  497. +       {
  498. +           for (Map.Entry<String, ArrayList<Integer>> scheme : schemes.entrySet())
  499. +           {
  500. +               final int cost = getFee(scheme.getValue());
  501. +               StringUtil.append(sb, "<font color=\"LEVEL\">", scheme.getKey(), " [", scheme.getValue().size(), " / ", player.getMaxBuffCount(), "]", ((cost > 0) ? " - cost: " + StringUtil.formatNumber(cost) : ""), "</font><br1>");
  502. +               StringUtil.append(sb, "<a action=\"bypass npc_%objectId%_givebuffs ", scheme.getKey(), " ", cost, "\">Use on Me</a>&nbsp;|&nbsp;");
  503. +               StringUtil.append(sb, "<a action=\"bypass npc_%objectId%_givebuffs ", scheme.getKey(), " ", cost, " pet\">Use on Pet</a>&nbsp;|&nbsp;");
  504. +               StringUtil.append(sb, "<a action=\"bypass npc_%objectId%_editschemes Buffs ", scheme.getKey(), " 1\">Edit</a>&nbsp;|&nbsp;");
  505. +               StringUtil.append(sb, "<a action=\"bypass npc_%objectId%_deletescheme ", scheme.getKey(), "\">Delete</a><br>");
  506. +           }
  507. +       }
  508. +      
  509. +       final NpcHtmlMessage html = new NpcHtmlMessage(0);
  510. +       html.setFile(getHtmlPath(getNpcId(), 1));
  511. +       html.replace("%schemes%", sb.toString());
  512. +       html.replace("%max_schemes%", Config.PBUFFER_MAX_SCHEMES);
  513. +       html.replace("%objectId%", getObjectId());
  514. +       player.sendPacket(html);
  515. +   }
  516. +  
  517. +   /**
  518. +    * Send an html packet to the {@link Player} set as parameter with Edit Scheme Menu info. This allows the {@link Player} to edit each created scheme (add/delete skills)
  519. +    * @param player : The {@link Player} to make checks on.
  520. +    * @param groupType : The group of skills to select.
  521. +    * @param schemeName : The scheme to make check.
  522. +    * @param page : The current checked page.
  523. +    */
  524. +   private void showEditSchemeWindow(Player player, String groupType, String schemeName, int page)
  525. +   {
  526. +       final NpcHtmlMessage html = new NpcHtmlMessage(0);
  527. +       final List<Integer> schemeSkills = BufferManager.getInstance().getScheme(player.getObjectId(), schemeName);
  528. +      
  529. +       html.setFile(getHtmlPath(getNpcId(), 2));
  530. +       html.replace("%schemename%", schemeName);
  531. +       html.replace("%count%", schemeSkills.size() + " / " + player.getMaxBuffCount());
  532. +       html.replace("%typesframe%", getTypesFrame(groupType, schemeName));
  533. +       html.replace("%skilllistframe%", getGroupSkillList(player, groupType, schemeName, page));
  534. +       html.replace("%objectId%", getObjectId());
  535. +       player.sendPacket(html);
  536. +   }
  537. +  
  538. +   /**
  539. +    * @param player : The {@link Player} to make checks on.
  540. +    * @param groupType : The group of skills to select.
  541. +    * @param schemeName : The scheme to make check.
  542. +    * @param page : The current checked page.
  543. +    * @return A {@link String} representing skills available for selection for a given groupType.
  544. +    */
  545. +   private String getGroupSkillList(Player player, String groupType, String schemeName, int page)
  546. +   {
  547. +       // Retrieve the entire skills list based on group type.
  548. +       List<Integer> skills = BufferManager.getInstance().getSkillsIdsByType(groupType);
  549. +       if (skills.isEmpty())
  550. +           return "That group doesn't contain any skills.";
  551. +      
  552. +       // Calculate page number.
  553. +       final int max = MathUtil.countPagesNumber(skills.size(), PAGE_LIMIT);
  554. +       if (page > max)
  555. +           page = max;
  556. +      
  557. +       // Cut skills list up to page number.
  558. +       skills = skills.subList((page - 1) * PAGE_LIMIT, Math.min(page * PAGE_LIMIT, skills.size()));
  559. +      
  560. +       final List<Integer> schemeSkills = BufferManager.getInstance().getScheme(player.getObjectId(), schemeName);
  561. +       final StringBuilder sb = new StringBuilder(skills.size() * 150);
  562. +      
  563. +       int row = 0;
  564. +       for (int skillId : skills)
  565. +       {
  566. +           final String icon = (skillId < 100) ? "icon.skill00" + skillId : (skillId < 1000) ? "icon.skill0" + skillId : "icon.skill" + skillId;
  567. +          
  568. +           sb.append(((row % 2) == 0 ? "<table width=\"280\" bgcolor=\"000000\"><tr>" : "<table width=\"280\"><tr>"));
  569. +          
  570. +           if (schemeSkills.contains(skillId))
  571. +               StringUtil.append(sb, "<td height=40 width=40><img src=\"", icon, "\" width=32 height=32></td><td width=190>", SkillTable.getInstance().getInfo(skillId, 1).getName(), "<br1><font color=\"B09878\">", BufferManager.getInstance().getAvailableBuff(skillId).getDescription(), "</font></td><td><button action=\"bypass npc_%objectId%_skillunselect ", groupType, " ", schemeName, " ", skillId, " ", page, "\" width=32 height=32 back=\"L2UI_CH3.mapbutton_zoomout2\" fore=\"L2UI_CH3.mapbutton_zoomout1\"></td>");
  572. +           else
  573. +               StringUtil.append(sb, "<td height=40 width=40><img src=\"", icon, "\" width=32 height=32></td><td width=190>", SkillTable.getInstance().getInfo(skillId, 1).getName(), "<br1><font color=\"B09878\">", BufferManager.getInstance().getAvailableBuff(skillId).getDescription(), "</font></td><td><button action=\"bypass npc_%objectId%_skillselect ", groupType, " ", schemeName, " ", skillId, " ", page, "\" width=32 height=32 back=\"L2UI_CH3.mapbutton_zoomin2\" fore=\"L2UI_CH3.mapbutton_zoomin1\"></td>");
  574. +          
  575. +           sb.append("</tr></table><img src=\"L2UI.SquareGray\" width=277 height=1>");
  576. +           row++;
  577. +       }
  578. +      
  579. +       for (int i = PAGE_LIMIT; i > row; i--)
  580. +           StringUtil.append(sb, "<img height=41>");
  581. +      
  582. +       // Build page footer.
  583. +       sb.append("<br><img src=\"L2UI.SquareGray\" width=277 height=1><table width=\"100%\" bgcolor=000000><tr>");
  584. +      
  585. +       if (page > 1)
  586. +           StringUtil.append(sb, "<td align=left width=70><a action=\"bypass npc_" + getObjectId() + "_editschemes ", groupType, " ", schemeName, " ", page - 1, "\">Previous</a></td>");
  587. +       else
  588. +           StringUtil.append(sb, "<td align=left width=70>Previous</td>");
  589. +      
  590. +       StringUtil.append(sb, "<td align=center width=100>Page ", page, "</td>");
  591. +      
  592. +       if (page < max)
  593. +           StringUtil.append(sb, "<td align=right width=70><a action=\"bypass npc_" + getObjectId() + "_editschemes ", groupType, " ", schemeName, " ", page + 1, "\">Next</a></td>");
  594. +       else
  595. +           StringUtil.append(sb, "<td align=right width=70>Next</td>");
  596. +      
  597. +       sb.append("</tr></table><img src=\"L2UI.SquareGray\" width=277 height=1>");
  598. +      
  599. +       return sb.toString();
  600. +   }
  601. +  
  602. +   /**
  603. +    * @param groupType : The group of skills to select.
  604. +    * @param schemeName : The scheme to make check.
  605. +    * @return A {@link String} representing all groupTypes available. The group currently on selection isn't linkable.
  606. +    */
  607. +   private static String getTypesFrame(String groupType, String schemeName)
  608. +   {
  609. +       final StringBuilder sb = new StringBuilder(500);
  610. +       sb.append("<table>");
  611. +      
  612. +       int count = 0;
  613. +       for (String type : BufferManager.getInstance().getSkillTypes())
  614. +       {
  615. +           if (count == 0)
  616. +               sb.append("<tr>");
  617. +          
  618. +           if (groupType.equalsIgnoreCase(type))
  619. +               StringUtil.append(sb, "<td width=65>", type, "</td>");
  620. +           else
  621. +               StringUtil.append(sb, "<td width=65><a action=\"bypass npc_%objectId%_editschemes ", type, " ", schemeName, " 1\">", type, "</a></td>");
  622. +          
  623. +           count++;
  624. +           if (count == 4)
  625. +           {
  626. +               sb.append("</tr>");
  627. +               count = 0;
  628. +           }
  629. +       }
  630. +      
  631. +       if (!sb.toString().endsWith("</tr>"))
  632. +           sb.append("</tr>");
  633. +      
  634. +       sb.append("</table>");
  635. +      
  636. +       return sb.toString();
  637. +   }
  638. +  
  639. +   /**
  640. +    * @param list : A {@link List} of skill ids.
  641. +    * @return a global fee for all skills contained in the {@link List}.
  642. +    */
  643. +   private static int getFee(ArrayList<Integer> list)
  644. +   {
  645. +       if (Config.PBUFFER_STATIC_BUFF_COST > 0)
  646. +           return list.size() * Config.PBUFFER_STATIC_BUFF_COST;
  647. +      
  648. +       int fee = 0;
  649. +       for (int sk : list)
  650. +           fee += BufferManager.getInstance().getAvailableBuff(sk).getPrice();
  651. +      
  652. +       return fee;
  653. +   }
  654. +  
  655. +   private void autoBuffFunction(Player player, String bufflist)
  656. +   {
  657. +       ArrayList<L2Skill> skills_to_buff = new ArrayList<>();
  658. +       List<Integer> list = null;
  659. +      
  660. +       if (bufflist.equalsIgnoreCase("fighter"))
  661. +           list = Config.PFIGHTER_SKILL_LIST;
  662. +       else if (bufflist.equalsIgnoreCase("mage"))
  663. +           list = Config.PMAGE_SKILL_LIST;
  664. +      
  665. +       if (list != null)
  666. +       {
  667. +           for (int skillId : list)
  668. +           {
  669. +               L2Skill skill = SkillTable.getInstance().getInfo(skillId, SkillTable.getInstance().getMaxLevel(skillId));
  670. +               if (skill != null)
  671. +                   skills_to_buff.add(skill);
  672. +           }
  673. +          
  674. +           for (L2Skill sk : skills_to_buff)
  675. +               sk.getEffects(player, player);
  676. +          
  677. +           player.updateEffectIcons();
  678. +          
  679. +           list = null;
  680. +       }
  681. +      
  682. +       skills_to_buff.clear();
  683. +      
  684. +       showMainWindow(player);
  685. +   }
  686. +  
  687. +}
  688. \ No newline at end of file
  689.  
Add Comment
Please, Sign In to add comment