Пример #1
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);
  }
Пример #2
0
  public void remove(String name) {
    int contactId = CharNameTable.getInstance().getIdByName(name);

    if (!_contacts.contains(name)) {
      activeChar.sendPacket(SystemMessageId.NAME_NOT_REGISTERED_ON_CONTACT_LIST);
      return;
    } else if (contactId < 1) {
      // TODO: Message?
      return;
    }

    _contacts.remove(name);

    try (Connection con = ConnectionFactory.getInstance().getConnection();
        PreparedStatement ps = con.prepareStatement(QUERY_REMOVE)) {
      ps.setInt(1, activeChar.getObjectId());
      ps.setInt(2, contactId);
      ps.execute();

      SystemMessage sm =
          SystemMessage.getSystemMessage(SystemMessageId.S1_SUCCESFULLY_DELETED_FROM_CONTACT_LIST);
      sm.addString(name);
      activeChar.sendPacket(sm);
    } catch (Exception e) {
      _log.log(
          Level.WARNING,
          "Error found in " + activeChar.getName() + "'s ContactsList: " + e.getMessage(),
          e);
    }
  }
Пример #3
0
  @Override
  public void onStart(BuffInfo info) {
    L2Character target = info.getEffected();
    L2Character activeChar = info.getEffector();
    Skill skill = info.getSkill();

    if (activeChar.isAlikeDead()) {
      return;
    }

    if (((skill.getFlyRadius() > 0) || (skill.getFlyType() != null))
        && activeChar.isMovementDisabled()) {
      final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_CANNOT_BE_USED);
      sm.addSkillName(skill);
      activeChar.sendPacket(sm);
      return;
    }

    if (target.isPlayer() && target.getActingPlayer().isFakeDeath()) {
      target.stopFakeDeath(true);
    }

    int damage = 0;
    boolean ss = skill.isPhysical() && activeChar.isChargedShot(ShotType.SOULSHOTS);
    final byte shld = Formulas.calcShldUse(activeChar, target, skill);
    // Physical damage critical rate is only affected by STR.
    boolean crit = false;
    if (skill.getBaseCritRate() > 0) {
      crit = Formulas.calcCrit(activeChar, target, skill);
    }

    damage = (int) Formulas.calcPhysDam(activeChar, target, skill, shld, false, ss);

    if ((skill.getMaxSoulConsumeCount() > 0) && activeChar.isPlayer()) {
      // Souls Formula (each soul increase +4%)
      int chargedSouls =
          (activeChar.getActingPlayer().getChargedSouls() <= skill.getMaxSoulConsumeCount())
              ? activeChar.getActingPlayer().getChargedSouls()
              : skill.getMaxSoulConsumeCount();
      damage *= 1 + (chargedSouls * 0.04);
    }
    if (crit) {
      damage *= 2;
    }

    if (damage > 0) {
      activeChar.sendDamageMessage(target, damage, false, crit, false);
      target.reduceCurrentHp(damage, activeChar, skill);
      target.notifyDamageReceived(damage, activeChar, skill, crit, false);

      // Check if damage should be reflected
      Formulas.calcDamageReflected(activeChar, target, skill, crit);
    } else {
      activeChar.sendPacket(SystemMessageId.ATTACK_FAILED);
    }

    if (skill.isSuicideAttack()) {
      activeChar.doDie(activeChar);
    }
  }
  public static void showFishSkillList(L2PcInstance player) {
    final List<L2SkillLearn> skills =
        SkillTreesData.getInstance().getAvailableFishingSkills(player);
    final AcquireSkillList asl = new AcquireSkillList(AcquireSkillType.FISHING);

    int count = 0;

    for (L2SkillLearn s : skills) {
      final Skill sk = SkillData.getInstance().getSkill(s.getSkillId(), s.getSkillLevel());

      if (sk == null) {
        continue;
      }
      count++;
      asl.addSkill(s.getSkillId(), s.getSkillLevel(), s.getSkillLevel(), s.getLevelUpSp(), 1);
    }

    if (count == 0) {
      final int minlLevel =
          SkillTreesData.getInstance()
              .getMinLevelForNewSkill(player, SkillTreesData.getInstance().getFishingSkillTree());
      if (minlLevel > 0) {
        SystemMessage sm =
            SystemMessage.getSystemMessage(SystemMessageId.DO_NOT_HAVE_FURTHER_SKILLS_TO_LEARN_S1);
        sm.addInt(minlLevel);
        player.sendPacket(sm);
      } else {
        player.sendPacket(SystemMessageId.NO_MORE_SKILLS_TO_LEARN);
      }
    } else {
      player.sendPacket(asl);
    }
  }
