/**
   * Manage actions when a player click on this L2PcInstance.<br>
   * <br>
   * <B><U> Actions on first click on the L2PcInstance (Select it)</U> :</B><br>
   * <br>
   * <li>Set the target of the player
   * <li>Send a Server->Client packet MyTargetSelected to the player (display the select window)<br>
   *     <br>
   *     <B><U> Actions on second click on the L2PcInstance (Follow it/Attack it/Intercat with
   *     it)</U> :</B><br>
   *     <br>
   * <li>Send a Server->Client packet MyTargetSelected to the player (display the select window)
   * <li>If target L2PcInstance has a Private Store, notify the player AI with AI_INTENTION_INTERACT
   * <li>If target L2PcInstance is autoAttackable, notify the player AI with AI_INTENTION_ATTACK<br>
   *     <br>
   * <li>If target L2PcInstance is NOT autoAttackable, notify the player AI with AI_INTENTION_FOLLOW
   *     <br>
   *     <br>
   *     <B><U> Example of use </U> :</B><br>
   *     <br>
   * <li>Client packet : Action, AttackRequest<br>
   *     <br>
   *
   * @param activeChar The player that start an action on target L2PcInstance
   */
  public boolean action(L2PcInstance activeChar, L2Object target, boolean interact) {
    // See description in TvTEvent.java
    if (!TvTEvent.onAction(activeChar, target.getObjectId())) return false;

    // Check if the L2PcInstance is confused
    if (activeChar.isOutOfControl()) return false;

    // Aggression target lock effect
    if (activeChar.isLockedTarget() && activeChar.getLockedTarget() != target) {
      activeChar.sendPacket(new SystemMessage(SystemMessageId.FAILED_CHANGE_TARGET));
      return false;
    }

    // Check if the activeChar already target this L2PcInstance
    if (activeChar.getTarget() != target) {
      // Set the target of the activeChar
      activeChar.setTarget(target);

      // Send a Server->Client packet MyTargetSelected to the activeChar
      // The color to display in the select window is White
      activeChar.sendPacket(new MyTargetSelected(target.getObjectId(), 0));
      if (activeChar != target) activeChar.sendPacket(new ValidateLocation((L2Character) target));
    } else if (interact) {
      if (activeChar != target) activeChar.sendPacket(new ValidateLocation((L2Character) target));
      // Check if this L2PcInstance has a Private Store
      if (((L2PcInstance) target).getPrivateStoreType() != 0) {
        activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target);
      } else {
        // Check if this L2PcInstance is autoAttackable
        if (target.isAutoAttackable(activeChar)) {
          // activeChar with lvl < 21 can't attack a cursed weapon holder
          // And a cursed weapon holder  can't attack activeChars with lvl < 21
          if ((((L2PcInstance) target).isCursedWeaponEquipped() && activeChar.getLevel() < 21)
              || (activeChar.isCursedWeaponEquipped() && ((L2Character) target).getLevel() < 21)) {
            activeChar.sendPacket(ActionFailed.STATIC_PACKET);
          } else {
            if (Config.GEODATA > 0) {
              if (GeoData.getInstance().canSeeTarget(activeChar, target)) {
                activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
                activeChar.onActionRequest();
              }
            } else {
              activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
              activeChar.onActionRequest();
            }
          }
        } else {
          // This Action Failed packet avoids activeChar getting stuck when clicking three or more
          // times
          activeChar.sendPacket(ActionFailed.STATIC_PACKET);
          if (Config.GEODATA > 0) {
            if (GeoData.getInstance().canSeeTarget(activeChar, target))
              activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, target);
          } else activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, target);
        }
      }
    }
    return true;
  }
示例#2
0
  private void remove(L2PcInstance activeChar, L2PcInstance playerInstance) {
    if (!TvTEvent.removeParticipant(playerInstance.getObjectId())) {
      activeChar.sendMessage("Player is not part of the event!");
      return;
    }

    new TvTEventTeleporter(
        playerInstance, Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES, true, true);
  }
示例#3
0
  private void add(L2PcInstance activeChar, L2PcInstance playerInstance) {
    if (playerInstance.isOnEvent()) {
      activeChar.sendMessage("Player already participated in the event!");
      return;
    }

    if (!TvTEvent.addParticipant(playerInstance)) {
      activeChar.sendMessage("Player instance could not be added, it seems to be null!");
      return;
    }

    if (TvTEvent.isStarted()) {
      new TvTEventTeleporter(
          playerInstance,
          TvTEvent.getParticipantTeamCoordinates(playerInstance.getObjectId()),
          true,
          false);
    }
  }
示例#4
0
  @Override
  public L2Object[] getTargetList(
      Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target) {
    List<L2Character> targetList = new ArrayList<>();
    if (onlyFirst) {
      return new L2Character[] {activeChar};
    }

    final L2PcInstance player = activeChar.getActingPlayer();

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

    targetList.add(player);

    final int radius = skill.getAffectRange();
    final boolean hasClan = player.getClan() != null;
    final boolean hasParty = player.isInParty();

    if (Skill.addPet(activeChar, player, radius, false)) {
      targetList.add(player.getPet());
    }

    player
        .getServitors()
        .values()
        .forEach(
            s -> {
              if (Skill.addCharacter(activeChar, s, radius, false)) {
                targetList.add(s);
              }
            });

    // if player in clan and not in party
    if (!(hasClan || hasParty)) {
      return targetList.toArray(new L2Character[targetList.size()]);
    }

    // Get all visible objects in a spherical area near the L2Character
    final Collection<L2PcInstance> objs = activeChar.getKnownList().getKnownPlayersInRadius(radius);
    int maxTargets = skill.getAffectLimit();
    for (L2PcInstance obj : objs) {
      if (obj == null) {
        continue;
      }

      // olympiad mode - adding only own side
      if (player.isInOlympiadMode()) {
        if (!obj.isInOlympiadMode()) {
          continue;
        }
        if (player.getOlympiadGameId() != obj.getOlympiadGameId()) {
          continue;
        }
        if (player.getOlympiadSide() != obj.getOlympiadSide()) {
          continue;
        }
      }

      if (player.isInDuel()) {
        if (player.getDuelId() != obj.getDuelId()) {
          continue;
        }

        if (hasParty
            && obj.isInParty()
            && (player.getParty().getLeaderObjectId() != obj.getParty().getLeaderObjectId())) {
          continue;
        }
      }

      if (!((hasClan && (obj.getClanId() == player.getClanId()))
          || (hasParty
              && obj.isInParty()
              && (player.getParty().getLeaderObjectId() == obj.getParty().getLeaderObjectId())))) {
        continue;
      }

      // Don't add this target if this is a Pc->Pc pvp
      // casting and pvp condition not met
      if (!player.checkPvpSkill(obj, skill)) {
        continue;
      }

      if (!TvTEvent.checkForTvTSkill(player, obj, skill)) {
        continue;
      }

      if (Skill.addPet(activeChar, obj, radius, false)) {
        targetList.add(obj.getPet());
      }

      obj.getServitors()
          .values()
          .forEach(
              s -> {
                if (Skill.addCharacter(activeChar, s, radius, false)) {
                  targetList.add(s);
                }
              });

      if (!Skill.addCharacter(activeChar, obj, radius, false)) {
        continue;
      }

      if ((maxTargets > 0) && (targetList.size() >= maxTargets)) {
        break;
      }

      targetList.add(obj);
    }
    return targetList.toArray(new L2Character[targetList.size()]);
  }
  private static final boolean validateGateCondition(L2PcInstance clanLeader, L2PcInstance player) {
    if (clanLeader.isAlikeDead()) {
      // Need retail message if there's one.
      player.sendMessage("Couldn't teleport to clan leader. The requirements was not meet.");
      return false;
    }

    if (clanLeader.isInStoreMode()) {
      // Need retail message if there's one.
      player.sendMessage("Couldn't teleport to clan leader. The requirements was not meet.");
      return false;
    }

    if (clanLeader.isRooted() || clanLeader.isInCombat()) {
      // Need retail message if there's one.
      player.sendMessage("Couldn't teleport to clan leader. The requirements was not meet.");
      return false;
    }

    if (clanLeader.isInOlympiadMode()) {
      // Need retail message if there's one.
      player.sendMessage("Couldn't teleport to clan leader. The requirements was not meet.");
      return false;
    }

    if (clanLeader.isFestivalParticipant()) {
      // Need retail message if there's one.
      player.sendMessage("Couldn't teleport to clan leader. The requirements was not meet.");
      return false;
    }

    if (clanLeader.inObserverMode()) {
      // Need retail message if there's one.
      player.sendMessage("Couldn't teleport to clan leader. The requirements was not meet.");
      return false;
    }

    if (clanLeader.isInsideZone(L2Character.ZONE_NOSUMMONFRIEND)) {
      // Need retail message if there's one.
      player.sendMessage("Couldn't teleport to clan leader. The requirements was not meet.");
      return false;
    }

    if (clanLeader.getInstanceId() > 0) {
      if (!Config.ALLOW_SUMMON_TO_INSTANCE
          || InstanceManager.getInstance().getInstance(player.getInstanceId()).isSummonAllowed()) {
        // Need retail message if there's one.
        player.sendMessage("Couldn't teleport to clan leader. The requirements was not meet.");
        return false;
      }
    }

    if (player.isIn7sDungeon()) {
      final int targetCabal = SevenSigns.getInstance().getPlayerCabal(clanLeader.getObjectId());
      if (SevenSigns.getInstance().isSealValidationPeriod()) {
        if (targetCabal != SevenSigns.getInstance().getCabalHighestScore()) {
          // Need retail message if there's one.
          player.sendMessage("Couldn't teleport to clan leader. The requirements was not meet.");
          return false;
        }
      } else {
        if (targetCabal == SevenSigns.CABAL_NULL) {
          // Need retail message if there's one.
          player.sendMessage("Couldn't teleport to clan leader. The requirements was not meet.");
          return false;
        }
      }
    }

    if (!TvTEvent.onEscapeUse(player.getObjectId())) {
      player.sendMessage("You on TvT Event, teleporting disabled.");
      return false;
    }

    if (!TvTEvent.onEscapeUse(clanLeader.getObjectId())) {
      // Need retail message if there's one.
      player.sendMessage("Couldn't teleport to clan leader. The requirements was not meet.");
      return false;
    }

    return true;
  }