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

    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
ファイル: RequestDispel.java プロジェクト: teeelle/l2jeuropa
 /** Method runImpl. */
 @Override
 protected void runImpl() {
   Player activeChar = getClient().getActiveChar();
   Creature target = activeChar;
   if (activeChar == null) {
     return;
   }
   if (activeChar.getObjectId() != _objectId) {
     for (Summon summon : activeChar.getSummonList()) {
       if (summon.getObjectId() == _objectId) {
         target = summon;
         break;
       }
     }
     if (target == null) {
       return;
     }
   }
   for (Effect e : target.getEffectList().getAllEffects()) {
     if ((e.getDisplayId() == _id) && (e.getDisplayLevel() == _level)) {
       if (!e.isOffensive()
           && !e.getSkill().isMusic()
           && e.getSkill().isSelfDispellable()
           && (e.getSkill().getSkillType() != SkillType.TRANSFORMATION)
           && (e.getTemplate().getEffectType() != EffectType.Hourglass)) {
         e.exit();
       } else {
         return;
       }
     }
   }
 }
コード例 #3
0
  /**
   * Method onEvtClanAttacked.
   *
   * @param attacked_member Creature
   * @param attacker Creature
   * @param damage int
   */
  @Override
  protected void onEvtClanAttacked(Creature attacked_member, Creature attacker, int damage) {
    super.onEvtClanAttacked(attacked_member, attacker, damage);
    final NpcInstance actor = getActor();

    if (_healSkills.length == 0) {
      return;
    }

    if (attacked_member.isDead()
        || actor.isDead()
        || (attacked_member.getCurrentHpPercents() > 50)) {
      return;
    }

    int heal_chance = 0;

    if (attacked_member.getId() == actor.getId()) {
      heal_chance = (attacked_member.getObjectId() == actor.getObjectId()) ? 100 : 0;
    } else {
      heal_chance = (attacked_member.getId() == Orfen_id) ? 90 : 10;
    }

    if (Rnd.chance(heal_chance) && canUseSkill(_healSkills[0], attacked_member, -1)) {
      addTaskAttack(attacked_member, _healSkills[0], 1000000);
    }
  }
コード例 #4
0
  /**
   * Method isAttackable.
   *
   * @param attacker Creature
   * @return boolean
   */
  @Override
  public boolean isAttackable(Creature attacker) {
    if ((attacker == null) || isOpen()) {
      return false;
    }

    SiegeEvent<?, ?> siegeEvent = getEvent(SiegeEvent.class);

    switch (getDoorType()) {
      case WALL:
        if (!attacker.isSummon()
            || (siegeEvent == null)
            || !siegeEvent.containsSiegeSummon((SummonInstance) attacker)) {
          return false;
        }
        break;

      case DOOR:
        Player player = attacker.getPlayer();

        if (player == null) {
          return false;
        }

        if (siegeEvent != null) {
          if (siegeEvent.getSiegeClan(SiegeEvent.DEFENDERS, player.getClan()) != null) {
            return false;
          }
        }
        break;
    }

    return !isInvul();
  }
コード例 #5
0
ファイル: DuelEvent.java プロジェクト: teeelle/l2jeuropa
  /**
   * Method canAttack.
   *
   * @param target Creature
   * @param attacker Creature
   * @param skill Skill
   * @param force boolean
   * @return boolean
   */
  @Override
  public boolean canAttack(Creature target, Creature attacker, Skill skill, boolean force) {
    if ((target.getTeam() == TeamType.NONE)
        || (attacker.getTeam() == TeamType.NONE)
        || (target.getTeam() == attacker.getTeam())) {
      return false;
    }

    DuelEvent duelEvent = target.getEvent(DuelEvent.class);
    return !((duelEvent == null) || (duelEvent != this));
  }
コード例 #6
0
    @Override
    public void onDeath(final Creature self, final Creature killer) {
      if (self.isNpc() && (self.getId() == NOKTUM)) {
        self.broadcastPacketToOthers(
            new ExShowScreenMessage(
                NpcString.GHOST_OF_HARNAK_CAN_ONLY_BE_HIT_NEAR_SOUL_CIRCLE,
                5000,
                ExShowScreenMessage.ScreenMessageAlign.BOTTOM_CENTER,
                true,
                ExShowScreenMessage.STRING_TYPE,
                0,
                false,
                0));
        self.removeListener(_deathListener);
      }

      if (self.isNpc() && (self.getId() == DEMONIC_NOKTUM)) {
        self.broadcastPacketToOthers(
            new ExShowScreenMessage(
                NpcString.GHOST_OF_HARNAK_CAN_ONLY_BE_HIT_NEAR_SOUL_CIRCLE,
                5000,
                ExShowScreenMessage.ScreenMessageAlign.BOTTOM_CENTER,
                true,
                ExShowScreenMessage.STRING_TYPE,
                0,
                false,
                0));
        self.removeListener(_deathListener);
      }
    }
