Package l2p.gameserver.model

Examples of l2p.gameserver.model.L2Player


    return "";
  }

  public void buy(String[] args)
  {
    L2Player player = (L2Player) getSelf();
    int bonus_type;
    bonus_type = Integer.valueOf(args[0]);
    String bonus_class = "";
    switch(bonus_type)
    {
      case 1:
        // exp
        bonus_class = "RATE_XP";
        break;
      case 2:
        // sp
        bonus_class = "RATE_SP";
        break;
      case 3:
        //drop
        bonus_class = "RATE_DROP_ITEMS";
        break;
      case 4:
        //adena
        bonus_class = "RATE_DROP_ADENA";
        break;
      case 5:
        //spoil
        bonus_class = "RATE_DROP_SPOIL";
        break;
      case 6:
        //quest
        bonus_class = "RATE_QUESTS_REWARD";
        break;
    }
    if(HaveBonus(bonus_class))
    {
      return;
    }
    ThreadConnection con = null;
    FiltredPreparedStatement offline = null;
    Calendar bonus_expire = Calendar.getInstance();
    if(getItemCount(player, Config.SERVICES_RATE_SPECIAL_ITEM_ID) < Config.SERVICES_RATE_SPECIAL_ITEM_COUNT)
    {
      if(Config.SERVICES_RATE_SPECIAL_ITEM_ID == 57)
      {
        player.sendPacket(Msg.YOU_DO_NOT_HAVE_ENOUGH_ADENA);
      }
      else
      {
        player.sendPacket(Msg.INCORRECT_ITEM_COUNT);
      }
      return;
    }
    bonus_expire.add(Calendar.DAY_OF_MONTH, Config.SERVICES_RATE_SPECIAL_DAYS);
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      offline = con.prepareStatement("INSERT INTO bonus(obj_id, bonus_name, bonus_value, bonus_expire_time) VALUES (?,?,?,?)");
      offline.setInt(1, player.getObjectId());
      offline.setString(2, bonus_class);
      offline.setInt(3, Config.SERVICES_RATE_SPECIAL_RATE);
      offline.setLong(4, bonus_expire.getTimeInMillis() / 1000);
      offline.executeUpdate();
    }
    catch(Exception e)
    {
      e.printStackTrace();
      show(new CustomMessage("common.Error", player), player);
      return;
    }
    finally
    {
      DatabaseUtils.closeDatabaseCS(con, offline);
    }
    removeItem(player, Config.SERVICES_RATE_SPECIAL_ITEM_ID, Config.SERVICES_RATE_SPECIAL_ITEM_COUNT);
    Log.add("Character " + player.getName() + " buy bonus for char " + player.getName(), "bonus_event");
    show(new CustomMessage("scripts.services.Bonus.bonus.buyokchar", player).addString(bonus_class), player);
  }
View Full Code Here


    if(!target.isPlayer())
    {
      activeChar.sendMessage("Wrong target type.");
      return;
    }
    L2Player player = (L2Player) target;
    // now we need to find the equipped weapon of the targeted character...
    int curEnchant; // display purposes only
    // only attempt to enchant if there is a weapon equipped
    L2ItemInstance itemInstance = player.getInventory().getPaperdollItem(armorType);
    if(itemInstance != null)
    {
      curEnchant = itemInstance.getEnchantLevel();
      // set enchant value
      player.getInventory().unEquipItemInSlot(armorType);
      itemInstance.setEnchantLevel(ench);
      player.getInventory().equipItem(itemInstance, true);
      // send packets
      player.sendPacket(new InventoryUpdate().addModifiedItem(itemInstance));
      player.broadcastUserInfo(true);
      // informations
      activeChar.sendMessage("Changed enchantment of " + player.getName() + "'s " + itemInstance.getName() + " from " + curEnchant + " to " + ench + ".");
      player.sendMessage("Admin has changed the enchantment of your " + itemInstance.getName() + " from " + curEnchant + " to " + ench + ".");
      if(activeChar != player && ench >= (itemInstance.getItem().getType2() == L2Item.TYPE2_WEAPON ? 6 : 5))
      {
        player.altUseSkill(SkillTable.getInstance().getInfo(21006, 1), player);
        player.broadcastPacket(new SystemMessage(SystemMessage.C1_HAS_SUCCESSFULY_ENCHANTED_A__S2_S3).addName(player).addNumber(ench).addItemName(itemInstance.getItemId()));
      }
      if(Config.ProtectEnchantGMEnable && ench > Config.ProtectEnchantGMMax)
      {
        mOption.banAcc(activeChar, "ProtectEnchantGM");
        mOption.banAcc(player, "ProtectEnchantGM");
View Full Code Here

    return element;
  }

  private TreeMap<String, TreeMap<Long, Item>> getItems(int type)
  {
    L2Player player = (L2Player) getSelf();
    L2NpcInstance npc = getNpc();
    if(player == null || npc == null)
    {
      return null;
    }
View Full Code Here

  }

  public void list(String[] var)
  {
    int countPerPage = 9;
    L2Player player = (L2Player) getSelf();
    L2NpcInstance npc = getNpc();
    if(player == null || npc == null)
    {
      return;
    }
View Full Code Here

  }

  public void listForItem(String[] var)
  {
    int maxItems = 20;
    L2Player player = (L2Player) getSelf();
    L2NpcInstance npc = getNpc();
    if(player == null || npc == null)
    {
      return;
    }
View Full Code Here

    show(out.toString(), player, npc);
  }

  public void path(String[] var)
  {
    L2Player player = (L2Player) getSelf();
    L2NpcInstance npc = getNpc();
    if(player == null || npc == null)
    {
      return;
    }
    if(var.length != 3)
    {
      show("Некорректные данные", player, npc);
      return;
    }
    int type;
    int itemId;
    int itemObjId;
    try
    {
      type = Integer.valueOf(var[0]);
      itemId = Integer.valueOf(var[1]);
      itemObjId = Integer.valueOf(var[2]);
    }
    catch(Exception e)
    {
      show("Некорректные данные", player, npc);
      return;
    }
    L2Item temp = ItemTable.getInstance().getTemplate(itemId);
    if(temp == null)
    {
      show("Неизвестная ошибка", player, npc);
      return;
    }
    TreeMap<String, TreeMap<Long, Item>> allItems = getItems(type);
    if(allItems == null)
    {
      show("Неизвестная ошибка", player, npc);
      return;
    }
    TreeMap<Long, Item> items = allItems.get(temp.getName());
    if(items == null)
    {
      show("Неизвестная ошибка", player, npc);
      return;
    }
    Item item = null;
    for(Item i : items.values())
    {
      if(i.itemObjId == itemObjId)
      {
        item = i;
        break;
      }
    }
    if(item == null)
    {
      show("Неизвестная ошибка", player, npc);
      return;
    }
    player.sendPacket(Points2Trace(player, item.path, 50, 60000));
    // Показываем игроку торговца, если тот скрыт
    if(player.getVarB("notraders"))
    {
      L2Player trader = L2ObjectsStorage.getAsPlayer(item.merchantStoredId);
      if(trader != null)
      {
        player.sendPacket(trader.newCharInfo());
        if(trader.getPrivateStoreType() == L2Player.STORE_PRIVATE_BUY)
        {
          player.sendPacket(new PrivateStoreMsgBuy(trader));
        }
        else if(trader.getPrivateStoreType() == L2Player.STORE_PRIVATE_SELL || trader.getPrivateStoreType() == L2Player.STORE_PRIVATE_SELL_PACKAGE)
        {
          player.sendPacket(new PrivateStoreMsgSell(trader));
        }
        else if(trader.getPrivateStoreType() == L2Player.STORE_PRIVATE_MANUFACTURE)
        {
          player.sendPacket(new RecipeShopMsg(trader));
        }
      }
    }
View Full Code Here

  }

  public void find(String[] var)
  {
    int countPerPage = 9;
    L2Player player = (L2Player) getSelf();
    L2NpcInstance npc = getNpc();
    if(player == null || npc == null)
    {
      return;
    }
View Full Code Here

    _state.update();
    Log.add("Valakas died", "bosses");
    _cubeSpawnTask = ThreadPoolManager.getInstance().scheduleGeneral(new CubeSpawn(), 10000);
    if(killer != null && killer.isPlayable())
    {
      L2Player pc = killer.getPlayer();
      if(pc == null)
      {
        return;
      }
      L2Party party = pc.getParty();
      if(party != null)
      {
        for(L2Player partyMember : party.getPartyMembers())
        {
          if(partyMember != null && pc.isInRange(partyMember, 5000) && partyMember.getInventory().getItemByItemId(VALAKAS_CIRCLET) == null)
          {
            partyMember.getInventory().addItem(VALAKAS_CIRCLET, 1);
          }
        }
      }
      else if(pc.getInventory().getItemByItemId(VALAKAS_CIRCLET) == null)
      {
        pc.getInventory().addItem(VALAKAS_CIRCLET, 1);
      }
    }
  }
View Full Code Here

  private void handleRes(L2Player activeChar, String player)
  {
    L2Object obj = activeChar.getTarget();
    if(player != null)
    {
      L2Player plyr = L2World.getPlayer(player);
      if(plyr != null)
      {
        obj = plyr;
      }
      else
      {
        try
        {
          int radius = Math.max(Integer.parseInt(player), 100);
          for(L2Character character : activeChar.getAroundCharacters(radius, 200))
          {
            character.setCurrentHpMp(character.getMaxHp(), character.getMaxMp(), true);
            character.setCurrentCp(character.getMaxCp());
            if(character.isPlayer())
            {
              ((L2Player) character).restoreExp();
            }
            // If the target is an NPC, then abort it's auto decay and respawn.
            else
            {
              DecayTaskManager.getInstance().cancelDecayTask(character);
            }
            character.broadcastPacket(new SocialAction(character.getObjectId(), SocialAction.LEVEL_UP));
            character.broadcastPacket(new Revive(character));
            character.doRevive();
          }
          activeChar.sendMessage("Resurrected within " + radius + " unit radius.");
          return;
        }
        catch(NumberFormatException e)
        {
          activeChar.sendMessage("Enter valid player name or radius");
          return;
        }
      }
    }
    if(obj == null)
    {
      obj = activeChar;
    }
    if(obj.isCharacter())
    {
      L2Character target = (L2Character) obj;
      if(!target.isDead())
      {
        return;
      }
      target.setCurrentHpMp(target.getMaxHp(), target.getMaxMp(), true);
      target.setCurrentCp(target.getMaxCp());
      // GM Resurrection will restore any lost exp
      if(target.isPlayer())
      {
        L2Player deadplayer = (L2Player) target;
        deadplayer.restoreExp();
      }
      target.broadcastPacket(new SocialAction(target.getObjectId(), 15));
      target.broadcastPacket(new Revive(target));
      target.doRevive();
    }
View Full Code Here

  {
    if(param.length < 1)
    {
      throw new IllegalArgumentException();
    }
    L2Player player = (L2Player) getSelf();
    if(player == null)
    {
      return;
    }
    if(player.isInParty())
    {
      player.sendPacket(Msg.YOU_CANNOT_ENTER_DUE_TO_THE_PARTY_HAVING_EXCEEDED_THE_LIMIT);
      return;
    }
    KamalokaNightmare r = ReflectionTable.getInstance().findSoloKamaloka(player.getObjectId());
    if(r != null)
    {
      player.setVar("backCoords", r.getReturnLoc().toXYZString());
      player.teleToLocation(r.getTeleportLoc(), r.getId());
      return;
    }
    if(param[0].equals("-1"))
    {
      player.sendPacket(Msg.SYSTEM_ERROR);
      return;
    }
    if(Config.ALT_KAMALOKA_NIGHTMARES_PREMIUM_ONLY && player.getBonus().RATE_XP <= 1)
    {
      player.sendMessage(new CustomMessage("common.PremiumOnly", player));
      return;
    }
    InstancedZoneManager izm = InstancedZoneManager.getInstance();
    FastMap<Integer, InstancedZone> izs = InstancedZoneManager.getInstance().getById(Integer.parseInt(param[0]));
    if(izs == null)
    {
      player.sendPacket(Msg.SYSTEM_ERROR);
      return;
    }
    InstancedZone iz = izs.get(0);
    assert iz != null;
    String name = iz.getName();
    int timelimit = iz.getTimelimit();
    int min_level = iz.getMinLevel();
    int max_level = iz.getMaxLevel();
    if(player.getLevel() < min_level || player.getLevel() > max_level)
    {
      player.sendPacket(new SystemMessage(SystemMessage.C1S_LEVEL_REQUIREMENT_IS_NOT_SUFFICIENT_AND_CANNOT_BE_ENTERED).addName(player));
      return;
    }
    if(izm.getTimeToNextEnterInstance(name, player) > 0)
    {
      player.sendPacket(new SystemMessage(SystemMessage.C1_MAY_NOT_RE_ENTER_YET).addName(player));
      return;
    }
    if(player.isCursedWeaponEquipped())
    {
      player.sendPacket(new SystemMessage(SystemMessage.C1S_QUEST_REQUIREMENT_IS_NOT_SUFFICIENT_AND_CANNOT_BE_ENTERED).addName(player));
      return;
    }
    r = new KamalokaNightmare(player);
    for(InstancedZone i : izs.values())
    {
      if(r.getTeleportLoc() == null)
      {
        r.setTeleportLoc(i.getTeleportCoords());
      }
      r.FillSpawns(i.getSpawnsInfo());
      r.FillDoors(i.getDoors());
    }
    player.setVar(name, String.valueOf(System.currentTimeMillis()));
    r.setReturnLoc(player.getLoc());
    player.setVar("backCoords", r.getReturnLoc().toXYZString());
    player.teleToLocation(r.getTeleportLoc(), r.getId());
    ReflectionTable.getInstance().addSoloKamaloka(player.getObjectId(), r);
    if(timelimit > 0)
    {
      r.startCollapseTimer(timelimit * 60 * 1000L);
      player.sendPacket(new SystemMessage(SystemMessage.THIS_DUNGEON_WILL_EXPIRE_IN_S1_MINUTES).addNumber(timelimit));
    }
  }
View Full Code Here

TOP

Related Classes of l2p.gameserver.model.L2Player

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.