Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * L2jFrozen Project - www.l2jfrozen.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.l2jfrozen.gameserver.handler.usercommandhandlers;
- import com.l2jfrozen.Config;
- import com.l2jfrozen.gameserver.ai.CtrlIntention;
- import com.l2jfrozen.gameserver.controllers.GameTimeController;
- import com.l2jfrozen.gameserver.datatables.xml.MapRegionTable;
- import com.l2jfrozen.gameserver.handler.IUserCommandHandler;
- import com.l2jfrozen.gameserver.managers.GrandBossManager;
- import com.l2jfrozen.gameserver.model.L2Character;
- import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
- import com.l2jfrozen.gameserver.model.entity.event.CTF;
- import com.l2jfrozen.gameserver.model.entity.event.DM;
- import com.l2jfrozen.gameserver.model.entity.event.TvT;
- import com.l2jfrozen.gameserver.model.entity.event.VIP;
- import com.l2jfrozen.gameserver.network.serverpackets.MagicSkillUser;
- import com.l2jfrozen.gameserver.network.serverpackets.SetupGauge;
- import com.l2jfrozen.gameserver.thread.ThreadPoolManager;
- import com.l2jfrozen.gameserver.util.Broadcast;
- /**
- *
- *
- */
- public class Escape implements IUserCommandHandler
- {
- private static final int[] COMMAND_IDS =
- {
- 52
- };
- /*
- * (non-Javadoc)
- * @see com.l2jfrozen.gameserver.handler.IUserCommandHandler#useUserCommand(int, com.l2jfrozen.gameserver.model.L2PcInstance)
- */
- @Override
- public boolean useUserCommand(final int id, final L2PcInstance activeChar)
- {
- final int unstuckTimer = activeChar.getAccessLevel().isGm() ? 1000 : Config.UNSTUCK_INTERVAL * 1000;
- // Check to see if the current player is in Festival.
- if (activeChar.isFestivalParticipant())
- {
- activeChar.sendMessage("You may not use an escape command in a festival.");
- return false;
- }
- if (activeChar.isArenaProtection() || activeChar.isInsideZone(L2Character.TOURNAMENT))
- {
- activeChar.sendMessage("You cannot use this skill in Tournament Event/Zone.");
- return false;
- }
- // Check to see if the current player is in TVT Event.
- if (activeChar._inEventTvT && TvT.is_started())
- {
- activeChar.sendMessage("You may not use an escape skill in TvT.");
- return false;
- }
- // Check to see if the current player is in CTF Event.
- if (activeChar._inEventCTF && CTF.is_started())
- {
- activeChar.sendMessage("You may not use an escape skill in CTF.");
- return false;
- }
- // Check to see if the current player is in DM Event.
- if (activeChar._inEventDM && DM.is_started())
- {
- activeChar.sendMessage("You may not use an escape skill in DM.");
- return false;
- }
- // Check to see if the current player is in Vip Event.
- if (activeChar._inEventVIP && VIP._started)
- {
- activeChar.sendMessage("You may not use an escape skill in VIP.");
- return false;
- }
- // Check to see if the current player is in Grandboss zone.
- if (GrandBossManager.getInstance().getZone(activeChar) != null && !activeChar.isGM())
- {
- activeChar.sendMessage("You may not use an escape command in Grand boss zone.");
- return false;
- }
- // Check to see if the current player is in jail.
- if (activeChar.isInJail())
- {
- activeChar.sendMessage("You can not escape from jail.");
- return false;
- }
- // Check to see if the current player is in fun event.
- if (activeChar.isInFunEvent())
- {
- activeChar.sendMessage("You may not escape from an Event.");
- return false;
- }
- // Check to see if the current player is in Observer Mode.
- if (activeChar.inObserverMode())
- {
- activeChar.sendMessage("You may not escape during Observer mode.");
- return false;
- }
- // Check to see if the current player is sitting.
- if (activeChar.isSitting())
- {
- activeChar.sendMessage("You may not escape when you sitting.");
- return false;
- }
- // Check player status.
- if (activeChar.isCastingNow() || activeChar.isMovementDisabled() || activeChar.isMuted() || activeChar.isAlikeDead() || activeChar.isInOlympiadMode() || activeChar.isAwaying())
- return false;
- if (unstuckTimer < 60000)
- activeChar.sendMessage("After " + unstuckTimer / 60000 + " min. you be returned to near village.");
- else
- activeChar.sendMessage("After " + unstuckTimer / 60000 + " min. you be returned to near village.");
- activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
- // SoE Animation section
- activeChar.setTarget(activeChar);
- activeChar.disableAllSkills();
- MagicSkillUser msk = new MagicSkillUser(activeChar, Config.UNSTUCK_ANIMATION_ID, 1, unstuckTimer, 0);
- activeChar.setTarget(null); // Like retail we haven't self target
- Broadcast.toSelfAndKnownPlayersInRadius(activeChar, msk, 810000/* 900 */);
- SetupGauge sg = new SetupGauge(0, unstuckTimer);
- activeChar.sendPacket(sg);
- msk = null;
- sg = null;
- // End SoE Animation section
- EscapeFinalizer ef = new EscapeFinalizer(activeChar);
- // continue execution later
- activeChar.setSkillCast(ThreadPoolManager.getInstance().scheduleGeneral(ef, unstuckTimer));
- activeChar.setSkillCastEndTime(10 + GameTimeController.getGameTicks() + unstuckTimer / GameTimeController.MILLIS_IN_TICK);
- ef = null;
- return true;
- }
- static class EscapeFinalizer implements Runnable
- {
- private final L2PcInstance _activeChar;
- EscapeFinalizer(final L2PcInstance activeChar)
- {
- _activeChar = activeChar;
- }
- @Override
- public void run()
- {
- if (_activeChar.isDead())
- return;
- _activeChar.setIsIn7sDungeon(false);
- _activeChar.enableAllSkills();
- try
- {
- if (_activeChar.getKarma() > 0 && Config.ALT_KARMA_TELEPORT_TO_FLORAN)
- {
- _activeChar.teleToLocation(17836, 170178, -3507, true); // Floran
- return;
- }
- if (Config.CUSTOMESCAPE_ENABLE)
- {
- _activeChar.teleToLocation(Config.ESCAPE_X, Config.ESCAPE_Y, Config.ESCAPE_Z);
- }
- else if (!Config.CUSTOMESCAPE_ENABLE)
- {
- _activeChar.teleToLocation(MapRegionTable.TeleportWhereType.Town);
- }
- }
- catch (final Throwable e)
- {
- if (Config.ENABLE_ALL_EXCEPTIONS)
- e.printStackTrace();
- }
- }
- }
- /*
- * (non-Javadoc)
- * @see com.l2jfrozen.gameserver.handler.IUserCommandHandler#getUserCommandList()
- */
- @Override
- public int[] getUserCommandList()
- {
- return COMMAND_IDS;
- }
- }
Add Comment
Please, Sign In to add comment