コード例 #7
0
  /**
   * Method onEvtAttacked.
   *
   * @param attacker Creature
   * @param damage int
   */
  @Override
  public void onEvtAttacked(Creature attacker, int damage) {
    final NpcInstance actor = getActor();
    super.onEvtAttacked(attacker, damage);

    if ((PositionUtils.calculateDistance(attacker, actor, false) > 300.) && Rnd.chance(0.13)) {
      addTaskCast(attacker, DRAIN_SKILL);
    }

    final Creature target = actor.getAggroList().getMostHated();

    if ((target.equals(attacker)) && Rnd.chance(0.3)) {
      addTaskCast(attacker, DAMAGE_SKILL);
    }
  }
コード例 #8
0
ファイル: DuelEvent.java プロジェクト: teeelle/l2jeuropa
  /**
   * Method checkForAttack.
   *
   * @param target Creature
   * @param attacker Creature
   * @param skill Skill
   * @param force boolean
   * @return SystemMsg
   */
  @Override
  public SystemMsg checkForAttack(Creature target, Creature attacker, Skill skill, boolean force) {
    if ((target.getTeam() == TeamType.NONE)
        || (attacker.getTeam() == TeamType.NONE)
        || (target.getTeam() == attacker.getTeam())) {
      return SystemMsg.INVALID_TARGET;
    }

    DuelEvent duelEvent = target.getEvent(DuelEvent.class);
    if ((duelEvent == null) || (duelEvent != this)) {
      return SystemMsg.INVALID_TARGET;
    }

    return null;
  }
コード例 #9
0
  /**
   * Method reduceCurrentHp.
   *
   * @param damage double
   * @param reflectableDamage double
   * @param attacker Creature
   * @param skill Skill
   * @param awake boolean
   * @param standUp boolean
   * @param directHp boolean
   * @param canReflect boolean
   * @param transferDamage boolean
   * @param isDot boolean
   * @param sendMessage boolean
   */
  @Override
  public void reduceCurrentHp(
      double damage,
      double reflectableDamage,
      Creature attacker,
      Skill skill,
      boolean awake,
      boolean standUp,
      boolean directHp,
      boolean canReflect,
      boolean transferDamage,
      boolean isDot,
      boolean sendMessage) {
    if (_massiveDamage > System.currentTimeMillis()) {
      damage = 10000;
    } else if (getCurrentHpPercents() > 50) {
      if (attacker.isPlayer()) {
        damage = ((damage / getMaxHp()) / 0.05) * 100;
      } else {
        damage = ((damage / getMaxHp()) / 0.05) * 10;
      }
    } else if (getCurrentHpPercents() > 30) {
      if (Rnd.chance(90)) {
        if (attacker.isPlayer()) {
          damage = ((damage / getMaxHp()) / 0.05) * 100;
        } else {
          damage = ((damage / getMaxHp()) / 0.05) * 10;
        }
      } else {
        _massiveDamage = System.currentTimeMillis() + 5000L;
      }
    } else {
      _massiveDamage = System.currentTimeMillis() + 5000L;
    }

    super.reduceCurrentHp(
        damage,
        reflectableDamage,
        attacker,
        skill,
        awake,
        standUp,
        directHp,
        canReflect,
        transferDamage,
        isDot,
        sendMessage);
  }
コード例 #10
0
ファイル: Dwarvs.java プロジェクト: Hl4p3x/mobius-source
  /**
   * Method checkAggression.
   *
   * @param target Creature
   * @return boolean
   */
  @Override
  public boolean checkAggression(Creature target) {
    if ((getIntention() != CtrlIntention.AI_INTENTION_ACTIVE) || !isGlobalAggro()) {
      return false;
    }

    if (target.isNpc() && !Util.contains(ATTACK_IDS, target.getId())) {
      return false;
    }

    if (!startBattle) {
      return false;
    }

    return super.checkAggression(target);
  }