Пример #5
0
  public void setReenterTime(InstanceWorld world) {
    if (world instanceof DPFWorld) {
      // Reenter time should be cleared every Wed and Sat at 6:30 AM, so we set next suitable
      Calendar reenter;
      Calendar now = Calendar.getInstance();
      Calendar reenterPointWed = (Calendar) now.clone();
      reenterPointWed.set(Calendar.AM_PM, Calendar.AM);
      reenterPointWed.set(Calendar.MINUTE, RESET_MIN);
      reenterPointWed.set(Calendar.HOUR_OF_DAY, RESET_HOUR);
      reenterPointWed.set(Calendar.DAY_OF_WEEK, Calendar.WEDNESDAY);
      Calendar reenterPointSat = (Calendar) reenterPointWed.clone();
      reenterPointSat.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);

      if (now.after(reenterPointSat)) {
        reenterPointWed.add(Calendar.WEEK_OF_MONTH, 1);
        reenter = (Calendar) reenterPointWed.clone();
      } else {
        reenter = (Calendar) reenterPointSat.clone();
      }

      SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.INSTANT_ZONE_S1_RESTRICTED);
      sm.addInstanceName(world.getTemplateId());
      // set instance reenter time for all allowed players
      for (int objectId : world.getAllowed()) {
        L2PcInstance player = L2World.getInstance().getPlayer(objectId);
        if ((player != null) && player.isOnline()) {
          InstanceManager.getInstance()
              .setInstanceTime(objectId, world.getTemplateId(), reenter.getTimeInMillis());
          player.sendPacket(sm);
        }
      }
    }
  }
  private static final void changeClanLeader(L2PcInstance player, String target) {
    if (!player.isClanLeader()) {
      player.sendPacket(new SystemMessage(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_DO_THAT));
      return;
    }
    if (player.getName().equalsIgnoreCase(target)) return;
    /*
     * Until proper clan leader change support is done, this is a little
     * exploit fix (leader, while fliying wyvern changes clan leader and the new leader
     * can ride the wyvern too)
     * DrHouse
     */
    if (player.isFlying()) {
      player.sendMessage("Please, stop flying");
      return;
    }

    final L2Clan clan = player.getClan();

    final L2ClanMember member = clan.getClanMember(target);
    if (member == null) {
      SystemMessage sm = new SystemMessage(SystemMessageId.S1_DOES_NOT_EXIST);
      sm.addString(target);
      player.sendPacket(sm);
      sm = null;
      return;
    }
    if (!member.isOnline()) {
      player.sendPacket(new SystemMessage(SystemMessageId.INVITED_USER_NOT_ONLINE));
      return;
    }
    clan.setNewLeader(member);
  }
Пример #7
0
  @Override
  public void onStart(BuffInfo info) {
    L2Character target = info.getEffected();
    if ((target == null) || target.isDead() || target.isDoor()) {
      return;
    }

    double amount = 0;
    double power = _power;
    boolean full = (power == 100.0);

    amount = full ? target.getMaxMp() : (target.getMaxMp() * power) / 100.0;
    // Prevents overheal and negative amount
    amount = Math.max(Math.min(amount, target.getMaxRecoverableMp() - target.getCurrentMp()), 0);
    if (amount != 0) {
      target.setCurrentMp(amount + target.getCurrentMp());
    }
    SystemMessage sm;
    if (info.getEffector().getObjectId() != target.getObjectId()) {
      sm = SystemMessage.getSystemMessage(SystemMessageId.S2_MP_RESTORED_BY_C1);
      sm.addCharName(info.getEffector());
    } else {
      sm = SystemMessage.getSystemMessage(SystemMessageId.S1_MP_RESTORED);
    }
    sm.addInt((int) amount);
    target.sendPacket(sm);
  }
