Package lineage2.gameserver.model

Examples of lineage2.gameserver.model.Playable


    nextAction nextAction = _nextAction;
    Object nextAction_arg0 = _nextAction_arg0;
    Object nextAction_arg1 = _nextAction_arg1;
    boolean nextAction_arg2 = _nextAction_arg2;
    boolean nextAction_arg3 = _nextAction_arg3;
    Playable actor = getActor();
    if ((nextAction == null) || actor.isActionsDisabled())
    {
      return false;
    }
    Skill skill;
    Creature target;
    GameObject object;
    switch (nextAction)
    {
      case ATTACK:
        if (nextAction_arg0 == null)
        {
          return false;
        }
        target = (Creature) nextAction_arg0;
        _forceUse = nextAction_arg2;
        _dontMove = nextAction_arg3;
        clearNextAction();
        setIntention(AI_INTENTION_ATTACK, target);
        break;
      case CAST:
        if ((nextAction_arg0 == null) || (nextAction_arg1 == null))
        {
          return false;
        }
        skill = (Skill) nextAction_arg0;
        target = (Creature) nextAction_arg1;
        _forceUse = nextAction_arg2;
        _dontMove = nextAction_arg3;
        clearNextAction();
        if (!skill.checkCondition(actor, target, _forceUse, _dontMove, true))
        {
          if ((skill.getNextAction() == NextAction.ATTACK) && !actor.equals(target))
          {
            setNextAction(PlayableAI.nextAction.ATTACK, target, null, _forceUse, false);
            return setNextIntention();
          }
          return false;
        }
        setIntention(AI_INTENTION_CAST, skill, target);
        break;
      case MOVE:
        if ((nextAction_arg0 == null) || (nextAction_arg1 == null))
        {
          return false;
        }
        Location loc = (Location) nextAction_arg0;
        Integer offset = (Integer) nextAction_arg1;
        clearNextAction();
        actor.moveToLocation(loc, offset, nextAction_arg2);
        break;
      case REST:
        actor.sitDown(null);
        break;
      case INTERACT:
        if (nextAction_arg0 == null)
        {
          return false;
View Full Code Here


   * Method onEvtThink.
   */
  @Override
  protected final void onEvtThink()
  {
    Playable actor = getActor();
    if (actor.isActionsDisabled())
    {
      return;
    }
    try
    {
View Full Code Here

  /**
   * Method thinkFollow.
   */
  protected void thinkFollow()
  {
    Playable actor = getActor();
    Creature target = (Creature) _intention_arg0;
    Integer offset = (Integer) _intention_arg1;
    if ((target == null) || target.isAlikeDead() || (actor.getDistance(target) > 4000) || (offset == null))
    {
      clientActionFailed();
      return;
    }
    if (actor.isFollow && (actor.getFollowTarget() == target))
    {
      clientActionFailed();
      return;
    }
    if (actor.isInRange(target, offset + 20) || actor.isMovementDisabled())
    {
      clientActionFailed();
    }
    if (_followTask != null)
    {
View Full Code Here

   * @param object GameObject
   */
  @Override
  protected void onIntentionInteract(GameObject object)
  {
    Playable actor = getActor();
    if (actor.isActionsDisabled())
    {
      setNextAction(nextAction.INTERACT, object, null, false, false);
      clientActionFailed();
      return;
    }
View Full Code Here

  /**
   * Method thinkInteract.
   */
  protected void thinkInteract()
  {
    Playable actor = getActor();
    GameObject target = (GameObject) _intention_arg0;
    if (target == null)
    {
      setIntention(AI_INTENTION_ACTIVE);
      return;
    }
    int range = (int) (Math.max(30, actor.getMinDistance(target)) + 20);
    if (actor.isInRangeZ(target, range))
    {
      if (actor.isPlayer())
      {
        //((Player) actor).doInteract(target);
        target.onActionSelect((Player) actor, false);
      }
      setIntention(AI_INTENTION_ACTIVE);
    }
    else
    {
      actor.moveToLocation(target.getLoc(), 40, true);
      setNextAction(nextAction.INTERACT, target, null, false, false);
    }
  }
View Full Code Here

   * @param object GameObject
   */
  @Override
  protected void onIntentionPickUp(GameObject object)
  {
    Playable actor = getActor();
    if (actor.isActionsDisabled())
    {
      setNextAction(nextAction.PICKUP, object, null, false, false);
      clientActionFailed();
      return;
    }
View Full Code Here

  /**
   * Method thinkPickUp.
   */
  protected void thinkPickUp()
  {
    final Playable actor = getActor();
    final GameObject target = (GameObject) _intention_arg0;
    if (target == null)
    {
      setIntention(AI_INTENTION_ACTIVE);
      return;
    }
    if (actor.isInRange(target, 30) && (Math.abs(actor.getZ() - target.getZ()) < 50))
    {
      if (actor.isPlayer() || actor.isPet())
      {
        actor.doPickupItem(target);
      }
      setIntention(AI_INTENTION_ACTIVE);
    }
    else
    {
      ThreadPoolManager.getInstance().execute(new RunnableImpl()
      {
        @Override
        public void runImpl()
        {
          actor.moveToLocation(target.getLoc(), 10, true);
          setNextAction(nextAction.PICKUP, target, null, false, false);
        }
      });
    }
  }
View Full Code Here

   * Method thinkAttack.
   * @param checkRange boolean
   */
  protected void thinkAttack(boolean checkRange)
  {
    Playable actor = getActor();
    Player player = actor.getPlayer();
    if (player == null)
    {
      setIntention(AI_INTENTION_ACTIVE);
      return;
    }
    if (actor.isActionsDisabled() || actor.isAttackingDisabled())
    {
      actor.sendActionFailed();
      return;
    }
    boolean isPosessed = (actor instanceof Summon) && ((Summon) actor).isDepressed();
    Creature attack_target = getAttackTarget();
    if ((attack_target == null) || attack_target.isDead() || (!isPosessed && !(_forceUse ? attack_target.isAttackable(actor) : attack_target.isAutoAttackable(actor))))
    {
      setIntention(AI_INTENTION_ACTIVE);
      actor.sendActionFailed();
      return;
    }
    if (!checkRange)
    {
      clientStopMoving();
      actor.doAttack(attack_target);
      return;
    }
    int range = actor.getPhysicalAttackRange();
    if (range < 10)
    {
      range = 10;
    }
    boolean canSee = GeoEngine.canSeeTarget(actor, attack_target, false);
    if (!canSee && ((range > 200) || (Math.abs(actor.getZ() - attack_target.getZ()) > 200)))
    {
      actor.sendPacket(SystemMsg.CANNOT_SEE_TARGET);
      setIntention(AI_INTENTION_ACTIVE);
      actor.sendActionFailed();
      return;
    }
    range += actor.getMinDistance(attack_target);
    if (actor.isFakeDeath())
    {
      actor.breakFakeDeath();
    }
    if (actor.isInRangeZ(attack_target, range))
    {
      if (!canSee)
      {
        actor.sendPacket(SystemMsg.CANNOT_SEE_TARGET);
        setIntention(AI_INTENTION_ACTIVE);
        actor.sendActionFailed();
        return;
      }
      clientStopMoving(false);
      actor.doAttack(attack_target);
    }
    else if (!_dontMove)
    {
      ThreadPoolManager.getInstance().execute(new ExecuteFollow(attack_target, range - 20));
    }
    else
    {
      actor.sendActionFailed();
    }
  }
View Full Code Here

   * Method thinkCast.
   * @param checkRange boolean
   */
  protected void thinkCast(boolean checkRange)
  {
    Playable actor = getActor();
    Creature target = getAttackTarget();
    if ((_skill.getSkillType() == SkillType.CRAFT) || _skill.isToggle())
    {
      if (_skill.checkCondition(actor, target, _forceUse, _dontMove, true))
      {
        actor.doCast(_skill, target, _forceUse);
      }
      return;
    }
    if ((target == null) || ((target.isDead() != _skill.getCorpse()) && !_skill.isNotTargetAoE()))
    {
      setIntention(AI_INTENTION_ACTIVE);
      actor.sendActionFailed();
      return;
    }
    if (!checkRange)
    {
      if ((_skill.getNextAction() == NextAction.ATTACK) && !actor.equals(target))
      {
        setNextAction(nextAction.ATTACK, target, null, _forceUse, false);
      }
      else
      {
        clearNextAction();
      }
      clientStopMoving();
      if (_skill.checkCondition(actor, target, _forceUse, _dontMove, true))
      {
        actor.doCast(_skill, target, _forceUse);
      }
      else
      {
        setNextIntention();
        if (getIntention() == CtrlIntention.AI_INTENTION_ATTACK)
        {
          thinkAttack(true);
        }
      }
      return;
    }
    int range = actor.getMagicalAttackRange(_skill);
    if (range < 10)
    {
      range = 10;
    }
    boolean canSee = (_skill.getSkillType() == SkillType.TAKECASTLE) || (_skill.getSkillType() == SkillType.TAKEFORTRESS) || GeoEngine.canSeeTarget(actor, target, actor.isFlying());
    boolean noRangeSkill = _skill.getCastRange() == 32767;
    if (!noRangeSkill && !canSee && ((range > 200) || (Math.abs(actor.getZ() - target.getZ()) > 200)))
    {
      actor.sendPacket(SystemMsg.CANNOT_SEE_TARGET);
      setIntention(AI_INTENTION_ACTIVE);
      actor.sendActionFailed();
      return;
    }
    range += actor.getMinDistance(target);
    if (actor.isFakeDeath())
    {
      actor.breakFakeDeath();
    }
    if (actor.isInRangeZ(target, range) || noRangeSkill)
    {
      if (!noRangeSkill && !canSee)
      {
        actor.sendPacket(SystemMsg.CANNOT_SEE_TARGET);
        setIntention(AI_INTENTION_ACTIVE);
        actor.sendActionFailed();
        return;
      }
      if ((_skill.getNextAction() == NextAction.ATTACK) && !actor.equals(target))
      {
        setNextAction(nextAction.ATTACK, target, null, _forceUse, false);
      }
      else
      {
        clearNextAction();
      }
      if (_skill.checkCondition(actor, target, _forceUse, _dontMove, true))
      {
        clientStopMoving(false);
        actor.doCast(_skill, target, _forceUse);
      }
      else
      {
        setNextIntention();
        if (getIntention() == CtrlIntention.AI_INTENTION_ATTACK)
        {
          thinkAttack(true);
        }
      }
    }
    else if (!_dontMove)
    {
      ThreadPoolManager.getInstance().execute(new ExecuteFollow(target, range - 20));
    }
    else
    {
      actor.sendPacket(Msg.YOUR_TARGET_IS_OUT_OF_RANGE);
      setIntention(AI_INTENTION_ACTIVE);
      actor.sendActionFailed();
    }
  }
View Full Code Here

   * Method lockTarget.
   * @param target Creature
   */
  public void lockTarget(Creature target)
  {
    Playable actor = getActor();
    if ((target == null) || target.isDead())
    {
      actor.setAggressionTarget(null);
    }
    else if (actor.getAggressionTarget() == null)
    {
      actor.getTarget();
      actor.setAggressionTarget(target);
      actor.setTarget(target);
      clearNextAction();
    }
  }
View Full Code Here

TOP

Related Classes of lineage2.gameserver.model.Playable

Copyright © 2018 www.massapicom. 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.