Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* l2jterius Project - www.l2jterius.com
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- *
- * http://www.gnu.org/copyleft/gpl.html
- */
- package l2jorion.game.model.actor.instance;
- import java.util.concurrent.ScheduledFuture;
- import l2jorion.Config;
- import l2jorion.game.datatables.SkillTable;
- import l2jorion.game.model.L2Skill;
- import l2jorion.game.network.serverpackets.MagicSkillUser;
- import l2jorion.game.network.serverpackets.NpcHtmlMessage;
- import l2jorion.game.skills.SkillHolder;
- import l2jorion.game.templates.L2NpcTemplate;
- import l2jorion.game.thread.ThreadPoolManager;
- /**
- * @author Tensador125
- */
- public class L2TeriusBuffInstance extends L2NpcInstance
- {
- private ScheduledFuture<?> _aiTask;
- public void showMainWindow(L2PcInstance player)
- {
- NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
- html.setFile("data/html/mods/TeriusBuff.htm");
- html.replace("%objectId%", String.valueOf(getObjectId()));
- html.replace("%npcname%", getName());
- player.sendPacket(html);
- }
- private class TeriusAI implements Runnable
- {
- private final L2TeriusBuffInstance _caster;
- protected TeriusAI(final L2TeriusBuffInstance caster)
- {
- _caster = caster;
- }
- private final SkillHolder[] FIGHTER_BUFFS =
- {
- new SkillHolder(4322, 1),
- new SkillHolder(4323, 1),
- new SkillHolder(4324, 1),
- new SkillHolder(4325, 1),
- new SkillHolder(4326, 1),
- new SkillHolder(4327, 1),
- };
- private final SkillHolder[] FIGHTER_BUFFS_LVL40 =
- {
- new SkillHolder(1204, 2),
- new SkillHolder(1035, 3),
- new SkillHolder(1036, 2),
- new SkillHolder(1040, 3),
- new SkillHolder(1045, 6),
- new SkillHolder(1048, 6),
- new SkillHolder(1068, 3),
- new SkillHolder(1077, 3),
- new SkillHolder(1086, 2),
- new SkillHolder(1268, 3),
- new SkillHolder(271, 1),
- new SkillHolder(274, 1),
- new SkillHolder(275, 1),
- new SkillHolder(310, 1),
- new SkillHolder(264, 1),
- new SkillHolder(267, 1),
- new SkillHolder(269, 1),
- new SkillHolder(304, 1),
- new SkillHolder(364, 1),
- new SkillHolder(268, 1),
- new SkillHolder(349, 1),
- new SkillHolder(1242, 3),
- new SkillHolder(1363, 1),
- new SkillHolder(1388, 3),
- };
- private final SkillHolder[] FIGHTER_BUFFS_LVL76 =
- {
- new SkillHolder(1040, 3),
- new SkillHolder(1036, 2),
- new SkillHolder(1045, 6),
- new SkillHolder(1068, 3),
- new SkillHolder(1035, 4),
- new SkillHolder(1240, 3),
- new SkillHolder(1242, 3),
- new SkillHolder(1077, 3),
- new SkillHolder(1086, 2),
- new SkillHolder(1204, 2),
- new SkillHolder(1268, 4),
- new SkillHolder(264, 1),
- new SkillHolder(266, 1),
- new SkillHolder(267, 1),
- new SkillHolder(268, 1),
- new SkillHolder(269, 1),
- new SkillHolder(304, 1),
- new SkillHolder(306, 1),
- new SkillHolder(308, 1),
- new SkillHolder(270, 1),
- new SkillHolder(364, 1),
- new SkillHolder(274, 1),
- new SkillHolder(275, 1),
- new SkillHolder(271, 1),
- new SkillHolder(309, 1),
- new SkillHolder(307, 1),
- new SkillHolder(272, 1),
- new SkillHolder(310, 1),
- new SkillHolder(1363, 1),
- new SkillHolder(1388, 3),
- new SkillHolder(4700, 13),
- };
- private final SkillHolder[] MAGE_BUFFS =
- {
- new SkillHolder(4322, 1),
- new SkillHolder(4323, 1),
- new SkillHolder(4328, 1),
- new SkillHolder(4329, 1),
- new SkillHolder(4330, 1),
- new SkillHolder(4331, 1),
- };
- private final SkillHolder[] MAGE_BUFFS_LVL40 =
- {
- new SkillHolder(1204, 2),
- new SkillHolder(1035, 3),
- new SkillHolder(1036, 2),
- new SkillHolder(1040, 3),
- new SkillHolder(1045, 6),
- new SkillHolder(1048, 6),
- new SkillHolder(1078, 6),
- new SkillHolder(1085, 3),
- new SkillHolder(1062, 2),
- new SkillHolder(1059, 3),
- new SkillHolder(273, 1),
- new SkillHolder(276, 1),
- new SkillHolder(365, 1),
- new SkillHolder(264, 1),
- new SkillHolder(268, 1),
- new SkillHolder(304, 1),
- new SkillHolder(267, 1),
- new SkillHolder(349, 1),
- new SkillHolder(1389, 3),
- new SkillHolder(1413, 1),
- new SkillHolder(1303, 2),
- };
- private final SkillHolder[] MAGE_BUFFS_LVL76 =
- {
- new SkillHolder(1040, 3),
- new SkillHolder(1036, 2),
- new SkillHolder(1045, 6),
- new SkillHolder(1048, 6),
- new SkillHolder(1062, 2),
- new SkillHolder(1035, 4),
- new SkillHolder(1085, 3),
- new SkillHolder(1078, 6),
- new SkillHolder(1243, 6),
- new SkillHolder(1204, 2),
- new SkillHolder(1303, 2),
- new SkillHolder(1259, 4),
- new SkillHolder(1059, 3),
- new SkillHolder(266, 1),
- new SkillHolder(264, 1),
- new SkillHolder(267, 1),
- new SkillHolder(306, 1),
- new SkillHolder(308, 1),
- new SkillHolder(270, 1),
- new SkillHolder(268, 1),
- new SkillHolder(304, 1),
- new SkillHolder(273, 1),
- new SkillHolder(307, 1),
- new SkillHolder(276, 1),
- new SkillHolder(349, 1),
- new SkillHolder(277, 1),
- new SkillHolder(365, 1),
- new SkillHolder(304, 1),
- new SkillHolder(1413, 1),
- new SkillHolder(1389, 3),
- new SkillHolder(4703, 13),
- };
- @Override
- public void run()
- {
- for (final L2PcInstance player : getKnownList().getKnownPlayers().values())
- {
- if (player.isMageClass() && player.getLevel() < 40)
- {
- for (SkillHolder skills : MAGE_BUFFS)
- {
- TeriusCast(player, skills.getSkill());
- }
- }
- if (!player.isMageClass() && player.getLevel() < 40)
- {
- for (SkillHolder skills : FIGHTER_BUFFS)
- {
- TeriusCast(player, skills.getSkill());
- }
- }
- if (player.isMageClass() && player.getLevel() >= 40 && player.getLevel() < 76)
- {
- for (SkillHolder skills : MAGE_BUFFS_LVL40)
- {
- TeriusCast(player, skills.getSkill());
- }
- }
- if (!player.isMageClass() && player.getLevel() >= 40 && player.getLevel() < 76)
- {
- for (SkillHolder skills : FIGHTER_BUFFS_LVL40)
- {
- TeriusCast(player, skills.getSkill());
- }
- }
- if (player.isMageClass() && player.getLevel() >= 76)
- {
- for (SkillHolder skills : MAGE_BUFFS_LVL76)
- {
- TeriusCast(player, skills.getSkill());
- }
- }
- if (!player.isMageClass() && player.getLevel() >= 76)
- {
- for (SkillHolder skills : FIGHTER_BUFFS_LVL76)
- {
- TeriusCast(player, skills.getSkill());
- }
- }
- }
- }
- private boolean TeriusCast(final L2PcInstance player, L2Skill skill)
- {
- if (player.isDead() || !player.isVisible() || !isInsideRadius(player, Config.RADIO_BUFFER, false, false))
- {
- return false;
- }
- if (player.getFirstEffect(skill) == null)
- {
- heal(player);
- SkillTable.getInstance().getInfo(skill.getId(), skill.getLevel()).getEffects(player, player);
- skill.getEffects(_caster, player, false, false, false);
- broadcastPacket(new MagicSkillUser(_caster, player, skill.getId(), skill.getLevel(), 1000, 0));
- return true;
- }
- return false;
- }
- }
- static void heal(L2PcInstance activeChar)
- {
- activeChar.setCurrentHp(activeChar.getMaxHp());
- activeChar.setCurrentCp(activeChar.getMaxCp());
- activeChar.setCurrentMp(activeChar.getMaxMp());
- }
- public L2TeriusBuffInstance(final int objectId, final L2NpcTemplate template)
- {
- super(objectId, template);
- if (_aiTask != null)
- {
- _aiTask.cancel(true);
- }
- _aiTask = ThreadPoolManager.getInstance().scheduleAiAtFixedRate(new TeriusAI(this), 3000, 3000);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement