示例#1
0
文件: Duel.java 项目: 3mRe/L2Java
  /** Playback the bow animation for all looser */
  public void playKneelAnimation() {
    L2PcInstance looser = getLooser();

    if (looser == null) {
      return;
    }

    if (_partyDuel && (looser.getParty() != null)) {
      for (L2PcInstance temp : looser.getParty().getMembers()) {
        temp.broadcastPacket(new SocialAction(temp.getObjectId(), 7));
      }
    } else {
      looser.broadcastPacket(new SocialAction(looser.getObjectId(), 7));
    }
  }
示例#2
0
  /**
   * Use the sit action.
   *
   * @param activeChar the player trying to sit
   * @param target the target to sit, throne, bench or chair
   * @return {@code true} if the player can sit, {@code false} otherwise
   */
  protected boolean useSit(L2PcInstance activeChar, L2Object target) {
    if (activeChar.getMountType() != MountType.NONE) {
      return false;
    }

    if (!activeChar.isSitting()
        && (target instanceof L2StaticObjectInstance)
        && (((L2StaticObjectInstance) target).getType() == 1)
        && activeChar.isInsideRadius(
            target, L2StaticObjectInstance.INTERACTION_DISTANCE, false, false)) {
      final ChairSit cs = new ChairSit(activeChar, target.getId());
      sendPacket(cs);
      activeChar.sitDown();
      activeChar.broadcastPacket(cs);
      return true;
    }

    if (activeChar.isFakeDeath()) {
      activeChar.stopEffects(L2EffectType.FAKE_DEATH);
    } else if (activeChar.isSitting()) {
      activeChar.standUp();
    } else {
      activeChar.sitDown();
    }
    return true;
  }
示例#3
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);
  }
示例#4
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);
  }
示例#5
0
 @Override
 public void run() {
   GrandBossManager.getInstance().setBossStatus(_bossId, DORMANT);
   if (FWA_DOSERVEREARTHQUAKE) {
     for (L2PcInstance p : L2World.getInstance().getAllPlayersArray()) {
       p.broadcastPacket(new Earthquake(185708, 114298, -8221, 20, 10));
     }
   }
 }
示例#6
0
  /**
   * Try to broadcast SocialAction packet.
   *
   * @param id the social action Id to broadcast
   */
  private void tryBroadcastSocial(int id) {
    final L2PcInstance activeChar = getActiveChar();
    if (activeChar == null) {
      return;
    }
    if (activeChar.isFishing()) {
      sendPacket(SystemMessageId.YOU_CANNOT_DO_THAT_WHILE_FISHING);
      return;
    }

    if (activeChar.canMakeSocialAction()) {
      activeChar.broadcastPacket(new SocialAction(activeChar.getObjectId(), id));
    }
  }
示例#7
0
  /**
   * @see com.l2jserver.gameserver.handler.IVoicedCommandHandler#useVoicedCommand(java.lang.String,
   *     com.l2jserver.gameserver.model.actor.instance.L2PcInstance, java.lang.String)
   */
  public boolean useVoicedCommand(String command, L2PcInstance activeChar, String params) {
    String screenMsgNoble = "Congratulations On Becoming A Noblesse!";

    try {
      if (validateNobleCommand(activeChar)
          && activeChar.destroyItemByItemId(
              "Noble", 3470, Config.L2JMOD_SYSTEM_NOBLE_AMOUNT_ITEM, activeChar, true)) {
        activeChar.startParalyze();
        activeChar.setNoble(true);
        activeChar.sendPacket(new UserInfo(activeChar));
        activeChar.sendPacket(new ExBrExtraUserInfo(activeChar));
        ExShowScreenMessage showMessage =
            new ExShowScreenMessage(screenMsgNoble, Config.L2JMOD_CUSTOM_WHITE_SCREEN_MESSAGE_TIME);
        activeChar.sendPacket(showMessage);
        activeChar.startAbnormalEffect(AbnormalEffect.REAL_TARGET);
        activeChar.startAbnormalEffect(AbnormalEffect.MAGIC_CIRCLE);
        activeChar.broadcastPacket(new PlaySound("Itemsound.quest_finish"));
        activeChar.setIsTeleporting(true); // block movements
        ThreadPoolManager.getInstance()
            .scheduleGeneral(
                new Runnable() {

                  @Override
                  public void run() {
                    activeChar.stopAbnormalEffect(AbnormalEffect.REAL_TARGET);
                    activeChar.stopAbnormalEffect(AbnormalEffect.MAGIC_CIRCLE);
                    activeChar.setIsTeleporting(false); // restore movements
                  }
                },
                Config.L2JMOD_CUSTOM_WHITE_SCREEN_MESSAGE_TIME / 3);
      }
    } catch (Exception e) {
      _log.log(
          Level.SEVERE,
          "Error when trying to become the player:"
              + activeChar.getName()
              + " in noble: "
              + e.getMessage(),
          e);
    }

    return true;
  }
示例#8
0
  protected void aiTask() {
    if (_thinking) {
      return;
    }
    _thinking = true;
    _time--;

    try {
      if (_mode == 1) {
        if (_deceptiveMode == 0) {
          _fishCurHp += (int) _regenHp;
        }
      } else {
        if (_deceptiveMode == 1) {
          _fishCurHp += (int) _regenHp;
        }
      }
      if (_stop == 0) {
        _stop = 1;
        int check = Rnd.get(100);
        if (check >= 70) {
          _mode = _mode == 0 ? 1 : 0;
        }
        if (_isUpperGrade) {
          check = Rnd.get(100);
          if (check >= 90) {
            _deceptiveMode = _deceptiveMode == 0 ? 1 : 0;
          }
        }
      } else {
        _stop--;
      }
    } finally {
      _thinking = false;
      ExFishingHpRegen efhr =
          new ExFishingHpRegen(_fisher, _time, _fishCurHp, _mode, 0, _anim, 0, _deceptiveMode);
      if (_anim != 0) {
        _fisher.broadcastPacket(efhr);
      } else {
        _fisher.sendPacket(efhr);
      }
    }
  }
示例#9
0
  public void changeHp(int hp, int pen) {
    _fishCurHp -= hp;
    if (_fishCurHp < 0) {
      _fishCurHp = 0;
    }

    _fisher.broadcastPacket(
        new ExFishingHpRegen(
            _fisher, _time, _fishCurHp, _mode, _goodUse, _anim, pen, _deceptiveMode));
    _anim = 0;
    if (_fishCurHp > (_fishMaxHp * 2)) {
      _fishCurHp = _fishMaxHp * 2;
      doDie(false);
      return;
    } else if (_fishCurHp == 0) {
      doDie(true);
      return;
    }
  }
  @Override
  protected void runImpl() {
    L2PcInstance player = getClient().getActiveChar();
    if (player == null) {
      return;
    }

    if (_items == null) {
      player.setPrivateStoreType(PrivateStoreType.NONE);
      player.broadcastUserInfo();
      return;
    }

    if (!player.getAccessLevel().allowTransaction()) {
      player.sendPacket(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_DO_THAT);
      return;
    }

    if (AttackStanceTaskManager.getInstance().hasAttackStanceTask(player) || player.isInDuel()) {
      player.sendPacket(
          SystemMessageId
              .WHILE_YOU_ARE_ENGAGED_IN_COMBAT_YOU_CANNOT_OPERATE_A_PRIVATE_STORE_OR_PRIVATE_WORKSHOP);
      player.sendPacket(new PrivateStoreManageListBuy(player));
      player.sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }

    if (player.isInsideZone(ZoneId.NO_STORE)) {
      player.sendPacket(new PrivateStoreManageListBuy(player));
      player.sendPacket(SystemMessageId.YOU_CANNOT_OPEN_A_PRIVATE_STORE_HERE);
      player.sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }

    if (!player.canOpenPrivateStore()) {
      player.sendPacket(new PrivateStoreManageListBuy(player));
      player.sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }

    TradeList tradeList = player.getBuyList();
    tradeList.clear();

    // Check maximum number of allowed slots for pvt shops
    if (_items.length > player.getPrivateBuyStoreLimit()) {
      player.sendPacket(new PrivateStoreManageListBuy(player));
      player.sendPacket(SystemMessageId.YOU_HAVE_EXCEEDED_THE_QUANTITY_THAT_CAN_BE_INPUTTED);
      return;
    }

    long totalCost = 0;
    for (Item i : _items) {
      if (!i.addToTradeList(tradeList)) {
        Util.handleIllegalPlayerAction(
            player,
            "Warning!! Character "
                + player.getName()
                + " of account "
                + player.getAccountName()
                + " tried to set price more than "
                + MAX_ADENA
                + " adena in Private Store - Buy.",
            Config.DEFAULT_PUNISH);
        return;
      }

      totalCost += i.getCost();
      if (totalCost > MAX_ADENA) {
        Util.handleIllegalPlayerAction(
            player,
            "Warning!! Character "
                + player.getName()
                + " of account "
                + player.getAccountName()
                + " tried to set total price more than "
                + MAX_ADENA
                + " adena in Private Store - Buy.",
            Config.DEFAULT_PUNISH);
        return;
      }
    }

    // Check for available funds
    if (totalCost > player.getAdena()) {
      player.sendPacket(new PrivateStoreManageListBuy(player));
      player.sendPacket(
          SystemMessageId
              .THE_PURCHASE_PRICE_IS_HIGHER_THAN_THE_AMOUNT_OF_MONEY_THAT_YOU_HAVE_AND_SO_YOU_CANNOT_OPEN_A_PERSONAL_STORE);
      return;
    }

    player.sitDown();
    player.setPrivateStoreType(PrivateStoreType.BUY);
    player.broadcastUserInfo();
    player.broadcastPacket(new PrivateStoreMsgBuy(player));
  }
  private void setEnchant(L2PcInstance activeChar, int ench, int armorType) {
    // get the target
    L2Object target = activeChar.getTarget();
    if (target == null) {
      target = activeChar;
    }
    L2PcInstance player = null;
    if (target instanceof L2PcInstance) {
      player = (L2PcInstance) target;
    } else {
      activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET);
      return;
    }

    // now we need to find the equipped weapon of the targeted character...
    int curEnchant = 0; // display purposes only
    L2ItemInstance itemInstance = null;

    // only attempt to enchant if there is a weapon equipped
    L2ItemInstance parmorInstance = player.getInventory().getPaperdollItem(armorType);
    if ((parmorInstance != null) && (parmorInstance.getLocationSlot() == armorType)) {
      itemInstance = parmorInstance;
    }

    if (itemInstance != null) {
      curEnchant = itemInstance.getEnchantLevel();

      // set enchant value
      player.getInventory().unEquipItemInSlot(armorType);
      itemInstance.setEnchantLevel(ench);
      player.getInventory().equipItem(itemInstance);

      // send packets
      InventoryUpdate iu = new InventoryUpdate();
      iu.addModifiedItem(itemInstance);
      player.sendPacket(iu);
      player.broadcastPacket(new CharInfo(player));
      player.sendPacket(new UserInfo(player));
      player.broadcastPacket(new ExBrExtraUserInfo(player));

      // informations
      activeChar.sendMessage(
          "Changed enchantment of "
              + player.getName()
              + "'s "
              + itemInstance.getItem().getName()
              + " from "
              + curEnchant
              + " to "
              + ench
              + ".");
      player.sendMessage(
          "Admin has changed the enchantment of your "
              + itemInstance.getItem().getName()
              + " from "
              + curEnchant
              + " to "
              + ench
              + ".");
    }
  }
  @Override
  protected void runImpl() {
    L2PcInstance player = getClient().getActiveChar();
    if (player == null) return;

    if (_items == null) {
      player.setPrivateStoreType(L2PcInstance.STORE_PRIVATE_NONE);
      player.broadcastUserInfo();
      return;
    }

    if (AttackStanceTaskManager.getInstance().getAttackStanceTask(player) || player.isInDuel()) {
      player.sendPacket(
          SystemMessage.getSystemMessage(SystemMessageId.CANT_OPERATE_PRIVATE_STORE_DURING_COMBAT));
      player.sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }

    if (player.isInsideZone(L2Character.ZONE_NOSTORE)) {
      player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NO_PRIVATE_WORKSHOP_HERE));
      player.sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }

    L2ManufactureList createList = new L2ManufactureList();

    List<L2RecipeList> dwarfRecipes = Arrays.asList(player.getDwarvenRecipeBook());
    List<L2RecipeList> commonRecipes = Arrays.asList(player.getCommonRecipeBook());

    for (Recipe i : _items) {
      L2RecipeList list = RecipeController.getInstance().getRecipeList(i.getRecipeId());

      if (!dwarfRecipes.contains(list) && !commonRecipes.contains(list)) {
        Util.handleIllegalPlayerAction(
            player,
            "Warning!! Player "
                + player.getName()
                + " of account "
                + player.getAccountName()
                + " tried to set recipe which he dont have.",
            Config.DEFAULT_PUNISH);
        return;
      }

      if (!i.addToList(createList)) {
        Util.handleIllegalPlayerAction(
            player,
            "Warning!! Character "
                + player.getName()
                + " of account "
                + player.getAccountName()
                + " tried to set price more than "
                + MAX_ADENA
                + " adena in Private Manufacture.",
            Config.DEFAULT_PUNISH);
        return;
      }
    }

    createList.setStoreName(
        player.getCreateList() != null ? player.getCreateList().getStoreName() : "");
    player.setCreateList(createList);

    player.setPrivateStoreType(L2PcInstance.STORE_PRIVATE_MANUFACTURE);
    player.sitDown();
    player.broadcastUserInfo();
    player.sendPacket(new RecipeShopMsg(player));
    player.broadcastPacket(new RecipeShopMsg(player));
  }