Exemple #1
0
        public static MobMeta Parse(WZProperty info)
        {
            MobMeta result = new MobMeta();

            result.IsBodyAttack        = info.ResolveFor <bool>("bodyAttack");
            result.Level               = info.ResolveFor <int>("level");
            result.MaxHP               = info.ResolveFor <long>("maxHP");
            result.MaxMP               = info.ResolveFor <long>("maxMP");
            result.Speed               = info.ResolveFor <int>("speed");
            result.FlySpeed            = info.ResolveFor <int>("flySpeed");
            result.PhysicalDamage      = info.ResolveFor <int>("PADamage");
            result.PhysicalDefense     = info.ResolveFor <int>("PDDamage");
            result.PhysicalDefenseRate = info.ResolveFor <int>("PDRate");
            result.MagicDamage         = info.ResolveFor <int>("MADamage");
            result.MagicDefense        = info.ResolveFor <int>("MDDamage");
            result.MagicDefenseRate    = info.ResolveFor <int>("MDRate");
            result.Accuracy            = info.ResolveFor <int>("acc");
            result.Evasion             = info.ResolveFor <int>("eva");
            result.EXP                  = info.ResolveFor <long>("exp");
            result.IsUndead             = info.ResolveFor <bool>("undead");
            result.MinimumPushDamage    = info.ResolveFor <int>("pushed");
            result.HPRecovery           = info.ResolveFor <int>("hpRecovery");
            result.MPRecovery           = info.ResolveFor <int>("mpRecovery");
            result.ElementalAttributes  = info.ResolveForOrNull <string>("elemAttr");
            result.SummonType           = (SummonType)(info.ResolveFor <int>("summonType") ?? 1);
            result.HPTagColor           = info.ResolveFor <int>("hpTagColor");
            result.HPTagBackgroundColor = info.ResolveFor <int>("hpTagBgcolor");
            result.HPGaugeHide          = info.ResolveFor <bool>("HPgaugeHide");
            result.NoRespawn            = info.ResolveFor <bool>("noRegen");
            result.RevivesMonsterId     = info.Resolve("revive")?.Children?.Select(c => Convert.ToInt32(((IWZPropertyVal)c).GetValue())).Select(c => MobInfo.GetFromId(info, c)).Where(c => c != null);
            result.LinksToOtherMob      = info.ResolveFor <int>("link");
            result.OnlyNormalAttack     = info.ResolveFor <bool>("onlyNormalAttack");
            result.FixedDamageAmount    = info.ResolveFor <uint>("fixedDamage");
            result.IsBoss               = info.ResolveFor <bool>("boss");
            result.IsAutoAggro          = info.ResolveFor <bool>("firstAttack");
            result.PublicReward         = info.ResolveFor <bool>("publicReward");
            result.ExplosiveReward      = info.ResolveFor <bool>("explosiveReward");
            result.IsInvincible         = info.ResolveFor <bool>("invincible");
            result.NoAttack             = info.ResolveFor <bool>("notAttack");
            result.RemoveAfterTime      = info.ResolveFor <int>("removeAfter");
            result.BuffId               = info.ResolveFor <uint>("buff");
            result.HideName             = info.ResolveFor <bool>("hideName");
            result.MonsterBookId        = info.ResolveFor <uint>("mbookID");

            return(result);
        }
Exemple #2
0
        public static Mob Parse(WZProperty stringWz, bool followLink = true)
        {
            int id;

            if (!int.TryParse(stringWz.NameWithoutExtension, out id))
            {
                return(null);
            }

            Mob result = new Mob();

            result.Id = id;

            result.mobImage = stringWz.ResolveOutlink($"Mob/{id.ToString("D7")}") ?? stringWz.ResolveOutlink($"Mob2/{id.ToString("D7")}");

            result.Name    = stringWz.ResolveForOrNull <string>("name");
            result.Meta    = result.mobImage.Children.Any(c => c.NameWithoutExtension.Equals("info")) ? MobMeta.Parse(result.mobImage.Resolve("info")) : null;
            result.LinksTo = result.Meta.LinksToOtherMob;

            result.Framebooks = result.mobImage.Children
                                .Where(c => c.NameWithoutExtension != "info")
                                .DistinctBy(c => c.NameWithoutExtension)
                                .ToDictionary(c => c.NameWithoutExtension, c => FrameBook.GetFrameCount(c));

            WZProperty familiarEntry = stringWz.ResolveOutlink($"String/MonsterBook/{id}");

            result.Description = familiarEntry?.ResolveForOrNull <string>("episode");

            ILookup <int, MapName> lookup = MapName.GetMapNameLookup(stringWz);

            result.FoundAt = stringWz.ResolveOutlink($"Etc/MobLocation/{id}")?
                             .Children.Concat(familiarEntry?.Resolve("map")?.Children ?? (new Dictionary <string, WZProperty>()).Values)
                             .Select(c => c.ResolveFor <int>() ?? -1).Distinct()
                             .Select(c => lookup[c]?.FirstOrDefault() ?? new MapName()
            {
                Name = "Unknown", StreetName = "Unknown", Id = c
            })
                             .ToArray();

            ILookup <int, ItemNameInfo> reportedDrops = ItemNameInfo.GetNameLookup(stringWz.ResolveOutlink("String"));

            result.Drops = familiarEntry?.Resolve("reward")?.Children
                           .Select(c => c.ResolveFor <int>() ?? -1)
                           .Select(c => reportedDrops[c]?.FirstOrDefault())
                           .Where(c => c != null)
                           .ToArray();

            List <int> linkFollowed = new List <int>();
            Mob        linked       = result;

            while (followLink && linked.Meta.LinksToOtherMob.HasValue && !linkFollowed.Contains(linked.Meta.LinksToOtherMob.Value))
            {
                linkFollowed.Add(linked.Meta.LinksToOtherMob.Value);
                linked = Parse(stringWz.ResolveOutlink($"String/Mob/{linked.Meta.LinksToOtherMob.Value}"), false);
            }

            if (linked != result)
            {
                result.Extend(linked);
            }

            return(result);
        }