示例#1
0
        public static void CreateItem(uint def_index, uint quality,
            uint rarity, uint level, List<ItemAttribute> attribs, Stream file, ItemData dataHeader)
        {
            CSGOItemProto econItem = new CSGOItemProto();

            econItem.id = 0;
            econItem.inventory = 0;
            econItem.def_index = def_index;
            econItem.level = level;
            econItem.rarity = rarity;
            econItem.quality = quality;
            econItem.flags = 0;
            econItem.origin = 0;

            econItem.attribute = new List<CSOEconItemAttribute>();

            foreach (var attrib in attribs)
            {
                CSOEconItemAttribute itemAttribute = new CSOEconItemAttribute();

                itemAttribute.def_index = attrib.Id;
                itemAttribute.value_bytes = BitConverter.GetBytes(attrib.ValueByte);

                econItem.attribute.Add(itemAttribute);
            }

            dataHeader.Type = 1;
            dataHeader.Length = CalcProtoBufSize(econItem);

            Write(file, dataHeader);

            Serializer.Serialize<CSGOItemProto>(file, econItem);
        }
        internal void AddNewItem(CSGOItemProto itemProto, Dictionary<AttributeInfo, CSOEconItemAttribute> attributeAndValue)
        {
            CSGOItemProto econItem = new CSGOItemProto();

            econItem = itemProto;

            foreach (var attrib in attributeAndValue)
            {
                econItem.attribute.Add(attrib.Value);
            }

            ItemData dataHeader = new ItemData();

            dataHeader.Type = 1;
            dataHeader.Length = CalcProtoBufSize(econItem);

            _itemList.Add(new Tuple<ItemData, CSGOItemProto>(dataHeader, econItem));
        }
 /// <summary>
 ///     Verify read dataheader
 /// </summary>
 /// <param name="dataHeader" type="ItemEditor.ItemData">
 ///     <para>
 ///         A ItemData struct to be verified
 ///     </para>
 /// </param>
 /// <returns>
 ///     True if it's valid, false otherwise
 /// </returns>
 private bool IsDataHeaderValid(ItemData dataHeader)
 {
     if (dataHeader.Type != 1)
     {
         return false;
     }
     else
     {
         return true;
     }
 }
示例#4
0
        public static void WriteDefaultValues()
        {
            SSEHeader header = new SSEHeader();
            ItemData dataHeader = new ItemData();

            header.FileHeader = "SSEItem";
            header.ItemCount = 4;

            List<ItemAttribute> attribsWeapon1 = new List<ItemAttribute>();

            ItemAttribute attribWeapon1 = new ItemAttribute();

            attribWeapon1.Id = 6;
            attribWeapon1.ValueByte = 266.0f;

            attribsWeapon1.Add(attribWeapon1);

            attribWeapon1 = new ItemAttribute();

            attribWeapon1.Id = 80;
            attribWeapon1.ValueByte = 0;

            attribsWeapon1.Add(attribWeapon1);

            attribWeapon1 = new ItemAttribute();

            attribWeapon1.Id = 81;
            attribWeapon1.ValueByte = 0;

            attribsWeapon1.Add(attribWeapon1);

            List<ItemAttribute> attribsWeapon2 = new List<ItemAttribute>();

            ItemAttribute attribWeapon2 = new ItemAttribute();

            attribWeapon2.Id = 6;
            attribWeapon2.ValueByte = BitConverter.ToSingle(new byte[] { 0x00, 0x00, 0x16, 0x42 }, 0);

            attribsWeapon2.Add(attribWeapon2);

            attribWeapon2 = new ItemAttribute();

            attribWeapon2.Id = 80;
            attribWeapon2.ValueByte = 0;

            attribsWeapon2.Add(attribWeapon2);

            attribWeapon2 = new ItemAttribute();

            attribWeapon2.Id = 82;
            attribWeapon2.ValueByte = 0;

            attribsWeapon2.Add(attribWeapon2);

            List<ItemAttribute> attribsMusic = new List<ItemAttribute>();

            ItemAttribute attribMusic = new ItemAttribute();

            attribMusic.Id = 113;
            attribMusic.ValueByte = 5;

            attribsMusic.Add(attribMusic);

            List<ItemAttribute> attribsSticker = new List<ItemAttribute>();

            ItemAttribute attribSticker = new ItemAttribute();

            attribSticker.Id = 166;
            attribSticker.ValueByte = 3;

            attribsSticker.Add(attribSticker);

            using (Stream stream = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.ReadWrite))
            {
                // id, inventory, quality, rarity, level, def_index, {attrs}
                Write(stream, header);
                // weapons 0 0 4 2 1 4 6=00008543 80=00000000 81=00000000
                CreateItem(4, 4, 2, 1, attribsWeapon1, stream, dataHeader);

                // weapon 0 0 4 2 1 16 6=00001642 80=00000000 81=00000000
                CreateItem(16, 4, 2, 1, attribsWeapon2, stream, dataHeader);

                // sticker 0 0 0 0 0 1209 113=02000000
                CreateItem(1209, 0, 0, 0, attribsMusic, stream, dataHeader);

                // music kit 0 0 0 0 0 1314 166=03000000
                CreateItem(1314, 0, 0, 0, attribsSticker, stream, dataHeader);
            }
        }
        /// <summary>
        ///     Add new item into items_730.bin
        /// </summary>
        /// <param name="itemType" type="KvFileReader.ItemInfo">
        ///     <para>
        ///         Type of item to be added
        ///     </para>
        /// </param>
        /// <param name="quality" type="KvFileReader.QualityInfo">
        ///     <para>
        ///         Quality of the item
        ///     </para>
        /// </param>
        /// <param name="rarity" type="KvFileReader.RarityInfo">
        ///     <para>
        ///         Rarity of the item
        ///     </para>
        /// </param>
        /// <param name="level" type="int">
        ///     <para>
        ///         Level of the item
        ///     </para>
        /// </param>
        /// <param name="attributeAndValue" type="System.Collections.Generic.Dictionary<KvFileReader.AttributeInfo,dynamic>">
        ///     <para>
        ///         Dictionary of item's attributes and their values
        ///     </para>
        /// </param>
        internal void AddNewItem(int codedValueItemType, int codedValueQuality,
            int codedValueRarity, int level, string customName, Dictionary<AttributeInfo, CSOEconItemAttribute> attributeAndValue)
        {
            CSGOItemProto econItem = new CSGOItemProto();

            //NOTE: must be filled with 0 as SSE will fill it later
            econItem.id = 0;
            econItem.inventory = 0;
            econItem.flags = 0;
            econItem.origin = 0;

            econItem.custom_name = customName;
            econItem.def_index = codedValueItemType;
            econItem.level = level;
            econItem.rarity = codedValueRarity;
            econItem.quality = codedValueQuality;

            foreach (var attrib in attributeAndValue)
            {
                econItem.attribute.Add(attrib.Value);
            }

            ItemData dataHeader = new ItemData();

            dataHeader.Type = 1;
            dataHeader.Length = CalcProtoBufSize(econItem);

            _itemList.Add(new Tuple<ItemData, CSGOItemProto>(dataHeader, econItem));
        }