Beispiel #1
0
        public static void Rewards(uint CID)
        {
            Character character;

            if (LifeCycle.TryGetById(CID, out character))
            {
                SMSG_EVENTINFO2 spkt = new SMSG_EVENTINFO2();
                foreach (EventItem rewardItem in Singleton.Database.FindEventItemList(character))
                {
                    spkt.AddItem(rewardItem.EventId, rewardItem.ItemId, rewardItem.ItemCount);
                }
                spkt.SessionId = character.id;
                character.client.Send((byte[])spkt);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Occurs when selecting a event reward
        /// </summary>
        /// <param name="cpkt"></param>
        private void CM_EVENTRECIEVEITEM(CMSG_RECEIVEEVENTITEM cpkt)
        {
            SMSG_EVENTINFO2 spkt = new SMSG_EVENTINFO2();

            spkt.Result = 1;

            try
            {
                Rag2Item  item;
                EventItem b = Singleton.Database.FindEventItemById(this.character, cpkt.RewardId);
                if (b.ItemId == 0)
                {
                    //Event reward not found
                    spkt.Result = 1;
                }
                else if (b.ItemCount == 0)
                {
                    //Event reward not found
                    spkt.Result = 1;
                }
                else if (this.character.container.Count == this.character.container.Capacity)
                {
                    //Full storage
                    spkt.Result = 1;
                }
                else if (!Singleton.Item.TryGetItemWithCount(b.ItemId, b.ItemCount, out item))
                {
                    //Item id not found
                    spkt.Result = 1;
                }
                else
                {
                    Singleton.Database.DeleteEventItemId(cpkt.RewardId);

                    //AMOUNT USED IN DECREMENT CALCULATIONS
                    int index = this.character.container.FindFirstFreeIndex();

                    if (index > -1)
                    {
                        this.character.container[index] = item;
                        SMSG_ADDITEM spkt2 = new SMSG_ADDITEM();
                        spkt2.Container    = 2;
                        spkt2.UpdateReason = (byte)ItemUpdateReason.EventReceived;
                        spkt2.SetItem(item, index);
                        spkt2.SessionId = this.character.id;
                        this.Send((byte[])spkt2);


                        //Type is used to calc type of item
                        //(21 seems to be used for Applogy Item)
                        if (item.info.type == 21)
                        {
                            Common.Skills.UpdateAddition(this.character, item.info.option_id);
                        }
                    }

                    spkt.Result = 0;
                }

                foreach (EventItem rewardItem in Singleton.Database.FindEventItemList(character))
                {
                    spkt.AddItem(rewardItem.EventId, rewardItem.ItemId, rewardItem.ItemCount);
                }
            }
            catch (Exception e)
            {
                Trace.TraceError(e.ToString());
            }
            finally
            {
                spkt.SessionId = character.id;
                this.Send((byte[])spkt);
            }
        }