Package net.sf.l2j.gameserver.model

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


        for(int index = 0;index < targets.length;index++)
        {
            if (!(targets[index] instanceof L2Attackable))
              continue;
          L2Attackable target = (L2Attackable)targets[index];
          L2Attackable.RewardItem[] items = null;
            boolean isSweeping = false;
          synchronized (target) {
            if (target.isSweepActive())
            {
              items = target.takeSweep();
              isSweeping = true;
            }
          }
            if (isSweeping)
            {
        if (items == null || items.length == 0)
          continue;
        for (L2Attackable.RewardItem ritem : items)
        {
          if (player.isInParty())
            player.getParty().distributeItem(player, ritem, true, target);
          else
          {
            L2ItemInstance item = player.getInventory().addItem("Sweep", ritem.getItemId(), ritem.getCount(), player, target);
            if (iu != null) iu.addItem(item);
            send = true;

            SystemMessage smsg;
            if (ritem.getCount() > 1)
            {
              smsg = new SystemMessage(SystemMessageId.EARNED_S2_S1_S); // earned $s2$s1
              smsg.addItemName(ritem.getItemId());
                            smsg.addNumber(ritem.getCount());
            }
            else
            {
              smsg = new SystemMessage(SystemMessageId.EARNED_ITEM); // earned $s1
              smsg.addItemName(ritem.getItemId());
            }
            player.sendPacket(smsg);
          }
        }
            }
            target.endDecayTask();

        if (send)
        {
                if (iu != null)
                  player.sendPacket(iu);
View Full Code Here


                  // these skills needs to be rechecked
                  if (Formulas.getInstance().calcSkillSuccess(activeChar, target, skill, ss, sps, bss))
                  {
                    if (target instanceof L2Attackable)
                    {
                        L2Attackable targ = (L2Attackable)target;
                      targ.stopHating(activeChar);
                        if (targ.getMostHated() == null)
                            {
                               ((L2AttackableAI)targ.getAI()).setGlobalAggro(-25);
                            targ.clearAggroList();
                            targ.getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
                            targ.setWalking();
                            }
                        }
                      skill.getEffects(activeChar, target);
                    }
                  else
View Full Code Here

        if (intention == AI_INTENTION_IDLE /*|| intention == AI_INTENTION_ACTIVE*/) // active becomes idle if only a summon is present
        {
            // Check if actor is not dead
            if (!_actor.isAlikeDead())
            {
                L2Attackable npc = (L2Attackable) _actor;

                // If its _knownPlayer isn't empty set the Intention to AI_INTENTION_ACTIVE
                if (npc.getKnownList().getKnownPlayers().size() > 0) intention = AI_INTENTION_ACTIVE;
                else intention = AI_INTENTION_IDLE;
            }

            if (intention == AI_INTENTION_IDLE)
            {
View Full Code Here

     * <li>If the actor  can't attack, order to it to return to its home location</li>
     *
     */
    private void thinkActive()
    {
        L2Attackable npc = (L2Attackable) _actor;

        // Update every 1s the _globalAggro counter to come close to 0
        if (_globalAggro != 0)
        {
            if (_globalAggro < 0) _globalAggro++;
            else _globalAggro--;
        }

        // Add all autoAttackable L2Character in L2Attackable Aggro Range to its _aggroList with 0 damage and 1 hate
        // A L2Attackable isn't aggressive during 10s after its spawn because _globalAggro is set to -10
        if (_globalAggro >= 0)
        {
            for (L2Character target : npc.getKnownList().getKnownCharactersInRadius(_attackRange))
            {
                if (target == null) continue;
                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 = _attackTarget; // Force mobs to attak anybody if confused
            else hated = npc.getMostHated();

            // Order to the L2Attackable to attack the target
            if (hated != null)
            {
                // Get the hate level of the L2Attackable against this L2Character target contained in _aggroList
                int aggro = npc.getHating(hated);

                if (aggro + _globalAggro > 0)
                {
                    // Set the L2Character movement type to run and send Server->Client packet ChangeMoveType to all others L2PcInstance
                    if (!_actor.isRunning()) _actor.setRunning();
View Full Code Here

            || _attackTimeout < GameTimeController.getGameTicks())
        {
            // Stop hating this target after the attack timeout or if target is dead
            if (_attackTarget != null)
            {
                L2Attackable npc = (L2Attackable) _actor;
                npc.stopHating(_attackTarget);
            }

            // Cancel target and timeout
            _attackTimeout = Integer.MAX_VALUE;
            _attackTarget = null;
View Full Code Here

     */
    @Override
  protected void onEvtAggression(L2Character target, int aggro)
    {
        if (_actor == null) return;
        L2Attackable me = (L2Attackable) _actor;

        if (target != null)
        {
            // Add the target to the actor _aggroList or update hate if already present
            me.addDamageHate(target, 0, aggro);

            // Get the hate of the actor against the target
            aggro = me.getHating(target);

            if (aggro <= 0)
            {
              if (me.getMostHated() == null)
              {
                _globalAggro = -25;
                me.clearAggroList();
                setIntention(AI_INTENTION_IDLE, null, null);
              }
            return;
            }

            // Set the actor AI Intention to AI_INTENTION_ATTACK
            if (getIntention() != CtrlIntention.AI_INTENTION_ATTACK)
            {
                // Set the L2Character movement type to run and send Server->Client packet ChangeMoveType to all others L2PcInstance
                if (!_actor.isRunning()) _actor.setRunning();

                L2SiegeGuardInstance sGuard = (L2SiegeGuardInstance) _actor;
                double homeX = target.getX() - sGuard.getHomeX();
                double homeY = target.getY() - sGuard.getHomeY();

                // Check if the L2SiegeGuardInstance is not too far from its home location
                if (homeX * homeX + homeY * homeY < 3240000) // 1800 * 1800
                    setIntention(CtrlIntention.AI_INTENTION_ATTACK, target, null);
            }
        }
        else
        {
          // currently only for setting lower general aggro
          if(aggro >= 0) return;

          L2Character mostHated = me.getMostHated();
          if (mostHated == null)
          {
            _globalAggro = -25;
            return;
          }
         
      for(L2Character aggroed : me.getAggroListRP().keySet())
        me.addDamageHate(aggroed, 0, aggro);

          aggro = me.getHating(mostHated);
          if (aggro <= 0)
            {
            _globalAggro = -25;
            me.clearAggroList();
            setIntention(AI_INTENTION_IDLE, null, null);
            }
        }
    }
View Full Code Here

  private L2Character _forcedTarget;
    private MobGroup _targetGroup;

  protected void thinkFollow()
    {
    L2Attackable me = (L2Attackable)_actor;

    if (!Util.checkIfInRange(MobGroupTable.FOLLOW_RANGE, me, getForcedTarget(), true))
        {
      int signX = (Rnd.nextInt(2) == 0) ? -1 : 1;
      int signY = (Rnd.nextInt(2) == 0) ? -1 : 1;
View Full Code Here

    }
  }

  protected void thinkCast()
    {
    L2Attackable npc = (L2Attackable)_actor;

    if (getAttackTarget() == null || getAttackTarget().isAlikeDead())
        {
            setAttackTarget(findNextRndTarget());
      clientStopMoving(null);
    }

    if (getAttackTarget() == null)
      return;

    npc.setTarget(getAttackTarget());

    L2Skill[] skills = null;
    //double dist2 = 0;

    try {
View Full Code Here

    if (getAttackTarget() == null || getAttackTarget().isAlikeDead())
        {
      if (getAttackTarget() != null)
            {
        // stop hating
        L2Attackable npc = (L2Attackable) _actor;
        npc.stopHating(getAttackTarget());
      }

      setIntention(AI_INTENTION_ACTIVE);
    }
        else
        {
      // notify aggression
      if (((L2NpcInstance) _actor).getFactionId() != null)
            {
        String faction_id = ((L2NpcInstance) _actor).getFactionId();

        for (L2Object obj : _actor.getKnownList().getKnownObjects().values())
                {
                    if (!(obj instanceof L2NpcInstance))
                        continue;

                    L2NpcInstance npc = (L2NpcInstance) obj;

                    if (faction_id != npc.getFactionId())
                        continue;

                    if (_actor.isInsideRadius(npc, npc.getFactionRange(), false, true)
                            && Math.abs(getAttackTarget().getZ() - npc.getZ()) < 200)
                    {
                        npc.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, getAttackTarget(), 1);
                    }
        }
      }

      L2Skill[] skills = null;
View Full Code Here

  }

  private boolean autoAttackCondition(L2Character target)
    {
    if (target == null || !(_actor instanceof L2Attackable)) return false;
    L2Attackable me = (L2Attackable)_actor;

    if (target instanceof L2FolkInstance
        || target instanceof L2DoorInstance)
      return false;

    if (target.isAlikeDead()
        || !me.isInsideRadius(target, me.getAggroRange(), false, false)
        || Math.abs(_actor.getZ() - target.getZ()) > 100)
      return false;

        // Check if the target isn't invulnerable
        if (target.isInvul())
            return false;

        // Check if the target is a L2PcInstance
        if (target instanceof L2PcInstance)
        {

            // Check if the target isn't in silent move mode
            if (((L2PcInstance)target).isSilentMoving())
                return false;
        }

        if (target instanceof L2NpcInstance)
          return false;

        return me.isAggressive();
  }
View Full Code Here

TOP

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

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.