Пример #1
0
 public static final int[] getEnchantCatalystId(ItemInstance item) {
   if (item.getTemplate().isWeapon())
     switch (item.getGrade().getCrystalId()) {
       case ItemTemplate.CRYSTAL_A:
         return catalyst[3];
       case ItemTemplate.CRYSTAL_B:
         return catalyst[2];
       case ItemTemplate.CRYSTAL_C:
         return catalyst[1];
       case ItemTemplate.CRYSTAL_D:
         return catalyst[0];
       case ItemTemplate.CRYSTAL_S:
         return catalyst[4];
       case ItemTemplate.CRYSTAL_R:
         return catalyst[5];
     }
   else if (item.getTemplate().isArmor() || item.getTemplate().isAccessory())
     switch (item.getGrade().getCrystalId()) {
       case ItemTemplate.CRYSTAL_A:
         return catalyst[9];
       case ItemTemplate.CRYSTAL_B:
         return catalyst[8];
       case ItemTemplate.CRYSTAL_C:
         return catalyst[7];
       case ItemTemplate.CRYSTAL_D:
         return catalyst[6];
       case ItemTemplate.CRYSTAL_S:
         return catalyst[10];
       case ItemTemplate.CRYSTAL_R:
         return catalyst[11];
     }
   return new int[] {0};
 }
Пример #2
0
  public static ItemInstance createItem(int itemId) {
    ItemInstance item = new ItemInstance(IdFactory.getInstance().getNextId(), itemId);
    item.setLocation(ItemLocation.VOID);
    item.setCount(1L);

    return item;
  }
  public void start(Player player, int type, NpcInstance npc) {
    if (!player.isInParty()) {
      showHtmlFile(player, "rift/NoParty.htm", npc);
      return;
    }

    if (!player.isGM()) {
      if (!player.getParty().isLeader(player)) {
        showHtmlFile(player, "rift/NotPartyLeader.htm", npc);
        return;
      }

      if (player.getParty().isInDimensionalRift()) {
        showHtmlFile(player, "rift/Cheater.htm", npc);

        if (!player.isGM())
          _log.warn(
              "Player "
                  + player.getName()
                  + "("
                  + player.getObjectId()
                  + ") was cheating in dimension rift area!");

        return;
      }

      if (player.getParty().getMemberCount() < Config.RIFT_MIN_PARTY_SIZE) {
        showHtmlFile(player, "rift/SmallParty.htm", npc);
        return;
      }

      for (Player p : player.getParty().getPartyMembers())
        if (!checkIfInPeaceZone(p.getLoc())) {
          showHtmlFile(player, "rift/NotInWaitingRoom.htm", npc);
          return;
        }

      ItemInstance i;
      for (Player p : player.getParty().getPartyMembers()) {
        i = p.getInventory().getItemByItemId(DIMENSIONAL_FRAGMENT_ITEM_ID);
        if (i == null || i.getCount() < getNeededItems(type)) {
          showHtmlFile(player, "rift/NoFragments.htm", npc);
          return;
        }
      }

      for (Player p : player.getParty().getPartyMembers())
        if (!p.getInventory()
            .destroyItemByItemId(DIMENSIONAL_FRAGMENT_ITEM_ID, getNeededItems(type))) {
          showHtmlFile(player, "rift/NoFragments.htm", npc);
          return;
        }
    }

    new DimensionalRift(player.getParty(), type, Rnd.get(1, _rooms.get(type).size() - 1));
  }
Пример #4
0
  /**
   * Проверяет соответствие уровня заточки и вообще катализатор ли это или левый итем
   *
   * @param item
   * @param catalyst
   * @return true если катализатор соответствует
   */
  public static final boolean checkCatalyst(ItemInstance item, ItemInstance catalyst) {
    if (item == null || catalyst == null) return false;

    int current = item.getEnchantLevel();
    if (current < (item.getTemplate().getBodyPart() == ItemTemplate.SLOT_FULL_ARMOR ? 4 : 3)
        || current > 9) return false;

    for (int catalystRequired : getEnchantCatalystId(item))
      if (catalystRequired == catalyst.getItemId()) return true;

    return false;
  }
