Package com.l2jfrozen.gameserver.model.actor.instance

Examples of com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance


  }

  @Override
  protected void runImpl()
  {
    L2PcInstance activeChar = getClient().getActiveChar();
    if(activeChar == null)
      return;

    L2PcInstance requestor = activeChar.getActiveRequester();
    if(requestor == null)
      return;

    if(_answer == 1)
    {
      requestor.deathPenalty(false);
      ClanTable.getInstance().deleteclanswars(requestor.getClanId(), activeChar.getClanId());
    }
    else
    {}

    activeChar.onTransactionRequest(null);
View Full Code Here


  {
    if (Config.DEBUG)
      _log.fine("DEBUG "+getType()+": ActionId: " + _actionId + " , ObjectID: " + _objectId);

    // Get the current L2PcInstance of the player
    final L2PcInstance activeChar = getClient().getActiveChar();
   
    if(activeChar == null)
      return;
   
    if (activeChar.inObserverMode())
    {
      getClient().sendPacket(new SystemMessage(SystemMessageId.OBSERVERS_CANNOT_PARTICIPATE));
      getClient().sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }
   
    final L2Object obj;
   
    if (activeChar.getTargetId() == _objectId)
      obj = activeChar.getTarget();
    else
      obj = L2World.getInstance().findObject(_objectId);
   
    // If object requested does not exist, add warn msg into logs
    if (obj == null)
    {
      // pressing e.g. pickup many times quickly would get you here
      // _log.warning("Character: " + activeChar.getName() + " request action with non existent ObjectID:" + _objectId);
      getClient().sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }

    // Players can't interact with objects in the other instances except from multiverse
    if (obj.getInstanceId() != activeChar.getInstanceId()
        && activeChar.getInstanceId() != -1)
    {
      getClient().sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }
   
    // Only GMs can directly interact with invisible characters
    if (obj instanceof L2PcInstance) {
      L2PcInstance player = (L2PcInstance)obj;
        if (player.getAppearance().getInvisible() && !activeChar.isGM()
          || player.isInArenaEvent() && !activeChar.isInArenaEvent()
          || !player.isInArenaEvent() && activeChar.isInArenaEvent())
        {
          getClient().sendPacket(ActionFailed.STATIC_PACKET);
          return;
        }
    }
View Full Code Here

  }
 
  @Override
  protected void runImpl()
  {
    L2PcInstance activeChar = getClient().getActiveChar();
    L2ItemInstance targetItem = (L2ItemInstance) L2World.getInstance().findObject(_targetItemObjId);
    L2ItemInstance refinerItem = (L2ItemInstance) L2World.getInstance().findObject(_refinerItemObjId);
    L2ItemInstance gemstoneItem = (L2ItemInstance) L2World.getInstance().findObject(_gemstoneItemObjId);

    if(targetItem == null || refinerItem == null || gemstoneItem == null)
      return;

    // Make sure the item is a gemstone
    int gemstoneItemId = gemstoneItem.getItem().getItemId();

    if(gemstoneItemId != 2131 && gemstoneItemId != 2132 && gemstoneItemId != 2133 && gemstoneItemId != 2134)
    {
      activeChar.sendPacket(new SystemMessage(SystemMessageId.THIS_IS_NOT_A_SUITABLE_ITEM));
      return;
    }

    // Check if the gemstoneCount is sufficant
    int itemGrade = targetItem.getItem().getItemGrade();

    switch(itemGrade)
    {
      case L2Item.CRYSTAL_C:
        if(_gemstoneCount != 20 || gemstoneItemId != 2131)
        {
          activeChar.sendPacket(new SystemMessage(SystemMessageId.GEMSTONE_QUANTITY_IS_INCORRECT));
          return;
        }
        break;
      case L2Item.CRYSTAL_B:
        if(_gemstoneCount != 30 || gemstoneItemId != 2132)
        {
          activeChar.sendPacket(new SystemMessage(SystemMessageId.GEMSTONE_QUANTITY_IS_INCORRECT));
          return;
        }
        break;
      case L2Item.CRYSTAL_A:
        if(_gemstoneCount != 20 || gemstoneItemId != 2133)
        {
          activeChar.sendPacket(new SystemMessage(SystemMessageId.GEMSTONE_QUANTITY_IS_INCORRECT));
          return;
        }
        break;
      case L2Item.CRYSTAL_S:
        if(_gemstoneCount != 25 || gemstoneItemId != 2134)
        {
          activeChar.sendPacket(new SystemMessage(SystemMessageId.GEMSTONE_QUANTITY_IS_INCORRECT));
          return;
        }
        break;
    }

    activeChar.sendPacket(new ExConfirmVariationGemstone(_gemstoneItemObjId, _gemstoneCount));
    activeChar.sendPacket(new SystemMessage(SystemMessageId.PRESS_THE_AUGMENT_BUTTON_TO_BEGIN));
  }
View Full Code Here

  }

  @Override
  protected void runImpl()
  {
    L2PcInstance player = getClient().getActiveChar();

    if(player == null)
      return;

    if (!getClient().getFloodProtectors().getTransaction().tryPerformAction("buy"))
    {
      player.sendMessage("You buying too fast.");
      return;
    }
   
    // Alt game - Karma punishment
    if(!Config.ALT_GAME_KARMA_PLAYER_CAN_SHOP && player.getKarma() > 0)
      return;

    L2Object target = player.getTarget();
    if(!player.isGM() && (target == null // No target (ie GM Shop)
        || !(target instanceof L2MerchantInstance) // Target not a merchant and not mercmanager
    || !player.isInsideRadius(target, L2NpcInstance.INTERACTION_DISTANCE, false, false)))
      return; // Distance is too far
   
    String htmlFolder = "";
    L2NpcInstance merchant = null;
    if(target instanceof L2MerchantInstance)
    {
      htmlFolder = "merchant";
      merchant = (L2NpcInstance) target;
    }
    else if(target instanceof L2FishermanInstance)
    {
      htmlFolder = "fisherman";
      merchant = (L2NpcInstance) target;
    }
    else
    {
      return;
    }
   
    if(_listId > 1000000) // lease
    {
      if(merchant.getTemplate().npcId != _listId - 1000000)
      {
        sendPacket(ActionFailed.STATIC_PACKET);
        return;
      }
    }

    long totalPrice = 0;
    // Proceed the sell
    for(int i = 0; i < _count; i++)
    {
      int objectId = _items[i * 3 + 0];
      @SuppressWarnings("unused")
      int itemId = _items[i * 3 + 1];
      int count = _items[i * 3 + 2];

      // Check count
      if(count <= 0 || count > Integer.MAX_VALUE)
      {
        //Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " of account " + player.getAccountName() + " tried to purchase over " + Integer.MAX_VALUE + " items at the same time.", Config.DEFAULT_PUNISH);
        SystemMessage sm = new SystemMessage(SystemMessageId.YOU_HAVE_EXCEEDED_QUANTITY_THAT_CAN_BE_INPUTTED);
        sendPacket(sm);
        sm = null;
        return;
      }

      L2ItemInstance item = player.checkItemManipulation(objectId, count, "sell");
     
      // Check Item
      if(item == null || !item.getItem().isSellable())
      {
        continue;
      }
     
      long price = item.getReferencePrice() / 2;
      totalPrice += price * count;
     
      // Fix exploit during Sell
      if ((Integer.MAX_VALUE / count) < price || totalPrice > Integer.MAX_VALUE)
      {
        //Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " of account " + player.getAccountName() + " tried to purchase over " + MAX_ADENA + " adena worth of goods.", Config.DEFAULT_PUNISH);
        SystemMessage sm = new SystemMessage(SystemMessageId.YOU_HAVE_EXCEEDED_QUANTITY_THAT_CAN_BE_INPUTTED);
        sendPacket(sm);
        sm = null;
        return;
      }
     
      // Check totalPrice
      if(totalPrice <= 0)
      {
        //Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " of account " + player.getAccountName() + " tried to purchase over " + Integer.MAX_VALUE + " adena worth of goods.", Config.DEFAULT_PUNISH);
        SystemMessage sm = new SystemMessage(SystemMessageId.YOU_HAVE_EXCEEDED_QUANTITY_THAT_CAN_BE_INPUTTED);
        sendPacket(sm);
        sm = null;
        return;
      }
     
      item = player.getInventory().destroyItem("Sell", objectId, count, player, null);

      /* TODO: Disabled until Leaseholders are rewritten ;-)
            int price = item.getReferencePrice()*(int)count/2;
            L2ItemInstance li = null;
            L2ItemInstance la = null;
            if (_listId > 1000000)
            {
              li = merchant.findLeaseItem(item.getItemId(),item.getEnchantLevel());
              la = merchant.getLeaseAdena();
              if (li == null || la == null) continue;
              price = li.getPriceToBuy()*(int)count; // player sells, thus merchant buys.
              if (price > la.getCount()) continue;
            }
      */
      /* TODO: Disabled until Leaseholders are rewritten ;-)
              if (item != null && _listId > 1000000)
              {
                li.setCount(li.getCount()+(int)count);
                li.updateDatabase();
                la.setCount(la.getCount()-price);
                la.updateDatabase();
              }
      */
    }
    player.addAdena("Sell", (int) totalPrice, merchant, false);

    String html = HtmCache.getInstance().getHtm("data/html/" + htmlFolder + "/" + merchant.getNpcId() + "-sold.htm");

    if(html != null)
    {
      NpcHtmlMessage soldMsg = new NpcHtmlMessage(merchant.getObjectId());
      soldMsg.setHtml(html.replaceAll("%objectId%", String.valueOf(merchant.getObjectId())));
      player.sendPacket(soldMsg);
    }

    // Update current load as well
    StatusUpdate su = new StatusUpdate(player.getObjectId());
    su.addAttribute(StatusUpdate.CUR_LOAD, player.getCurrentLoad());
    player.sendPacket(su);
    player.sendPacket(new ItemList(player, true));
  }
