コード例 #1
0
ファイル: Auction.java プロジェクト: impos89/l2emu
  /** Remove bids */
  private void removeBids() {
    Connection con = null;
    try {
      con = L2DatabaseFactory.getInstance().getConnection(con);
      PreparedStatement statement;

      statement = con.prepareStatement("DELETE FROM auction_bid WHERE auctionId=?");
      statement.setInt(1, getId());
      statement.execute();

      statement.close();
    } catch (Exception e) {
      _log.fatal("Exception: Auction.deleteFromDB(): " + e.getMessage(), e);
    } finally {
      L2DatabaseFactory.close(con);
    }

    for (Bidder b : _bidders.values()) {
      if (ClanTable.getInstance().getClanByName(b.getClanName()).getHasHideout() == 0)
        returnItem(b.getClanName(), PcInventory.ADENA_ID, b.getBid(), true); // 10 % tax
      else {
        L2Player bidder = L2World.getInstance().getPlayer(b.getName());
        if (bidder != null) bidder.sendMessage("Congratulations! You have won a ClanHall!");
      }
      ClanTable.getInstance().getClanByName(b.getClanName()).setAuctionBiddedAt(0, true);
    }
    _bidders.clear();
  }
コード例 #2
0
ファイル: RequestKeyMapping.java プロジェクト: impos89/l2emu
  /** @see net.l2emuproject.gameserver.clientpackets.L2GameClientPacket#runImpl() */
  @Override
  protected void runImpl() {
    L2Player activeChar = getClient().getActiveChar();
    if (activeChar == null) return;

    if (Config.STORE_UI_SETTINGS) activeChar.sendPacket(new ExUiSetting(activeChar));
  }
コード例 #3
0
ファイル: DuelRestriction.java プロジェクト: impos89/l2emu
  @Override
  public final boolean canTeleport(L2Player activeChar) {
    // Check to see if player is in a duel
    if (activeChar.getPlayerDuel().isInDuel()) {
      activeChar.sendMessage("You can't teleport during a duel.");
      return false;
    }

    return true;
  }
コード例 #4
0
ファイル: DuelRestriction.java プロジェクト: impos89/l2emu
  @Override
  public final boolean isRestricted(
      L2Player activeChar, Class<? extends GlobalRestriction> callingRestriction) {
    if (activeChar.getPlayerDuel().isInDuel()) {
      activeChar.sendMessage("You are participating in a duel!");
      return true;
    }

    return false;
  }
コード例 #5
0
ファイル: Auction.java プロジェクト: impos89/l2emu
 /**
  * Take Item in WHC
  *
  * @param bidder
  * @param itemId
  * @param quantity
  */
 private boolean takeItem(L2Player bidder, int itemId, int quantity) {
   if (bidder.getClan() != null && bidder.getClan().getWarehouse().getAdena() >= quantity) {
     bidder
         .getClan()
         .getWarehouse()
         .destroyItemByItemId("Auction", PcInventory.ADENA_ID, quantity, bidder, bidder);
     return true;
   }
   bidder.sendPacket(SystemMessageId.NOT_ENOUGH_ADENA_IN_CWH);
   return false;
 }
コード例 #6
0
ファイル: GrailApostleStrong.java プロジェクト: impos89/l2emu
  @Override
  public void transformedSkills(L2Player player) {
    int level = -1;
    if (player.getLevel() >= 60) level = 4;
    else if (player.getLevel() >= 1) level = 1;
    {
      addSkill(player, 559, level); // Spear
      addSkill(player, 560, level); // Power Slash
      addSkill(player, 561, level); // Bless of Angel
      addSkill(player, 562, level); // Wind of Angel
    }

    player.getPlayerTransformation().addTransformAllowedSkill(SKILLS);
  }
コード例 #7
0
ファイル: CrownManager.java プロジェクト: impos89/l2emu
  public static void checkCrowns(L2Player activeChar) {
    if (activeChar == null) return;

    int crownId = -1;
    boolean isLeader = false;

    final L2Clan clan = activeChar.getClan();

    if (clan != null) {
      final Castle castle = CastleManager.getInstance().getCastleByOwner(clan);

      if (castle != null) crownId = CrownTable.getCrownId(castle.getCastleId());

      if (clan.getLeaderId() == activeChar.getObjectId()) isLeader = true;
    }

    boolean alreadyFoundCirclet = false;
    boolean alreadyFoundCrown = false;

    for (L2ItemInstance item : activeChar.getInventory().getItems()) {
      if (ArrayUtils.contains(CrownTable.getCrownIds(), item.getItemId())) {
        if (crownId > 0) {
          if (item.getItemId() == crownId) {
            if (!alreadyFoundCirclet) {
              alreadyFoundCirclet = true;
              continue;
            }
          } else if (item.getItemId() == 6841 && isLeader) {
            if (!alreadyFoundCrown) {
              alreadyFoundCrown = true;
              continue;
            }
          }
        }

        // WRONG! The crown is not sellable/tradeable/dropable
        // And the circlets are sellable!!!, but not tradeable or dropable
        // Unequip is what happens
        if (item.getItemId() == 6841 || Config.ALT_REMOVE_CASTLE_CIRCLETS)
          activeChar.destroyItem("Removing Crown", item, activeChar, true);
        else if (item.isEquipped())
          activeChar.getInventory().unEquipItemInSlot(Inventory.PAPERDOLL_HAIR2);

        // No need to update every item in the inventory
        // activeChar.getInventory().updateDatabase();
      }
    }
  }
コード例 #8
0
ファイル: Auction.java プロジェクト: impos89/l2emu
  /** Set a bid */
  public synchronized void setBid(L2Player bidder, int bid) {
    int requiredAdena = bid;
    if (getHighestBidderName().equals(bidder.getClan().getLeaderName()))
      requiredAdena = bid - getHighestBidderMaxBid();

    if ((getHighestBidderId() > 0 && bid > getHighestBidderMaxBid())
        || (getHighestBidderId() == 0 && bid >= getStartingBid())) {
      if (takeItem(bidder, PcInventory.ADENA_ID, requiredAdena)) {
        updateInDB(bidder, bid);
        bidder.getClan().setAuctionBiddedAt(_id, true);
        return;
      }
    }
    if ((bid < getStartingBid()) || (bid <= getHighestBidderMaxBid()))
      bidder.sendPacket(SystemMessageId.BID_PRICE_MUST_BE_HIGHER);
  }
コード例 #9
0
ファイル: PurchaseBracelet.java プロジェクト: impos89/l2emu
  @Override
  public final String onAdvEvent(String event, L2Npc npc, L2Player player) {
    String htmltext = event;
    QuestState st = player.getQuestState(QN);

    if (st == null) return htmltext;

    if (st.getQuestItemsCount(BIG_RED_NIMBLE_FISH) >= 25
        && st.getQuestItemsCount(GREAT_CODRAN) >= 50
        && st.getQuestItemsCount(MEMENTO_MORI) >= 4
        && st.getQuestItemsCount(EARTH_EGG) >= 5
        && st.getQuestItemsCount(NONLIVING_NUCLEUS) >= 5
        && st.getQuestItemsCount(DRAGON_HEART) >= 3
        && st.getQuestItemsCount(57) >= 7500000) {
      st.takeItems(BIG_RED_NIMBLE_FISH, 25);
      st.takeItems(GREAT_CODRAN, 50);
      st.takeItems(MEMENTO_MORI, 4);
      st.takeItems(EARTH_EGG, 5);
      st.takeItems(NONLIVING_NUCLEUS, 5);
      st.takeItems(DRAGON_HEART, 3);
      st.takeAdena(7500000);

      if (event.equalsIgnoreCase("Little_Angel")) st.giveItems(ANGEL_BRACELET, 1);
      else if (event.equalsIgnoreCase("Little_Devil")) st.giveItems(DEVIL_BRACELET, 1);
    } else htmltext = "30098-no.htm";

    st.exitQuest(true);
    return htmltext;
  }
コード例 #10
0
ファイル: L2CharacterAI.java プロジェクト: impos89/l2emu
  /**
   * Modify current Intention and actions if the target is lost.<br>
   * <br>
   * <B><U> Actions</U> : <I>If the target is lost</I></B><br>
   * <br>
   * <li>Stop the actor auto-attack client side by sending Server->Client packet AutoAttackStop
   *     (broadcast)
   * <li>Stop the actor movement server side AND client side by sending Server->Client packet
   *     StopMove/StopRotation (broadcast)
   * <li>Set the Intention of this AbstractAI to AI_INTENTION_ACTIVE<br>
   *     <br>
   *     <B><U> Example of use </U> :</B><br>
   *     <br>
   * <li>L2PLayerAI, L2SummonAI<br>
   *     <br>
   *
   * @param target The targeted L2Object
   * @return True if the target is lost
   */
  protected boolean checkTargetLost(L2Object target) {
    // check if player is fakedeath
    if (target instanceof L2Player) {
      L2Player target2 = (L2Player) target; // convert object to chara

      if (target2.isFakeDeath()) {
        target2.stopFakeDeath(true);
        return false;
      }
    }
    if (target == null) {
      // Set the Intention of this AbstractAI to AI_INTENTION_ACTIVE
      setIntention(AI_INTENTION_ACTIVE);
      return true;
    }
    return false;
  }
コード例 #11
0
ファイル: PurchaseBracelet.java プロジェクト: impos89/l2emu
  @Override
  public final String onTalk(L2Npc npc, L2Player player) {
    QuestState st = player.getQuestState(QN);

    if (st == null) st = newQuestState(player);

    return "30098.htm";
  }
コード例 #12
0
ファイル: MagicLeader.java プロジェクト: impos89/l2emu
  @Override
  public void transformedSkills(L2Player player) {
    {
      addSkill(player, 874, 1); // Magic Leader Flame Strike
      addSkill(player, 875, 1); // Magic Leader Empower
    }

    player.getPlayerTransformation().addTransformAllowedSkill(SKILLS);
  }