Пример #5
0
  @Override
  protected final void writeImpl() {
    writeC(0x9a);
    writeS(_name);
    writeD(_limit); // c4?
    writeH(1); // show window ??

    writeH(_size);
    for (ItemInstance temp : _items) {
      if (!temp.getTemplate().isQuest()) writeItemInfo(_player, temp);
    }
  }
  private long getItemCountById(Player player, int itemId) {
    long itemCount = 0;

    PcInventory inventory = player.getInventory();

    if (inventory != null) {
      ItemInstance itemInstance = inventory.getItemByItemId(itemId);

      if (itemInstance != null) itemCount = itemInstance.getCount();
    }

    return itemCount;
  }
Пример #7
0
  /**
   * Проверяет возможность передачи вещи
   *
   * @param player
   * @param item
   * @return
   */
  public static final boolean checkIfCanDiscard(Player player, ItemInstance item) {
    if (item.isHeroItem()) return false;

    if (player.getMountControlItemObjId() == item.getObjectId()) return false;

    if (player.getPetControlItem() == item) return false;

    if (player.getEnchantScroll() == item) return false;

    if (item.isCursed()) return false;

    if (item.getTemplate().isQuest()) return false;

    return true;
  }
Пример #8
0
  public static long removeItem(Playable playable, ItemInstance item, long count, boolean notify) {
    long removed = 0;
    if (playable == null || count < 1) return removed;

    Playable player = playable.getPlayer();
    if (item.getTemplate().isStackable()) {
      if (player.getInventory().destroyItem(item, count)) removed = count;
    } else
      for (long i = 0; i < count; i++) if (player.getInventory().destroyItem(item, 1)) removed++;

    if (removed > 0 && notify)
      player.sendPacket(SystemMessage2.removeItems(item.getItemId(), removed));

    return removed;
  }
Пример #9
0
  public void deletePet(ItemInstance item, Creature owner) {
    int petObjectId = 0;

    Connection con = null;
    PreparedStatement statement = null;
    ResultSet rset = null;
    try {
      int itemObjId = item.getObjectId();
      con = DatabaseFactory.getInstance().getConnection();
      statement = con.prepareStatement(SELECT_SQL_QUERY);
      statement.setInt(1, itemObjId);
      rset = statement.executeQuery();
      while (rset.next()) petObjectId = rset.getInt("objId");

      DbUtils.close(statement, rset);

      Player player = owner.getPlayer();

      PetInstance pet = player.getPet();
      if (pet != null && pet.getObjectId() == petObjectId) pet.unSummon(false);

      if (player != null && player.isMounted() && player.getMountControlItemObjId() == itemObjId)
        player.getMount().onControlItemDelete();

      // if it's a pet control item, delete the pet
      statement = con.prepareStatement(DELETE_SQL_QUERY);
      statement.setInt(1, itemObjId);
      statement.execute();
    } catch (Exception e) {
      _log.error("CharNameTable.deletePet(ItemInstance, Creature): " + e, e);
    } finally {
      DbUtils.closeQuietly(con, statement, rset);
    }
  }
Пример #10
0
  public static boolean canAddItem(Player player, ItemInstance item) {
    if (!player.getInventory().validateWeight(item)) {
      player.sendPacket(SystemMsg.YOU_HAVE_EXCEEDED_THE_WEIGHT_LIMIT);
      return false;
    }

    if (!player.getInventory().validateCapacity(item)) {
      player.sendPacket(SystemMsg.YOUR_INVENTORY_IS_FULL);
      return false;
    }

    if (!item.getTemplate().getHandler().pickupItem(player, item)) return false;

    PickableAttachment attachment =
        item.getAttachment() instanceof PickableAttachment
            ? (PickableAttachment) item.getAttachment()
            : null;
    if (attachment != null && !attachment.canPickUp(player)) return false;

    return true;
  }
