l2j_mobius/trunk/dist/game/data/scripts/handlers/actionhandlers/L2ArtefactInstanceAction.java
2015-01-02 15:09:44 +00:00

71 lines
2.4 KiB
Java

/*
* Copyright (C) 2004-2015 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack 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.
*
* L2J DataPack 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.actionhandlers;
import com.l2jserver.gameserver.ai.CtrlIntention;
import com.l2jserver.gameserver.enums.InstanceType;
import com.l2jserver.gameserver.handler.IActionHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
public class L2ArtefactInstanceAction implements IActionHandler
{
/**
* Manage actions when a player click on the L2ArtefactInstance.<BR>
* <BR>
* <B><U> Actions</U> :</B><BR>
* <BR>
* <li>Set the L2NpcInstance as target of the L2PcInstance player (if necessary)</li> <li>Send a Server->Client packet MyTargetSelected to the L2PcInstance player (display the select window)</li> <li>Send a Server->Client packet ValidateLocation to correct the L2NpcInstance position and heading
* on the client</li><BR>
* <BR>
* <B><U> Example of use </U> :</B><BR>
* <BR>
* <li>Client packet : Action, AttackRequest</li><BR>
* <BR>
*/
@Override
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
{
if (!((L2Npc) target).canTarget(activeChar))
{
return false;
}
if (activeChar.getTarget() != target)
{
activeChar.setTarget(target);
}
else if (interact)
{
// Calculate the distance between the L2PcInstance and the L2NpcInstance
if (!((L2Npc) target).canInteract(activeChar))
{
// Notify the L2PcInstance AI with AI_INTENTION_INTERACT
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target);
}
}
return true;
}
@Override
public InstanceType getInstanceType()
{
return InstanceType.L2ArtefactInstance;
}
}