コード例 #1
0
        /// <summary>
        /// </summary>
        /// <param name="client">
        /// </param>
        /// <param name="container">
        /// </param>
        /// <param name="placement">
        /// </param>
        public static void TradeSkillTargetChanged(ZoneClient client, int container, int placement)
        {
            if ((container != 0) && (placement != 0))
            {
                client.Character.TradeSkillTarget = new TradeSkillInfo(0, container, placement);

                Item item = client.Character.BaseInventory.GetItemInContainer(container, placement);
                TradeSkillPacket.SendTarget(client.Character, TradeSkill.Instance.TargetProcessesCount(item.HighID));

                TradeSkillChanged(client);
            }
            else
            {
                client.Character.TradeSkillTarget = null;
            }
        }
コード例 #2
0
        /// <summary>
        /// </summary>
        /// <param name="client">
        /// </param>
        private static void TradeSkillChanged(IZoneClient client)
        {
            TradeSkillInfo source = client.Controller.Character.TradeSkillSource;
            TradeSkillInfo target = client.Controller.Character.TradeSkillTarget;

            if ((source != null) && (target != null))
            {
                Item sourceItem = client.Controller.Character.BaseInventory.GetItemInContainer(
                    source.Container,
                    source.Placement);
                Item targetItem = client.Controller.Character.BaseInventory.GetItemInContainer(
                    target.Container,
                    target.Placement);

                TradeSkillEntry ts = TradeSkill.Instance.GetTradeSkillEntry(sourceItem.HighID, targetItem.HighID);
                if (ts != null)
                {
                    if (ts.ValidateRange(sourceItem.Quality, targetItem.Quality))
                    {
                        foreach (TradeSkillSkill tsi in ts.Skills)
                        {
                            int skillReq = (int)Math.Ceiling(tsi.Percent / 100M * targetItem.Quality);
                            if (skillReq > client.Controller.Character.Stats[tsi.StatId].Value)
                            {
                                TradeSkillPacket.SendRequirement(client.Controller.Character, tsi.StatId, skillReq);
                            }
                        }

                        int leastbump = 0;
                        int maxbump   = 0;
                        if (ts.IsImplant)
                        {
                            if (targetItem.Quality >= 250)
                            {
                                maxbump = 5;
                            }
                            else if (targetItem.Quality >= 201)
                            {
                                maxbump = 4;
                            }
                            else if (targetItem.Quality >= 150)
                            {
                                maxbump = 3;
                            }
                            else if (targetItem.Quality >= 100)
                            {
                                maxbump = 2;
                            }
                            else if (targetItem.Quality >= 50)
                            {
                                maxbump = 1;
                            }
                        }

                        foreach (TradeSkillSkill tsSkill in ts.Skills)
                        {
                            if (tsSkill.SkillPerBump != 0)
                            {
                                leastbump =
                                    Math.Min(
                                        Convert.ToInt32(
                                            (client.Controller.Character.Stats[tsSkill.StatId].Value
                                             - (tsSkill.Percent / 100M * targetItem.Quality)) / tsSkill.SkillPerBump),
                                        maxbump);
                            }
                        }

                        TradeSkillPacket.SendResult(
                            client.Controller.Character,
                            targetItem.Quality,
                            Math.Min(targetItem.Quality + leastbump, ItemLoader.ItemList[ts.ResultHighId].Quality),
                            ts.ResultLowId,
                            ts.ResultHighId);
                    }
                    else
                    {
                        TradeSkillPacket.SendOutOfRange(
                            client.Controller.Character,
                            Convert.ToInt32(
                                Math.Round((double)targetItem.Quality - ts.QLRangePercent * targetItem.Quality / 100)));
                    }
                }
                else
                {
                    TradeSkillPacket.SendNotTradeskill(client.Controller.Character);
                }
            }
        }