Advertisement
tensador125

L2BufferRadius style GOD with levels l2jorion

Apr 26th, 2022
596
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 8.04 KB | None | 0 0
  1. /* l2jterius Project - www.l2jterius.com
  2.  *
  3.  * This program is free software; you can redistribute it and/or modify
  4.  * it under the terms of the GNU General Public License as published by
  5.  * the Free Software Foundation; either version 2, or (at your option)
  6.  * any later version.
  7.  *
  8.  * This program is distributed in the hope that it will be useful,
  9.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11.  * GNU General Public License for more details.
  12.  *
  13.  * You should have received a copy of the GNU General Public License
  14.  * along with this program; if not, write to the Free Software
  15.  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  16.  * 02111-1307, USA.
  17.  *
  18.  * http://www.gnu.org/copyleft/gpl.html
  19.  */
  20. package l2jorion.game.model.actor.instance;
  21.  
  22. import java.util.concurrent.ScheduledFuture;
  23.  
  24. import l2jorion.Config;
  25. import l2jorion.game.datatables.SkillTable;
  26. import l2jorion.game.model.L2Skill;
  27. import l2jorion.game.network.serverpackets.MagicSkillUser;
  28. import l2jorion.game.network.serverpackets.NpcHtmlMessage;
  29. import l2jorion.game.skills.SkillHolder;
  30. import l2jorion.game.templates.L2NpcTemplate;
  31. import l2jorion.game.thread.ThreadPoolManager;
  32.  
  33. /**
  34.  * @author Tensador125
  35.  */
  36. public class L2TeriusBuffInstance extends L2NpcInstance
  37. {
  38.     private ScheduledFuture<?> _aiTask;
  39.    
  40.     public void showMainWindow(L2PcInstance player)
  41.     {
  42.        
  43.         NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
  44.         html.setFile("data/html/mods/TeriusBuff.htm");
  45.         html.replace("%objectId%", String.valueOf(getObjectId()));
  46.         html.replace("%npcname%", getName());
  47.         player.sendPacket(html);
  48.     }
  49.    
  50.     private class TeriusAI implements Runnable
  51.     {
  52.         private final L2TeriusBuffInstance _caster;
  53.        
  54.         protected TeriusAI(final L2TeriusBuffInstance caster)
  55.         {
  56.             _caster = caster;
  57.         }
  58.        
  59.         private final SkillHolder[] FIGHTER_BUFFS =
  60.         {
  61.             new SkillHolder(4322, 1),
  62.             new SkillHolder(4323, 1),
  63.             new SkillHolder(4324, 1),
  64.             new SkillHolder(4325, 1),
  65.             new SkillHolder(4326, 1),
  66.             new SkillHolder(4327, 1),
  67.         };
  68.         private final SkillHolder[] FIGHTER_BUFFS_LVL40 =
  69.         {
  70.             new SkillHolder(1204, 2),
  71.             new SkillHolder(1035, 3),
  72.             new SkillHolder(1036, 2),
  73.             new SkillHolder(1040, 3),
  74.             new SkillHolder(1045, 6),
  75.             new SkillHolder(1048, 6),
  76.             new SkillHolder(1068, 3),
  77.             new SkillHolder(1077, 3),
  78.             new SkillHolder(1086, 2),
  79.             new SkillHolder(1268, 3),
  80.             new SkillHolder(271, 1),
  81.             new SkillHolder(274, 1),
  82.             new SkillHolder(275, 1),
  83.             new SkillHolder(310, 1),
  84.             new SkillHolder(264, 1),
  85.             new SkillHolder(267, 1),
  86.             new SkillHolder(269, 1),
  87.             new SkillHolder(304, 1),
  88.             new SkillHolder(364, 1),
  89.             new SkillHolder(268, 1),
  90.             new SkillHolder(349, 1),
  91.             new SkillHolder(1242, 3),
  92.             new SkillHolder(1363, 1),
  93.             new SkillHolder(1388, 3),
  94.         };
  95.         private final SkillHolder[] FIGHTER_BUFFS_LVL76 =
  96.         {
  97.             new SkillHolder(1040, 3),
  98.             new SkillHolder(1036, 2),
  99.             new SkillHolder(1045, 6),
  100.             new SkillHolder(1068, 3),
  101.             new SkillHolder(1035, 4),
  102.             new SkillHolder(1240, 3),
  103.             new SkillHolder(1242, 3),
  104.             new SkillHolder(1077, 3),
  105.             new SkillHolder(1086, 2),
  106.             new SkillHolder(1204, 2),
  107.             new SkillHolder(1268, 4),
  108.             new SkillHolder(264, 1),
  109.             new SkillHolder(266, 1),
  110.             new SkillHolder(267, 1),
  111.             new SkillHolder(268, 1),
  112.             new SkillHolder(269, 1),
  113.             new SkillHolder(304, 1),
  114.             new SkillHolder(306, 1),
  115.             new SkillHolder(308, 1),
  116.             new SkillHolder(270, 1),
  117.             new SkillHolder(364, 1),
  118.             new SkillHolder(274, 1),
  119.             new SkillHolder(275, 1),
  120.             new SkillHolder(271, 1),
  121.             new SkillHolder(309, 1),
  122.             new SkillHolder(307, 1),
  123.             new SkillHolder(272, 1),
  124.             new SkillHolder(310, 1),
  125.             new SkillHolder(1363, 1),
  126.             new SkillHolder(1388, 3),
  127.             new SkillHolder(4700, 13),
  128.         };
  129.         private final SkillHolder[] MAGE_BUFFS =
  130.         {
  131.             new SkillHolder(4322, 1),
  132.             new SkillHolder(4323, 1),
  133.             new SkillHolder(4328, 1),
  134.             new SkillHolder(4329, 1),
  135.             new SkillHolder(4330, 1),
  136.             new SkillHolder(4331, 1),
  137.         };
  138.         private final SkillHolder[] MAGE_BUFFS_LVL40 =
  139.         {
  140.             new SkillHolder(1204, 2),
  141.             new SkillHolder(1035, 3),
  142.             new SkillHolder(1036, 2),
  143.             new SkillHolder(1040, 3),
  144.             new SkillHolder(1045, 6),
  145.             new SkillHolder(1048, 6),
  146.             new SkillHolder(1078, 6),
  147.             new SkillHolder(1085, 3),
  148.             new SkillHolder(1062, 2),
  149.             new SkillHolder(1059, 3),
  150.             new SkillHolder(273, 1),
  151.             new SkillHolder(276, 1),
  152.             new SkillHolder(365, 1),
  153.             new SkillHolder(264, 1),
  154.             new SkillHolder(268, 1),
  155.             new SkillHolder(304, 1),
  156.             new SkillHolder(267, 1),
  157.             new SkillHolder(349, 1),
  158.             new SkillHolder(1389, 3),
  159.             new SkillHolder(1413, 1),
  160.             new SkillHolder(1303, 2),
  161.         };
  162.         private final SkillHolder[] MAGE_BUFFS_LVL76 =
  163.         {
  164.             new SkillHolder(1040, 3),
  165.             new SkillHolder(1036, 2),
  166.             new SkillHolder(1045, 6),
  167.             new SkillHolder(1048, 6),
  168.             new SkillHolder(1062, 2),
  169.             new SkillHolder(1035, 4),
  170.             new SkillHolder(1085, 3),
  171.             new SkillHolder(1078, 6),
  172.             new SkillHolder(1243, 6),
  173.             new SkillHolder(1204, 2),
  174.             new SkillHolder(1303, 2),
  175.             new SkillHolder(1259, 4),
  176.             new SkillHolder(1059, 3),
  177.             new SkillHolder(266, 1),
  178.             new SkillHolder(264, 1),
  179.             new SkillHolder(267, 1),
  180.             new SkillHolder(306, 1),
  181.             new SkillHolder(308, 1),
  182.             new SkillHolder(270, 1),
  183.             new SkillHolder(268, 1),
  184.             new SkillHolder(304, 1),
  185.             new SkillHolder(273, 1),
  186.             new SkillHolder(307, 1),
  187.             new SkillHolder(276, 1),
  188.             new SkillHolder(349, 1),
  189.             new SkillHolder(277, 1),
  190.             new SkillHolder(365, 1),
  191.             new SkillHolder(304, 1),
  192.             new SkillHolder(1413, 1),
  193.             new SkillHolder(1389, 3),
  194.             new SkillHolder(4703, 13),
  195.         };
  196.        
  197.         @Override
  198.         public void run()
  199.         {
  200.             for (final L2PcInstance player : getKnownList().getKnownPlayers().values())
  201.             {
  202.                
  203.                 if (player.isMageClass() && player.getLevel() < 40)
  204.                 {
  205.                     for (SkillHolder skills : MAGE_BUFFS)
  206.                     {
  207.                         TeriusCast(player, skills.getSkill());
  208.                     }
  209.                    
  210.                 }
  211.                 if (!player.isMageClass() && player.getLevel() < 40)
  212.                 {
  213.                     for (SkillHolder skills : FIGHTER_BUFFS)
  214.                     {
  215.                         TeriusCast(player, skills.getSkill());
  216.                     }
  217.                 }
  218.                 if (player.isMageClass() && player.getLevel() >= 40 && player.getLevel() < 76)
  219.                 {
  220.                     for (SkillHolder skills : MAGE_BUFFS_LVL40)
  221.                     {
  222.                         TeriusCast(player, skills.getSkill());
  223.                     }
  224.                 }
  225.                 if (!player.isMageClass() && player.getLevel() >= 40 && player.getLevel() < 76)
  226.                 {
  227.                     for (SkillHolder skills : FIGHTER_BUFFS_LVL40)
  228.                     {
  229.                         TeriusCast(player, skills.getSkill());
  230.                     }
  231.                 }
  232.                 if (player.isMageClass() && player.getLevel() >= 76)
  233.                 {
  234.                     for (SkillHolder skills : MAGE_BUFFS_LVL76)
  235.                     {
  236.                         TeriusCast(player, skills.getSkill());
  237.                     }
  238.                 }
  239.                 if (!player.isMageClass() && player.getLevel() >= 76)
  240.                 {
  241.                     for (SkillHolder skills : FIGHTER_BUFFS_LVL76)
  242.                     {
  243.                         TeriusCast(player, skills.getSkill());
  244.                     }
  245.                 }
  246.                
  247.             }
  248.         }
  249.        
  250.         private boolean TeriusCast(final L2PcInstance player, L2Skill skill)
  251.         {
  252.             if (player.isDead() || !player.isVisible() || !isInsideRadius(player, Config.RADIO_BUFFER, false, false))
  253.             {
  254.                 return false;
  255.             }
  256.            
  257.             if (player.getFirstEffect(skill) == null)
  258.             {
  259.                 heal(player);
  260.                 SkillTable.getInstance().getInfo(skill.getId(), skill.getLevel()).getEffects(player, player);
  261.                 skill.getEffects(_caster, player, false, false, false);
  262.                 broadcastPacket(new MagicSkillUser(_caster, player, skill.getId(), skill.getLevel(), 1000, 0));
  263.                
  264.                 return true;
  265.             }
  266.            
  267.             return false;
  268.         }
  269.     }
  270.    
  271.     static void heal(L2PcInstance activeChar)
  272.     {
  273.         activeChar.setCurrentHp(activeChar.getMaxHp());
  274.         activeChar.setCurrentCp(activeChar.getMaxCp());
  275.         activeChar.setCurrentMp(activeChar.getMaxMp());
  276.     }
  277.    
  278.     public L2TeriusBuffInstance(final int objectId, final L2NpcTemplate template)
  279.     {
  280.         super(objectId, template);
  281.        
  282.         if (_aiTask != null)
  283.         {
  284.             _aiTask.cancel(true);
  285.         }
  286.        
  287.         _aiTask = ThreadPoolManager.getInstance().scheduleAiAtFixedRate(new TeriusAI(this), 3000, 3000);
  288.     }
  289.    
  290. }
  291.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement