Ejemplo n.º 1
0
  public boolean trigger(int event, int damage, byte element, boolean playable, L2Skill skill) {
    if (_pvpOnly && !playable) {
      return false;
    }

    if (_elements != null && Arrays.binarySearch(_elements, element) < 0) {
      return false;
    }

    if (_activationSkills != null
        && skill != null
        && Arrays.binarySearch(_activationSkills, skill.getId()) < 0) {
      return false;
    }

    // onCast is called on every skill cast, so we must check if trigger
    // have limit (can be triggered only by some specific skill)
    if (_bySkillId > 0 && (skill == null || skill.getId() != _bySkillId)) {
      return false;
    }

    // if the skill has "activationMinDamage" setted to higher than -1(default)
    // and if "activationMinDamage" is still higher than the recieved damage, the skill wont trigger
    if (_mindmg > -1 && _mindmg > damage) {
      return false;
    }

    return _triggerType.check(event) && (_chance < 0 || Rnd.getChance(_chance));
  }
Ejemplo n.º 2
0
  @Override
  public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets) {
    boolean acted = true;

    L2PcInstance player = null;
    if (activeChar instanceof L2PcInstance) {
      player = (L2PcInstance) activeChar;
    }

    if (skill.getEffectId() != 0) {
      L2Skill sk =
          SkillTable.getInstance()
              .getInfo(skill.getEffectId(), skill.getEffectLvl() == 0 ? 1 : skill.getEffectLvl());

      if (sk != null) {
        skill = sk;
      }
    }

    boolean ss = activeChar.isSoulshotCharged(skill);
    boolean sps = activeChar.isSpiritshotCharged(skill);
    boolean bss = activeChar.isBlessedSpiritshotCharged(skill);

    L2Character target;
    for (L2Object obj : targets) {
      if (obj instanceof L2Character) {
        target = (L2Character) obj;
      } else {
        continue;
      }

      byte shld = 0;

      if (Reflect.calcSkillReflect(target, skill) == Variables.SKILL_REFLECT_SUCCEED) {
        target = activeChar;
      }

      // Персонаж, владеющий ПО, не может быть бафнутым и не сам не может никого бафать
      if (skill.getSkillType() == L2SkillType.BUFF
          && activeChar.isNpc()
          && ((L2Npc) activeChar).getClanHall() != null) {
        if (!target.equals(activeChar)) {
          if (target instanceof L2PcInstance) {
            L2PcInstance trg = (L2PcInstance) target;
            if (trg.isCursedWeaponEquipped()) {
              continue;
            }
            // Avoiding block checker players get buffed from outside
            else if (trg.getEventController().isInHandysBlockCheckerEventArena()) {
              continue;
            }
          } else if (player != null && player.isCursedWeaponEquipped()) {
            continue;
          }
        }
      }

      switch (skill.getSkillType()) {
        case HOT:
        case CPHOT:
        case MPHOT:
          if (activeChar.isInvul()) {
            continue;
          }
          break;
      }

      if (skill.isOffensive() || skill.isDebuff()) {
        shld = Shield.calcShldUse(activeChar, target, skill);
        acted = Skills.calcSkillSuccess(activeChar, target, skill, shld, ss, sps, bss);
      }

      if (acted) {
        if (skill.isToggle()) {
          for (L2Effect e : target.getAllEffects()) {
            if (e != null && e.getSkill().getId() == skill.getId()) {
              e.exit();
              return;
            }
          }
        }

        // if this is a debuff let the duel manager know about it
        // so the debuff can be removed after the duel
        // (player & target must be in the same duel)
        if (target instanceof L2PcInstance
            && ((L2PcInstance) target).isInDuel()
            && (skill.getSkillType() == L2SkillType.DEBUFF
                || skill.getSkillType() == L2SkillType.BUFF)
            && player != null
            && player.getDuelId() == ((L2PcInstance) target).getDuelId()) {
          DuelManager dm = DuelManager.getInstance();
          for (L2Effect buff : skill.getEffects(activeChar, target, new Env(shld, ss, sps, bss))) {
            if (buff != null) {
              dm.onBuff((L2PcInstance) target, buff);
            }
          }
        } else {
          L2Effect[] effects = skill.getEffects(activeChar, target, new Env(shld, ss, sps, bss));

          if (target instanceof L2PcInstance && !target.getPets().isEmpty()) {
            for (L2Summon pet : target.getPets()) {
              if (!pet.equals(activeChar)
                  && pet instanceof L2SummonInstance
                  && effects.length > 0) {
                if (effects[0].canBeStolen() || skill.isHeroSkill() || skill.isStatic()) {
                  skill.getEffects(activeChar, pet, new Env(shld, ss, sps, bss));
                }
              }
            }
          }
        }

        if (skill.getSkillType() == L2SkillType.AGGDEBUFF) {
          if (target instanceof L2Attackable) {
            target
                .getAI()
                .notifyEvent(CtrlEvent.EVT_AGGRESSION, activeChar, (int) skill.getPower());
          } else if (target instanceof L2Playable) {
            if (target.getTarget().equals(activeChar)) {
              target.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, activeChar);
            } else {
              target.setTarget(activeChar);
            }
          }
        }
      } else {
        activeChar.sendPacket(SystemMessageId.ATTACK_FAILED);
      }

      // Possibility of a lethal strike
      BlowDamage.calcLethalHit(activeChar, target, skill);
    }

    // self Effect :]
    if (skill.hasSelfEffects()) {
      L2Effect effect = activeChar.getFirstEffect(skill.getId());
      if (effect != null && effect.isSelfEffect()) {
        // Replace old effect with new one.
        effect.exit();
      }
      skill.getEffectsSelf(activeChar);
    }

    activeChar.spsUncharge(skill);
  }
Ejemplo n.º 3
0
  @Override
  public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets) {
    if (!(activeChar instanceof L2PcInstance)) {
      return;
    }

    boolean isMastersCall = skill.getId() == 23249;

    L2PcInstance activePlayer = activeChar.getActingPlayer();

    if (!isMastersCall && !activePlayer.getSummonFriendController().checkSummonerStatus()) {
      return;
    }

    try {
      for (L2Character target : (L2Character[]) targets) {
        if (target == null || activeChar.equals(target) || !target.isPlayer()) {
          continue;
        }

        if (isMastersCall) // Master's Call
        {
          L2Party party = target.getParty();
          if (party != null) {
            party
                .getMembers()
                .stream()
                .filter(partyMember -> !target.equals(partyMember))
                .forEach(
                    partyMember ->
                        partyMember.teleToLocation(
                            target.getX(), target.getY(), target.getZ(), true));
          } else {
            activePlayer.sendPacket(
                SystemMessage.getSystemMessage(SystemMessageId.S1_CANNOT_BE_USED)
                    .addSkillName(skill));
          }
        } else {
          if (skill.isClanSkill()) // Призыв Клана
          {
            if (!target.getActingPlayer().isInSameClan(activePlayer)) {
              activePlayer.sendPacket(
                  SystemMessage.getSystemMessage(SystemMessageId.S1_CANNOT_BE_USED)
                      .addSkillName(skill));
              continue;
            } else if (!target.getActingPlayer().isInSameParty(activePlayer)) {
              activePlayer.sendPacket(
                  SystemMessage.getSystemMessage(SystemMessageId.S1_CANNOT_BE_USED)
                      .addSkillName(skill));
              continue;
            }
          }

          L2PcInstance targetPlayer = target.getActingPlayer();

          if (!Util.checkIfInRange(500, activeChar, target, false)) {
            if (!targetPlayer.getSummonFriendController().setSummoner(activePlayer, skill)) {
              SystemMessage sm =
                  SystemMessage.getSystemMessage(SystemMessageId.C1_ALREADY_SUMMONED);
              sm.addString(target.getName());
              activePlayer.sendPacket(sm);
            }

            ConfirmDlg confirm =
                new ConfirmDlg(
                    SystemMessageId.C1_WISHES_TO_SUMMON_YOU_FROM_S2_DO_YOU_ACCEPT.getId());
            confirm.addCharName(activeChar);
            confirm.addZoneName(activeChar.getX(), activeChar.getY(), activeChar.getZ());
            confirm.addTime(30000);
            confirm.addRequesterId(activePlayer.getObjectId());
            target.sendPacket(confirm);
            // targetPlayer.getSummonFriendController().teleport();
          }
        }
      }
    } catch (Exception e) {
      _log.log(Level.ERROR, "", e);
    }
  }