コード例 #13
0
ファイル: DivineKnight.java プロジェクト: impos89/l2emu
  @Override
  public void transformedSkills(L2Player player) {
    {
      addSkill(player, 680, 1); // Divine Knight Hate
      addSkill(player, 681, 1); // Divine Knight Hate Aura
      addSkill(player, 682, 1); // Divine Knight Stun Attack
      addSkill(player, 683, 1); // Divine Knight Thunder Storm
      addSkill(player, 684, 1); // Divine Knight Ultimate Defense
      addSkill(player, 685, 1); // Sacrifice Knight
      addSkill(player, 795, 1); // Divine Knight Brandish
      addSkill(player, 796, 1); // Divine Knight Explosion
    }

    player.getPlayerTransformation().addTransformAllowedSkill(SKILLS);
  }
コード例 #14
0
ファイル: ChannelLeave.java プロジェクト: impos89/l2emu
  /* (non-Javadoc)
   * @see net.l2emuproject.gameserver.handler.IUserCommandHandler#useUserCommand(int, net.l2emuproject.gameserver.model.L2PcInstance)
   */
  @Override
  public boolean useUserCommand(int id, L2Player activeChar) {
    if (id != COMMAND_IDS[0]) return false;

    if (activeChar.isInParty()) {
      if (activeChar.getParty().isLeader(activeChar)
          && activeChar.getParty().isInCommandChannel()) {
        L2Party party = activeChar.getParty();
        L2CommandChannel channel = party.getCommandChannel();
        channel.removeParty(party);

        SystemMessage sm = SystemMessageId.LEFT_COMMAND_CHANNEL.getSystemMessage();
        party.broadcastToPartyMembers(sm);
        sm = new SystemMessage(SystemMessageId.C1_PARTY_LEFT_COMMAND_CHANNEL);
        sm.addString(activeChar.getName());
        channel.broadcastToChannelMembers(sm);
        return true;
      }

      activeChar.sendPacket(SystemMessageId.ONLY_PARTY_LEADER_CAN_LEAVE_CHANNEL);
    }

    return false;
  }
コード例 #15
0
ファイル: DuelRestriction.java プロジェクト: impos89/l2emu
  @Override
  public final boolean canInviteToParty(L2Player activeChar, L2Player target) {
    if (activeChar.getPlayerDuel().isInDuel() || target.getPlayerDuel().isInDuel()) return false;

    return true;
  }
コード例 #16
0
ファイル: Auction.java プロジェクト: impos89/l2emu
  /** Update auction in DB */
  private void updateInDB(L2Player bidder, int bid) {
    Connection con = null;
    try {
      con = L2DatabaseFactory.getInstance().getConnection(con);
      PreparedStatement statement;

      if (getBidders().get(bidder.getClanId()) != null) {
        statement =
            con.prepareStatement(
                "UPDATE auction_bid SET bidderId=?, bidderName=?, maxBid=?, time_bid=? WHERE auctionId=? AND bidderId=?");
        statement.setInt(1, bidder.getClanId());
        statement.setString(2, bidder.getClan().getLeaderName());
        statement.setInt(3, bid);
        statement.setLong(4, System.currentTimeMillis());
        statement.setInt(5, getId());
        statement.setInt(6, bidder.getClanId());
        statement.execute();
        statement.close();
      } else {
        statement =
            con.prepareStatement(
                "INSERT INTO auction_bid (id, auctionId, bidderId, bidderName, maxBid, clan_name, time_bid) VALUES (?, ?, ?, ?, ?, ?, ?)");
        statement.setInt(1, IdFactory.getInstance().getNextId());
        statement.setInt(2, getId());
        statement.setInt(3, bidder.getClanId());
        statement.setString(4, bidder.getName());
        statement.setInt(5, bid);
        statement.setString(6, bidder.getClan().getName());
        statement.setLong(7, System.currentTimeMillis());
        statement.execute();
        statement.close();
        L2Player highest = L2World.getInstance().getPlayer(_highestBidderName);
        if (highest != null) highest.sendMessage("You have been out bidded");
      }
      _highestBidderId = bidder.getClanId();
      _highestBidderMaxBid = bid;
      _highestBidderName = bidder.getClan().getLeaderName();
      if (_bidders.get(_highestBidderId) == null) {
        _bidders.put(
            _highestBidderId,
            new Bidder(
                _highestBidderName, bidder.getClan().getName(), bid, System.currentTimeMillis()));
      } else {
        _bidders.get(_highestBidderId).setBid(bid);
        _bidders.get(_highestBidderId).setTimeBid(System.currentTimeMillis());
      }
      bidder.sendPacket(SystemMessageId.BID_IN_CLANHALL_AUCTION);
    } catch (Exception e) {
      _log.fatal("Exception: Auction.updateInDB(L2Player bidder, int bid): ", e);
    } finally {
      L2DatabaseFactory.close(con);
    }
  }