Пример #11
0
  public static final IStaticPacket checkIfCanEquip(PetInstance pet, ItemInstance item) {
    if (!item.isEquipable()) return SystemMsg.YOUR_PET_CANNOT_CARRY_THIS_ITEM;

    int petId = pet.getNpcId();

    if (item.getTemplate().isPendant() //
        || PetDataHolder.isWolf(petId) && item.getTemplate().isForWolf() //
        || PetDataHolder.isHatchling(petId) && item.getTemplate().isForHatchling() //
        || PetDataHolder.isStrider(petId) && item.getTemplate().isForStrider() //
        || PetDataHolder.isGreatWolf(petId) && item.getTemplate().isForGWolf() //
        || PetDataHolder.isBabyPet(petId) && item.getTemplate().isForPetBaby() //
        || PetDataHolder.isImprovedBabyPet(petId) && item.getTemplate().isForPetBaby() //
    ) return null;

    return SystemMsg.YOUR_PET_CANNOT_CARRY_THIS_ITEM;
  }
Пример #12
0
  public static int getCrystallizeCrystalAdd(ItemInstance item) {
    int result = 0;
    int crystalsAdd = 0;
    if (item.isWeapon()) {
      switch (item.getGrade()) {
        case D:
          crystalsAdd = 90;
          break;
        case C:
          crystalsAdd = 45;
          break;
        case B:
          crystalsAdd = 67;
          break;
        case A:
          crystalsAdd = 145;
          break;
        case S:
        case S80:
        case S84:
          crystalsAdd = 250;
          break;
        case R:
        case R95:
        case R99:
          crystalsAdd = 500;
          break;
      }
    } else {
      switch (item.getGrade()) {
        case D:
          crystalsAdd = 11;
          break;
        case C:
          crystalsAdd = 6;
          break;
        case B:
          crystalsAdd = 11;
          break;
        case A:
          crystalsAdd = 20;
          break;
        case S:
        case S80:
        case S84:
          crystalsAdd = 25;
          break;
        case R:
        case R95:
        case R99:
          crystalsAdd = 30;
          break;
      }
    }

    if (item.getEnchantLevel() > 3) {
      result = crystalsAdd * 3;
      if (item.isWeapon()) crystalsAdd *= 2;
      else crystalsAdd *= 3;
      result += crystalsAdd * (item.getEnchantLevel() - 3);
    } else result = crystalsAdd * item.getEnchantLevel();

    return result;
  }
Пример #13
0
 public static boolean checkIfCanPickup(Playable playable, ItemInstance item) {
   Player player = playable.getPlayer();
   return item.getDropTimeOwner() <= System.currentTimeMillis()
       || item.getDropPlayers().contains(player.getObjectId());
 }
