Package com.l2jfrozen.gameserver.model

Examples of com.l2jfrozen.gameserver.model.L2Object


    }
    */

    _doorTable = DoorTable.getInstance();

    L2Object target2 = null;

    if(command.startsWith("admin_close ")) //id
    {
      try
      {
View Full Code Here


    int[] newCollisions = new int[newSize + 31 >> 5];

    // 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

  private void thinkPickUp()
  {
    if(_actor.isAllSkillsDisabled())
      return;

    final L2Object target = getTarget();
   
    if(checkTargetLost(target))
      return;

    if(maybeMoveToPawn(target, 36))
View Full Code Here

  private void thinkInteract()
  {
    if(_actor.isAllSkillsDisabled())
      return;

    final L2Object target = getTarget();
   
    if(checkTargetLost(target))
      return;

    if(maybeMoveToPawn(target, 36))
View Full Code Here

              {
                _actor.setTarget(_actor);
              }
            }

            L2Object OldTarget = _actor.getTarget();

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

            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(originalAttackTarget, range);

      return;
    }
    // Else, if this is close enough to attack
    _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))
        {
          if(sk.getSkillType() == L2Skill.SkillType.BUFF || sk.getSkillType() == L2Skill.SkillType.HEAL)
          {
            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;
                }
              }

              effects = null;
            }
            if(useSkillSelf)
            {
              _actor.setTarget(_actor);
            }
          }
          // GeoData Los Check here
          if(!useSkillSelf && !GeoData.getInstance().canSeeTarget(_actor, _actor.getTarget()))
            return;

          L2Object OldTarget = _actor.getTarget();

          clientStopMoving(null);
          _accessor.doCast(sk);
          _actor.setTarget(OldTarget);
          OldTarget = null;
View Full Code Here

    if(DEBUG)
    {
      int cnt = 0;
      for(int i = 0; i < _table.length; i++)
      {
        L2Object obj = _table[i];
        if(obj == null)
        {
          assert _keys[i] == 0 || _keys[i] == 0x80000000;
        }
        else
        {
          cnt++;
          assert obj.getObjectId() == (_keys[i] & 0x7FFFFFFF);
        }
      }
      assert cnt == _count;
    }
  }
View Full Code Here

    int[] newKeys = new int[newSize];

    // 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 = _keys[i] & 0x7FFFFFFF;
      if(Config.ASSERT)
      {
        assert hashcode == obj.getObjectId();
      }
      int seed = hashcode;
      int incr = 1 + ((seed >> 5) + 1) % (newSize - 1);
      int ntry = 0;
      do
View Full Code Here

    if(targetList.size() == 0)
      return true;

    // Choosing randomly a new target
    int nextTargetIdx = Rnd.nextInt(targetList.size());
    L2Object target = targetList.get(nextTargetIdx);

    // Attacking the target
    //getEffected().setTarget(target);
    getEffected().setTarget(target);
    getEffected().getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
