Exemple #1
0
 public static final boolean hasSpecialIngredient(int id, long amount, L2PcInstance player) {
   switch (id) {
     case CLAN_REPUTATION:
       if (player.getClan() == null) {
         player.sendPacket(SystemMessageId.YOU_ARE_NOT_A_CLAN_MEMBER);
         break;
       }
       if (!player.isClanLeader()) {
         player.sendPacket(SystemMessageId.ONLY_THE_CLAN_LEADER_IS_ENABLED);
         break;
       }
       if (player.getClan().getReputationScore() < amount) {
         player.sendPacket(SystemMessageId.THE_CLAN_REPUTATION_SCORE_IS_TOO_LOW);
         break;
       }
       return true;
     case FAME:
       if (player.getFame() < amount) {
         player.sendPacket(SystemMessageId.NOT_ENOUGH_FAME_POINTS);
         break;
       }
       return true;
   }
   return false;
 }
Exemple #2
0
  /**
   * Claims the hero status for the given player.
   *
   * @param player the player to become hero
   */
  public void claimHero(L2PcInstance player) {
    _heroes.get(player.getObjectId()).set(CLAIMED, true);

    final L2Clan clan = player.getClan();
    if ((clan != null) && (clan.getLevel() >= 5)) {
      clan.addReputationScore(Config.HERO_POINTS, true);
      final SystemMessage sm =
          SystemMessage.getSystemMessage(
              SystemMessageId.CLAN_MEMBER_C1_BECAME_HERO_AND_GAINED_S2_REPUTATION_POINTS);
      sm.addString(CharNameTable.getInstance().getNameById(player.getObjectId()));
      sm.addInt(Config.HERO_POINTS);
      clan.broadcastToOnlineMembers(sm);
    }

    player.setHero(true);
    player.broadcastPacket(new SocialAction(player.getObjectId(), 20016)); // Hero Animation
    player.sendPacket(new UserInfo(player));
    player.sendPacket(new ExBrExtraUserInfo(player));
    player.broadcastUserInfo();
    // Set Gained hero and reload data
    setHeroGained(player.getObjectId());
    loadFights(player.getObjectId());
    loadDiary(player.getObjectId());
    _heroMessage.put(player.getObjectId(), "");

    updateHeroes(false);
  }
Exemple #3
0
 @Override
 public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
   String htmltext = null;
   switch (event) {
     case "32557-01.html":
       {
         htmltext = event;
         break;
       }
     case "licence":
       {
         final L2Clan clan = player.getClan();
         if ((clan == null) || !player.isClanLeader() || (clan.getLevel() < MIN_CLAN_LV)) {
           htmltext = "32557-02.html";
         } else if (hasAtLeastOneQuestItem(player, LICENCE)) {
           htmltext = "32557-04.html";
         } else if (AirShipManager.getInstance().hasAirShipLicense(clan.getId())) {
           player.sendPacket(SystemMessageId.THE_AIRSHIP_SUMMON_LICENSE_ALREADY_ACQUIRED);
         } else if (getQuestItemsCount(player, STONE) >= STONE_COUNT) {
           takeItems(player, STONE, STONE_COUNT);
           giveItems(player, LICENCE, 1);
         } else {
           htmltext = "32557-03.html";
         }
         break;
       }
   }
   return htmltext;
 }
  @Override
  protected void runImpl() {
    final L2PcInstance activeChar = getClient().getActiveChar();
    if (activeChar == null) {
      return;
    }

    final L2Clan clan = activeChar.getClan();
    if (clan == null) {
      return;
    }

    if (!activeChar.hasClanPrivilege(ClanPrivilege.CL_MANAGE_RANKS)) {
      return;
    }

    final L2ClanMember member = clan.getClanMember(_member);
    if (member == null) {
      return;
    }

    if (member.getObjectId() == clan.getLeaderId()) {
      return;
    }

    if (member.getPledgeType() == L2Clan.SUBUNIT_ACADEMY) {
      // also checked from client side
      activeChar.sendMessage("You cannot change academy member grade");
      return;
    }

    member.setPowerGrade(_powerGrade);
    clan.broadcastClanStatus();
  }
