public override async Task RunImpl()
        {
            await Task.Run(() =>
            {
                L2Player player = _client.CurrentPlayer;

                if ((player.EnchantState != ItemEnchantManager.StateEnchantStart) ||
                    (player.EnchantItem.ObjectId != _aSTargetId))
                {
                    player.SendSystemMessage(SystemMessageId.RegistrationOfEnhancementSpellbookHasFailed);
                    player.SendActionFailedAsync();
                    return;
                }

                L2Item stone = player.GetItemByObjId(_aSSupportId);

                if (stone == null)
                {
                    player.SendSystemMessage(SystemMessageId.RegistrationOfEnhancementSpellbookHasFailed);
                    player.SendActionFailedAsync();
                    return;
                }

                ItemEnchantManager.GetInstance().TryPutStone(player, stone);
            });
        }
        public override async Task RunImpl()
        {
            await Task.Run(() =>
            {
                L2Player player = _client.CurrentPlayer;

                if (player.EnchantState != ItemEnchantManager.StatePutItem)
                {
                    player.SendSystemMessage(SystemMessage.SystemMessageId.InappropriateEnchantCondition);
                    player.SendActionFailedAsync();
                    return;
                }

                L2Item item = player.GetItemByObjId(_aSTargetId);

                if (item == null)
                {
                    player.SendSystemMessage(SystemMessage.SystemMessageId.InappropriateEnchantCondition);
                    player.SendActionFailedAsync();
                    return;
                }

                ItemEnchantManager.GetInstance().TryPutItem(player, item);
            });
        }
        public override void run()
        {
            L2Player player = Client.CurrentPlayer;

            if (player.EnchantState != ItemEnchantManager.STATE_PUT_ITEM)
            {
                player.sendSystemMessage(355);//Inappropriate enchant conditions.
                player.sendActionFailed();
                return;
            }

            L2Item item = player.Inventory.getByObject(a_sTargetID);

            if (item == null)
            {
                player.sendSystemMessage(355);//Inappropriate enchant conditions.
                player.sendActionFailed();
                return;
            }

            ItemEnchantManager.getInstance().tryPutItem(player, item);
        }
Example #4
0
        public override void run()
        {
            L2Player player = Client.CurrentPlayer;

            if (player.EnchantState != ItemEnchantManager.STATE_ENCHANT_START || player.EnchantItem.ObjID != a_sTargetID)
            {
                player.sendSystemMessage(2387);//Registration of the support enhancement spellbook has failed.
                player.sendActionFailed();
                return;
            }

            L2Item stone = player.Inventory.getByObject(a_sSupportID);

            if (stone == null)
            {
                player.sendSystemMessage(2387);//Registration of the support enhancement spellbook has failed.
                player.sendActionFailed();
                return;
            }

            ItemEnchantManager.getInstance().tryPutStone(player, stone);
        }
Example #5
0
        public override void RunImpl()
        {
            L2Player player = _client.CurrentPlayer;

            if (player.EnchantState != ItemEnchantManager.StateEnchantStart)
            {
                player.SendSystemMessage(SystemMessage.SystemMessageId.InappropriateEnchantCondition);
                player.SendActionFailed();
                return;
            }

            if (_aSTargetId != player.EnchantItem.ObjId)
            {
                player.SendSystemMessage(SystemMessage.SystemMessageId.InappropriateEnchantCondition);
                player.SendActionFailed();
                return;
            }

            short rate = 50;

            if (player.EnchantStone != null)
            {
                EnchantScroll stone = ItemEnchantManager.GetInstance().GetSupport(player.EnchantStone.Template.ItemId);
                rate += stone.Bonus;
            }

            if (player.EnchantItem.Enchant < 4)
            {
                rate = 100;
            }

            if (rate > 100)
            {
                rate = 100;
            }

            InventoryUpdate iu    = null;
            bool            equip = false;

            if ((rate == 100) || (new Random().Next(100) < rate))
            {
                player.EnchantItem.Enchant += 1;
                //player.EnchantItem.sql_update();

                iu = new InventoryUpdate();
                iu.AddModItem(player.EnchantItem);

                player.SendPacket(new EnchantResult(EnchantResultVal.Success));

                equip = player.EnchantItem.IsEquipped == 1;

                //if (equip && (player.EnchantItem.Enchant == 4) && (player.EnchantItem.Template.ItemSkillEnch4 != null))
                //{
                //    player.AddSkill(player.EnchantItem.Template.ItemSkillEnch4, false, false);
                //    player.UpdateSkillList();
                //}
                //todo check +6 set
            }
            else
            {
                EnchantScroll scr = ItemEnchantManager.GetInstance().GetScroll(player.EnchantScroll.Template.ItemId);
                switch (scr.Type)
                {
                case EnchantType.Blessed:
                    player.EnchantItem.Enchant = 0;
                    //player.EnchantItem.sql_update();

                    iu = new InventoryUpdate();
                    iu.AddModItem(player.EnchantItem);

                    player.SendPacket(new EnchantResult(EnchantResultVal.BreakToOne));
                    break;

                case EnchantType.Ancient:
                    player.SendPacket(new EnchantResult(EnchantResultVal.SafeBreak));
                    break;

                default:
                {
                    if (player.EnchantItem.IsEquipped == 1)
                    {
                        //int pdollId = player.Inventory.getPaperdollId(player.EnchantItem.Template);
                        // player.setPaperdoll(pdollId, null, false);
                        equip = true;
                    }

                    iu = new InventoryUpdate();
                    iu.AddDelItem(player.EnchantItem);

                    //int id = player.EnchantItem.Template.CrystalType.CrystalId;
                    //player.SendPacket(new EnchantResult(EnchantResultVal.BreakToCount, id, cry));
                    //player.AddItem(id, cry);
                }
                break;
                }
            }

            if (player.EnchantStone != null)
            {
                player.DestroyItem(player.EnchantStone, 1);
            }

            player.DestroyItem(player.EnchantScroll, 1);

            if (iu != null)
            {
                player.SendPacket(iu);
            }

            player.EnchantItem   = null;
            player.EnchantScroll = null;
            player.EnchantStone  = null;
            player.EnchantState  = 0;

            if (equip)
            {
                player.BroadcastUserInfo();
            }
        }