Пример #8
0
  public boolean addExpAndSp(long addToExp, long addToSp) {
    if (getActiveChar().isUncontrollable() || !addExp(addToExp)) {
      return false;
    }

    SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOUR_PET_GAINED_S1_XP);
    sm.addLong(addToExp);
    getActiveChar().updateAndBroadcastStatus(1);
    getActiveChar().sendPacket(sm);
    return true;
  }
  private static final void assignSubPledgeLeader(
      L2PcInstance player, String clanName, String leaderName) {
    if (!player.isClanLeader()) {
      player.sendPacket(new SystemMessage(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_DO_THAT));
      return;
    }
    if (leaderName.length() > 16) {
      player.sendPacket(new SystemMessage(SystemMessageId.NAMING_CHARNAME_UP_TO_16CHARS));
      return;
    }
    if (player.getName().equals(leaderName)) {
      player.sendPacket(
          new SystemMessage(SystemMessageId.CAPTAIN_OF_ROYAL_GUARD_CANNOT_BE_APPOINTED));
      return;
    }

    final L2Clan clan = player.getClan();
    final SubPledge subPledge = player.getClan().getSubPledge(clanName);

    if (null == subPledge || subPledge.getId() == L2Clan.SUBUNIT_ACADEMY) {
      player.sendPacket(new SystemMessage(SystemMessageId.CLAN_NAME_INCORRECT));
      return;
    }
    if (clan.getClanMember(leaderName) == null
        || (clan.getClanMember(leaderName).getPledgeType() != 0)) {
      if (subPledge.getId() >= L2Clan.SUBUNIT_KNIGHT1)
        player.sendPacket(
            new SystemMessage(SystemMessageId.CAPTAIN_OF_ORDER_OF_KNIGHTS_CANNOT_BE_APPOINTED));
      else if (subPledge.getId() >= L2Clan.SUBUNIT_ROYAL1)
        player.sendPacket(
            new SystemMessage(SystemMessageId.CAPTAIN_OF_ROYAL_GUARD_CANNOT_BE_APPOINTED));

      return;
    }

    subPledge.setLeaderId(clan.getClanMember(leaderName).getObjectId());
    clan.updateSubPledgeInDB(subPledge.getId());

    final L2ClanMember leaderSubPledge = clan.getClanMember(leaderName);
    final L2PcInstance leaderPlayer = leaderSubPledge.getPlayerInstance();
    if (leaderPlayer != null) {
      leaderPlayer.setPledgeClass(leaderSubPledge.calculatePledgeClass(leaderPlayer));
      leaderPlayer.sendPacket(new UserInfo(leaderPlayer));
      leaderPlayer.sendPacket(new ExBrExtraUserInfo(leaderPlayer));
    }

    clan.broadcastClanStatus();
    SystemMessage sm = new SystemMessage(SystemMessageId.C1_HAS_BEEN_SELECTED_AS_CAPTAIN_OF_S2);
    sm.addString(leaderName);
    sm.addString(clanName);
    clan.broadcastToOnlineMembers(sm);
    sm = null;
  }
Пример #10
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";
  }
  /** @see com.l2jserver.gameserver.model.L2Effect#onActionTime() */
  @Override
  public boolean onActionTime() {
    if (getCount() == getTotalCount() - 1) return true; // do nothing first time
    int mpConsume = getSkill().getMpConsume();

    L2PcInstance caster = (L2PcInstance) getEffector();

    for (L2Character cha :
        _actor.getKnownList().getKnownCharactersInRadius(getSkill().getSkillRadius())) {
      if (cha == null) continue;

      if (cha instanceof L2Playable) {
        if (caster.canAttackCharacter(cha)) {
          L2PcInstance owner = null;
          if (cha instanceof L2Summon) owner = ((L2Summon) cha).getOwner();
          else owner = (L2PcInstance) cha;

          if (owner != null && owner.getPet() != null) {
            if (mpConsume > getEffector().getCurrentMp()) {
              getEffector()
                  .sendPacket(
                      SystemMessage.getSystemMessage(SystemMessageId.SKILL_REMOVED_DUE_LACK_MP));
              return false;
            } else getEffector().reduceCurrentMp(mpConsume);

            owner.getPet().unSummon(owner);
            owner.getAI().notifyEvent(CtrlEvent.EVT_ATTACKED, getEffector());
          }
        }
      }
    }
    return true;
  }
