Package net.sf.l2j.gameserver.model.actor.instance

Examples of net.sf.l2j.gameserver.model.actor.instance.L2PcInstance


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

    if (activeChar == null) return;
    if (targetItem == null)
    {
      activeChar.sendPacket(new ExVariationCancelResult(0));
      return;
    }

    // cannot remove augmentation from a not augmented item
    if (!targetItem.isAugmented())
    {
      activeChar.sendPacket(new SystemMessage(SystemMessageId.AUGMENTATION_REMOVAL_CAN_ONLY_BE_DONE_ON_AN_AUGMENTED_ITEM));
      activeChar.sendPacket(new ExVariationCancelResult(0));
      return;
    }

    // get the price
    int price=0;
    switch (targetItem.getItem().getItemGrade())
    {
      case L2Item.CRYSTAL_C:
        if (targetItem.getCrystalCount() < 1720)
          price = 95000;
        else if (targetItem.getCrystalCount() < 2452)
          price = 150000;
        else
          price = 210000;
        break;
      case L2Item.CRYSTAL_B:
        if (targetItem.getCrystalCount() < 1746)
          price = 240000;
        else
          price = 270000;
        break;
      case L2Item.CRYSTAL_A:
        if (targetItem.getCrystalCount() < 2160)
          price = 330000;
        else if (targetItem.getCrystalCount() < 2824)
          price = 390000;
        else
          price = 420000;
        break;
      case L2Item.CRYSTAL_S:
        price = 480000;
        break;
      // any other item type is not augmentable
      default:
        activeChar.sendPacket(new ExVariationCancelResult(0));
        return;
    }

    // try to reduce the players adena
    if (!activeChar.reduceAdena("RequestRefineCancel", price, null, true)) return;

    // unequip item
    if (targetItem.isEquipped()) activeChar.disarmWeapons();

    // remove the augmentation
    targetItem.removeAugmentation();

    // send ExVariationCancelResult
    activeChar.sendPacket(new ExVariationCancelResult(1));

    // send inventory update
    InventoryUpdate iu = new InventoryUpdate();
    iu.addModifiedItem(targetItem);
    activeChar.sendPacket(iu);

    // send system message
    SystemMessage sm = new SystemMessage(SystemMessageId.AUGMENTATION_HAS_BEEN_SUCCESSFULLY_REMOVED_FROM_YOUR_S1);
    sm.addString(targetItem.getItemName());
    activeChar.sendPacket(sm);
  }
View Full Code Here


   * Overloaded method that takes player's name as parameter
   * @param name
   */
  public void oustPartyMember(String name)
  {
    L2PcInstance player = getPlayerByName(name);

    if (player != null)
    {
      if (isLeader(player))
      {
View Full Code Here

      distributeAdena(player, item.getCount(), player);
      ItemTable.getInstance().destroyItem("Party", item, player, null);
      return;
    }

    L2PcInstance target = getActualLooter(player, item.getItemId(), false, player);
    target.addItem("Party", item, player, true);

    // Send messages to other party members about reward
    if (item.getCount() > 1)
    {
      SystemMessage msg = new SystemMessage(SystemMessageId.S1_PICKED_UP_S2_S3);
      msg.addString(target.getName());
      msg.addItemName(item.getItemId());
      msg.addNumber(item.getCount());
      broadcastToPartyMembers(target, msg);
    }
    else
    {
      SystemMessage msg = new SystemMessage(SystemMessageId.S1_PICKED_UP_S2);
      msg.addString(target.getName());
      msg.addItemName(item.getItemId());
      broadcastToPartyMembers(target, msg);
    }
  }
View Full Code Here

    {
      distributeAdena(player, item.getCount(), target);
      return;
    }

    L2PcInstance looter = getActualLooter(player, item.getItemId(), spoil, target);

    looter.addItem(spoil?"Sweep":"Party", item.getItemId(), item.getCount(), player, true);

    // Send messages to other aprty members about reward
    if (item.getCount() > 1)
    {
      SystemMessage msg = spoil ?  new SystemMessage(SystemMessageId.S1_SWEEPED_UP_S2_S3)
                                : new SystemMessage(SystemMessageId.S1_PICKED_UP_S2_S3);
      msg.addString(looter.getName());
      msg.addItemName(item.getItemId());
      msg.addNumber(item.getCount());
      broadcastToPartyMembers(looter, msg);
    }
    else
    {
      SystemMessage msg = spoil ?  new SystemMessage(SystemMessageId.S1_SWEEPED_UP_S2)
                                : new SystemMessage(SystemMessageId.S1_PICKED_UP_S2);
      msg.addString(looter.getName());
      msg.addItemName(item.getItemId());
      broadcastToPartyMembers(looter, msg);
    }
  }
View Full Code Here


        if (object instanceof L2PcInstance)
        {
            // Check if the object added is a L2PcInstance that owns Karma
            L2PcInstance player = (L2PcInstance) object;

            if ( (player.getKarma() > 0) )
            {
                if (Config.DEBUG) _log.fine(getActiveChar().getObjectId()+": PK "+player.getObjectId()+" entered scan range");

                // Set the L2GuardInstance Intention to AI_INTENTION_ACTIVE
                if (getActiveChar().getAI().getIntention() == CtrlIntention.AI_INTENTION_IDLE)
                    getActiveChar().getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE, null);
            }
View Full Code Here

    else if ((command.startsWith("admin_character_list"))||(command.startsWith("admin_character_info")))
    {
      try
      {
        String val = command.substring(21);
        L2PcInstance target = L2World.getInstance().getPlayer(val);
        if (target != null)
          showCharacterInfo(activeChar, target);
        else
          activeChar.sendPacket(new SystemMessage(SystemMessageId.CHARACTER_DOES_NOT_EXIST));
      }
      catch (StringIndexOutOfBoundsException e)
      {
        activeChar.sendMessage("Usage: //character_info <player_name>");
      }
    }
    else if (command.startsWith("admin_show_characters"))
    {
      try
      {
        String val = command.substring(22);
        int page = Integer.parseInt(val);
        listCharacters(activeChar, page);
      }
      catch (StringIndexOutOfBoundsException e)
      {
        //Case of empty page number
        activeChar.sendMessage("Usage: //show_characters <page_number>");
      }
    }
    else if (command.startsWith("admin_find_character"))
    {
      try
      {
        String val = command.substring(21);
        findCharacter(activeChar, val);
      }
      catch (StringIndexOutOfBoundsException e)
      {  //Case of empty character name
        activeChar.sendMessage("Usage: //find_character <character_name>");
        listCharacters(activeChar, 0);
      }
    }
    else if (command.startsWith("admin_find_ip"))
    {
      try
      {
        String val = command.substring(14);
        findCharactersPerIp(activeChar, val);
      }
      catch (Exception e)
      {  //Case of empty or malformed IP number
        activeChar.sendMessage("Usage: //find_ip <www.xxx.yyy.zzz>");
        listCharacters(activeChar, 0);
      }
    }
    else if (command.startsWith("admin_find_account"))
    {
      try
      {
        String val = command.substring(19);
        findCharactersPerAccount(activeChar, val);
      }
      catch (Exception e)
      {  //Case of empty or malformed player name
        activeChar.sendMessage("Usage: //find_account <player_name>");
        listCharacters(activeChar, 0);
      }
    }
    else if (command.equals("admin_edit_character"))
      editCharacter(activeChar);
    // Karma control commands
    else if (command.equals("admin_nokarma"))
      setTargetKarma(activeChar, 0);
    else if (command.startsWith("admin_setkarma"))
    {
      try
      {
        String val = command.substring(15);
        int karma = Integer.parseInt(val);
        if (activeChar == activeChar.getTarget() || activeChar.getAccessLevel()>=REQUIRED_LEVEL2)
          GMAudit.auditGMAction(activeChar.getName(), command, activeChar.getName(), "");
        setTargetKarma(activeChar, karma);
      }
      catch (StringIndexOutOfBoundsException e)
      {
        if (Config.DEVELOPER )
          System.out.println("Set karma error: "+e);
        activeChar.sendMessage("Usage: //setkarma <new_karma_value>");
      }
    }
    else if (command.startsWith("admin_save_modifications"))
    {
      try
      {
        String val = command.substring(24);
        if (activeChar == activeChar.getTarget() || activeChar.getAccessLevel()>=REQUIRED_LEVEL2)
          GMAudit.auditGMAction(activeChar.getName(), command, activeChar.getName(), "");
        adminModifyCharacter(activeChar, val);
      }
      catch (StringIndexOutOfBoundsException e)
      {  //Case of empty character name
        activeChar.sendMessage("Error while modifying character.");
        listCharacters(activeChar, 0);
      }
    }
    else if (command.startsWith("admin_rec"))
    {
      try
      {
        String val = command.substring(10);
        int recVal = Integer.parseInt(val);
        L2Object target = activeChar.getTarget();
        L2PcInstance player = null;
        if (activeChar != target && activeChar.getAccessLevel()<REQUIRED_LEVEL2)
          return false;
        if (target instanceof L2PcInstance) {
          player = (L2PcInstance)target;
        } else {
          return false;
        }
        player.setRecomHave(recVal);
        player.sendMessage("You have been recommended by a GM");
        player.broadcastUserInfo();
      } catch (Exception e)
      {
        activeChar.sendMessage("Usage: //rec number");
      }
    }
    else if (command.startsWith("admin_setclass"))
    {
      try
      {
        String val = command.substring(15);
        int classidval = Integer.parseInt(val);
        L2Object target = activeChar.getTarget();
        L2PcInstance player = null;
        if (activeChar != target && activeChar.getAccessLevel()<REQUIRED_LEVEL2)
          return false;
        if (target instanceof L2PcInstance)
          player = (L2PcInstance)target;
        else
          return false;
        boolean valid=false;
        for (ClassId classid: ClassId.values())
          if (classidval == classid.getId())
            valid = true;
        if (valid && (player.getClassId().getId() != classidval))
        {
          player.setClassId(classidval);
          if (!player.isSubClassActive())
            player.setBaseClass(classidval);
          String newclass = player.getTemplate().className;
          player.store();
          player.sendMessage("A GM changed your class to "+newclass);
          player.broadcastUserInfo();
          activeChar.sendMessage(player.getName()+" is a "+newclass);
        }
        activeChar.sendMessage("Usage: //setclass <valid_new_classid>");
      }
      catch (StringIndexOutOfBoundsException e)
      {
        AdminHelpPage.showHelpPage(activeChar, "charclasses.htm");
      }
    }
    else if (command.startsWith("admin_settitle"))
    {
      try
      {
        String val = command.substring(15);
        L2Object target = activeChar.getTarget();
        L2PcInstance player = null;
        if (activeChar != target && activeChar.getAccessLevel()<REQUIRED_LEVEL2)
          return false;
        if (target instanceof L2PcInstance) {
          player = (L2PcInstance)target;
        } else {
          return false;
        }
        player.setTitle(val);
        player.sendMessage("Your title has been changed by a GM");
        player.broadcastTitleInfo();
      }
      catch (StringIndexOutOfBoundsException e)
      {   //Case of empty character title
        activeChar.sendMessage("You need to specify the new title.");
      }
    }
    else if (command.startsWith("admin_setname"))
    {
      try
      {
        String val = command.substring(14);
        L2Object target = activeChar.getTarget();
        L2PcInstance player = null;
        if (activeChar != target && activeChar.getAccessLevel()<REQUIRED_LEVEL2)
          return false;
        if (target instanceof L2PcInstance) {
          player = (L2PcInstance)target;
        } else {
          return false;
        }
        player.setName(val);
        player.sendMessage("Your name has been changed by a GM");
        player.broadcastUserInfo();
        player.store();
      }
      catch (StringIndexOutOfBoundsException e)
      {   //Case of empty character name
        activeChar.sendMessage("Usage: //setname new_name_for_target");
      }
    }
    else if (command.startsWith("admin_setsex"))
    {
      L2Object target = activeChar.getTarget();
      L2PcInstance player = null;
      if (activeChar != target && activeChar.getAccessLevel()<REQUIRED_LEVEL2)
        return false;
      if (target instanceof L2PcInstance) {
        player = (L2PcInstance)target;
      } else {
        return false;
      }
      player.getAppearance().setSex(player.getAppearance().getSex()? false : true);
      player.sendMessage("Your gender has been changed by a GM");
      player.broadcastUserInfo();
      player.decayMe();
      player.spawnMe(player.getX(),player.getY(),player.getZ());
    }
    else if (command.startsWith("admin_setcolor"))
    {
      try
      {
        String val          = command.substring(15);
        L2Object target     = activeChar.getTarget();
        L2PcInstance player = null;
        if (activeChar != target && activeChar.getAccessLevel()<REQUIRED_LEVEL2)
          return false;
        if (target instanceof L2PcInstance) {
          player = (L2PcInstance)target;
        } else {
          return false;
        }
        player.getAppearance().setNameColor(Integer.decode("0x"+val));
        player.sendMessage("Your name color has been changed by a GM");
        player.broadcastUserInfo();
      }
      catch (StringIndexOutOfBoundsException e)
      {   //Case of empty color
        activeChar.sendMessage("You need to specify the new color.");
      }
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());
View Full Code Here

  @Override
  public void useItem(L2PlayableInstance playable, L2ItemInstance item)
  {
    if (!(playable instanceof L2PcInstance))
      return;
    L2PcInstance activeChar = (L2PcInstance)playable;

      int itemId = item.getItemId();
      int itemToCreateId = 0;
      int amount = 0; // default regular pack

      if (itemId >= 5134 && itemId <= 5139) // SS
      {
        if (itemId == 5134) // No Grade
          itemToCreateId = 1835;
        else
          itemToCreateId = itemId - 3672;

        amount = 300;
      }
      else if(itemId >= 5250 && itemId <= 5255) // Greater SS
      {
        if (itemId == 5250) // No Grade
          itemToCreateId = 1835;
        else
             itemToCreateId = itemId - 3788;

        amount = 1000;
      }
      else if(itemId >= 5140 && itemId <= 5145) // SpS
      {
      }
      else if(itemId >= 5256 && itemId <= 5261) // Greater SpS
      {
      }

    activeChar.getInventory().destroyItem("Extract", item, activeChar, null);
    activeChar.getInventory().addItem("Extract", itemToCreateId, amount, activeChar, item);

      SystemMessage sm = new SystemMessage(SystemMessageId.EARNED_S2_S1_S);
      sm.addItemName(itemToCreateId);
      sm.addNumber(amount);
      activeChar.sendPacket(sm);

        ItemList playerUI = new ItemList(activeChar, false);
        activeChar.sendPacket(playerUI);
  }