コード例 #11
0
ファイル: Zofan29.java プロジェクト: teeelle/l2jeuropa
 @Override
 public boolean checkAggression(Creature target) {
   if (target.isPlayable()) {
     return false;
   }
   return super.checkAggression(target);
 }
コード例 #12
0
ファイル: Zofan29.java プロジェクト: teeelle/l2jeuropa
 @Override
 protected void onEvtAttacked(Creature attacker, int damage) {
   if ((attacker == null) || (attacker.isPlayable())) {
     return;
   }
   super.onEvtAttacked(attacker, damage);
 }
コード例 #13
0
ファイル: MonsterWarrior.java プロジェクト: teeelle/l2jeuropa
  private boolean checkTarget(Creature target) {
    if (target == null) return false;
    if (target.isPlayer()) return true;

    if (target.isNpc()) {
      NpcInstance npc = (NpcInstance) target;
      int _id = npc.getNpcId();
      if (_id == 27430
          || _id == 27431
          || _id == 27432
          || _id == 27433
          || _id == 27434
          || _id == 27425
          || _id == 33416) return false;
    }
    return true;
  }
コード例 #14
0
ファイル: FoundryWorker.java プロジェクト: teeelle/l2jeuropa
 /**
  * Method onEvtAttacked.
  *
  * @param attacker Creature
  * @param damage int
  */
 @Override
 protected void onEvtAttacked(Creature attacker, int damage) {
   final NpcInstance actor = getActor();
   if (attacker != null) {
     final Location pos = Location.findPointToStay(actor, 150, 250);
     if (GeoEngine.canMoveToCoord(
         attacker.getX(),
         attacker.getY(),
         attacker.getZ(),
         pos.x,
         pos.y,
         pos.z,
         actor.getGeoIndex())) {
       actor.setRunning();
       addTaskMove(pos, false);
     }
   }
 }
コード例 #15
0
  /** Method onDespawn. */
  @Override
  protected void onDespawn() {
    if (_autoActionTask != null) {
      _autoActionTask.cancel(false);
      _autoActionTask = null;
    }

    super.onDespawn();
  }
コード例 #16
0
 public ExFishingStartCombat(
     Creature character, int time, int hp, int mode, int lureType, int deceptiveMode) {
   char_obj_id = character.getObjectId();
   _time = time;
   _hp = hp;
   _mode = mode;
   _lureType = lureType;
   _deceptiveMode = deceptiveMode;
 }
コード例 #17
0
  /**
   * Method onDeath.
   *
   * @param killer Creature
   */
  @Override
  protected void onDeath(Creature killer) {
    _openLock.lock();

    try {
      setGeoOpen(true);
    } finally {
      _openLock.unlock();
    }
    super.onDeath(killer);
  }
コード例 #18
0
  /** Method onRevive. */
  @Override
  protected void onRevive() {
    super.onRevive();
    _openLock.lock();

    try {
      if (!isOpen()) {
        setGeoOpen(false);
      }
    } finally {
      _openLock.unlock();
    }
  }
コード例 #19
0
ファイル: TameControl.java プロジェクト: teeelle/l2jeuropa
 /**
  * Method useSkill.
  *
  * @param activeChar Creature
  * @param targets List<Creature>
  */
 @Override
 public void useSkill(Creature activeChar, List<Creature> targets) {
   if (isSSPossible()) {
     activeChar.unChargeShots(isMagic());
   }
   if (!activeChar.isPlayer()) {
     return;
   }
   Player player = activeChar.getPlayer();
   if (player.getTrainedBeasts() == null) {
     return;
   }
   if (_type == 0) {
     for (Creature target : targets) {
       if ((target != null) && (target instanceof TamedBeastInstance)) {
         if (player.getTrainedBeasts().get(target.getObjectId()) != null) {
           ((TamedBeastInstance) target).despawnWithDelay(1000);
         }
       }
     }
   } else if (_type > 0) {
     if (_type == 1) {
       for (TamedBeastInstance tamedBeast : player.getTrainedBeasts().values()) {
         tamedBeast
             .getAI()
             .setIntention(CtrlIntention.AI_INTENTION_FOLLOW, player, Config.FOLLOW_RANGE);
       }
     } else if (_type == 3) {
       for (TamedBeastInstance tamedBeast : player.getTrainedBeasts().values()) {
         tamedBeast.buffOwner();
       }
     } else if (_type == 4) {
       for (TamedBeastInstance tamedBeast : player.getTrainedBeasts().values()) {
         tamedBeast.doDespawn();
       }
     }
   }
 }
