Esempio n. 1
0
  public synchronized void doDie(boolean win) {
    if (_fishAiTask != null) {
      _fishAiTask.cancel(false);
      _fishAiTask = null;
    }

    if (_fisher == null) {
      return;
    }

    if (win) {
      final L2FishingMonster fishingMonster =
          FishingMonstersData.getInstance().getFishingMonster(_fisher.getLevel());
      if (fishingMonster != null) {
        if (Rnd.get(100) <= fishingMonster.getProbability()) {
          _fisher.sendPacket(SystemMessageId.YOU_VE_CAUGHT_GOLDEEN);
          final L2Npc monster =
              AbstractScript.addSpawn(fishingMonster.getFishingMonsterId(), _fisher);
          monster.setTarget(_fisher);
        } else {
          _fisher.sendPacket(SystemMessageId.YOU_CAUGHT_SOMETHING);
          _fisher.addItem("Fishing", _fishId, 1, null, true);
          FishingChampionshipManager.getInstance().newFish(_fisher, _lureId);
        }
      }
    }

    _fisher.endFishing(win, true);
    _fisher = null;
  }
Esempio n. 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);
  }
Esempio n. 3
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;
 }
  @Override
  protected void runImpl() {
    final L2PcInstance activeChar = getClient().getActiveChar();
    if (activeChar == null) {
      return;
    }

    activeChar.sendPacket(new UserInfo(activeChar));
    activeChar.sendPacket(new ExBrExtraUserInfo(activeChar));

    Collection<L2Object> objs = activeChar.getKnownList().getKnownObjects().values();
    for (L2Object object : objs) {
      if (object.getPoly().isMorphed() && object.getPoly().getPolyType().equals("item")) {
        activeChar.sendPacket(new SpawnItem(object));
      } else {
        if (!object.isVisibleFor(activeChar)) {
          object.sendInfo(activeChar);

          if (object instanceof L2Character) {
            // Update the state of the L2Character object client
            // side by sending Server->Client packet
            // MoveToPawn/CharMoveToLocation and AutoAttackStart to
            // the L2PcInstance
            final L2Character obj = (L2Character) object;
            if (obj.getAI() != null) {
              obj.getAI().describeStateToPlayer(activeChar);
            }
          }
        }
      }
    }
  }
  @Override
  protected void runImpl() {
    // Get the current L2PcInstance of the player
    final L2PcInstance activeChar = getClient().getActiveChar();
    if (activeChar == null) {
      return;
    }

    // Get the level of the used skill
    int level = activeChar.getSkillLevel(_skillId);
    if (level <= 0) {
      activeChar.sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }

    // Get the L2Skill template corresponding to the skillID received from the client
    Skill skill = SkillData.getInstance().getSkill(_skillId, level);

    // Check the validity of the skill
    if (skill != null) {
      activeChar.setCurrentSkillWorldPosition(new Location(_x, _y, _z));

      // normally magicskilluse packet turns char client side but for these skills, it doesn't (even
      // with correct target)
      activeChar.setHeading(
          Util.calculateHeadingFrom(activeChar.getX(), activeChar.getY(), _x, _y));
      Broadcast.toKnownPlayers(activeChar, new ValidateLocation(activeChar));

      activeChar.useMagic(skill, _ctrlPressed, _shiftPressed);
    } else {
      activeChar.sendPacket(ActionFailed.STATIC_PACKET);
      _log.warning("No skill found with id " + _skillId + " and level " + level + " !!");
    }
  }
Esempio n. 6
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);
    }
  }
Esempio n. 7
0
  @Override
  public boolean useBypass(String command, L2PcInstance player, L2Character bypassOrigin) {
    final QuestState qs = getQuestState(player, false);
    if ((qs != null)
        || (player.getLevel() < MIN_LEVEL)
        || (player.getLevel() > MAX_LEVEL)
        || (player.getRace() == Race.ERTHEIA)
        || !command.equals("Q10390_Teleport")) {
      return false;
    }

    if (player.isInParty()) {
      player.sendPacket(
          new ExShowScreenMessage("You cannot teleport when you are in party.", 5000));
    } else if (player.isInCombat()) {
      player.sendPacket(
          new ExShowScreenMessage("You cannot teleport when you are in combat.", 5000));
    } else if (player.isInDuel()) {
      player.sendPacket(
          new ExShowScreenMessage("You cannot teleport when you are in a duel.", 5000));
    } else if (player.isInOlympiadMode()) {
      player.sendPacket(
          new ExShowScreenMessage("You cannot teleport when you are in Olympiad.", 5000));
    } else if (player.isInVehicle()) {
      player.sendPacket(
          new ExShowScreenMessage(
              "You cannot teleport when you are in any vehicle or mount.", 5000));
    } else {
      player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
      player.teleToLocation(TP_LOCS[player.getRace().ordinal()]);
    }
    return true;
  }
  /** Handle chat type 'all' */
  @Override
  public void handleChat(int type, L2PcInstance activeChar, String params, String text) {
    boolean vcd_used = false;
    if (text.startsWith(".")) {
      StringTokenizer st = new StringTokenizer(text);
      IVoicedCommandHandler vch;
      String command = "";

      if (st.countTokens() > 1) {
        command = st.nextToken().substring(1);
        params = text.substring(command.length() + 2);
        vch = VoicedCommandHandler.getInstance().getHandler(command);
      } else {
        command = text.substring(1);
        if (Config.DEBUG) {
          _log.info("Command: " + command);
        }
        vch = VoicedCommandHandler.getInstance().getHandler(command);
      }
      if (vch != null) {
        vch.useVoicedCommand(command, activeChar, params);
        vcd_used = true;
      } else {
        if (Config.DEBUG) {
          _log.warning("No handler registered for bypass '" + command + "'");
        }
        vcd_used = false;
      }
    }
    if (!vcd_used) {
      if (activeChar.isChatBanned() && Util.contains(Config.BAN_CHAT_CHANNELS, type)) {
        activeChar.sendPacket(SystemMessageId.CHATTING_IS_CURRENTLY_PROHIBITED);
        return;
      }

      /**
       * Match the character "." literally (Exactly 1 time) Match any character that is NOT a .
       * character. Between one and unlimited times as possible, giving back as needed (greedy)
       */
      if (text.matches("\\.{1}[^\\.]+")) {
        activeChar.sendPacket(SystemMessageId.INCORRECT_SYNTAX);
      } else {
        CreatureSay cs =
            new CreatureSay(
                activeChar.getObjectId(), type, activeChar.getAppearance().getVisibleName(), text);
        Collection<L2PcInstance> plrs = activeChar.getKnownList().getKnownPlayers().values();
        for (L2PcInstance player : plrs) {
          if ((player != null)
              && activeChar.isInsideRadius(player, 1250, false, true)
              && !BlockList.isBlocked(player, activeChar)) {
            player.sendPacket(cs);
          }
        }

        activeChar.sendPacket(cs);
      }
    }
  }
Esempio n. 9
0
 private static final void doObserve(
     final L2PcInstance player, final L2Npc npc, final Location pos, final long cost) {
   if (player.reduceAdena("Broadcast", cost, npc, true)) {
     // enter mode
     player.enterObserverMode(pos);
     player.sendPacket(new ItemList(player, false));
   }
   player.sendPacket(ActionFailed.STATIC_PACKET);
 }
  @Override
  public final boolean useBypass(String command, L2PcInstance activeChar, L2Character target) {
    try {
      final L2Npc olymanager = activeChar.getLastFolkNPC();

      if (command.startsWith(COMMANDS[0])) // list
      {
        if (!Olympiad.getInstance().inCompPeriod()) {
          activeChar.sendPacket(SystemMessageId.THE_OLYMPIAD_GAME_IS_NOT_CURRENTLY_IN_PROGRESS);
          return false;
        }

        activeChar.sendPacket(new ExOlympiadMatchList());
      } else {
        if ((olymanager == null) || !(olymanager instanceof L2OlympiadManagerInstance)) {
          return false;
        }

        if (!activeChar.inObserverMode()
            && !activeChar.isInsideRadius(olymanager, 300, false, false)) {
          return false;
        }

        if (OlympiadManager.getInstance().isRegisteredInComp(activeChar)) {
          activeChar.sendPacket(
              SystemMessageId
                  .WHILE_YOU_ARE_ON_THE_WAITING_LIST_YOU_ARE_NOT_ALLOWED_TO_WATCH_THE_GAME);
          return false;
        }

        if (!Olympiad.getInstance().inCompPeriod()) {
          activeChar.sendPacket(SystemMessageId.THE_OLYMPIAD_GAME_IS_NOT_CURRENTLY_IN_PROGRESS);
          return false;
        }

        if (activeChar.isOnEvent()) {
          activeChar.sendMessage("You can not observe games while registered on an event");
          return false;
        }

        final int arenaId = Integer.parseInt(command.substring(12).trim());
        final OlympiadGameTask nextArena =
            OlympiadGameManager.getInstance().getOlympiadTask(arenaId);
        if (nextArena != null) {
          activeChar.enterOlympiadObserverMode(
              nextArena.getZone().getSpectatorSpawns().get(0), arenaId);
          activeChar.setInstanceId(
              OlympiadGameManager.getInstance().getOlympiadTask(arenaId).getZone().getInstanceId());
        }
      }
      return true;

    } catch (Exception e) {
      _log.log(Level.WARNING, "Exception in " + getClass().getSimpleName(), e);
    }
    return false;
  }
Esempio n. 11
0
 @Override
 public void run() {
   try {
     activeChar.sendPacket(SystemMessageId.YOU_ARE_NO_LONGER_TRYING_ON_EQUIPMENT2);
     activeChar.sendPacket(new ExUserInfoEquipSlot(activeChar));
   } catch (Exception e) {
     _log.log(Level.SEVERE, "", e);
   }
 }
Esempio n. 12
0
  @Override
  public boolean useBypass(String command, L2PcInstance activeChar, L2Character target) {
    if (!(target instanceof L2ObservationInstance)) {
      return false;
    }

    if (activeChar.hasSummon()) {
      activeChar.sendPacket(
          SystemMessageId.YOU_MAY_NOT_OBSERVE_A_SIEGE_WITH_A_PET_OR_SERVITOR_SUMMONED);
      return false;
    }
    if (activeChar.isOnEvent()) {
      activeChar.sendMessage("Cannot use while current Event");
      return false;
    }

    String _command = command.split(" ")[0].toLowerCase();
    final int param;
    try {
      param = Integer.parseInt(command.split(" ")[1]);
    } catch (NumberFormatException nfe) {
      _log.log(Level.WARNING, "Exception in " + getClass().getSimpleName(), nfe);
      return false;
    }

    if ((param < 0) || (param > (LOCATIONS.length - 1))) {
      return false;
    }
    final int[] locCost = LOCATIONS[param];

    Location loc = new Location(locCost[0], locCost[1], locCost[2]);
    final long cost = locCost[3];

    switch (_command) {
      case "observesiege":
        {
          if (SiegeManager.getInstance().getSiege(loc) != null) {
            doObserve(activeChar, (L2Npc) target, loc, cost);
          } else {
            activeChar.sendPacket(SystemMessageId.OBSERVATION_IS_ONLY_POSSIBLE_DURING_A_SIEGE);
          }
          return true;
        }
      case "observeoracle": // Oracle Dusk/Dawn
        {
          doObserve(activeChar, (L2Npc) target, loc, cost);
          return true;
        }
      case "observe": // Observe
        {
          doObserve(activeChar, (L2Npc) target, loc, cost);
          return true;
        }
    }
    return false;
  }
  @Override
  public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
    final QuestState st = getQuestState(player, false);
    if (st == null) {
      return null;
    }

    String htmltext = event;
    switch (event) {
      case "32711-04.html":
        if (player.getLevel() >= 79) {
          st.startQuest();
          htmltext =
              (st.hasQuestItems(CET_1_SHEET, CET_2_SHEET, CET_3_SHEET))
                  ? "32711-04a.html"
                  : "32711-04.html";
        }
        break;
      case "32711-05a.html":
        player.sendPacket(new RadarControl(0, 2, 186214, 61591, -4152));
        break;
      case "32711-05b.html":
        player.sendPacket(new RadarControl(0, 2, 187554, 60800, -4984));
        break;
      case "32711-05c.html":
        player.sendPacket(new RadarControl(0, 2, 193432, 53922, -4368));
        break;
      case "spawn":
        if (!hasQuestItems(player, CET_1_SHEET, CET_2_SHEET, CET_3_SHEET)) {
          return getNoQuestMsg(player);
        } else if ((hekaton != null) && !hekaton.isDead()) {
          return "32711-09.html";
        }
        String respawn = loadGlobalQuestVar("Respawn");
        long remain =
            (!respawn.isEmpty()) ? Long.parseLong(respawn) - System.currentTimeMillis() : 0;
        if (remain > 0) {
          return "32711-09a.html";
        }
        st.takeItems(CET_1_SHEET, 1);
        st.takeItems(CET_2_SHEET, 1);
        st.takeItems(CET_3_SHEET, 1);
        hekaton = addSpawn(HEKATON_PRIME, 191777, 56197, -7624, 0, false, 0);
        htmltext = "32711-09.html";
        break;
      case "32711-03.htm":
      case "32711-05.html":
      case "32711-06.html":
        break;
      default:
        htmltext = null;
        break;
    }
    return htmltext;
  }
