Рейтинг темы:
  • 0 Голос(ов) - 0 в среднем
  • 1
  • 2
  • 3
  • 4
  • 5
ПА(РЕализация шанса заточки)
#11
Судя по коду, оно у вас уже реализовано:
[SRC="java"]
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;
}
[/SRC]
Ответ
#12
ExLite Написал:Судя по коду, оно у вас уже реализовано:
[SRC="java"]
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;
}
[/SRC]

Это с Frist-Team
А вот с ентерпрайса
Код:
public class RequestEnchantItem extends L2GameClientPacket
{
    private static final String    _C__58_REQUESTENCHANTITEM    = "[C] 58 RequestEnchantItem";

    private int                    _objectId;
    private static final int[] _scrolls100 = {20521,22018,22019,20522,22020,22021};

    /**
     * packet type id 0x58
     *
     * sample
     *
     * 58
     * c0 d5 00 10 // objectId
     *
     * format:      cd
     * @param decrypt
     */
    @Override
    protected void readImpl()
    {
        _objectId = readD();
    }

    @Override
    protected void runImpl()
    {
        L2PcInstance activeChar = getClient().getActiveChar();
        if (activeChar == null || _objectId == 0)
            return;
        
        if (activeChar.isOnline() == 0)
        {
            activeChar.getPcSecurity(). stopEnchanting();
            activeChar.sendPacket(new EnchantResult(2, 0, 0));
            return;
        }
        
        //L2EMU-VCT
        if (activeChar.getPrivateStoreType() != 0)
        {
            activeChar.getPcSecurity().stopEnchanting();
            activeChar.sendPacket(SystemMessageId.CANNOT_ENCHANT_WHILE_STORE);
            activeChar.sendPacket(new EnchantResult(2, 0, 0));
            return;
        }
        
        if (activeChar.isProcessingTransaction())
        {
            activeChar.getPcSecurity().stopEnchanting();
            activeChar.sendPacket(SystemMessageId.ALREADY_TRADING);
            activeChar.sendPacket(new EnchantResult(2, 0, 0));
            return;
        }
        
        if (activeChar.isProcessingRequest())
        {
            activeChar.getPcSecurity().stopEnchanting();
            activeChar.sendPacket(new EnchantResult(2, 0, 0));
            return;
        }
        
        if (activeChar.getTradeRefusal())
        {
            activeChar.getPcSecurity().stopEnchanting();
            activeChar.sendMessage("Target is in trade refusal mode.");
            activeChar.sendPacket(new EnchantResult(2, 0, 0));
            return;
        }
        //L2EMU-VCT

        // Restrict enchant during restart/shutdown (because of an existing exploit)
        if (Shutdown.isActionDisabled(DisableType.ENCHANT))
        {
            activeChar.getPcSecurity().stopEnchanting();
            activeChar.sendMessage("Enchanting items is not allowed during restart/shutdown.");
            activeChar.sendPacket(new EnchantResult(2, 0, 0));
            return;
        }

        // Restrict enchant during a trade (bug if enchant fails)
        if (activeChar.getActiveTradeList() != null)
        {
            // Cancel trade
            activeChar.getPcSecurity().stopEnchanting();
            activeChar.sendMessage("Enchanting items is not allowed during a trade.");
            activeChar.sendPacket(new EnchantResult(2, 0, 0));
            return;
        }
        
        L2ItemInstance item = activeChar.getInventory().getItemByObjectId(_objectId);
        L2ItemInstance scroll = activeChar.getPcSecurity().getActiveEnchantScroll();
        L2ItemInstance support = activeChar.getPcSecurity().getActiveEnchantSupportItem();
        
        if (item == null || scroll == null || item.getOwnerId() != activeChar.getObjectId() || item != activeChar.getPcSecurity().getActiveEnchantItem())
        {
            Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " use cheat program ", Config.DEFAULT_PUNISH);
            activeChar.getPcSecurity().stopEnchanting();
            activeChar.sendPacket(new EnchantResult(2, 0, 0));
            return;
        }
        
        //if (activeChar.isMoving()) activeChar.stopMove(null);
        
        // template for scroll
        EnchantScroll scrollTemplate = EnchantItemTable.getInstance().getEnchantScroll(scroll);

