Package net.sf.l2j.gameserver.model

Examples of net.sf.l2j.gameserver.model.L2Object


                    if (((sk.getSkillType() == L2Skill.SkillType.BUFF || sk.getSkillType() == L2Skill.SkillType.HEAL) || (dist_2 >= castRange * castRange / 9)
                        && (dist_2 <= castRange * castRange) && (castRange > 70))
                        && !_actor.isSkillDisabled(sk.getId())
                        && _actor.getCurrentMp() >= _actor.getStat().getMpConsume(sk) && !sk.isPassive())
                    {
                        L2Object OldTarget = _actor.getTarget();
                        if (sk.getSkillType() == L2Skill.SkillType.BUFF
                            || sk.getSkillType() == L2Skill.SkillType.HEAL)
                        {
                            boolean useSkillSelf = true;
                            if (sk.getSkillType() == L2Skill.SkillType.HEAL
                                && _actor.getCurrentHp() > (int) (_actor.getMaxHp() / 1.5))
                            {
                                useSkillSelf = false;
                                break;
                            }
                            if (sk.getSkillType() == L2Skill.SkillType.BUFF)
                            {
                                L2Effect[] effects = _actor.getAllEffects();
                                for (int i = 0; effects != null && i < effects.length; i++)
                                {
                                    L2Effect effect = effects[i];
                                    if (effect.getSkill() == sk)
                                    {
                                        useSkillSelf = false;
                                        break;
                                    }
                                }
                            }
                            if (useSkillSelf) _actor.setTarget(_actor);
                        }

                        clientStopMoving(null);
                        _accessor.doCast(sk);
                        _actor.setTarget(OldTarget);
                        return;
                    }
                }

            // Check if the L2SiegeGuardInstance is attacking, knows the target and can't run
            if (!(_actor.isAttackingNow()) && (_actor.getRunSpeed() == 0)
                && (_actor.getKnownList().knowsObject(_attackTarget)))
            {
              // Cancel the target
                _actor.getKnownList().removeKnownObject(_attackTarget);
                _actor.setTarget(null);
                setIntention(AI_INTENTION_IDLE, null, null);
            }
            else
            {
                double dx = _actor.getX() - _attackTarget.getX();
                double dy = _actor.getY() - _attackTarget.getY();
                double dz = _actor.getZ() - _attackTarget.getZ();
                double homeX = _attackTarget.getX() - sGuard.getHomeX();
                double homeY = _attackTarget.getY() - sGuard.getHomeY();

                // Check if the L2SiegeGuardInstance isn't too far from it's home location
                if ((dx * dx + dy * dy > 10000) && (homeX * homeX + homeY * homeY > 3240000) // 1800 * 1800
                    && (_actor.getKnownList().knowsObject(_attackTarget)))
                {
                    // Cancel the target
                    _actor.getKnownList().removeKnownObject(_attackTarget);
                    _actor.setTarget(null);
                    setIntention(AI_INTENTION_IDLE, null, null);
                }
                else // Move the actor to Pawn server side AND client side by sending Server->Client packet MoveToPawn (broadcast)
                {
                  // Temporary hack for preventing guards jumping off towers,
                  // before replacing this with effective geodata checks and AI modification
                  if(dz*dz < 170*170) // normally 130 if guard z coordinates correct
                    moveToPawn(_attackTarget, range);
                }
            }

            return;

        }
        // Else, if the actor is muted and far from target, just "move to pawn"
        else if (_actor.isMuted() && dist_2 > (range + 20) * (range + 20))
        {
          // Temporary hack for preventing guards jumping off towers,
          // before replacing this with effective geodata checks and AI modification
          double dz = _actor.getZ() - _attackTarget.getZ();
          if(dz*dz < 170*170) // normally 130 if guard z coordinates correct
            moveToPawn(_attackTarget, range);
            return;
        }
        // Else, if this is close enough to attack
        else if (dist_2 <= (range + 20) * (range + 20))
        {
            // Force mobs to attak anybody if confused
            L2Character hated = null;
            if (_actor.isConfused()) hated = _attackTarget;
            else hated = ((L2Attackable) _actor).getMostHated();

            if (hated == null)
            {
                setIntention(AI_INTENTION_ACTIVE, null, null);
                return;
            }
            if (hated != _attackTarget) _attackTarget = hated;

            _attackTimeout = MAX_ATTACK_TIMEOUT + GameTimeController.getGameTicks();

            // check for close combat skills && heal/buff skills
            if (!_actor.isMuted() && Rnd.nextInt(100) <= 5)
            {
                for (L2Skill sk : skills)
                {
                    int castRange = sk.getCastRange();

                    if (castRange * castRange >= dist_2 && castRange <= 70 && !sk.isPassive()
                        && _actor.getCurrentMp() >= _actor.getStat().getMpConsume(sk)
                        && !_actor.isSkillDisabled(sk.getId()))
                    {
                        L2Object OldTarget = _actor.getTarget();
                        if (sk.getSkillType() == L2Skill.SkillType.BUFF
                            || sk.getSkillType() == L2Skill.SkillType.HEAL)
                        {
                            boolean useSkillSelf = true;
                            if (sk.getSkillType() == L2Skill.SkillType.HEAL
View Full Code Here


        if (target != null)
          if (maybeMoveToPawn(target, _actor.getMagicalAttackRange(_skill))) return;

        if (_skill.getHitTime() > 50) clientStopMoving(null);

        L2Object oldTarget = _actor.getTarget();
        if (oldTarget != null)
        {
            // Replace the current target by the cast target
            if (target != null && oldTarget != target) _actor.setTarget(getCastTarget());
View Full Code Here

    }

    private void thinkPickUp()
    {
        if (_actor.isAllSkillsDisabled()) return;
      L2Object target = getTarget();
        if (checkTargetLost(target)) return;
        if (maybeMoveToPawn(target, 36)) return;
        setIntention(AI_INTENTION_IDLE);
        ((L2PcInstance.AIAccessor) _accessor).doPickupItem(target);
        return;
View Full Code Here

    }

    private void thinkInteract()
    {
        if (_actor.isAllSkillsDisabled()) return;
        L2Object target = getTarget();
        if (checkTargetLost(target)) return;
        if (maybeMoveToPawn(target, 36)) return;
        if (!(target instanceof L2StaticObjectInstance)) ((L2PcInstance.AIAccessor) _accessor).doInteract((L2Character) target);
        setIntention(AI_INTENTION_IDLE);
        return;
View Full Code Here

        for (L2DoorInstance door: castle.getDoors())
                door.openMe();
            }
            if (command.equals("admin_open"))
            {
                L2Object target     = activeChar.getTarget();
                if (target instanceof L2DoorInstance)
                {
                    ((L2DoorInstance)target).openMe();
                }
                else
                {
                    activeChar.sendMessage("Incorrect target.");
                }
            }

            if (command.equals("admin_close"))
            {
                L2Object target = activeChar.getTarget();
                if (target instanceof L2DoorInstance)
                {
                    ((L2DoorInstance)target).closeMe();
                }
                else
View Full Code Here

                            && !_actor.isSkillDisabled(sk.getId())
                            && _actor.getCurrentMp() >= _actor.getStat().getMpConsume(sk)
                            && !sk.isPassive()
                            && Rnd.nextInt(100) <= 5)
                        {
                            L2Object OldTarget = _actor.getTarget();
                            if (sk.getSkillType() == L2Skill.SkillType.BUFF
                                || sk.getSkillType() == L2Skill.SkillType.HEAL)
                            {
                                boolean useSkillSelf = true;
                                if (sk.getSkillType() == L2Skill.SkillType.HEAL
                                    && _actor.getCurrentHp() > (int) (_actor.getMaxHp() / 1.5))
                                {
                                    useSkillSelf = false;
                                    break;
                                }
                                if (sk.getSkillType() == L2Skill.SkillType.BUFF)
                                {
                                    L2Effect[] effects = _actor.getAllEffects();
                                    for (int i = 0; effects != null && i < effects.length; i++)
                                    {
                                        L2Effect effect = effects[i];
                                        if (effect.getSkill() == sk)
                                        {
                                            useSkillSelf = false;
                                            break;
                                        }
                                    }
                                }
                                if (useSkillSelf) _actor.setTarget(_actor);
                            }

                            clientStopMoving(null);
                            _accessor.doCast(sk);
                            _actor.setTarget(OldTarget);
                            return;
                        }
                    }

                // Move the actor to Pawn server side AND client side by sending Server->Client packet MoveToPawn (broadcast)
                if (hated.isMoving()) range -= 100; if (range < 5) range = 5;
                moveToPawn(getAttackTarget(), range);
            }
            // Else, if this is close enough to attack
            else
            {
                _attackTimeout = MAX_ATTACK_TIMEOUT + GameTimeController.getGameTicks();

                // check for close combat skills && heal/buff skills
                if (!_actor.isMuted() /*&& _rnd.nextInt(100) <= 5*/)
                {
                  boolean useSkillSelf = true;
                    for (L2Skill sk : skills)
                    {
                        if (/*sk.getCastRange() >= dist && sk.getCastRange() <= 70 && */!sk.isPassive()
                            && _actor.getCurrentMp() >= _actor.getStat().getMpConsume(sk)
                            && !_actor.isSkillDisabled(sk.getId()) && (Rnd.nextInt(100) <= 8
                            || (_actor instanceof L2PenaltyMonsterInstance && Rnd.nextInt(100) <= 20)))
                        {
                            L2Object OldTarget = _actor.getTarget();
                            if (sk.getSkillType() == L2Skill.SkillType.BUFF
                                || sk.getSkillType() == L2Skill.SkillType.HEAL)
                            {
                                useSkillSelf = true;
                                if (sk.getSkillType() == L2Skill.SkillType.HEAL
View Full Code Here

  }

  private void handleTarget(String command, L2PcInstance activeChar) {
    try {
      String targetName = command.substring(13);
      L2Object obj = L2World.getInstance().getPlayer(targetName);
      if ((obj != null) && (obj instanceof L2PcInstance)) {
        obj.onAction(activeChar);
      } else {
        SystemMessage sm = new SystemMessage(SystemMessageId.S1_S2);
        sm.addString("Player "+targetName+" not found");
        activeChar.sendPacket(sm);
      }
View Full Code Here

    handleRes(activeChar, null);
  }

  private void handleRes(L2PcInstance activeChar, String player) {

    L2Object obj = activeChar.getTarget();
    if (player != null)
    {
      L2PcInstance plyr = L2World.getInstance().getPlayer(player);

      if (plyr != null)
View Full Code Here

    {
      int cnt = 0;
      assert _collisions.length == ((_table.length+31)>>5);
      for (int i=0; i < _table.length; i++)
      {
        L2Object obj = _table[i];
        if (obj != null)
          cnt++;
      }
      assert cnt == _count;
    }
View Full Code Here

    // over all old entries
  next_entry:
    for (int i=0; i < _table.length; i++)
    {
      L2Object obj = _table[i];
      if (obj == null)
        continue;
      final int hashcode = obj.getObjectId();
      int seed = hashcode;
      int incr = 1 + (((seed >> 5) + 1) % (newSize - 1));
      int ntry = 0;
      do
      {
View Full Code Here

TOP

Related Classes of net.sf.l2j.gameserver.model.L2Object

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.