107 lines
3.3 KiB
Java
107 lines
3.3 KiB
Java
/*
|
|
* This file is part of the L2J Mobius project.
|
|
*
|
|
* 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
package handlers.usercommandhandlers;
|
|
|
|
import static com.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ACTIVE;
|
|
|
|
import com.l2jmobius.Config;
|
|
import com.l2jmobius.gameserver.data.xml.impl.SkillData;
|
|
import com.l2jmobius.gameserver.handler.IUserCommandHandler;
|
|
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
|
import com.l2jmobius.gameserver.model.skills.Skill;
|
|
import com.l2jmobius.gameserver.model.skills.SkillCaster;
|
|
import com.l2jmobius.gameserver.model.skills.SkillCastingType;
|
|
import com.l2jmobius.gameserver.network.SystemMessageId;
|
|
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
|
|
|
/**
|
|
* Unstuck user command.
|
|
*/
|
|
public class Unstuck implements IUserCommandHandler
|
|
{
|
|
private static final int[] COMMAND_IDS =
|
|
{
|
|
52
|
|
};
|
|
|
|
@Override
|
|
public boolean useUserCommand(int id, L2PcInstance activeChar)
|
|
{
|
|
if (activeChar.isJailed())
|
|
{
|
|
activeChar.sendMessage("You cannot use this function while you are jailed.");
|
|
return false;
|
|
}
|
|
|
|
final int unstuckTimer = (activeChar.getAccessLevel().isGm() ? 1000 : Config.UNSTUCK_INTERVAL * 1000);
|
|
|
|
if (activeChar.isInOlympiadMode())
|
|
{
|
|
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_USE_THAT_SKILL_IN_A_OLYMPIAD_MATCH);
|
|
return false;
|
|
}
|
|
|
|
if (activeChar.isCastingNow(SkillCaster::isAnyNormalType) || activeChar.isMovementDisabled() || activeChar.isMuted() || activeChar.isAlikeDead() || activeChar.inObserverMode() || activeChar.isCombatFlagEquipped())
|
|
{
|
|
return false;
|
|
}
|
|
|
|
final Skill escape = SkillData.getInstance().getSkill(2099, 1); // 5 minutes escape
|
|
final Skill GM_escape = SkillData.getInstance().getSkill(2100, 1); // 1 second escape
|
|
if (activeChar.getAccessLevel().isGm())
|
|
{
|
|
if (GM_escape != null)
|
|
{
|
|
activeChar.doCast(GM_escape);
|
|
return true;
|
|
}
|
|
activeChar.sendMessage("You use Escape: 1 second.");
|
|
}
|
|
else if ((Config.UNSTUCK_INTERVAL == 300) && (escape != null))
|
|
{
|
|
activeChar.doCast(escape);
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
final SkillCaster skillCaster = SkillCaster.castSkill(activeChar, activeChar.getTarget(), escape, null, SkillCastingType.NORMAL, false, false, unstuckTimer);
|
|
if (skillCaster == null)
|
|
{
|
|
activeChar.sendPacket(ActionFailed.get(SkillCastingType.NORMAL));
|
|
activeChar.getAI().setIntention(AI_INTENTION_ACTIVE);
|
|
return false;
|
|
}
|
|
|
|
if (Config.UNSTUCK_INTERVAL > 100)
|
|
{
|
|
activeChar.sendMessage("You use Escape: " + (unstuckTimer / 60000) + " minutes.");
|
|
}
|
|
else
|
|
{
|
|
activeChar.sendMessage("You use Escape: " + (unstuckTimer / 1000) + " seconds.");
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public int[] getUserCommandList()
|
|
{
|
|
return COMMAND_IDS;
|
|
}
|
|
}
|