@Override
  public String onSkillSee(
      L2Npc npc, L2PcInstance caster, L2Skill skill, L2Object[] targets, boolean isPet) {
    if (caster == null) {
      return null;
    }
    if (!(npc instanceof L2Attackable)) {
      return null;
    }

    L2Attackable attackable = (L2Attackable) npc;

    int skillAggroPoints = skill.getAggroPoints();

    if (caster.getPet() != null) {
      if (targets.length == 1 && contains(targets, caster.getPet())) skillAggroPoints = 0;
    }

    if (skillAggroPoints > 0) {
      if (attackable.hasAI() && (attackable.getAI().getIntention() == AI_INTENTION_ATTACK)) {
        L2Object npcTarget = attackable.getTarget();
        for (L2Object skillTarget : targets) {
          if (npcTarget == skillTarget || npc == skillTarget) {
            L2Character originalCaster = isPet ? caster.getPet() : caster;
            attackable.addDamageHate(
                originalCaster, 0, (skillAggroPoints * 150) / (attackable.getLevel() + 7));
          }
        }
      }
    }

    return null;
  }
Esempio n. 2
0
  /**
   * @see
   *     com.l2jserver.gameserver.handler.ISkillHandler#useSkill(com.l2jserver.gameserver.model.actor.L2Character,
   *     com.l2jserver.gameserver.model.L2Skill, com.l2jserver.gameserver.model.L2Object[])
   */
  public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets) {
    if (!(activeChar instanceof L2PcInstance)) return;

    final L2Object[] targetList = skill.getTargetList(activeChar);
    if (targetList == null || targetList.length == 0) return;

    if (Config.DEBUG) _log.info("Casting sow");

    L2MonsterInstance target;

    for (L2Object tgt : targetList) {
      if (!(tgt instanceof L2MonsterInstance)) continue;

      target = (L2MonsterInstance) tgt;
      if (target.isDead()
          || target.isSeeded()
          || target.getSeederId() != activeChar.getObjectId()) {
        activeChar.sendPacket(ActionFailed.STATIC_PACKET);
        continue;
      }

      final int seedId = target.getSeedType();
      if (seedId == 0) {
        activeChar.sendPacket(ActionFailed.STATIC_PACKET);
        continue;
      }

      // Consuming used seed
      if (!activeChar.destroyItemByItemId("Consume", seedId, 1, target, false)) {
        activeChar.sendPacket(ActionFailed.STATIC_PACKET);
        return;
      }

      SystemMessage sm;
      if (calcSuccess(activeChar, target, seedId)) {
        activeChar.sendPacket(new PlaySound("Itemsound.quest_itemget"));
        target.setSeeded((L2PcInstance) activeChar);
        sm = SystemMessage.getSystemMessage(SystemMessageId.THE_SEED_WAS_SUCCESSFULLY_SOWN);
      } else sm = SystemMessage.getSystemMessage(SystemMessageId.THE_SEED_WAS_NOT_SOWN);

      if (activeChar.getParty() == null) activeChar.sendPacket(sm);
      else activeChar.getParty().broadcastToPartyMembers(sm);

      // TODO: Mob should not aggro on player, this way doesn't work really nice
      target.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
    }
  }