Package com.l2jfrozen.gameserver.model.actor.instance

Source Code of com.l2jfrozen.gameserver.model.actor.instance.L2ArtefactInstance

/*
* 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.model.actor.instance;

import com.l2jfrozen.gameserver.ai.CtrlIntention;
import com.l2jfrozen.gameserver.model.L2Character;
import com.l2jfrozen.gameserver.network.serverpackets.ActionFailed;
import com.l2jfrozen.gameserver.network.serverpackets.MyTargetSelected;
import com.l2jfrozen.gameserver.network.serverpackets.ValidateLocation;
import com.l2jfrozen.gameserver.templates.L2NpcTemplate;

/**
* This class manages all Castle Siege Artefacts.<BR>
* <BR>
*
* @version $Revision: 1.11.2.1.2.7 $ $Date: 2005/04/06 16:13:40 $
*/
public final class L2ArtefactInstance extends L2NpcInstance
{
  /**
   * Constructor of L2ArtefactInstance (use L2Character and L2NpcInstance constructor).<BR>
   * <BR>
   * <B><U> Actions</U> :</B><BR>
   * <BR>
   * <li>Call the L2Character constructor to set the _template of the L2ArtefactInstance (copy skills from template to
   * object and link _calculators to NPC_STD_CALCULATOR)</li> <li>Set the name of the L2ArtefactInstance</li> <li>
   * Create a RandomAnimation Task that will be launched after the calculated delay if the server allow it</li><BR>
   * <BR>
   *
   * @param objectId Identifier of the object to initialized
   * @param template
   */
  public L2ArtefactInstance(int objectId, L2NpcTemplate template)
  {
    super(objectId, template);
  }

  /**
   * Return False.<BR>
   * <BR>
   */
  @Override
  public boolean isAutoAttackable(L2Character attacker)
  {
    return false;
  }

  @Override
  public boolean isAttackable()
  {
    return false;
  }

  /**
   * 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>
   *
   * @param player The L2PcInstance that start an action on the L2ArtefactInstance
   */
  @Override
  public void onAction(L2PcInstance player)
  {
    if(!canTarget(player))
      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
      MyTargetSelected my = new MyTargetSelected(getObjectId(), 0);
      player.sendPacket(my);

      // 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 L2NpcInstance
      if(!canInteract(player))
      {
        // Notify the L2PcInstance AI with AI_INTENTION_INTERACT
        player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, this);
      }
    }
    // Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet
    player.sendPacket(ActionFailed.STATIC_PACKET);
  }

  @Override
  public void reduceCurrentHp(double damage, L2Character attacker)
  {}

  @Override
  public void reduceCurrentHp(double damage, L2Character attacker, boolean awake)
  {}

  @Override
  public void onForcedAttack(L2PcInstance player)
  {
    player.sendPacket(ActionFailed.STATIC_PACKET);
  }
}
TOP

Related Classes of com.l2jfrozen.gameserver.model.actor.instance.L2ArtefactInstance

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.