コード例 #20
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();
       }
     }
   }
 }
コード例 #21
0
ファイル: MDam.java プロジェクト: teeelle/l2jeuropa
 /**
  * Method useSkill.
  *
  * @param activeChar Creature
  * @param targets List<Creature>
  */
 @Override
 public void useSkill(Creature activeChar, List<Creature> targets) {
   int sps =
       isSSPossible()
           ? (isMagic()
               ? activeChar.getChargedSpiritShot()
               : activeChar.getChargedSoulShot() ? 2 : 0)
           : 0;
   Creature realTarget;
   boolean reflected;
   for (Creature target : targets) {
     if (target != null) {
       if (target.isDead()) {
         continue;
       }
       reflected = target.checkReflectSkill(activeChar, this);
       realTarget = reflected ? activeChar : target;
       Formulas.AttackInfo info = Formulas.calcMagicDam(activeChar, realTarget, this, sps);
       if (info.damage >= 1) {
         realTarget.reduceCurrentHp(
             info.damage,
             info.reflectableDamage,
             activeChar,
             this,
             true,
             true,
             false,
             true,
             false,
             false,
             true);
       }
       getEffects(activeChar, target, getActivateRate() > 0, false, reflected);
     }
   }
   if (isSuicideAttack()) {
     activeChar.doDie(null);
   } else if (isSSPossible()) {
     activeChar.unChargeShots(isMagic());
   }
 }
コード例 #22
0
ファイル: Dwarvs.java プロジェクト: Hl4p3x/mobius-source
  /**
   * Method canAttackCharacter.
   *
   * @param target Creature
   * @return boolean
   */
  @Override
  protected boolean canAttackCharacter(Creature target) {
    final NpcInstance actor = getActor();

    if (getIntention() == CtrlIntention.AI_INTENTION_ATTACK) {
      final AggroList.AggroInfo ai = actor.getAggroList().get(target);
      return (ai != null) && (ai.hate > 0);
    }

    if (!startBattle) {
      return false;
    }

    return Util.contains(ATTACK_IDS, target.getId());
  }
コード例 #23
0
ファイル: ArcanZone.java プロジェクト: teeelle/l2jeuropa
    @Override
    public void onZoneEnter(Zone zone, Creature cha) {
      if (zone == null) return;

      if (cha == null) return;

      if (cha instanceof Player) {
        Player player = cha.getPlayer();
        if (ArcanManager.getStage() == _RED) {
          player.sendPacket(new EventTrigger(_BLUE, false));
          player.sendPacket(new EventTrigger(_RED, true));
        } else {
          player.sendPacket(new EventTrigger(_RED, false));
          player.sendPacket(new EventTrigger(_BLUE, true));
        }
      }
    }
コード例 #24
0
 /**
  * Method clearArena.
  *
  * @param zoneName String
  */
 public void clearArena(String zoneName) {
   Zone zone = ReflectionUtils.getZone(zoneName);
   if (zone != null) {
     for (Creature cha : zone.getObjects()) {
       if (cha.isPlayer() && (cha.getPlayer().getBlockCheckerArena() < 0)) {
         cha.getPlayer().teleToClosestTown();
       } else if (cha.isNpc()) {
         cha.deleteMe();
       }
     }
   }
 }
コード例 #25
0
ファイル: ArtefactAI.java プロジェクト: Hl4p3x/mobius-source
  /**
   * Method onEvtAggression.
   *
   * @param attacker Creature
   * @param aggro int
   */
  @Override
  protected void onEvtAggression(Creature attacker, int aggro) {
    final NpcInstance actor = (NpcInstance) getActor();
    final Player player = attacker.getPlayer();

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

    final SiegeEvent<?, ?> siegeEvent1 = actor.getEvent(SiegeEvent.class);
    final SiegeEvent<?, ?> siegeEvent2 = player.getEvent(SiegeEvent.class);
    final SiegeClanObject siegeClan =
        siegeEvent1.getSiegeClan(SiegeEvent.ATTACKERS, player.getClan());

    if ((siegeEvent2 == null) || ((siegeEvent1.equals(siegeEvent2)) && (siegeClan != null))) {
      ThreadPoolManager.getInstance().schedule(new notifyGuard(player), 1000);
    }
  }
コード例 #26
0
ファイル: EpicZone.java プロジェクト: Hl4p3x/mobius-source
    /**
     * Method onZoneEnter.
     *
     * @param zone Zone
     * @param cha Creature
     * @see lineage2.gameserver.listener.zone.OnZoneEnterLeaveListener#onZoneEnter(Zone, Creature)
     */
    @Override
    public void onZoneEnter(Zone zone, Creature cha) {
      if ((zone.getParams() == null) || !cha.isPlayable() || cha.getPlayer().isGM()) {
        return;
      }

      if (cha.getLevel() > zone.getParams().getInteger("levelLimit")) {
        if (cha.isPlayer()) {
          cha.getPlayer()
              .sendMessage("Your level is too high to access this zone. You've been banished out.");
        }

        cha.teleToLocation(Location.parseLoc(zone.getParams().getString("tele")));
      }
    }
コード例 #27
0
 /** Method onSpawn. */
 @Override
 protected void onSpawn() {
   super.onSpawn();
   setCurrentHpMp(getMaxHp(), getMaxMp(), true);
   closeMe(null, true);
 }
コード例 #28
0
ファイル: ChargeSoul.java プロジェクト: Hl4p3x/mobius-source
  /**
   * Method useSkill.
   *
   * @param activeChar Creature
   * @param targets List<Creature>
   */
  @Override
  public void useSkill(Creature activeChar, List<Creature> targets) {
    if (!activeChar.isPlayer()) {
      return;
    }

    boolean ss = activeChar.getChargedSoulShot() && isSSPossible();

    if (ss && (getTargetType() != SkillTargetType.TARGET_SELF)) {
      activeChar.unChargeShots(false);
    }

    Creature realTarget;
    boolean reflected;

    for (Creature target : targets) {
      if (target != null) {
        if (target.isDead()) {
          continue;
        }

        reflected = (target != activeChar) && target.checkReflectSkill(activeChar, this);
        realTarget = reflected ? activeChar : target;

        if (getPower() > 0) {
          AttackInfo info =
              Formulas.calcPhysDam(activeChar, realTarget, this, false, false, ss, false);

          if (info.lethal_dmg > 0) {
            realTarget.reduceCurrentHp(
                info.lethal_dmg,
                info.reflectableDamage,
                activeChar,
                this,
                true,
                true,
                false,
                false,
                false,
                false,
                false);
          }

          realTarget.reduceCurrentHp(
              info.damage,
              info.reflectableDamage,
              activeChar,
              this,
              true,
              true,
              false,
              true,
              false,
              false,
              true);

          if (!reflected) {
            realTarget.doCounterAttack(this, activeChar, false);
          }
        }

        if (realTarget.isPlayable() || realTarget.isMonster()) {
          activeChar.setConsumedSouls(activeChar.getConsumedSouls() + _numSouls, null);
        }

        getEffects(activeChar, target, getActivateRate() > 0, false, reflected);
      }
    }

    if (isSSPossible()) {
      activeChar.unChargeShots(isMagic());
    }
  }
コード例 #29
0
ファイル: Aggression.java プロジェクト: Hl4p3x/mobius-source
  /**
   * Method useSkill.
   *
   * @param activeChar Creature
   * @param targets List<Creature>
   */
  @Override
  public void useSkill(Creature activeChar, List<Creature> targets) {
    int effect = _effectPoint;

    if (isSSPossible()
        && (activeChar.getChargedSoulShot() || (activeChar.getChargedSpiritShot() > 0))) {
      effect *= 2;
    }

    for (Creature target : targets) {
      if (target != null) {
        if (!target.isAutoAttackable(activeChar)) {
          continue;
        }

        if (target.isNpc()) {
          if (_unaggring) {
            if (target.isNpc() && activeChar.isPlayable()) {
              ((NpcInstance) target).getAggroList().addDamageHate(activeChar, 0, -effect);
            }
          } else {
            target.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, activeChar, effect);

            if (!_silent) {
              target.getAI().notifyEvent(CtrlEvent.EVT_ATTACKED, activeChar, 0);
            }
          }
        } else if (target.isPlayable() && !target.isDebuffImmune()) {
          target.setTarget(activeChar);
        }

        getEffects(activeChar, target, getActivateRate() > 0, false);
      }
    }

    if (isSSPossible()) {
      activeChar.unChargeShots(isMagic());
    }
  }
コード例 #30
0
 public NickNameChanged(Creature cha) {
   objectId = cha.getObjectId();
   title = cha.getTitle();
 }