Advertisement
tensador125

L2J BUFFER STYLE GOD L2JFROZEN

Apr 16th, 2023 (edited)
1,023
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 7.86 KB | Gaming | 0 0
  1. /* l2jfrozen Project - www.l2jfrozen.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 com.l2jfrozen.gameserver.model.actor.instance;
  21.  
  22. import java.util.concurrent.ScheduledFuture;
  23.  
  24. import com.l2jfrozen.Config;
  25. import com.l2jfrozen.gameserver.ai.CtrlIntention;
  26. import com.l2jfrozen.gameserver.datatables.SkillTable;
  27. import com.l2jfrozen.gameserver.model.L2Skill;
  28. import com.l2jfrozen.gameserver.model.base.ClassId;
  29. import com.l2jfrozen.gameserver.network.serverpackets.ActionFailed;
  30. import com.l2jfrozen.gameserver.network.serverpackets.MagicSkillUser;
  31. import com.l2jfrozen.gameserver.network.serverpackets.MoveToPawn;
  32. import com.l2jfrozen.gameserver.network.serverpackets.MyTargetSelected;
  33. import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage;
  34. import com.l2jfrozen.gameserver.network.serverpackets.ValidateLocation;
  35. import com.l2jfrozen.gameserver.skills.SkillHolder;
  36. import com.l2jfrozen.gameserver.templates.L2NpcTemplate;
  37. import com.l2jfrozen.gameserver.thread.ThreadPoolManager;
  38.  
  39. /**
  40.  * @author terius
  41.  */
  42. public class L2TeriusBuffInstance extends L2NpcInstance
  43. {
  44.     private ScheduledFuture<?> _aiTask;
  45.    
  46.     @Override
  47.     public void onAction(L2PcInstance player)
  48.     {
  49.         if (this != player.getTarget())
  50.         {
  51.             player.setTarget(this);
  52.             player.sendPacket(new MyTargetSelected(getObjectId(), 0));
  53.             player.sendPacket(new ValidateLocation(this));
  54.         }
  55.         else
  56.         {
  57.             if (!canInteract(player))
  58.                 player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, this);
  59.             else
  60.             {
  61.                 // Rotate the player to face the instance
  62.                 player.sendPacket(new MoveToPawn(player, this, L2NpcInstance.INTERACTION_DISTANCE));
  63.                
  64.                 if (hasRandomAnimation())
  65.                     onRandomAnimation();
  66.                
  67.                 showMainWindow(player);
  68.                
  69.                 // Send ActionFailed to the player in order to avoid he stucks
  70.                 player.sendPacket(ActionFailed.STATIC_PACKET);
  71.             }
  72.         }
  73.     }
  74.    
  75.     private void showMainWindow(L2PcInstance player)
  76.     {
  77.        
  78.         NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
  79.         html.setFile("data/html/mods/TeriusBuff.htm");
  80.         html.replace("%objectId%", String.valueOf(getObjectId()));
  81.         html.replace("%npcname%", getName());
  82.         player.sendPacket(html);
  83.     }  
  84.    
  85.     private class TeriusAI implements Runnable
  86.     {
  87.         private final L2TeriusBuffInstance _caster;
  88.        
  89.         protected TeriusAI(final L2TeriusBuffInstance caster)
  90.         {
  91.             _caster = caster;
  92.         }
  93.        
  94.         private final SkillHolder[] FIGHTER_BUFFS =
  95.         {
  96.             new SkillHolder(1352, 1),
  97.             new SkillHolder(1353, 1),
  98.             new SkillHolder(1415, 1),
  99.             new SkillHolder(1393, 3),
  100.             new SkillHolder(1392, 3),
  101.             new SkillHolder(1191, 3),
  102.             new SkillHolder(1189, 3),
  103.             new SkillHolder(1182, 3),
  104.             new SkillHolder(1392, 3),
  105.             new SkillHolder(1040, 3),
  106.             new SkillHolder(1036, 2),
  107.             new SkillHolder(1062, 2),
  108.             new SkillHolder(1045, 6),
  109.             new SkillHolder(1068, 3),
  110.             new SkillHolder(1035, 4),
  111.             new SkillHolder(1240, 3),
  112.             new SkillHolder(1242, 3),
  113.             new SkillHolder(1077, 3),
  114.             new SkillHolder(1086, 2),
  115.             new SkillHolder(1204, 2),
  116.             new SkillHolder(1268, 4),
  117.             new SkillHolder(264, 1),
  118.             new SkillHolder(266, 1),
  119.             new SkillHolder(267, 1),
  120.             new SkillHolder(268, 1),
  121.             new SkillHolder(269, 1),
  122.             new SkillHolder(304, 1),
  123.             new SkillHolder(306, 1),
  124.             new SkillHolder(308, 1),
  125.             new SkillHolder(270, 1),
  126.             new SkillHolder(364, 1),
  127.             new SkillHolder(274, 1),
  128.             new SkillHolder(275, 1),
  129.             new SkillHolder(271, 1),
  130.             new SkillHolder(309, 1),
  131.             new SkillHolder(307, 1),
  132.             new SkillHolder(272, 1),
  133.             new SkillHolder(310, 1),
  134.             new SkillHolder(1363, 1),
  135.             new SkillHolder(1388, 3),
  136.             new SkillHolder(4700, 13),
  137.             new SkillHolder(1323, 1),
  138.         };
  139.         private final SkillHolder[] MAGE_BUFFS =
  140.         {
  141.             new SkillHolder(1352, 1),
  142.             new SkillHolder(1353, 1),
  143.             new SkillHolder(1415, 1),
  144.             new SkillHolder(1393, 3),
  145.             new SkillHolder(1392, 3),
  146.             new SkillHolder(1191, 3),
  147.             new SkillHolder(1189, 3),
  148.             new SkillHolder(1182, 3),
  149.             new SkillHolder(1392, 3),
  150.             new SkillHolder(1040, 3),
  151.             new SkillHolder(1036, 2),
  152.             new SkillHolder(1045, 6),
  153.             new SkillHolder(1048, 6),
  154.             new SkillHolder(1062, 2),
  155.             new SkillHolder(1035, 4),
  156.             new SkillHolder(1085, 3),
  157.             new SkillHolder(1078, 6),
  158.             new SkillHolder(1304, 3),
  159.             new SkillHolder(1243, 6),
  160.             new SkillHolder(1204, 2),
  161.             new SkillHolder(1303, 2),
  162.             new SkillHolder(1259, 4),
  163.             new SkillHolder(1059, 3),
  164.             new SkillHolder(266, 1),
  165.             new SkillHolder(264, 1),
  166.             new SkillHolder(267, 1),
  167.             new SkillHolder(306, 1),
  168.             new SkillHolder(308, 1),
  169.             new SkillHolder(270, 1),
  170.             new SkillHolder(268, 1),
  171.             new SkillHolder(304, 1),
  172.             new SkillHolder(273, 1),
  173.             new SkillHolder(307, 1),
  174.             new SkillHolder(276, 1),
  175.             new SkillHolder(349, 1),
  176.             new SkillHolder(277, 1),
  177.             new SkillHolder(365, 1),
  178.             new SkillHolder(304, 1),
  179.             new SkillHolder(1413, 1),
  180.             new SkillHolder(1389, 3),
  181.             new SkillHolder(4702, 13),
  182.             new SkillHolder(1323, 1),
  183.         };
  184.        
  185.         @Override
  186.         public void run()
  187.         {
  188.             for (final L2PcInstance player : getKnownList().getKnownPlayers().values())
  189.             {          
  190.                
  191.                 if (player.isMageClass() && (player.getClassId() != ClassId.overlord) && (player.getClassId() != ClassId.warcryer))
  192.                 {
  193.                     for (SkillHolder skills : MAGE_BUFFS)
  194.                     {
  195.                         TeriusCast(player, skills.getSkill());
  196.                     }
  197.  
  198.                 }else
  199.                     for (SkillHolder skills : FIGHTER_BUFFS)
  200.                     {
  201.                         TeriusCast(player, skills.getSkill());
  202.                     }
  203.  
  204.             }
  205.         }  
  206.        
  207.     private boolean TeriusCast(final L2PcInstance player,L2Skill skill)
  208.         {
  209.             if (player.isDead() || !player.isVisible() || !isInsideRadius(player, 200, false, false))
  210.                 return false;
  211.            
  212.             if (player.getFirstEffect(skill) == null)
  213.             {
  214.                 heal(player);
  215.                 SkillTable.getInstance().getInfo(skill.getId(), skill.getLevel()).getEffects(player, player);
  216.                 skill.getEffects(_caster, player, false, false, false);
  217.                 broadcastPacket(new MagicSkillUser(_caster, player, skill.getId(), skill.getLevel(), Config.PROTECTOR_SKILLTIME, 0));
  218.  
  219.                 return true;
  220.             }
  221.            
  222.             return false;
  223.         }
  224.     }
  225.    
  226.     static void heal(L2PcInstance activeChar)
  227.     {
  228.         activeChar.setCurrentHp(activeChar.getMaxHp());
  229.         activeChar.setCurrentCp(activeChar.getMaxCp());
  230.         activeChar.setCurrentMp(activeChar.getMaxMp());
  231.     }  
  232.    
  233.     public L2TeriusBuffInstance(final int objectId, final L2NpcTemplate template)
  234.     {
  235.         super(objectId, template);
  236.        
  237.         if (_aiTask != null)
  238.         {
  239.             _aiTask.cancel(true);
  240.         }
  241.        
  242.         _aiTask = ThreadPoolManager.getInstance().scheduleAiAtFixedRate(new TeriusAI(this), 3000, 3000);
  243.     }
  244.  
  245. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement