コード例 #1
0
ファイル: NpcWarriorAI.java プロジェクト: teeelle/l2jeuropa
  private boolean startAttack() {
    NpcInstance actor = getActor();
    if (target == null) {
      List<NpcInstance> around = actor.getAroundNpc(3000, 150);
      if (around != null && !around.isEmpty()) {
        for (NpcInstance npc : around) {
          if (checkTarget(npc)) {
            if (target == null || actor.getDistance3D(npc) < actor.getDistance3D(target)) {
              target = npc;
            }
          }
        }
      }
    }

    if (target != null
        && !actor.isAttackingNow()
        && !actor.isCastingNow()
        && !target.isDead()
        && GeoEngine.canSeeTarget(actor, target, false)
        && target.isVisible()) {
      actor.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, target, 1);
      return true;
    }

    if (target != null
        && (!target.isVisible()
            || target.isDead()
            || !GeoEngine.canSeeTarget(actor, target, false))) {
      target = null;
      return false;
    }

    return false;
  }
コード例 #2
0
ファイル: FrostBuffalo.java プロジェクト: teeelle/l2jeuropa
 /**
  * Method onEvtSeeSpell.
  *
  * @param skill Skill
  * @param caster Creature
  */
 @Override
 protected void onEvtSeeSpell(Skill skill, Creature caster) {
   final NpcInstance actor = getActor();
   if (skill.isMagic()) {
     return;
   }
   if (_mobsNotSpawned) {
     _mobsNotSpawned = false;
     for (int i = 0; i < MOBS_COUNT; i++) {
       try {
         SimpleSpawner sp = new SimpleSpawner(NpcHolder.getInstance().getTemplate(MOBS));
         sp.setLoc(Location.findPointToStay(actor, 100, 120));
         NpcInstance npc = sp.doSpawn(true);
         if (caster.isPet() || caster.isServitor()) {
           npc.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, caster, Rnd.get(2, 100));
         }
         npc.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, caster.getPlayer(), Rnd.get(1, 100));
       } catch (Exception e) {
         e.printStackTrace();
       }
     }
   }
 }
コード例 #3
0
ファイル: Zofan29.java プロジェクト: teeelle/l2jeuropa
 @Override
 protected boolean thinkActive() {
   NpcInstance actor = getActor();
   if (actor.isDead()) {
     return false;
   }
   List<NpcInstance> around = actor.getAroundNpc(800, 500);
   if ((around != null) && (!around.isEmpty())) {
     for (NpcInstance npc : around) {
       if (npc.getNpcId() == 51030) {
         actor.getAI().notifyEvent(CtrlEvent.EVT_ATTACKED, npc, Integer.valueOf(500));
       }
     }
   }
   return true;
 }
コード例 #4
0
ファイル: ArtefactAI.java プロジェクト: Hl4p3x/mobius-source
    /** Method runImpl. */
    @Override
    public void runImpl() {
      final NpcInstance actor = (NpcInstance) getActor();
      final Player attacker = _playerRef.get();

      if ((attacker == null) || (actor == null)) {
        return;
      }

      for (NpcInstance npc : actor.getAroundNpc(1500, 200)) {
        if (npc.isSiegeGuard() && Rnd.chance(20)) {
          npc.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, attacker, 5000);
        }
      }

      if ((attacker.getCastingSkill() != null)
          && (attacker.getCastingSkill().getTargetType() == Skill.SkillTargetType.TARGET_HOLY)) {
        ThreadPoolManager.getInstance().schedule(this, 10000);
      }
    }
コード例 #5
0
  /** Method thinkAttack. */
  @Override
  protected void thinkAttack() {
    final NpcInstance actor = getActor();
    final NpcInstance brother = getBrother();

    if (!brother.isDead() && !actor.isInRange(brother, 300)) {
      actor.altOnMagicUseTimer(getActor(), SkillTable.getInstance().getInfo(6371, 1));
    } else {
      removeInvul(actor);
    }

    if ((_spawnTimer + 40000) < System.currentTimeMillis()) {
      _spawnTimer = System.currentTimeMillis();
      final NpcInstance mob =
          actor
              .getReflection()
              .addSpawnWithoutRespawn(
                  _minions[Rnd.get(_minions.length)], Location.findAroundPosition(actor, 300), 0);
      mob.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, actor.getAggressionTarget(), 1000);
    }

    super.thinkAttack();
  }
コード例 #6
0
 @Override
 public void run() {
   _npc.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, player, Integer.valueOf(150));
   checkInRadius(32764, st, _npc);
 }