Пример #12
0
  @Override
  public boolean doDie(L2Character killer) {
    if (!super.doDie(killer)) {
      return false;
    }

    final L2PcInstance player = killer.getActingPlayer();
    if (player != null) {
      broadcastPacket(
          SystemMessage.getSystemMessage(SystemMessageId.CONGRATULATIONS_YOUR_RAID_WAS_SUCCESSFUL));
      if (player.getParty() != null) {
        for (L2PcInstance member : player.getParty().getMembers()) {
          member.setRaidPoints(member.getRaidPoints() + ((getLevel() / 2) + Rnd.get(-5, 5)));
          if (member.isNoble()) {
            Hero.getInstance().setRBkilled(member.getObjectId(), getId());
          }
        }
      } else {
        player.setRaidPoints(player.getRaidPoints() + ((getLevel() / 2) + Rnd.get(-5, 5)));
        if (player.isNoble()) {
          Hero.getInstance().setRBkilled(player.getObjectId(), getId());
        }
      }
    }

    RaidBossSpawnManager.getInstance().updateStatus(this, true);
    return true;
  }
Пример #13
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);
    }
  }
Пример #14
0
  public boolean add(String name) {
    SystemMessage sm;

    int contactId = CharNameTable.getInstance().getIdByName(name);
    if (_contacts.contains(name)) {
      activeChar.sendPacket(SystemMessageId.NAME_ALREADY_EXIST_ON_CONTACT_LIST);
      return false;
    } else if (activeChar.getName().equals(name)) {
      activeChar.sendPacket(SystemMessageId.CANNOT_ADD_YOUR_NAME_ON_CONTACT_LIST);
      return false;
    } else if (_contacts.size() >= 100) {
      activeChar.sendPacket(SystemMessageId.CONTACT_LIST_LIMIT_REACHED);
      return false;
    } else if (contactId < 1) {
      sm = SystemMessage.getSystemMessage(SystemMessageId.NAME_S1_NOT_EXIST_TRY_ANOTHER_NAME);
      sm.addString(name);
      activeChar.sendPacket(sm);
      return false;
    } else {
      for (String contactName : _contacts) {
        if (contactName.equalsIgnoreCase(name)) {
          activeChar.sendPacket(SystemMessageId.NAME_ALREADY_EXIST_ON_CONTACT_LIST);
          return false;
        }
      }
    }

    try (Connection con = ConnectionFactory.getInstance().getConnection();
        PreparedStatement ps = con.prepareStatement(QUERY_ADD)) {
      ps.setInt(1, activeChar.getObjectId());
      ps.setInt(2, contactId);
      ps.execute();

      _contacts.add(name);

      sm = SystemMessage.getSystemMessage(SystemMessageId.S1_SUCCESSFULLY_ADDED_TO_CONTACT_LIST);
      sm.addString(name);
      activeChar.sendPacket(sm);
    } catch (Exception e) {
      _log.log(
          Level.WARNING,
          "Error found in " + activeChar.getName() + "'s ContactsList: " + e.getMessage(),
          e);
    }
    return true;
  }