View Full Code Here

              if(!GeoData.getInstance().canSeeTarget(_actor, cha))
              {
                break;
              }

              L2Object OldTarget = _actor.getTarget();
              _actor.setTarget(cha);
              clientStopMoving(null);
              _accessor.doCast(sk);
              _actor.setTarget(OldTarget);
              return;
            }
          }
        }
        continue;
      }

      L2NpcInstance npc = (L2NpcInstance) cha;

      if(!faction_id.equalsIgnoreCase(npc.getFactionId()))
      {
        continue;
      }

      if(npc.getAI() != null) // TODO: possibly check not needed
      {
        if(!npc.isDead() && Math.abs(target.getZ() - npc.getZ()) < 600
        //&& _actor.getAttackByList().contains(getAttackTarget())
        && (npc.getAI().getIntention() == CtrlIntention.AI_INTENTION_IDLE || npc.getAI().getIntention() == CtrlIntention.AI_INTENTION_ACTIVE)
        //limiting aggro for siege guards
        && target.isInsideRadius(npc, 1500, true, false) && GeoData.getInstance().canSeeTarget(npc, target))
        {
          // Notify the L2Object AI with EVT_AGGRESSION
          L2CharacterAI ai = npc.getAI();
          if(ai!=null)
            ai.notifyEvent(CtrlEvent.EVT_AGGRESSION, getAttackTarget(), 1);
        }
        // heal friends
        if(/*_selfAnalysis.hasHealOrResurrect && */!_actor.isAttackingDisabled() && npc.getCurrentHp() < npc.getMaxHp() * 0.6 && _actor.getCurrentHp() > _actor.getMaxHp() / 2 && _actor.getCurrentMp() > _actor.getMaxMp() / 2 && npc.isInCombat())
        {
          for(L2Skill sk : /* _selfAnalysis.healSkills*/healSkills)
          {
            if(_actor.getCurrentMp() < sk.getMpConsume())
            {
              continue;
            }
            if(_actor.isSkillDisabled(sk.getId()))
            {
              continue;
            }
            if(!Util.checkIfInRange(sk.getCastRange(), _actor, npc, true))
            {
              continue;
            }

            int chance = 4;
            if(chance >= Rnd.get(100))
            {
              continue;
            }
            if(!GeoData.getInstance().canSeeTarget(_actor, npc))
            {
              break;
            }

            L2Object OldTarget = _actor.getTarget();
            _actor.setTarget(npc);
            clientStopMoving(null);
            _accessor.doCast(sk);
            _actor.setTarget(OldTarget);
            return;
View Full Code Here

        int castRange = sk.getCastRange();

        if(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() == SkillType.BUFF || sk.getSkillType() == SkillType.HEAL)
          {
            boolean useSkillSelf = true;
            if(sk.getSkillType() == SkillType.HEAL && _actor.getCurrentHp() > (int) (_actor.getMaxHp() / 1.5))
            {
              useSkillSelf = false;
              break;
            }
            if(sk.getSkillType() == 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.getSpawn().getLocx();
        double homeY = attackTarget.getY() - sGuard.getSpawn().getLocy();

        // Check if the L2SiegeGuardInstance isn't too far from it's home location
        if(dx * dx + dy * dy > 10000 && homeX * homeX + homeY * homeY > 3240000 && _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 GeoClient checks and AI modification
          if(dz * dz < 170 * 170) // normally 130 if guard z coordinates correct
          {
            //if (_selfAnalysis.isMage)
            //  range = _selfAnalysis.maxCastRange - 50;
            if(_actor.getWalkSpeed() <= 0)
              return;
            if(attackTarget.isMoving())
            {
              moveToPawn(attackTarget, range - 70);
            }
            else
            {
              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 * range)
    {
      // Temporary hack for preventing guards jumping off towers,
      // before replacing this with effective GeoClient checks and AI modification
      double dz = _actor.getZ() - attackTarget.getZ();
      if(dz * dz < 170 * 170) // normally 130 if guard z coordinates correct
      {
        //if (_selfAnalysis.isMage)
        //  range = _selfAnalysis.maxCastRange - 50;
        if(_actor.getWalkSpeed() <= 0)
          return;
        if(attackTarget.isMoving())
        {
          moveToPawn(attackTarget, range - 70);
        }
        else
        {
          moveToPawn(attackTarget, range);
        }
      }
      return;
    }
    // Else, if this is close enough to attack
    else if(dist_2 <= range * range)
    {
      // Force mobs to attack 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 && !sk.isPassive() && _actor.getCurrentMp() >= _actor.getStat().getMpConsume(sk) && !_actor.isSkillDisabled(sk.getId()))
          {
            L2Object OldTarget = _actor.getTarget();
            if(sk.getSkillType() == SkillType.BUFF || sk.getSkillType() == SkillType.HEAL)
            {
              boolean useSkillSelf = true;
              if(sk.getSkillType() == SkillType.HEAL && _actor.getCurrentHp() > (int) (_actor.getMaxHp() / 1.5))
              {
View Full Code Here

TOP

Related Classes of com.l2jfrozen.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.