Exemple #1
0
        protected override void ReadEntry(JObject entry)
        {
            entry.AssertNotMissing("id", "name", "group", "tags", "gender", "vehicleType", "runSpeedFactor", "state", "invWidth", "invHeight", "range", "attackSpeed", "knockCount", "splashRadius", "splashAngle", "splashDamage", "stand", "ai", "color1", "color2", "color3", "cp", "life");

            var raceData = new RaceData();

            raceData.Id               = entry.ReadInt("id");
            raceData.Name             = entry.ReadString("name");
            raceData.Group            = entry.ReadString("group");
            raceData.Tags             = entry.ReadString("tags");
            raceData.Gender           = (Gender)entry.ReadByte("gender");
            raceData.VehicleType      = entry.ReadInt("vehicleType");
            raceData.RunSpeedFactor   = entry.ReadFloat("runSpeedFactor");
            raceData.DefaultState     = entry.ReadUInt("state");
            raceData.InventoryWidth   = entry.ReadInt("invWidth");
            raceData.InventoryHeight  = entry.ReadInt("invHeight");
            raceData.AttackSkill      = 23002;        // Combat Mastery, they all use this anyway.
            raceData.AttackMinBase    = entry.ReadInt("attackMinBase");
            raceData.AttackMaxBase    = entry.ReadInt("attackMaxBase");
            raceData.AttackMinBaseMod = entry.ReadInt("attackMinBaseMod");
            raceData.AttackMaxBaseMod = entry.ReadInt("attackMaxBaseMod");
            raceData.InjuryMinBase    = entry.ReadInt("injuryMinBase");
            raceData.InjuryMaxBase    = entry.ReadInt("injuryMaxBase");
            raceData.InjuryMinBaseMod = entry.ReadInt("injuryMinBaseMod");
            raceData.InjuryMaxBaseMod = entry.ReadInt("injuryMaxBaseMod");
            raceData.AttackRange      = entry.ReadInt("range");
            raceData.AttackSpeed      = entry.ReadInt("attackSpeed");
            raceData.KnockCount       = entry.ReadInt("knockCount");
            raceData.CriticalBase     = entry.ReadInt("criticalBase");
            raceData.CriticalBaseMod  = entry.ReadInt("criticalBaseMod");
            raceData.BalanceBase      = entry.ReadInt("balanceBase");
            raceData.BalanceBaseMod   = entry.ReadInt("balanceBaseMod");
            raceData.SplashRadius     = entry.ReadInt("splashRadius");
            raceData.SplashAngle      = entry.ReadInt("splashAngle");
            raceData.SplashDamage     = entry.ReadFloat("splashDamage");
            raceData.Stand            = (RaceStands)entry.ReadInt("stand");
            raceData.SharpMindImmune  = entry.ReadBool("sharpMindImmune");
            raceData.AI               = entry.ReadString("ai");

            // Looks
            raceData.Color1 = entry.ReadUInt("color1");
            raceData.Color2 = entry.ReadUInt("color2");
            raceData.Color3 = entry.ReadUInt("color3");

            if (!entry.ContainsAnyKeys("size", "sizeMin", "sizeMax"))
            {
                raceData.SizeMin = raceData.SizeMax = 1;
            }
            else if (entry.ContainsKey("size"))
            {
                raceData.SizeMin = raceData.SizeMax = entry.ReadFloat("size");
            }
            else
            {
                raceData.SizeMin = entry.ReadFloat("sizeMin", 1);
                raceData.SizeMax = entry.ReadFloat("sizeMax", 1);
            }

            if (raceData.SizeMin > raceData.SizeMax)
            {
                raceData.SizeMax = raceData.SizeMin;
            }

            // Face
            Action <string, JObject, List <int> > readArrOrIntCol = (col, obj, list) =>
            {
                if (obj[col] != null)
                {
                    if (obj[col].Type == JTokenType.Integer)
                    {
                        list.Add(obj.ReadInt(col));
                    }
                    else if (obj[col].Type == JTokenType.Array)
                    {
                        list.AddRange(obj[col].Select(id => (int)id));
                    }
                }
            };

            readArrOrIntCol("eyeColor", entry, raceData.Face.EyeColors);
            readArrOrIntCol("eyeType", entry, raceData.Face.EyeTypes);
            readArrOrIntCol("mouthType", entry, raceData.Face.MouthTypes);
            readArrOrIntCol("skinColor", entry, raceData.Face.SkinColors);

            // Stat Info
            raceData.Level = entry.ReadInt("level");
            raceData.Str   = entry.ReadFloat("str");
            raceData.Int   = entry.ReadFloat("int");
            raceData.Dex   = entry.ReadFloat("dex");
            raceData.Will  = entry.ReadFloat("will");
            raceData.Luck  = entry.ReadFloat("luck");

            raceData.CombatPower      = entry.ReadFloat("cp");
            raceData.Life             = entry.ReadFloat("life");
            raceData.Mana             = entry.ReadFloat("mana");
            raceData.Stamina          = entry.ReadFloat("stamina");
            raceData.LifeRecoveryRate = entry.ReadFloat("lifeRecoveryRate", 1);
            raceData.Defense          = entry.ReadInt("defense");
            raceData.Protection       = (int)entry.ReadFloat("protection");
            raceData.ElementPhysical  = entry.ReadInt("elementPhysical");
            raceData.ElementLightning = entry.ReadInt("elementLightning");
            raceData.ElementFire      = entry.ReadInt("elementFire");
            raceData.ElementIce       = entry.ReadInt("elementIce");
            raceData.Exp     = entry.ReadInt("exp");
            raceData.GoldMin = entry.ReadInt("goldMin");
            raceData.GoldMax = entry.ReadInt("goldMax");

            // Drops
            if (entry.ContainsKeys("drops"))
            {
                foreach (JObject drop in entry["drops"].Where(a => a.Type == JTokenType.Object))
                {
                    drop.AssertNotMissing("itemId", "chance");

                    var dropData = new DropData();
                    dropData.ItemId = drop.ReadInt("itemId");
                    dropData.Chance = drop.ReadFloat("chance");
                    var amount = drop.ReadInt("amount");
                    dropData.AmountMin = drop.ReadInt("amountMin");
                    dropData.AmountMax = drop.ReadInt("amountMax");
                    dropData.Prefix    = drop.ReadInt("prefix");
                    dropData.Suffix    = drop.ReadInt("suffix");
                    dropData.Feature   = drop.ReadString("feature");

                    if (amount != 0)
                    {
                        dropData.AmountMin = dropData.AmountMax = amount;
                    }
                    if (dropData.AmountMin > dropData.AmountMax)
                    {
                        dropData.AmountMax = dropData.AmountMin;
                    }

                    if (dropData.Chance > 100)
                    {
                        dropData.Chance = 100;
                    }
                    else if (dropData.Chance < 0)
                    {
                        dropData.Chance = 0;
                    }

                    if (drop.ContainsKey("color1"))
                    {
                        dropData.Color1 = drop.ReadUInt("color1");
                    }
                    if (drop.ContainsKey("color2"))
                    {
                        dropData.Color2 = drop.ReadUInt("color2");
                    }
                    if (drop.ContainsKey("color3"))
                    {
                        dropData.Color3 = drop.ReadUInt("color3");
                    }

                    dropData.Durability = drop.ReadInt("durability", -1);

                    if (drop.ContainsKey("foodQuality"))
                    {
                        dropData.FoodQuality = drop.ReadInt("foodQuality");
                    }
                    if (drop.ContainsKey("formId"))
                    {
                        dropData.FormId = drop.ReadInt("formId");
                    }
                    if (drop.ContainsKey("scale"))
                    {
                        dropData.Scale = drop.ReadFloat("scale");
                    }
                    if (drop.ContainsKey("metaData1"))
                    {
                        dropData.MetaData1 = drop.ReadString("metaData1");
                    }
                    if (drop.ContainsKey("metaData2"))
                    {
                        dropData.MetaData2 = drop.ReadString("metaData2");
                    }

                    raceData.Drops.Add(dropData);
                }
            }

            // Skills
            if (entry.ContainsKeys("skills"))
            {
                foreach (JObject skill in entry["skills"].Where(a => a.Type == JTokenType.Object))
                {
                    skill.AssertNotMissing("skillId", "rank");

                    // Check feature
                    var feature = skill.ReadString("feature");
                    if (!string.IsNullOrWhiteSpace(feature) && !AuraData.FeaturesDb.IsEnabled(feature))
                    {
                        continue;
                    }

                    var skillData = new RaceSkillData();
                    skillData.SkillId = skill.ReadUShort("skillId");

                    var rank = skill.ReadString("rank");
                    if (rank == "N")
                    {
                        skillData.Rank = 0;
                    }
                    else
                    {
                        skillData.Rank = (byte)(16 - int.Parse(rank, NumberStyles.HexNumber));
                    }

                    raceData.Skills.Add(skillData);
                }
            }

            // Items
            if (entry.ContainsKeys("equip"))
            {
                foreach (JObject item in entry["equip"].Where(a => a.Type == JTokenType.Object))
                {
                    item.AssertNotMissing("itemId", "pocket");

                    var itemData = new RaceItemData();

                    // Item ids
                    if (item["itemId"].Type == JTokenType.Integer)
                    {
                        itemData.ItemIds.Add(item.ReadInt("itemId"));
                    }
                    else if (item["itemId"].Type == JTokenType.Array)
                    {
                        foreach (var id in item["itemId"])
                        {
                            itemData.ItemIds.Add((int)id);
                        }
                    }

                    // Check that we got ids
                    if (itemData.ItemIds.Count == 0)
                    {
                        throw new MandatoryValueException(null, "itemId", item);
                    }

                    // Color 1
                    if (item["color1"] != null)
                    {
                        if (item["color1"].Type == JTokenType.Integer)
                        {
                            itemData.Color1s.Add(item.ReadUInt("color1"));
                        }
                        else if (item["color1"].Type == JTokenType.Array)
                        {
                            foreach (var id in item["color1"])
                            {
                                itemData.Color1s.Add((uint)id);
                            }
                        }
                    }

                    // Color 2
                    if (item["color2"] != null)
                    {
                        if (item["color2"].Type == JTokenType.Integer)
                        {
                            itemData.Color2s.Add(item.ReadUInt("color2"));
                        }
                        else if (item["color2"].Type == JTokenType.Array)
                        {
                            foreach (var id in item["color2"])
                            {
                                itemData.Color2s.Add((uint)id);
                            }
                        }
                    }

                    // Color 3
                    if (item["color3"] != null)
                    {
                        if (item["color3"].Type == JTokenType.Integer)
                        {
                            itemData.Color3s.Add(item.ReadUInt("color3"));
                        }
                        else if (item["color3"].Type == JTokenType.Array)
                        {
                            foreach (var id in item["color3"])
                            {
                                itemData.Color3s.Add((uint)id);
                            }
                        }
                    }

                    // Pocket
                    itemData.Pocket = item.ReadInt("pocket");

                    raceData.Equip.Add(itemData);
                }
            }

            // Speed
            SpeedData actionInfo;

            if ((actionInfo = AuraData.SpeedDb.Find(raceData.Group + "/walk")) != null)
            {
                raceData.WalkingSpeed = actionInfo.Speed;
            }
            else if ((actionInfo = AuraData.SpeedDb.Find(raceData.Group + "/*")) != null)
            {
                raceData.WalkingSpeed = actionInfo.Speed;
            }
            else if ((actionInfo = AuraData.SpeedDb.Find(Regex.Replace(raceData.Group, "/.*$", "") + "/*/walk")) != null)
            {
                raceData.WalkingSpeed = actionInfo.Speed;
            }
            else if ((actionInfo = AuraData.SpeedDb.Find(Regex.Replace(raceData.Group, "/.*$", "") + "/*/*")) != null)
            {
                raceData.WalkingSpeed = actionInfo.Speed;
            }
            else
            {
                raceData.WalkingSpeed = 207.6892f;
            }

            if ((actionInfo = AuraData.SpeedDb.Find(raceData.Group + "/run")) != null)
            {
                raceData.RunningSpeed = actionInfo.Speed;
            }
            else if ((actionInfo = AuraData.SpeedDb.Find(raceData.Group + "/*")) != null)
            {
                raceData.RunningSpeed = actionInfo.Speed;
            }
            else if ((actionInfo = AuraData.SpeedDb.Find(Regex.Replace(raceData.Group, "/.*$", "") + "/*/run")) != null)
            {
                raceData.RunningSpeed = actionInfo.Speed;
            }
            else if ((actionInfo = AuraData.SpeedDb.Find(Regex.Replace(raceData.Group, "/.*$", "") + "/*/*")) != null)
            {
                raceData.RunningSpeed = actionInfo.Speed;
            }
            else
            {
                raceData.RunningSpeed = 373.850647f;
            }

            this.Entries[raceData.Id] = raceData;
        }
