Рейтинг темы:
  • 0 Голос(ов) - 0 в среднем
  • 1
  • 2
  • 3
  • 4
  • 5
ПА(РЕализация шанса заточки)
#1
Добрый день уважаемые!
Прошу помощи у знающих людей, как реализовать функционал увеличение шанса заточки при покупке ПА на Исходниках "L2emuEnt"
Вот настройки ПА аккаунта
Код:
# Premium state rates, if premiumId > 0
# Premium Exp/Sp rate mod - as * RateXp/Sp
# Premium as classic - use premiumId from table accounts
# if classic false - use custom rates from character_variables for premium rates with same names
# Рейты для ПА, классический тип по ПА аккаунта
PremiumClassic = true
PremiumRateXpSp = 2.0
# Premium drop count mod, IF AUTOLOOT ON, for drop/spoil, mobs/guards/seal stones/adena, not use for GRB
# Рейты дропа/спойла могут быть только если включен автолут
PremiumDropAdenaCount = 2.0
PremiumDropItemChance = 1.0
PremiumDropItemCount = 2.0
PremiumSpoilItemChance = 1.0
PremiumSpoilItemCount = 2.0
PremiumDropStoneChance = 1.0
PremiumDropStoneCount = 2.0
PremiumDropGuardItemChance = 1.0
PremiumDropGuardItemCount = 2.0
PremiumDropRaidItemChance = 1.0
PremiumDropRaidItemCount = 2.0
PremiumDropGrandBossItemChance = 1.0
PremiumDropEventItemChance = 1.0
PremiumDropEventItemCount = 2.0
PremiumManorItemCount = 2.0

Вот что то типо такого
Код:
# % Шанса успешной заточки для ПА
EnchantChancePA = 68
EnchantChanceArmorPA = 52
EnchantChanceAccessoryPA = 54
# Шанс заточки Блесс точкой
EnchantChanceBlessPA = 68
EnchantChanceArmorBlessPA = 52
EnchantChanceAccessoryBlessPA = 54
# Шанс заточки Кристальной точкой
EnchantChanceCrystalPA = 68
EnchantChanceCrystalArmorPA = 52
EnchantChanceCrystalAccessoryPA = 54
Ответ
#2
Если в конфиг не вынесено, значит не реализовано. А значит нужно брать исходники и допиливать, там не сложно.
А если исходников нет то никак :confused:
Ответ
#3
flopix Написал:Если в конфиг не вынесено, значит не реализовано. А значит нужно брать исходники и допиливать, там не сложно.
А если исходников нет то никак :confused:

Исходники сборки имеются,а именно код реализации ПА шанса заточки нету..


Up!!
Помогите пожалуйста!
Ответ
#4
sakson Написал:Исходники сборки имеются,а именно код реализации ПА шанса заточки нету..


Up!!
Помогите пожалуйста!

Ну так, если есть исходники, добавьте загрузку своих конфигов и всуньте пару проверок при заточке и радуйтесь. Или вы кода готового ждете ?
Ответ
#5
ExLite Написал:Ну так, если есть исходники, добавьте загрузку своих конфигов и всуньте пару проверок при заточке и радуйтесь. Или вы кода готового ждете ?
Именно так и есть, в первом же сообщении написано не прямыми словами "Дайте код чтоб с ПА точить лучше".
Ответ
#6
хых... да вобще.

тут реализации то: пара строк в конфиг да пара в пакет заточки.
Ответ
#7
ExLite Написал:Ну так, если есть исходники, добавьте загрузку своих конфигов и всуньте пару проверок при заточке и радуйтесь. Или вы кода готового ждете ?

Что то типо этого?
Код:
else if(Config.SERVICES_RATE_TYPE != Bonus.NO_BONUS && player.getNetConnection().getBonus() > 1)
            {
                if (ItemFunctions.isBlessedEnchantScroll(scrollId)) chance = Config.CHANCE_WEAPON_BLESS_PA;
                else chance = ItemFunctions.isCrystallEnchantScroll(scrollId) ? Config.CHANCE_CRYSTAL_WEAPON_PA : Config.CHANCE_WEAPON_PA;
            }
