Jump to content

Question

Posted

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

  • 0
Posted (edited)

there is a piece in united-extreme forum that says about this

i hope it gives you a clue  cause im not really good at core java design

plus i could find a dirty way to make it work as example of mortal blow playsound i did b4

Inside L2PcInstace.java, you need to specify what the "isAutoPot" value is and of course its default state.

 

private boolean isAutoPot = False;

 

 

yours is 

 public boolean isAutoPot(int id)


i dont get it know this i started to hate java when learning about private and public shits  lol

******


on the other hand

why you cannot just make item mana potion operation type toggle 
and edit the item skill for consume on % mana drop  

 

Edited by etherian
  • 0
Posted

i changed to private and error :) so the problem is it doesnt really do something ingame not even the sendmessages so i assume its something with map/future task / threadpool

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Posts

    • I am selling my l2jeternity high five (all inclusive option $300) license+daily $50(mission) mod, autofarm, this is a very good and stable H5 assembly on market if you know how to run it properly, project developer LordWinter also a very passionate person and active in daily basis, because I am no longer using it, selling this out to put in good use for new h5 l2project. I am selling this for $180, pm me for details/offer. thanks *Sale and rebinding with the consent of the developer LordWinter payment option : paypal/crypto telegram: @arcadin77  
    • Hello friends, good morning, good afternoon or good evening, depending on the time you are seeing this! I have been trying to decompile and compile again with only the classes that I want LineageEffect.u for a few days now, but I have not been successful. Could someone help me by clearing up some doubts about how I can do this work and be successful?!
    • **INTERLUDE REMASTERED** Moonland is a server that's been running for about three years without wipe, and they don't plan on wiping it anytime soon. I'm selling my items or even the account due to not having much time to play anymore. I'm selling only for $$$. Not going to disclose my nickname in the server, but here are some of the items: Lvl 5 equipment for both mage and fighter +100 mage pvp set 2mastery jewels for fighter, 2 for mage, blessed antharas, blessed queen ant, ring of fallen angel, earring of fafurion. 1k + col, VIP cosmetics for armor, agathion and weapons(duals + mage wep)   I'm only selling for real money via paypal or cs2 skins so don't offer me anything else.
    • ➡ Discount for your purchase: MAY2025 (10% discount) ➡ Our Online Shop: https://socnet.store  ➡ Our SMM-Boosting Panel: https://socnet.pro  ➡ Telegram Shop Bot: https://socnet.shop  ➡ Telegram Support: https://t.me/solomon_bog  ➡ Telegram Channel: https://t.me/accsforyou_shop  ➡ Discord Support: @AllSocialNetworksShop  ➡ Discord Server: https://discord.gg/y9AStFFsrh  ➡ WhatsApp Support: https://wa.me/79051904467 ➡ WhatsApp Channel: https://whatsapp.com/channel/0029Vau0CMX002TGkD4uHa2n  ➡ Email Support: solomonbog@socnet.store 
  • Topics

×
×
  • Create New...