Exemple #5
0
 public static final void giveSpecialProduct(int id, long amount, L2PcInstance player) {
   switch (id) {
     case CLAN_REPUTATION:
       player.getClan().addReputationScore((int) amount, true);
       break;
     case FAME:
       player.setFame((int) (player.getFame() + amount));
       player.sendPacket(new UserInfo(player));
       player.sendPacket(new ExBrExtraUserInfo(player));
       break;
   }
 }
  @Override
  public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon) {
    if (player.getClan() == null) {
      return null;
    }

    QuestState st = null;
    if (player.isClanLeader()) {
      st = getQuestState(player, false);
    } else {
      L2PcInstance pleader = player.getClan().getLeader().getPlayerInstance();
      if ((pleader != null) && player.isInsideRadius(pleader, 1500, true, false)) {
        st = getQuestState(pleader, false);
      }
    }

    if ((st != null) && st.isStarted()) {
      st.rewardItems(TYRANNOSAURUS_CLAW, 1);
      st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
    }
    return null;
  }
  @Override
  protected void runImpl() {
    L2PcInstance activeChar = getClient().getActiveChar();
    if (activeChar == null) {
      return;
    }

    L2Clan clan = activeChar.getClan();
    if (clan != null) {
      PledgeShowMemberListAll pm = new PledgeShowMemberListAll(clan, activeChar);
      activeChar.sendPacket(pm);
    }
  }
Exemple #8
0
  public Die(L2Character cha) {
    _charObjId = cha.getObjectId();
    _activeChar = cha;
    if (cha.isPlayer()) {
      final L2PcInstance player = cha.getActingPlayer();
      _access = player.getAccessLevel();
      _clan = player.getClan();
      _isJailed = player.isInJail();
    }

    _canTeleport = cha.canRevive() && !cha.isPendingRevive();
    _sweepable = cha.isL2Attackable() && cha.isSweepActive();
  }
Exemple #9
0
  public void openCloseDoor(L2PcInstance activeChar, int doorId, boolean open) {
    if (activeChar.getClan() != getOwnerClan()) {
      return;
    }

    L2DoorInstance door = getDoor(doorId);
    if (door != null) {
      if (open) {
        door.openMe();
      } else {
        door.closeMe();
      }
    }
  }
  @Override
  protected void runImpl() {
    L2PcInstance activeChar = getClient().getActiveChar();
    if (activeChar == null) {
      return;
    }

    L2PcInstance ob = L2World.getInstance().getPlayer(_id);

    if (ob == null) {
      activeChar.sendPacket(new SystemMessage(SystemMessageId.YOU_HAVE_INVITED_THE_WRONG_TARGET));
      return;
    }

    if (activeChar.getClan() == null) {
      activeChar.sendPacket(new SystemMessage(SystemMessageId.YOU_ARE_NOT_A_CLAN_MEMBER));
      return;
    }

    L2PcInstance target = ob;
    L2Clan clan = activeChar.getClan();
    if (!clan.checkAllyJoinCondition(activeChar, target)) {
      return;
    }
    if (!activeChar.getRequest().setRequest(target, this)) {
      return;
    }

    SystemMessage sm =
        new SystemMessage(SystemMessageId.S2_ALLIANCE_LEADER_OF_S1_REQUESTED_ALLIANCE);
    sm.addString(activeChar.getClan().getAllyName());
    sm.addString(activeChar.getName());
    target.sendPacket(sm);
    sm = null;
    AskJoinAlly aja = new AskJoinAlly(activeChar.getObjectId(), activeChar.getClan().getAllyName());
    target.sendPacket(aja);
  }
Exemple #11
0
  private String giveReputation(
      L2Npc npc, L2PcInstance player, int count, int itemId, int itemCount) {
    if (getQuestItemsCount(player, itemId) >= itemCount) {
      takeItems(player, itemId, itemCount);
      player.getClan().addReputationScore(count, true);

      final SystemMessage sm =
          SystemMessage.getSystemMessage(
              SystemMessageId.YOUR_CLAN_HAS_ADDED_S1_POINT_S_TO_ITS_CLAN_REPUTATION);
      sm.addInt(count);
      player.sendPacket(sm);
      return npc.getId() + "-04.html";
    }
    return npc.getId() + "-03.html";
  }