Example #6
0
 public EnchantScrolls()
 {
     Ids = ItemEnchantManager.GetInstance().GetIds();
 }
Example #7
0
        public override void run()
        {
            L2Player player = Client.CurrentPlayer;

            if (player.EnchantState != ItemEnchantManager.STATE_ENCHANT_START)
            {
                player.sendSystemMessage(355);//Inappropriate enchant conditions.
                player.sendActionFailed();
                return;
            }

            if (a_sTargetID != player.EnchantItem.ObjID)
            {
                player.sendSystemMessage(355);//Inappropriate enchant conditions.
                player.sendActionFailed();
                return;
            }

            short rate = 50;

            if (player.EnchantStone != null)
            {
                EnchantScroll stone = ItemEnchantManager.getInstance().getSupport(player.EnchantStone.Template.ItemID);
                rate += stone.bonus;
            }

            if (player.EnchantItem.Enchant < 4)
            {
                rate = 100;
            }

            if (rate > 100)
            {
                rate = 100;
            }

            InventoryUpdate iu    = null;
            bool            equip = false;

            if (rate == 100 ? true : new Random().Next(100) < rate)
            {
                player.EnchantItem.Enchant += 1;
                player.EnchantItem.sql_update();

                iu = new InventoryUpdate();
                iu.addModItem(player.EnchantItem);

                player.sendPacket(new EnchantResult(EnchantResultVal.success));

                equip = player.EnchantItem._isEquipped == 1;

                if (equip && player.EnchantItem.Enchant == 4 && player.EnchantItem.Template.item_skill_ench4 != null)
                {
                    player.addSkill(player.EnchantItem.Template.item_skill_ench4, false, false);
                    player.updateSkillList();
                }
                //todo check +6 set
            }
            else
            {
                EnchantScroll scr = ItemEnchantManager.getInstance().getScroll(player.EnchantScroll.Template.ItemID);
                switch (scr.Type)
                {
                case EnchantType.blessed:
                    player.EnchantItem.Enchant = 0;
                    player.EnchantItem.sql_update();

                    iu = new InventoryUpdate();
                    iu.addModItem(player.EnchantItem);

                    player.sendPacket(new EnchantResult(EnchantResultVal.breakToOne));
                    break;

                case EnchantType.ancient:
                    player.sendPacket(new EnchantResult(EnchantResultVal.safeBreak));
                    break;

                default:
                {
                    if (player.EnchantItem._isEquipped == 1)
                    {
                        int pdollId = player.Inventory.getPaperdollId(player.EnchantItem.Template);
                        player.setPaperdoll(pdollId, null, false);
                        equip = true;
                    }

                    player.Inventory.removeItem(player.EnchantItem);
                    iu = new InventoryUpdate();
                    iu.addDelItem(player.EnchantItem);

                    long cry = player.EnchantItem.Template._cryCount;

                    if (cry == 0)
                    {
                        player.sendPacket(new EnchantResult(EnchantResultVal.breakToNothing));
                    }
                    else
                    {
                        int id = player.EnchantItem.Template.getCrystallId();
                        player.sendPacket(new EnchantResult(EnchantResultVal.breakToCount, id, cry));
                        player.Inventory.addItem(id, cry, true, true);
                    }
                }
                break;
                }
            }

            if (player.EnchantStone != null)
            {
                player.Inventory.destroyItem(player.EnchantStone, 1, true, true);
            }

            player.Inventory.destroyItem(player.EnchantScroll, 1, false, true);

            if (iu != null)
            {
                player.sendPacket(iu);
            }

            player.EnchantItem   = null;
            player.EnchantScroll = null;
            player.EnchantStone  = null;
            player.EnchantState  = 0;

            if (equip)
            {
                player.broadcastUserInfo();
            }
        }