Ответ
#8
sakson Написал:Что то типо этого?
Код:
else if(Config.SERVICES_RATE_TYPE != Bonus.NO_BONUS && player.getNetConnection().getBonus() > 1)
            {
                if (ItemFunctions.isBlessedEnchantScroll(scrollId)) chance = Config.CHANCE_WEAPON_BLESS_PA;
                else chance = ItemFunctions.isCrystallEnchantScroll(scrollId) ? Config.CHANCE_CRYSTAL_WEAPON_PA : Config.CHANCE_WEAPON_PA;
            }
Именно! Осталось только проверять что точим(оружие, армор, бижа) и в соответствии повысить шанс.
Ответ
#9
Там уже должны быть все проверки. Просто в нужных местах добавить условие.

если ПА есть - шанс с ПА
иначе обычный шанс.
Ответ
#10
А в какой пакет данное вбивать?

RequestEnchantItem????????
Код:
public class RequestEnchantItem extends L2GameClientPacket
{
    private int _objectId, _catalystObjId;

    @Override
    protected void readImpl()
    {
        _objectId = readD();
        _catalystObjId = readD();
    }

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

        if(player.isActionsDisabled())
        {
            player.setEnchantScroll(null);
            player.sendActionFailed();
            return;
        }

        if(player.isInTrade())
        {
            player.setEnchantScroll(null);
            player.sendActionFailed();
            return;
        }

        if(player.isInStoreMode())
        {
            player.setEnchantScroll(null);
            player.sendPacket(EnchantResult.CANCEL);
            player.sendPacket(SystemMsg.YOU_CANNOT_ENCHANT_WHILE_OPERATING_A_PRIVATE_STORE_OR_PRIVATE_WORKSHOP);
            player.sendActionFailed();
            return;
        }

