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 com.l2jterius.gameserver.model.actor.instance;
- import java.util.concurrent.ScheduledFuture;
- import com.l2jterius.Config;
- import com.l2jterius.gameserver.ai.CtrlIntention;
- import com.l2jterius.gameserver.datatables.SkillTable;
- import com.l2jterius.gameserver.model.L2Skill;
- import com.l2jterius.gameserver.model.base.ClassId;
- import com.l2jterius.gameserver.network.serverpackets.ActionFailed;
- import com.l2jterius.gameserver.network.serverpackets.MagicSkillUser;
- import com.l2jterius.gameserver.network.serverpackets.MoveToPawn;
- import com.l2jterius.gameserver.network.serverpackets.MyTargetSelected;
- import com.l2jterius.gameserver.network.serverpackets.NpcHtmlMessage;
- import com.l2jterius.gameserver.network.serverpackets.ValidateLocation;
- import com.l2jterius.gameserver.skills.SkillHolder;
- import com.l2jterius.gameserver.templates.L2NpcTemplate;
- import com.l2jterius.gameserver.thread.ThreadPoolManager;
- /**
- * @author ADM-Terius
- */
- public class L2FavorecedoraInstance extends L2NpcInstance
- {
- private ScheduledFuture<?> _aiTask;
- @Override
- public void onAction(L2PcInstance player)
- {
- if (this != player.getTarget())
- {
- player.setTarget(this);
- player.sendPacket(new MyTargetSelected(getObjectId(), 0));
- player.sendPacket(new ValidateLocation(this));
- }
- else
- {
- if (!canInteract(player))
- player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, this);
- else
- {
- // Rotate the player to face the instance
- player.sendPacket(new MoveToPawn(player, this, L2NpcInstance.INTERACTION_DISTANCE));
- if (hasRandomAnimation())
- onRandomAnimation();
- showMainWindow(player);
- // Send ActionFailed to the player in order to avoid he stucks
- player.sendPacket(ActionFailed.STATIC_PACKET);
- }
- }
- }
- /**
- * @param player
- */
- private void showMainWindow(L2PcInstance player)
- {
- NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
- html.setFile("data/html/mods/FavorecedoraBuff.htm");
- html.replace("%objectId%", String.valueOf(getObjectId()));
- html.replace("%npcname%", getName());
- player.sendPacket(html);
- }
- private class TeriusAI implements Runnable
- {
- private final L2FavorecedoraInstance _caster;
- protected TeriusAI(final L2FavorecedoraInstance caster)
- {
- _caster = caster;
- }
- private final SkillHolder[] HERO_BUFFS =
- {
- new SkillHolder(2622, 1),
- };
- private final SkillHolder[] CLANLORD_BUFFS =
- {
- new SkillHolder(2621, 1),
- };
- private final SkillHolder[] DonatorM_BUFFS =
- {
- new SkillHolder(2619, 1),
- };
- private final SkillHolder[] DonatorW_BUFFS =
- {
- new SkillHolder(2620, 1),
- };
- @Override
- public void run()
- {
- for (final L2PcInstance player : getKnownList().getKnownPlayers().values())
- {
- if (player.isMageClass() && (player.isDonator() && (player.getClassId() != ClassId.overlord) && (player.getClassId() != ClassId.warcryer)))
- {
- for (SkillHolder skills : DonatorM_BUFFS)
- {
- TeriusCast(player, skills.getSkill());
- }
- }else
- if(player.isDonator())
- for (SkillHolder skills : DonatorW_BUFFS)
- {
- TeriusCast(player, skills.getSkill());
- }
- if(player.isHero() && (player.isDonator()))
- {
- for (SkillHolder skills : HERO_BUFFS)
- {
- TeriusCast(player, skills.getSkill());
- }
- }
- if((player.isCastleLord(1) || (player.isCastleLord(2) || (player.isCastleLord(3) || (player.isCastleLord(4) || (player.isCastleLord(5) || (player.isCastleLord(6) || (player.isCastleLord(7) || (player.isCastleLord(8) || (player.isCastleLord(9) && (player.isDonator())))))))))))
- {
- for (SkillHolder skills : CLANLORD_BUFFS)
- {
- TeriusCast(player, skills.getSkill());
- }
- }
- }
- }
- // Funcion de casteo al jugador
- private boolean TeriusCast(final L2PcInstance player,L2Skill skill)
- {
- if (player.isDead() || !player.isVisible() || !isInsideRadius(player, 200, 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(), Config.PROTECTOR_SKILLTIME, 0));
- skill = null;
- return true;
- }
- return false;
- }
- }
- static void heal(L2PcInstance activeChar)
- {
- activeChar.setCurrentHp(activeChar.getMaxHp());
- activeChar.setCurrentCp(activeChar.getMaxCp());
- activeChar.setCurrentMp(activeChar.getMaxMp());
- }
- public L2FavorecedoraInstance(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