Esempio n. 14
0
  @Override
  protected void runImpl() {
    final L2PcInstance player = getClient().getActiveChar();
    if (player == null) return;

    final TradeList trade = player.getActiveTradeList();
    if (trade == null) {
      _log.warning(
          "Character: "
              + player.getName()
              + " requested item:"
              + _objectId
              + " add without active tradelist:"
              + _tradeId);
      return;
    }

    final L2PcInstance partner = trade.getPartner();
    if (partner == null
        || L2World.getInstance().getPlayer(partner.getObjectId()) == null
        || partner.getActiveTradeList() == null) {
      // Trade partner not found, cancel trade
      if (partner != null)
        _log.warning(
            "Character:" + player.getName() + " requested invalid trade object: " + _objectId);
      SystemMessage msg = new SystemMessage(SystemMessageId.TARGET_IS_NOT_FOUND_IN_THE_GAME);
      player.sendPacket(msg);
      player.cancelActiveTrade();
      return;
    }

    if (trade.isConfirmed() || partner.getActiveTradeList().isConfirmed()) {
      player.sendPacket(
          new SystemMessage(SystemMessageId.CANNOT_ADJUST_ITEMS_AFTER_TRADE_CONFIRMED));
      return;
    }

    if (!player.getAccessLevel().allowTransaction()) {
      player.sendMessage("Transactions are disable for your Access Level");
      player.cancelActiveTrade();
      return;
    }

    if (!player.validateItemManipulation(_objectId, "trade")) {
      player.sendPacket(new SystemMessage(SystemMessageId.NOTHING_HAPPENED));
      return;
    }

    final TradeList.TradeItem item = trade.addItem(_objectId, _count);
    if (item != null) {
      player.sendPacket(new TradeOwnAdd(item));
      trade.getPartner().sendPacket(new TradeOtherAdd(item));
    }
  }
Esempio n. 15
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;
   }
 }
Esempio n. 16
0
  /**
   * Broadcast a packet to the challenged team
   *
   * @param packet
   */
  public void broadcastToTeam2(L2GameServerPacket packet) {
    if (_playerB == null) {
      return;
    }

    if (_partyDuel && (_playerB.getParty() != null)) {
      for (L2PcInstance temp : _playerB.getParty().getMembers()) {
        temp.sendPacket(packet);
      }
    } else {
      _playerB.sendPacket(packet);
    }
  }
Esempio n. 17
0
  private static final void doObserve(L2PcInstance player, L2Npc npc, String val) {
    StringTokenizer st = new StringTokenizer(val);
    long cost = Long.parseLong(st.nextToken());
    int x = Integer.parseInt(st.nextToken());
    int y = Integer.parseInt(st.nextToken());
    int z = Integer.parseInt(st.nextToken());

    if (player.reduceAdena("Broadcast", cost, npc, true)) {
      // enter mode
      player.enterObserverMode(x, y, z);
      player.sendPacket(new ItemList(player, false));
    }
    player.sendPacket(ActionFailed.STATIC_PACKET);
  }
Esempio n. 18
0
  public void deleteRoom(int id) {
    for (L2PcInstance _member : getRoom(id).getPartyMembers()) {
      if (_member == null) {
        continue;
      }

      _member.sendPacket(new ExClosePartyRoom());
      _member.sendPacket(SystemMessageId.PARTY_ROOM_DISBANDED);

      _member.setPartyRoom(0);
      // _member.setPartyMatching(0);
      _member.broadcastUserInfo();
    }
    _rooms.remove(id);
  }
Esempio n. 19
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;
 }
  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 final synchronized void enterInstance(L2PcInstance player) {
    // check for existing instances for this player
    InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
    if (world != null) {
      if (world.templateId != INSTANCE_ID) {
        player.sendPacket(SystemMessageId.ALREADY_ENTERED_ANOTHER_INSTANCE_CANT_ENTER);
        return;
      }
      Instance inst = InstanceManager.getInstance().getInstance(world.instanceId);
      if (inst != null) {
        teleportPlayer(player, TELEPORT, world.instanceId);
      }
      return;
    }
    // New instance
    final int instanceId =
        InstanceManager.getInstance().createDynamicInstance("PailakaSongOfIceAndFire.xml");

    world = new InstanceWorld();
    world.instanceId = instanceId;
    world.templateId = INSTANCE_ID;
    InstanceManager.getInstance().addWorld(world);

    world.allowed.add(player.getObjectId());
    teleportPlayer(player, TELEPORT, instanceId);
  }