        PcInventory inventory = player.getInventory();
        inventory.writeLock();
        try
        {
            ItemInstance item = inventory.getItemByObjectId(_objectId);
            ItemInstance catalyst = _catalystObjId > 0 ? inventory.getItemByObjectId(_catalystObjId) : null;
            ItemInstance scroll = player.getEnchantScroll();

            if(item == null || scroll == null)
            {
                player.sendActionFailed();
                return;
            }

            EnchantScroll enchantScroll = EnchantItemHolder.getInstance().getEnchantScroll(scroll.getItemId());
            if(enchantScroll == null)
            {
                doEnchantOld(player, item, scroll, catalyst);
                return;
            }

            if(enchantScroll.getMaxEnchant() != -1 && item.getEnchantLevel() >= enchantScroll.getMaxEnchant())
            {
                player.sendPacket(EnchantResult.CANCEL);
                player.sendPacket(SystemMsg.INAPPROPRIATE_ENCHANT_CONDITIONS);
                player.sendActionFailed();
                return;
            }

            if(enchantScroll.getItems().size() > 0)
            {
                if(!enchantScroll.getItems().contains(item.getItemId()))
                {
                    player.sendPacket(EnchantResult.CANCEL);
                    player.sendPacket(SystemMsg.DOES_NOT_FIT_STRENGTHENING_CONDITIONS_OF_THE_SCROLL);
                    player.sendActionFailed();
                    return;
                }
            }
            else
            {
                if(!enchantScroll.getGrades().contains(item.getCrystalType()))
                {
                    player.sendPacket(EnchantResult.CANCEL);
                    player.sendPacket(SystemMsg.DOES_NOT_FIT_STRENGTHENING_CONDITIONS_OF_THE_SCROLL);
                    player.sendActionFailed();
                    return;
                }
            }

            if(!item.canBeEnchanted(false))
            {
                player.sendPacket(EnchantResult.CANCEL);
                player.sendPacket(SystemMsg.INAPPROPRIATE_ENCHANT_CONDITIONS);
                player.sendActionFailed();
                return;
            }

            if(!inventory.destroyItem(scroll, 1L) || catalyst != null && !inventory.destroyItem(catalyst, 1L))
            {
                player.sendPacket(EnchantResult.CANCEL);
                player.sendActionFailed();
                return;
            }

            boolean equipped = false;
            if(equipped = item.isEquipped())
                inventory.unEquipItem(item);

            int safeEnchantLevel = item.getTemplate().getBodyPart() == ItemTemplate.SLOT_FULL_ARMOR ? 4 : 3;

            int chance = 0;
            if(item.getItemId() != 21580 || item.getItemId() != 21706)
                chance = enchantScroll.getChance();
            else if(item.getItemId() == 21580 || item.getItemId() == 21706)
            {
                if(item.getEnchantLevel() == 3)
                    chance = Config.ENCHANT_CHANCE_CRYSTAL_ARMOR_OLF_4;
                else if(item.getEnchantLevel() == 4)
                    chance = Config.ENCHANT_CHANCE_CRYSTAL_ARMOR_OLF_5;
                else if(item.getEnchantLevel() == 5)
                    chance = Config.ENCHANT_CHANCE_CRYSTAL_ARMOR_OLF_6;
                else if(item.getEnchantLevel() == 6)
                    chance = Config.ENCHANT_CHANCE_CRYSTAL_ARMOR_OLF_7;
                else if(item.getEnchantLevel() == 7)
                    chance = Config.ENCHANT_CHANCE_CRYSTAL_ARMOR_OLF_8;
                else if(item.getEnchantLevel() == 8)
                    chance = Config.ENCHANT_CHANCE_CRYSTAL_ARMOR_OLF_9;
                else if(item.getEnchantLevel() == 9)
                    chance = Config.ENCHANT_CHANCE_CRYSTAL_ARMOR_OLF;

            }
            if(item.getEnchantLevel() < safeEnchantLevel)
                chance = 100;

            if(Rnd.chance(chance))
            {
                item.setEnchantLevel(item.getEnchantLevel() + 1);
                item.setJdbcState(JdbcEntityState.UPDATED);
                item.update();

                if(equipped)
                    inventory.equipItem(item);

                player.sendPacket(new InventoryUpdate().addModifiedItem(item));

                player.sendPacket(EnchantResult.SUCESS);

                if(enchantScroll.isHasVisualEffect() && item.getEnchantLevel() > 3)
                    player.broadcastPacket(new MagicSkillUse(player, player, 5965, 1, 500, 1500));
            }
            else
            {
                switch(enchantScroll.getResultType())
                {
                    case CRYSTALS:
                        if(item.isEquipped())
                        player.sendDisarmMessage(item);

                        Log.LogItem(player, Log.EnchantFail, item);

                        if(!inventory.destroyItem(item, 1L))
                        {
                            player.sendActionFailed();
                            return;
                        }

                        int crystalId = item.getCrystalType().cry;
                        if(crystalId > 0 && item.getTemplate().getCrystalCount() > 0)
                        {
                            int crystalAmount = (int) (item.getTemplate().getCrystalCount() * 0.87);
                            if(item.getEnchantLevel() > 3)
                                crystalAmount += item.getTemplate().getCrystalCount() * 0.25 * (item.getEnchantLevel() - 3);
                            if(crystalAmount < 1)
                                crystalAmount = 1;

                            player.sendPacket(new EnchantResult(1, crystalId, crystalAmount));
                            ItemFunctions.addItem(player, crystalId, crystalAmount, true);
                        }
                        else
                            player.sendPacket(EnchantResult.FAILED_NO_CRYSTALS);

                        if(enchantScroll.isHasVisualEffect())
                            player.broadcastPacket(new MagicSkillUse(player, player, 5949, 1, 500, 1500));
                        break;
                    case DROP_ENCHANT:
                        item.setEnchantLevel(0);
                        item.setJdbcState(JdbcEntityState.UPDATED);
                        item.update();

                        if(equipped)
                            inventory.equipItem(item);

                        player.sendPacket(new InventoryUpdate().addModifiedItem(item));
                        player.sendPacket(SystemMsg.THE_BLESSED_ENCHANT_FAILED);
                        player.sendPacket(EnchantResult.BLESSED_FAILED);
                        break;
                    case NOTHING:
                        player.sendPacket(EnchantResult.ANCIENT_FAILED);
                        break;
                }
            }
        }
        finally
        {
            inventory.writeUnlock();

            player.setEnchantScroll(null);
            player.updateStats();
        }
    }

    //@Deprecated
    private static void doEnchantOld(Player player, ItemInstance item, ItemInstance scroll, ItemInstance catalyst)
    {
        PcInventory inventory = player.getInventory();
        // Затычка, ибо клиент криво обрабатывает RequestExTryToPutEnchantSupportItem
        if(!ItemFunctions.checkCatalyst(item, catalyst))
            catalyst = null;

        if(!item.canBeEnchanted(true))
        {
            player.sendPacket(EnchantResult.CANCEL);
            player.sendPacket(SystemMsg.INAPPROPRIATE_ENCHANT_CONDITIONS);
            player.sendActionFailed();
            return;
        }

        int crystalId = ItemFunctions.getEnchantCrystalId(item, scroll, catalyst);

        if(crystalId == -1)
        {
            player.sendPacket(EnchantResult.CANCEL);
            player.sendPacket(SystemMsg.DOES_NOT_FIT_STRENGTHENING_CONDITIONS_OF_THE_SCROLL);
            player.sendActionFailed();
            return;
        }

        int scrollId = scroll.getItemId();

        if(scrollId == 13540 && item.getItemId() != 13539)
        {
            player.sendPacket(EnchantResult.CANCEL);
            player.sendPacket(SystemMsg.DOES_NOT_FIT_STRENGTHENING_CONDITIONS_OF_THE_SCROLL);
            player.sendActionFailed();
            return;
        }

        // ольф 21580(21581/21582)
        if((scrollId == 21581 || scrollId == 21582) && item.getItemId() != 21580)
        {
            player.sendPacket(EnchantResult.CANCEL);
            player.sendPacket(SystemMsg.DOES_NOT_FIT_STRENGTHENING_CONDITIONS_OF_THE_SCROLL);
            player.sendActionFailed();
            return;
        }

        // ольф 21706(21707)
        if(scrollId == 21707 && item.getItemId() != 21706)
        {
            player.sendPacket(EnchantResult.CANCEL);
            player.sendPacket(SystemMsg.DOES_NOT_FIT_STRENGTHENING_CONDITIONS_OF_THE_SCROLL);
            player.sendActionFailed();
            return;
        }

        // ольф 21706(21707)
        if(scrollId != 21707 && item.getItemId() == 21706)
        {
            player.sendPacket(EnchantResult.CANCEL);
            player.sendPacket(SystemMsg.DOES_NOT_FIT_STRENGTHENING_CONDITIONS_OF_THE_SCROLL);
            player.sendActionFailed();
            return;
        }

        // ольф 21580(21581/21582)
        if((scrollId != 21581 || scrollId != 21582) && item.getItemId() == 21580)
        {
            player.sendPacket(EnchantResult.CANCEL);
            player.sendPacket(SystemMsg.DOES_NOT_FIT_STRENGTHENING_CONDITIONS_OF_THE_SCROLL);
            player.sendActionFailed();
            return;
        }

        // TODO: [pchayka] временный хардкод до улучения системы описания свитков заточки
        if(ItemFunctions.isDestructionWpnEnchantScroll(scrollId) && item.getEnchantLevel() >= 15 || ItemFunctions.isDestructionArmEnchantScroll(scrollId) && item.getEnchantLevel() >= 6)
        {
            player.sendPacket(EnchantResult.CANCEL);
            player.sendPacket(SystemMsg.DOES_NOT_FIT_STRENGTHENING_CONDITIONS_OF_THE_SCROLL);
            player.sendActionFailed();
            return;
        }

        int itemType = item.getTemplate().getType2();
        boolean fail = false;
        switch(item.getItemId())
        {
            case 13539:
                if(item.getEnchantLevel() >= Config.ENCHANT_MAX_MASTER_YOGI_STAFF)
                    fail = true;
                break;
            case 21580:
                if(item.getEnchantLevel() < 9)
                    fail = false;
                else
                    fail = true;
                break;
            default:
            {
                if(itemType == ItemTemplate.TYPE2_WEAPON)
                {
                    if(Config.ENCHANT_MAX_WEAPON > 0 && item.getEnchantLevel() >= Config.ENCHANT_MAX_WEAPON)
                        fail = true;
                }
                else if(itemType == ItemTemplate.TYPE2_SHIELD_ARMOR)
                {    
                    if(Config.ENCHANT_MAX_ARMOR > 0 && item.getEnchantLevel() >= Config.ENCHANT_MAX_ARMOR)
                        fail = true;
                }    
                else if(itemType == ItemTemplate.TYPE2_ACCESSORY)
                {    
                    if(Config.ENCHANT_MAX_JEWELRY > 0 && item.getEnchantLevel() >= Config.ENCHANT_MAX_JEWELRY)
                        fail = true;
                }        
                else fail = true;
            }
                break;
        }

        if(!inventory.destroyItem(scroll, 1L) || catalyst != null && !inventory.destroyItem(catalyst, 1L))
        {
            player.sendPacket(EnchantResult.CANCEL);
            player.sendActionFailed();
            return;
        }

        if(fail)
        {
            player.sendPacket(EnchantResult.CANCEL);
            player.sendPacket(SystemMsg.INAPPROPRIATE_ENCHANT_CONDITIONS);
            player.sendActionFailed();
            return;
        }

        int safeEnchantLevel = item.getTemplate().getBodyPart() == ItemTemplate.SLOT_FULL_ARMOR ? Config.SAFE_ENCHANT_FULL_BODY : Config.SAFE_ENCHANT_COMMON;

        double chance;
        if(item.getEnchantLevel() < safeEnchantLevel)
            chance = 100;
        else if(itemType == ItemTemplate.TYPE2_WEAPON)
        {
            if(Config.USE_ALT_ENCHANT)
            {
                if(ItemFunctions.isCrystallEnchantScroll(scrollId))
                    chance = item.getEnchantLevel() > Config.ENCHANT_WEAPON_FIGHT_CRYSTAL.size() ? Config.ENCHANT_WEAPON_FIGHT_CRYSTAL.get(Config.ENCHANT_WEAPON_FIGHT_CRYSTAL.size() - 1) : Config.ENCHANT_WEAPON_FIGHT_CRYSTAL.get(item.getEnchantLevel());
                else if(ItemFunctions.isBlessedEnchantScroll(scrollId))
                    chance = item.getEnchantLevel() > Config.ENCHANT_WEAPON_FIGHT_BLESSED.size() ? Config.ENCHANT_WEAPON_FIGHT_BLESSED.get(Config.ENCHANT_WEAPON_FIGHT_BLESSED.size() - 1) : Config.ENCHANT_WEAPON_FIGHT_BLESSED.get(item.getEnchantLevel());
                else
                    chance = item.getEnchantLevel() > Config.ENCHANT_WEAPON_FIGHT.size() ? Config.ENCHANT_WEAPON_FIGHT.get(Config.ENCHANT_WEAPON_FIGHT.size() - 1) : Config.ENCHANT_WEAPON_FIGHT.get(item.getEnchantLevel());
            }
                        else if((Config.SERVICES_RATE_TYPE != Bonus.NO_BONUS && player.getNetConnection().getBonus() > 1) && Config.USE_ALT_ENCHANT_PA)
                        {
                                if(ItemFunctions.isCrystallEnchantScroll(scrollId))
                    chance = item.getEnchantLevel() > Config.ENCHANT_WEAPON_FIGHT_CRYSTAL_PA.size() ? Config.ENCHANT_WEAPON_FIGHT_CRYSTAL_PA.get(Config.ENCHANT_WEAPON_FIGHT_CRYSTAL_PA.size() - 1) : Config.ENCHANT_WEAPON_FIGHT_CRYSTAL_PA.get(item.getEnchantLevel());
                else if(ItemFunctions.isBlessedEnchantScroll(scrollId))
                    chance = item.getEnchantLevel() > Config.ENCHANT_WEAPON_FIGHT_BLESSED_PA.size() ? Config.ENCHANT_WEAPON_FIGHT_BLESSED_PA.get(Config.ENCHANT_WEAPON_FIGHT_BLESSED_PA.size() - 1) : Config.ENCHANT_WEAPON_FIGHT_BLESSED_PA.get(item.getEnchantLevel());
                else
                    chance = item.getEnchantLevel() > Config.ENCHANT_WEAPON_FIGHT_PA.size() ? Config.ENCHANT_WEAPON_FIGHT_PA.get(Config.ENCHANT_WEAPON_FIGHT_PA.size() - 1) : Config.ENCHANT_WEAPON_FIGHT_PA.get(item.getEnchantLevel());
                        }        
            else if(Config.SERVICES_RATE_TYPE != Bonus.NO_BONUS && player.getNetConnection().getBonus() > 1)
            {
                if (ItemFunctions.isBlessedEnchantScroll(scrollId)) chance = Config.ENCHANT_CHANCE_WEAPON_BLESS_PA;
                else chance = ItemFunctions.isCrystallEnchantScroll(scrollId) ? Config.ENCHANT_CHANCE_CRYSTAL_WEAPON_PA : Config.ENCHANT_CHANCE_WEAPON_PA;
            }
            else if (ItemFunctions.isBlessedEnchantScroll(scrollId)) chance = Config.ENCHANT_CHANCE_WEAPON_BLESS;
            else chance = ItemFunctions.isCrystallEnchantScroll(scrollId) ? Config.ENCHANT_CHANCE_CRYSTAL_WEAPON : Config.ENCHANT_CHANCE_WEAPON;
        }
        else if(itemType == ItemTemplate.TYPE2_SHIELD_ARMOR)
            if(Config.USE_ALT_ENCHANT)
            {
                if(ItemFunctions.isCrystallEnchantScroll(scrollId))
                    chance = item.getEnchantLevel() > Config.ENCHANT_ARMOR_CRYSTAL.size() ? Config.ENCHANT_ARMOR_CRYSTAL.get(Config.ENCHANT_ARMOR_CRYSTAL.size() - 1) : Config.ENCHANT_ARMOR_CRYSTAL.get(item.getEnchantLevel());
                else if(ItemFunctions.isBlessedEnchantScroll(scrollId))
                    chance = item.getEnchantLevel() > Config.ENCHANT_ARMOR_BLESSED.size() ? Config.ENCHANT_ARMOR_BLESSED.get(Config.ENCHANT_ARMOR_BLESSED.size() - 1) : Config.ENCHANT_ARMOR_BLESSED.get(item.getEnchantLevel());
                else
                    chance = item.getEnchantLevel() > Config.ENCHANT_ARMOR.size() ? Config.ENCHANT_ARMOR.get(Config.ENCHANT_ARMOR.size() - 1) : Config.ENCHANT_ARMOR.get(item.getEnchantLevel());
            }
                        else if((Config.SERVICES_RATE_TYPE != Bonus.NO_BONUS && player.getNetConnection().getBonus() > 1) && Config.USE_ALT_ENCHANT_PA)
                        {
                if(ItemFunctions.isCrystallEnchantScroll(scrollId))
                    chance = item.getEnchantLevel() > Config.ENCHANT_ARMOR_CRYSTAL_PA.size() ? Config.ENCHANT_ARMOR_CRYSTAL_PA.get(Config.ENCHANT_ARMOR_CRYSTAL_PA.size() - 1) : Config.ENCHANT_ARMOR_CRYSTAL_PA.get(item.getEnchantLevel());
                else if(ItemFunctions.isBlessedEnchantScroll(scrollId))
                    chance = item.getEnchantLevel() > Config.ENCHANT_ARMOR_BLESSED_PA.size() ? Config.ENCHANT_ARMOR_BLESSED_PA.get(Config.ENCHANT_ARMOR_BLESSED_PA.size() - 1) : Config.ENCHANT_ARMOR_BLESSED_PA.get(item.getEnchantLevel());
                else
                    chance = item.getEnchantLevel() > Config.ENCHANT_ARMOR_PA.size() ? Config.ENCHANT_ARMOR_PA.get(Config.ENCHANT_ARMOR_PA.size() - 1) : Config.ENCHANT_ARMOR_PA.get(item.getEnchantLevel());
            }  
            else if(Config.SERVICES_RATE_TYPE != Bonus.NO_BONUS && player.getNetConnection().getBonus() > 1)
            {
                if (ItemFunctions.isBlessedEnchantScroll(scrollId)) chance = Config.ENCHANT_CHANCE_ARMOR_BLESS_PA;
                else chance = ItemFunctions.isCrystallEnchantScroll(scrollId) ? Config.ENCHANT_CHANCE_CRYSTAL_ARMOR_PA : Config.ENCHANT_CHANCE_ARMOR_PA;
            }
            else if (ItemFunctions.isBlessedEnchantScroll(scrollId)) chance = Config.ENCHANT_CHANCE_ARMOR_BLESS;
            else chance = ItemFunctions.isCrystallEnchantScroll(scrollId) ? Config.ENCHANT_CHANCE_CRYSTAL_ARMOR : Config.ENCHANT_CHANCE_ARMOR;
        else if(itemType == ItemTemplate.TYPE2_ACCESSORY)
            if(Config.USE_ALT_ENCHANT)
            {
                if(ItemFunctions.isCrystallEnchantScroll(scrollId))
                    chance = item.getEnchantLevel() > Config.ENCHANT_ARMOR_JEWELRY_CRYSTAL.size() ? Config.ENCHANT_ARMOR_JEWELRY_CRYSTAL.get(Config.ENCHANT_ARMOR_JEWELRY_CRYSTAL.size() - 1) : Config.ENCHANT_ARMOR_JEWELRY_CRYSTAL.get(item.getEnchantLevel());
                else if(ItemFunctions.isBlessedEnchantScroll(scrollId))
                    chance = item.getEnchantLevel() > Config.ENCHANT_ARMOR_JEWELRY_BLESSED.size() ? Config.ENCHANT_ARMOR_JEWELRY_BLESSED.get(Config.ENCHANT_ARMOR_JEWELRY_BLESSED.size() - 1) : Config.ENCHANT_ARMOR_JEWELRY_BLESSED.get(item.getEnchantLevel());
                else
                    chance = item.getEnchantLevel() > Config.ENCHANT_ARMOR_JEWELRY.size() ? Config.ENCHANT_ARMOR_JEWELRY.get(Config.ENCHANT_ARMOR_JEWELRY.size() - 1) : Config.ENCHANT_ARMOR_JEWELRY.get(item.getEnchantLevel());
            }
            else if((Config.SERVICES_RATE_TYPE != Bonus.NO_BONUS && player.getNetConnection().getBonus() > 1) && Config.USE_ALT_ENCHANT_PA)
                        {
                if(ItemFunctions.isCrystallEnchantScroll(scrollId))
                    chance = item.getEnchantLevel() > Config.ENCHANT_ARMOR_JEWELRY_CRYSTAL_PA.size() ? Config.ENCHANT_ARMOR_JEWELRY_CRYSTAL_PA.get(Config.ENCHANT_ARMOR_JEWELRY_CRYSTAL_PA.size() - 1) : Config.ENCHANT_ARMOR_JEWELRY_CRYSTAL_PA.get(item.getEnchantLevel());
                else if(ItemFunctions.isBlessedEnchantScroll(scrollId))
                    chance = item.getEnchantLevel() > Config.ENCHANT_ARMOR_JEWELRY_BLESSED_PA.size() ? Config.ENCHANT_ARMOR_JEWELRY_BLESSED_PA.get(Config.ENCHANT_ARMOR_JEWELRY_BLESSED_PA.size() - 1) : Config.ENCHANT_ARMOR_JEWELRY_BLESSED_PA.get(item.getEnchantLevel());
                else
                    chance = item.getEnchantLevel() > Config.ENCHANT_ARMOR_JEWELRY_PA.size() ? Config.ENCHANT_ARMOR_JEWELRY_PA.get(Config.ENCHANT_ARMOR_JEWELRY_PA.size() - 1) : Config.ENCHANT_ARMOR_JEWELRY_PA.get(item.getEnchantLevel());
            }    
                        else if(Config.SERVICES_RATE_TYPE != Bonus.NO_BONUS && player.getNetConnection().getBonus() > 1)
            {
                if (ItemFunctions.isBlessedEnchantScroll(scrollId)) chance = Config.ENCHANT_CHANCE_ACCESSORY_BLESS_PA;
                else chance = ItemFunctions.isCrystallEnchantScroll(scrollId) ? Config.ENCHANT_CHANCE_CRYSTAL_ACCESSORY_PA : Config.ENCHANT_CHANCE_ACCESSORY_PA;
            }
            else if (ItemFunctions.isBlessedEnchantScroll(scrollId)) chance = Config.ENCHANT_CHANCE_ACCESSORY_BLESS;
            else chance = ItemFunctions.isCrystallEnchantScroll(scrollId) ? Config.ENCHANT_CHANCE_CRYSTAL_ACCESSORY : Config.ENCHANT_CHANCE_ACCESSORY;
        else
        {
            player.sendPacket(EnchantResult.CANCEL);
            player.sendActionFailed();
            return;
        }

        if(ItemFunctions.isDivineEnchantScroll(scrollId)) // Item Mall divine
            chance = 100;
        else if(ItemFunctions.isItemMallEnchantScroll(scrollId)) // Item Mall normal/ancient
            chance += 10;

        if(catalyst != null)
            chance += ItemFunctions.getCatalystPower(catalyst.getItemId());

        if(scrollId == 13540)
            chance = item.getEnchantLevel() < Config.SAFE_ENCHANT_MASTER_YOGI_STAFF ? 100 : Config.ENCHANT_CHANCE_MASTER_YOGI_STAFF;
        else if(scrollId == 21581 || scrollId == 21582)
            if(item.getEnchantLevel() < 9)
                chance = item.getEnchantLevel() < 3 ? 100 : Config.ENCHANT_CHANCE_CRYSTAL_ARMOR_OLF;
            else
                chance = 0;

        boolean equipped = false;
        if(equipped = item.isEquipped())
            inventory.unEquipItem(item);
        if(Rnd.chance(chance))
        {
            item.setEnchantLevel(item.getEnchantLevel() + 1);
            item.setJdbcState(JdbcEntityState.UPDATED);
            item.update();

            if(equipped)
                inventory.equipItem(item);

            player.sendPacket(new InventoryUpdate().addModifiedItem(item));

            player.sendPacket(EnchantResult.SUCESS);

            if(scrollId == 13540 && item.getEnchantLevel() > 3 || Config.SHOW_ENCHANT_EFFECT_RESULT)
                player.broadcastPacket(new MagicSkillUse(player, player, 5965, 1, 500, 1500));
        }
        else if(ItemFunctions.isBlessedEnchantScroll(scrollId)) // фейл, но заточка блесед
        {
            item.setEnchantLevel(Config.SAFE_ENCHANT_LVL);
            item.setJdbcState(JdbcEntityState.UPDATED);
            item.update();

            if(equipped)
                inventory.equipItem(item);

            player.sendPacket(new InventoryUpdate().addModifiedItem(item));
            player.sendPacket(SystemMsg.THE_BLESSED_ENCHANT_FAILED);
            player.sendPacket(EnchantResult.BLESSED_FAILED);
        }
        else if(ItemFunctions.isAncientEnchantScroll(scrollId) || ItemFunctions.isDestructionWpnEnchantScroll(scrollId) || ItemFunctions.isDestructionArmEnchantScroll(scrollId)) // фейл, но заточка ancient или destruction
            player.sendPacket(EnchantResult.ANCIENT_FAILED);
        else
        // фейл, разбиваем вещь
        {
            if(item.isEquipped())
                player.sendDisarmMessage(item);

            Log.LogItem(player, Log.EnchantFail, item);

            if(!inventory.destroyItem(item, 1L))
            {
                player.sendPacket(new SystemMessage(SystemMessage.THE_ENCHANTMENT_HAS_FAILED_YOUR_S1_HAS_BEEN_CRYSTALLIZED).addItemName(item.getItemId()));
                player.sendActionFailed();
                return;
            }

            if(crystalId > 0 && item.getTemplate().getCrystalCount() > 0)
            {
                int crystalAmount = (int) (item.getTemplate().getCrystalCount() * 0.87);
                if(item.getEnchantLevel() > 3)
                    crystalAmount += item.getTemplate().getCrystalCount() * 0.25 * (item.getEnchantLevel() - 3);
                if(crystalAmount < 1)
                    crystalAmount = 1;

                player.sendPacket(new EnchantResult(1, crystalId, crystalAmount));
                ItemFunctions.addItem(player, crystalId, crystalAmount, true);
            }
            else
                player.sendPacket(EnchantResult.FAILED_NO_CRYSTALS);

            if(scrollId == 13540 || Config.SHOW_ENCHANT_EFFECT_RESULT)
                player.broadcastPacket(new MagicSkillUse(player, player, 5949, 1, 500, 1500));
        }
    }
}
Ответ


