Example #1
0
 public override void Link(ARKDinoDataObject[] data)
 {
     if (isLocalLink)
     {
         localLinkObject = data[localLinkIndex];
     }
 }
        private static float[] ConvertStatsFloat(ARKDinoDataObject c, string name)
        {
            float[] s     = new float[15];
            var     props = c.GetPropertiesByName(name);

            foreach (var p in props)
            {
                int   index = p.index;
                float data;
                if (p.GetType() == typeof(FloatProperty))
                {
                    data = ((FloatProperty)p).value;
                }
                else
                {
                    throw new Exception("Unexpected type for converting stats!");
                }
                if (index > s.Length)
                {
                    throw new Exception("Unexpected index for converting stats!");
                }
                s[index] = data;
            }
            return(s);
        }
        private static string ConvertStatus(ARKDinoDataObject d)
        {
            string status = "YOUR_TARGET";

            if (d.HasProperty("TamedAggressionLevel"))
            {
                int agroLevel = d.GetIntProperty("TamedAggressionLevel");
                switch (agroLevel)
                {
                case 0:
                    status = "PASSIVE";
                    break;

                case 1:
                    status = "NEUTRAL";
                    break;

                case 2:
                    status = "AGGRESSIVE";
                    break;
                }
                if (d.GetBoolProperty("bPassiveFlee", 0, false))
                {
                    status = "PASSIVE_FLEE";
                }
            }
            return(status);
        }
Example #4
0
        public static ARKDinoDataObject[] ReadData(byte[] content)
        {
            //Open stream
            IOMemoryStream stream = new IOMemoryStream(new System.IO.MemoryStream(content), true);

            //Read number of values
            int objectCount = stream.ReadInt();

            //Read object headers
            ARKDinoDataObject[] objects = new ARKDinoDataObject[objectCount];
            for (int i = 0; i < objectCount; i++)
            {
                objects[i] = ARKDinoDataObject.ReadFromFile(stream);
            }

            //Now, read payloads for all of these objects
            foreach (ARKDinoDataObject o in objects)
            {
                stream.position = o.payloadStart;
                o.properties    = new List <BaseProperty>();
                BaseProperty prop = BaseProperty.ReadProperty(stream);
                while (prop != null)
                {
                    o.properties.Add(prop);
                    prop = BaseProperty.ReadProperty(stream);
                }
            }

            //Now, link all of the properties
            foreach (ARKDinoDataObject o in objects)
            {
                foreach (BaseProperty prop in o.properties)
                {
                    prop.Link(objects);
                }
            }

            return(objects);
        }
        private static DbDino ParseDinoData(DbServer server, string inventoryId, ulong revisionId, byte revisionIndex, int inventoryType, ulong inventoryItemId, string request)
        {
            //Decode data as bytes and read
            byte[] data = new byte[request.Length / 2];
            for (int index = 0; index < data.Length; index++)
            {
                data[index] = byte.Parse(request.Substring(index * 2, 2), System.Globalization.NumberStyles.HexNumber);
            }

            //Now, decode and parse
            ARKDinoDataObject[] parts = ARKDinoDataTool.ReadData(data);
            Console.WriteLine(JsonConvert.SerializeObject(parts));

            //Get dino part
            ARKDinoDataObject d = parts[0];

            //Convert colors
            List <string> colors = new List <string>();

            for (int i = 0; true; i++)
            {
                ByteProperty colorProp = d.GetPropertyByName <ByteProperty>("ColorSetIndices", i);
                if (colorProp == null)
                {
                    break;
                }
                byte color = colorProp.byteValue;
                if (color <= 0 || color > ArkStatics.ARK_COLOR_IDS.Length)
                {
                    colors.Add("#FFFFFF");
                }
                else
                {
                    colors.Add(ArkStatics.ARK_COLOR_IDS[colorProp.byteValue - 1]); //Look this up in the color table to get the nice HTML value.
                }
            }

            //Get status component
            ARKDinoDataObject status = d.GetPropertyByName <ObjectProperty>("MyCharacterStatusComponent").localLinkObject;

            //Read as dino, adding required fields first
            DbDino dino = new DbDino
            {
                revision_id            = revisionId,
                revision_type          = revisionIndex,
                is_cryo                = true,
                cryo_inventory_id      = inventoryId,
                dino_id                = Program.GetMultipartID(d.GetPropertyByName <UInt32Property>("DinoID1").value, d.GetPropertyByName <UInt32Property>("DinoID2").value),
                tribe_id               = d.GetPropertyByName <IntProperty>("TargetingTeam").value,
                tamed_name             = d.GetStringProperty("TamedName", 0, ""),
                classname              = Program.TrimArkClassname(d.name),
                tamer_name             = d.GetStringProperty("TamerString", 0, ""),
                baby_age               = d.GetFloatProperty("BabyAge", 0, 1),
                is_baby                = d.GetBoolProperty("bIsBaby", 0, false),
                next_imprint_time      = d.GetDoubleProperty("BabyNextCuddleTime", 0, 0),
                imprint_quality        = d.GetFloatProperty("DinoImprintingQuality", 0, 0),
                color_indexes          = new int[6],
                experience             = status.GetFloatProperty("ExperiencePoints", 0, 0),
                server_id              = server._id,
                location               = new DbLocation(0, 0, 0),
                is_female              = d.GetBoolProperty("bIsFemale", 0, false),
                level                  = status.GetIntProperty("BaseCharacterLevel", 0, 0) + status.GetUInt16Property("ExtraCharacterLevel", 0, 0),
                base_level             = status.GetIntProperty("BaseCharacterLevel", 0, 0),
                is_tamed               = true,
                taming_effectiveness   = 1,
                max_stats              = ConvertStatsFloat(status, "MaxStatusValues"),
                current_stats          = ConvertStatsFloat(status, "CurrentStatusValues"),
                tamed_levelups_applied = ConvertStatsInt(status, "NumberOfLevelUpPointsAppliedTamed"),
                base_levelups_applied  = ConvertStatsInt(status, "NumberOfLevelUpPointsApplied"),
                status                 = ConvertStatus(d),
                cryo_inventory_type    = inventoryType,
                cryo_inventory_itemid  = inventoryItemId,
                experience_points      = status.GetFloatProperty("ExperiencePoints", 0, 0)
            };

            return(dino);
        }