Пример #14
0
  /**
   * Проверяет возможность носить эту вещь.
   *
   * @return null, если вещь носить можно, либо SystemMessage, который можно показать игроку
   */
  public static final IStaticPacket checkIfCanEquip(Player player, ItemInstance item) {
    // FIXME [G1ta0] черезмерный хардкод, переделать на условия
    int itemId = item.getItemId();
    int targetSlot = item.getTemplate().getBodyPart();
    Clan clan = player.getClan();

    // TODO: [Bonux] проверить, могут ли носить Камаэли щиты и сигили R ранга.
    if (!player.getClassId().isOfLevel(ClassLevel.AWAKED)
        && item.getGrade() != ItemGrade.R
        && item.getGrade() != ItemGrade.R95
        && item.getGrade() != ItemGrade.R99) {
      // камаэли и хеви/робы/щиты/сигилы
      if (player.getRace() == Race.KAMAEL
          && (item.getItemType() == ArmorType.HEAVY
              || item.getItemType() == ArmorType.MAGIC
              || item.getItemType() == ArmorType.SIGIL
              || item.getItemType() == WeaponType.NONE))
        return SystemMsg.YOU_DO_NOT_MEET_THE_REQUIRED_CONDITION_TO_EQUIP_THAT_ITEM;

      // не камаэли и рапиры/арбалеты/древние мечи
      if (player.getRace() != Race.KAMAEL
          && (item.getItemType() == WeaponType.CROSSBOW
              || item.getItemType() == WeaponType.RAPIER
              || item.getItemType() == WeaponType.ANCIENTSWORD))
        return SystemMsg.YOU_DO_NOT_MEET_THE_REQUIRED_CONDITION_TO_EQUIP_THAT_ITEM;
    }

    if (itemId >= 7850 && itemId <= 7859 && player.getLvlJoinedAcademy() == 0) // Clan Oath Armor
    return SystemMsg.THIS_ITEM_CAN_ONLY_BE_WORN_BY_A_MEMBER_OF_THE_CLAN_ACADEMY;

    if (isClanApellaItem(itemId) && player.getPledgeRank().ordinal() < PledgeRank.WISEMAN.ordinal())
      return SystemMsg.YOU_DO_NOT_MEET_THE_REQUIRED_CONDITION_TO_EQUIP_THAT_ITEM;

    if (item.getItemType() == WeaponType.DUALDAGGER
        && player.getSkillLevel(923) < 1
        && player.getSkillLevel(10502) < 1)
      return SystemMsg.YOU_DO_NOT_MEET_THE_REQUIRED_CONDITION_TO_EQUIP_THAT_ITEM;

    // Корона лидера клана, владеющего замком
    if (itemId == 6841 && (clan == null || !player.isClanLeader() || clan.getCastle() == 0))
      return SystemMsg.YOU_DO_NOT_MEET_THE_REQUIRED_CONDITION_TO_EQUIP_THAT_ITEM;

    // Нельзя одевать оружие, если уже одето проклятое оружие. Проверка двумя способами, для
    // надежности.
    if (targetSlot == ItemTemplate.SLOT_LR_HAND
        || targetSlot == ItemTemplate.SLOT_L_HAND
        || targetSlot == ItemTemplate.SLOT_R_HAND) {
      if (itemId != player.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_RHAND)
          && CursedWeaponsManager.getInstance()
              .isCursed(player.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_RHAND)))
        return SystemMsg.YOU_DO_NOT_MEET_THE_REQUIRED_CONDITION_TO_EQUIP_THAT_ITEM;
      if (player.isCursedWeaponEquipped() && itemId != player.getCursedWeaponEquippedId())
        return SystemMsg.YOU_DO_NOT_MEET_THE_REQUIRED_CONDITION_TO_EQUIP_THAT_ITEM;
    }

    // Плащи
    if (item.getTemplate().isCloak()) {
      // Can be worn by Knights or higher ranks who own castle
      if (item.getName().contains("Knight")
          && (player.getPledgeRank().ordinal() < PledgeRank.KNIGHT.ordinal()
              || player.getCastle() == null))
        return SystemMsg.YOU_DO_NOT_MEET_THE_REQUIRED_CONDITION_TO_EQUIP_THAT_ITEM;

      // Плащи для камаэлей
      if (item.getName().contains("Kamael") && player.getRace() != Race.KAMAEL)
        return SystemMsg.YOU_DO_NOT_MEET_THE_REQUIRED_CONDITION_TO_EQUIP_THAT_ITEM;

      // Плащи можно носить только с S80 или S84 сетом
      if (!player.getOpenCloak())
        return SystemMsg.THE_CLOAK_CANNOT_BE_EQUIPPED_BECAUSE_YOUR_ARMOR_SET_IS_NOT_COMPLETE;
    }

    if (targetSlot == ItemTemplate.SLOT_DECO) {
      int count = player.getTalismanCount();
      if (count <= 0)
        return new SystemMessage2(
                SystemMsg.YOU_CANNOT_WEAR_S1_BECAUSE_YOU_ARE_NOT_WEARING_A_BRACELET)
            .addItemName(itemId);

      ItemInstance deco;
      for (int slot = Inventory.PAPERDOLL_DECO1; slot <= Inventory.PAPERDOLL_DECO6; slot++) {
        deco = player.getInventory().getPaperdollItem(slot);
        if (deco != null) {
          if (deco == item) return null; // талисман уже одет и количество слотов больше нуля
          // Проверяем на количество слотов и одинаковые талисманы
          if (--count <= 0 || deco.getItemId() == itemId)
            return new SystemMessage2(
                    SystemMsg.YOU_CANNOT_EQUIP_S1_BECAUSE_YOU_DO_NOT_HAVE_ANY_AVAILABLE_SLOTS)
                .addItemName(itemId);
        }
      }
    }
    return null;
  }
  public void teleportPlayer(FightBattleArenaObject arena) {
    Player player = _player;
    if (player == null) return;

    if (player.isTeleporting()) {
      _player = null;
      return;
    }

    if (player.isInObserverMode()) {
      if (player.getOlympiadObserveGame() != null) player.leaveOlympiadObserverMode(true);
      else player.leaveObserverMode();
    }

    // Un activate clan skills
    if (player.getClan() != null) player.getClan().disableSkills(player);

    // Remove Hero Skills
    player.activateHeroSkills(false);

    // Abort casting if player casting
    if (player.isCastingNow()) player.abortCast(true, true);

    // Abort attack if player attacking
    if (player.isAttackingNow()) player.abortAttack(true, true);

    // Удаляем баффы и чужие кубики
    for (Effect e : player.getEffectList().getEffects()) {
      if (!player.isSpecialEffect(e.getSkill())
          && (e.getEffectType() != EffectType.Cubic
              || player.getSkillLevel(e.getSkill().getId()) <= 0)) e.exit();
    }

    // Remove Servitor's Buffs
    Servitor[] servitors = player.getServitors();
    if (servitors.length > 0) {
      for (Servitor servitor : servitors) {
        if (servitor.isPet()) servitor.unSummon(false);
        else {
          servitor.getEffectList().stopAllEffects();
          servitor.transferOwnerBuffs();
        }
      }
    }

    // unsummon agathion
    if (player.getAgathionId() > 0) player.setAgathion(0);

    // Сброс кулдауна всех скилов, время отката которых меньше 15 минут
    for (TimeStamp sts : player.getSkillReuses()) {
      if (sts == null) continue;

      Skill skill = SkillTable.getInstance().getInfo(sts.getId(), sts.getLevel());
      if (skill == null) continue;

      if (sts.getReuseBasic() <= 15 * 60001L) player.enableSkill(skill);
    }

    // Обновляем скилл лист, после удаления скилов
    player.sendPacket(new SkillList(player));

    // Обновляем куллдаун, после сброса
    player.sendPacket(new SkillCoolTime(player));

    // Проверяем одетые вещи на возможность ношения.
    player.getInventory().validateItems();

    // remove bsps/sps/ss automation
    Set<Integer> activeSoulShots = player.getAutoSoulShot();
    for (int itemId : activeSoulShots) {
      player.removeAutoSoulShot(itemId);
      player.sendPacket(new ExAutoSoulShot(itemId, false));
    }

    // Разряжаем заряженные соул и спирит шоты
    ItemInstance weapon = player.getActiveWeaponInstance();
    if (weapon != null) {
      weapon.setChargedSpiritshot(ItemInstance.CHARGED_NONE);
      weapon.setChargedSoulshot(ItemInstance.CHARGED_NONE);
    }

    player.setCurrentCp(player.getMaxCp());
    player.setCurrentMp(player.getMaxMp());

    if (player.isDead()) {
      player.setCurrentHp(player.getMaxHp(), true);
      player.broadcastPacket(new Revive(player));
      // player.broadcastStatusUpdate();
    } else player.setCurrentHp(player.getMaxHp(), false);

    player.broadcastUserInfo(true);

    DuelEvent duel = player.getEvent(DuelEvent.class);
    if (duel != null) duel.abortDuel(player);

    _returnLoc = player.getStablePoint() == null ? player.getLoc() : player.getStablePoint();

    if (player.isSitting()) player.standUp();

    player.setTarget(null);

    player.leaveParty();

    player.setStablePoint(_returnLoc);

    Location loc =
        arena.getMember1() == this
            ? arena.getInfo().getTeleportLoc1()
            : arena.getInfo().getTeleportLoc2();
    player.teleToLocation(
        Location.findPointToStay(loc, 0, arena.getReflection().getGeoIndex()),
        arena.getReflection());

    setDamage(0.);
    setKilled(false);
  }