Возможно похожие темы ...
Тема Автор Ответы Просмотры Последний пост
  Заточки :) Enchanter 3 1,757 02-07-2018, 08:41 PM
Последний пост: Emperor
  Лаг катализатора для заточки SoniPro 5 2,262 09-23-2017, 01:35 PM
Последний пост: 4ipolino
  Реализация KnownList Alay 38 8,934 02-16-2017, 11:23 PM
Последний пост: Visor
  CommunityBoard + GM Shop реализация michail_ST 5 1,670 04-21-2016, 01:20 PM
Последний пост: flopix
  Заточки в стопку GodStopMe 16 3,542 04-07-2015, 10:41 AM
Последний пост: Kampina
  Доброго времени суток (Команда + реализация) Creat1v 0 1,017 01-11-2015, 11:22 AM
Последний пост: Creat1v
  Отображение заточки в покупке\продаже aCis Map 10 2,567 07-19-2014, 05:48 PM
Последний пост: moveton
  Реализация инстанса Линдвиора NoizeBD 2 1,433 05-13-2014, 09:13 PM
Последний пост: NoizeBD
  Стоимость заточки скилов Intelect 5 1,482 05-13-2014, 11:03 AM
Последний пост: Persy
  Разделение заточки. GOODPower 0 1,065 03-20-2014, 02:22 AM
Последний пост: GOODPower

Перейти к форуму:


Пользователи, просматривающие эту тему: 1 Гость(ей)