/* * 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 silentium.gameserver.model.actor.instance; import silentium.gameserver.ai.CtrlIntention; import silentium.gameserver.model.L2Skill; import silentium.gameserver.model.actor.L2Character; import silentium.gameserver.model.actor.L2Npc; import silentium.gameserver.network.serverpackets.ActionFailed; import silentium.gameserver.network.serverpackets.MoveToPawn; import silentium.gameserver.network.serverpackets.MyTargetSelected; import silentium.gameserver.network.serverpackets.ValidateLocation; import silentium.gameserver.templates.chars.L2NpcTemplate; /** * This class manages all Castle Siege Artefacts. */ public final class L2ArtefactInstance extends L2NpcInstance { public L2ArtefactInstance(int objectId, L2NpcTemplate template) { super(objectId, template); } /** * @see silentium.gameserver.model.actor.L2Npc#onSpawn() */ @Override public void onSpawn() { super.onSpawn(); getCastle().registerArtefact(this); } /** * Manage actions when a player click on the L2ArtefactInstance.<BR> * <BR> * <B><U> Actions</U> :</B><BR> * <BR> * <li>Set the L2Npc 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 L2Npc 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> * * @param player * The L2PcInstance that start an action on the L2ArtefactInstance */ @Override public void onAction(L2PcInstance player) { if (!player.canTarget()) return; if (this != player.getTarget()) { // Set the target of the L2PcInstance player player.setTarget(this); // Send a Server->Client packet MyTargetSelected to the L2PcInstance player player.sendPacket(new MyTargetSelected(getObjectId(), 0)); // Send a Server->Client packet ValidateLocation to correct the L2ArtefactInstance position and heading on the client player.sendPacket(new ValidateLocation(this)); } else { // Calculate the distance between the L2PcInstance and the L2Npc if (!canInteract(player)) { // Notify the L2PcInstance AI with AI_INTENTION_INTERACT player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, this); } else { // Rotate the player to face the instance player.sendPacket(new MoveToPawn(player, this, L2Npc.INTERACTION_DISTANCE)); // Send ActionFailed to the player in order to avoid he stucks player.sendPacket(ActionFailed.STATIC_PACKET); } } } @Override public boolean isAutoAttackable(L2Character attacker) { return false; } @Override public boolean isAttackable() { return false; } @Override public void onForcedAttack(L2PcInstance player) { player.sendPacket(ActionFailed.STATIC_PACKET); } @Override public void reduceCurrentHp(double damage, L2Character attacker, L2Skill skill) { } @Override public void reduceCurrentHp(double damage, L2Character attacker, boolean awake, boolean isDOT, L2Skill skill) { } }