        // scroll not found in list
        if (scrollTemplate == null)
        {
            activeChar.getPcSecurity().stopEnchanting();
            _log.warn("RequestEnchantItem scrollTemplate = null for scroll itemId="+scroll.getItemId());
            activeChar.sendPacket(new EnchantResult(2, 0, 0));
            return;
        }

        // template for support item, if exist
        EnchantItem supportTemplate = null;
        if (support != null)
            supportTemplate = EnchantItemTable.getInstance().getSupportItem(support);

        // first validation check
        if (!scrollTemplate.isValid(item, supportTemplate) || !ItemTable.isEnchantable(item) || activeChar.isEquipping() || activeChar.isAttackingNow() || activeChar.isCastingNow())
        {
            activeChar.sendPacket(new SystemMessage(SystemMessageId.INAPPROPRIATE_ENCHANT_CONDITION));
            activeChar.getPcSecurity().stopEnchanting();
            activeChar.sendPacket(new EnchantResult(2, 0, 0));
            return;
        }

        // attempting to destroy scroll
        scroll = activeChar.getInventory().destroyItem("EnchantDestroy", scroll.getObjectId(), 1, activeChar, item);
        if (scroll == null)
        {
            activeChar.sendPacket(new SystemMessage(SystemMessageId.NOT_ENOUGH_ITEMS));
            Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " tried to enchant with a scroll he doesn't have", Config.DEFAULT_PUNISH);
            activeChar.getPcSecurity().stopEnchanting();
            activeChar.sendPacket(new EnchantResult(2, 0, 0));
            return;
        }

        // attempting to destroy support if exist
        if (support != null)
        {
            support = activeChar.getInventory().destroyItem("EnchantDestroy", support.getObjectId(), 1, activeChar, item);
            if (support == null)
            {
                activeChar.sendPacket(new SystemMessage(SystemMessageId.NOT_ENOUGH_ITEMS));
                Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " tried to enchant with a support item he doesn't have", Config.DEFAULT_PUNISH);
                activeChar.getPcSecurity().stopEnchanting();
                activeChar.sendPacket(new EnchantResult(2, 0, 0));
                return;
            }
        }

        SystemMessage sm;

        int chance = (int)Math.round(scrollTemplate.getChance(item, supportTemplate));
        
        if (chance == -1)
        {
            activeChar.sendMessage("Not valid item for enchant");
            activeChar.getPcSecurity().stopEnchanting();
            activeChar.sendPacket(new EnchantResult(2, 0, 0));
            return;
        }

        if (chance == -2)
        {
            activeChar.sendMessage("Enchant limitis riched for this item");
            activeChar.getPcSecurity().stopEnchanting();
            activeChar.sendPacket(new EnchantResult(2, 0, 0));
            return;
        }
        
        //L2EMU-VCT
        if (Config.ENT_RETAIL_ENCHANT_SYSTEM)
        {
            if (item.getItem().getBodyPart() == L2Item.SLOT_FULL_ARMOR)
                chance = AdvUtil.InDegree(chance,(item.getEnchantLevel()-Config.ENCHANT_SAFE_MAX_FULL + 1));
            else
                chance = AdvUtil.InDegree(chance,(item.getEnchantLevel()-Config.ENCHANT_SAFE_MAX + 1));
        }
        //L2EMU-VCT
        
        // last validation check
        if (item.getOwnerId() != activeChar.getObjectId()
                || !ItemTable.isEnchantable(item)
                || chance < 0)
        {
            activeChar.sendPacket(new SystemMessage(SystemMessageId.INAPPROPRIATE_ENCHANT_CONDITION));
            activeChar.getPcSecurity().stopEnchanting();
            activeChar.sendPacket(new EnchantResult(2, 0, 0));
            return;
        }

        if (Config.ENT_TEST)
            _log.info("EnchantItem CharName="+activeChar.getName()+" enchant item="+item.getName()+" to EnchantLevel="+(item.getEnchantLevel() + 1)+" chance="+chance+" of 10000");
        if (Config.ENCHANT_SHOWCLIENT)
        {
            String bless = "";
            if (scrollTemplate.isBlessed()  || (Config.ENT_ENCHANTSTONE_SAFE && supportTemplate != null))
                bless = " blessed";
            String safe = "";
            if (scrollTemplate.isSafe())
                bless = " safe";
            if (activeChar.isLangRu())
                activeChar.sendMessage("Заточка "+item.getName()+" до +"+(item.getEnchantLevel() + 1)+" шанс "+((double)chance / 100.0)+"% "+bless+safe);
            else
                activeChar.sendMessage("Enchant "+item.getName()+" to +"+(item.getEnchantLevel() + 1)+" chance "+((double)chance / 100.0)+"%"+ bless+safe);
        }
        
        if (!Config.ENCHANT_USE100 && Util.contains(_scrolls100, scroll.getItemId()))
        {
            _log.warn("RequestEnchantItem player="+activeChar.getName()+" use 100% enchant scroll "+scroll.getName()+"("+scroll.getItemId()+") count="+scroll.getCount());
            activeChar.getPcSecurity().stopEnchanting();
            activeChar.sendPacket(new EnchantResult(2, 0, 0));
            return;
        }
        
        boolean needEquip = false;
        L2ItemInstance itemBack = null;
        // unequip item on enchant failure to avoid item skills stack
        if (item.isEquipped())
        {
            if (item.isArmor() && item.getItem().getType2() != L2Item.TYPE2_ACCESSORY && activeChar.getInventory().getPaperdollItem(Inventory.PAPERDOLL_BACK) != null)
            {
                itemBack = activeChar.getInventory().getPaperdollItem(Inventory.PAPERDOLL_BACK);
                activeChar.useEquippableItemSilent(itemBack);
            }
            needEquip = activeChar.useEquippableItemSilent(item);
        }
        
        if (Rnd.get(10000) < chance)
        {
            if (Config.ENCHANT_LOG)
                ItemTable.logEnchantItem(activeChar, item, scroll, support, chance, true," to +"+(item.getEnchantLevel() + 1));
            // success
            // обработка параметра directlyToLevel
            if (scrollTemplate.getDirectlyToLevel() > 0)
            {
                if (item.getEnchantLevel() < scrollTemplate.getDirectlyToLevel())
                    item.setEnchantLevel(scrollTemplate.getDirectlyToLevel());
                else
                    item.setEnchantLevel(item.getEnchantLevel() + 1);
            }
            item.setEnchantLevel(item.getEnchantLevel() + 1);
            if (needEquip)
            {
                if (activeChar.useEquippableItemSilent(item) && itemBack != null && !itemBack.isEquipped())
                        activeChar.useEquippableItemSilent(itemBack);
            }
            item.updateDatabase();
            activeChar.sendPacket(new EnchantResult(0, 0, 0));
        }
        else
        {
            if (scrollTemplate.isSafe())
            {
                if (Config.ENCHANT_LOG)
                    ItemTable.logEnchantItem(activeChar, item, scroll, support, chance, false, " isSafe");
                // safe enchant - remain old value
                // need retail message
                if (needEquip)
                {
                    if (activeChar.useEquippableItemSilent(item) && itemBack != null && !itemBack.isEquipped())
                        activeChar.useEquippableItemSilent(itemBack);
                }
                activeChar.sendPacket(new EnchantResult(5, 0, 0));
            }
            else if (scrollTemplate.getIsSafeToLevel() > 0)
            {
                if (Config.ENCHANT_LOG)
                    ItemTable.logEnchantItem(activeChar, item, scroll, support, chance, false, " isSafeToLevel");

                // If itm.enchLvl >= isSafeLevel then drop to item.enchLvl to isSafeLevel
                if (scrollTemplate.getIsSafeToLevel() < item.getEnchantLevel())
                {
                    item.setEnchantLevel(scrollTemplate.getIsSafeToLevel());
                    item.updateDatabase();
                }

                // safe enchant - remain old value
                // need retail message
                if (needEquip)
                {
                    if (activeChar.useEquippableItemSilent(item) && itemBack != null && !itemBack.isEquipped())
                        activeChar.useEquippableItemSilent(itemBack);
                }
                activeChar.sendPacket(new EnchantResult(5, 0, 0));
            }
            else
            {
                if (scrollTemplate.isBlessed()  || (Config.ENT_ENCHANTSTONE_SAFE && supportTemplate != null))
                {
                    // blessed enchant - clear enchant value
                    sm = new SystemMessage(SystemMessageId.BLESSED_ENCHANT_FAILED);
                    activeChar.sendPacket(sm);

                    if (Config.ENCHANT_LOG)
                        ItemTable.logEnchantItem(activeChar, item, scroll, support, chance, false, " to +"+scrollTemplate.getBreakToLevel());
                    
                    item.setEnchantLevel(scrollTemplate.getBreakToLevel());
                    if (needEquip)
                    {
                        if (activeChar.useEquippableItemSilent(item) && itemBack != null && !itemBack.isEquipped())
                            activeChar.useEquippableItemSilent(itemBack);
                    }
                    item.updateDatabase();
                    activeChar.sendPacket(new EnchantResult(3, 0, 0));
                }
                else
                {
                    // enchant failed, destroy item
                    int crystalId = item.getItem().getCrystalItemId();
                    int count = item.getCrystalCount() - (item.getItem().getCrystalCount() + 1) / 2;
                    if (count < 1)
                        count = 1;

                    if (Config.ENCHANT_LOG)
                        ItemTable.logEnchantItem(activeChar, item, scroll, support, chance, false, " destroy to crystals");
                    
                    L2ItemInstance destroyItem = activeChar.getInventory().destroyItem("EnchantDestroy", item, activeChar, null);
                    if (destroyItem == null)
                    {
                        // unable to destroy item, cheater ?
                        Util.handleIllegalPlayerAction(activeChar, "Unable to delete item on enchant failure from player " + activeChar.getName() + ", possible cheater !", Config.DEFAULT_PUNISH);
                        activeChar.getPcSecurity().stopEnchanting();
                        activeChar.sendPacket(new EnchantResult(2, 0, 0));
                        return;
                    }

                    L2ItemInstance crystals = null;
                    if (crystalId != 0)
                    {
                        crystals = activeChar.getInventory().addItem("EnchantCreate", crystalId, count, activeChar, destroyItem);
                        if (crystals == null) return;

                        sm = new SystemMessage(SystemMessageId.EARNED_S2_S1_S);
                        sm.addItemName(crystals);
                        sm.addItemNumber(count);
                        activeChar.sendPacket(sm);
                    }

                    if (!Config.FORCE_INVENTORY_UPDATE)
                    {
                        InventoryUpdate iu = new InventoryUpdate();
                        if (destroyItem.getCount() == 0)
                            iu.addRemovedItem(destroyItem);
                        else
                            iu.addModifiedItem(destroyItem);
                        if (crystals != null)
                            iu.addItem(crystals);

                        activeChar.sendPacket(iu);
                    }
                    else
                        activeChar.sendPacket(new ItemList(activeChar, true));

                    L2World.removeObject(destroyItem);
                    if (crystalId == 0)
                        activeChar.sendPacket(new EnchantResult(4, 0, 0));
                    else
                        activeChar.sendPacket(new EnchantResult(1, crystalId, count));
                }
            }
        }
        sm = null;

        StatusUpdate su = new StatusUpdate(activeChar.getObjectId());
        su.addAttribute(StatusUpdate.CUR_LOAD, activeChar.getCurrentLoad());
        activeChar.sendPacket(su);
        su = null;

        activeChar.getPcSecurity().setActiveEnchantItem(null);
        activeChar.getPcSecurity().setActiveEnchantScroll(null);
        activeChar.getPcSecurity().setActiveEnchantSupportItem(null);
        activeChar.sendPacket(new ItemList(activeChar, false));
        activeChar.sendPacket(new ShortCutInit(activeChar));
        activeChar.broadcastUserInfo();
    }
    
    /* (non-Javadoc)
     * @see enterprise.gameserver.clientpackets.ClientBasePacket#getType()
     */
    @Override
    public String getType()
    {
        return _C__58_REQUESTENCHANTITEM;
    }
}
Ответ
#13
Ну, тогда все ясно. Просто взять и Ctrl+C -> Ctrl+V (как Вы хотели) с одной сборки в другую у Вас не выйдет, что бы адаптировать или написать то что вам нужно под Emu, Вам надо понять код, а для этого, как минимум, необходимо знать основы какого либо языка программирования.
Ответ
#14
Пичальнее некуда...
Ответ
#15
sakson Написал:Пичальнее некуда...
Вам дали ответ, причем очень четкий и понятный.
Берете исходники - будьте готовы с ними работать. Никто за вас не будет ничего писать.
Ответ


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

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


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