Exemple #2
0
        protected override void ReadEntry(JObject entry)
        {
            entry.AssertNotMissing("id", "name", "group", "tags", "gender", "vehicleType", "runSpeedFactor", "state", "invWidth", "invHeight", "attackMin", "attackMax", "range", "attackSpeed", "knockCount", "critical", "criticalRate", "splashRadius", "splashAngle", "splashDamage", "stand", "ai", "color1", "color2", "color3", "size", "cp", "life", "defense", "protection", "element");

            var raceData = new RaceData();

            raceData.Id              = entry.ReadInt("id");
            raceData.Name            = entry.ReadString("name");
            raceData.Group           = entry.ReadString("group");
            raceData.Tags            = entry.ReadString("tags");
            raceData.Gender          = (Gender)entry.ReadByte("gender");
            raceData.VehicleType     = entry.ReadInt("vehicleType");
            raceData.RunSpeedFactor  = entry.ReadFloat("runSpeedFactor");
            raceData.DefaultState    = entry.ReadUInt("state");
            raceData.InventoryWidth  = entry.ReadInt("invWidth");
            raceData.InventoryHeight = entry.ReadInt("invHeight");
            raceData.AttackSkill     = 23002;         // Combat Mastery, they all use this anyway.
            raceData.AttackMin       = entry.ReadInt("attackMin");
            raceData.AttackMax       = entry.ReadInt("attackMax");
            raceData.AttackRange     = entry.ReadInt("range");
            raceData.AttackSpeed     = entry.ReadInt("attackSpeed");
            raceData.KnockCount      = entry.ReadInt("knockCount");
            raceData.Critical        = entry.ReadInt("critical");
            raceData.CriticalRate    = entry.ReadInt("criticalRate");
            raceData.SplashRadius    = entry.ReadInt("splashRadius");
            raceData.SplashAngle     = entry.ReadInt("splashAngle");
            raceData.SplashDamage    = entry.ReadFloat("splashDamage");
            raceData.Stand           = (RaceStands)entry.ReadInt("stand");
            raceData.AI              = entry.ReadString("ai");

            // Looks
            raceData.Size   = entry.ReadFloat("size");
            raceData.Color1 = entry.ReadUInt("color1");
            raceData.Color2 = entry.ReadUInt("color2");
            raceData.Color3 = entry.ReadUInt("color3");

            // Face
            Action <string, JObject, List <int> > readArrOrIntCol = (col, obj, list) =>
            {
                if (obj[col] != null)
                {
                    if (obj[col].Type == JTokenType.Integer)
                    {
                        list.Add(obj.ReadInt(col));
                    }
                    else if (obj[col].Type == JTokenType.Array)
                    {
                        list.AddRange(obj[col].Select(id => (int)id));
                    }
                }
            };

            readArrOrIntCol("eyeColor", entry, raceData.Face.EyeColors);
            readArrOrIntCol("eyeType", entry, raceData.Face.EyeTypes);
            readArrOrIntCol("mouthType", entry, raceData.Face.MouthTypes);
            readArrOrIntCol("skinColor", entry, raceData.Face.SkinColors);

            // Stat Info
            raceData.CombatPower = entry.ReadFloat("cp");
            raceData.Life        = entry.ReadFloat("life");
            raceData.Defense     = entry.ReadInt("defense");
            raceData.Protection  = (int)entry.ReadFloat("protection");
            raceData.Element     = (Element)entry.ReadByte("element");
            raceData.Exp         = entry.ReadInt("exp");
            raceData.GoldMin     = entry.ReadInt("goldMin");
            raceData.GoldMax     = entry.ReadInt("goldMax");

            // Drops
            if (entry.ContainsKeys("drops"))
            {
                foreach (JObject drop in entry["drops"].Where(a => a.Type == JTokenType.Object))
                {
                    drop.AssertNotMissing("itemId", "chance");

                    var dropData = new DropData();
                    dropData.ItemId = drop.ReadInt("itemId");
                    dropData.Chance = drop.ReadFloat("chance");

                    dropData.Chance /= 100;
                    if (dropData.Chance > 1)
                    {
                        dropData.Chance = 1;
                    }
                    else if (dropData.Chance < 0)
                    {
                        dropData.Chance = 0;
                    }

                    raceData.Drops.Add(dropData);
                }
            }

            // Skills
            if (entry.ContainsKeys("skills"))
            {
                foreach (JObject skill in entry["skills"].Where(a => a.Type == JTokenType.Object))
                {
                    skill.AssertNotMissing("skillId", "rank");

                    var skillData = new RaceSkillData();
                    skillData.SkillId = skill.ReadUShort("skillId");

                    var rank = skill.ReadString("rank");
                    if (rank == "N")
                    {
                        skillData.Rank = 0;
                    }
                    else
                    {
                        skillData.Rank = (byte)(16 - int.Parse(rank, NumberStyles.HexNumber));
                    }

                    raceData.Skills.Add(skillData);
                }
            }

            // Items
            if (entry.ContainsKeys("equip"))
            {
                foreach (JObject item in entry["equip"].Where(a => a.Type == JTokenType.Object))
                {
                    item.AssertNotMissing("itemId", "pocket");

                    var itemData = new RaceItemData();

                    // Item ids
                    if (item["itemId"].Type == JTokenType.Integer)
                    {
                        itemData.ItemIds.Add(item.ReadInt("itemId"));
                    }
                    else if (item["itemId"].Type == JTokenType.Array)
                    {
                        foreach (var id in item["itemId"])
                        {
                            itemData.ItemIds.Add((int)id);
                        }
                    }

                    // Check that we got ids
                    if (itemData.ItemIds.Count == 0)
                    {
                        throw new MandatoryValueException(null, "itemId", item);
                    }

                    // Color 1
                    if (item["color1"] != null)
                    {
                        if (item["color1"].Type == JTokenType.Integer)
                        {
                            itemData.Color1s.Add(item.ReadUInt("color1"));
                        }
                        else if (item["color1"].Type == JTokenType.Array)
                        {
                            foreach (var id in item["color1"])
                            {
                                itemData.Color1s.Add((uint)id);
                            }
                        }
                    }

                    // Color 2
                    if (item["color2"] != null)
                    {
                        if (item["color2"].Type == JTokenType.Integer)
                        {
                            itemData.Color2s.Add(item.ReadUInt("color2"));
                        }
                        else if (item["color2"].Type == JTokenType.Array)
                        {
                            foreach (var id in item["color2"])
                            {
                                itemData.Color2s.Add((uint)id);
                            }
                        }
                    }

                    // Color 3
                    if (item["color3"] != null)
                    {
                        if (item["color3"].Type == JTokenType.Integer)
                        {
                            itemData.Color3s.Add(item.ReadUInt("color3"));
                        }
                        else if (item["color3"].Type == JTokenType.Array)
                        {
                            foreach (var id in item["color3"])
                            {
                                itemData.Color3s.Add((uint)id);
                            }
                        }
                    }

                    // Pocket
                    itemData.Pocket = item.ReadInt("pocket");

                    raceData.Equip.Add(itemData);
                }
            }

            // Speed
            SpeedData actionInfo;

            if ((actionInfo = AuraData.SpeedDb.Find(raceData.Group + "/walk")) != null)
            {
                raceData.WalkingSpeed = actionInfo.Speed;
            }
            else if ((actionInfo = AuraData.SpeedDb.Find(raceData.Group + "/*")) != null)
            {
                raceData.WalkingSpeed = actionInfo.Speed;
            }
            else if ((actionInfo = AuraData.SpeedDb.Find(Regex.Replace(raceData.Group, "/.*$", "") + "/*/walk")) != null)
            {
                raceData.WalkingSpeed = actionInfo.Speed;
            }
            else if ((actionInfo = AuraData.SpeedDb.Find(Regex.Replace(raceData.Group, "/.*$", "") + "/*/*")) != null)
            {
                raceData.WalkingSpeed = actionInfo.Speed;
            }
            else
            {
                raceData.WalkingSpeed = 207.6892f;
            }

            if ((actionInfo = AuraData.SpeedDb.Find(raceData.Group + "/run")) != null)
            {
                raceData.RunningSpeed = actionInfo.Speed;
            }
            else if ((actionInfo = AuraData.SpeedDb.Find(raceData.Group + "/*")) != null)
            {
                raceData.RunningSpeed = actionInfo.Speed;
            }
            else if ((actionInfo = AuraData.SpeedDb.Find(Regex.Replace(raceData.Group, "/.*$", "") + "/*/run")) != null)
            {
                raceData.RunningSpeed = actionInfo.Speed;
            }
            else if ((actionInfo = AuraData.SpeedDb.Find(Regex.Replace(raceData.Group, "/.*$", "") + "/*/*")) != null)
            {
                raceData.RunningSpeed = actionInfo.Speed;
            }
            else
            {
                raceData.RunningSpeed = 373.850647f;
            }

            this.Entries[raceData.Id] = raceData;
        }