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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Posts

    • Vouch for @Ave i can say im very statisfied with the order I've made he was fast and reliable i totally recommend him to anyone who wants a decent updater with high quality design.
    • What can I say other than that I’m satisfied with the order I made. The guy is reliable and very good at what he does. I recommend him 100%.
    • Lineage2 Freya High Five @ Reshade with fog and rain etc @ Gracia final epilogue atmosphere   this reshade will eat lots of GPU power 50% or more of an RTX 3060 so be carefull depending on what effects are activated and their settings will eat even more GPU recomended 60hz monitor settings and via nvidia panel in Lineage2 game profile vsync settings to on effects are set up till film deck and the rest are not used but still working again this can eat alot of GPU Don't overheat GPU this is for freya high five but might work on others too copy in the  System  folder the folder  reshade-shaders  and the files  d3d9.dll  ReShade.ini  ReShadePreset.ini  ReShade.log  CccDddCcc.ini insert opens the menu and delete is on and of some settings need  ctrl + left click  to be changed   making another profile will reset the not activated effects to their default values so just copy the profile  CccDddCcc  and rename if needed also something needs to be closed from settings in game menu, the blur at distance and advanced shaders but keeping the advanced water effects all reflections   for those that don't like the h5 look of the sky and the red fog and rain and ambien red at night on all maps well if we want the cool gracia final epilogue back then we need to do this rename the  Maps  folder to Mapsretail or whatever copy the  Maps  folder from gracia final epilogue to h5 also we need the  L2_Skies.utx  from gracia final epilogue  Textures  folder to be replaced and also we need to do the same to the files  timeenv0.int  timeenv1.int  timeenv2.int  timeenv3.int  found in  system  folder   another setting that will probably be needed but not really tested out is to open file  option.ini  from  system  folder and add cachesize like this   [FirstRun] FirstRun=2   [Engine.GameEngine] CacheSizeMegs=512   also maybe is good to change those to 4.000000   [ClippingRange] Terrain=4.000000 Actor=4.000000 StaticMesh=4.000000 StaticMeshLod=4.000000 Pawn=4.000000       sorry bad english   https://mega.nz/file/aRNXxDrQ#mbxrNERBtW0XEEezK6w8-86oZWuX1k6NgtR6RZWKRVM   the compression on the video is kinda bad but meh    
  • Topics

×
×
  • Create New...

Important Information

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..