View Full Code Here

  }

  @Override
  protected void runImpl()
  {
    L2PcInstance _activeChar = getClient().getActiveChar();
    if (_activeChar == null)
      return;
   
    _activeChar.sendPacket(new ExListPartyMatchingWaitingRoom(_activeChar, _page, _minlvl, _maxlvl, _mode));
  }
View Full Code Here

  }

  @Override
  protected void runImpl()
  {
    L2PcInstance _activeChar = getClient().getActiveChar();

    if(_activeChar == null)
      return;

    _activeChar.getKnownList().updateKnownObjects();
    _activeChar.sendPacket(new UserInfo(_activeChar));

    for(L2Object object : _activeChar.getKnownList().getKnownObjects().values())
    {
      if(object == null)
      {
        continue;
      }

      if(object.getPoly().isMorphed() && object.getPoly().getPolyType().equals("item"))
      {
        _activeChar.sendPacket(new SpawnItemPoly(object));
      }
      else
      {
        if(object instanceof L2ItemInstance)
        {
          _activeChar.sendPacket(new SpawnItem((L2ItemInstance) object));
        }
        else if(object instanceof L2DoorInstance)
        {
          _activeChar.sendPacket(new DoorInfo((L2DoorInstance) object, false));
          _activeChar.sendPacket(new DoorStatusUpdate((L2DoorInstance) object));
        }
        else if(object instanceof L2BoatInstance)
        {
          if(!_activeChar.isInBoat() && object != _activeChar.getBoat())
          {
            _activeChar.sendPacket(new VehicleInfo((L2BoatInstance) object));
            ((L2BoatInstance) object).sendVehicleDeparture(_activeChar);
          }
        }
        else if(object instanceof L2StaticObjectInstance)
        {
          _activeChar.sendPacket(new StaticObject((L2StaticObjectInstance) object));
        }
        else if(object instanceof L2NpcInstance)
        {
          _activeChar.sendPacket(new NpcInfo((L2NpcInstance) object, _activeChar));
        }
        else if(object instanceof L2Summon)
        {
          L2Summon summon = (L2Summon) object;

          // Check if the L2PcInstance is the owner of the Pet
          if(_activeChar.equals(summon.getOwner()))
          {
            _activeChar.sendPacket(new PetInfo(summon));

            if(summon instanceof L2PetInstance)
            {
              _activeChar.sendPacket(new PetItemList((L2PetInstance) summon));
            }
          }
          else
          {
            _activeChar.sendPacket(new NpcInfo(summon, _activeChar));
          }

          // The PetInfo packet wipes the PartySpelled (list of active spells' icons).  Re-add them
          summon.updateEffectIcons(true);
        }
        else if(object instanceof L2PcInstance)
        {
          L2PcInstance otherPlayer = (L2PcInstance) object;

          if(otherPlayer.isInBoat())
          {
            otherPlayer.getPosition().setWorldPosition(otherPlayer.getBoat().getPosition().getWorldPosition());
            _activeChar.sendPacket(new CharInfo(otherPlayer));
            int relation = otherPlayer.getRelation(_activeChar);

            if(otherPlayer.getKnownList().getKnownRelations().get(_activeChar.getObjectId()) != null && otherPlayer.getKnownList().getKnownRelations().get(_activeChar.getObjectId()) != relation)
            {
              _activeChar.sendPacket(new RelationChanged(otherPlayer, relation, _activeChar.isAutoAttackable(otherPlayer)));
            }

            _activeChar.sendPacket(new GetOnVehicle(otherPlayer, otherPlayer.getBoat(), otherPlayer.getInBoatPosition().getX(), otherPlayer.getInBoatPosition().getY(), otherPlayer.getInBoatPosition().getZ()));
          }
          else
          {
            _activeChar.sendPacket(new CharInfo(otherPlayer));
            int relation = otherPlayer.getRelation(_activeChar);

            if(otherPlayer.getKnownList().getKnownRelations().get(_activeChar.getObjectId()) != null && otherPlayer.getKnownList().getKnownRelations().get(_activeChar.getObjectId()) != relation)
            {
              _activeChar.sendPacket(new RelationChanged(otherPlayer, relation, _activeChar.isAutoAttackable(otherPlayer)));
            }
          }
        }
View Full Code Here

  }

  @Override
  protected void runImpl()
  {
    L2PcInstance activeChar = getClient().getActiveChar();

    if(activeChar == null)
      return;

    L2PcInstance requestor = activeChar.getRequest().getPartner();

    if(requestor == null)
      return;

    if(_response == 0)
    {
      activeChar.sendPacket(new SystemMessage(SystemMessageId.YOU_DID_NOT_RESPOND_TO_ALLY_INVITATION));
      requestor.sendPacket(new SystemMessage(SystemMessageId.NO_RESPONSE_TO_ALLY_INVITATION));
    }
    else
    {
      if(!(requestor.getRequest().getRequestPacket() instanceof RequestJoinAlly))
        return; // hax

      L2Clan clan = requestor.getClan();
      // we must double check this cause of hack
      if(clan.checkAllyJoinCondition(requestor, activeChar))
      {
        //TODO: Need correct message id
        requestor.sendPacket(new SystemMessage(SystemMessageId.YOU_HAVE_SUCCEEDED_INVITING_FRIEND));
        activeChar.sendPacket(new SystemMessage(SystemMessageId.YOU_ACCEPTED_ALLIANCE));
        activeChar.getClan().setAllyId(clan.getAllyId());
        activeChar.getClan().setAllyName(clan.getAllyName());
        activeChar.getClan().setAllyPenaltyExpiryTime(0, 0);
        activeChar.getClan().setAllyCrest(clan.getAllyCrestId());
View Full Code Here

  }
 
  @Override
  protected void runImpl()
  {
    L2PcInstance player = getClient().getActiveChar();
    if (player == null)
      return;
   
    if (!getClient().getFloodProtectors().getTransaction().tryPerformAction("privatestorebuy"))
    {
      player.sendMessage("You buying items too fast.");
      return;
    }
   
    L2Object object = L2World.getInstance().findObject(_storePlayerId);
    if (object == null || !(object instanceof L2PcInstance))
      return;
   
    L2PcInstance storePlayer = (L2PcInstance) object;
    if (!(storePlayer.getPrivateStoreType() == L2PcInstance.STORE_PRIVATE_SELL || storePlayer.getPrivateStoreType() == L2PcInstance.STORE_PRIVATE_PACKAGE_SELL))
      return;
   
    if (!player.getAccessLevel().allowTransaction())
    {
      player.sendMessage("Unsufficient privileges.");
      player.sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }
   
    TradeList storeList = storePlayer.getSellList();
   
    if (storeList == null)
      return;
   
    // Check if player didn't choose any items
    if (_items == null || _items.length == 0)
    {
      player.sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }
   
    // FIXME: this check should be (and most probabliy is) done in the TradeList mechanics
    long priceTotal = 0;
    for (ItemRequest ir : _items)
    {
      if (ir.getCount() > Integer.MAX_VALUE || ir.getCount() < 0)
      {
        String msgErr = "[RequestPrivateStoreBuy] player " + getClient().getActiveChar().getName() + " tried an overflow exploit, ban this player!";
        Util.handleIllegalPlayerAction(getClient().getActiveChar(), msgErr, Config.DEFAULT_PUNISH);
        return;
      }
     
      TradeItem sellersItem = storeList.getItem(ir.getObjectId());
     
      if (sellersItem == null)
      {
        String msgErr = "[RequestPrivateStoreBuy] player " + getClient().getActiveChar().getName() + " tried to buy an item not sold in a private store (buy), ban this player!";
        Util.handleIllegalPlayerAction(getClient().getActiveChar(), msgErr, Config.DEFAULT_PUNISH);
        return;
      }
     
      if (ir.getPrice() != sellersItem.getPrice())
      {
        String msgErr = "[RequestPrivateStoreBuy] player " + getClient().getActiveChar().getName() + " tried to change the seller's price in a private store (buy), ban this player!";
        Util.handleIllegalPlayerAction(getClient().getActiveChar(), msgErr, Config.DEFAULT_PUNISH);
        return;
      }
     
      L2ItemInstance iEnchant = storePlayer.getInventory().getItemByObjectId(ir.getObjectId());
      int enchant = 0;
      if (iEnchant == null)
      {
        enchant = 0;
      }
      else
      {
        enchant = iEnchant.getEnchantLevel();
      }
      ir.setEnchant(enchant);
     
      priceTotal += ir.getPrice() * ir.getCount();
    }
   
    // FIXME: this check should be (and most probabliy is) done in the TradeList mechanics
    if (priceTotal < 0 || priceTotal > Integer.MAX_VALUE)
    {
      String msgErr = "[RequestPrivateStoreBuy] player " + getClient().getActiveChar().getName() + " tried an overflow exploit, ban this player!";
      Util.handleIllegalPlayerAction(getClient().getActiveChar(), msgErr, Config.DEFAULT_PUNISH);
      return;
    }
   
    if (Config.SELL_BY_ITEM)
    {
      if (player.getItemCount(Config.SELL_ITEM, -1) < priceTotal)
      {
        sendPacket(SystemMessage.sendString("You do not have needed items to buy"));
        sendPacket(ActionFailed.STATIC_PACKET);
        return;
      }
     
    }
    else
    {
      if (player.getAdena() < priceTotal)
      {
        sendPacket(new SystemMessage(SystemMessageId.YOU_NOT_ENOUGH_ADENA));
        sendPacket(ActionFailed.STATIC_PACKET);
        return;
      }
    }
   
    if (storePlayer.getPrivateStoreType() == L2PcInstance.STORE_PRIVATE_PACKAGE_SELL)
    {
      if (storeList.getItemCount() > _count)
      {
        String msgErr = "[RequestPrivateStoreBuy] player " + getClient().getActiveChar().getName() + " tried to buy less items then sold by package-sell, ban this player for bot-usage!";
        Util.handleIllegalPlayerAction(getClient().getActiveChar(), msgErr, Config.DEFAULT_PUNISH);
        return;
      }
    }
   
    if (!storeList.PrivateStoreBuy(player, _items, (int) priceTotal))
    {
      sendPacket(ActionFailed.STATIC_PACKET);
      // Punishment e log in audit
      Util.handleIllegalPlayerAction(storePlayer, "PrivateStore buy has failed due to invalid list or request. Player: " + player.getName(), Config.DEFAULT_PUNISH);
      _log.warning("PrivateStore buy has failed due to invalid list or request. Player: " + player.getName() + ", Private store of: " + storePlayer.getName());
      return;
    }
   
    if (storeList.getItemCount() == 0)
    {
      storePlayer.setPrivateStoreType(L2PcInstance.STORE_PRIVATE_NONE);
      storePlayer.broadcastUserInfo();
    }
   
    /*
     * Lease holders are currently not implemented else if (_seller != null) { // lease shop sell L2MerchantInstance seller = (L2MerchantInstance)_seller; L2ItemInstance ladena = seller.getLeaseAdena(); for (TradeItem ti : buyerlist) { L2ItemInstance li =
     * seller.getLeaseItemByObjectId(ti.getObjectId()); if (li == null) { if (ti.getObjectId() == ladena.getObjectId()) { buyer.addAdena(ti.getCount()); ladena.setCount(ladena.getCount()-ti.getCount()); ladena.updateDatabase(); } continue; } int cnt = li.getCount(); if (cnt < ti.getCount())
View Full Code Here

  protected void readImpl() { }

  @Override
  protected void runImpl()
  {
    L2PcInstance player = getClient().getActiveChar();

    if (player == null)
      return;

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

    if (!player.isClanLeader())
    {
      player.sendPacket(new SystemMessage(SystemMessageId.ONLY_CLAN_LEADER_WITHDRAW_ALLY));
      return;
    }

    L2Clan clan = player.getClan();

    if (clan.getAllyId() == 0)
    {
      player.sendPacket(new SystemMessage(SystemMessageId.NO_CURRENT_ALLIANCES));
      return;
    }

    if (clan.getClanId() == clan.getAllyId())
    {
      player.sendPacket(new SystemMessage(SystemMessageId.ALLIANCE_LEADER_CANT_WITHDRAW));
      return;
    }

    long currentTime = System.currentTimeMillis();

    clan.setAllyId(0);
    clan.setAllyName(null);
    clan.setAllyPenaltyExpiryTime(currentTime + Config.ALT_ALLY_JOIN_DAYS_WHEN_LEAVED * 86400000L, L2Clan.PENALTY_TYPE_CLAN_LEAVED); //24*60*60*1000 = 86400000
    clan.setAllyCrest(0);
    clan.updateClanInDB();

    player.sendPacket(new SystemMessage(SystemMessageId.YOU_HAVE_WITHDRAWN_FROM_ALLIANCE));
  }
View Full Code Here

  }

  @Override
  protected void runImpl()
  {
    L2PcInstance activeChar = getClient().getActiveChar();

    if(activeChar == null)
      return;

    SystemMessage sm;
   
    // ======<Friend List>======
    activeChar.sendPacket(new SystemMessage(SystemMessageId.FRIEND_LIST_HEAD));

    L2PcInstance friend = null;
    for (String friendName : activeChar.getFriendList())
    {
      friend = L2World.getInstance().getPlayer(friendName);
     
      if (friend == null || friend.isOnline()==0)
      {
        // (Currently: Offline)
        sm = new SystemMessage(SystemMessageId.S1_OFFLINE);
        sm.addString(friendName);
      }
View Full Code Here

TOP

Related Classes of com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.