Esempio n. 22
0
  public L2Fishing(
      L2PcInstance Fisher, L2Fish fish, boolean isNoob, boolean isUpperGrade, int lureId) {
    _fisher = Fisher;
    _fishMaxHp = fish.getFishHp();
    _fishCurHp = _fishMaxHp;
    _regenHp = fish.getHpRegen();
    _fishId = fish.getItemId();
    _time = fish.getCombatDuration();
    _isUpperGrade = isUpperGrade;
    _lureId = lureId;
    final int lureType;
    if (isUpperGrade) {
      _deceptiveMode = ((Rnd.get(100) >= 90) ? 1 : 0);
      lureType = 2;
    } else {
      _deceptiveMode = 0;
      lureType = (isNoob ? 0 : 1);
    }
    _mode = ((Rnd.get(100) >= 80) ? 1 : 0);

    _fisher.broadcastPacket(
        new ExFishingStartCombat(_fisher, _time, _fishMaxHp, _mode, lureType, _deceptiveMode));
    _fisher.sendPacket(new PlaySound(1, "SF_S_01", 0, 0, 0, 0, 0));
    // Succeeded in getting a bite
    // _fisher.sendPacket(SystemMessageId.YOU_VE_GOT_A_BITE);

    if ((_fishAiTask == null) && _fisher.isFishing()) {
      _fishAiTask = ThreadPoolManager.getInstance().scheduleEffectAtFixedRate(this, 1000, 1000);
    }

    // TODO: New fishing system?
    doDie(true);
  }
 private void showSiegeTimePage(L2PcInstance activeChar) {
   final NpcHtmlMessage adminReply = new NpcHtmlMessage();
   adminReply.setFile(activeChar.getHtmlPrefix(), "data/html/admin/territorywartime.htm");
   adminReply.replace(
       "%time%", TerritoryWarManager.getInstance().getTWStart().getTime().toString());
   activeChar.sendPacket(adminReply);
 }
Esempio n. 24
0
  @Override
  protected void runImpl() {
    if (Config.DEBUG) {
      _log.log(Level.FINE, "Info for clan " + _clanId + " requested");
    }

    final L2PcInstance activeChar = getClient().getActiveChar();
    if (activeChar == null) {
      return;
    }

    final L2Clan clan = ClanTable.getInstance().getClan(_clanId);
    if (clan == null) {
      if (Config.DEBUG) {
        _log.warning(
            getType()
                + ": Clan data for clanId "
                + _clanId
                + " is missing for player "
                + activeChar);
      }
      return; // we have no clan data ?!? should not happen
    }

    activeChar.sendPacket(new PledgeInfo(clan));
  }
  private void showFortSelectPage(L2PcInstance activeChar) {
    int i = 0;
    final NpcHtmlMessage adminReply = new NpcHtmlMessage();
    adminReply.setFile(activeChar.getHtmlPrefix(), "data/html/admin/forts.htm");

    final List<Fort> forts = FortManager.getInstance().getForts();
    final StringBuilder cList = new StringBuilder(forts.size() * 100);

    for (Fort fort : forts) {
      if (fort != null) {
        // L2JTW uses fort.getCName() instead of fort.getName()
        StringUtil.append(
            cList,
            "<td fixwidth=90><a action=\"bypass -h admin_fortsiege ",
            String.valueOf(fort.getResidenceId()),
            "\">",
            fort.getName(),
            " id: ",
            String.valueOf(fort.getResidenceId()),
            "</a></td>");
        i++;
      }
      // L2JTW: if (i > 0)
      if (i > 2) {
        cList.append("</tr><tr>");
        i = 0;
      }
    }

    adminReply.replace("%forts%", cList.toString());
    activeChar.sendPacket(adminReply);
  }
 @Override
 protected void runImpl() {
   final L2PcInstance activeChar = getActiveChar();
   if (activeChar != null) {
     activeChar.sendPacket(new HennaEquipList(activeChar));
   }
 }
