Package lineage2.gameserver.network.clientpackets

Source Code of lineage2.gameserver.network.clientpackets.AbstractTargetAction

package lineage2.gameserver.network.clientpackets;

import lineage2.gameserver.model.GameObject;
import lineage2.gameserver.model.Player;
import lineage2.gameserver.utils.Location;

/**
*/
public abstract class AbstractTargetAction extends L2GameClientPacket
{
  private final Location _actorPosition = new Location();
  private boolean _forced;
  private int _targetObjectId;

  @Override
  protected void readImpl()
  {
    _targetObjectId = readD();
    _actorPosition.x = readD();
    _actorPosition.y = readD();
    _actorPosition.z = readD();
    _forced = readC() == 1;
  }

  @Override
  protected void runImpl()
  {
    final Player actor = getActiveChar();

    if(actor == null)
    {
      return;
    }

    final GameObject obj = actor.getVisibleObject(_targetObjectId);

    if(obj == null)
    {
      return;
    }

    if(_actorPosition.isNull())
    {
      return;
    }

    if(obj.isTargetable(actor))
    {
      if(isAttackRequest())
      {
        if(actor.getPlayerAccess().CanAttack)
        {
          obj.onForcedAttack(actor, _forced);
        }
      }
      else
      {
        obj.onActionSelect(actor, _forced);
      }
      actor.setActive();
    }
    actor.sendActionFailed();
  }

  protected abstract boolean isAttackRequest();
}
TOP

Related Classes of lineage2.gameserver.network.clientpackets.AbstractTargetAction

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.