Exemple #12
0
 @Override
 public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
   String htmltext = null;
   switch (event) {
     case "32024.html":
     case "32024-02.html":
     case "32025.html":
     case "32025-02.html":
       {
         htmltext = event;
         break;
       }
     case "repinfo":
       {
         htmltext =
             (player.getClan().getLevel() > 4)
                 ? npc.getId() + "-02.html"
                 : npc.getId() + "-05.html";
         break;
       }
     case "exchange-ba":
       {
         htmltext =
             giveReputation(
                 npc, player, Config.BLOODALLIANCE_POINTS, BLOOD_ALLIANCE, BLOOD_ALLIANCE_COUNT);
         break;
       }
     case "exchange-bo":
       {
         htmltext =
             giveReputation(npc, player, Config.BLOODOATH_POINTS, BLOOD_OATH, BLOOD_OATH_COUNT);
         break;
       }
     case "exchange-ke":
       {
         htmltext =
             giveReputation(
                 npc,
                 player,
                 Config.KNIGHTSEPAULETTE_POINTS,
                 KNIGHTS_EPAULETTE,
                 KNIGHTS_EPAULETTE_COUNT);
         break;
       }
   }
   return htmltext;
 }
Exemple #13
0
 public static final boolean takeSpecialIngredient(int id, long amount, L2PcInstance player) {
   switch (id) {
     case CLAN_REPUTATION:
       player.getClan().takeReputationScore((int) amount, true);
       SystemMessage smsg =
           SystemMessage.getSystemMessage(SystemMessageId.S1_DEDUCTED_FROM_CLAN_REP);
       smsg.addLong(amount);
       player.sendPacket(smsg);
       return true;
     case FAME:
       player.setFame(player.getFame() - (int) amount);
       player.sendPacket(new UserInfo(player));
       player.sendPacket(new ExBrExtraUserInfo(player));
       return true;
   }
   return false;
 }
  @Override
  public String onTalk(L2Npc npc, L2PcInstance player) {
    String htmltext = getNoQuestMsg(player);
    final QuestState st = getQuestState(player, true);
    if (st == null) {
      return htmltext;
    }

    L2Clan clan = player.getClan();
    switch (st.getState()) {
      case State.CREATED:
        htmltext =
            ((clan == null) || !player.isClanLeader() || (clan.getLevel() < 5))
                ? "31331-0.htm"
                : "31331-1.htm";
        break;
      case State.STARTED:
        if ((clan == null) || !player.isClanLeader()) {
          st.exitQuest(true);
          return "31331-8.html";
        }

        if (!st.hasQuestItems(TYRANNOSAURUS_CLAW)) {
          htmltext = "31331-4.html";
        } else {
          int count = (int) st.getQuestItemsCount(TYRANNOSAURUS_CLAW);
          int reward = (count < 10) ? (30 * count) : (59 + (30 * count));
          st.playSound(QuestSound.ITEMSOUND_QUEST_FANFARE_1);
          st.takeItems(TYRANNOSAURUS_CLAW, -1);
          clan.addReputationScore(reward, true);
          player.sendPacket(
              SystemMessage.getSystemMessage(
                      SystemMessageId
                          .YOU_HAVE_SUCCESSFULLY_COMPLETED_A_CLAN_QUEST_S1_POINT_S_HAVE_BEEN_ADDED_TO_YOUR_CLAN_REPUTATION)
                  .addInt(reward));
          clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
          htmltext = "31331-7.html";
        }
        break;
      default:
        break;
    }
    return htmltext;
  }
  @Override
  protected void runImpl() {
    final L2PcInstance activeChar = getClient().getActiveChar();

    if ((activeChar == null) || (activeChar.getClan() != null)) {
      return;
    }

    final L2Clan clan = ClanTable.getInstance().getClan(_clanId);

    if (clan == null) {
      return;
    }

    final PledgeApplicantInfo info =
        new PledgeApplicantInfo(
            activeChar.getObjectId(),
            activeChar.getName(),
            activeChar.getLevel(),
            _karma,
            _clanId,
            _message);

    if (ClanEntryManager.getInstance().addPlayerApplicationToClan(_clanId, info)) {
      activeChar.sendPacket(new ExPledgeRecruitApplyInfo(ClanEntryStatus.WAITING));

      final L2PcInstance clanLeader = L2World.getInstance().getPlayer(clan.getLeaderId());

      if (clanLeader != null) {
        clanLeader.sendPacket(ExPledgeWaitingListAlarm.STATIC_PACKET);
      }
    } else {
      final SystemMessage sm =
          SystemMessage.getSystemMessage(
              SystemMessageId
                  .YOU_MAY_APPLY_FOR_ENTRY_AFTER_S1_MINUTE_S_DUE_TO_CANCELLING_YOUR_APPLICATION);
      sm.addLong(ClanEntryManager.getInstance().getPlayerLockTime(activeChar.getObjectId()));
      activeChar.sendPacket(sm);
    }
  }
  @Override
  public boolean testImpl(L2Character effector, L2Character effected, Skill skill, L2Item item) {
    if ((effector == null) || !effector.isPlayer()) {
      return !_val;
    }

    final L2PcInstance player = effector.getActingPlayer();
    boolean canSummonSiegeGolem = true;
    if (player.isAlikeDead() || player.isCursedWeaponEquipped() || (player.getClan() == null)) {
      canSummonSiegeGolem = false;
    }

    final Castle castle = CastleManager.getInstance().getCastle(player);
    final Fort fort = FortManager.getInstance().getFort(player);
    if ((castle == null) && (fort == null)) {
      canSummonSiegeGolem = false;
    }

    if (((fort != null) && (fort.getResidenceId() == 0))
        || ((castle != null) && (castle.getResidenceId() == 0))) {
      player.sendPacket(SystemMessageId.INCORRECT_TARGET);
      canSummonSiegeGolem = false;
    } else if (((castle != null) && !castle.getSiege().isInProgress())
        || ((fort != null) && !fort.getSiege().isInProgress())) {
      player.sendPacket(SystemMessageId.INCORRECT_TARGET);
      canSummonSiegeGolem = false;
    } else if ((player.getClanId() != 0)
        && (((castle != null) && (castle.getSiege().getAttackerClan(player.getClanId()) == null))
            || ((fort != null) && (fort.getSiege().getAttackerClan(player.getClanId()) == null)))) {
      player.sendPacket(SystemMessageId.INCORRECT_TARGET);
      canSummonSiegeGolem = false;
    } else if ((SevenSigns.getInstance().checkSummonConditions(player))) {
      canSummonSiegeGolem = false;
    }
    return (_val == canSummonSiegeGolem);
  }