Esempio n. 27
0
 private final String funcConfirmHtml(
     final L2PcInstance player,
     final L2Npc npc,
     final Castle castle,
     final int func,
     final int level) {
   if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_SET_FUNCTIONS)) {
     final NpcHtmlMessage html;
     final String fstring = (func == Castle.FUNC_TELEPORT) ? "9" : "10";
     if (level == 0) {
       html = getHtmlPacket(player, npc, "castleresetdeco.html");
       html.replace("%AgitDecoSubmit%", Integer.toString(func));
     } else if ((castle.getFunction(func) != null)
         && (castle.getFunction(func).getLvl() == level)) {
       html = getHtmlPacket(player, npc, "castledecoalreadyset.html");
       html.replace("%AgitDecoEffect%", "<fstring p1=\"" + level + "\">" + fstring + "</fstring>");
     } else {
       html = getHtmlPacket(player, npc, "castledeco-0" + func + ".html");
       html.replace(
           "%AgitDecoCost%",
           "<fstring p1=\""
               + getFunctionFee(func, level)
               + "\" p2=\""
               + (getFunctionRatio(func) / 86400000)
               + "\">6</fstring>");
       html.replace("%AgitDecoEffect%", "<fstring p1=\"" + level + "\">" + fstring + "</fstring>");
       html.replace("%AgitDecoSubmit%", func + " " + level);
     }
     player.sendPacket(html);
     return null;
   }
   return "chamberlain-21.html";
 }
Esempio n. 28
0
  @Override
  public boolean useBypass(String command, L2PcInstance activeChar, L2Character target) {
    if (!target.isNpc()) {
      return false;
    }

    final L2Npc npc = (L2Npc) target;
    final NpcHtmlMessage html = new NpcHtmlMessage(npc.getObjectId());
    {
      if (npc.getCastle().getOwnerId() > 0) {
        html.setFile(activeChar.getHtmlPrefix(), "data/html/territorystatus.htm");
        L2Clan clan = ClanTable.getInstance().getClan(npc.getCastle().getOwnerId());
        html.replace("%clanname%", clan.getName());
        html.replace("%clanleadername%", clan.getLeaderName());
      } else {
        html.setFile(activeChar.getHtmlPrefix(), "data/html/territorynoclan.htm");
      }
    }
    html.replace("%castlename%", npc.getCastle().getName());
    html.replace("%taxpercent%", "" + npc.getCastle().getTaxPercent());
    html.replace("%objectId%", String.valueOf(npc.getObjectId()));
    {
      if (npc.getCastle().getResidenceId() > 6) {
        html.replace("%territory%", "The Kingdom of Elmore");
      } else {
        html.replace("%territory%", "The Kingdom of Aden");
      }
    }
    activeChar.sendPacket(html);
    return true;
  }
Esempio n. 29
0
  @RegisterEvent(EventType.ON_PLAYER_LEVEL_CHANGED)
  @RegisterType(ListenerRegisterType.GLOBAL)
  public void OnPlayerLevelChanged(OnPlayerLevelChanged event) {
    final L2PcInstance player = event.getActiveChar();
    final int oldLevel = event.getOldLevel();
    final int newLevel = event.getNewLevel();

    if (((oldLevel == (newLevel - 1)) && (player.getLevel() >= MIN_LEVEL))
        && (player.getLevel() <= MAX_LEVEL)
        && !(player.getRace() == Race.ERTHEIA)) {
      final QuestState qs = getQuestState(player, false);
      if (qs == null) {
        final NpcHtmlMessage html = new NpcHtmlMessage(0, 0);
        html.setHtml(
            HtmCache.getInstance()
                .getHtm(
                    player.getHtmlPrefix(),
                    "scripts/quests/Q10390_KekropusLetter/"
                        + "Announce_"
                        + player.getRace().name()
                        + ".html"));
        player.sendPacket(html);
        // todo: get proper announce html && handle it
      }
      return;
    }
  }
 private void showFortSiegePage(L2PcInstance activeChar, Fort fort) {
   final NpcHtmlMessage adminReply = new NpcHtmlMessage();
   adminReply.setFile(activeChar.getHtmlPrefix(), "data/html/admin/fort.htm");
   // L2JTW uses fort.getCName() instead of fort.getName()
   adminReply.replace("%fortName%", fort.getName());
   adminReply.replace("%fortId%", String.valueOf(fort.getResidenceId()));
   activeChar.sendPacket(adminReply);
 }