Welcome to RUSaCis - эмулятор Interlude

Присоединяйтесь к нам прямо сейчас, чтобы получить доступ ко всем нашим возможностям. После регистрации и входа в систему вы сможете создавать темы, публиковать ответы в существующих темах, давать репутацию пользователям - так же приобрести исходный код. Это также быстро, так чего же вы ждете?

autoacp

shalva

Бродяга
Регистрация
22 Сен 2021
Сообщения
14
Реакции
1
Баллы
3
RaCoin
0
zdrastvuite vot dobavil etat cod
nu negde ne magu naiti dla nevo voiced command
esli ukavo zavalalas prashu podelites


Index: net.sf.l2j;Config.java
===================================================================
--- net.sf.l2j;Config.java (revision 84)
+++ net.sf.l2j;Config.java (working copy)

+ /** Auto potions settings */
+ public static Map<Integer, Integer> AUTO_POTIONS = new HashMap<>();
+ public static Map<Integer, String[]> AUTO_POTIONS_LIMITS = new HashMap<>();



+ String ap = player.getProperty("AutoPotions", "");
+ String[] ap_split = ap.split(";");
+ for (String s : ap_split)
+ {
+ String[] ss = s.split(",");
+ AUTO_POTIONS.put(Integer.parseInt(ss[0]), Integer.parseInt(ss[1]));
+ }
+ String apl = player.getProperty("AutoPotionsLimits", "");
+ String[] apl_split = apl.split(";");
+ for (String s : apl_split)
+ {
+ String[] ss = s.split(",");
+ AUTO_POTIONS_LIMITS.put(Integer.parseInt(ss[0]), new String[] { ss[1], ss[2] });
+ }


Index: net.sf.l2j.gameserver.ban;AutoPotionTask.java
===================================================================
--- net.sf.l2j.gameserver.ban;AutoPotionTask.java (revision 84)
+++ net.sf.l2j.gameserver.l2jban.autopotion;AutoPotionTask.java (working copy)


+ package net.sf.l2j.gameserver.l2jban.autopotion;
+
+ import net.sf.l2j.Config;
+ import net.sf.l2j.gameserver.model.L2Skill;
+ import net.sf.l2j.gameserver.model.actor.instance.Player;
+ import net.sf.l2j.gameserver.model.holder.IntIntHolder;
+
+ public class AutoPotionTask implements Runnable
+ {
+ private int itemId;
+ private Player player;
+
+ public AutoPotionTask(int itemId, Player player)
+ {
+ this.itemId = itemId;
+ this.player = player;
+ }
+
+ @Override
+ public void run()
+ {
+ if (!player.isOnline())
+ {
+ player.stopAutoPotion(itemId);
+ return;
+ }
+ if (player.isInOlympiadMode())
+ {
+ player.sendMessage("You cannot that in olympiad mode.");
+ player.stopAutoPotion(itemId);
+ return;
+ }
+
+ if (Config.AUTO_POTIONS_LIMITS.containsKey(itemId))
+ {
+ String type = Config.AUTO_POTIONS_LIMITS.get(itemId)[0];
+ int val = Integer.parseInt(Config.AUTO_POTIONS_LIMITS.get(itemId)[1]);
+
+ switch (type)
+ {
+ case "CP":
+ {
+ if ((player.getCurrentCp() / player.getMaxCp()) * 100 > val)
+ return;
+ break;
+ }
+ case "HP":
+ {
+ if ((player.getCurrentHp() / player.getMaxHp()) * 100 > val)
+ return;
+ break;
+ }
+ case "MP":
+ {
+ if ((player.getCurrentMp() / player.getMaxMp()) * 100 > val)
+ return;
+ break;
+ }
+ }
+ }
+
+ if (!player.destroyItemByItemId("auto potion use", itemId, 1, null, true))
+ {
+ player.stopAutoPotion(itemId);
+ player.sendMessage("Incorrect item count.");
+ return;
+ }
+
+ if (player.getInventory().getItemByItemId(itemId) == null)
+ {
+ player.stopAutoPotion(itemId);
+ return;
+ }
+ IntIntHolder[] skills = player.getInventory().getItemByItemId(itemId).getEtcItem().getSkills();
+ if (skills == null)
+ return;
+
+ for (IntIntHolder skill : skills)
+ {
+ if (skill == null)
+ continue;
+
+ L2Skill sk = skill.getSkill();
+ if (sk == null)
+ continue;
+
+ player.doSimultaneousCast(sk);
+ }
+ }
+
+ public int getItemId()
+ {
+ return itemId;
+ }
+ }

Index: net.sf.l2j.gameserver.model.actor;player.java
===================================================================
--- net.sf.l2j.gameserver.model.actor;player.java (revision 84)
+++ net.sf.l2j.gameserver.model.actor;player.java (working copy)


- import net.sf.l2j.gameserver.geoengine.GeoEngine;
+ import net.sf.l2j.gameserver.geoengine.GeoEngine;
+ import l2jban.autopotion.AutoPotionTask;


+ private Map<AutoPotionTask, ScheduledFuture<?>> autoPotionTasks = new HashMap<>();

+ public void stopAutoPotion(int itemId)
+ {
+ AutoPotionTask temp = null;
+ for (AutoPotionTask atp : autoPotionTasks.keySet())
+ {
+ if (atp.getItemId() == itemId)
+ {
+ temp = atp;
+ break;
+ }
+ }
+
+ if (temp == null)
+ return;
+
+ autoPotionTasks.get(temp).cancel(true);
+ autoPotionTasks.remove(temp);
+ sendPacket(new ExAutoSoulShot(itemId, 0));
+ sendMessage("The automatic use of "+ItemTable.getInstance().getTemplate(itemId).getName()+" has been deactivated.");
+ }
+
+ public void startAutoPotion(int itemId)
+ {
+ for (AutoPotionTask atp : autoPotionTasks.keySet())
+ if (atp.getItemId() == itemId)
+ return;
+
+ AutoPotionTask atp = new AutoPotionTask(itemId, this);
+ autoPotionTasks.put(atp, ThreadPool.scheduleAtFixedRate(atp, Config.AUTO_POTIONS.get(itemId)*1000, Config.AUTO_POTIONS.get(itemId)*1000));
+ sendPacket(new ExAutoSoulShot(itemId, 1));
+ sendMessage("You have activated the automatic use of "+ItemTable.getInstance().getTemplate(itemId).getName()+".");
+ }

Index: config/players.propertis
===================================================================
--- config/players.propertis (revision 84)
+++ config/players.propertis (working copy)

+ # Auto potions ids
+ # The ids of the potions you type here will be activated to be auto with right click.
+ # Use like: itemId,seconds;itemId,seconds
+ # Seconds represents every x seconds a potion will be added when auto is activated
+ AutoPotions = 6539,1;6540,1
+ # Percentage (%) limitations.
+ # Use like: itemId,type,%;itemId,type,%
+ # For example, if you want mana potions to be used if MP is less than 80%, add 728,MP,80
+ # If you don't add a limitation for a type of potion(for example cp potion), it will be used even if cp is fully restored.
+ AutoPotionsLimits = 6539,MP,75;6540,CP,95
 

Сверху Снизу