public ArkPlayer(ArkWorld world, DotArkGameObject orig) : base(world, orig) { playerName = GetStringProperty("PlayerName"); steamName = GetStringProperty("PlatformProfileName"); arkId = GetUInt64Property("LinkedPlayerDataID"); //Read the struct containing Steam ID StructProperty sprop = (StructProperty)GetSingleProperty("PlatformProfileID"); ArkStructUniqueNetId nsprop = (ArkStructUniqueNetId)sprop.structData; steamId = nsprop.netId; //Tribe stuff if (HasProperty("TribeName")) { tribeName = GetStringProperty("TribeName"); tribeId = GetInt32Property("TargetingTeam"); isInTribe = true; } else { tribeName = "No Tribe"; tribeId = -1; isInTribe = false; } //Check if alive try { HighLevelArkGameObjectRef statusComponent = GetGameObjectRef("MyCharacterStatusComponent"); currentStats = ArkDinosaurStats.ReadStats(statusComponent, "CurrentStatusValues", false); isAlive = currentStats.health > 0.1f; } catch { isAlive = false; } }
public ArkDinosaur(ArkWorld world, DotArkGameObject orig) : base(world, orig) { //Grab the data and save it here. //Get the other components of this dinosaur. HighLevelArkGameObjectRef statusComponent = GetGameObjectRef("MyCharacterStatusComponent"); //Check if this dinosaur is tamed. isTamed = CheckIfValueExists("TamedName") && CheckIfValueExists("TribeName") && CheckIfValueExists("TargetingTeam"); //Grab the values that will exist on both tamed and untamed dinosaurs. isFemale = GetBooleanProperty("bIsFemale"); //Convert the colors into a byte array and hex. var colorAttrib = GetPropertiesByName("ColorSetIndices"); //Get all of the color properties from the dinosaur. These are indexes in the color table. colors = new byte[colorAttrib.Length]; //Initialize the array for storing the indexes. These will be saved to the file. colors_hex = new string[colorAttrib.Length]; //Initialize the array for reading nice HTML color values. for (int i = 0; i < colors.Length; i++) //For each color region this dinosaur has. Each "ColorSetIndices" value is a color region. { colors[i] = ((ByteProperty)colorAttrib[i]).byteValue; //Get the index in the color table by getting the byte value out of the property //Validate that the color is in range byte color = colors[i]; if (color <= 0 || color > ArkColorIds.ARK_COLOR_IDS.Length) { colors_hex[i] = "#FFF"; } else { colors_hex[i] = ArkColorIds.ARK_COLOR_IDS[colors[i] - 1]; //Look this up in the color table to get the nice HTML value. } } //Read the dinosaur ID by combining the the bytes of the two UInt32 values. byte[] buf = new byte[8]; BitConverter.GetBytes(GetUInt32Property("DinoID1")).CopyTo(buf, 0); BitConverter.GetBytes(GetUInt32Property("DinoID2")).CopyTo(buf, 4); //Convert this to a ulong dinosaurId = BitConverter.ToUInt64(buf, 0); //Read in levels currentStats = ArkDinosaurStats.ReadStats(statusComponent, "CurrentStatusValues", false); baseLevelupsApplied = ArkDinosaurStats.ReadStats(statusComponent, "NumberOfLevelUpPointsApplied", true); baseLevel = 1; if (statusComponent.CheckIfValueExists("BaseCharacterLevel")) { baseLevel = statusComponent.GetInt32Property("BaseCharacterLevel"); } level = baseLevel; //Now, convert attributes that only exist on tamed dinosaurs. isInTribe = isTamed; if (isTamed) { tamedName = GetStringProperty("TamedName"); tribeId = GetInt32Property("TargetingTeam"); tamerName = GetStringProperty("TribeName"); tamedLevelupsApplied = ArkDinosaurStats.ReadStats(statusComponent, "NumberOfLevelUpPointsAppliedTamed", true); if (statusComponent.CheckIfValueExists("ExtraCharacterLevel")) { level += statusComponent.GetUInt16Property("ExtraCharacterLevel"); } if (statusComponent.HasProperty("ExperiencePoints")) { experience = statusComponent.GetFloatProperty("ExperiencePoints"); } else { experience = 0; } isBaby = GetBooleanProperty("bIsBaby"); if (isBaby) { babyAge = GetFloatProperty("BabyAge"); nextImprintTime = -1; if (HasProperty("BabyNextCuddleTime")) { nextImprintTime = GetDoubleProperty("BabyNextCuddleTime"); } if (statusComponent.HasProperty("DinoImprintingQuality")) { imprintQuality = statusComponent.GetFloatProperty("DinoImprintingQuality"); } else { imprintQuality = 0; } } } //Get the dino entry data dino_entry = ArkImports.GetDinoDataByClassname(classname.classname); isInit = true; }
/// <summary> /// Generate this data from a GameObject's properties. /// </summary> /// <param name="gameobject"></param> /// <param name="propertyName"></param> /// <returns></returns> public static ArkDinosaurStats ReadStats(HighLevelArkGameObjectRef gameobject, string propertyName, bool isByteProp) { ArkDinosaurStats s = new ArkDinosaurStats(); //Read each property name and loop through them. var props = gameobject.GetPropertiesByName(propertyName); foreach (var p in props) { int index = p.index; float data; if (isByteProp) { data = (float)(((ByteProperty)p).byteValue); } else { data = (float)p.data; } switch (index) { case 0: s.health = data; break; case 1: s.stamina = data; break; case 2: s.unknown1 = data; break; case 3: s.oxygen = data; break; case 4: s.food = data; break; case 5: s.water = data; break; case 6: s.unknown2 = data; break; case 7: s.inventoryWeight = data; break; case 8: s.meleeDamageMult = data; break; case 9: s.movementSpeedMult = data; break; case 10: s.unknown2 = data; break; case 11: s.unknown4 = data; break; default: //We shouldn't be here... throw new Exception($"Unknown index ID while reading Dinosaur stats {index}!"); } } return(s); }