Package net.sf.l2j.gameserver.model

Examples of net.sf.l2j.gameserver.model.L2Character$HitTask


    }
  }

  protected void thinkAttackGroup()
    {
    L2Character target = getForcedTarget();
    if (target == null || target.isAlikeDead())
        {
      // try to get next group target
      setForcedTarget(findNextGroupTarget());
      clientStopMoving(null);
    }

    if (target == null)
      return;

    L2Skill[] skills = null;
    double dist2 = 0;
    int range = 0;
    int max_range = 0;

    _actor.setTarget(target);
    // as a response, we put the target in a forcedattack mode
    L2ControllableMobInstance theTarget = (L2ControllableMobInstance)target;
    L2ControllableMobAI ctrlAi = (L2ControllableMobAI)theTarget.getAI();
    ctrlAi.forceAttack(_actor);

    try {
      skills = _actor.getAllSkills();
      dist2 = _actor.getPlanDistanceSq(target.getX(), target.getY());
      range = _actor.getPhysicalAttackRange() + _actor.getTemplate().collisionRadius + target.getTemplate().collisionRadius;
      max_range = range;
    }
        catch (NullPointerException e) {
      _log.warning("Encountered Null Value.");
      e.printStackTrace();
View Full Code Here


        moveToPawn(getAttackTarget(), range);
        return;
      }

            // Force mobs to attack anybody if confused.
      L2Character hated;

      if (_actor.isConfused())
        hated = findNextRndTarget();
      else
        hated = getAttackTarget();
View Full Code Here

  }

  private void thinkActive()
    {
        setAttackTarget(findNextRndTarget());
    L2Character hated;

    if (_actor.isConfused())
      hated = findNextRndTarget();
    else
      hated = getAttackTarget();
View Full Code Here

            dy      = npcY - targetY;

            if (dx*dx + dy*dy > dblAggroRange)
                continue;

      L2Character target = (L2Character) obj;

            if (autoAttackCondition(target)) // check aggression
        potentialTarget.add(target);
    }

    if (potentialTarget.size() == 0) // nothing to do
      return null;

    // we choose a random target
    int choice = Rnd.nextInt(potentialTarget.size());
    L2Character target = potentialTarget.get(choice);

    return target;
  }
View Full Code Here

        super.clientNotifyDead();
    }

    private void thinkAttack()
    {
      L2Character target = getAttackTarget();
      if (target == null)
        return;
        if (checkTargetLostOrDead(target))
        {
          //Notify the target
View Full Code Here

    }

    private void thinkCast()
    {

      L2Character target = getCastTarget();
        //if (Config.DEBUG) _log.warning("L2PlayerAI: thinkCast -> Start");

        if (checkTargetLost(target))
        {
            if (_skill.isOffensive() && getAttackTarget() != null)
View Full Code Here

        //boolean blessedScroll = (itemId != 737);
        boolean humanScroll = (itemId == 3936 || itemId == 3959 || itemId == 737);
        boolean petScroll = (itemId == 6387 || itemId == 737);

        // SoR Animation section
        L2Character target = (L2Character)activeChar.getTarget();

        if (target != null && target.isDead())
        {
            L2PcInstance targetPlayer = null;

            if (target instanceof L2PcInstance)
              targetPlayer = (L2PcInstance)target;
View Full Code Here

            //L2Object[] objects = L2World.getInstance().getVisibleObjects(_actor, ((L2NpcInstance)_actor).getAggroRange());
            // Go through visible objects
            for (L2Object obj : npc.getKnownList().getKnownObjects().values())
            {
                if (obj == null || !(obj instanceof L2Character)) continue;
                L2Character target = (L2Character) obj;

                /*
                 * Check to see if this is a festival mob spawn.
                 * If it is, then check to see if the aggro trigger
                 * is a festival participant...if so, move to attack it.
                 */
                if ((_actor instanceof L2FestivalMonsterInstance) && obj instanceof L2PcInstance)
                {
                    L2PcInstance targetPlayer = (L2PcInstance) obj;

                    if (!(targetPlayer.isFestivalParticipant())) continue;
                }

                // For each L2Character check if the target is autoattackable
                if (autoAttackCondition(target)) // check aggression
                {
                    // Get the hate level of the L2Attackable against this L2Character target contained in _aggroList
                    int hating = npc.getHating(target);

                    // Add the attacker to the L2Attackable _aggroList with 0 damage and 1 hate
                    if (hating == 0) npc.addDamageHate(target, 0, 1);
                }
            }

            // Chose a target from its aggroList
            L2Character hated;
            if (_actor.isConfused()) hated = getAttackTarget(); // Force mobs to attak anybody if confused
            else hated = npc.getMostHated();

            // Order to the L2Attackable to attack the target
            if (hated != null)
View Full Code Here

                    }
                }
            }

            // Force mobs to attack anybody if confused
            L2Character hated;
            if (_actor.isConfused()) hated = getAttackTarget();
            else hated = ((L2Attackable) _actor).getMostHated();

            if (hated == null)
            {
                setIntention(AI_INTENTION_ACTIVE);
                return;
            }
            if (hated != getAttackTarget())
            {
                setAttackTarget(hated);
            }
            // We should calculate new distance cuz mob can have changed the target
            dist2 = _actor.getPlanDistanceSq(hated.getX(), hated.getY());

            if (hated.isMoving()) range += 50;
            // Check if the actor isn't far from target
            if (dist2 > range*range)
            {
                // check for long ranged skills and heal/buff skills
                if (!_actor.isMuted() &&
                  (!Config.ALT_GAME_MOB_ATTACK_AI || (_actor instanceof L2MonsterInstance && Rnd.nextInt(100) <= 5))
                   )
                    for (L2Skill sk : skills)
                    {
                        int castRange = sk.getCastRange();

                        if (((sk.getSkillType() == L2Skill.SkillType.BUFF || sk.getSkillType() == L2Skill.SkillType.HEAL) || (dist2 >= castRange * castRange / 9.0)
                            && (dist2 <= castRange * castRange) && (castRange > 70))
                            && !_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
            {
View Full Code Here

          int radius  = Integer.parseInt(player);
          for (L2Object object : activeChar.getKnownList().getKnownObjects().values())
          {
            if (object instanceof L2Character)
            {
              L2Character character = (L2Character) object;
              character.setCurrentHpMp(character.getMaxHp(), character.getMaxMp());
              if ( object instanceof L2PcInstance ) character.setCurrentCp(character.getMaxCp());
            }
          }
          activeChar.sendMessage("Healed within " + radius + " unit radius.");
          return;
        }
        catch (NumberFormatException nbe) {}
      }
    }
    if (obj == null)
      obj = activeChar;
    if (obj instanceof L2Character)
    {
      L2Character target = (L2Character)obj;
      target.setCurrentHpMp(target.getMaxHp(), target.getMaxMp());
      if ( target instanceof L2PcInstance )
        target.setCurrentCp(target.getMaxCp());
      if (Config.DEBUG)
        _log.fine("GM: "+activeChar.getName()+"("+activeChar.getObjectId()+") healed character "+target.getName());
    }
    else
      activeChar.sendPacket(new SystemMessage(SystemMessageId.INCORRECT_TARGET));
  }
View Full Code Here

TOP

Related Classes of net.sf.l2j.gameserver.model.L2Character$HitTask

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.