This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..
Question
HowardStern
Hello! So i adapted devlins code for l2jfrozen
if (itemId == 728 || itemId == 1539 || itemId == 5592) { switch (itemId) { case 728: // mana potion { if (activeChar.isAutoPot(728)) { activeChar.sendPacket(new ExAutoSoulShot(728, 0)); activeChar.sendMessage("Deactivated auto mana potions."); activeChar.setAutoPot(728, null, false); } else { if (activeChar.getInventory().getItemByItemId(728) != null) { if (activeChar.getInventory().getItemByItemId(728).getCount() > 1) { activeChar.sendPacket(new ExAutoSoulShot(728, 1)); activeChar.sendMessage("Activated auto mana potions."); activeChar.setAutoPot(728, ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new AutoPot(728, activeChar), 1000, MANA_POT_CD*1000), true); } else { MagicSkillUser msu = new MagicSkillUser(activeChar, activeChar, 2279, 2, 0, 100); activeChar.broadcastPacket(msu); Potions is = new Potions(); is.useItem(activeChar, activeChar.getInventory().getItemByItemId(728)); } } } break; } case 1539: // greater healing potion { if (activeChar.isAutoPot(1539)) { activeChar.sendPacket(new ExAutoSoulShot(1539, 0)); activeChar.sendMessage("Deactivated auto healing potions."); activeChar.setAutoPot(1539, null, false); } else { if (activeChar.getInventory().getItemByItemId(1539) != null) { if (activeChar.getInventory().getItemByItemId(1539).getCount() > 1) { activeChar.sendPacket(new ExAutoSoulShot(1539, 1)); activeChar.sendMessage("Activated auto healing potions."); activeChar.setAutoPot(1539, ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new AutoPot(1539, activeChar), 1000, HEALING_POT_CD*1000), true); } else { MagicSkillUser msu = new MagicSkillUser(activeChar, activeChar, 2037, 1, 0, 100); activeChar.broadcastPacket(msu); Potions is = new Potions(); is.useItem(activeChar, activeChar.getInventory().getItemByItemId(1539)); } } } break; } case 5592: // greater cp potion { if (activeChar.isAutoPot(5592)) { activeChar.sendPacket(new ExAutoSoulShot(5592, 0)); activeChar.sendMessage("Deactivated auto cp potions."); activeChar.setAutoPot(5592, null, false); } else { if (activeChar.getInventory().getItemByItemId(5592) != null) { if (activeChar.getInventory().getItemByItemId(5592).getCount() > 1) { activeChar.sendPacket(new ExAutoSoulShot(5592, 1)); activeChar.sendMessage("Activated auto cp potions."); activeChar.setAutoPot(5592, ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new AutoPot(5592, activeChar), 1000, CP_POT_CD*1000), true); } else { MagicSkillUser msu = new MagicSkillUser(activeChar, activeChar, 2166, 2, 0, 100); activeChar.broadcastPacket(msu); Potions is = new Potions(); is.useItem(activeChar, activeChar.getInventory().getItemByItemId(5592)); } } } break; } } return; }part 2 of soulshots.java
private class AutoPot implements Runnable { private int id; private L2PcInstance activeChar; public AutoPot(int id, L2PcInstance activeChar) { this.id = id; this.activeChar = activeChar; } @Override public void run() { if (activeChar.getInventory().getItemByItemId(id) == null) { activeChar.sendPacket(new ExAutoSoulShot(id, 0)); activeChar.setAutoPot(id, null, false); return; } switch (id) { case 728: { if (activeChar.getCurrentMp() < 0.70*activeChar.getMaxMp()) { MagicSkillUser msu = new MagicSkillUser(activeChar, activeChar, 2279, 2, 0, 100); activeChar.broadcastPacket(msu); Potions is = new Potions(); is.useItem(activeChar, activeChar.getInventory().getItemByItemId(728)); } break; } case 1539: { if (activeChar.getCurrentHp() < 0.95*activeChar.getMaxHp()) { MagicSkillUser msu = new MagicSkillUser(activeChar, activeChar, 2037, 1, 0, 100); activeChar.broadcastPacket(msu); Potions is = new Potions(); is.useItem(activeChar, activeChar.getInventory().getItemByItemId(1539)); } break; } case 5592: { if (activeChar.getCurrentCp() < 0.95*activeChar.getMaxCp()) { MagicSkillUser msu = new MagicSkillUser(activeChar, activeChar, 2166, 2, 0, 100); activeChar.broadcastPacket(msu); Potions is = new Potions(); is.useItem(activeChar, activeChar.getInventory().getItemByItemId(5592)); } break; } } if (activeChar.getInventory().getItemByItemId(id) == null) { activeChar.sendPacket(new ExAutoSoulShot(id, 0)); activeChar.setAutoPot(id, null, false); } } }Now L2PcInstance
private HashMap<Integer, Future<?>> _autoPotTasks = new HashMap<>(); public boolean isAutoPot(int id) { return _autoPotTasks.keySet().contains(id); } public void setAutoPot(int id, Future<?> task, boolean add) { if (add) _autoPotTasks.put(id, task); else { _autoPotTasks.get(id).cancel(true); _autoPotTasks.remove(id); } }and part 2
// Add karma to attacker and increase its PK counter setPvpKills(getPvpKills() + 1); if (isAutoPot(728)) { sendPacket(new ExAutoSoulShot(728, 0)); setAutoPot(728, null, false); } if (isAutoPot(1539)) { sendPacket(new ExAutoSoulShot(1539, 0)); setAutoPot(1539, null, false); } if (isAutoPot(5592)) { sendPacket(new ExAutoSoulShot(5592, 0)); setAutoPot(5592, null, false); }i am stuck why it doesnt work?
mana is type shot on skill i removed the isPotion=true.. what i am doing wrong???
it is seems that the threadpooltask never run because i do not even get the message ingame
2 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now