Exemple #17
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()]);
  }
  @Override
  public boolean useUserCommand(int id, L2PcInstance activeChar) {
    if ((id != COMMAND_IDS[0]) && (id != COMMAND_IDS[1]) && (id != COMMAND_IDS[2])) {
      return false;
    }

    final L2Clan clan = activeChar.getClan();
    if (clan == null) {
      activeChar.sendPacket(SystemMessageId.NOT_JOINED_IN_ANY_CLAN);
      return false;
    }

    try (Connection con = L2DatabaseFactory.getInstance().getConnection()) {
      String query;
      // Attack List
      if (id == 88) {
        activeChar.sendPacket(SystemMessageId.CLANS_YOU_DECLARED_WAR_ON);
        query = ATTACK_LIST;
      }
      // Under Attack List
      else if (id == 89) {
        activeChar.sendPacket(SystemMessageId.CLANS_THAT_HAVE_DECLARED_WAR_ON_YOU);
        query = UNDER_ATTACK_LIST;
      }
      // War List
      else {
        activeChar.sendPacket(SystemMessageId.WAR_LIST);
        query = WAR_LIST;
      }

      try (PreparedStatement ps = con.prepareStatement(query)) {
        ps.setInt(1, clan.getId());
        ps.setInt(2, clan.getId());

        SystemMessage sm;
        try (ResultSet rs = ps.executeQuery()) {
          String clanName;
          int ally_id;
          while (rs.next()) {
            clanName = rs.getString("clan_name");
            ally_id = rs.getInt("ally_id");
            if (ally_id > 0) {
              // Target With Ally
              sm = SystemMessage.getSystemMessage(SystemMessageId.S1_S2_ALLIANCE);
              sm.addString(clanName);
              sm.addString(rs.getString("ally_name"));
            } else {
              // Target Without Ally
              sm = SystemMessage.getSystemMessage(SystemMessageId.S1_NO_ALLI_EXISTS);
              sm.addString(clanName);
            }
            activeChar.sendPacket(sm);
          }
        }
      }
      activeChar.sendPacket(SystemMessageId.FRIEND_LIST_FOOTER);
    } catch (Exception e) {
      _log.log(Level.WARNING, "", e);
    }
    return true;
  }
  @Override
  public boolean useAdminCommand(String command, L2PcInstance activeChar) {
    StringTokenizer st = new StringTokenizer(command, " ");
    command = st.nextToken(); // Get actual command

    // Get fort
    Fort fort = null;
    int fortId = 0;
    if (st.hasMoreTokens()) {
      fortId = Integer.parseInt(st.nextToken());
      fort = FortManager.getInstance().getFortById(fortId);
    }
    // Get fort
    if (((fort == null) || (fortId == 0))) {
      // No fort specified
      showFortSelectPage(activeChar);
    } else {
      L2Object target = activeChar.getTarget();
      L2PcInstance player = null;
      if (target instanceof L2PcInstance) {
        player = (L2PcInstance) target;
      }

      if (command.equalsIgnoreCase("admin_add_fortattacker")) {
        if (player == null) {
          activeChar.sendPacket(SystemMessageId.TARGET_IS_INCORRECT);
        } else {
          if (fort.getSiege().addAttacker(player, false) == 4) {
            final SystemMessage sm =
                SystemMessage.getSystemMessage(SystemMessageId.REGISTERED_TO_S1_FORTRESS_BATTLE);
            sm.addCastleId(fort.getResidenceId());
            player.sendPacket(sm);
          } else {
            player.sendMessage("During registering error occurred!");
          }
        }
      } else if (command.equalsIgnoreCase("admin_clear_fortsiege_list")) {
        fort.getSiege().clearSiegeClan();
      } else if (command.equalsIgnoreCase("admin_endfortsiege")) {
        fort.getSiege().endSiege();
      } else if (command.equalsIgnoreCase("admin_list_fortsiege_clans")) {
        activeChar.sendMessage("Not implemented yet.");
      } else if (command.equalsIgnoreCase("admin_setfort")) {
        if ((player == null) || (player.getClan() == null)) {
          activeChar.sendPacket(SystemMessageId.TARGET_IS_INCORRECT);
        } else {
          fort.endOfSiege(player.getClan());
        }
      } else if (command.equalsIgnoreCase("admin_removefort")) {
        L2Clan clan = fort.getOwnerClan();
        if (clan != null) {
          fort.removeOwner(true);
        } else {
          activeChar.sendMessage("Unable to remove fort");
        }
      } else if (command.equalsIgnoreCase("admin_spawn_fortdoors")) {
        fort.resetDoors();
      } else if (command.equalsIgnoreCase("admin_startfortsiege")) {
        fort.getSiege().startSiege();
      }

      showFortSiegePage(activeChar, fort);
    }
    return true;
  }
 private final boolean isOwner(final L2PcInstance player, final L2Npc npc) {
   return player.canOverrideCond(PcCondOverride.CASTLE_CONDITIONS)
       || ((player.getClan() != null) && (player.getClanId() == npc.getCastle().getOwnerId()));
 }