Пример #15
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;
 }
  private static final boolean checkAndChangeClass(L2PcInstance player, int val) {
    final ClassId currentClassId = player.getClassId();
    if (getMinLevel(currentClassId.level()) > player.getLevel() && !Config.ALLOW_ENTIRE_TREE)
      return false;

    if (!validateClassId(currentClassId, val)) return false;

    int newJobLevel = currentClassId.level() + 1;

    // Weight/Inventory check
    if (!Config.CLASS_MASTER_SETTINGS.getRewardItems(newJobLevel).isEmpty()
        && !player.isInventoryUnder80(false)) {
      player.sendPacket(
          SystemMessage.getSystemMessage(SystemMessageId.INVENTORY_LESS_THAN_80_PERCENT));
      return false;
    }

    // check if player have all required items for class transfer
    for (int _itemId : Config.CLASS_MASTER_SETTINGS.getRequireItems(newJobLevel).keys()) {
      int _count = Config.CLASS_MASTER_SETTINGS.getRequireItems(newJobLevel).get(_itemId);
      if (player.getInventory().getInventoryItemCount(_itemId, -1) < _count) {
        player.sendPacket(SystemMessageId.NOT_ENOUGH_ITEMS);
        return false;
      }
    }

    // get all required items for class transfer
    for (int _itemId : Config.CLASS_MASTER_SETTINGS.getRequireItems(newJobLevel).keys()) {
      int _count = Config.CLASS_MASTER_SETTINGS.getRequireItems(newJobLevel).get(_itemId);
      if (!player.destroyItemByItemId("ClassMaster", _itemId, _count, player, true)) return false;
    }

    // reward player with items
    for (int _itemId : Config.CLASS_MASTER_SETTINGS.getRewardItems(newJobLevel).keys()) {
      int _count = Config.CLASS_MASTER_SETTINGS.getRewardItems(newJobLevel).get(_itemId);
      player.addItem("ClassMaster", _itemId, _count, player, true);
    }

    player.setClassId(val);

    if (player.isSubClassActive())
      player.getSubClasses().get(player.getClassIndex()).setClassId(player.getActiveClass());
    else player.setBaseClass(player.getActiveClass());

    Quest q = QuestManager.getInstance().getQuest("SkillTransfer");
    if (q != null) q.startQuestTimer("givePormanders", 1, null, player);

    player.broadcastUserInfo();

    if (Config.CLASS_MASTER_SETTINGS.isAllowed(player.getClassId().level() + 1)
        && Config.ALTERNATE_CLASS_MASTER
        && ((player.getClassId().level() == 1 && player.getLevel() >= 40)
            || (player.getClassId().level() == 2 && player.getLevel() >= 76)))
      showQuestionMark(player);

    return true;
  }
Пример #17
0
 @Override
 public void onStart(BuffInfo info) {
   if (info.getEffected().isPlayer()) {
     final L2Clan clan = info.getEffected().getActingPlayer().getClan();
     if (clan != null) {
       SystemMessage msg =
           SystemMessage.getSystemMessage(SystemMessageId.COURT_MAGICIAN_CREATED_PORTAL);
       clan.broadcastToOtherOnlineMembers(msg, info.getEffected().getActingPlayer());
     }
   }
 }
Пример #18
0
  /**
   * Do the countdown and send message to players if necessary
   *
   * @return current count
   */
  public int countdown() {
    _countdown--;

    if (_countdown > 3) {
      return _countdown;
    }

    // Broadcast countdown to duelists
    SystemMessage sm = null;
    if (_countdown > 0) {
      sm = SystemMessage.getSystemMessage(SystemMessageId.THE_DUEL_WILL_BEGIN_IN_S1_SECOND_S);
      sm.addInt(_countdown);
    } else {
      sm = SystemMessage.getSystemMessage(SystemMessageId.LET_THE_DUEL_BEGIN);
    }

    broadcastToTeam1(sm);
    broadcastToTeam2(sm);

    return _countdown;
  }
  @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);
    }
  }
Пример #20
0
 @Override
 public void run() {
   if (_player != null) {
     if (_player.isOnline()) {
       final long hours = TimeUnit.MILLISECONDS.toHours(_player.getUptime());
       _player.sendPacket(
           SystemMessage.getSystemMessage(
                   SystemMessageId.YOU_HAVE_PLAYED_FOR_S1_HOUR_S_PLEASE_TAKE_A_BREAK)
               .addLong(hours));
     } else {
       _player.stopWarnUserTakeBreak();
     }
   }
 }