View Full Code Here

  }

  @Override
  protected void runImpl()
  {
    L2PcInstance player = getClient().getActiveChar();
    if (player == null) 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;

    TradeList storeList = storePlayer.getSellList();
    if (storeList == null) return;

        if (Config.GM_DISABLE_TRANSACTION && player.getAccessLevel() >= Config.GM_TRANSACTION_MIN && player.getAccessLevel() <= Config.GM_TRANSACTION_MAX)
        {
          player.sendMessage("Transactions are disable for your Access Level");
            sendPacket(new ActionFailed());
            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;
      }
      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 (player.getAdena() < priceTotal)
    {
      sendPacket(new SystemMessage(SystemMessageId.YOU_NOT_ENOUGH_ADENA));
      sendPacket(new ActionFailed());
      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(new ActionFailed());
            _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)
    {
View Full Code Here

  }

  private void setTargetKarma(L2PcInstance activeChar, int newKarma) {
    // function to change karma of selected char
    L2Object target = activeChar.getTarget();
    L2PcInstance player = null;
    if (target instanceof L2PcInstance)
      player = (L2PcInstance)target;
    else
      return;

    if ( newKarma >= 0 )
    {
      // for display
      int oldKarma = player.getKarma();
      // update karma
      player.setKarma(newKarma);
      //Common character information
      player.sendPacket( new SystemMessage(SystemMessageId.YOUR_KARMA_HAS_BEEN_CHANGED_TO).addString(String.valueOf(newKarma)));
      //Admin information
      activeChar.sendMessage("Successfully Changed karma for "+player.getName()+" from (" + oldKarma + ") to (" + newKarma + ").");
      if (Config.DEBUG)
        _log.fine("[SET KARMA] [GM]"+activeChar.getName()+" Changed karma for "+player.getName()+" from (" + oldKarma + ") to (" + newKarma + ").");
    }
    else
    {
      // tell admin of mistake
      activeChar.sendMessage("You must enter a value for karma greater than or equal to 0.");
      if (Config.DEBUG)
        _log.fine("[SET KARMA] ERROR: [GM]"+activeChar.getName()+" entered an incorrect value for new karma: " + newKarma + " for "+player.getName()+".");
    }
  }
View Full Code Here

TOP

Related Classes of net.sf.l2j.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.