Page 1 of 1

Olympiads Count down time for Restoring CP/HP/MP

Posted: Mon Jun 20, 2011 11:09 pm
by Iruel
If you want to receive support we need this info to help you properly.
» Find Revision
L2J Revision Number: 4654
L2JDP Revision Number: 8046

Greetings,

I would gladly creat this topic on another section but I failed cause of my post number count. Anyway,

Once players get inside olympiads, they got 60 seconds to buff up and, at least on my l2j server version, I am having full CP/HP/MP restoration on the moment I port (60s) while it should only be restored, those status, at 50s. This is how retail olympiad restoration count down works. I do not intend to make a point on this, I just would like to have some information on how to get to that time. Any idea would be highly appreciated.

Re: Olympiads Count down time for Restoring CP/HP/MP

Posted: Wed Jun 22, 2011 2:55 pm
by BiggBoss
remove restoration from teleport and scheduled it in 10 seconds

Code: Select all

 Index: java/com/l2jserver/gameserver/model/olympiad/AbstractOlympiadGame.java===================================================================--- java/com/l2jserver/gameserver/model/olympiad/AbstractOlympiadGame.java  (revision 4684)+++ java/com/l2jserver/gameserver/model/olympiad/AbstractOlympiadGame.java  (working copy)@@ -220,6 +220,10 @@            player.setCurrentHp(player.getMaxHp());            player.setCurrentMp(player.getMaxMp());            +           Thread restoreThread = new Thread(new RestoreStats(player));+           restoreThread.setPriority(7);+           restoreThread.start();+                       // Remove Summon's Buffs            final L2Summon summon = player.getPet();            if (summon != null)@@ -407,6 +411,36 @@            _log.log(Level.WARNING, e.getMessage(), e);        }    }+   +   private static class RestoreStats implements Runnable+   {+       private L2PcInstance _plr;+       +       private RestoreStats(L2PcInstance p)+       {+           _plr = p;+       }+       +       @Override+       public void run()+       {+           try+           {+               Thread.sleep(10000);+           }+           catch(InterruptedException ie)+           {+               ie.printStackTrace();+           }+           +           if(_plr.isInOlympiadMode())+           {+               _plr.setCurrentCp(_plr.getMaxCp());+               _plr.setCurrentHp(_plr.getMaxHp());+               _plr.setCurrentMp(_plr.getMaxMp());+           }+       }+   }     public abstract CompetitionType getType();  

Re: Olympiads Count down time for Restoring CP/HP/MP

Posted: Wed Jun 22, 2011 9:46 pm
by Iruel
Thank you very much BiggBoss!

Cheers.

Re: Olympiads Count down time for Restoring CP/HP/MP

Posted: Wed Jun 22, 2011 11:21 pm
by JIV
why not use threadpool? maybe its after appearance packet?

Re: Olympiads Count down time for Restoring CP/HP/MP

Posted: Thu Jun 23, 2011 9:51 am
by BiggBoss
its a trivial task (also, the restoration could be done in catch clause to ensure its done), so i though not to pass it to the threadpool

Re: Olympiads Count down time for Restoring CP/HP/MP

Posted: Thu Jun 23, 2011 11:32 am
by JIV
so you saying create whole new thread each port to arena is much more efficient for task which execution is 1ms?

Re: Olympiads Count down time for Restoring CP/HP/MP

Posted: Thu Jun 23, 2011 11:35 am
by BiggBoss
i never said anything about efficiency, but i dont see the point to let it sleep in the pool

Re: Olympiads Count down time for Restoring CP/HP/MP

Posted: Thu Jun 23, 2011 11:45 am
by JIV
true, that would be bad of course but you can use in such case:

Code: Select all

com.l2jserver.gameserver.ThreadPoolManager.scheduleGeneral(Runnable, long)

Re: Olympiads Count down time for Restoring CP/HP/MP

Posted: Thu Jun 23, 2011 11:47 am
by BiggBoss
lol, i didnt mean to sleep the thread in the thread pool, but to pass the task to it