Пример #21
0
  @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);
  }
  /**
   * this displays PledgeSkillList to the player.
   *
   * @param player
   */
  public static final void showPledgeSkillList(L2PcInstance player) {
    if (player.getClan() == null || !player.isClanLeader()) {
      NpcHtmlMessage html = new NpcHtmlMessage(1);
      html.setFile(player.getHtmlPrefix(), "data/html/villagemaster/NotClanLeader.htm");
      player.sendPacket(html);
      player.sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }

    L2PledgeSkillLearn[] skills = SkillTreeTable.getInstance().getAvailablePledgeSkills(player);
    AcquireSkillList asl = new AcquireSkillList(AcquireSkillList.SkillType.Clan);
    int counts = 0;

    for (L2PledgeSkillLearn s : skills) {
      int cost = s.getRepCost();
      int itemCount = s.getItemCount();
      counts++;

      asl.addSkill(s.getId(), s.getLevel(), s.getLevel(), cost, itemCount);
    }

    if (counts == 0) {
      if (player.getClan().getLevel() < 8) {
        SystemMessage sm = new SystemMessage(SystemMessageId.DO_NOT_HAVE_FURTHER_SKILLS_TO_LEARN);
        if (player.getClan().getLevel() < 5) sm.addNumber(5);
        else sm.addNumber(player.getClan().getLevel() + 1);
        player.sendPacket(sm);
      } else {
        NpcHtmlMessage html = new NpcHtmlMessage(1);
        html.setFile(player.getHtmlPrefix(), "data/html/villagemaster/NoMoreSkills.htm");
        player.sendPacket(html);
      }
    } else player.sendPacket(asl);

    player.sendPacket(ActionFailed.STATIC_PACKET);
  }
 @Override
 public void reduceCurrentHp(double damage, L2Character attacker, L2Skill skill) {
   super.reduceCurrentHp(damage, attacker, skill);
   if (canTalk()) {
     if ((getCastle() != null && getCastle().getSiege().getIsInProgress())
         || (getFort() != null && getFort().getSiege().getIsInProgress())
         || (getConquerableHall() != null && getConquerableHall().isInSiege())) {
       if (_clan != null) {
         // send warning to owners of headquarters that theirs base is under attack
         _clan.broadcastToOnlineMembers(
             SystemMessage.getSystemMessage(SystemMessageId.BASE_UNDER_ATTACK));
         setCanTalk(false);
         ThreadPoolManager.getInstance().scheduleGeneral(new ScheduleTalkTask(), 20000);
       }
     }
   }
 }
  /**
   * Handle chat type 'partymatchroom'
   *
   * @see net.sf.l2j.gameserver.handler.IChatHandler#handleChat(int,
   *     net.sf.l2j.gameserver.model.actor.instance.L2PcInstance, java.lang.String)
   */
  public void handleChat(int type, L2PcInstance activeChar, String target, String text) {
    if (activeChar.isInPartyMatchRoom()) {
      PartyMatchRoom _room = PartyMatchRoomList.getInstance().getPlayerRoom(activeChar);
      if (_room != null) {
        if (activeChar.isChatBanned() && Util.contains(Config.BAN_CHAT_CHANNELS, type)) {
          activeChar.sendPacket(
              SystemMessage.getSystemMessage(SystemMessageId.CHATTING_IS_CURRENTLY_PROHIBITED));
          return;
        }

        CreatureSay cs =
            new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text);
        for (L2PcInstance _member : _room.getPartyMembers()) {
          _member.sendPacket(cs);
        }
      }
    }
  }
Пример #25
0
  @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;
  }
Пример #26
0
  /**
   * Sets reenter time for every player in the instance.
   *
   * @param world the instance
   * @param time the time in milliseconds
   */
  protected void setReenterTime(InstanceWorld world, long time) {
    for (int objectId : world.getAllowed()) {
      InstanceManager.getInstance().setInstanceTime(objectId, world.getTemplateId(), time);
      final L2PcInstance player = L2World.getInstance().getPlayer(objectId);
      if ((player != null) && player.isOnline()) {
        player.sendPacket(
            SystemMessage.getSystemMessage(
                    SystemMessageId
                        .INSTANT_ZONE_S1_S_ENTRY_HAS_BEEN_RESTRICTED_YOU_CAN_CHECK_THE_NEXT_POSSIBLE_ENTRY_TIME_BY_USING_THE_COMMAND_INSTANCEZONE)
                .addString(
                    InstanceManager.getInstance().getInstance(world.getInstanceId()).getName()));
      }
    }

    if (Config.DEBUG_INSTANCES) {
      _log.info(
          "Time restrictions has been set for player in instance ID: "
              + world.getInstanceId()
              + " ("
              + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(time)
              + ")");
    }
  }