Пример #16
0
 public void showBuyTicket(Player player, int val) {
   if (state != ACCEPTING_BETS) return;
   int npcId = getNpcId();
   String filename, search, replace;
   NpcHtmlMessage html = new NpcHtmlMessage(player, this);
   if (val < 10) {
     filename = getHtmlPath(npcId, 2, player);
     html.setFile(filename);
     for (int i = 0; i < 8; i++) {
       int n = i + 1;
       search = "Mob" + n;
       html.replace(search, MonsterRace.getInstance().getMonsters()[i].getTemplate().name);
     }
     search = "No1";
     if (val == 0) html.replace(search, "");
     else {
       html.replace(search, "" + val);
       player.setRace(0, val);
     }
   } else if (val < 20) {
     if (player.getRace(0) == 0) return;
     filename = getHtmlPath(npcId, 3, player);
     html.setFile(filename);
     html.replace("0place", "" + player.getRace(0));
     search = "Mob1";
     replace = MonsterRace.getInstance().getMonsters()[player.getRace(0) - 1].getTemplate().name;
     html.replace(search, replace);
     search = "0adena";
     if (val == 10) html.replace(search, "");
     else {
       html.replace(search, "" + cost[val - 11]);
       player.setRace(1, val - 10);
     }
   } else if (val == 20) {
     if (player.getRace(0) == 0 || player.getRace(1) == 0) return;
     filename = getHtmlPath(npcId, 4, player);
     html.setFile(filename);
     html.replace("0place", "" + player.getRace(0));
     search = "Mob1";
     replace = MonsterRace.getInstance().getMonsters()[player.getRace(0) - 1].getTemplate().name;
     html.replace(search, replace);
     search = "0adena";
     int price = cost[player.getRace(1) - 1];
     html.replace(search, "" + price);
     search = "0tax";
     int tax = 0;
     html.replace(search, "" + tax);
     search = "0total";
     int total = price + tax;
     html.replace(search, "" + total);
   } else {
     if (player.getRace(0) == 0 || player.getRace(1) == 0) return;
     if (player.getAdena() < cost[player.getRace(1) - 1]) {
       player.sendPacket(SystemMsg.YOU_DO_NOT_HAVE_ENOUGH_ADENA);
       return;
     }
     int ticket = player.getRace(0);
     int priceId = player.getRace(1);
     player.setRace(0, 0);
     player.setRace(1, 0);
     player.reduceAdena(cost[priceId - 1], true);
     SystemMessage sm = new SystemMessage(SystemMessage.ACQUIRED__S1_S2);
     sm.addNumber(_raceNumber);
     sm.addItemName(4443);
     player.sendPacket(sm);
     ItemInstance item = ItemFunctions.createItem(4443);
     item.setEnchantLevel(_raceNumber);
     item.setCustomType1(ticket);
     item.setCustomType2(cost[priceId - 1] / 100);
     player.getInventory().addItem(item);
     return;
   }
   html.replace("1race", String.valueOf(_raceNumber));
   player.sendPacket(html);
   player.sendActionFailed();
 }