Пример #27
0
  public Duel(L2PcInstance playerA, L2PcInstance playerB, int partyDuel, int duelId) {
    _duelId = duelId;
    _playerA = playerA;
    _playerB = playerB;
    _partyDuel = partyDuel == 1 ? true : false;

    _duelEndTime = Calendar.getInstance();
    _duelEndTime.add(Calendar.SECOND, _partyDuel ? PARTY_DUEL_DURATION : PLAYER_DUEL_DURATION);

    setFinished(false);

    if (_partyDuel) {
      // inform players that they will be ported shortly
      SystemMessage sm =
          SystemMessage.getSystemMessage(
              SystemMessageId
                  .IN_A_MOMENT_YOU_WILL_BE_TRANSPORTED_TO_THE_SITE_WHERE_THE_DUEL_WILL_TAKE_PLACE);
      broadcastToTeam1(sm);
      broadcastToTeam2(sm);
    }
    // Schedule duel start
    ThreadPoolManager.getInstance().scheduleGeneral(new ScheduleStartDuelTask(this), 3000);
  }
Пример #28
0
  @Override
  public void useSkill(L2Character activeChar, L2Object[] targets) {
    if (activeChar.isAlikeDead()) {
      return;
    }

    boolean ss = useSoulShot() && activeChar.isChargedShot(ShotType.SOULSHOTS);
    boolean sps = useSpiritShot() && activeChar.isChargedShot(ShotType.SPIRITSHOTS);
    boolean bss = useSpiritShot() && activeChar.isChargedShot(ShotType.BLESSED_SPIRITSHOTS);

    for (L2Character target : (L2Character[]) targets) {
      if (target.isAlikeDead() && (getTargetType() != L2TargetType.CORPSE_MOB)) {
        continue;
      }

      if ((activeChar != target) && target.isInvul()) {
        continue; // No effect on invulnerable chars unless they cast it themselves.
      }

      boolean mcrit = Formulas.calcMCrit(activeChar.getMCriticalHit(target, this));
      byte shld = Formulas.calcShldUse(activeChar, target, this);
      int damage =
          isStaticDamage()
              ? (int) getPower()
              : (int) Formulas.calcMagicDam(activeChar, target, this, shld, sps, bss, mcrit);

      int _drain = 0;
      int _cp = (int) target.getCurrentCp();
      int _hp = (int) target.getCurrentHp();

      if (_cp > 0) {
        if (damage < _cp) {
          _drain = 0;
        } else {
          _drain = damage - _cp;
        }
      } else if (damage > _hp) {
        _drain = _hp;
      } else {
        _drain = damage;
      }

      double hpAdd = _absorbAbs + (_absorbPart * _drain);
      double hp =
          ((activeChar.getCurrentHp() + hpAdd) > activeChar.getMaxHp()
              ? activeChar.getMaxHp()
              : (activeChar.getCurrentHp() + hpAdd));

      activeChar.setCurrentHp(hp);

      StatusUpdate suhp = new StatusUpdate(activeChar);
      suhp.addAttribute(StatusUpdate.CUR_HP, (int) hp);
      activeChar.sendPacket(suhp);

      // Check to see if we should damage the target
      if ((damage > 0) && (!target.isDead() || (getTargetType() != L2TargetType.CORPSE_MOB))) {
        // Manage attack or cast break of the target (calculating rate, sending message...)
        if (!target.isRaid() && Formulas.calcAtkBreak(target, damage)) {
          target.breakAttack();
          target.breakCast();
        }

        activeChar.sendDamageMessage(target, damage, mcrit, false, false);

        if (Config.LOG_GAME_DAMAGE
            && activeChar.isPlayable()
            && (damage > Config.LOG_GAME_DAMAGE_THRESHOLD)) {
          LogRecord record = new LogRecord(Level.INFO, "");
          record.setParameters(
              new Object[] {activeChar, " did damage ", damage, this, " to ", target});
          record.setLoggerName("mdam");
          _logDamage.log(record);
        }

        if (hasEffects() && (getTargetType() != L2TargetType.CORPSE_MOB)) {
          // ignoring vengance-like reflections
          if ((Formulas.calcSkillReflect(target, this) & Formulas.SKILL_REFLECT_SUCCEED) > 0) {
            activeChar.stopSkillEffects(getId());
            getEffects(target, activeChar);
            SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_FEEL_S1_EFFECT);
            sm.addSkillName(getId());
            activeChar.sendPacket(sm);
          } else {
            // activate attacked effects, if any
            target.stopSkillEffects(getId());
            if (Formulas.calcSkillSuccess(activeChar, target, this, shld, ss, sps, bss)) {
              getEffects(activeChar, target);
            } else {
              SystemMessage sm =
                  SystemMessage.getSystemMessage(SystemMessageId.C1_RESISTED_YOUR_S2);
              sm.addCharName(target);
              sm.addSkillName(this);
              activeChar.sendPacket(sm);
            }
          }
        }

        target.reduceCurrentHp(damage, activeChar, this);
      }

      // Check to see if we should do the decay right after the cast
      if (target.isDead() && (getTargetType() == L2TargetType.CORPSE_MOB) && target.isNpc()) {
        ((L2Npc) target).endDecayTask();
      }
    }
    // effect self :]
    L2Effect effect = activeChar.getFirstEffect(getId());
    if ((effect != null) && effect.isSelfEffect()) {
      // Replace old effect with new one.
      effect.exit();
    }
    // cast self effect if any
    getEffectsSelf(activeChar);
    // Consume shot
    activeChar.setChargedShot(bss ? ShotType.BLESSED_SPIRITSHOTS : ShotType.SPIRITSHOTS, false);
  }
  @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;
  }
Пример #30
0
  private void updateOwnerInDB() {
    L2Clan clan = getOwnerClan();
    int clanId = 0;
    if (clan != null) {
      clanId = clan.getId();
      _lastOwnedTime.setTimeInMillis(System.currentTimeMillis());
    } else {
      _lastOwnedTime.setTimeInMillis(0);
    }

    try (Connection con = ConnectionFactory.getInstance().getConnection();
        PreparedStatement ps =
            con.prepareStatement(
                "UPDATE fort SET owner=?,lastOwnedTime=?,state=?,castleId=? WHERE id = ?")) {
      ps.setInt(1, clanId);
      ps.setLong(2, _lastOwnedTime.getTimeInMillis());
      ps.setInt(3, 0);
      ps.setInt(4, 0);
      ps.setInt(5, getResidenceId());
      ps.execute();

      // Announce to clan members
      if (clan != null) {
        clan.setFortId(getResidenceId()); // Set has fort flag for new owner
        SystemMessage sm;
        sm =
            SystemMessage.getSystemMessage(
                SystemMessageId.S1_IS_VICTORIOUS_IN_THE_FORTRESS_BATTLE_OF_S2);
        sm.addString(clan.getName());
        sm.addCastleId(getResidenceId());
        L2World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm));
        clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
        clan.broadcastToOnlineMembers(new PlaySound(1, "Siege_Victory", 0, 0, 0, 0, 0));
        if (_FortUpdater[0] != null) {
          _FortUpdater[0].cancel(false);
        }
        if (_FortUpdater[1] != null) {
          _FortUpdater[1].cancel(false);
        }
        _FortUpdater[0] =
            ThreadPoolManager.getInstance()
                .scheduleGeneralAtFixedRate(
                    new FortUpdater(this, clan, 0, UpdaterType.PERIODIC_UPDATE),
                    Config.FS_UPDATE_FRQ * 60000L,
                    Config.FS_UPDATE_FRQ * 60000L); // Schedule owner tasks to start running
        if (Config.FS_MAX_OWN_TIME > 0) {
          _FortUpdater[1] =
              ThreadPoolManager.getInstance()
                  .scheduleGeneralAtFixedRate(
                      new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME),
                      3600000,
                      3600000); // Schedule owner tasks to remove owener
        }
      } else {
        if (_FortUpdater[0] != null) {
          _FortUpdater[0].cancel(false);
        }
        _FortUpdater[0] = null;
        if (_FortUpdater[1] != null) {
          _FortUpdater[1].cancel(false);
        }
        _FortUpdater[1] = null;
      }
    } catch (Exception e) {
      _log.log(Level.WARNING, "Exception: updateOwnerInDB(L2Clan clan): " + e.getMessage(), e);
    }
  }